summaryrefslogtreecommitdiff
path: root/qa/qa/resource
diff options
context:
space:
mode:
authorRobert Speicher <rspeicher@gmail.com>2021-01-20 13:34:23 -0600
committerRobert Speicher <rspeicher@gmail.com>2021-01-20 13:34:23 -0600
commit6438df3a1e0fb944485cebf07976160184697d72 (patch)
tree00b09bfd170e77ae9391b1a2f5a93ef6839f2597 /qa/qa/resource
parent42bcd54d971da7ef2854b896a7b34f4ef8601067 (diff)
downloadgitlab-ce-6438df3a1e0fb944485cebf07976160184697d72.tar.gz
Add latest changes from gitlab-org/gitlab@13-8-stable-eev13.8.0-rc42
Diffstat (limited to 'qa/qa/resource')
-rw-r--r--qa/qa/resource/clusters/agent.rb54
-rw-r--r--qa/qa/resource/clusters/agent_token.rb49
-rw-r--r--qa/qa/resource/protected_branch.rb2
3 files changed, 104 insertions, 1 deletions
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' }