Class: QAT::Reporter::Xray::Publisher::Cloud
- Defined in:
- lib/qat/reporter/xray/publisher/cloud.rb
Overview
QAT::Reporter::Xray::Publisher::Cloud integrator class
Instance Attribute Summary
Attributes inherited from Base
#base_url, #cloud_xray_api_credentials, #default_cloud_api_url, #default_headers, #login_credentials
Instance Method Summary collapse
-
#auth_token ⇒ Object
Get the Authorization Token based on client_id & client_secret (ONLY FOR CLOUD XRAY).
-
#export_test_scenarios(keys, filter = nil) ⇒ Object
Export Xray test scenarios to a zip file via API.
- #get_jira_issue(issue_key) ⇒ Object
- #get_jira_linked_issue(linked_issue_id) ⇒ Object
- #get_project(project_key) ⇒ Object
-
#get_transitions(issue_key) ⇒ Object
Get workflow transitions of an issue.
- #import_cucumber_behave_tests(info, results) ⇒ Object
-
#import_cucumber_tests(project_key, file_path, project_id = nil) ⇒ Object
Import Cucumber features files as a zip file via API.
-
#send_execution_results(results) ⇒ Object
Posts the execution json results in Xray.
-
#transitions_issue(issue_key, payload) ⇒ Object
Change transition issue.
- #update_jira_issue(issue_key, payload) ⇒ Object
Methods inherited from Base
#cloud_graphql_headers, #create_issue, #initialize
Constructor Details
This class inherits a constructor from QAT::Reporter::Xray::Publisher::Base
Instance Method Details
#auth_token ⇒ Object
Get the Authorization Token based on client_id & client_secret (ONLY FOR CLOUD XRAY)
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/qat/reporter/xray/publisher/cloud.rb', line 49 def auth_token return @auth_token if @auth_token client_id = cloud_xray_api_credentials[0] client_secret = cloud_xray_api_credentials[1] auth_header_cloud = { client_id: client_id, client_secret: client_secret } response = Client.new(default_cloud_api_url).post('/api/v1/authenticate', auth_header_cloud).body bearer = JSON.parse(response) @auth_token = { Authorization: "Bearer #{bearer}" } end |
#export_test_scenarios(keys, filter = nil) ⇒ Object
Export Xray test scenarios to a zip file via API
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/qat/reporter/xray/publisher/cloud.rb', line 98 def export_test_scenarios(keys, filter = nil) params = { keys: keys, } params[:filter] = filter if filter.present? headers = auth_token.merge(params: params) puts "Exporting features from: #{default_cloud_api_url}/api/v1/export/cucumber" all_tests = RestClient.get("#{default_cloud_api_url}/api/v1/export/cucumber", headers) raise(NoTestsFoundError, "No Tests found for keys: #{keys}") if all_tests.code != 200 all_test_keys = all_tests.body.to_s.scan(/(@TEST_\w+-\d+)/).flatten (0...all_test_keys.count).to_a.map do |index| { test_issue_key: all_test_keys[index].gsub('@TEST_', '') } end end |
#get_jira_issue(issue_key) ⇒ Object
10 11 12 13 |
# File 'lib/qat/reporter/xray/publisher/cloud.rb', line 10 def get_jira_issue(issue_key) headers = { 'Content-Type': 'application/json' }.merge(auth_headers) Client.new(base_url).get("/rest/api/3/issue/#{issue_key}", headers) end |
#get_jira_linked_issue(linked_issue_id) ⇒ Object
20 21 22 23 |
# File 'lib/qat/reporter/xray/publisher/cloud.rb', line 20 def get_jira_linked_issue(linked_issue_id) headers = { 'Content-Type': 'application/json' }.merge(auth_headers) Client.new(base_url).get("/rest/api/3/issueLink/#{linked_issue_id}", headers) end |
#get_project(project_key) ⇒ Object
25 26 27 28 |
# File 'lib/qat/reporter/xray/publisher/cloud.rb', line 25 def get_project(project_key) headers = { 'Content-Type': 'application/json' }.merge(auth_headers) Client.new(base_url).get("/rest/api/3/project/#{project_key}", headers) end |
#get_transitions(issue_key) ⇒ Object
Get workflow transitions of an issue
31 32 33 34 |
# File 'lib/qat/reporter/xray/publisher/cloud.rb', line 31 def get_transitions(issue_key) headers = { 'Content-Type': 'application/json' }.merge(auth_headers) Client.new(base_url).get("/rest/api/2/issue/#{issue_key}/transitions", headers) end |
#import_cucumber_behave_tests(info, results) ⇒ Object
66 67 68 69 70 71 72 73 74 |
# File 'lib/qat/reporter/xray/publisher/cloud.rb', line 66 def import_cucumber_behave_tests(info, results) headers = { 'Content-Type': 'multipart/form-data' }.merge(auth_token) payload = { info: File.new(info, 'rb'), results: File.new(results, 'rb') } Client.new(default_cloud_api_url).post('/api/v2/import/execution/behave/multipart', payload, headers) end |
#import_cucumber_tests(project_key, file_path, project_id = nil) ⇒ Object
Import Cucumber features files as a zip file via API
80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/qat/reporter/xray/publisher/cloud.rb', line 80 def import_cucumber_tests(project_key, file_path, project_id = nil) headers = auth_token.merge({ multipart: true, params: { projectKey: project_key, projectId: project_id, source: project_key } }) payload = { file: File.new(file_path, 'rb') } Client.new(default_cloud_api_url).post('/api/v1/import/feature', payload, headers) end |
#send_execution_results(results) ⇒ Object
Posts the execution json results in Xray
43 44 45 46 |
# File 'lib/qat/reporter/xray/publisher/cloud.rb', line 43 def send_execution_results(results) headers = { 'Content-Type': 'application/json' }.merge(auth_token) Client.new(default_cloud_api_url).post('/api/v1/import/execution', results.to_json, headers) end |
#transitions_issue(issue_key, payload) ⇒ Object
Change transition issue
37 38 39 40 |
# File 'lib/qat/reporter/xray/publisher/cloud.rb', line 37 def transitions_issue(issue_key, payload) headers = { 'Content-Type': 'application/json' }.merge(auth_headers) Client.new(base_url).post("/rest/api/2/issue/#{issue_key}/transitions", payload.to_json, headers) end |
#update_jira_issue(issue_key, payload) ⇒ Object
15 16 17 18 |
# File 'lib/qat/reporter/xray/publisher/cloud.rb', line 15 def update_jira_issue(issue_key, payload) headers = { 'Content-Type': 'application/json' }.merge(auth_headers) Client.new(base_url).put("/rest/api/2/issue/#{issue_key}", payload.to_json, headers) end |