topological_inventory-providers-common 3.0.1 → 3.0.2

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: b0d5e54970be70204d7ac119fdd23e0a68bbc01a3e1d3c64520ce3fc6129cfe7
4
- data.tar.gz: 624c68af0b57940bc5436099f1a4238eb5405a9e9b87706911278b5c3fcf44e0
3
+ metadata.gz: ecc26cbace6fd3e43de690666e17f8c7d27e153efb05a2d48fb281712f073e8c
4
+ data.tar.gz: 0221166156a11b5f75da12b3fc1bb861b8594a058823fa2771c62a529ea165f5
5
5
  SHA512:
6
- metadata.gz: ac55e0263630b78533d49b061d972beab29e249911f785f536a8acbb3cada1d88e3935849d089791f9be001b87a0f3100b4e44bc3595527d169107ef14a5e9b0
7
- data.tar.gz: df3b8288f73292d647a77629d5f5ae78a21dad4eeb206e6b1e4e2d077ffd475c60c705f0365311b374fd88544a81943403484089f829aa3611919e95d2ee734f
6
+ metadata.gz: ce5b60dd2047b2b316fa8e0add3b114664f707feae697afd45febf1abd265af96990b89c32ba53e6084f5abfb0a177cdc5ea2eb8c1f9437fdd3791e2dd19b2f0
7
+ data.tar.gz: d5ebb51170ffb18b7aaba271f5361742c1a2d849c96b181274b7f2562e67e4cb29bf94f83067ca41e26c51ff01a5ccf595fa4c776135a3b4cd1b154a7b3fea97
data/CHANGELOG.md CHANGED
@@ -3,6 +3,9 @@ All notable changes to this project will be documented in this file.
3
3
 
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
+ ## [3.0.2] - 2021-08-24
7
+ Support PSK headers in sources api client #78
8
+
6
9
  ## [3.0.1] - 2021-04-30
7
10
  More generic activesupport dependency #77
8
11
 
@@ -90,7 +93,8 @@ manageiq-loggers to >= 0.4.2 #20
90
93
  ## [1.0.0] - 2020-03-19
91
94
  ### Initial release to rubygems.org
92
95
 
93
- [Unreleased]: https://github.com/RedHatInsights/topological_inventory-providers-common/compare/v3.0.1.freeze...HEAD
96
+ [Unreleased]: https://github.com/RedHatInsights/topological_inventory-providers-common/compare/v3.0.2.freeze...HEAD
97
+ [3.0.2]: https://github.com/RedHatInsights/topological_inventory-providers-common/compare/v3.0.1.freeze...v3.0.2.freeze
94
98
  [3.0.1]: https://github.com/RedHatInsights/topological_inventory-providers-common/compare/v3.0.0.freeze...v3.0.1.freeze
95
99
  [3.0.0]: https://github.com/RedHatInsights/topological_inventory-providers-common/compare/v2.1.5.freeze...v3.0.0.freeze
96
100
  [2.1.5]: https://github.com/RedHatInsights/topological_inventory-providers-common/compare/v2.1.4.freeze...v2.1.5.freeze
@@ -15,10 +15,27 @@ module TopologicalInventory
15
15
  end
16
16
 
17
17
  def init_default_api
18
- default_headers.merge!(identity) if identity.present?
18
+ # TODO: remove this once PSK is set up everywhere.
19
+ if identity.present?
20
+ if psk
21
+ parsed_identity = JSON.parse(Base64.decode64(identity.fetch('x-rh-identity')))
22
+
23
+ default_headers.merge!(
24
+ "x-rh-sources-psk" => psk,
25
+ "x-rh-sources-account-number" => parsed_identity['identity']['account_number']
26
+ )
27
+ else
28
+ default_headers.merge!(identity)
29
+ end
30
+ end
31
+
19
32
  ::SourcesApiClient::DefaultApi.new(self)
20
33
  end
21
34
 
35
+ def psk
36
+ @psk ||= ENV.fetch("SOURCES_PSK", nil)
37
+ end
38
+
22
39
  def fetch_default_endpoint(source_id)
23
40
  endpoints = api.list_source_endpoints(source_id)&.data || []
24
41
  endpoints.find(&:default)
@@ -1,7 +1,7 @@
1
1
  module TopologicalInventory
2
2
  module Providers
3
3
  module Common
4
- VERSION = "3.0.1".freeze
4
+ VERSION = "3.0.2".freeze
5
5
  end
6
6
  end
7
7
  end
@@ -9,7 +9,8 @@ RSpec.shared_examples "availability_check" do
9
9
  let(:external_tenant) { '11001' }
10
10
  let(:kafka_client) { TopologicalInventory::Providers::Common::MessagingClient.default.client }
11
11
  let(:identity) { {'x-rh-identity' => Base64.strict_encode64({'identity' => {'account_number' => external_tenant, 'user' => {'is_org_admin' => true}}}.to_json)} }
12
- let(:headers) { {'Content-Type' => 'application/json'}.merge(identity) }
12
+ let(:identity_with_psk) { { "x-rh-sources-account-number" => external_tenant, "x-rh-sources-psk" => '1234' } }
13
+ let(:headers) { ENV['SOURCES_PSK'] ? {'Content-Type' => 'application/json'}.merge(identity_with_psk) : {'Content-Type' => 'application/json'}.merge(identity) }
13
14
  let(:status_available) { described_class::STATUS_AVAILABLE }
14
15
  let(:status_unavailable) { described_class::STATUS_UNAVAILABLE }
15
16
  let(:error_message) { 'error_message' }
@@ -1,5 +1,15 @@
1
1
  require "topological_inventory/providers/common/operations/source"
2
2
 
3
3
  RSpec.describe TopologicalInventory::Providers::Common::Operations::Source do
4
+ context "PSK" do
5
+ around do |example|
6
+ ENV['SOURCES_PSK'] = '1234'
7
+ example.run
8
+ ENV['SOURCES_PSK'] = nil
9
+ end
10
+
11
+ it_behaves_like "availability_check"
12
+ end
13
+
4
14
  it_behaves_like "availability_check"
5
15
  end
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: 3.0.1
4
+ version: 3.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Slemr
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-04-30 00:00:00.000000000 Z
11
+ date: 2021-08-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport