Fix scopes and access token specs

This commit is contained in:
Piotr Sarnacki 2013-05-08 13:21:22 +02:00
parent 3b299cfec7
commit cdabec540d
2 changed files with 6 additions and 6 deletions

View File

@ -5,7 +5,7 @@ describe 'App' do
FactoryGirl.create(:test, :number => '3.1', :queue => 'builds.common')
add_endpoint '/foo' do
get '/hash', scope: [:foo, :bar] do
get '/:id/bar', scope: [:foo, :bar] do
respond_with foo: 'bar'
end
@ -18,20 +18,20 @@ describe 'App' do
it 'checks if token has one of the required scopes' do
token = Travis::Api::App::AccessToken.new(app_id: 1, user_id: 2, scopes: [:foo]).tap(&:save)
response = get '/foo/hash', {}, 'HTTP_ACCEPT' => 'application/json', 'HTTP_AUTHORIZATION' => "token #{token.token}"
response = get '/foo/1/bar', {}, 'HTTP_ACCEPT' => 'application/json; version=2', 'HTTP_AUTHORIZATION' => "token #{token.token}"
response.should be_successful
response.headers['X-Accepted-OAuth-Scopes'].should == 'foo'
token = Travis::Api::App::AccessToken.new(app_id: 1, user_id: 2, scopes: [:bar]).tap(&:save)
response = get '/foo/hash', {}, 'HTTP_ACCEPT' => 'application/json', 'HTTP_AUTHORIZATION' => "token #{token.token}"
response = get '/foo/1/bar', {}, 'HTTP_ACCEPT' => 'application/json; version=2', 'HTTP_AUTHORIZATION' => "token #{token.token}"
response.should be_successful
response.headers['X-Accepted-OAuth-Scopes'].should == 'bar'
token = Travis::Api::App::AccessToken.new(app_id: 1, user_id: 2, scopes: [:baz]).tap(&:save)
response = get '/foo/hash', {}, 'HTTP_ACCEPT' => 'application/json', 'HTTP_AUTHORIZATION' => "token #{token.token}"
response.status.should == 403
response = get '/foo/1/bar', {}, 'HTTP_ACCEPT' => 'application/json; version=2', 'HTTP_AUTHORIZATION' => "token #{token.token}"
response.status.should == 404
end
it 'checks if required_params match the from the request' do

View File

@ -25,7 +25,7 @@ describe Travis::Api::App::AccessToken do
described_class.find_by_token(token.token).should_not be_nil
sleep 1.5
sleep 2
described_class.find_by_token(token.token).should be_nil
end