diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-08-30 22:38:23 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-08-30 22:38:23 +0300 |
commit | f6211f5842821e9fa6acc6881d0ec2c4e9d0ca92 (patch) | |
tree | d029b03d6f079cf6e6e5bdd25fb4efcd22bafa00 /spec/lib/gitlab | |
parent | 3dbdaea3d971a2f5b59778c7d1e10d6c25874b89 (diff) |
Add latest changes from gitlab-org/security/gitlab@16-1-stable-ee
Diffstat (limited to 'spec/lib/gitlab')
4 files changed, 25 insertions, 83 deletions
diff --git a/spec/lib/gitlab/pagination/gitaly_keyset_pager_spec.rb b/spec/lib/gitlab/pagination/gitaly_keyset_pager_spec.rb index b5ed583b1f1..79942139b4f 100644 --- a/spec/lib/gitlab/pagination/gitaly_keyset_pager_spec.rb +++ b/spec/lib/gitlab/pagination/gitaly_keyset_pager_spec.rb @@ -127,17 +127,27 @@ RSpec.describe Gitlab::Pagination::GitalyKeysetPager do end end - context 'with "none" pagination option' do + context "with 'none' pagination option" do let(:expected_result) { double(:result) } let(:query) { { pagination: 'none' } } - it 'uses offset pagination' do - expect(finder).to receive(:execute).with(gitaly_pagination: false).and_return(expected_result) - expect(Kaminari).not_to receive(:paginate_array) - expect(Gitlab::Pagination::OffsetPagination).not_to receive(:new) + context "with a finder that is not a TreeFinder" do + it_behaves_like 'offset pagination' + end + + context "with a finder that is a TreeFinder" do + before do + allow(finder).to receive(:is_a?).with(::Repositories::TreeFinder).and_return(true) + end - actual_result = pager.paginate(finder) - expect(actual_result).to eq(expected_result) + it "doesn't uses offset pagination" do + expect(finder).to receive(:execute).with(gitaly_pagination: false).and_return(expected_result) + expect(Kaminari).not_to receive(:paginate_array) + expect(Gitlab::Pagination::OffsetPagination).not_to receive(:new) + + actual_result = pager.paginate(finder) + expect(actual_result).to eq(expected_result) + end end end end diff --git a/spec/lib/gitlab/regex_spec.rb b/spec/lib/gitlab/regex_spec.rb index 5e58282ff92..f85395fb491 100644 --- a/spec/lib/gitlab/regex_spec.rb +++ b/spec/lib/gitlab/regex_spec.rb @@ -86,36 +86,6 @@ RSpec.describe Gitlab::Regex, feature_category: :tooling do } end - describe '.bulk_import_destination_namespace_path_regex' do - subject { described_class.bulk_import_destination_namespace_path_regex } - - it { is_expected.not_to match('?gitlab') } - it { is_expected.not_to match("Users's something") } - it { is_expected.not_to match('/source') } - it { is_expected.not_to match('http:') } - it { is_expected.not_to match('https:') } - it { is_expected.not_to match('example.com/?stuff=true') } - it { is_expected.not_to match('example.com:5000/?stuff=true') } - it { is_expected.not_to match('http://gitlab.example/gitlab-org/manage/import/gitlab-migration-test') } - it { is_expected.not_to match('_good_for_me!') } - it { is_expected.not_to match('good_for+you') } - it { is_expected.not_to match('source/') } - it { is_expected.not_to match('.source/full./path') } - it { is_expected.not_to match('.source/.full/.path') } - it { is_expected.not_to match('_source') } - it { is_expected.not_to match('.source') } - - it { is_expected.to match('source') } - it { is_expected.to match('source/full') } - it { is_expected.to match('source/full/path') } - it { is_expected.to match('sou_rce/fu-ll/pa.th') } - it { is_expected.to match('domain_namespace') } - it { is_expected.to match('gitlab-migration-test') } - it { is_expected.to match('1-project-path') } - it { is_expected.to match('e-project-path') } - it { is_expected.to match('') } # it is possible to pass an empty string for destination_namespace in bulk_import POST request - end - describe '.bulk_import_source_full_path_regex_message' do subject { described_class.bulk_import_source_full_path_regex_message } @@ -129,44 +99,6 @@ RSpec.describe Gitlab::Regex, feature_category: :tooling do } end - describe '.bulk_import_source_full_path_regex' do - subject { described_class.bulk_import_source_full_path_regex } - - it { is_expected.not_to match("Users's something") } - it { is_expected.not_to match('/source') } - it { is_expected.not_to match('http:') } - it { is_expected.not_to match('https:') } - it { is_expected.not_to match('example.com/?stuff=true') } - it { is_expected.not_to match('example.com:5000/?stuff=true') } - it { is_expected.not_to match('http://gitlab.example/gitlab-org/manage/import/gitlab-migration-test') } - it { is_expected.not_to match('source/') } - it { is_expected.not_to match('') } - it { is_expected.not_to match('.source/full./path') } - it { is_expected.not_to match('?gitlab') } - it { is_expected.not_to match('_good_for_me!') } - it { is_expected.not_to match('group/@*%_my_other-project-----') } - it { is_expected.not_to match('_foog-for-me!') } - it { is_expected.not_to match('.source/full/path.') } - - it { is_expected.to match('good_for+you') } - it { is_expected.to match('source') } - it { is_expected.to match('.source') } - it { is_expected.to match('_source') } - it { is_expected.to match('source/full') } - it { is_expected.to match('source/full/path') } - it { is_expected.to match('domain_namespace') } - it { is_expected.to match('gitlab-migration-test') } - it { is_expected.to match('source/full/path-') } - it { is_expected.to match('.source/full/path') } - it { is_expected.to match('.source/.full/.path') } - it { is_expected.to match('source/full/.path') } - it { is_expected.to match('source/full/..path') } - it { is_expected.to match('source/full/---1path') } - it { is_expected.to match('source/full/-___path') } - it { is_expected.to match('source/full/path---') } - it { is_expected.to match('group/__my_other-project-----') } - end - describe '.group_path_regex' do subject { described_class.group_path_regex } diff --git a/spec/lib/gitlab/usage/metrics/instrumentations/count_bulk_imports_entities_metric_spec.rb b/spec/lib/gitlab/usage/metrics/instrumentations/count_bulk_imports_entities_metric_spec.rb index 317929f77e6..4bd9c64c05a 100644 --- a/spec/lib/gitlab/usage/metrics/instrumentations/count_bulk_imports_entities_metric_spec.rb +++ b/spec/lib/gitlab/usage/metrics/instrumentations/count_bulk_imports_entities_metric_spec.rb @@ -5,17 +5,17 @@ require 'spec_helper' RSpec.describe Gitlab::Usage::Metrics::Instrumentations::CountBulkImportsEntitiesMetric, feature_category: :importers do let_it_be(:user) { create(:user) } let_it_be(:bulk_import_projects) do - create_list(:bulk_import_entity, 2, source_type: 'project_entity', created_at: 3.weeks.ago, status: 2) - create(:bulk_import_entity, source_type: 'project_entity', created_at: 3.weeks.ago, status: 0) + create_list(:bulk_import_entity, 2, :project_entity, created_at: 3.weeks.ago, status: 2) + create(:bulk_import_entity, :project_entity, created_at: 3.weeks.ago, status: 0) end let_it_be(:bulk_import_groups) do - create_list(:bulk_import_entity, 2, source_type: 'group_entity', created_at: 3.weeks.ago, status: 2) - create(:bulk_import_entity, source_type: 'group_entity', created_at: 3.weeks.ago, status: 0) + create_list(:bulk_import_entity, 2, :group_entity, created_at: 3.weeks.ago, status: 2) + create(:bulk_import_entity, :group_entity, created_at: 3.weeks.ago, status: 0) end let_it_be(:old_bulk_import_project) do - create(:bulk_import_entity, source_type: 'project_entity', created_at: 2.months.ago, status: 2) + create(:bulk_import_entity, :project_entity, created_at: 2.months.ago, status: 2) end context 'with no source_type' do diff --git a/spec/lib/gitlab/usage/metrics/instrumentations/count_imported_projects_total_metric_spec.rb b/spec/lib/gitlab/usage/metrics/instrumentations/count_imported_projects_total_metric_spec.rb index bfc4240def6..ae2b06c03ba 100644 --- a/spec/lib/gitlab/usage/metrics/instrumentations/count_imported_projects_total_metric_spec.rb +++ b/spec/lib/gitlab/usage/metrics/instrumentations/count_imported_projects_total_metric_spec.rb @@ -15,15 +15,15 @@ RSpec.describe Gitlab::Usage::Metrics::Instrumentations::CountImportedProjectsTo let_it_be(:old_import) { create(:project, import_type: 'gitea', creator_id: user.id, created_at: 2.months.ago) } let_it_be(:bulk_import_projects) do - create_list(:bulk_import_entity, 3, source_type: 'project_entity', created_at: 3.weeks.ago) + create_list(:bulk_import_entity, 3, :project_entity, created_at: 3.weeks.ago) end let_it_be(:bulk_import_groups) do - create_list(:bulk_import_entity, 3, source_type: 'group_entity', created_at: 3.weeks.ago) + create_list(:bulk_import_entity, 3, :group_entity, created_at: 3.weeks.ago) end let_it_be(:old_bulk_import_project) do - create(:bulk_import_entity, source_type: 'project_entity', created_at: 2.months.ago) + create(:bulk_import_entity, :project_entity, created_at: 2.months.ago) end before do |