diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-06-20 14:10:13 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-06-20 14:10:13 +0300 |
commit | 0ea3fcec397b69815975647f5e2aa5fe944a8486 (patch) | |
tree | 7979381b89d26011bcf9bdc989a40fcc2f1ed4ff /spec/services/resource_access_tokens | |
parent | 72123183a20411a36d607d70b12d57c484394c8e (diff) |
Add latest changes from gitlab-org/gitlab@15-1-stable-eev15.1.0-rc42
Diffstat (limited to 'spec/services/resource_access_tokens')
-rw-r--r-- | spec/services/resource_access_tokens/create_service_spec.rb | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/spec/services/resource_access_tokens/create_service_spec.rb b/spec/services/resource_access_tokens/create_service_spec.rb index 5a88929334b..127948549b0 100644 --- a/spec/services/resource_access_tokens/create_service_spec.rb +++ b/spec/services/resource_access_tokens/create_service_spec.rb @@ -268,10 +268,36 @@ RSpec.describe ResourceAccessTokens::CreateService do end it_behaves_like 'allows creation of bot with valid params' + + context 'when user specifies an access level of OWNER for the bot' do + let_it_be(:params) { { access_level: Gitlab::Access::OWNER } } + + context 'when the executor is a MAINTAINER' do + it 'does not add the bot user with the specified access level in the resource' do + response = subject + + expect(response.error?).to be true + expect(response.errors).to include('Could not provision owner access to project access token') + end + end + + context 'when the executor is an OWNER' do + let_it_be(:user) { project.first_owner } + + it 'adds the bot user with the specified access level in the resource' do + response = subject + + access_token = response.payload[:access_token] + bot_user = access_token.user + + expect(resource.members.owners.map(&:user_id)).to include(bot_user.id) + end + end + end end end - context 'when resource is a project' do + context 'when resource is a group' do let_it_be(:resource_type) { 'group' } let_it_be(:resource) { group } @@ -283,6 +309,18 @@ RSpec.describe ResourceAccessTokens::CreateService do end it_behaves_like 'allows creation of bot with valid params' + + context 'when user specifies an access level of OWNER for the bot' do + let_it_be(:params) { { access_level: Gitlab::Access::OWNER } } + + it 'adds the bot user with the specified access level in the resource' do + response = subject + access_token = response.payload[:access_token] + bot_user = access_token.user + + expect(resource.members.owners.map(&:user_id)).to include(bot_user.id) + end + end end end end |