foreman_rh_cloud 5.0.30 → 5.0.33
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/api/v2/rh_cloud/cloud_request_controller.rb +83 -0
- data/app/controllers/foreman_inventory_upload/uploads_controller.rb +7 -0
- data/app/helpers/foreman_inventory_upload_host_helper.rb +2 -1
- data/app/models/setting/rh_cloud.rb +2 -1
- data/app/services/foreman_rh_cloud/cloud_ping_service.rb +4 -1
- data/app/services/foreman_rh_cloud/cloud_presence.rb +124 -0
- data/app/services/foreman_rh_cloud/cloud_request.rb +8 -1
- data/app/services/foreman_rh_cloud/cloud_request_forwarder.rb +1 -1
- data/app/services/foreman_rh_cloud/hit_remediations_retriever.rb +67 -0
- data/app/services/foreman_rh_cloud/remediations_retriever.rb +16 -45
- data/app/services/foreman_rh_cloud/template_renderer_helper.rb +13 -1
- data/app/services/foreman_rh_cloud/url_remediations_retriever.rb +37 -0
- data/app/views/job_templates/rh_cloud_download_playbook.erb +26 -0
- data/config/routes.rb +2 -0
- data/lib/foreman_inventory_upload/generators/fact_helpers.rb +3 -1
- data/lib/foreman_rh_cloud/engine.rb +13 -2
- data/lib/foreman_rh_cloud/version.rb +1 -1
- data/lib/foreman_rh_cloud.rb +11 -1
- data/lib/insights_cloud/async/connector_playbook_execution_reporter_task.rb +193 -0
- data/lib/insights_cloud/generators/playbook_progress_generator.rb +49 -0
- data/lib/tasks/insights.rake +13 -0
- data/package.json +1 -1
- data/test/controllers/insights_cloud/api/cloud_request_controller_test.rb +78 -0
- data/test/controllers/inventory_upload/cloud_status_controller_test.rb +2 -0
- data/test/jobs/connector_playbook_execution_reporter_task_test.rb +207 -0
- data/test/unit/fact_helpers_test.rb +2 -2
- data/test/unit/foreman_rh_cloud_self_host_test.rb +7 -0
- data/test/unit/playbook_progress_generator_test.rb +75 -0
- data/test/unit/services/foreman_rh_cloud/cloud_request_forwarder_test.rb +19 -0
- data/test/unit/services/foreman_rh_cloud/cloud_status_service_test.rb +4 -0
- data/test/unit/services/foreman_rh_cloud/{remediations_retriever_test.rb → hit_remediations_retriever_test.rb} +3 -3
- data/test/unit/services/foreman_rh_cloud/url_remediations_retriever_test.rb +27 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudPingModal/index.js +1 -1
- data/webpack/InsightsHostDetailsTab/InsightsTotalRiskChart.js +1 -1
- metadata +19 -4
@@ -133,4 +133,23 @@ class CloudRequestForwarderTest < ActiveSupport::TestCase
|
|
133
133
|
assert_equal 'GET', actual[:method]
|
134
134
|
assert_equal params, actual[:headers][:params]
|
135
135
|
end
|
136
|
+
|
137
|
+
test 'should forward content type correctly' do
|
138
|
+
user_agent = { :foo => :bar }
|
139
|
+
params = { :page => 5, :per_page => 42 }
|
140
|
+
ForemanRhCloud::BranchInfo.any_instance.expects(:core_app_name).returns('test_app')
|
141
|
+
ForemanRhCloud::BranchInfo.any_instance.expects(:core_app_version).returns('test_ver')
|
142
|
+
|
143
|
+
req = ActionDispatch::Request.new(
|
144
|
+
'REQUEST_URI' => '/foo/bar',
|
145
|
+
'REQUEST_METHOD' => 'GET',
|
146
|
+
'HTTP_USER_AGENT' => user_agent,
|
147
|
+
'rack.input' => ::Puma::NullIO.new,
|
148
|
+
'action_dispatch.request.query_parameters' => params
|
149
|
+
)
|
150
|
+
|
151
|
+
actual = @forwarder.prepare_request_opts(req, 'TEST PAYLOAD', params, generate_certs_hash)
|
152
|
+
|
153
|
+
assert_match /text\/html/, actual[:headers][:content_type]
|
154
|
+
end
|
136
155
|
end
|
@@ -28,6 +28,8 @@ class CloudStatusServiceTest < ActiveSupport::TestCase
|
|
28
28
|
RestClient::Response.new('TEST RESPONSE ORG 1')
|
29
29
|
)
|
30
30
|
|
31
|
+
Katello::UpstreamConnectionChecker.any_instance.expects(:assert_connection).twice.returns(true)
|
32
|
+
|
31
33
|
service = ForemanRhCloud::CloudPingService.new(organizations, nil)
|
32
34
|
actual = service.ping
|
33
35
|
|
@@ -55,6 +57,8 @@ class CloudStatusServiceTest < ActiveSupport::TestCase
|
|
55
57
|
'TEST RESPONSE ORG 0'
|
56
58
|
)
|
57
59
|
|
60
|
+
Katello::UpstreamConnectionChecker.any_instance.expects(:assert_connection).returns(true)
|
61
|
+
|
58
62
|
service = ForemanRhCloud::CloudPingService.new(organizations, nil)
|
59
63
|
actual = service.ping
|
60
64
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'test_plugin_helper'
|
2
2
|
|
3
|
-
class
|
3
|
+
class HitRemediationsRetrieverTest < ActiveSupport::TestCase
|
4
4
|
setup do
|
5
5
|
@host1 = FactoryBot.create(:host)
|
6
6
|
@host2 = FactoryBot.create(:host)
|
@@ -16,7 +16,7 @@ class RemediationsRetrieverTest < ActiveSupport::TestCase
|
|
16
16
|
host2_hit1 = FactoryBot.create(:insights_hit, rule_id: rule1.rule_id, host_id: @host2.id)
|
17
17
|
|
18
18
|
pairs = [{'hit_id' => host1_hit1.id, 'resolution_id' => rule1_remediation1.id}, {'hit_id' => host2_hit1.id, 'resolution_id' => rule1_remediation1.id}]
|
19
|
-
retriever = ForemanRhCloud::
|
19
|
+
retriever = ForemanRhCloud::HitRemediationsRetriever.new(pairs)
|
20
20
|
|
21
21
|
actual_request = retriever.send(:playbook_request)
|
22
22
|
|
@@ -39,7 +39,7 @@ class RemediationsRetrieverTest < ActiveSupport::TestCase
|
|
39
39
|
host2_hit1 = FactoryBot.create(:insights_hit, rule_id: rule1.rule_id, host_id: @host2.id)
|
40
40
|
|
41
41
|
pairs = [{'hit_id' => host1_hit1.id, 'resolution_id' => rule1_remediation1.id}, {'hit_id' => host2_hit1.id, 'resolution_id' => rule1_remediation2.id}]
|
42
|
-
retriever = ForemanRhCloud::
|
42
|
+
retriever = ForemanRhCloud::HitRemediationsRetriever.new(pairs)
|
43
43
|
|
44
44
|
actual_request = retriever.send(:playbook_request)
|
45
45
|
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'test_plugin_helper'
|
2
|
+
|
3
|
+
class UrlRemediationsRetrieverTest < ActiveSupport::TestCase
|
4
|
+
test 'Calls the given url' do
|
5
|
+
Setting[:rh_cloud_token] = 'TEST_TOKEN'
|
6
|
+
retreiver = ForemanRhCloud::UrlRemediationsRetriever.new(
|
7
|
+
url: 'http://test.example.com',
|
8
|
+
payload: 'TEST_PAYLOAD',
|
9
|
+
headers: {
|
10
|
+
custom1: 'TEST_HEADER',
|
11
|
+
}
|
12
|
+
)
|
13
|
+
|
14
|
+
response = mock('response')
|
15
|
+
response.stubs(:body).returns('TEST_RESPONSE')
|
16
|
+
retreiver.expects(:execute_cloud_request).with do |params|
|
17
|
+
params[:method] == :get &&
|
18
|
+
params[:url] == 'http://test.example.com' &&
|
19
|
+
params[:headers][:custom1] == 'TEST_HEADER' &&
|
20
|
+
params[:payload] == "\"TEST_PAYLOAD\""
|
21
|
+
end.returns(response)
|
22
|
+
|
23
|
+
actual = retreiver.create_playbook
|
24
|
+
|
25
|
+
assert_equal 'TEST_RESPONSE', actual
|
26
|
+
end
|
27
|
+
end
|
@@ -25,7 +25,7 @@ const InsightsTotalRiskCard = ({ hostDetails: { id } }) => {
|
|
25
25
|
} = useAPI('get', insightsCloudUrl(`hits/${id}`), API_OPTIONS);
|
26
26
|
|
27
27
|
useEffect(() => {
|
28
|
-
if (status
|
28
|
+
if (status === STATUS.RESOLVED) {
|
29
29
|
const risks = getInitialRisks();
|
30
30
|
hits.forEach(({ total_risk: risk }) => {
|
31
31
|
risks[risk].value += 1;
|
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.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: 2022-
|
11
|
+
date: 2022-04-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: katello
|
@@ -132,6 +132,7 @@ files:
|
|
132
132
|
- LICENSE
|
133
133
|
- README.md
|
134
134
|
- Rakefile
|
135
|
+
- app/controllers/api/v2/rh_cloud/cloud_request_controller.rb
|
135
136
|
- app/controllers/api/v2/rh_cloud/inventory_controller.rb
|
136
137
|
- app/controllers/concerns/insights_cloud/candlepin_cache.rb
|
137
138
|
- app/controllers/concerns/insights_cloud/client_authentication.rb
|
@@ -166,12 +167,16 @@ files:
|
|
166
167
|
- app/services/foreman_rh_cloud/cloud_auth.rb
|
167
168
|
- app/services/foreman_rh_cloud/cloud_connector.rb
|
168
169
|
- app/services/foreman_rh_cloud/cloud_ping_service.rb
|
170
|
+
- app/services/foreman_rh_cloud/cloud_presence.rb
|
169
171
|
- app/services/foreman_rh_cloud/cloud_request.rb
|
170
172
|
- app/services/foreman_rh_cloud/cloud_request_forwarder.rb
|
173
|
+
- app/services/foreman_rh_cloud/hit_remediations_retriever.rb
|
171
174
|
- app/services/foreman_rh_cloud/insights_status_cleaner.rb
|
172
175
|
- app/services/foreman_rh_cloud/remediations_retriever.rb
|
173
176
|
- app/services/foreman_rh_cloud/template_renderer_helper.rb
|
177
|
+
- app/services/foreman_rh_cloud/url_remediations_retriever.rb
|
174
178
|
- app/views/hosts/_insights_tab.html.erb
|
179
|
+
- app/views/job_templates/rh_cloud_download_playbook.erb
|
175
180
|
- app/views/job_templates/rh_cloud_remediations.erb
|
176
181
|
- app/views/layouts/foreman_rh_cloud/application.html.erb
|
177
182
|
- config/Gemfile.lock.gh_test
|
@@ -215,6 +220,7 @@ files:
|
|
215
220
|
- lib/foreman_rh_cloud/engine.rb
|
216
221
|
- lib/foreman_rh_cloud/version.rb
|
217
222
|
- lib/insights_cloud.rb
|
223
|
+
- lib/insights_cloud/async/connector_playbook_execution_reporter_task.rb
|
218
224
|
- lib/insights_cloud/async/insights_client_status_aging.rb
|
219
225
|
- lib/insights_cloud/async/insights_full_sync.rb
|
220
226
|
- lib/insights_cloud/async/insights_generate_notifications.rb
|
@@ -222,6 +228,7 @@ files:
|
|
222
228
|
- lib/insights_cloud/async/insights_rules_sync.rb
|
223
229
|
- lib/insights_cloud/async/insights_scheduled_sync.rb
|
224
230
|
- lib/insights_cloud/async/rules_result.rb
|
231
|
+
- lib/insights_cloud/generators/playbook_progress_generator.rb
|
225
232
|
- lib/inventory_sync/async/host_result.rb
|
226
233
|
- lib/inventory_sync/async/inventory_full_sync.rb
|
227
234
|
- lib/inventory_sync/async/inventory_hosts_sync.rb
|
@@ -237,6 +244,7 @@ files:
|
|
237
244
|
- locale/gemspec.rb
|
238
245
|
- package.json
|
239
246
|
- test/controllers/accounts_controller_test.rb
|
247
|
+
- test/controllers/insights_cloud/api/cloud_request_controller_test.rb
|
240
248
|
- test/controllers/insights_cloud/api/machine_telemetries_controller_test.rb
|
241
249
|
- test/controllers/insights_sync/settings_controller_test.rb
|
242
250
|
- test/controllers/inventory_upload/api/inventory_controller_test.rb
|
@@ -246,6 +254,7 @@ files:
|
|
246
254
|
- test/controllers/uploads_settings_controller_test.rb
|
247
255
|
- test/factories/insights_factories.rb
|
248
256
|
- test/factories/inventory_upload_factories.rb
|
257
|
+
- test/jobs/connector_playbook_execution_reporter_task_test.rb
|
249
258
|
- test/jobs/insights_client_status_aging_test.rb
|
250
259
|
- test/jobs/insights_full_sync_test.rb
|
251
260
|
- test/jobs/insights_resolutions_sync_test.rb
|
@@ -262,14 +271,16 @@ files:
|
|
262
271
|
- test/unit/foreman_rh_cloud_self_host_test.rb
|
263
272
|
- test/unit/insights_facet_test.rb
|
264
273
|
- test/unit/metadata_generator_test.rb
|
274
|
+
- test/unit/playbook_progress_generator_test.rb
|
265
275
|
- test/unit/rh_cloud_http_proxy_test.rb
|
266
276
|
- test/unit/rh_cloud_permissions_test.rb
|
267
277
|
- test/unit/services/foreman_rh_cloud/branch_info_test.rb
|
268
278
|
- test/unit/services/foreman_rh_cloud/cloud_request_forwarder_test.rb
|
269
279
|
- test/unit/services/foreman_rh_cloud/cloud_status_service_test.rb
|
280
|
+
- test/unit/services/foreman_rh_cloud/hit_remediations_retriever_test.rb
|
270
281
|
- test/unit/services/foreman_rh_cloud/insights_status_cleaner_test.rb
|
271
|
-
- test/unit/services/foreman_rh_cloud/remediations_retriever_test.rb
|
272
282
|
- test/unit/services/foreman_rh_cloud/template_renderer_helper_test.rb
|
283
|
+
- test/unit/services/foreman_rh_cloud/url_remediations_retriever_test.rb
|
273
284
|
- test/unit/shell_process_job_test.rb
|
274
285
|
- test/unit/slice_generator_test.rb
|
275
286
|
- test/unit/tags_generator_test.rb
|
@@ -672,6 +683,7 @@ specification_version: 4
|
|
672
683
|
summary: Summary of ForemanRhCloud.
|
673
684
|
test_files:
|
674
685
|
- test/controllers/accounts_controller_test.rb
|
686
|
+
- test/controllers/insights_cloud/api/cloud_request_controller_test.rb
|
675
687
|
- test/controllers/insights_cloud/api/machine_telemetries_controller_test.rb
|
676
688
|
- test/controllers/insights_sync/settings_controller_test.rb
|
677
689
|
- test/controllers/inventory_upload/api/inventory_controller_test.rb
|
@@ -681,6 +693,7 @@ test_files:
|
|
681
693
|
- test/controllers/uploads_settings_controller_test.rb
|
682
694
|
- test/factories/insights_factories.rb
|
683
695
|
- test/factories/inventory_upload_factories.rb
|
696
|
+
- test/jobs/connector_playbook_execution_reporter_task_test.rb
|
684
697
|
- test/jobs/insights_client_status_aging_test.rb
|
685
698
|
- test/jobs/insights_full_sync_test.rb
|
686
699
|
- test/jobs/insights_resolutions_sync_test.rb
|
@@ -697,14 +710,16 @@ test_files:
|
|
697
710
|
- test/unit/foreman_rh_cloud_self_host_test.rb
|
698
711
|
- test/unit/insights_facet_test.rb
|
699
712
|
- test/unit/metadata_generator_test.rb
|
713
|
+
- test/unit/playbook_progress_generator_test.rb
|
700
714
|
- test/unit/rh_cloud_http_proxy_test.rb
|
701
715
|
- test/unit/rh_cloud_permissions_test.rb
|
702
716
|
- test/unit/services/foreman_rh_cloud/branch_info_test.rb
|
703
717
|
- test/unit/services/foreman_rh_cloud/cloud_request_forwarder_test.rb
|
704
718
|
- test/unit/services/foreman_rh_cloud/cloud_status_service_test.rb
|
719
|
+
- test/unit/services/foreman_rh_cloud/hit_remediations_retriever_test.rb
|
705
720
|
- test/unit/services/foreman_rh_cloud/insights_status_cleaner_test.rb
|
706
|
-
- test/unit/services/foreman_rh_cloud/remediations_retriever_test.rb
|
707
721
|
- test/unit/services/foreman_rh_cloud/template_renderer_helper_test.rb
|
722
|
+
- test/unit/services/foreman_rh_cloud/url_remediations_retriever_test.rb
|
708
723
|
- test/unit/shell_process_job_test.rb
|
709
724
|
- test/unit/slice_generator_test.rb
|
710
725
|
- test/unit/tags_generator_test.rb
|