foreman_rh_cloud 9.0.58 → 9.0.60

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: 48906395af94f2d71160604c547ba3855d46440ff1f29b60f11b0b1fbe6d9d12
4
- data.tar.gz: fcc42c3924b9bdcf1135ce967298e08b9089610ae9240bcb3fe45421fc658b06
3
+ metadata.gz: 7fc9fef343039c3d7fb7aca6dc870f356c45ed2a67d40184cea8c4c9a0792b7d
4
+ data.tar.gz: 19cb1bbe3ece3cf95fc568d2415aed4eabb215e8bdf609afb2f2b5d0a1229a23
5
5
  SHA512:
6
- metadata.gz: 189c8a3d0f7db4274c10bd0baa57542fbfd82c0d0ddedf9bb7da5429b5045e1bad9dc6434248737db0deb2be792af34f8f8067ef8397ba85a3c3cc9f0ae29f5e
7
- data.tar.gz: 16039e69ed139efee3304bb64086391f1ee8e44bf42732793c8700fc3941d62c1f011cf87f514a931336ad4b20560b150364debcbe1547cbc3cfe75a735b5e05
6
+ metadata.gz: 40bb4d0d7f9f537ccac76103385f6babf23a05ac7acef3c906dc7de3c660e6ebb94e87455021c825472fe701a4cf8abd0125c247344451000256964b67b720ee
7
+ data.tar.gz: ab205ff552f4ff1a7e50c50dcf0f32ad5fd36b6ca3f1b05eb95665b5e47e36150187361a3222a14298c6f08e0ddea85af229e1105eb2634ff95735839db6a202
@@ -38,7 +38,7 @@ module ForemanRhCloud
38
38
  def prepare_forward_payload(original_request, controller_name)
39
39
  forward_payload = original_request.request_parameters[controller_name]
40
40
 
41
- forward_payload = original_request.raw_post.clone if original_request.post? && original_request.raw_post
41
+ forward_payload = original_request.raw_post.clone if (original_request.post? || original_request.patch?) && original_request.raw_post
42
42
  forward_payload = original_request.body.read if original_request.put?
43
43
 
44
44
  forward_payload = original_request.params.slice(:file, :metadata) if original_request.params[:file]
@@ -50,7 +50,9 @@ module ForemanRhCloud
50
50
 
51
51
  def prepare_forward_params(original_request, branch_id)
52
52
  forward_params = original_request.query_parameters
53
- if original_request.user_agent && !original_request.user_agent.include?('redhat_access_cfme')
53
+ compliance_request = original_request.path.match?(/compliance\/v2(\/.*)?/)
54
+ user_agent = original_request.user_agent.present? && !original_request.user_agent.include?('redhat_access_cfme')
55
+ if user_agent && !compliance_request
54
56
  forward_params = forward_params.merge(:branch_id => branch_id)
55
57
  end
56
58
 
@@ -1,3 +1,3 @@
1
1
  module ForemanRhCloud
2
- VERSION = '9.0.58'.freeze
2
+ VERSION = '9.0.60'.freeze
3
3
  end
data/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "foreman_rh_cloud",
3
- "version": "9.0.58",
3
+ "version": "9.0.60",
4
4
  "description": "Inventory Upload =============",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -65,16 +65,15 @@ class CloudRequestForwarderTest < ActiveSupport::TestCase
65
65
  end
66
66
 
67
67
  test 'should forward patch payload' do
68
- params = { 'pumpkin' => 'pie' }
68
+ post_data = 'Random PATCH data'
69
69
  req = ActionDispatch::Request.new(
70
70
  'REQUEST_URI' => '/foo/bar?baz=awesome',
71
71
  'REQUEST_METHOD' => 'PATCH',
72
72
  'rack.input' => ::Puma::NullIO.new,
73
- 'RAW_POST_DATA' => 'Random PATCH data',
74
- "action_dispatch.request.path_parameters" => { :format => "json" },
75
- "action_dispatch.request.request_parameters" => { 'vegetables' => params }
73
+ 'RAW_POST_DATA' => post_data,
74
+ "action_dispatch.request.path_parameters" => { :format => "json" }
76
75
  )
77
- assert_equal params.to_json, @forwarder.prepare_forward_payload(req, 'vegetables')
76
+ assert_equal post_data, @forwarder.prepare_forward_payload(req, 'Random PATCH data')
78
77
  end
79
78
 
80
79
  test 'should forward file with metadata' do
@@ -113,6 +112,30 @@ class CloudRequestForwarderTest < ActiveSupport::TestCase
113
112
  assert_equal params.merge(:branch_id => 74), @forwarder.prepare_forward_params(req, 74)
114
113
  end
115
114
 
115
+ test 'should NOT add branch id into forwarded params for compliance urls' do
116
+ user_agent = { :foo => :bar }
117
+ params = { :page => 5, :per_page => 42 }
118
+
119
+ uris = [
120
+ "/redhat_access/r/insights/platform/compliance/v2/systems/MyUUID/policies",
121
+ "/redhat_access/r/insights/platform/compliance/v2/policies/MyUUID",
122
+ "/redhat_access/r/insights/platform/compliance/v2/systems/MyUUID",
123
+ "/redhat_access/r/insights/platform/compliance/v2/policies",
124
+ "/redhat_access/r/insights/platform/compliance/v2/",
125
+ ]
126
+ uris.each do |uri|
127
+ req = ActionDispatch::Request.new(
128
+ 'REQUEST_URI' => uri,
129
+ 'REQUEST_METHOD' => 'GET',
130
+ 'HTTP_USER_AGENT' => user_agent,
131
+ 'rack.input' => ::Puma::NullIO.new,
132
+ 'action_dispatch.request.query_parameters' => params
133
+ )
134
+ req.stubs(:path).returns(uri)
135
+ refute @forwarder.prepare_forward_params(req, 74).key?(:branch_id), "Branch id should not be added for #{uri}"
136
+ end
137
+ end
138
+
116
139
  test 'should reuse BranchInfo identifiers for user_agent' do
117
140
  user_agent = { :foo => :bar }
118
141
  params = { :page => 5, :per_page => 42 }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman_rh_cloud
3
3
  version: !ruby/object:Gem::Version
4
- version: 9.0.58
4
+ version: 9.0.60
5
5
  platform: ruby
6
6
  authors:
7
7
  - Foreman Red Hat Cloud team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-09-12 00:00:00.000000000 Z
11
+ date: 2025-03-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: foreman_ansible