summaryrefslogtreecommitdiff
path: root/spec/services/auth/dependency_proxy_authentication_service_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/services/auth/dependency_proxy_authentication_service_spec.rb')
-rw-r--r--spec/services/auth/dependency_proxy_authentication_service_spec.rb25
1 files changed, 14 insertions, 11 deletions
diff --git a/spec/services/auth/dependency_proxy_authentication_service_spec.rb b/spec/services/auth/dependency_proxy_authentication_service_spec.rb
index ba50149f53a..1fd1677c7da 100644
--- a/spec/services/auth/dependency_proxy_authentication_service_spec.rb
+++ b/spec/services/auth/dependency_proxy_authentication_service_spec.rb
@@ -13,28 +13,31 @@ RSpec.describe Auth::DependencyProxyAuthenticationService do
describe '#execute' do
subject { service.execute(authentication_abilities: nil) }
+ shared_examples 'returning' do |status:, message:|
+ it "returns #{message}", :aggregate_failures do
+ expect(subject[:http_status]).to eq(status)
+ expect(subject[:message]).to eq(message)
+ end
+ end
+
context 'dependency proxy is not enabled' do
before do
stub_config(dependency_proxy: { enabled: false })
end
- it 'returns not found' do
- result = subject
-
- expect(result[:http_status]).to eq(404)
- expect(result[:message]).to eq('dependency proxy not enabled')
- end
+ it_behaves_like 'returning', status: 404, message: 'dependency proxy not enabled'
end
context 'without a user' do
let(:user) { nil }
- it 'returns forbidden' do
- result = subject
+ it_behaves_like 'returning', status: 403, message: 'access forbidden'
+ end
+
+ context 'with a deploy token as user' do
+ let_it_be(:user) { create(:deploy_token) }
- expect(result[:http_status]).to eq(403)
- expect(result[:message]).to eq('access forbidden')
- end
+ it_behaves_like 'returning', status: 403, message: 'access forbidden'
end
context 'with a user' do