diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-01-10 20:37:25 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-01-10 20:37:52 +0000 |
commit | c6983662116bcf5313cca0165499f14345788c28 (patch) | |
tree | 8d31e97edc29cc8abdb6ded6867b9af567d5d03e /spec | |
parent | 1eef146c2d1de19d4e995d421e5787053e50db80 (diff) | |
download | gitlab-ce-c6983662116bcf5313cca0165499f14345788c28.tar.gz |
Add latest changes from gitlab-org/security/gitlab@14-6-stable-ee
Diffstat (limited to 'spec')
-rw-r--r-- | spec/requests/api/projects_spec.rb | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/spec/requests/api/projects_spec.rb b/spec/requests/api/projects_spec.rb index 79dbbd20d83..8406ded85d8 100644 --- a/spec/requests/api/projects_spec.rb +++ b/spec/requests/api/projects_spec.rb @@ -3138,6 +3138,29 @@ RSpec.describe API::Projects do expect(json_response['message']).to eq('404 Project Not Found') end + it 'returns 404 if the source project members cannot be viewed by the requester' do + private_project = create(:project, :private) + + expect do + post api("/projects/#{project.id}/import_project_members/#{private_project.id}", user) + end.not_to change { project.members.count } + + expect(response).to have_gitlab_http_status(:not_found) + expect(json_response['message']).to eq('404 Project Not Found') + end + + it 'returns 403 if the source project members cannot be administered by the requester' do + project.add_maintainer(user2) + project2.add_developer(user2) + + expect do + post api("/projects/#{project.id}/import_project_members/#{project2.id}", user2) + end.not_to change { project.members.count } + + expect(response).to have_gitlab_http_status(:forbidden) + expect(json_response['message']).to eq('403 Forbidden - Project') + end + it 'returns 422 if the import failed for valid projects' do allow_next_instance_of(::ProjectTeam) do |project_team| allow(project_team).to receive(:import).and_return(false) |