summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorFrancisco Lopez <fjlopez@gitlab.com>2017-11-16 17:03:19 +0100
committerFrancisco Lopez <fjlopez@gitlab.com>2017-11-17 10:02:11 +0100
commit1436598e49792b78f5f753477a9d8c097d666b99 (patch)
tree2c025f10d38aaa27d850092633933838e37ad8f5 /spec
parentaa84ef1e1af0bac40279e02e4ce889cb660ed9d0 (diff)
downloadgitlab-ce-1436598e49792b78f5f753477a9d8c097d666b99.tar.gz
Moved Exceptions to Gitlab::Auth
Diffstat (limited to 'spec')
-rw-r--r--spec/lib/gitlab/auth/request_authenticator_spec.rb4
-rw-r--r--spec/lib/gitlab/auth/user_auth_finders_spec.rb20
-rw-r--r--spec/requests/api/helpers_spec.rb8
3 files changed, 16 insertions, 16 deletions
diff --git a/spec/lib/gitlab/auth/request_authenticator_spec.rb b/spec/lib/gitlab/auth/request_authenticator_spec.rb
index 6b8a8759314..b7348f5cd78 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(Gitlab::Auth::UserAuthFinders::UnauthorizedError)
+ allow_any_instance_of(described_class).to receive(:find_user_from_warden).and_raise(Gitlab::Auth::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(Gitlab::Auth::UserAuthFinders::UnauthorizedError)
+ allow_any_instance_of(described_class).to receive(:find_user_from_access_token).and_raise(Gitlab::Auth::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 522e82c5912..4637816570c 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(Gitlab::Auth::UserAuthFinders::UnauthorizedError)
+ expect { find_user_from_rss_token }.to raise_error(Gitlab::Auth::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(Gitlab::Auth::UserAuthFinders::UnauthorizedError)
+ expect { find_user_from_access_token }.to raise_error(Gitlab::Auth::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(Gitlab::Auth::UserAuthFinders::UnauthorizedError)
+ expect { find_personal_access_token }.to raise_error(Gitlab::Auth::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(Gitlab::Auth::UserAuthFinders::UnauthorizedError)
+ expect { find_oauth_access_token }.to raise_error(Gitlab::Auth::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 Gitlab::Auth::UserAuthFinders::ExpiredError if token expired' do
+ it 'returns Gitlab::Auth::ExpiredError if token expired' do
personal_access_token.expires_at = 1.day.ago
- expect { validate_access_token! }.to raise_error(Gitlab::Auth::UserAuthFinders::ExpiredError)
+ expect { validate_access_token! }.to raise_error(Gitlab::Auth::ExpiredError)
end
- it 'returns Gitlab::Auth::UserAuthFinders::RevokedError if token revoked' do
+ it 'returns Gitlab::Auth::RevokedError if token revoked' do
personal_access_token.revoke!
- expect { validate_access_token! }.to raise_error(Gitlab::Auth::UserAuthFinders::RevokedError)
+ expect { validate_access_token! }.to raise_error(Gitlab::Auth::RevokedError)
end
- it 'returns Gitlab::Auth::UserAuthFinders::InsufficientScopeError if invalid token scope' do
- expect { validate_access_token!(scopes: [:sudo]) }.to raise_error(Gitlab::Auth::UserAuthFinders::InsufficientScopeError)
+ it 'returns Gitlab::Auth::InsufficientScopeError if invalid token scope' do
+ expect { validate_access_token!(scopes: [:sudo]) }.to raise_error(Gitlab::Auth::InsufficientScopeError)
end
end
end
diff --git a/spec/requests/api/helpers_spec.rb b/spec/requests/api/helpers_spec.rb
index 919df575c6e..0462f494e15 100644
--- a/spec/requests/api/helpers_spec.rb
+++ b/spec/requests/api/helpers_spec.rb
@@ -166,21 +166,21 @@ describe API::Helpers do
personal_access_token = create(:personal_access_token, user: user, scopes: ['read_user'])
env[Gitlab::Auth::UserAuthFinders::PRIVATE_TOKEN_HEADER] = personal_access_token.token
- expect { current_user }.to raise_error Gitlab::Auth::UserAuthFinders::InsufficientScopeError
+ expect { current_user }.to raise_error Gitlab::Auth::InsufficientScopeError
end
it 'does not allow revoked tokens' do
personal_access_token.revoke!
env[Gitlab::Auth::UserAuthFinders::PRIVATE_TOKEN_HEADER] = personal_access_token.token
- expect { current_user }.to raise_error Gitlab::Auth::UserAuthFinders::RevokedError
+ expect { current_user }.to raise_error Gitlab::Auth::RevokedError
end
it 'does not allow expired tokens' do
personal_access_token.update_attributes!(expires_at: 1.day.ago)
env[Gitlab::Auth::UserAuthFinders::PRIVATE_TOKEN_HEADER] = personal_access_token.token
- expect { current_user }.to raise_error Gitlab::Auth::UserAuthFinders::ExpiredError
+ expect { current_user }.to raise_error Gitlab::Auth::ExpiredError
end
end
end
@@ -392,7 +392,7 @@ describe API::Helpers do
end
it 'raises an error' do
- expect { current_user }.to raise_error Gitlab::Auth::UserAuthFinders::InsufficientScopeError
+ expect { current_user }.to raise_error Gitlab::Auth::InsufficientScopeError
end
end
end