qat-reporter-xray-sa 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fc05318346ba2729e2e0cadf5107680c66af58801584e6a642857eba49a06b8b
|
4
|
+
data.tar.gz: 9eabaf67ebe585b6ce67304ad0789636e554cadf7a8c6626bf31f551f1b7eace
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9d96688a2db2b67e92454daf88c8d11bdd5c9c6179a0a1eb19ec8e67c8e6d6c4be2022e5c8ea06ad6211ab0cab922766d53a5791819b0f4f6d20b7b2f74ac1e7
|
7
|
+
data.tar.gz: 5ef5be87b3b73ee22cb74969f43e70f951b7ef397726405948dc665e428bfc5569b272123aa36f8c0623559953855a99ded3c26a611ac4d85340568053f2e70e
|
@@ -1,142 +1,151 @@
|
|
1
1
|
require_relative 'publisher'
|
2
2
|
|
3
3
|
module QAT
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
4
|
+
module Reporter
|
5
|
+
class Xray
|
6
|
+
# QAT::Reporter::Xray configuration module
|
7
|
+
module Config
|
8
|
+
class << self
|
9
|
+
|
10
|
+
attr_accessor :project_key, :jira_url, :xray_default_api_url, :xray_default_api_url_graphql, :login_credentials, :publisher, :jira_type,
|
11
|
+
:cloud_xray_api_credentials, :xray_test_environment, :xray_test_version, :xray_test_revision, :xray_export_test_keys, :xray_export_test_filter
|
12
|
+
|
13
|
+
# Default xray API url (Jira Cloud)
|
14
|
+
DEFAULT_XRAY_URL = 'https://xray.cloud.getxray.app'
|
15
|
+
DEFAULT_XRAY_GRAPHQL = 'https://xray.cloud.getxray.app/api/v2/graphql'
|
16
|
+
|
17
|
+
# Returns the xray instanced type (hosted or cloud)
|
18
|
+
def jira_type
|
19
|
+
@jira_type
|
20
|
+
end
|
21
|
+
|
22
|
+
# Returns the jira url
|
23
|
+
def jira_url
|
24
|
+
@jira_url
|
25
|
+
end
|
26
|
+
|
27
|
+
# Returns the default xray jira url for cloud api
|
28
|
+
def xray_default_api_url
|
29
|
+
DEFAULT_XRAY_URL
|
30
|
+
end
|
31
|
+
|
32
|
+
# Returns the default xray jira url for cloud api graphql
|
33
|
+
def xray_default_api_url_graphql
|
34
|
+
DEFAULT_XRAY_GRAPHQL
|
35
|
+
end
|
36
|
+
|
37
|
+
# Returns the login credentials array could -> [username, password, apiToken]
|
38
|
+
def login_credentials
|
39
|
+
@login_credentials
|
40
|
+
end
|
41
|
+
|
42
|
+
# Returns the login credentials array for cloud api [client_id, client_secret]
|
43
|
+
def cloud_xray_api_credentials
|
44
|
+
@cloud_xray_api_credentials || nil
|
45
|
+
end
|
46
|
+
|
47
|
+
# Returns the test keys to export
|
48
|
+
def xray_export_test_keys
|
49
|
+
@keys || nil
|
50
|
+
end
|
51
|
+
|
52
|
+
# Returns the test filter to export
|
53
|
+
def xray_export_test_filter
|
54
|
+
@filter || nil
|
55
|
+
end
|
56
|
+
|
57
|
+
# Returns the project key value
|
58
|
+
def project_key
|
59
|
+
@project_key
|
60
|
+
end
|
61
|
+
|
62
|
+
# Returns the xray test environment value
|
63
|
+
def xray_test_environment
|
64
|
+
@xray_test_environment || get_env_from_qat_config
|
65
|
+
end
|
66
|
+
|
67
|
+
# Returns the xray test version value
|
68
|
+
def xray_test_version
|
69
|
+
@xray_test_version || get_version_from_qat_config
|
70
|
+
end
|
71
|
+
|
72
|
+
# Returns the xray test revision value
|
73
|
+
def xray_test_revision
|
74
|
+
@xray_test_revision || get_revision_from_qat_config
|
75
|
+
end
|
76
|
+
|
77
|
+
def publisher=(publisher)
|
78
|
+
@publisher = publisher
|
79
|
+
end
|
80
|
+
|
81
|
+
def publisher
|
82
|
+
@publisher
|
83
|
+
end
|
84
|
+
|
85
|
+
private
|
86
|
+
|
87
|
+
def get_env_from_qat_config
|
88
|
+
begin
|
89
|
+
QAT.configuration.dig(:xray, :environment_name)
|
90
|
+
rescue ArgumentError
|
91
|
+
raise(NoEnvironmentDefined, 'JIRA\'s environment must be defined!')
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
def get_version_from_qat_config
|
96
|
+
begin
|
97
|
+
QAT.configuration.dig(:xray, :version)
|
98
|
+
rescue ArgumentError
|
99
|
+
raise(NoVersionDefined, 'JIRA\'s version must be defined!')
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
def get_revision_from_qat_config
|
104
|
+
begin
|
105
|
+
QAT.configuration.dig(:xray, :revision)
|
106
|
+
rescue ArgumentError
|
107
|
+
raise(NoRevisionDefined, 'JIRA\'s revision must be defined!')
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
# Error returned when the QAT project has not defined the Jira Environment
|
112
|
+
class NoEnvironmentDefined < StandardError
|
113
|
+
end
|
114
|
+
|
115
|
+
# Error returned when the QAT project has not defined the Jira Version
|
116
|
+
class NoVersionDefined < StandardError
|
117
|
+
end
|
118
|
+
|
119
|
+
# Error returned when the QAT project has not defined the Jira Revision
|
120
|
+
class NoRevisionDefined < StandardError
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
class << self
|
126
|
+
# Configures the QAT::Formatter::Xray
|
127
|
+
def configure(&block)
|
128
|
+
yield Config
|
129
|
+
|
130
|
+
QAT::Reporter::Xray::Config.publisher = QAT::Reporter::Xray::Publisher.const_get(QAT::Reporter::Xray::Config.jira_type.capitalize).new
|
131
|
+
|
132
|
+
raise(LoginCredentialsUndefinedError, 'JIRA\'s login credentials must be defined!') unless QAT::Reporter::Xray::Config.login_credentials
|
133
|
+
raise(PublisherUndefinedError, 'XRAY\'s publisher is not defined!') unless QAT::Reporter::Xray::Config.publisher.present?
|
134
|
+
return QAT::Reporter::Xray::Config.publisher
|
135
|
+
end
|
136
|
+
|
137
|
+
# Error returned when the the JIRA project key is not defined
|
138
|
+
class ProjectKeyUndefinedError < StandardError
|
139
|
+
end
|
140
|
+
|
141
|
+
# Error returned when the the JIRA login credentials is not defined
|
142
|
+
class LoginCredentialsUndefinedError < StandardError
|
143
|
+
end
|
144
|
+
|
145
|
+
# Error returned when not publisher was defined
|
146
|
+
class PublisherUndefinedError < StandardError
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
142
151
|
end
|
@@ -10,14 +10,15 @@ module QAT
|
|
10
10
|
module Publisher
|
11
11
|
# QAT::Reporter::Xray::Publisher::Base integrator class
|
12
12
|
class Base
|
13
|
-
attr_reader :base_url, :default_headers, :login_credentials, :default_cloud_api_url, :cloud_xray_api_credentials
|
13
|
+
attr_reader :base_url, :default_headers, :login_credentials, :default_cloud_api_url, :default_cloud_api_url_graphql, :cloud_xray_api_credentials
|
14
14
|
|
15
15
|
# Initializes Xray Publisher url and login information
|
16
16
|
def initialize
|
17
|
-
@base_url
|
18
|
-
@login_credentials
|
19
|
-
@default_cloud_api_url
|
20
|
-
@
|
17
|
+
@base_url = QAT::Reporter::Xray::Config.jira_url
|
18
|
+
@login_credentials = QAT::Reporter::Xray::Config.login_credentials
|
19
|
+
@default_cloud_api_url = QAT::Reporter::Xray::Config.xray_default_api_url
|
20
|
+
@default_cloud_api_url_graphql = QAT::Reporter::Xray::Config.xray_default_api_url_graphql
|
21
|
+
@cloud_xray_api_credentials = QAT::Reporter::Xray::Config.cloud_xray_api_credentials
|
21
22
|
end
|
22
23
|
|
23
24
|
# Creates a Jira issue
|
@@ -96,9 +97,8 @@ module QAT
|
|
96
97
|
|
97
98
|
# log_request operation, final_url, args
|
98
99
|
# begin
|
99
|
-
|
100
|
-
log_response response
|
101
|
-
response
|
100
|
+
RestClient.method(operation).call(final_url, *args)
|
101
|
+
#log_response response
|
102
102
|
# validate response
|
103
103
|
# rescue RestClient::ExceptionWithResponse => e
|
104
104
|
# puts e.response
|
@@ -8,6 +8,10 @@ module QAT
|
|
8
8
|
# QAT::Reporter::Xray::Publisher::Cloud integrator class
|
9
9
|
class Cloud < Base
|
10
10
|
|
11
|
+
def get_test_execution_graphql(issue)
|
12
|
+
Graphql.get_test_execution(issue, auth_headers, default_cloud_api_url_graphql)
|
13
|
+
end
|
14
|
+
|
11
15
|
def get_jira_issue(issue_key)
|
12
16
|
headers = { 'Content-Type': 'application/json' }.merge(auth_headers)
|
13
17
|
Client.new(base_url).get("/rest/api/3/issue/#{issue_key}", headers)
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require_relative 'base'
|
2
|
+
require "graphql/client"
|
3
|
+
require "graphql/client/http"
|
4
|
+
|
5
|
+
module QAT
|
6
|
+
module Reporter
|
7
|
+
class Xray
|
8
|
+
module Publisher
|
9
|
+
|
10
|
+
module Graphql
|
11
|
+
# Configure GraphQL endpoint using the basic HTTP network adapter.
|
12
|
+
HTTP = GraphQL::Client::HTTP.new(@url) do
|
13
|
+
def headers(context)
|
14
|
+
@headers
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
# Fetch latest schema on init, this will make a network request
|
19
|
+
GraphQL::Client.dump_schema(Graph::HTTP, "schema.json")
|
20
|
+
Schema = GraphQL::Client.load_schema('schema.json')
|
21
|
+
|
22
|
+
# However, it's smart to dump this to a JSON file and load from disk
|
23
|
+
#
|
24
|
+
# Run it from a script or rake task
|
25
|
+
# GraphQL::Client.dump_schema(SWAPI::HTTP, "path/to/schema.json")
|
26
|
+
#
|
27
|
+
# Schema = GraphQL::Client.load_schema("path/to/schema.json")
|
28
|
+
|
29
|
+
Client = GraphQL::Client.new(schema: Schema, execute: HTTP)
|
30
|
+
|
31
|
+
TestExecution = Graph::Client.parse <<-GRAPHQL
|
32
|
+
{
|
33
|
+
getTestExecution(issueId: "#{@issue}") {
|
34
|
+
issueId
|
35
|
+
tests(limit: 100) {
|
36
|
+
total
|
37
|
+
start
|
38
|
+
limit
|
39
|
+
results {
|
40
|
+
issueId
|
41
|
+
testType {
|
42
|
+
name
|
43
|
+
}
|
44
|
+
}
|
45
|
+
}
|
46
|
+
}
|
47
|
+
}
|
48
|
+
GRAPHQL
|
49
|
+
|
50
|
+
def self.get_test_execution(issue, headers, url)
|
51
|
+
@issue, @headers, @url = issue, headers, url
|
52
|
+
Graph::Client.query(TestExecution)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: qat-reporter-xray-sa
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- QAT
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-08-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: vcr
|
@@ -98,6 +98,20 @@ dependencies:
|
|
98
98
|
- - ">="
|
99
99
|
- !ruby/object:Gem::Version
|
100
100
|
version: '0'
|
101
|
+
- !ruby/object:Gem::Dependency
|
102
|
+
name: graphql-client
|
103
|
+
requirement: !ruby/object:Gem::Requirement
|
104
|
+
requirements:
|
105
|
+
- - ">="
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: '0'
|
108
|
+
type: :runtime
|
109
|
+
prerelease: false
|
110
|
+
version_requirements: !ruby/object:Gem::Requirement
|
111
|
+
requirements:
|
112
|
+
- - ">="
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: '0'
|
101
115
|
description: |2
|
102
116
|
QAT Report Xray Standalone belongs to QAT Report collection but stand alone version, so no dependencies from other
|
103
117
|
QAT gems are required.
|
@@ -113,6 +127,7 @@ files:
|
|
113
127
|
- lib/qat/reporter/xray/publisher.rb
|
114
128
|
- lib/qat/reporter/xray/publisher/base.rb
|
115
129
|
- lib/qat/reporter/xray/publisher/cloud.rb
|
130
|
+
- lib/qat/reporter/xray/publisher/graphql.rb
|
116
131
|
- lib/qat/reporter/xray/publisher/hosted.rb
|
117
132
|
- lib/qat/reporter/xray/tasks.rb
|
118
133
|
- lib/qat/reporter/xray/tasks/tests.rb
|