Commit de212bdf authored by Anastasia McDonald's avatar Anastasia McDonald

Merge branch 'group-deploy-token-api-resource' into 'master'

Fabricate group deploy token resource via API

See merge request gitlab-org/gitlab!75131
parents f5c62d08 fccd1ae7
...@@ -4,31 +4,46 @@ module QA ...@@ -4,31 +4,46 @@ module QA
module Resource module Resource
class GroupDeployToken < Base class GroupDeployToken < Base
attr_accessor :name, :expires_at attr_accessor :name, :expires_at
attr_writer :scopes
attribute :username do attribute :id
Page::Group::Settings::Repository.perform do |repository_page| attribute :token
repository_page.expand_deploy_tokens(&:token_username) attribute :username
attribute :group do
Group.fabricate! do |resource|
resource.name = 'group-with-deploy-token'
resource.description = 'group for adding deploy token test'
end end
end end
attribute :password do def fabricate_via_api!
Page::Group::Settings::Repository.perform do |repository_page| super
repository_page.expand_deploy_tokens(&:token_password)
end end
def api_get_path
"/groups/#{group.id}/deploy_tokens"
end end
attribute :group do def api_post_path
Group.fabricate! do |resource| api_get_path
resource.name = 'group-with-deploy-token'
resource.description = 'group for adding deploy token test'
end end
def api_post_body
{
name: @name,
scopes: @scopes
}
end end
attribute :project do def api_delete_path
Project.fabricate! do |resource| "/groups/#{group.id}/deploy_tokens/#{id}"
resource.name = 'project-to-deploy'
resource.description = 'project for adding deploy token test'
end end
def resource_web_url(resource)
super
rescue ResourceURLMissingError
# this particular resource does not expose a web_url property
end end
def fabricate! def fabricate!
......
...@@ -21,9 +21,14 @@ module QA ...@@ -21,9 +21,14 @@ module QA
end end
let(:group_deploy_token) do let(:group_deploy_token) do
Resource::GroupDeployToken.fabricate_via_browser_ui! do |deploy_token| Resource::GroupDeployToken.fabricate_via_api! do |deploy_token|
deploy_token.name = 'nuget-group-deploy-token' deploy_token.name = 'nuget-group-deploy-token'
deploy_token.group = project.group deploy_token.group = project.group
deploy_token.scopes = %w[
read_repository
read_package_registry
write_package_registry
]
end end
end end
...@@ -70,7 +75,7 @@ module QA ...@@ -70,7 +75,7 @@ module QA
when :ci_job_token when :ci_job_token
'${CI_JOB_TOKEN}' '${CI_JOB_TOKEN}'
when :group_deploy_token when :group_deploy_token
"\"#{group_deploy_token.password}\"" "\"#{group_deploy_token.token}\""
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment