foreman_rh_cloud 4.0.32 → 4.0.36
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 +16 -5
- data/app/services/foreman_rh_cloud/cloud_request_forwarder.rb +16 -5
- data/lib/foreman_rh_cloud/engine.rb +13 -11
- 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 +23 -0
- metadata +3 -4
- data/config/package-lock.json +0 -41822
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 224802f19d8eb36625b3d80121e6325d2733920417d1b45d229b448e20cd8164
|
|
4
|
+
data.tar.gz: 3ffe588112a4638c952b7dc11786e811dd484aba2f013b03fd070b09cd5292d0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: '08abdef66a17843cec33bf0a6fa84c689ecdceab413df010936c0b9b7226ce9b2ed00d1853c23838b49faa01a96ab86673d59554910ba78ebbfd654ecc439d8e'
|
|
7
|
+
data.tar.gz: 3f432ee32d4d1e81b1f5dddccd98265be4e62422ca28a062264be78dd3ce3c58f657aae55dd572a27cc8d88c38ac8b6250f328f17d9951572340af694644259b
|
|
@@ -33,14 +33,25 @@ module InsightsCloud::Api
|
|
|
33
33
|
}, status: @cloud_response.code
|
|
34
34
|
end
|
|
35
35
|
|
|
36
|
-
|
|
37
|
-
|
|
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_')
|
|
38
39
|
end
|
|
39
|
-
|
|
40
|
+
# Append general headers
|
|
40
41
|
assign_header(response, @cloud_response, :x_resource_count, true)
|
|
41
|
-
|
|
42
|
+
headers[Rack::ETAG] = @cloud_response.headers[:etag]
|
|
42
43
|
|
|
43
|
-
|
|
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
|
|
44
55
|
end
|
|
45
56
|
|
|
46
57
|
def branch_info
|
|
@@ -25,11 +25,12 @@ module ForemanRhCloud
|
|
|
25
25
|
base_params = {
|
|
26
26
|
method: original_request.method,
|
|
27
27
|
payload: forward_payload,
|
|
28
|
-
headers:
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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
|
+
}),
|
|
33
34
|
}
|
|
34
35
|
base_params.merge(path_params(original_request.path, certs))
|
|
35
36
|
end
|
|
@@ -80,6 +81,16 @@ module ForemanRhCloud
|
|
|
80
81
|
end
|
|
81
82
|
end
|
|
82
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
|
+
|
|
83
94
|
def platform_request?
|
|
84
95
|
->(request_path) { request_path.include? '/platform' }
|
|
85
96
|
end
|
|
@@ -6,15 +6,18 @@ module ForemanRhCloud
|
|
|
6
6
|
engine_name 'foreman_rh_cloud'
|
|
7
7
|
|
|
8
8
|
def self.register_scheduled_task(task_class, cronline)
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
9
|
+
ForemanTasks::RecurringLogic.transaction(isolation: :serializable) do
|
|
10
|
+
return if ForemanTasks::RecurringLogic.joins(:tasks)
|
|
11
|
+
.merge(ForemanTasks::Task.where(label: task_class.name))
|
|
12
|
+
.exists?
|
|
13
|
+
|
|
14
|
+
User.as_anonymous_admin do
|
|
15
|
+
recurring_logic = ForemanTasks::RecurringLogic.new_from_cronline(cronline)
|
|
16
|
+
recurring_logic.save!
|
|
17
|
+
recurring_logic.start(task_class)
|
|
18
|
+
end
|
|
17
19
|
end
|
|
20
|
+
rescue ActiveRecord::TransactionIsolationError
|
|
18
21
|
end
|
|
19
22
|
|
|
20
23
|
initializer 'foreman_rh_cloud.load_default_settings', :before => :load_config_initializers do
|
|
@@ -136,10 +139,9 @@ module ForemanRhCloud
|
|
|
136
139
|
Foreman::Gettext::Support.add_text_domain locale_domain, locale_dir
|
|
137
140
|
end
|
|
138
141
|
|
|
139
|
-
|
|
142
|
+
initializer 'foreman_rh_cloud.register_rex_features', :before => :finisher_hook do |_app|
|
|
140
143
|
# skip database manipulations while tables do not exist, like in migrations
|
|
141
|
-
if ActiveRecord::Base.connection.data_source_exists?(ForemanTasks::Task.table_name)
|
|
142
|
-
|
|
144
|
+
if ActiveRecord::Base.connection.data_source_exists?(ForemanTasks::Task.table_name)
|
|
143
145
|
RemoteExecutionFeature.register(
|
|
144
146
|
:rh_cloud_remediate_hosts,
|
|
145
147
|
N_('Apply Insights recommendations'),
|
data/package.json
CHANGED
|
@@ -60,6 +60,29 @@ module InsightsCloud::Api
|
|
|
60
60
|
assert_equal x_rh_insights_request_id, @response.headers['x_rh_insights_request_id']
|
|
61
61
|
end
|
|
62
62
|
|
|
63
|
+
test "should set etag header to response from cloud" do
|
|
64
|
+
etag = '12345'
|
|
65
|
+
req = RestClient::Request.new(:method => 'GET', :url => 'http://test.theforeman.org', :headers => { "If-None-Match": etag})
|
|
66
|
+
net_http_resp = Net::HTTPResponse.new(1.0, 200, "OK")
|
|
67
|
+
net_http_resp[Rack::ETAG] = etag
|
|
68
|
+
res = RestClient::Response.create(@body, net_http_resp, req)
|
|
69
|
+
::ForemanRhCloud::CloudRequestForwarder.any_instance.stubs(:forward_request).returns(res)
|
|
70
|
+
|
|
71
|
+
get :forward_request, params: { "path" => "static/v1/release/insights-core.egg" }
|
|
72
|
+
assert_equal etag, @response.headers[Rack::ETAG]
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
test "should set content type header to response from cloud" do
|
|
76
|
+
req = RestClient::Request.new(:method => 'GET', :url => 'http://test.theforeman.org')
|
|
77
|
+
net_http_resp = Net::HTTPResponse.new(1.0, 200, "OK")
|
|
78
|
+
net_http_resp['Content-Type'] = 'application/zip'
|
|
79
|
+
res = RestClient::Response.create(@body, net_http_resp, req)
|
|
80
|
+
::ForemanRhCloud::CloudRequestForwarder.any_instance.stubs(:forward_request).returns(res)
|
|
81
|
+
|
|
82
|
+
get :forward_request, params: { "path" => "static/v1/release/insights-core.egg" }
|
|
83
|
+
assert_equal net_http_resp['Content-Type'], @response.headers['Content-Type']
|
|
84
|
+
end
|
|
85
|
+
|
|
63
86
|
test "should handle failed authentication to cloud" do
|
|
64
87
|
net_http_resp = Net::HTTPResponse.new(1.0, 401, "Unauthorized")
|
|
65
88
|
res = RestClient::Response.create(@body, net_http_resp, @http_req)
|
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: 4.0.
|
|
4
|
+
version: 4.0.36
|
|
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: 2022-
|
|
11
|
+
date: 2022-11-10 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: katello
|
|
@@ -174,7 +174,6 @@ files:
|
|
|
174
174
|
- app/views/layouts/foreman_rh_cloud/application.html.erb
|
|
175
175
|
- config/Gemfile.lock.gh_test
|
|
176
176
|
- config/database.yml.example
|
|
177
|
-
- config/package-lock.json
|
|
178
177
|
- config/package-lock.json.gh_test
|
|
179
178
|
- config/package-lock.json.plugin
|
|
180
179
|
- config/rh_cert-api_chain.pem
|
|
@@ -659,7 +658,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
659
658
|
- !ruby/object:Gem::Version
|
|
660
659
|
version: '0'
|
|
661
660
|
requirements: []
|
|
662
|
-
rubygems_version: 3.
|
|
661
|
+
rubygems_version: 3.3.7
|
|
663
662
|
signing_key:
|
|
664
663
|
specification_version: 4
|
|
665
664
|
summary: Summary of ForemanRhCloud.
|