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>2023-02-20 16:49:51 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-02-20 16:49:51 +0300
commit71786ddc8e28fbd3cb3fcc4b3ff15e5962a1c82e (patch)
tree6a2d93ef3fb2d353bb7739e4b57e6541f51cdd71 /spec/services/import
parenta7253423e3403b8c08f8a161e5937e1488f5f407 (diff)
Add latest changes from gitlab-org/gitlab@15-9-stable-eev15.9.0-rc42
Diffstat (limited to 'spec/services/import')
-rw-r--r--spec/services/import/gitlab_projects/file_acquisition_strategies/remote_file_spec.rb86
1 files changed, 22 insertions, 64 deletions
diff --git a/spec/services/import/gitlab_projects/file_acquisition_strategies/remote_file_spec.rb b/spec/services/import/gitlab_projects/file_acquisition_strategies/remote_file_spec.rb
index 8565299b9b7..a28a552746f 100644
--- a/spec/services/import/gitlab_projects/file_acquisition_strategies/remote_file_spec.rb
+++ b/spec/services/import/gitlab_projects/file_acquisition_strategies/remote_file_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe ::Import::GitlabProjects::FileAcquisitionStrategies::RemoteFile, :aggregate_failures do
+RSpec.describe ::Import::GitlabProjects::FileAcquisitionStrategies::RemoteFile, :aggregate_failures, feature_category: :importers do
let(:remote_url) { 'https://external.file.path/file.tar.gz' }
let(:params) { { remote_import_url: remote_url } }
@@ -40,23 +40,19 @@ RSpec.describe ::Import::GitlabProjects::FileAcquisitionStrategies::RemoteFile,
end
end
- context 'when import_project_from_remote_file_s3 is enabled' do
- before do
- stub_feature_flags(import_project_from_remote_file_s3: true)
- end
-
- context 'when the HTTP request fail to recover the headers' do
- it 'adds the error message' do
- expect(Gitlab::HTTP)
- .to receive(:head)
- .and_raise(StandardError, 'request invalid')
+ context 'when the HTTP request fails to recover the headers' do
+ it 'adds the error message' do
+ expect(Gitlab::HTTP)
+ .to receive(:head)
+ .and_raise(StandardError, 'request invalid')
- expect(subject).not_to be_valid
- expect(subject.errors.full_messages)
- .to include('Failed to retrive headers: request invalid')
- end
+ expect(subject).not_to be_valid
+ expect(subject.errors.full_messages)
+ .to include('Failed to retrive headers: request invalid')
end
+ end
+ context 'when request is not from an S3 server' do
it 'validates the remote content-length' do
stub_headers_for(remote_url, { 'content-length' => 11.gigabytes })
@@ -72,57 +68,19 @@ RSpec.describe ::Import::GitlabProjects::FileAcquisitionStrategies::RemoteFile,
expect(subject.errors.full_messages)
.to include("Content type 'unknown' not allowed. (Allowed: application/gzip, application/x-tar, application/x-gzip)")
end
-
- context 'when trying to import from AWS S3' do
- it 'adds an error suggesting to use `projects/remote-import-s3`' do
- stub_headers_for(
- remote_url,
- 'Server' => 'AmazonS3',
- 'x-amz-request-id' => 'some-id'
- )
-
- expect(subject).not_to be_valid
- expect(subject.errors.full_messages)
- .to include('To import from AWS S3 use `projects/remote-import-s3`')
- end
- end
end
- context 'when import_project_from_remote_file_s3 is disabled' do
- before do
- stub_feature_flags(import_project_from_remote_file_s3: false)
- end
-
- context 'when trying to import from AWS S3' do
- it 'does not validate the remote content-length or content-type' do
- stub_headers_for(
- remote_url,
- 'Server' => 'AmazonS3',
- 'x-amz-request-id' => 'some-id',
- 'content-length' => 11.gigabytes,
- 'content-type' => 'unknown'
- )
-
- expect(subject).to be_valid
- end
- end
-
- context 'when NOT trying to import from AWS S3' do
- it 'validates content-length and content-type' do
- stub_headers_for(
- remote_url,
- 'Server' => 'NOT AWS S3',
- 'content-length' => 11.gigabytes,
- 'content-type' => 'unknown'
- )
-
- expect(subject).not_to be_valid
-
- expect(subject.errors.full_messages)
- .to include("Content type 'unknown' not allowed. (Allowed: application/gzip, application/x-tar, application/x-gzip)")
- expect(subject.errors.full_messages)
- .to include('Content length is too big (should be at most 10 GB)')
- end
+ context 'when request is from an S3 server' do
+ it 'does not validate the remote content-length or content-type' do
+ stub_headers_for(
+ remote_url,
+ 'Server' => 'AmazonS3',
+ 'x-amz-request-id' => 'some-id',
+ 'content-length' => 11.gigabytes,
+ 'content-type' => 'unknown'
+ )
+
+ expect(subject).to be_valid
end
end
end