qat-reporter-xray-sa 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 38d6b57f31e3eca19dc06fe60e05ca40d1913036ce926df4e541638b730295b4
4
- data.tar.gz: 46538af29e00d3038fe04d517019212587b98b26f966a6ab51ffb8a45ed07868
3
+ metadata.gz: fc05318346ba2729e2e0cadf5107680c66af58801584e6a642857eba49a06b8b
4
+ data.tar.gz: 9eabaf67ebe585b6ce67304ad0789636e554cadf7a8c6626bf31f551f1b7eace
5
5
  SHA512:
6
- metadata.gz: bff21ebb0f0b833b418c9aa9f285605e19b559db7a6c42abe2f85fad780497f212eb2ac80c0adac790e8f2ed826768a199453718130ca69be5e3bf19ac7b024e
7
- data.tar.gz: 33861c2deca303693bc5888f13e3946dc31e2b95252a0f72c81cec431348d792be44df4dfe6cc1e32bb017ccaba4f74de10be81adb19ec6c6e75bd5191e9d1ec
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
- 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, :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
-
16
- # Returns the xray instanced type (hosted or cloud)
17
- def jira_type
18
- @jira_type
19
- end
20
-
21
- # Returns the jira url
22
- def jira_url
23
- @jira_url
24
- end
25
-
26
- # Returns the default xray jira url for cloud api
27
- def xray_default_api_url
28
- DEFAULT_XRAY_URL
29
- end
30
-
31
- # Returns the login credentials array could -> [username, password, apiToken]
32
- def login_credentials
33
- @login_credentials
34
- end
35
-
36
- # Returns the login credentials array for cloud api [client_id, client_secret]
37
- def cloud_xray_api_credentials
38
- @cloud_xray_api_credentials || nil
39
- end
40
-
41
- # Returns the test keys to export
42
- def xray_export_test_keys
43
- @keys || nil
44
- end
45
-
46
- # Returns the test filter to export
47
- def xray_export_test_filter
48
- @filter || nil
49
- end
50
-
51
- # Returns the project key value
52
- def project_key
53
- @project_key
54
- end
55
-
56
- # Returns the xray test environment value
57
- def xray_test_environment
58
- @xray_test_environment || get_env_from_qat_config
59
- end
60
-
61
- # Returns the xray test version value
62
- def xray_test_version
63
- @xray_test_version || get_version_from_qat_config
64
- end
65
-
66
- # Returns the xray test revision value
67
- def xray_test_revision
68
- @xray_test_revision || get_revision_from_qat_config
69
- end
70
-
71
- def publisher=(publisher)
72
- @publisher = publisher
73
- end
74
-
75
- def publisher
76
- @publisher
77
- end
78
-
79
-
80
- private
81
-
82
- def get_env_from_qat_config
83
- begin
84
- QAT.configuration.dig(:xray, :environment_name)
85
- rescue ArgumentError
86
- raise(NoEnvironmentDefined, 'JIRA\'s environment must be defined!')
87
- end
88
- end
89
-
90
- def get_version_from_qat_config
91
- begin
92
- QAT.configuration.dig(:xray, :version)
93
- rescue ArgumentError
94
- raise(NoVersionDefined, 'JIRA\'s version must be defined!')
95
- end
96
- end
97
-
98
- def get_revision_from_qat_config
99
- begin
100
- QAT.configuration.dig(:xray, :revision)
101
- rescue ArgumentError
102
- raise(NoRevisionDefined, 'JIRA\'s revision must be defined!')
103
- end
104
- end
105
-
106
- # Error returned when the QAT project has not defined the Jira Environment
107
- class NoEnvironmentDefined < StandardError
108
- end
109
- # Error returned when the QAT project has not defined the Jira Version
110
- class NoVersionDefined < StandardError
111
- end
112
- # Error returned when the QAT project has not defined the Jira Revision
113
- class NoRevisionDefined < StandardError
114
- end
115
- end
116
- end
117
-
118
- class << self
119
- # Configures the QAT::Formatter::Xray
120
- def configure(&block)
121
- yield Config
122
-
123
- QAT::Reporter::Xray::Config.publisher = QAT::Reporter::Xray::Publisher.const_get(QAT::Reporter::Xray::Config.jira_type.capitalize).new
124
-
125
- raise(LoginCredentialsUndefinedError, 'JIRA\'s login credentials must be defined!') unless QAT::Reporter::Xray::Config.login_credentials
126
- raise(PublisherUndefinedError, 'XRAY\'s publisher is not defined!') unless QAT::Reporter::Xray::Config.publisher.present?
127
- return QAT::Reporter::Xray::Config.publisher
128
- end
129
-
130
- # Error returned when the the JIRA project key is not defined
131
- class ProjectKeyUndefinedError < StandardError
132
- end
133
- # Error returned when the the JIRA login credentials is not defined
134
- class LoginCredentialsUndefinedError < StandardError
135
- end
136
- # Error returned when not publisher was defined
137
- class PublisherUndefinedError < StandardError
138
- end
139
- end
140
- end
141
- end
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 = 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
- @cloud_xray_api_credentials = QAT::Reporter::Xray::Config.cloud_xray_api_credentials
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
- response = RestClient.method(operation).call(final_url, *args)
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
@@ -5,7 +5,7 @@ module QAT
5
5
  # Namespace for QAT Reporter's Xray integrations
6
6
  class Xray
7
7
  # Represents QAT Reporter's Xray integrations' version
8
- VERSION = '1.0.0'
8
+ VERSION = '1.1.0'
9
9
  end
10
10
  end
11
11
  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.0.0
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-07-29 00:00:00.000000000 Z
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