Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-04-27 11:57:43 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-04-27 11:57:43 +0300
commitbc299f54e841488b4ab37777761db1dfc7f3b60e (patch)
treebf58693acb03633a63138874072e3d3af3ee9f76 /spec/services
parent2fad41087674984a064cf6a312ac34c16bb2a1aa (diff)
Add latest changes from gitlab-org/security/gitlab@13-11-stable-ee
Diffstat (limited to 'spec/services')
-rw-r--r--spec/services/auth/dependency_proxy_authentication_service_spec.rb25
-rw-r--r--spec/services/projects/download_service_spec.rb5
2 files changed, 17 insertions, 13 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
diff --git a/spec/services/projects/download_service_spec.rb b/spec/services/projects/download_service_spec.rb
index 0f743eaa7f5..7d4fce814f5 100644
--- a/spec/services/projects/download_service_spec.rb
+++ b/spec/services/projects/download_service_spec.rb
@@ -20,8 +20,9 @@ RSpec.describe Projects::DownloadService do
context 'for URLs that are on the whitelist' do
before do
- stub_request(:get, 'http://mycompany.fogbugz.com/rails_sample.jpg').to_return(body: File.read(Rails.root + 'spec/fixtures/rails_sample.jpg'))
- stub_request(:get, 'http://mycompany.fogbugz.com/doc_sample.txt').to_return(body: File.read(Rails.root + 'spec/fixtures/doc_sample.txt'))
+ # `ssrf_filter` resolves the hostname. See https://github.com/carrierwaveuploader/carrierwave/commit/91714adda998bc9e8decf5b1f5d260d808761304
+ stub_request(:get, %r{http://[\d\.]+/rails_sample.jpg}).to_return(body: File.read(Rails.root + 'spec/fixtures/rails_sample.jpg'))
+ stub_request(:get, %r{http://[\d\.]+/doc_sample.txt}).to_return(body: File.read(Rails.root + 'spec/fixtures/doc_sample.txt'))
end
context 'an image file' do