Class: QAT::Reporter::Xray::Publisher::Cloud

Inherits:
Base
  • Object
show all
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

Methods inherited from Base

#create_issue, #initialize

Constructor Details

This class inherits a constructor from QAT::Reporter::Xray::Publisher::Base

Instance Method Details

#auth_tokenObject

Get the Authorization Token based on client_id & client_secret (ONLY FOR CLOUD XRAY)



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/qat/reporter/xray/publisher/cloud.rb', line 18

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) ⇒ Object

Export Xray test scenarios to a zip file via API

Parameters:

  • keys (String)

    test scenarios

  • filter (String)

    project filter

See Also:



57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/qat/reporter/xray/publisher/cloud.rb', line 57

def export_test_scenarios(keys, filter)
  params          = {
    keys: keys,
  }
  params[:filter] = filter unless filter == 'nil'

  headers = auth_token.merge(params: params)

  log.info "Exporting features from: #{default_cloud_api_url}/api/v1/export/cucumber"
  rsp = RestClient.get("#{default_cloud_api_url}/api/v1/export/cucumber", headers)

  extract_feature_files(rsp)
end

#import_cucumber_tests(project_key, file_path, project_id = nil) ⇒ Object

Import Cucumber features files as a zip file via API

Parameters:

  • project_key (String)

    JIRA’s project key

  • file_path (String)

    Cucumber features files’ zip file

See Also:



39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/qat/reporter/xray/publisher/cloud.rb', line 39

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



12
13
14
15
# File 'lib/qat/reporter/xray/publisher/cloud.rb', line 12

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