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>2021-10-27 16:06:17 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-10-27 16:06:17 +0300
commit8cf3b9ab464420af642931a89f5fb24c65b1338d (patch)
treebbe9873aef1a15764fe668258f6aea4e0efac2eb /spec
parentc1c828ac7f7b3c2e51d81921bbef9d474cd4d0a4 (diff)
Add latest changes from gitlab-org/security/gitlab@14-4-stable-ee
Diffstat (limited to 'spec')
-rw-r--r--spec/requests/api/groups_spec.rb18
-rw-r--r--spec/requests/api/projects_spec.rb22
2 files changed, 40 insertions, 0 deletions
diff --git a/spec/requests/api/groups_spec.rb b/spec/requests/api/groups_spec.rb
index 2c7e2ecff85..cee727ae6fe 100644
--- a/spec/requests/api/groups_spec.rb
+++ b/spec/requests/api/groups_spec.rb
@@ -879,6 +879,15 @@ RSpec.describe API::Groups do
expect(json_response['prevent_sharing_groups_outside_hierarchy']).to eq(true)
end
+ it 'does not update visibility_level if it is restricted' do
+ stub_application_setting(restricted_visibility_levels: [Gitlab::VisibilityLevel::INTERNAL])
+
+ put api("/groups/#{group1.id}", user1), params: { visibility: 'internal' }
+
+ expect(response).to have_gitlab_http_status(:bad_request)
+ expect(json_response['message']['visibility_level']).to include('internal has been restricted by your GitLab administrator')
+ end
+
context 'updating the `default_branch_protection` attribute' do
subject do
put api("/groups/#{group1.id}", user1), params: { default_branch_protection: ::Gitlab::Access::PROTECTION_NONE }
@@ -966,6 +975,15 @@ RSpec.describe API::Groups do
expect(response).to have_gitlab_http_status(:ok)
expect(json_response['name']).to eq(new_group_name)
end
+
+ it 'ignores visibility level restrictions' do
+ stub_application_setting(restricted_visibility_levels: [Gitlab::VisibilityLevel::INTERNAL])
+
+ put api("/groups/#{group1.id}", admin), params: { visibility: 'internal' }
+
+ expect(response).to have_gitlab_http_status(:ok)
+ expect(json_response['visibility']).to eq('internal')
+ end
end
context 'when authenticated as an user that can see the group' do
diff --git a/spec/requests/api/projects_spec.rb b/spec/requests/api/projects_spec.rb
index 9b23c008ae7..dd6afa869e0 100644
--- a/spec/requests/api/projects_spec.rb
+++ b/spec/requests/api/projects_spec.rb
@@ -3203,6 +3203,15 @@ RSpec.describe API::Projects do
expect(json_response['visibility']).to eq('private')
end
+ it 'does not update visibility_level if it is restricted' do
+ stub_application_setting(restricted_visibility_levels: [Gitlab::VisibilityLevel::INTERNAL])
+
+ put api("/projects/#{project3.id}", user), params: { visibility: 'internal' }
+
+ expect(response).to have_gitlab_http_status(:bad_request)
+ expect(json_response['message']['visibility_level']).to include('internal has been restricted by your GitLab administrator')
+ end
+
it 'does not update name to existing name' do
project_param = { name: project3.name }
@@ -3526,6 +3535,19 @@ RSpec.describe API::Projects do
end
end
+ context 'when authenticated as the admin' do
+ let_it_be(:admin) { create(:admin) }
+
+ it 'ignores visibility level restrictions' do
+ stub_application_setting(restricted_visibility_levels: [Gitlab::VisibilityLevel::INTERNAL])
+
+ put api("/projects/#{project3.id}", admin), params: { visibility: 'internal' }
+
+ expect(response).to have_gitlab_http_status(:ok)
+ expect(json_response['visibility']).to eq('internal')
+ end
+ end
+
context 'when updating repository storage' do
let(:unknown_storage) { 'new-storage' }
let(:new_project) { create(:project, :repository, namespace: user.namespace) }