From 6438df3a1e0fb944485cebf07976160184697d72 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Wed, 20 Jan 2021 13:34:23 -0600 Subject: Add latest changes from gitlab-org/gitlab@13-8-stable-ee --- qa/qa/resource/clusters/agent.rb | 54 ++++++++++++++++++++++++++++++++++ qa/qa/resource/clusters/agent_token.rb | 49 ++++++++++++++++++++++++++++++ qa/qa/resource/protected_branch.rb | 2 +- 3 files changed, 104 insertions(+), 1 deletion(-) create mode 100644 qa/qa/resource/clusters/agent.rb create mode 100644 qa/qa/resource/clusters/agent_token.rb (limited to 'qa/qa/resource') diff --git a/qa/qa/resource/clusters/agent.rb b/qa/qa/resource/clusters/agent.rb new file mode 100644 index 00000000000..cad5a4c6b1d --- /dev/null +++ b/qa/qa/resource/clusters/agent.rb @@ -0,0 +1,54 @@ +# frozen_string_literal: true + +module QA + module Resource + module Clusters + class Agent < QA::Resource::Base + attribute :id + attribute :name + attribute :project do + QA::Resource::Project.fabricate_via_api! do |project| + project.name = 'project-with-cluster-agent' + end + end + + def initialize + @name = "my-agent" + end + + def fabricate! + puts 'TODO: FABRICATE VIA UI' + end + # TODO + # + # The UI for this model is not yet implemented. So far it can only be + # created through the GraphQL API + # def fabricate + # + # end + + def api_get_path + "gid://gitlab/Clusters::Agent/#{id}" + end + + def api_post_path + "/graphql" + end + + def api_post_body + <<~GQL + mutation createAgent { + createClusterAgent(input: { projectPath: "#{project.full_path}", name: "#{@name}" }) { + clusterAgent { + id + name + } + errors + } + } + GQL + end + end + end + end +end diff --git a/qa/qa/resource/clusters/agent_token.rb b/qa/qa/resource/clusters/agent_token.rb new file mode 100644 index 00000000000..6a5e861b650 --- /dev/null +++ b/qa/qa/resource/clusters/agent_token.rb @@ -0,0 +1,49 @@ +# frozen_string_literal: true + +module QA + module Resource + module Clusters + class AgentToken < QA::Resource::Base + attribute :id + attribute :secret + attribute :agent do + QA::Resource::Clusters::Agent.fabricate_via_api! + end + + def fabricate! + puts 'TODO: FABRICATE VIA UI' + end + # TODO + # + # The UI for this model is not yet implemented. So far it can only be + # created through the GraphQL API + # def fabricate + # + # end + + def api_get_path + "gid://gitlab/Clusters::AgentToken/#{id}" + end + + def api_post_path + "/graphql" + end + + def api_post_body + <<~GQL + mutation createToken { + clusterAgentTokenCreate(input: { clusterAgentId: "gid://gitlab/Clusters::Agent/#{agent.id}" }) { + secret # This is the value you need to use on the next step + token { + createdAt + id + } + errors + } + } + GQL + end + end + end + end +end diff --git a/qa/qa/resource/protected_branch.rb b/qa/qa/resource/protected_branch.rb index 51ea9d1c5b9..7eb5442a964 100644 --- a/qa/qa/resource/protected_branch.rb +++ b/qa/qa/resource/protected_branch.rb @@ -22,7 +22,7 @@ module QA Resource::Repository::Commit.fabricate_via_api! do |commit| commit.project = project commit.branch = branch_name - commit.start_branch = 'master' + commit.start_branch = project.default_branch commit.commit_message = 'Add new file' commit.add_files([ { file_path: "new_file-#{SecureRandom.hex(8)}.md", content: 'new file' } -- cgit v1.2.1