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?
|
headers['Vary'] << ', Authorization' unless public?
|
||||||
true
|
true
|
||||||
elsif env['travis.access_token']
|
elsif env['travis.access_token']
|
||||||
halt 403, "insufficient access"
|
pass { halt 403, "insufficient access" }
|
||||||
else
|
else
|
||||||
halt 401, "no access token supplied"
|
pass { halt 401, "no access token supplied" }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -8,6 +8,8 @@ describe Travis::Api::App::Extensions::Scoping do
|
||||||
register Travis::Api::App::Extensions::Scoping
|
register Travis::Api::App::Extensions::Scoping
|
||||||
get('/') { 'ok' }
|
get('/') { 'ok' }
|
||||||
get('/private', scope: :private) { 'ok' }
|
get('/private', scope: :private) { 'ok' }
|
||||||
|
get('/pass_me', scope: :private) { 'first' }
|
||||||
|
get('/pass_me') { 'second' }
|
||||||
end
|
end
|
||||||
|
|
||||||
User.stubs(:find).with(user.id).returns(user)
|
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-Accepted-OAuth-Scopes'].should == 'private'
|
||||||
headers['X-OAuth-Scopes'].should == 'foo,bar'
|
headers['X-OAuth-Scopes'].should == 'foo,bar'
|
||||||
end
|
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
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user