topological_inventory-providers-common 1.0.7 → 1.0.8

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: 868c8f764cd11d9888ed99698a309cc199fdf92823963f4e5cae71208d506ff7
4
- data.tar.gz: 39c352e8b1306bdb87675bf0ccc1fe08f02b0c13555b2466c4c38d7a76979aca
3
+ metadata.gz: 22571a5f48d3d126fc3fddd2992643b2dddccc6c2bb20b5eb8263901bf6ca148
4
+ data.tar.gz: 437ce9d295f10ab3e10b2b32ea64c89efecd66ff2538c6152f2d67d38f4a9f39
5
5
  SHA512:
6
- metadata.gz: c2a8af390114548a89c7dc5bb43f1a6e3784a5a59ebd2ce1c7451c15726015df1353e3dcbc3755d7637d696707b0d6db93e5d4907920a1c4b09d3f6410130a77
7
- data.tar.gz: 46e6596954367336de4049f8024da8b5e63e5be4c60636c77f91f22c3e407229b38aca604137907d1f5cd6411201d9c3b57e4ad5bab2cfb749b2c04e9ca8eeab
6
+ metadata.gz: 4abc37ec7c40eef6bdd0e4555404607228edf396b3c9482b7f735419f1359e68bd13139515d9dc2f0a359e28f23e51f38e39877405c5f3e66f7e414f559fce17
7
+ data.tar.gz: e2652340645a001205c36f4cfad7fe75f0a0dd18301f27cce72fcf856fb48c4be6b2863c00aa7ed7ae40141f1153096ed1bebae6a478e8854f13a52e8524788f
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
4
4
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
5
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
+ ## [1.0.8] - 2020-08-10
8
+ Added refresh-type to save and sweep inventory #45
9
+ Add => to error messages that rubocop missed #44
10
+
7
11
  ## [1.0.7] - 2020-07-27
8
12
  Update operations/source model for receptor-enabled availability checks #36
9
13
  Add check for Application subresource under a Source during Availability check #40
@@ -43,8 +47,9 @@ manageiq-loggers to >= 0.4.2 #20
43
47
  ## [1.0.0] - 2020-03-19
44
48
  ### Initial release to rubygems.org
45
49
 
46
- [Unreleased]: https://github.com/RedHatInsights/topological_inventory-providers-common/compare/v1.0.7...HEAD
47
- [1.0.6]: https://github.com/RedHatInsights/topological_inventory-providers-common/compare/v1.0.6...v1.0.7
50
+ [Unreleased]: https://github.com/RedHatInsights/topological_inventory-providers-common/compare/v1.0.8...HEAD
51
+ [1.0.8]: https://github.com/RedHatInsights/topological_inventory-providers-common/compare/v1.0.7...v1.0.8
52
+ [1.0.7]: https://github.com/RedHatInsights/topological_inventory-providers-common/compare/v1.0.6...v1.0.7
48
53
  [1.0.6]: https://github.com/RedHatInsights/topological_inventory-providers-common/compare/v1.0.5...v1.0.6
49
54
  [1.0.5]: https://github.com/RedHatInsights/topological_inventory-providers-common/compare/v1.0.4...v1.0.5
50
55
  [1.0.4]: https://github.com/RedHatInsights/topological_inventory-providers-common/compare/v1.0.3...v1.0.4
@@ -153,8 +153,9 @@ module TopologicalInventory
153
153
 
154
154
  def endpoint
155
155
  @endpoint ||= api_client.fetch_default_endpoint(source_id)
156
- rescue e
156
+ rescue => e
157
157
  logger.availability_check("Failed to fetch Endpoint for Source #{source_id}: #{e.message}", :error)
158
+ nil
158
159
  end
159
160
 
160
161
  def authentication
@@ -163,14 +164,16 @@ module TopologicalInventory
163
164
  else
164
165
  api_client.fetch_authentication(source_id, endpoint)
165
166
  end
166
- rescue e
167
+ rescue => e
167
168
  logger.availability_check("Failed to fetch Authentication for Source #{source_id}: #{e.message}", :error)
169
+ nil
168
170
  end
169
171
 
170
172
  def application
171
173
  @application ||= api_client.fetch_application(source_id)
172
- rescue e
174
+ rescue => e
173
175
  logger.availability_check("Failed to fetch Application for Source #{source_id}: #{e.message}", :error)
176
+ nil
174
177
  end
175
178
 
176
179
  def check_time
@@ -1,7 +1,7 @@
1
1
  module TopologicalInventory
2
2
  module Providers
3
3
  module Common
4
- VERSION = "1.0.7"
4
+ VERSION = "1.0.8"
5
5
  end
6
6
  end
7
7
  end
@@ -42,7 +42,7 @@ RSpec.shared_examples "availability_check" do
42
42
  stub_get(:endpoint, list_endpoints_response)
43
43
  stub_get(:authentication, list_endpoint_authentications_response)
44
44
  stub_get(:password, internal_api_authentication_response)
45
- stub_get(:application, "[]")
45
+ stub_not_found(:application)
46
46
 
47
47
  # PATCH
48
48
  source_patch_body = {'availability_status' => described_class::STATUS_AVAILABLE, 'last_available_at' => subject.send(:check_time), 'last_checked_at' => subject.send(:check_time)}.to_json
@@ -65,7 +65,7 @@ RSpec.shared_examples "availability_check" do
65
65
  stub_get(:endpoint, list_endpoints_response)
66
66
  stub_get(:authentication, list_endpoint_authentications_response)
67
67
  stub_get(:password, internal_api_authentication_response)
68
- stub_get(:application, "[]")
68
+ stub_not_found(:application)
69
69
 
70
70
  # PATCH
71
71
  connection_error_message = "Some connection error"
@@ -86,8 +86,8 @@ RSpec.shared_examples "availability_check" do
86
86
 
87
87
  it "updates only Source to 'unavailable' status if Endpoint not found" do
88
88
  # GET
89
- stub_get(:endpoint, '')
90
- stub_get(:application, "[]")
89
+ stub_not_found(:endpoint)
90
+ stub_not_found(:application)
91
91
 
92
92
  # PATCH
93
93
  source_patch_body = {'availability_status' => described_class::STATUS_UNAVAILABLE, 'last_checked_at' => subject.send(:check_time)}.to_json
@@ -106,7 +106,7 @@ RSpec.shared_examples "availability_check" do
106
106
  # GET
107
107
  stub_get(:endpoint, list_endpoints_response)
108
108
  stub_get(:authentication, list_endpoint_authentications_response_empty)
109
- stub_get(:application, "[]")
109
+ stub_not_found(:application)
110
110
 
111
111
  # PATCH
112
112
  source_patch_body = {'availability_status' => described_class::STATUS_UNAVAILABLE, 'last_checked_at' => subject.send(:check_time)}.to_json
@@ -142,7 +142,7 @@ RSpec.shared_examples "availability_check" do
142
142
  context "when it is available" do
143
143
  it "updates the availability status to available" do
144
144
  # GET
145
- stub_get(:endpoint, "[]")
145
+ stub_not_found(:endpoint)
146
146
  stub_get(:application, list_applications_response)
147
147
  # PATCH
148
148
  application_patch_body = {'last_available_at' => subject.send(:check_time), 'last_checked_at' => subject.send(:check_time)}.to_json
@@ -163,7 +163,7 @@ RSpec.shared_examples "availability_check" do
163
163
  context "when it is unavailable" do
164
164
  it "updates the availability status to unavailable" do
165
165
  # GET
166
- stub_get(:endpoint, "[]")
166
+ stub_not_found(:endpoint)
167
167
  stub_get(:application, list_applications_unavailable_response)
168
168
  # PATCH
169
169
  application_patch_body = {'last_checked_at' => subject.send(:check_time)}.to_json
@@ -203,6 +203,27 @@ RSpec.shared_examples "availability_check" do
203
203
  end
204
204
  end
205
205
 
206
+ def stub_not_found(object_type)
207
+ case object_type
208
+ when :endpoint
209
+ stub_request(:get, "#{sources_api_url}/sources/#{source_id}/endpoints")
210
+ .with(:headers => headers)
211
+ .to_return(:status => 404, :body => {}.to_json, :headers => {})
212
+ when :authentication
213
+ stub_request(:get, "#{sources_api_url}/endpoints/#{endpoint_id}/authentications")
214
+ .with(:headers => headers)
215
+ .to_return(:status => 404, :body => {}.to_json, :headers => {})
216
+ when :password
217
+ stub_request(:get, "#{host_url}#{sources_internal_api_path}/authentications/#{authentication_id}?expose_encrypted_attribute%5B%5D=password")
218
+ .with(:headers => headers)
219
+ .to_return(:status => 404, :body => {}.to_json, :headers => {})
220
+ when :application
221
+ stub_request(:get, "#{sources_api_url}/sources/#{source_id}/applications")
222
+ .with(:headers => headers)
223
+ .to_return(:status => 404, :body => {}.to_json, :headers => {})
224
+ end
225
+ end
226
+
206
227
  def stub_patch(object_type, data)
207
228
  case object_type
208
229
  when :source
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: topological_inventory-providers-common
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.7
4
+ version: 1.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Slemr
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-07-28 00:00:00.000000000 Z
11
+ date: 2020-08-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport