ci_toolkit 1.5.24 → 1.6.1

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: dd562f4fd521be367616dd224494af02a37431c7a2e7ad04cfdb3e021b64456f
4
- data.tar.gz: a51db4bc721f309482748d1852387abcec89aec95745607d726ca0834f85c678
3
+ metadata.gz: e72169e62cce70b95ff7872f841a40721103289b06792dc18863d08f5d5aa535
4
+ data.tar.gz: fba0e495ebd1c8e69efa917a1fb159078e42df29dc2a805fda7175bcb0992269
5
5
  SHA512:
6
- metadata.gz: cdd2864b3d4a3958c141edb99f70616589fbe3fa04140aa80ab01348ca750dfcf5300216355c05f9d21593f4467dec9d7be32d49098ef33452337ce4e597323f
7
- data.tar.gz: 74fbcf1d6572a201d4f46f73113b155d5de74710b2fb7151d7580ba6bc137b635e1dff90f061e5c9471c75b2cf1a4e318c23ad1c860e7c5aade894c30815769e
6
+ metadata.gz: 1ea49531735be387235cb0481ba039ae6f964e21055e0769b788e05c1417a6406386226b2f304edaee1a45d753f4793b7701c705152db8f2e88e485ca9957495
7
+ data.tar.gz: c4210324b27bf7b0b591627fd29bdd8790f3b0ae1acae963c02da0e1745e3485fd544ead1448d4c30c81a9ea8fb2f51d9cb5d375fa7a811bfa2c4ad5e85cee57
data/.rubocop.yml CHANGED
@@ -21,4 +21,7 @@ Metrics/BlockLength:
21
21
  RSpec/MultipleExpectations:
22
22
  Max: 5
23
23
  RSpec/ExampleLength:
24
- Max: 20
24
+ Max: 20
25
+
26
+ RSpec/VerifiedDoubleReference:
27
+ Enabled: false
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ci_toolkit (1.5.24)
4
+ ci_toolkit (1.6.1)
5
5
  faraday
6
6
  faraday-multipart
7
7
  faraday_middleware
@@ -14,22 +14,23 @@ PATH
14
14
  GEM
15
15
  remote: https://rubygems.org/
16
16
  specs:
17
- addressable (2.8.0)
18
- public_suffix (>= 2.0.2, < 5.0)
17
+ addressable (2.8.4)
18
+ public_suffix (>= 2.0.2, < 6.0)
19
19
  ast (2.4.2)
20
- date (3.2.1)
21
- diff-lcs (1.4.4)
20
+ date (3.3.3)
21
+ diff-lcs (1.5.0)
22
22
  docile (1.4.0)
23
- faraday (1.8.0)
23
+ faraday (1.10.3)
24
24
  faraday-em_http (~> 1.0)
25
25
  faraday-em_synchrony (~> 1.0)
26
26
  faraday-excon (~> 1.1)
27
- faraday-httpclient (~> 1.0.1)
27
+ faraday-httpclient (~> 1.0)
28
+ faraday-multipart (~> 1.0)
28
29
  faraday-net_http (~> 1.0)
29
- faraday-net_http_persistent (~> 1.1)
30
+ faraday-net_http_persistent (~> 1.0)
30
31
  faraday-patron (~> 1.0)
31
32
  faraday-rack (~> 1.0)
32
- multipart-post (>= 1.2, < 3)
33
+ faraday-retry (~> 1.0)
33
34
  ruby2_keywords (>= 0.0.4)
34
35
  faraday-em_http (1.0.0)
35
36
  faraday-em_synchrony (1.0.0)
@@ -41,6 +42,7 @@ GEM
41
42
  faraday-net_http_persistent (1.2.0)
42
43
  faraday-patron (1.0.0)
43
44
  faraday-rack (1.0.0)
45
+ faraday-retry (1.0.3)
44
46
  faraday_middleware (1.2.0)
45
47
  faraday (~> 1.0)
46
48
  gitlab (4.19.0)
@@ -49,38 +51,36 @@ GEM
49
51
  httparty (0.21.0)
50
52
  mini_mime (>= 1.0.0)
51
53
  multi_xml (>= 0.5.2)
52
- ipaddr (1.2.3)
53
- json (2.5.1)
54
- jwt (2.3.0)
54
+ json (2.6.3)
55
+ jwt (2.7.0)
55
56
  mini_mime (1.1.2)
56
57
  multi_xml (0.6.0)
57
- multipart-post (2.1.1)
58
- octokit (4.21.0)
59
- faraday (>= 0.9)
60
- sawyer (~> 0.8.0, >= 0.5.3)
61
- openssl (2.2.1)
62
- ipaddr
58
+ multipart-post (2.3.0)
59
+ octokit (6.1.1)
60
+ faraday (>= 1, < 3)
61
+ sawyer (~> 0.9)
62
+ openssl (3.1.0)
63
63
  parallel (1.23.0)
64
64
  parser (3.2.2.1)
65
65
  ast (~> 2.4.1)
66
- public_suffix (4.0.6)
66
+ public_suffix (5.0.1)
67
67
  rainbow (3.1.1)
68
68
  rake (13.0.6)
69
69
  regexp_parser (2.8.0)
70
70
  rexml (3.2.5)
71
- rspec (3.10.0)
72
- rspec-core (~> 3.10.0)
73
- rspec-expectations (~> 3.10.0)
74
- rspec-mocks (~> 3.10.0)
75
- rspec-core (3.10.1)
76
- rspec-support (~> 3.10.0)
77
- rspec-expectations (3.10.1)
71
+ rspec (3.12.0)
72
+ rspec-core (~> 3.12.0)
73
+ rspec-expectations (~> 3.12.0)
74
+ rspec-mocks (~> 3.12.0)
75
+ rspec-core (3.12.2)
76
+ rspec-support (~> 3.12.0)
77
+ rspec-expectations (3.12.3)
78
78
  diff-lcs (>= 1.2.0, < 2.0)
79
- rspec-support (~> 3.10.0)
80
- rspec-mocks (3.10.2)
79
+ rspec-support (~> 3.12.0)
80
+ rspec-mocks (3.12.5)
81
81
  diff-lcs (>= 1.2.0, < 2.0)
82
- rspec-support (~> 3.10.0)
83
- rspec-support (3.10.2)
82
+ rspec-support (~> 3.12.0)
83
+ rspec-support (3.12.0)
84
84
  rubocop (1.51.0)
85
85
  json (~> 2.3)
86
86
  parallel (~> 1.10)
@@ -93,16 +93,22 @@ GEM
93
93
  unicode-display_width (>= 2.4.0, < 3.0)
94
94
  rubocop-ast (1.28.1)
95
95
  parser (>= 3.2.1.0)
96
+ rubocop-capybara (2.18.0)
97
+ rubocop (~> 1.41)
98
+ rubocop-factory_bot (2.23.1)
99
+ rubocop (~> 1.33)
96
100
  rubocop-rake (0.6.0)
97
101
  rubocop (~> 1.0)
98
- rubocop-rspec (2.5.0)
99
- rubocop (~> 1.19)
102
+ rubocop-rspec (2.22.0)
103
+ rubocop (~> 1.33)
104
+ rubocop-capybara (~> 2.17)
105
+ rubocop-factory_bot (~> 2.22)
100
106
  ruby-progressbar (1.13.0)
101
107
  ruby2_keywords (0.0.5)
102
- sawyer (0.8.2)
108
+ sawyer (0.9.2)
103
109
  addressable (>= 2.3.5)
104
- faraday (> 0.8, < 2.0)
105
- simplecov (0.21.2)
110
+ faraday (>= 0.17.3, < 3)
111
+ simplecov (0.22.0)
106
112
  docile (~> 1.1)
107
113
  simplecov-html (~> 0.11)
108
114
  simplecov_json_formatter (~> 0.1)
@@ -110,16 +116,17 @@ GEM
110
116
  simplecov-json (0.2.3)
111
117
  json
112
118
  simplecov
113
- simplecov_json_formatter (0.1.3)
119
+ simplecov_json_formatter (0.1.4)
114
120
  terminal-table (3.0.2)
115
121
  unicode-display_width (>= 1.1.1, < 3)
116
- time (0.2.0)
122
+ time (0.2.2)
117
123
  date
118
124
  unicode-display_width (2.4.2)
119
125
 
120
126
  PLATFORMS
121
127
  universal-darwin-20
122
128
  x86_64-darwin-21
129
+ x86_64-darwin-22
123
130
  x86_64-linux
124
131
 
125
132
  DEPENDENCIES
data/ci_toolkit.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "ci_toolkit"
5
- spec.version = "1.5.24"
5
+ spec.version = "1.6.1"
6
6
  spec.authors = ["Gero Keller"]
7
7
  spec.email = ["gero.f.keller@gmail.com"]
8
8
 
@@ -7,7 +7,6 @@ require "faraday/multipart"
7
7
  module CiToolkit
8
8
  # A client for Seetest webservice.
9
9
  # See API doc for more info: https://docs.experitest.com/display/PM/How+To+Execute+Rest+API
10
- # rubocop:disable Metrics/ClassLength
11
10
  class SeeTestClient
12
11
  SUCCESS = "SUCCESS"
13
12
  OKAY = "OK"
@@ -19,52 +18,40 @@ module CiToolkit
19
18
  @faraday_conn = bot.faraday_conn
20
19
  end
21
20
 
22
- # rubocop:disable Metrics/AbcSize
23
- # rubocop:disable Metrics/MethodLength
24
21
  def upload_file(
25
22
  project_name:,
26
23
  unique_name:,
27
24
  full_path_to_file:,
28
25
  content_type: "application/octet-stream"
29
26
  )
30
- response = faraday_upload(
31
- project_name,
32
- unique_name,
33
- full_path_to_file,
34
- content_type
35
- ).body
36
-
37
- # Application already exists. Replace it.
38
- if response[:status] == SUCCESS && response[:data][:created] == "false"
39
- response = replace_existing_application(
40
- response[:data][:id],
41
- project_name,
42
- unique_name,
43
- full_path_to_file,
44
- content_type
45
- )
46
- # Application with unique name already exist. Replace it.
47
- elsif response[:status] == ERROR && !response[:data].nil? && !response[:data][:uniqueName].nil?
48
- response = replace_existing_application_by_unique_name(
49
- project_name,
50
- unique_name,
51
- full_path_to_file,
52
- content_type
53
- )
54
- end
55
27
 
56
- unless response[:status] == SUCCESS
28
+ response = upload_or_replace(project_name, unique_name, full_path_to_file, content_type)
29
+
30
+ unless response["status"] == SUCCESS
57
31
  raise StandardError,
58
32
  "Upload response from Seetest returned an error. Response body is: '#{response}'"
59
33
  end
60
34
 
61
- response[:status]
35
+ response["status"]
62
36
  end
63
- # rubocop:enable Metrics/AbcSize Metrics/MethodLength
64
- # rubocop:enable Metrics/MethodLength
65
37
 
66
38
  private
67
39
 
40
+ def upload_or_replace(project_name, unique_name, full_path_to_file, content_type)
41
+ application_info_response = faraday_get_application_info(unique_name)
42
+ if application_info_response.empty?
43
+ return faraday_upload(project_name, unique_name, full_path_to_file, content_type).body
44
+ end
45
+
46
+ application_info_response.each do |app_response|
47
+ next unless app_response["uniqueName"] == unique_name
48
+
49
+ response = replace_existing_application(app_response["id"], project_name, unique_name, full_path_to_file,
50
+ content_type)
51
+ return response if response["status"] == SUCCESS
52
+ end
53
+ end
54
+
68
55
  def replace_existing_application(
69
56
  application_id,
70
57
  project_name,
@@ -73,24 +60,12 @@ module CiToolkit
73
60
  content_type
74
61
  )
75
62
  response = faraday_delete_application(application_id)
76
-
77
- if response[:status] == SUCCESS && response[:code] == OKAY
63
+ if response["status"] == SUCCESS && response["code"] == OKAY
78
64
  response = faraday_upload_file_with_error_handling(project_name, unique_name, full_path_to_file, content_type)
79
65
  end
80
66
  response
81
67
  end
82
68
 
83
- def replace_existing_application_by_unique_name(project_name, unique_name, full_path_to_file, content_type)
84
- application_info_response = faraday_get_application_info(unique_name)
85
- application_info_response.each do |app_response|
86
- next unless app_response[:uniqueName] == unique_name
87
-
88
- response = replace_existing_application(app_response[:id], project_name, unique_name, full_path_to_file,
89
- content_type)
90
- return response if response[:status] == SUCCESS
91
- end
92
- end
93
-
94
69
  def faraday_upload_file_with_error_handling(
95
70
  project_name,
96
71
  unique_name,
@@ -98,7 +73,7 @@ module CiToolkit
98
73
  content_type
99
74
  )
100
75
  response = faraday_upload(project_name, unique_name, full_path_to_file, content_type).body
101
- unless response[:status] == SUCCESS && response[:data][:created] == "true"
76
+ unless response["status"] == SUCCESS && response["data"]["created"] == "true"
102
77
  raise StandardError,
103
78
  "Upload response from Seetest returned an error. Response body is: '#{response}'"
104
79
  end
@@ -123,18 +98,12 @@ module CiToolkit
123
98
 
124
99
  def faraday_get_application_info(unique_name)
125
100
  params = { uniqueName: unique_name }
126
- response = @faraday_conn.get("/api/#{API_VERSION}/applications", params).body
127
- if response.empty?
128
- raise StandardError,
129
- "Get application info for uniqueName: #{unique_name} from Seetest returned an error. " \
130
- "Response body is: '#{response}'"
131
- end
132
- response
101
+ @faraday_conn.get("/api/#{API_VERSION}/applications", params).body
133
102
  end
134
103
 
135
104
  def faraday_delete_application(application_id)
136
105
  response = @faraday_conn.post("/api/#{API_VERSION}/applications/#{application_id}/delete").body
137
- unless response[:status] == SUCCESS && response[:code] == OKAY
106
+ unless response["status"] == SUCCESS && response["code"] == OKAY
138
107
  raise StandardError,
139
108
  "Delete application id: #{application_id} from Seetest returned an error. " \
140
109
  "Response body is: '#{response}'"
@@ -142,5 +111,4 @@ module CiToolkit
142
111
  response
143
112
  end
144
113
  end
145
- # rubocop:enable Metrics/ClassLength
146
114
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ci_toolkit
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.24
4
+ version: 1.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gero Keller
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-05-25 00:00:00.000000000 Z
11
+ date: 2023-05-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday