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:
Diffstat (limited to 'spec/lib/bulk_imports')
-rw-r--r--spec/lib/bulk_imports/common/pipelines/lfs_objects_pipeline_spec.rb15
-rw-r--r--spec/lib/bulk_imports/common/pipelines/uploads_pipeline_spec.rb14
-rw-r--r--spec/lib/bulk_imports/projects/pipelines/design_bundle_pipeline_spec.rb19
-rw-r--r--spec/lib/bulk_imports/projects/pipelines/repository_bundle_pipeline_spec.rb19
4 files changed, 56 insertions, 11 deletions
diff --git a/spec/lib/bulk_imports/common/pipelines/lfs_objects_pipeline_spec.rb b/spec/lib/bulk_imports/common/pipelines/lfs_objects_pipeline_spec.rb
index 297ac0ca0ba..50640e1e4ba 100644
--- a/spec/lib/bulk_imports/common/pipelines/lfs_objects_pipeline_spec.rb
+++ b/spec/lib/bulk_imports/common/pipelines/lfs_objects_pipeline_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe BulkImports::Common::Pipelines::LfsObjectsPipeline do
+RSpec.describe BulkImports::Common::Pipelines::LfsObjectsPipeline, feature_category: :importers do
let_it_be(:portable) { create(:project) }
let_it_be(:oid) { 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855' }
@@ -118,13 +118,22 @@ RSpec.describe BulkImports::Common::Pipelines::LfsObjectsPipeline do
context 'when file path is symlink' do
it 'returns' do
symlink = File.join(tmpdir, 'symlink')
+ FileUtils.ln_s(lfs_file_path, symlink)
- FileUtils.ln_s(File.join(tmpdir, lfs_file_path), symlink)
-
+ expect(Gitlab::Utils::FileInfo).to receive(:linked?).with(symlink).and_call_original
expect { pipeline.load(context, symlink) }.not_to change { portable.lfs_objects.count }
end
end
+ context 'when file path shares multiple hard links' do
+ it 'returns' do
+ FileUtils.link(lfs_file_path, File.join(tmpdir, 'hard_link'))
+
+ expect(Gitlab::Utils::FileInfo).to receive(:linked?).with(lfs_file_path).and_call_original
+ expect { pipeline.load(context, lfs_file_path) }.not_to change { portable.lfs_objects.count }
+ end
+ end
+
context 'when path is a directory' do
it 'returns' do
expect { pipeline.load(context, Dir.tmpdir) }.not_to change { portable.lfs_objects.count }
diff --git a/spec/lib/bulk_imports/common/pipelines/uploads_pipeline_spec.rb b/spec/lib/bulk_imports/common/pipelines/uploads_pipeline_spec.rb
index bc6d36452b4..09c8c7b92c2 100644
--- a/spec/lib/bulk_imports/common/pipelines/uploads_pipeline_spec.rb
+++ b/spec/lib/bulk_imports/common/pipelines/uploads_pipeline_spec.rb
@@ -105,6 +105,7 @@ RSpec.describe BulkImports::Common::Pipelines::UploadsPipeline, feature_category
it 'returns' do
path = File.join(tmpdir, 'test')
FileUtils.touch(path)
+
expect { pipeline.load(context, path) }.not_to change { portable.uploads.count }
end
end
@@ -118,13 +119,22 @@ RSpec.describe BulkImports::Common::Pipelines::UploadsPipeline, feature_category
context 'when path is a symlink' do
it 'does not upload the file' do
symlink = File.join(tmpdir, 'symlink')
+ FileUtils.ln_s(upload_file_path, symlink)
- FileUtils.ln_s(File.join(tmpdir, upload_file_path), symlink)
-
+ expect(Gitlab::Utils::FileInfo).to receive(:linked?).with(symlink).and_call_original
expect { pipeline.load(context, symlink) }.not_to change { portable.uploads.count }
end
end
+ context 'when path has multiple hard links' do
+ it 'does not upload the file' do
+ FileUtils.link(upload_file_path, File.join(tmpdir, 'hard_link'))
+
+ expect(Gitlab::Utils::FileInfo).to receive(:linked?).with(upload_file_path).and_call_original
+ expect { pipeline.load(context, upload_file_path) }.not_to change { portable.uploads.count }
+ end
+ end
+
context 'when path traverses' do
it 'does not upload the file' do
path_traversal = "#{uploads_dir_path}/avatar/../../../../etc/passwd"
diff --git a/spec/lib/bulk_imports/projects/pipelines/design_bundle_pipeline_spec.rb b/spec/lib/bulk_imports/projects/pipelines/design_bundle_pipeline_spec.rb
index 5b7309b09f5..87efad92131 100644
--- a/spec/lib/bulk_imports/projects/pipelines/design_bundle_pipeline_spec.rb
+++ b/spec/lib/bulk_imports/projects/pipelines/design_bundle_pipeline_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe BulkImports::Projects::Pipelines::DesignBundlePipeline do
+RSpec.describe BulkImports::Projects::Pipelines::DesignBundlePipeline, feature_category: :importers do
let_it_be(:design) { create(:design, :with_file) }
let(:portable) { create(:project) }
@@ -125,9 +125,9 @@ RSpec.describe BulkImports::Projects::Pipelines::DesignBundlePipeline do
context 'when path is symlink' do
it 'returns' do
symlink = File.join(tmpdir, 'symlink')
+ FileUtils.ln_s(design_bundle_path, symlink)
- FileUtils.ln_s(File.join(tmpdir, design_bundle_path), symlink)
-
+ expect(Gitlab::Utils::FileInfo).to receive(:linked?).with(symlink).and_call_original
expect(portable.design_repository).not_to receive(:create_from_bundle)
pipeline.load(context, symlink)
@@ -136,6 +136,19 @@ RSpec.describe BulkImports::Projects::Pipelines::DesignBundlePipeline do
end
end
+ context 'when path has multiple hard links' do
+ it 'returns' do
+ FileUtils.link(design_bundle_path, File.join(tmpdir, 'hard_link'))
+
+ expect(Gitlab::Utils::FileInfo).to receive(:linked?).with(design_bundle_path).and_call_original
+ expect(portable.design_repository).not_to receive(:create_from_bundle)
+
+ pipeline.load(context, design_bundle_path)
+
+ expect(portable.design_repository.exists?).to eq(false)
+ end
+ end
+
context 'when path is not under tmpdir' do
it 'returns' do
expect { pipeline.load(context, '/home/test.txt') }
diff --git a/spec/lib/bulk_imports/projects/pipelines/repository_bundle_pipeline_spec.rb b/spec/lib/bulk_imports/projects/pipelines/repository_bundle_pipeline_spec.rb
index 07fafc19026..5aae8c959fa 100644
--- a/spec/lib/bulk_imports/projects/pipelines/repository_bundle_pipeline_spec.rb
+++ b/spec/lib/bulk_imports/projects/pipelines/repository_bundle_pipeline_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe BulkImports::Projects::Pipelines::RepositoryBundlePipeline do
+RSpec.describe BulkImports::Projects::Pipelines::RepositoryBundlePipeline, feature_category: :importers do
let_it_be(:source) { create(:project, :repository) }
let(:portable) { create(:project) }
@@ -123,9 +123,9 @@ RSpec.describe BulkImports::Projects::Pipelines::RepositoryBundlePipeline do
context 'when path is symlink' do
it 'returns' do
symlink = File.join(tmpdir, 'symlink')
+ FileUtils.ln_s(bundle_path, symlink)
- FileUtils.ln_s(File.join(tmpdir, bundle_path), symlink)
-
+ expect(Gitlab::Utils::FileInfo).to receive(:linked?).with(symlink).and_call_original
expect(portable.repository).not_to receive(:create_from_bundle)
pipeline.load(context, symlink)
@@ -134,6 +134,19 @@ RSpec.describe BulkImports::Projects::Pipelines::RepositoryBundlePipeline do
end
end
+ context 'when path has mutiple hard links' do
+ it 'returns' do
+ FileUtils.link(bundle_path, File.join(tmpdir, 'hard_link'))
+
+ expect(Gitlab::Utils::FileInfo).to receive(:linked?).with(bundle_path).and_call_original
+ expect(portable.repository).not_to receive(:create_from_bundle)
+
+ pipeline.load(context, bundle_path)
+
+ expect(portable.repository.exists?).to eq(false)
+ end
+ end
+
context 'when path is not under tmpdir' do
it 'returns' do
expect { pipeline.load(context, '/home/test.txt') }