foreman_rh_cloud 5.0.34 → 5.0.35
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/insights_cloud/api/machine_telemetries_controller.rb +7 -1
- data/lib/foreman_rh_cloud/engine.rb +13 -10
- data/lib/foreman_rh_cloud/version.rb +1 -1
- data/lib/insights_cloud/async/insights_scheduled_sync.rb +4 -0
- data/package.json +1 -1
- data/test/controllers/insights_cloud/api/machine_telemetries_controller_test.rb +16 -0
- data/test/unit/services/foreman_rh_cloud/cloud_request_forwarder_test.rb +13 -8
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 437d70d98a43e88f7835426bf1a8ae7995a2b759038e3a5908dc41e122544ed1
|
4
|
+
data.tar.gz: a655276cda12b06662db3670019747c518e9204c22ca8ad3591024945dd48fb8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3d59ebbe9a845efd88c9d70f1d44ff9ebae7e5faabd947c3ba3d48e5f22435c97052be363839805208b381fea29f643a35ef241f2ff0ae462d1720d6ff5fd538
|
7
|
+
data.tar.gz: f7d94f184cbeba9d50b6e8a83d71db08a3c6417972b6d51b6ca247558a4769a6f17fbfdae37f9e4f5efe2a73a8095885a44e109d2b736fbc1d824f9e68528fe1
|
@@ -49,7 +49,13 @@ module InsightsCloud::Api
|
|
49
49
|
end
|
50
50
|
|
51
51
|
def branch_info
|
52
|
-
|
52
|
+
payload = nil
|
53
|
+
|
54
|
+
User.as_anonymous_admin do
|
55
|
+
payload = ForemanRhCloud::BranchInfo.new.generate(@uuid, @host, @branch_id, request.host).to_json
|
56
|
+
end
|
57
|
+
|
58
|
+
render :json => payload
|
53
59
|
end
|
54
60
|
|
55
61
|
def assign_header(res, cloud_res, header, transform)
|
@@ -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
|
@@ -140,9 +143,9 @@ module ForemanRhCloud
|
|
140
143
|
Foreman::Gettext::Support.add_text_domain locale_domain, locale_dir
|
141
144
|
end
|
142
145
|
|
143
|
-
|
146
|
+
initializer 'foreman_rh_cloud.register_rex_features', :before => :finisher_hook do |_app|
|
144
147
|
# skip database manipulations while tables do not exist, like in migrations
|
145
|
-
if ActiveRecord::Base.connection.data_source_exists?(ForemanTasks::Task.table_name)
|
148
|
+
if ActiveRecord::Base.connection.data_source_exists?(ForemanTasks::Task.table_name)
|
146
149
|
RemoteExecutionFeature.register(
|
147
150
|
:rh_cloud_remediate_hosts,
|
148
151
|
N_('Apply Insights recommendations'),
|
data/package.json
CHANGED
@@ -60,6 +60,18 @@ 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
|
+
|
63
75
|
test "should handle failed authentication to cloud" do
|
64
76
|
net_http_resp = Net::HTTPResponse.new(1.0, 401, "Unauthorized")
|
65
77
|
res = RestClient::Response.create(@body, net_http_resp, @http_req)
|
@@ -116,6 +128,10 @@ module InsightsCloud::Api
|
|
116
128
|
test 'should get branch info' do
|
117
129
|
get :branch_info
|
118
130
|
|
131
|
+
res = JSON.parse(@response.body)
|
132
|
+
|
133
|
+
assert_not_equal 0, res['labels'].find { |l| l['key'] == 'hostgroup' }.count
|
134
|
+
|
119
135
|
assert_response :success
|
120
136
|
end
|
121
137
|
|
@@ -6,18 +6,23 @@ class CloudRequestForwarderTest < ActiveSupport::TestCase
|
|
6
6
|
|
7
7
|
setup do
|
8
8
|
@forwarder = ::ForemanRhCloud::CloudRequestForwarder.new
|
9
|
+
|
10
|
+
ForemanRhCloud.stubs(:base_url).returns('https://cloud.example.com')
|
11
|
+
ForemanRhCloud.stubs(:cert_base_url).returns('https://cert.cloud.example.com')
|
12
|
+
ForemanRhCloud.stubs(:legacy_insights_url).returns('https://cert-api.access.example.com')
|
13
|
+
ForemanRhCloud.stubs(:authentication_url).returns('https://sso.example.com/auth/realms/redhat-external/protocol/openid-connect/token')
|
9
14
|
end
|
10
15
|
|
11
16
|
test 'should prepare correct cloud url' do
|
12
17
|
paths = {
|
13
|
-
"/redhat_access/r/insights/platform/module-update-router/v1/channel?module=insights-core" => "https://cert.cloud.
|
14
|
-
"/redhat_access/r/insights/v1/static/release/insights-core.egg" => "https://cert-api.access.
|
15
|
-
"/redhat_access/r/insights/v1/static/uploader.v2.json" => "https://cert-api.access.
|
16
|
-
"/redhat_access/r/insights/v1/static/uploader.v2.json.asc" => "https://cert-api.access.
|
17
|
-
"/redhat_access/r/insights/platform/inventory/v1/hosts" => "https://cert.cloud.
|
18
|
-
"/redhat_access/r/insights/platform/ingress/v1/upload" => "https://cert.cloud.
|
19
|
-
"/redhat_access/r/insights/uploads/67200803-132b-474b-a6f9-37be74185df4" => "https://cert-api.access.
|
20
|
-
"/redhat_access/r/insights/" => "https://cert.cloud.
|
18
|
+
"/redhat_access/r/insights/platform/module-update-router/v1/channel?module=insights-core" => "https://cert.cloud.example.com/api/module-update-router/v1/channel?module=insights-core",
|
19
|
+
"/redhat_access/r/insights/v1/static/release/insights-core.egg" => "https://cert-api.access.example.com/r/insights/v1/static/release/insights-core.egg",
|
20
|
+
"/redhat_access/r/insights/v1/static/uploader.v2.json" => "https://cert-api.access.example.com/r/insights/v1/static/uploader.v2.json",
|
21
|
+
"/redhat_access/r/insights/v1/static/uploader.v2.json.asc" => "https://cert-api.access.example.com/r/insights/v1/static/uploader.v2.json.asc",
|
22
|
+
"/redhat_access/r/insights/platform/inventory/v1/hosts" => "https://cert.cloud.example.com/api/inventory/v1/hosts",
|
23
|
+
"/redhat_access/r/insights/platform/ingress/v1/upload" => "https://cert.cloud.example.com/api/ingress/v1/upload",
|
24
|
+
"/redhat_access/r/insights/uploads/67200803-132b-474b-a6f9-37be74185df4" => "https://cert-api.access.example.com/r/insights/uploads/67200803-132b-474b-a6f9-37be74185df4",
|
25
|
+
"/redhat_access/r/insights/" => "https://cert.cloud.example.com/api/apicast-tests/ping",
|
21
26
|
}
|
22
27
|
|
23
28
|
paths.each do |key, value|
|
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: 5.0.
|
4
|
+
version: 5.0.35
|
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-05-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: katello
|