foreman_rh_cloud 3.0.29 → 3.0.32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/services/foreman_rh_cloud/cloud_request_forwarder.rb +1 -1
- data/config/Gemfile.lock.gh_test +1 -1
- data/config/package-lock.json +41822 -0
- data/lib/foreman_inventory_upload/generators/fact_helpers.rb +3 -1
- data/lib/foreman_inventory_upload/generators/tags.rb +8 -1
- data/lib/foreman_rh_cloud/version.rb +1 -1
- data/package.json +1 -1
- data/test/unit/fact_helpers_test.rb +2 -2
- data/test/unit/services/foreman_rh_cloud/cloud_request_forwarder_test.rb +17 -0
- data/test/unit/tags_generator_test.rb +15 -0
- metadata +3 -2
@@ -104,7 +104,9 @@ module ForemanInventoryUpload
|
|
104
104
|
end
|
105
105
|
|
106
106
|
def obfuscate_ip(ip, ips_dict)
|
107
|
-
|
107
|
+
max_obfuscated = ips_dict.values.map { |v| IPAddr.new(v).to_i }.max || IPAddr.new('10.230.230.0').to_i
|
108
|
+
|
109
|
+
IPAddr.new(max_obfuscated + 1, Socket::AF_INET).to_s
|
108
110
|
end
|
109
111
|
|
110
112
|
def bios_uuid(host)
|
@@ -13,7 +13,7 @@ module ForemanInventoryUpload
|
|
13
13
|
organizations +
|
14
14
|
content_data +
|
15
15
|
satellite_server_data
|
16
|
-
).reject { |key, value| value.empty? }
|
16
|
+
).reject { |key, value| value.empty? }.map { |key, value| [key, truncated_value(value)] }
|
17
17
|
end
|
18
18
|
|
19
19
|
def generate_parameters
|
@@ -22,6 +22,7 @@ module ForemanInventoryUpload
|
|
22
22
|
(@host.host_inherited_params_objects || [])
|
23
23
|
.map { |item| [item.name, item.value] }
|
24
24
|
.select { |_name, value| value.present? || value.is_a?(FalseClass) }
|
25
|
+
.map { |key, value| [key, truncated_value(value)] }
|
25
26
|
end
|
26
27
|
|
27
28
|
private
|
@@ -58,6 +59,12 @@ module ForemanInventoryUpload
|
|
58
59
|
['organization_id', @host.organization_id.to_s],
|
59
60
|
]
|
60
61
|
end
|
62
|
+
|
63
|
+
def truncated_value(value)
|
64
|
+
return 'Original value exceeds 250 characters' if value.to_s.length > 250
|
65
|
+
|
66
|
+
value
|
67
|
+
end
|
61
68
|
end
|
62
69
|
end
|
63
70
|
end
|
data/package.json
CHANGED
@@ -30,13 +30,13 @@ class FactHelpersTest < ActiveSupport::TestCase
|
|
30
30
|
test 'obfuscates ips with insights-client data' do
|
31
31
|
host = mock('host')
|
32
32
|
@instance.expects(:fact_value).with(host, 'insights_client::ips').returns(
|
33
|
-
'[{"obfuscated": "10.230.230.1", "original": "224.0.0.1"}, {"obfuscated": "10.230.230.
|
33
|
+
'[{"obfuscated": "10.230.230.1", "original": "224.0.0.1"}, {"obfuscated": "10.230.230.255", "original": "224.0.0.251"}]'
|
34
34
|
)
|
35
35
|
|
36
36
|
actual = @instance.obfuscated_ips(host)
|
37
37
|
|
38
38
|
assert_equal '10.230.230.1', actual['224.0.0.1']
|
39
|
-
assert_equal '10.230.
|
39
|
+
assert_equal '10.230.231.0', actual['224.0.0.2']
|
40
40
|
end
|
41
41
|
|
42
42
|
test 'obfuscates ips without insights-client data' do
|
@@ -139,4 +139,21 @@ class CloudRequestForwarderTest < ActiveSupport::TestCase
|
|
139
139
|
)
|
140
140
|
assert_equal params.merge(:branch_id => 74), @forwarder.prepare_forward_params(req, 74)
|
141
141
|
end
|
142
|
+
|
143
|
+
test 'should forward content type correctly' do
|
144
|
+
user_agent = { :foo => :bar }
|
145
|
+
params = { :page => 5, :per_page => 42 }
|
146
|
+
|
147
|
+
req = ActionDispatch::Request.new(
|
148
|
+
'REQUEST_URI' => '/foo/bar',
|
149
|
+
'REQUEST_METHOD' => 'GET',
|
150
|
+
'HTTP_USER_AGENT' => user_agent,
|
151
|
+
'rack.input' => ::Puma::NullIO.new,
|
152
|
+
'action_dispatch.request.query_parameters' => params
|
153
|
+
)
|
154
|
+
|
155
|
+
actual = @forwarder.prepare_request_opts(req, 'TEST PAYLOAD', params, { cert: @cert1, key: OpenSSL::PKey::RSA.new(1024).to_pem })
|
156
|
+
|
157
|
+
assert_match /text\/html/, actual[:headers][:content_type]
|
158
|
+
end
|
142
159
|
end
|
@@ -103,6 +103,21 @@ class TagsGeneratorTest < ActiveSupport::TestCase
|
|
103
103
|
assert_equal 0, actual.count
|
104
104
|
end
|
105
105
|
|
106
|
+
test 'truncates parameter tags' do
|
107
|
+
FactoryBot.create(:setting, :name => 'include_parameter_tags', :settings_type => "boolean", :category => "Setting::RhCloud", :default => false, :value => true)
|
108
|
+
|
109
|
+
@host.stubs(:host_inherited_params_objects).returns(
|
110
|
+
[
|
111
|
+
OpenStruct.new(name: 'str_param', value: 'a' * 251),
|
112
|
+
]
|
113
|
+
)
|
114
|
+
|
115
|
+
generator = create_generator
|
116
|
+
actual = Hash[generator.generate_parameters]
|
117
|
+
|
118
|
+
assert_equal 'Original value exceeds 250 characters', actual['str_param']
|
119
|
+
end
|
120
|
+
|
106
121
|
private
|
107
122
|
|
108
123
|
def create_generator
|
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: 3.0.
|
4
|
+
version: 3.0.32
|
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:
|
11
|
+
date: 2022-03-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: katello
|
@@ -188,6 +188,7 @@ files:
|
|
188
188
|
- app/views/layouts/foreman_rh_cloud/application.html.erb
|
189
189
|
- config/Gemfile.lock.gh_test
|
190
190
|
- config/database.yml.example
|
191
|
+
- config/package-lock.json
|
191
192
|
- config/package-lock.json.gh_test
|
192
193
|
- config/package-lock.json.plugin
|
193
194
|
- config/routes.rb
|