pass if scope does not match
This commit is contained in:
parent
cc2a1cd50e
commit
01fe983a0c
|
@ -31,9 +31,9 @@ class Travis::Api::App
|
|||
headers['Vary'] << ', Authorization' unless public?
|
||||
true
|
||||
elsif env['travis.access_token']
|
||||
halt 403, "insufficient access"
|
||||
pass { halt 403, "insufficient access" }
|
||||
else
|
||||
halt 401, "no access token supplied"
|
||||
pass { halt 401, "no access token supplied" }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -8,6 +8,8 @@ describe Travis::Api::App::Extensions::Scoping do
|
|||
register Travis::Api::App::Extensions::Scoping
|
||||
get('/') { 'ok' }
|
||||
get('/private', scope: :private) { 'ok' }
|
||||
get('/pass_me', scope: :private) { 'first' }
|
||||
get('/pass_me') { 'second' }
|
||||
end
|
||||
|
||||
User.stubs(:find).with(user.id).returns(user)
|
||||
|
@ -62,4 +64,15 @@ describe Travis::Api::App::Extensions::Scoping do
|
|||
headers['X-Accepted-OAuth-Scopes'].should == 'private'
|
||||
headers['X-OAuth-Scopes'].should == 'foo,bar'
|
||||
end
|
||||
|
||||
it 'passes on to unscoped routes' do
|
||||
get('/pass_me').should be_ok
|
||||
body.should == 'second'
|
||||
end
|
||||
|
||||
|
||||
it 'does not pass if scope matches' do
|
||||
with_scopes('/pass_me', :private).should be_ok
|
||||
body.should == 'first'
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue
Block a user