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
path: root/spec
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-12-13 15:13:10 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-12-13 15:13:10 +0300
commit8ebd99a81f8fe458153de9815f73f9067d010293 (patch)
tree29390f8f6e89af290768a32e4bb6cf281c44105d /spec
parentc283bdb7bc86aee27a7ed065fc9fb17e4c4ffee6 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r--spec/controllers/projects/deploy_keys_controller_spec.rb6
-rw-r--r--spec/factories/container_registry/protection/rules.rb2
-rw-r--r--spec/features/profiles/user_manages_applications_spec.rb2
-rw-r--r--spec/frontend/fixtures/deploy_keys.rb42
-rw-r--r--spec/graphql/types/container_registry/protection/rule_type_spec.rb4
-rw-r--r--spec/lib/api/helpers/import_github_helpers_spec.rb3
-rw-r--r--spec/lib/gitlab/github_import/client_pool_spec.rb41
-rw-r--r--spec/lib/gitlab/github_import/settings_spec.rb7
-rw-r--r--spec/lib/gitlab/github_import_spec.rb23
-rw-r--r--spec/lib/sidebars/user_settings/menus/applications_menu_spec.rb2
-rw-r--r--spec/models/bulk_import_spec.rb31
-rw-r--r--spec/models/bulk_imports/entity_spec.rb9
-rw-r--r--spec/models/container_registry/protection/rule_spec.rb6
-rw-r--r--spec/requests/api/graphql/mutations/container_registry/protection/rule/create_spec.rb26
-rw-r--r--spec/requests/api/graphql/mutations/container_registry/protection/rule/delete_spec.rb6
-rw-r--r--spec/requests/api/group_export_spec.rb32
-rw-r--r--spec/requests/api/import_github_spec.rb25
-rw-r--r--spec/requests/api/project_export_spec.rb32
-rw-r--r--spec/requests/legacy_routes_spec.rb10
-rw-r--r--spec/serializers/deploy_keys/basic_deploy_key_entity_spec.rb13
-rw-r--r--spec/services/container_registry/protection/create_rule_service_spec.rb22
-rw-r--r--spec/services/container_registry/protection/delete_rule_service_spec.rb2
-rw-r--r--spec/services/import/github_service_spec.rb14
-rw-r--r--spec/workers/concerns/gitlab/github_import/object_importer_spec.rb13
24 files changed, 202 insertions, 171 deletions
diff --git a/spec/controllers/projects/deploy_keys_controller_spec.rb b/spec/controllers/projects/deploy_keys_controller_spec.rb
index 43f089cede9..a285a84ca0b 100644
--- a/spec/controllers/projects/deploy_keys_controller_spec.rb
+++ b/spec/controllers/projects/deploy_keys_controller_spec.rb
@@ -76,7 +76,7 @@ RSpec.describe Projects::DeployKeysController, feature_category: :continuous_del
it 'returns only enabled keys' do
get :enabled_keys, params: params.merge(format: :json)
- expect(json_response.pluck("id")).to match_array([deploy_key_for_target_project.deploy_key_id])
+ expect(json_response['keys'].pluck("id")).to match_array([deploy_key_for_target_project.deploy_key_id])
end
end
@@ -88,7 +88,7 @@ RSpec.describe Projects::DeployKeysController, feature_category: :continuous_del
it 'returns available project keys' do
get :available_project_keys, params: params.merge(format: :json)
- expect(json_response.pluck("id")).to match_array([deploy_key_for_accessible_project.deploy_key_id])
+ expect(json_response['keys'].pluck("id")).to match_array([deploy_key_for_accessible_project.deploy_key_id])
end
end
@@ -100,7 +100,7 @@ RSpec.describe Projects::DeployKeysController, feature_category: :continuous_del
it 'returns available public keys' do
get :available_public_keys, params: params.merge(format: :json)
- expect(json_response.pluck("id")).to match_array([deploy_key_public.id])
+ expect(json_response['keys'].pluck("id")).to match_array([deploy_key_public.id])
end
end
end
diff --git a/spec/factories/container_registry/protection/rules.rb b/spec/factories/container_registry/protection/rules.rb
index cbd5c9d8652..4d2fb1411c3 100644
--- a/spec/factories/container_registry/protection/rules.rb
+++ b/spec/factories/container_registry/protection/rules.rb
@@ -3,7 +3,7 @@
FactoryBot.define do
factory :container_registry_protection_rule, class: 'ContainerRegistry::Protection::Rule' do
project
- container_path_pattern { '@my_scope/my_container' }
+ repository_path_pattern { 'my_project/my_container' }
delete_protected_up_to_access_level { :developer }
push_protected_up_to_access_level { :developer }
end
diff --git a/spec/features/profiles/user_manages_applications_spec.rb b/spec/features/profiles/user_manages_applications_spec.rb
index e3c4a797431..b4010cccbbc 100644
--- a/spec/features/profiles/user_manages_applications_spec.rb
+++ b/spec/features/profiles/user_manages_applications_spec.rb
@@ -4,7 +4,7 @@ require 'spec_helper'
RSpec.describe 'User manages applications', feature_category: :user_profile do
let_it_be(:user) { create(:user) }
- let_it_be(:new_application_path) { applications_profile_path }
+ let_it_be(:new_application_path) { user_settings_applications_path }
let_it_be(:index_path) { oauth_applications_path }
before do
diff --git a/spec/frontend/fixtures/deploy_keys.rb b/spec/frontend/fixtures/deploy_keys.rb
index 05fca368fd5..8c371827594 100644
--- a/spec/frontend/fixtures/deploy_keys.rb
+++ b/spec/frontend/fixtures/deploy_keys.rb
@@ -12,12 +12,19 @@ RSpec.describe Projects::DeployKeysController, '(JavaScript fixtures)', type: :c
let(:project2) { create(:project, :internal) }
let(:project3) { create(:project, :internal) }
let(:project4) { create(:project, :internal) }
+ let(:project_key) { create(:deploy_key) }
+ let(:internal_key) { create(:deploy_key) }
before do
# Using an admin for these fixtures because they are used for verifying a frontend
# component that would normally get its data from `Admin::DeployKeysController`
sign_in(admin)
enable_admin_mode!(admin)
+ create(:rsa_deploy_key_5120, public: true)
+ create(:deploy_keys_project, project: project, deploy_key: project_key)
+ create(:deploy_keys_project, project: project2, deploy_key: internal_key)
+ create(:deploy_keys_project, project: project3, deploy_key: project_key)
+ create(:deploy_keys_project, project: project4, deploy_key: project_key)
end
after do
@@ -27,14 +34,6 @@ RSpec.describe Projects::DeployKeysController, '(JavaScript fixtures)', type: :c
render_views
it 'deploy_keys/keys.json' do
- create(:rsa_deploy_key_5120, public: true)
- project_key = create(:deploy_key)
- internal_key = create(:deploy_key)
- create(:deploy_keys_project, project: project, deploy_key: project_key)
- create(:deploy_keys_project, project: project2, deploy_key: internal_key)
- create(:deploy_keys_project, project: project3, deploy_key: project_key)
- create(:deploy_keys_project, project: project4, deploy_key: project_key)
-
get :index, params: {
namespace_id: project.namespace.to_param,
project_id: project
@@ -42,4 +41,31 @@ RSpec.describe Projects::DeployKeysController, '(JavaScript fixtures)', type: :c
expect(response).to be_successful
end
+
+ it 'deploy_keys/enabled_keys.json' do
+ get :enabled_keys, params: {
+ namespace_id: project.namespace.to_param,
+ project_id: project
+ }, format: :json
+
+ expect(response).to be_successful
+ end
+
+ it 'deploy_keys/available_project_keys.json' do
+ get :available_project_keys, params: {
+ namespace_id: project.namespace.to_param,
+ project_id: project
+ }, format: :json
+
+ expect(response).to be_successful
+ end
+
+ it 'deploy_keys/available_public_keys.json' do
+ get :available_public_keys, params: {
+ namespace_id: project.namespace.to_param,
+ project_id: project
+ }, format: :json
+
+ expect(response).to be_successful
+ end
end
diff --git a/spec/graphql/types/container_registry/protection/rule_type_spec.rb b/spec/graphql/types/container_registry/protection/rule_type_spec.rb
index 58b53af80fb..40a45609345 100644
--- a/spec/graphql/types/container_registry/protection/rule_type_spec.rb
+++ b/spec/graphql/types/container_registry/protection/rule_type_spec.rb
@@ -15,8 +15,8 @@ RSpec.describe GitlabSchema.types['ContainerRegistryProtectionRule'], feature_ca
it { is_expected.to have_non_null_graphql_type(::Types::GlobalIDType[::ContainerRegistry::Protection::Rule]) }
end
- describe 'container_path_pattern' do
- subject { described_class.fields['containerPathPattern'] }
+ describe 'repository_path_pattern' do
+ subject { described_class.fields['repositoryPathPattern'] }
it { is_expected.to have_non_null_graphql_type(GraphQL::Types::String) }
end
diff --git a/spec/lib/api/helpers/import_github_helpers_spec.rb b/spec/lib/api/helpers/import_github_helpers_spec.rb
index 3324e38660c..7f8fbad1273 100644
--- a/spec/lib/api/helpers/import_github_helpers_spec.rb
+++ b/spec/lib/api/helpers/import_github_helpers_spec.rb
@@ -7,7 +7,6 @@ RSpec.describe API::Helpers::ImportGithubHelpers, feature_category: :importers d
helper = Class.new.include(described_class).new
def helper.params = {
personal_access_token: 'foo',
- additional_access_tokens: 'bar',
github_hostname: 'github.example.com'
}
helper
@@ -21,7 +20,7 @@ RSpec.describe API::Helpers::ImportGithubHelpers, feature_category: :importers d
describe '#access_params' do
it 'makes the passed in personal access token and extra tokens accessible' do
- expect(subject.access_params).to eq({ github_access_token: 'foo', additional_access_tokens: 'bar' })
+ expect(subject.access_params).to eq({ github_access_token: 'foo' })
end
end
diff --git a/spec/lib/gitlab/github_import/client_pool_spec.rb b/spec/lib/gitlab/github_import/client_pool_spec.rb
deleted file mode 100644
index aabb47c2cf1..00000000000
--- a/spec/lib/gitlab/github_import/client_pool_spec.rb
+++ /dev/null
@@ -1,41 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-
-RSpec.describe Gitlab::GithubImport::ClientPool, feature_category: :importers do
- subject(:pool) { described_class.new(token_pool: %w[foo bar], per_page: 1, parallel: true) }
-
- describe '#best_client' do
- it 'returns the client with the most remaining requests' do
- allow(Gitlab::GithubImport::Client).to receive(:new).and_return(
- instance_double(
- Gitlab::GithubImport::Client,
- requests_remaining?: true, remaining_requests: 10, rate_limit_resets_in: 1
- ),
- instance_double(
- Gitlab::GithubImport::Client,
- requests_remaining?: true, remaining_requests: 20, rate_limit_resets_in: 2
- )
- )
-
- expect(pool.best_client.remaining_requests).to eq(20)
- end
-
- context 'when all clients are rate limited' do
- it 'returns the client with the closest rate limit reset time' do
- allow(Gitlab::GithubImport::Client).to receive(:new).and_return(
- instance_double(
- Gitlab::GithubImport::Client,
- requests_remaining?: false, remaining_requests: 10, rate_limit_resets_in: 10
- ),
- instance_double(
- Gitlab::GithubImport::Client,
- requests_remaining?: false, remaining_requests: 20, rate_limit_resets_in: 20
- )
- )
-
- expect(pool.best_client.rate_limit_resets_in).to eq(10)
- end
- end
- end
-end
diff --git a/spec/lib/gitlab/github_import/settings_spec.rb b/spec/lib/gitlab/github_import/settings_spec.rb
index de497bc6689..ea1526ca25f 100644
--- a/spec/lib/gitlab/github_import/settings_spec.rb
+++ b/spec/lib/gitlab/github_import/settings_spec.rb
@@ -62,12 +62,11 @@ RSpec.describe Gitlab::GithubImport::Settings, feature_category: :importers do
collaborators_import: false,
foo: :bar
},
- timeout_strategy: "optimistic",
- additional_access_tokens: %w[foo bar]
+ timeout_strategy: "optimistic"
}.stringify_keys
end
- it 'puts optional steps, timeout strategy & access tokens into projects import_data' do
+ it 'puts optional steps and timeout strategy into projects import_data' do
project.build_or_assign_import_data(credentials: { user: 'token' })
settings.write(data_input)
@@ -76,8 +75,6 @@ RSpec.describe Gitlab::GithubImport::Settings, feature_category: :importers do
.to eq optional_stages.stringify_keys
expect(project.import_data.data['timeout_strategy'])
.to eq("optimistic")
- expect(project.import_data.credentials.fetch(:additional_access_tokens))
- .to eq(data_input['additional_access_tokens'])
end
end
diff --git a/spec/lib/gitlab/github_import_spec.rb b/spec/lib/gitlab/github_import_spec.rb
index 8453f002bc0..1721f470b33 100644
--- a/spec/lib/gitlab/github_import_spec.rb
+++ b/spec/lib/gitlab/github_import_spec.rb
@@ -11,8 +11,6 @@ RSpec.describe Gitlab::GithubImport, feature_category: :importers do
let(:project) { double(:project, import_url: 'http://t0ken@github.com/user/repo.git', id: 1, group: nil) }
it 'returns a new Client with a custom token' do
- allow(project).to receive(:import_data)
-
expect(described_class::Client)
.to receive(:new)
.with('123', host: nil, parallel: true, per_page: 100)
@@ -26,7 +24,6 @@ RSpec.describe Gitlab::GithubImport, feature_category: :importers do
expect(project)
.to receive(:import_data)
.and_return(import_data)
- .twice
expect(described_class::Client)
.to receive(:new)
@@ -49,31 +46,12 @@ RSpec.describe Gitlab::GithubImport, feature_category: :importers do
described_class.ghost_user_id
end
end
-
- context 'when there are additional access tokens' do
- it 'returns a new ClientPool containing all tokens' do
- import_data = double(:import_data, credentials: { user: '123', additional_access_tokens: %w[foo bar] })
-
- expect(project)
- .to receive(:import_data)
- .and_return(import_data)
- .twice
-
- expect(described_class::ClientPool)
- .to receive(:new)
- .with(token_pool: %w[foo bar 123], host: nil, parallel: true, per_page: 100)
-
- described_class.new_client_for(project)
- end
- end
end
context 'GitHub Enterprise' do
let(:project) { double(:project, import_url: 'http://t0ken@github.another-domain.com/repo-org/repo.git', group: nil) }
it 'returns a new Client with a custom token' do
- allow(project).to receive(:import_data)
-
expect(described_class::Client)
.to receive(:new)
.with('123', host: 'http://github.another-domain.com/api/v3', parallel: true, per_page: 100)
@@ -87,7 +65,6 @@ RSpec.describe Gitlab::GithubImport, feature_category: :importers do
expect(project)
.to receive(:import_data)
.and_return(import_data)
- .twice
expect(described_class::Client)
.to receive(:new)
diff --git a/spec/lib/sidebars/user_settings/menus/applications_menu_spec.rb b/spec/lib/sidebars/user_settings/menus/applications_menu_spec.rb
index eeda4fb844c..a0c175051df 100644
--- a/spec/lib/sidebars/user_settings/menus/applications_menu_spec.rb
+++ b/spec/lib/sidebars/user_settings/menus/applications_menu_spec.rb
@@ -4,7 +4,7 @@ require 'spec_helper'
RSpec.describe Sidebars::UserSettings::Menus::ApplicationsMenu, feature_category: :navigation do
it_behaves_like 'User settings menu',
- link: '/-/profile/applications',
+ link: '/-/user_settings/applications',
title: _('Applications'),
icon: 'applications',
active_routes: { controller: 'oauth/applications' }
diff --git a/spec/models/bulk_import_spec.rb b/spec/models/bulk_import_spec.rb
index 015357214b9..57c6df39167 100644
--- a/spec/models/bulk_import_spec.rb
+++ b/spec/models/bulk_import_spec.rb
@@ -3,12 +3,12 @@
require 'spec_helper'
RSpec.describe BulkImport, type: :model, feature_category: :importers do
- let_it_be(:created_bulk_import) { create(:bulk_import, :created) }
- let_it_be(:started_bulk_import) { create(:bulk_import, :started) }
- let_it_be(:finished_bulk_import) { create(:bulk_import, :finished) }
+ let_it_be(:created_bulk_import) { create(:bulk_import, :created, updated_at: 2.hours.ago) }
+ let_it_be(:started_bulk_import) { create(:bulk_import, :started, updated_at: 3.hours.ago) }
+ let_it_be(:finished_bulk_import) { create(:bulk_import, :finished, updated_at: 1.hour.ago) }
let_it_be(:failed_bulk_import) { create(:bulk_import, :failed) }
let_it_be(:stale_created_bulk_import) { create(:bulk_import, :created, updated_at: 3.days.ago) }
- let_it_be(:stale_started_bulk_import) { create(:bulk_import, :started, updated_at: 3.days.ago) }
+ let_it_be(:stale_started_bulk_import) { create(:bulk_import, :started, updated_at: 2.days.ago) }
describe 'associations' do
it { is_expected.to belong_to(:user).required }
@@ -23,10 +23,27 @@ RSpec.describe BulkImport, type: :model, feature_category: :importers do
it { is_expected.to define_enum_for(:source_type).with_values(%i[gitlab]) }
end
- describe '.stale scope' do
- subject { described_class.stale }
+ describe 'scopes' do
+ describe '.stale' do
+ subject { described_class.stale }
- it { is_expected.to contain_exactly(stale_created_bulk_import, stale_started_bulk_import) }
+ it { is_expected.to contain_exactly(stale_created_bulk_import, stale_started_bulk_import) }
+ end
+
+ describe '.order_by_updated_at_and_id' do
+ subject { described_class.order_by_updated_at_and_id(:desc) }
+
+ it 'sorts by given direction' do
+ is_expected.to eq([
+ failed_bulk_import,
+ finished_bulk_import,
+ created_bulk_import,
+ started_bulk_import,
+ stale_started_bulk_import,
+ stale_created_bulk_import
+ ])
+ end
+ end
end
describe '.all_human_statuses' do
diff --git a/spec/models/bulk_imports/entity_spec.rb b/spec/models/bulk_imports/entity_spec.rb
index 612fa7acfa3..ce143a1aa33 100644
--- a/spec/models/bulk_imports/entity_spec.rb
+++ b/spec/models/bulk_imports/entity_spec.rb
@@ -200,6 +200,15 @@ RSpec.describe BulkImports::Entity, type: :model, feature_category: :importers d
expect(described_class.stale).to contain_exactly(entity_1)
end
end
+
+ describe '.order_by_updated_at_and_id' do
+ it 'returns entities ordered by updated_at and id' do
+ entity_1 = create(:bulk_import_entity, updated_at: 3.days.ago)
+ entity_2 = create(:bulk_import_entity, updated_at: 2.days.ago)
+
+ expect(described_class.order_by_updated_at_and_id(:desc)).to eq([entity_2, entity_1])
+ end
+ end
end
describe '.all_human_statuses' do
diff --git a/spec/models/container_registry/protection/rule_spec.rb b/spec/models/container_registry/protection/rule_spec.rb
index 9f162736efd..1706fcf76ae 100644
--- a/spec/models/container_registry/protection/rule_spec.rb
+++ b/spec/models/container_registry/protection/rule_spec.rb
@@ -38,9 +38,9 @@ RSpec.describe ContainerRegistry::Protection::Rule, type: :model, feature_catego
describe 'validations' do
subject { build(:container_registry_protection_rule) }
- describe '#container_path_pattern' do
- it { is_expected.to validate_presence_of(:container_path_pattern) }
- it { is_expected.to validate_length_of(:container_path_pattern).is_at_most(255) }
+ describe '#repository_path_pattern' do
+ it { is_expected.to validate_presence_of(:repository_path_pattern) }
+ it { is_expected.to validate_length_of(:repository_path_pattern).is_at_most(255) }
end
describe '#delete_protected_up_to_access_level' do
diff --git a/spec/requests/api/graphql/mutations/container_registry/protection/rule/create_spec.rb b/spec/requests/api/graphql/mutations/container_registry/protection/rule/create_spec.rb
index 0c708c3dc41..71b8c99c1c0 100644
--- a/spec/requests/api/graphql/mutations/container_registry/protection/rule/create_spec.rb
+++ b/spec/requests/api/graphql/mutations/container_registry/protection/rule/create_spec.rb
@@ -15,7 +15,7 @@ RSpec.describe 'Creating the container registry protection rule', :aggregate_fai
let(:kwargs) do
{
project_path: project.full_path,
- container_path_pattern: container_registry_protection_rule_attributes.container_path_pattern,
+ repository_path_pattern: container_registry_protection_rule_attributes.repository_path_pattern,
push_protected_up_to_access_level: 'MAINTAINER',
delete_protected_up_to_access_level: 'MAINTAINER'
}
@@ -26,7 +26,7 @@ RSpec.describe 'Creating the container registry protection rule', :aggregate_fai
<<~QUERY
containerRegistryProtectionRule {
id
- containerPathPattern
+ repositoryPathPattern
}
clientMutationId
errors
@@ -48,7 +48,7 @@ RSpec.describe 'Creating the container registry protection rule', :aggregate_fai
'errors' => be_blank,
'containerRegistryProtectionRule' => {
'id' => be_present,
- 'containerPathPattern' => kwargs[:container_path_pattern]
+ 'repositoryPathPattern' => kwargs[:repository_path_pattern]
}
)
end
@@ -57,7 +57,7 @@ RSpec.describe 'Creating the container registry protection rule', :aggregate_fai
expect { subject }.to change { ::ContainerRegistry::Protection::Rule.count }.by(1)
expect(::ContainerRegistry::Protection::Rule.where(project: project,
- container_path_pattern: kwargs[:container_path_pattern])).to exist
+ repository_path_pattern: kwargs[:repository_path_pattern])).to exist
end
end
@@ -84,9 +84,9 @@ RSpec.describe 'Creating the container registry protection rule', :aggregate_fai
}
end
- context 'with invalid input field `containerPathPattern`' do
+ context 'with invalid input field `repositoryPathPattern`' do
let(:kwargs) do
- super().merge(container_path_pattern: '')
+ super().merge(repository_path_pattern: '')
end
it_behaves_like 'an erroneous response'
@@ -95,7 +95,7 @@ RSpec.describe 'Creating the container registry protection rule', :aggregate_fai
it {
subject.tap do
- expect(mutation_response['errors']).to eq ["Container path pattern can't be blank"]
+ expect(mutation_response['errors']).to eq ["Repository path pattern can't be blank"]
end
}
end
@@ -108,9 +108,9 @@ RSpec.describe 'Creating the container registry protection rule', :aggregate_fai
context 'when container name pattern is slightly different' do
let(:kwargs) do
- # The field `container_path_pattern` is unique; this is why we change the value in a minimum way
+ # The field `repository_path_pattern` is unique; this is why we change the value in a minimum way
super().merge(
- container_path_pattern: "#{existing_container_registry_protection_rule.container_path_pattern}-unique"
+ repository_path_pattern: "#{existing_container_registry_protection_rule.repository_path_pattern}-unique"
)
end
@@ -121,9 +121,9 @@ RSpec.describe 'Creating the container registry protection rule', :aggregate_fai
end
end
- context 'when field `container_path_pattern` is taken' do
+ context 'when field `repository_path_pattern` is taken' do
let(:kwargs) do
- super().merge(container_path_pattern: existing_container_registry_protection_rule.container_path_pattern,
+ super().merge(repository_path_pattern: existing_container_registry_protection_rule.repository_path_pattern,
push_protected_up_to_access_level: 'MAINTAINER')
end
@@ -134,12 +134,12 @@ RSpec.describe 'Creating the container registry protection rule', :aggregate_fai
it 'returns without error' do
subject
- expect(mutation_response['errors']).to eq ['Container path pattern has already been taken']
+ expect(mutation_response['errors']).to eq ['Repository path pattern has already been taken']
end
it 'does not create new container protection rules' do
expect(::ContainerRegistry::Protection::Rule.where(project: project,
- container_path_pattern: kwargs[:container_path_pattern],
+ repository_path_pattern: kwargs[:repository_path_pattern],
push_protected_up_to_access_level: Gitlab::Access::MAINTAINER)).not_to exist
end
end
diff --git a/spec/requests/api/graphql/mutations/container_registry/protection/rule/delete_spec.rb b/spec/requests/api/graphql/mutations/container_registry/protection/rule/delete_spec.rb
index 126d4bfdd4a..8b5eaf580f4 100644
--- a/spec/requests/api/graphql/mutations/container_registry/protection/rule/delete_spec.rb
+++ b/spec/requests/api/graphql/mutations/container_registry/protection/rule/delete_spec.rb
@@ -41,7 +41,7 @@ RSpec.describe 'Deleting a container registry protection rule', :aggregate_failu
'errors' => be_blank,
'containerRegistryProtectionRule' => {
'id' => container_protection_rule.to_global_id.to_s,
- 'containerPathPattern' => container_protection_rule.container_path_pattern,
+ 'repositoryPathPattern' => container_protection_rule.repository_path_pattern,
'deleteProtectedUpToAccessLevel' => container_protection_rule.delete_protected_up_to_access_level.upcase,
'pushProtectedUpToAccessLevel' => container_protection_rule.push_protected_up_to_access_level.upcase
}
@@ -50,7 +50,7 @@ RSpec.describe 'Deleting a container registry protection rule', :aggregate_failu
context 'with existing container registry protection rule belonging to other project' do
let_it_be(:container_protection_rule) do
- create(:container_registry_protection_rule, container_path_pattern: 'protection_rule_other_project')
+ create(:container_registry_protection_rule, repository_path_pattern: 'protection_rule_other_project')
end
it_behaves_like 'an erroneous reponse'
@@ -61,7 +61,7 @@ RSpec.describe 'Deleting a container registry protection rule', :aggregate_failu
context 'with deleted container registry protection rule' do
let!(:container_protection_rule) do
create(:container_registry_protection_rule, project: project,
- container_path_pattern: 'protection_rule_deleted').destroy!
+ repository_path_pattern: 'protection_rule_deleted').destroy!
end
it_behaves_like 'an erroneous reponse'
diff --git a/spec/requests/api/group_export_spec.rb b/spec/requests/api/group_export_spec.rb
index d0f7c000544..c48ade1cb8b 100644
--- a/spec/requests/api/group_export_spec.rb
+++ b/spec/requests/api/group_export_spec.rb
@@ -311,6 +311,8 @@ RSpec.describe API::GroupExport, feature_category: :importers do
expect(response).to have_gitlab_http_status(:ok)
expect(json_response.pluck('relation')).to contain_exactly('labels', 'milestones', 'badges')
expect(json_response.pluck('status')).to contain_exactly(-1, 0, 1)
+ expect(json_response.pluck('batched')).to all(eq(false))
+ expect(json_response.pluck('batches_count')).to all(eq(0))
end
context 'when relation is specified' do
@@ -322,6 +324,36 @@ RSpec.describe API::GroupExport, feature_category: :importers do
expect(json_response['status']).to eq(0)
end
end
+
+ context 'when there is a batched export' do
+ let_it_be(:batched_export) do
+ create(:bulk_import_export, :started, :batched, group: group, relation: 'boards', batches_count: 1)
+ end
+
+ let_it_be(:batch) { create(:bulk_import_export_batch, objects_count: 5, export: batched_export) }
+
+ it 'returns a list of batched relation export statuses' do
+ get api(status_path, user)
+
+ expect(response).to have_gitlab_http_status(:ok)
+ expect(json_response).to include(
+ hash_including(
+ 'relation' => batched_export.relation,
+ 'batched' => true,
+ 'batches_count' => 1,
+ 'batches' => contain_exactly(
+ {
+ 'batch_number' => 1,
+ 'error' => nil,
+ 'objects_count' => batch.objects_count,
+ 'status' => batch.status,
+ 'updated_at' => batch.updated_at.as_json
+ }
+ )
+ )
+ )
+ end
+ end
end
context 'when bulk import is disabled' do
diff --git a/spec/requests/api/import_github_spec.rb b/spec/requests/api/import_github_spec.rb
index 9a42b11dc76..f555f39ff74 100644
--- a/spec/requests/api/import_github_spec.rb
+++ b/spec/requests/api/import_github_spec.rb
@@ -5,8 +5,7 @@ require 'spec_helper'
RSpec.describe API::ImportGithub, feature_category: :importers do
let(:token) { "asdasd12345" }
let(:provider) { :github }
- let(:access_params) { { github_access_token: token, additional_access_tokens: additional_access_tokens } }
- let(:additional_access_tokens) { nil }
+ let(:access_params) { { github_access_token: token } }
let(:provider_username) { user.username }
let(:provider_user) { double('provider', login: provider_username).as_null_object }
let(:provider_repo) do
@@ -134,28 +133,6 @@ RSpec.describe API::ImportGithub, feature_category: :importers do
expect(response).to have_gitlab_http_status(:bad_request)
end
end
-
- context 'when additional access tokens are provided' do
- let(:additional_access_tokens) { 'token1,token2' }
-
- it 'returns 201' do
- expected_access_params = { github_access_token: token, additional_access_tokens: %w[token1 token2] }
-
- expect(Gitlab::LegacyGithubImport::ProjectCreator)
- .to receive(:new)
- .with(provider_repo, provider_repo[:name], user.namespace, user, type: provider, **expected_access_params)
- .and_return(double(execute: project))
-
- post api("/import/github", user), params: {
- target_namespace: user.namespace_path,
- personal_access_token: token,
- repo_id: non_existing_record_id,
- additional_access_tokens: 'token1,token2'
- }
-
- expect(response).to have_gitlab_http_status(:created)
- end
- end
end
describe "POST /import/github/cancel" do
diff --git a/spec/requests/api/project_export_spec.rb b/spec/requests/api/project_export_spec.rb
index 22729e068da..6d5591d7500 100644
--- a/spec/requests/api/project_export_spec.rb
+++ b/spec/requests/api/project_export_spec.rb
@@ -688,6 +688,8 @@ RSpec.describe API::ProjectExport, :aggregate_failures, :clean_gitlab_redis_cach
expect(response).to have_gitlab_http_status(:ok)
expect(json_response.pluck('relation')).to contain_exactly('labels', 'milestones', 'project_badges')
expect(json_response.pluck('status')).to contain_exactly(-1, 0, 1)
+ expect(json_response.pluck('batched')).to all(eq(false))
+ expect(json_response.pluck('batches_count')).to all(eq(0))
end
context 'when relation is specified' do
@@ -699,6 +701,36 @@ RSpec.describe API::ProjectExport, :aggregate_failures, :clean_gitlab_redis_cach
expect(json_response['status']).to eq(0)
end
end
+
+ context 'when there is a batched export' do
+ let_it_be(:batched_export) do
+ create(:bulk_import_export, :started, :batched, project: project, relation: 'issues', batches_count: 1)
+ end
+
+ let_it_be(:batch) { create(:bulk_import_export_batch, objects_count: 5, export: batched_export) }
+
+ it 'returns a list of batched relation export statuses' do
+ get api(status_path, user)
+
+ expect(response).to have_gitlab_http_status(:ok)
+ expect(json_response).to include(
+ hash_including(
+ 'relation' => batched_export.relation,
+ 'batched' => true,
+ 'batches_count' => 1,
+ 'batches' => contain_exactly(
+ {
+ 'batch_number' => 1,
+ 'error' => nil,
+ 'objects_count' => batch.objects_count,
+ 'status' => batch.status,
+ 'updated_at' => batch.updated_at.as_json
+ }
+ )
+ )
+ )
+ end
+ end
end
context 'with bulk_import is disabled' do
diff --git a/spec/requests/legacy_routes_spec.rb b/spec/requests/legacy_routes_spec.rb
index 65af3c78fd7..29d26c87461 100644
--- a/spec/requests/legacy_routes_spec.rb
+++ b/spec/requests/legacy_routes_spec.rb
@@ -13,4 +13,14 @@ RSpec.describe "Legacy routes", type: :request, feature_category: :system_access
get "/-/profile/audit_log"
expect(response).to redirect_to('/-/user_settings/authentication_log')
end
+
+ it "/-/profile/active_sessions" do
+ get "/-/profile/active_sessions"
+ expect(response).to redirect_to('/-/user_settings/active_sessions')
+ end
+
+ it "/-/profile/applications" do
+ get "/-/profile/applications"
+ expect(response).to redirect_to('/-/user_settings/applications')
+ end
end
diff --git a/spec/serializers/deploy_keys/basic_deploy_key_entity_spec.rb b/spec/serializers/deploy_keys/basic_deploy_key_entity_spec.rb
index 7df6413f416..8645bbd49fb 100644
--- a/spec/serializers/deploy_keys/basic_deploy_key_entity_spec.rb
+++ b/spec/serializers/deploy_keys/basic_deploy_key_entity_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe DeployKeys::BasicDeployKeyEntity do
+RSpec.describe DeployKeys::BasicDeployKeyEntity, feature_category: :continuous_delivery do
include RequestAwareEntity
let(:user) { create(:user) }
@@ -56,7 +56,18 @@ RSpec.describe DeployKeys::BasicDeployKeyEntity do
end
context 'project deploy key' do
+ let(:options) { { user: user, project: project } }
+
it { expect(entity.as_json).to include(can_edit: true) }
+ it { expect(entity.as_json).to include(edit_path: edit_project_deploy_key_path(options[:project], deploy_key)) }
+
+ it do
+ expect(entity.as_json).to include(enable_path: enable_project_deploy_key_path(options[:project], deploy_key))
+ end
+
+ it do
+ expect(entity.as_json).to include(disable_path: disable_project_deploy_key_path(options[:project], deploy_key))
+ end
end
context 'public deploy key' do
diff --git a/spec/services/container_registry/protection/create_rule_service_spec.rb b/spec/services/container_registry/protection/create_rule_service_spec.rb
index 3c319caf25c..4559a8fb131 100644
--- a/spec/services/container_registry/protection/create_rule_service_spec.rb
+++ b/spec/services/container_registry/protection/create_rule_service_spec.rb
@@ -22,7 +22,7 @@ RSpec.describe ContainerRegistry::Protection::CreateRuleService, '#execute', fea
container_registry_protection_rule:
be_a(ContainerRegistry::Protection::Rule)
.and(have_attributes(
- container_path_pattern: params[:container_path_pattern],
+ repository_path_pattern: params[:repository_path_pattern],
push_protected_up_to_access_level: params[:push_protected_up_to_access_level].to_s,
delete_protected_up_to_access_level: params[:delete_protected_up_to_access_level].to_s
))
@@ -36,7 +36,7 @@ RSpec.describe ContainerRegistry::Protection::CreateRuleService, '#execute', fea
expect(
ContainerRegistry::Protection::Rule.where(
project: project,
- container_path_pattern: params[:container_path_pattern],
+ repository_path_pattern: params[:repository_path_pattern],
push_protected_up_to_access_level: params[:push_protected_up_to_access_level]
)
).to exist
@@ -57,7 +57,7 @@ RSpec.describe ContainerRegistry::Protection::CreateRuleService, '#execute', fea
expect(
ContainerRegistry::Protection::Rule.where(
project: project,
- container_path_pattern: params[:container_path_pattern],
+ repository_path_pattern: params[:repository_path_pattern],
push_protected_up_to_access_level: params[:push_protected_up_to_access_level]
)
).not_to exist
@@ -67,12 +67,12 @@ RSpec.describe ContainerRegistry::Protection::CreateRuleService, '#execute', fea
it_behaves_like 'a successful service response'
context 'when fields are invalid' do
- context 'when container_path_pattern is invalid' do
- let(:params) { super().merge(container_path_pattern: '') }
+ context 'when repository_path_pattern is invalid' do
+ let(:params) { super().merge(repository_path_pattern: '') }
it_behaves_like 'an erroneous service response'
- it { is_expected.to have_attributes(message: match(/Container path pattern can't be blank/)) }
+ it { is_expected.to have_attributes(message: match(/Repository path pattern can't be blank/)) }
end
context 'when delete_protected_up_to_access_level is invalid' do
@@ -100,8 +100,8 @@ RSpec.describe ContainerRegistry::Protection::CreateRuleService, '#execute', fea
context 'when container registry name pattern is slightly different' do
let(:params) do
super().merge(
- # The field `container_path_pattern` is unique; this is why we change the value in a minimum way
- container_path_pattern: "#{existing_container_registry_protection_rule.container_path_pattern}-unique",
+ # The field `repository_path_pattern` is unique; this is why we change the value in a minimum way
+ repository_path_pattern: "#{existing_container_registry_protection_rule.repository_path_pattern}-unique",
push_protected_up_to_access_level:
existing_container_registry_protection_rule.push_protected_up_to_access_level
)
@@ -110,17 +110,17 @@ RSpec.describe ContainerRegistry::Protection::CreateRuleService, '#execute', fea
it_behaves_like 'a successful service response'
end
- context 'when field `container_path_pattern` is taken' do
+ context 'when field `repository_path_pattern` is taken' do
let(:params) do
super().merge(
- container_path_pattern: existing_container_registry_protection_rule.container_path_pattern,
+ repository_path_pattern: existing_container_registry_protection_rule.repository_path_pattern,
push_protected_up_to_access_level: :maintainer
)
end
it_behaves_like 'an erroneous service response'
- it { is_expected.to have_attributes(errors: ['Container path pattern has already been taken']) }
+ it { is_expected.to have_attributes(errors: ['Repository path pattern has already been taken']) }
it { expect { subject }.not_to change { existing_container_registry_protection_rule.updated_at } }
end
diff --git a/spec/services/container_registry/protection/delete_rule_service_spec.rb b/spec/services/container_registry/protection/delete_rule_service_spec.rb
index bdc2ca727d2..acefe6a55d0 100644
--- a/spec/services/container_registry/protection/delete_rule_service_spec.rb
+++ b/spec/services/container_registry/protection/delete_rule_service_spec.rb
@@ -58,7 +58,7 @@ RSpec.describe ContainerRegistry::Protection::DeleteRuleService, '#execute', fea
context 'with deleted container registry protection rule' do
let!(:container_registry_protection_rule) do
create(:container_registry_protection_rule, project: project,
- container_path_pattern: 'protection_rule_deleted').destroy!
+ repository_path_pattern: 'protection_rule_deleted').destroy!
end
it_behaves_like 'a successful service response'
diff --git a/spec/services/import/github_service_spec.rb b/spec/services/import/github_service_spec.rb
index 39832ee4b13..fc649b61426 100644
--- a/spec/services/import/github_service_spec.rb
+++ b/spec/services/import/github_service_spec.rb
@@ -5,12 +5,7 @@ require 'spec_helper'
RSpec.describe Import::GithubService, feature_category: :importers do
let_it_be(:user) { create(:user) }
let_it_be(:token) { 'complex-token' }
- let_it_be(:access_params) do
- {
- github_access_token: 'github-complex-token',
- additional_access_tokens: %w[foo bar]
- }
- end
+ let_it_be(:access_params) { { github_access_token: 'github-complex-token' } }
let(:settings) { instance_double(Gitlab::GithubImport::Settings) }
let(:user_namespace_path) { user.namespace_path }
@@ -37,7 +32,6 @@ RSpec.describe Import::GithubService, feature_category: :importers do
.to receive(:write)
.with(
optional_stages: optional_stages,
- additional_access_tokens: access_params[:additional_access_tokens],
timeout_strategy: timeout_strategy
)
end
@@ -98,7 +92,6 @@ RSpec.describe Import::GithubService, feature_category: :importers do
expect(settings)
.to have_received(:write)
.with(optional_stages: nil,
- additional_access_tokens: access_params[:additional_access_tokens],
timeout_strategy: timeout_strategy
)
expect_snowplow_event(
@@ -124,7 +117,6 @@ RSpec.describe Import::GithubService, feature_category: :importers do
.to have_received(:write)
.with(
optional_stages: nil,
- additional_access_tokens: access_params[:additional_access_tokens],
timeout_strategy: timeout_strategy
)
expect_snowplow_event(
@@ -157,7 +149,6 @@ RSpec.describe Import::GithubService, feature_category: :importers do
.to have_received(:write)
.with(
optional_stages: nil,
- additional_access_tokens: access_params[:additional_access_tokens],
timeout_strategy: timeout_strategy
)
expect_snowplow_event(
@@ -194,7 +185,6 @@ RSpec.describe Import::GithubService, feature_category: :importers do
.to have_received(:write)
.with(
optional_stages: optional_stages,
- additional_access_tokens: access_params[:additional_access_tokens],
timeout_strategy: timeout_strategy
)
end
@@ -210,7 +200,6 @@ RSpec.describe Import::GithubService, feature_category: :importers do
.to have_received(:write)
.with(
optional_stages: optional_stages,
- additional_access_tokens: access_params[:additional_access_tokens],
timeout_strategy: timeout_strategy
)
end
@@ -224,7 +213,6 @@ RSpec.describe Import::GithubService, feature_category: :importers do
.to have_received(:write)
.with(
optional_stages: optional_stages,
- additional_access_tokens: %w[foo bar],
timeout_strategy: timeout_strategy
)
end
diff --git a/spec/workers/concerns/gitlab/github_import/object_importer_spec.rb b/spec/workers/concerns/gitlab/github_import/object_importer_spec.rb
index 0f7625713e3..bba855f5095 100644
--- a/spec/workers/concerns/gitlab/github_import/object_importer_spec.rb
+++ b/spec/workers/concerns/gitlab/github_import/object_importer_spec.rb
@@ -201,25 +201,22 @@ RSpec.describe Gitlab::GithubImport::ObjectImporter, :aggregate_failures, featur
expect(project.import_failures.last.exception_message).to eq('some error')
end
- context 'without github_identifiers defined' do
+ context 'when a NoMethod error is raised' do
let(:stubbed_representation) { representation_class.instance_eval { undef_method :github_identifiers } }
- it 'logs error when representation does not have a github_id' do
- expect(importer_class).not_to receive(:new)
-
+ it 'logs the error but does not re-raise it, so the worker does not retry' do
expect(Gitlab::Import::ImportFailureService)
.to receive(:track)
.with(
project_id: project.id,
exception: a_kind_of(NoMethodError),
error_source: 'klass_name',
- fail_import: true,
+ fail_import: false,
external_identifiers: { object_type: 'dummy' }
)
.and_call_original
- expect { worker.import(project, client, { 'number' => 10 }) }
- .to raise_error(NoMethodError, /^undefined method `github_identifiers/)
+ worker.import(project, client, { 'number' => 10 })
end
end
@@ -237,7 +234,7 @@ RSpec.describe Gitlab::GithubImport::ObjectImporter, :aggregate_failures, featur
.and_raise(exception)
end
- it 'logs an error' do
+ it 'logs the error but does not re-raise it, so the worker does not retry' do
expect(Gitlab::GithubImport::Logger)
.to receive(:info)
.with(