foreman_rh_cloud 3.0.29 → 3.0.33
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 +4 -4
- data/app/controllers/insights_cloud/api/machine_telemetries_controller.rb +23 -4
- data/app/services/foreman_rh_cloud/cloud_request_forwarder.rb +18 -5
- data/config/Gemfile.lock.gh_test +1 -1
- 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/controllers/insights_cloud/api/machine_telemetries_controller_test.rb +39 -39
- data/test/test_plugin_helper.rb +53 -0
- 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 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1f5ec744a85ab1dc41ab93fc5949cd4f86df921c6141848fd4a1f2de7d26e0f6
|
|
4
|
+
data.tar.gz: a9754dcaa8eb46f7260bccd6ba6e4fb730793df4caf2dff18370e19f7a8a62cf
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a22b012bf970556113871948f939b034ca9a2487bd2bbb23118cbdfa475d46a4481a3f7b5934a49d2ca6871fb8fa3bd3d4ab2dd692f35024c7623f85491fa259
|
|
7
|
+
data.tar.gz: 1153735dba9d5f08046e331e4b560620a9d463270942e919c32d5f1d1b36f2fe674d25b605af9681eeecb06deacbc9a3c04dcf6fe4a998bf3d23b53bb92ecfa5
|
|
@@ -25,14 +25,33 @@ module InsightsCloud::Api
|
|
|
25
25
|
}, status: :bad_gateway
|
|
26
26
|
end
|
|
27
27
|
|
|
28
|
-
if @cloud_response.
|
|
29
|
-
return
|
|
28
|
+
if @cloud_response.code >= 300
|
|
29
|
+
return render json: {
|
|
30
|
+
:message => 'Cloud request failed',
|
|
31
|
+
:headers => {},
|
|
32
|
+
:response => @cloud_response,
|
|
33
|
+
}, status: @cloud_response.code
|
|
30
34
|
end
|
|
31
35
|
|
|
36
|
+
# Append redhat-specific headers
|
|
37
|
+
@cloud_response.headers.each do |key, value|
|
|
38
|
+
assign_header(response, @cloud_response, key, false) if key.to_s.start_with?('x_rh_')
|
|
39
|
+
end
|
|
40
|
+
# Append general headers
|
|
32
41
|
assign_header(response, @cloud_response, :x_resource_count, true)
|
|
33
|
-
|
|
42
|
+
headers[Rack::ETAG] = @cloud_response.headers[:etag]
|
|
34
43
|
|
|
35
|
-
|
|
44
|
+
if @cloud_response.headers[:content_disposition]
|
|
45
|
+
# If there is a Content-Disposition header, it means we are forwarding binary data, send the raw data with proper
|
|
46
|
+
# content type
|
|
47
|
+
send_data @cloud_response, disposition: @cloud_response.headers[:content_disposition], type: @cloud_response.headers[:content_type]
|
|
48
|
+
elsif @cloud_response.headers[:content_type] =~ /zip/
|
|
49
|
+
# if there is no Content-Disposition, but the content type is binary according the content type,
|
|
50
|
+
# forward the request as binry too
|
|
51
|
+
send_data @cloud_response, type: @cloud_response.headers[:content_type]
|
|
52
|
+
else
|
|
53
|
+
render json: @cloud_response, status: @cloud_response.code
|
|
54
|
+
end
|
|
36
55
|
end
|
|
37
56
|
|
|
38
57
|
def branch_info
|
|
@@ -17,17 +17,20 @@ module ForemanRhCloud
|
|
|
17
17
|
logger.debug("Sending request to: #{request_opts[:url]}")
|
|
18
18
|
|
|
19
19
|
execute_cloud_request(request_opts)
|
|
20
|
+
rescue RestClient::Exception => error_response
|
|
21
|
+
error_response.response
|
|
20
22
|
end
|
|
21
23
|
|
|
22
24
|
def prepare_request_opts(original_request, forward_payload, forward_params, certs)
|
|
23
25
|
base_params = {
|
|
24
26
|
method: original_request.method,
|
|
25
27
|
payload: forward_payload,
|
|
26
|
-
headers:
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
headers: original_headers(original_request).merge(
|
|
29
|
+
{
|
|
30
|
+
params: forward_params,
|
|
31
|
+
user_agent: http_user_agent(original_request),
|
|
32
|
+
content_type: original_request.media_type.presence || original_request.format.to_s,
|
|
33
|
+
}),
|
|
31
34
|
}
|
|
32
35
|
base_params.merge(path_params(original_request.path, certs))
|
|
33
36
|
end
|
|
@@ -78,6 +81,16 @@ module ForemanRhCloud
|
|
|
78
81
|
end
|
|
79
82
|
end
|
|
80
83
|
|
|
84
|
+
def original_headers(original_request)
|
|
85
|
+
headers = {
|
|
86
|
+
if_none_match: original_request.if_none_match,
|
|
87
|
+
if_modified_since: original_request.if_modified_since,
|
|
88
|
+
}.compact
|
|
89
|
+
|
|
90
|
+
logger.debug("Sending headers: #{headers}")
|
|
91
|
+
headers
|
|
92
|
+
end
|
|
93
|
+
|
|
81
94
|
def platform_request?
|
|
82
95
|
->(request_path) { request_path.include? '/platform' }
|
|
83
96
|
end
|
data/config/Gemfile.lock.gh_test
CHANGED
|
@@ -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
|
@@ -3,6 +3,8 @@ require 'test_plugin_helper'
|
|
|
3
3
|
module InsightsCloud::Api
|
|
4
4
|
class MachineTelemetriesControllerTest < ActionController::TestCase
|
|
5
5
|
context '#forward_request' do
|
|
6
|
+
include MockCerts
|
|
7
|
+
|
|
6
8
|
setup do
|
|
7
9
|
@body = 'Cloud response body'
|
|
8
10
|
@http_req = RestClient::Request.new(:method => 'GET', :url => 'http://test.theforeman.org')
|
|
@@ -12,38 +14,9 @@ module InsightsCloud::Api
|
|
|
12
14
|
User.current = ::Katello::CpConsumerUser.new(:uuid => host.subscription_facet.uuid, :login => host.subscription_facet.uuid)
|
|
13
15
|
InsightsCloud::Api::MachineTelemetriesController.any_instance.stubs(:upstream_owner).returns({ 'uuid' => 'abcdefg' })
|
|
14
16
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
"FzAVBgNVBAMMDnRoZWZvcmVtYW4ub3JnMB4XDTE4MDMyNDEyMzYyOFoXDTI4MDMy\r\n" +
|
|
19
|
-
"MTEyMzYyOFowTzELMAkGA1UEBh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
|
|
46
|
-
"-----END CERTIFICATE-----"
|
|
17
|
+
setup_certs_expectation do
|
|
18
|
+
InsightsCloud::Api::MachineTelemetriesController.any_instance.stubs(:candlepin_id_cert)
|
|
19
|
+
end
|
|
47
20
|
end
|
|
48
21
|
|
|
49
22
|
test "should respond with response from cloud" do
|
|
@@ -63,13 +36,6 @@ module InsightsCloud::Api
|
|
|
63
36
|
::ForemanRhCloud::CloudRequestForwarder.any_instance.expects(:execute_cloud_request).with do |opts|
|
|
64
37
|
opts[:headers][:content_type] == 'application/json'
|
|
65
38
|
end.returns(res)
|
|
66
|
-
InsightsCloud::Api::MachineTelemetriesController.any_instance.expects(:candlepin_id_cert)
|
|
67
|
-
.returns(
|
|
68
|
-
{
|
|
69
|
-
cert: @cert1,
|
|
70
|
-
key: OpenSSL::PKey::RSA.new(1024).to_pem,
|
|
71
|
-
}
|
|
72
|
-
)
|
|
73
39
|
InsightsCloud::Api::MachineTelemetriesController.any_instance.expects(:cp_owner_id).returns('123')
|
|
74
40
|
|
|
75
41
|
post :forward_request, as: :json, params: { "path" => "static/v1/test", "machine_telemetry" => {"foo" => "bar"} }
|
|
@@ -90,6 +56,29 @@ module InsightsCloud::Api
|
|
|
90
56
|
assert_equal x_rh_insights_request_id, @response.headers['x_rh_insights_request_id']
|
|
91
57
|
end
|
|
92
58
|
|
|
59
|
+
test "should set etag header to response from cloud" do
|
|
60
|
+
etag = '12345'
|
|
61
|
+
req = RestClient::Request.new(:method => 'GET', :url => 'http://test.theforeman.org', :headers => { "If-None-Match": etag})
|
|
62
|
+
net_http_resp = Net::HTTPResponse.new(1.0, 200, "OK")
|
|
63
|
+
net_http_resp[Rack::ETAG] = etag
|
|
64
|
+
res = RestClient::Response.create(@body, net_http_resp, req)
|
|
65
|
+
::ForemanRhCloud::CloudRequestForwarder.any_instance.stubs(:forward_request).returns(res)
|
|
66
|
+
|
|
67
|
+
get :forward_request, params: { "path" => "static/v1/release/insights-core.egg" }
|
|
68
|
+
assert_equal etag, @response.headers[Rack::ETAG]
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
test "should set content type header to response from cloud" do
|
|
72
|
+
req = RestClient::Request.new(:method => 'GET', :url => 'http://test.theforeman.org')
|
|
73
|
+
net_http_resp = Net::HTTPResponse.new(1.0, 200, "OK")
|
|
74
|
+
net_http_resp['Content-Type'] = 'application/zip'
|
|
75
|
+
res = RestClient::Response.create(@body, net_http_resp, req)
|
|
76
|
+
::ForemanRhCloud::CloudRequestForwarder.any_instance.stubs(:forward_request).returns(res)
|
|
77
|
+
|
|
78
|
+
get :forward_request, params: { "path" => "static/v1/release/insights-core.egg" }
|
|
79
|
+
assert_equal net_http_resp['Content-Type'], @response.headers['Content-Type']
|
|
80
|
+
end
|
|
81
|
+
|
|
93
82
|
test "should handle failed authentication to cloud" do
|
|
94
83
|
net_http_resp = Net::HTTPResponse.new(1.0, 401, "Unauthorized")
|
|
95
84
|
res = RestClient::Response.create(@body, net_http_resp, @http_req)
|
|
@@ -99,6 +88,17 @@ module InsightsCloud::Api
|
|
|
99
88
|
assert_equal 502, @response.status
|
|
100
89
|
assert_equal 'Authentication to the Insights Service failed.', JSON.parse(@response.body)['message']
|
|
101
90
|
end
|
|
91
|
+
|
|
92
|
+
test "should forward errors to the client" do
|
|
93
|
+
net_http_resp = Net::HTTPResponse.new(1.0, 500, "TEST_RESPONSE")
|
|
94
|
+
res = RestClient::Response.create(@body, net_http_resp, @http_req)
|
|
95
|
+
::ForemanRhCloud::CloudRequestForwarder.any_instance.stubs(:execute_cloud_request).raises(RestClient::InternalServerError.new(res))
|
|
96
|
+
|
|
97
|
+
get :forward_request, params: { "path" => "platform/module-update-router/v1/channel" }
|
|
98
|
+
assert_equal 500, @response.status
|
|
99
|
+
assert_equal 'Cloud request failed', JSON.parse(@response.body)['message']
|
|
100
|
+
assert_match /#{@body}/, JSON.parse(@response.body)['response']
|
|
101
|
+
end
|
|
102
102
|
end
|
|
103
103
|
|
|
104
104
|
context '#branch_info' do
|
data/test/test_plugin_helper.rb
CHANGED
|
@@ -39,3 +39,56 @@ module KatelloLocationFix
|
|
|
39
39
|
end
|
|
40
40
|
end
|
|
41
41
|
end
|
|
42
|
+
|
|
43
|
+
module MockCerts
|
|
44
|
+
extend ActiveSupport::Concern
|
|
45
|
+
|
|
46
|
+
def test_certificate
|
|
47
|
+
@test_certificate ||= "-----BEGIN CERTIFICATE-----\r\n" +
|
|
48
|
+
"MIIFdDCCA1ygAwIBAgIJAM5Uqykb3EAtMA0GCSqGSIb3DQEBCwUAME8xCzAJBgNV\r\n" +
|
|
49
|
+
"BAYTAklMMREwDwYDVQQIDAhUZWwgQXZpdjEUMBIGA1UECgwLVGhlIEZvcmVtYW4x\r\n" +
|
|
50
|
+
"FzAVBgNVBAMMDnRoZWZvcmVtYW4ub3JnMB4XDTE4MDMyNDEyMzYyOFoXDTI4MDMy\r\n" +
|
|
51
|
+
"MTEyMzYyOFowTzELMAkGA1UEBhMCSUwxETAPBgNVBAgMCFRlbCBBdml2MRQwEgYD\r\n" +
|
|
52
|
+
"VQQKDAtUaGUgRm9yZW1hbjEXMBUGA1UEAwwOdGhlZm9yZW1hbi5vcmcwggIiMA0G\r\n" +
|
|
53
|
+
"CSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDF04/s4h+BgHPG1HDZ/sDlYq925pkc\r\n" +
|
|
54
|
+
"RTVAfnE2EXDAmZ6W4Q9ueDY65MHe3ZWO5Dg72kNSP2sK9kRI7Dk5CAFOgyw1rH8t\r\n" +
|
|
55
|
+
"Hd1+0xp/lv6e4SvSYghxIL68vFe0ftKkm1usqejBM5ZTgKr7JCI+XSIN36F65Kde\r\n" +
|
|
56
|
+
"c+vxwBnayuhP04r9/aaE/709SXML4eRVYW8I3qFy9FPtUOm+bY8U2PIv5fHayqbG\r\n" +
|
|
57
|
+
"cL/4t3+MCtMhHJsLzdBXya+1P5t+HcKjUNlmwoUF961YAktVuEFloGd0RMRlqF3/\r\n" +
|
|
58
|
+
"itU3QNlXgA5QBI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+DUeEKUWVGnr9U9xOaC+Ws+oX7MIEUCDM7p2ob4JwcjnFs1jZgHh\r\n" +
|
|
72
|
+
"Hwig+i7doTlc701PvKWO96fuNHK3B3/jTb1fVvSZ49O/RvY1VWODdUdxWmXGHNh3\r\n" +
|
|
73
|
+
"LoR8tSPEb46lC2DXGaIQumqQt8PnBG+vL1qkQa1SGTV7dJ8TTbxbv0S+sS+igkk9\r\n" +
|
|
74
|
+
"zsIEK8Ea3Ep935cXximz0faAAKHSA+It+xHLAyDtqy2KaAEBgGsBuuWlUfK6TaP3\r\n" +
|
|
75
|
+
"Gwdjct3y4yYUO45lUsUfHqX8vk/4ttW5zYeDiW+HArJz+9VUXNbEdury4kGuHgBj\r\n" +
|
|
76
|
+
"xHD4Bsul65+hHZ9QywKU26F1A6TLkYpQ2rk/Dx9LGICM4m4IlHjWJPFsQdtkyOor\r\n" +
|
|
77
|
+
"osxMtcaZZ1E=\r\n" +
|
|
78
|
+
"-----END CERTIFICATE-----"
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def generate_certs_hash
|
|
82
|
+
{
|
|
83
|
+
cert: test_certificate,
|
|
84
|
+
key: OpenSSL::PKey::RSA.new(1024).to_pem,
|
|
85
|
+
}
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
def setup_certs_expectation
|
|
89
|
+
expectation = yield
|
|
90
|
+
expectation.returns(
|
|
91
|
+
generate_certs_hash
|
|
92
|
+
)
|
|
93
|
+
end
|
|
94
|
+
end
|
|
@@ -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.33
|
|
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-11-08 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: katello
|
|
@@ -672,7 +672,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
672
672
|
- !ruby/object:Gem::Version
|
|
673
673
|
version: '0'
|
|
674
674
|
requirements: []
|
|
675
|
-
rubygems_version: 3.
|
|
675
|
+
rubygems_version: 3.3.7
|
|
676
676
|
signing_key:
|
|
677
677
|
specification_version: 4
|
|
678
678
|
summary: Summary of ForemanRhCloud.
|