diff options
author | Francisco Lopez <fjlopez@gitlab.com> | 2017-11-16 15:39:30 +0100 |
---|---|---|
committer | Francisco Lopez <fjlopez@gitlab.com> | 2017-11-17 10:02:11 +0100 |
commit | aa84ef1e1af0bac40279e02e4ce889cb660ed9d0 (patch) | |
tree | 3fe0bd2c53236abd49f017c7711decd1980900b5 /spec/lib/gitlab/auth | |
parent | 98f7982ceccd6f7996774911632943e9f43df6e3 (diff) | |
download | gitlab-ce-aa84ef1e1af0bac40279e02e4ce889cb660ed9d0.tar.gz |
Moving exceptions to UserAuthFinders
Diffstat (limited to 'spec/lib/gitlab/auth')
-rw-r--r-- | spec/lib/gitlab/auth/request_authenticator_spec.rb | 4 | ||||
-rw-r--r-- | spec/lib/gitlab/auth/user_auth_finders_spec.rb | 20 |
2 files changed, 12 insertions, 12 deletions
diff --git a/spec/lib/gitlab/auth/request_authenticator_spec.rb b/spec/lib/gitlab/auth/request_authenticator_spec.rb index 4ddebed119f..6b8a8759314 100644 --- a/spec/lib/gitlab/auth/request_authenticator_spec.rb +++ b/spec/lib/gitlab/auth/request_authenticator_spec.rb @@ -33,7 +33,7 @@ describe Gitlab::Auth::RequestAuthenticator do end it 'bubbles up exceptions' do - allow_any_instance_of(described_class).to receive(:find_user_from_warden).and_raise(API::APIGuard::UnauthorizedError) + allow_any_instance_of(described_class).to receive(:find_user_from_warden).and_raise(Gitlab::Auth::UserAuthFinders::UnauthorizedError) end end @@ -59,7 +59,7 @@ describe Gitlab::Auth::RequestAuthenticator do end it 'rescue API::APIGuard::AuthenticationException exceptions' do - allow_any_instance_of(described_class).to receive(:find_user_from_access_token).and_raise(API::APIGuard::UnauthorizedError) + allow_any_instance_of(described_class).to receive(:find_user_from_access_token).and_raise(Gitlab::Auth::UserAuthFinders::UnauthorizedError) expect(subject.find_sessionless_user).to be_blank end diff --git a/spec/lib/gitlab/auth/user_auth_finders_spec.rb b/spec/lib/gitlab/auth/user_auth_finders_spec.rb index 1b3bc2fc65c..522e82c5912 100644 --- a/spec/lib/gitlab/auth/user_auth_finders_spec.rb +++ b/spec/lib/gitlab/auth/user_auth_finders_spec.rb @@ -65,7 +65,7 @@ describe Gitlab::Auth::UserAuthFinders do it 'returns exception if invalid rss_token' do set_param(:rss_token, 'invalid_token') - expect { find_user_from_rss_token }.to raise_error(API::APIGuard::UnauthorizedError) + expect { find_user_from_rss_token }.to raise_error(Gitlab::Auth::UserAuthFinders::UnauthorizedError) end end @@ -96,7 +96,7 @@ describe Gitlab::Auth::UserAuthFinders do env[Gitlab::Auth::UserAuthFinders::PRIVATE_TOKEN_HEADER] = personal_access_token.token allow_any_instance_of(PersonalAccessToken).to receive(:user).and_return(nil) - expect { find_user_from_access_token }.to raise_error(API::APIGuard::UnauthorizedError) + expect { find_user_from_access_token }.to raise_error(Gitlab::Auth::UserAuthFinders::UnauthorizedError) end end end @@ -127,7 +127,7 @@ describe Gitlab::Auth::UserAuthFinders do it 'returns exception if invalid personal_access_token' do env[Gitlab::Auth::UserAuthFinders::PRIVATE_TOKEN_HEADER] = 'invalid_token' - expect { find_personal_access_token }.to raise_error(API::APIGuard::UnauthorizedError) + expect { find_personal_access_token }.to raise_error(Gitlab::Auth::UserAuthFinders::UnauthorizedError) end end @@ -158,7 +158,7 @@ describe Gitlab::Auth::UserAuthFinders do it 'returns exception if invalid oauth_access_token' do env['HTTP_AUTHORIZATION'] = "Bearer invalid_token" - expect { find_oauth_access_token }.to raise_error(API::APIGuard::UnauthorizedError) + expect { find_oauth_access_token }.to raise_error(Gitlab::Auth::UserAuthFinders::UnauthorizedError) end end @@ -174,20 +174,20 @@ describe Gitlab::Auth::UserAuthFinders do allow_any_instance_of(described_class).to receive(:access_token).and_return(personal_access_token) end - it 'returns API::APIGuard::ExpiredError if token expired' do + it 'returns Gitlab::Auth::UserAuthFinders::ExpiredError if token expired' do personal_access_token.expires_at = 1.day.ago - expect { validate_access_token! }.to raise_error(API::APIGuard::ExpiredError) + expect { validate_access_token! }.to raise_error(Gitlab::Auth::UserAuthFinders::ExpiredError) end - it 'returns API::APIGuard::RevokedError if token revoked' do + it 'returns Gitlab::Auth::UserAuthFinders::RevokedError if token revoked' do personal_access_token.revoke! - expect { validate_access_token! }.to raise_error(API::APIGuard::RevokedError) + expect { validate_access_token! }.to raise_error(Gitlab::Auth::UserAuthFinders::RevokedError) end - it 'returns API::APIGuard::InsufficientScopeError if invalid token scope' do - expect { validate_access_token!(scopes: [:sudo]) }.to raise_error(API::APIGuard::InsufficientScopeError) + it 'returns Gitlab::Auth::UserAuthFinders::InsufficientScopeError if invalid token scope' do + expect { validate_access_token!(scopes: [:sudo]) }.to raise_error(Gitlab::Auth::UserAuthFinders::InsufficientScopeError) end end end |