summaryrefslogtreecommitdiff
path: root/spec/support
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-06-29 14:30:51 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2022-06-29 14:30:51 +0000
commite74db6bfa85dbeb243dafcdbf03c0e5aff3f6069 (patch)
treeb10184090863fcb73ebcc444cc6123cdfd7f9520 /spec/support
parent5370ec1c3d27d646be672039e78161d22b1e2a80 (diff)
downloadgitlab-ce-e74db6bfa85dbeb243dafcdbf03c0e5aff3f6069.tar.gz
Add latest changes from gitlab-org/security/gitlab@15-1-stable-ee
Diffstat (limited to 'spec/support')
-rw-r--r--spec/support/shared_contexts/project_features_shared_context.rb28
-rw-r--r--spec/support/shared_examples/policies/project_policy_shared_examples.rb13
-rw-r--r--spec/support/shared_examples/services/container_registry_auth_service_shared_examples.rb6
3 files changed, 33 insertions, 14 deletions
diff --git a/spec/support/shared_contexts/project_features_shared_context.rb b/spec/support/shared_contexts/project_features_shared_context.rb
new file mode 100644
index 00000000000..40d9cb29c14
--- /dev/null
+++ b/spec/support/shared_contexts/project_features_shared_context.rb
@@ -0,0 +1,28 @@
+# frozen_string_literal: true
+
+RSpec.shared_context 'repository disabled via project features' do
+ before do
+ project.project_feature.update_columns(
+ # Disable merge_requests and builds as well, since merge_requests and
+ # builds cannot have higher visibility than repository.
+ merge_requests_access_level: ProjectFeature::DISABLED,
+ builds_access_level: ProjectFeature::DISABLED,
+ repository_access_level: ProjectFeature::DISABLED)
+ end
+end
+
+RSpec.shared_context 'registry disabled via project features' do
+ before do
+ project.project_feature.update_columns(
+ container_registry_access_level: ProjectFeature::DISABLED
+ )
+ end
+end
+
+RSpec.shared_context 'registry set to private via project features' do
+ before do
+ project.project_feature.update_columns(
+ container_registry_access_level: ProjectFeature::PRIVATE
+ )
+ end
+end
diff --git a/spec/support/shared_examples/policies/project_policy_shared_examples.rb b/spec/support/shared_examples/policies/project_policy_shared_examples.rb
index 63e4d458ad4..c4083df47e2 100644
--- a/spec/support/shared_examples/policies/project_policy_shared_examples.rb
+++ b/spec/support/shared_examples/policies/project_policy_shared_examples.rb
@@ -345,16 +345,7 @@ RSpec.shared_examples 'project policies as admin without admin mode' do
end
RSpec.shared_examples 'package access with repository disabled' do
- context 'when repository is disabled' do
- before do
- project.project_feature.update!(
- # Disable merge_requests and builds as well, since merge_requests and
- # builds cannot have higher visibility than repository.
- merge_requests_access_level: ProjectFeature::DISABLED,
- builds_access_level: ProjectFeature::DISABLED,
- repository_access_level: ProjectFeature::DISABLED)
- end
+ include_context 'repository disabled via project features'
- it { is_expected.to be_allowed(:read_package) }
- end
+ it { is_expected.to be_allowed(:read_package) }
end
diff --git a/spec/support/shared_examples/services/container_registry_auth_service_shared_examples.rb b/spec/support/shared_examples/services/container_registry_auth_service_shared_examples.rb
index 7677e5d8cb2..f18869fb380 100644
--- a/spec/support/shared_examples/services/container_registry_auth_service_shared_examples.rb
+++ b/spec/support/shared_examples/services/container_registry_auth_service_shared_examples.rb
@@ -142,9 +142,9 @@ RSpec.shared_examples 'logs an auth warning' do |requested_actions|
requested_project_path: project.full_path,
requested_actions: requested_actions,
authorized_actions: [],
- user_id: current_user.id,
- username: current_user.username
- }
+ user_id: current_user&.id,
+ username: current_user&.username
+ }.compact
end
it do