foreman_rh_cloud 12.1.2 → 12.1.4
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/README.md +3 -5
- data/app/controllers/concerns/insights_cloud/package_profile_upload_extensions.rb +33 -0
- data/app/controllers/insights_cloud/api/machine_telemetries_controller.rb +1 -1
- data/app/services/foreman_rh_cloud/cert_auth.rb +9 -1
- data/app/services/foreman_rh_cloud/cloud_request_forwarder.rb +8 -3
- data/app/views/api/v2/hosts/insights/base.rabl +6 -0
- data/db/seeds.d/200_features.rb +4 -0
- data/lib/foreman_inventory_upload/async/generate_report_job.rb +11 -5
- data/lib/foreman_inventory_upload/async/upload_report_job.rb +15 -4
- data/lib/foreman_inventory_upload/generators/archived_report.rb +2 -2
- data/lib/foreman_inventory_upload/generators/fact_helpers.rb +65 -13
- data/lib/foreman_inventory_upload/generators/queries.rb +7 -5
- data/lib/foreman_inventory_upload/generators/slice.rb +0 -1
- data/lib/foreman_inventory_upload/generators/tags.rb +4 -1
- data/lib/foreman_inventory_upload.rb +2 -2
- data/lib/foreman_rh_cloud/engine.rb +31 -2
- data/lib/foreman_rh_cloud/version.rb +1 -1
- data/lib/inventory_sync/async/inventory_hosts_sync.rb +2 -0
- data/lib/tasks/hybrid_cloud.rake +105 -37
- data/lib/tasks/rh_cloud_inventory.rake +3 -2
- data/package.json +1 -1
- data/test/controllers/insights_cloud/api/cloud_request_controller_test.rb +1 -2
- data/test/unit/archived_report_generator_test.rb +1 -1
- data/test/unit/fact_helpers_test.rb +267 -2
- data/test/unit/rh_cloud_http_proxy_test.rb +8 -0
- data/test/unit/services/foreman_rh_cloud/cloud_request_forwarder_test.rb +19 -2
- data/test/unit/slice_generator_test.rb +69 -10
- data/test/unit/tags_generator_test.rb +1 -0
- data/webpack/ForemanColumnExtensions/index.js +41 -0
- data/webpack/global_index.js +3 -0
- metadata +4 -1
@@ -64,9 +64,10 @@ class SliceGeneratorTest < ActiveSupport::TestCase
|
|
64
64
|
'dmi::system::product_name',
|
65
65
|
'dmi::chassis::asset_tag',
|
66
66
|
'insights_client::obfuscate_hostname_enabled',
|
67
|
+
'insights_client::obfuscated_hostname',
|
68
|
+
'insights_client::obfuscate_ipv4_enabled',
|
69
|
+
'insights_client::obfuscated_ipv4',
|
67
70
|
'insights_client::hostname',
|
68
|
-
'insights_client::obfuscate_ip_enabled',
|
69
|
-
'insights_client::ips',
|
70
71
|
'insights_id',
|
71
72
|
]
|
72
73
|
end
|
@@ -418,14 +419,38 @@ class SliceGeneratorTest < ActiveSupport::TestCase
|
|
418
419
|
assert_equal 1, generator.hosts_count
|
419
420
|
end
|
420
421
|
|
421
|
-
test '
|
422
|
+
test 'does not obfuscate fqdn when insights_client obfuscate_hostname_enabled fact is missing and obfuscate_inventory_hostnames setting is false' do
|
423
|
+
# Create a host and obfuscated_hostname fact, but do NOT create the obfuscate_hostname_enabled fact
|
424
|
+
obfuscated_hostname_data = [
|
425
|
+
{ 'original' => @host.fqdn, 'obfuscated' => '0dd449d0a027.example.com' },
|
426
|
+
]
|
427
|
+
obfuscated_hostname_value = JSON.generate(obfuscated_hostname_data)
|
428
|
+
FactoryBot.create(:fact_value,
|
429
|
+
fact_name: fact_names['insights_client::obfuscated_hostname'],
|
430
|
+
value: obfuscated_hostname_value,
|
431
|
+
host: @host)
|
432
|
+
# Do NOT create the 'insights_client::obfuscate_hostname_enabled' fact
|
433
|
+
|
434
|
+
batch = Host.where(id: @host.id).in_batches.first
|
435
|
+
generator = create_generator(batch)
|
436
|
+
|
437
|
+
json_str = generator.render
|
438
|
+
actual = JSON.parse(json_str.join("\n"))
|
439
|
+
|
440
|
+
assert_not_nil(actual_host = actual['hosts'].first)
|
441
|
+
assert_equal @host.fqdn, actual_host['fqdn'], "FQDN should not be obfuscated when obfuscate_hostname_enabled is missing and setting is false"
|
442
|
+
assert_not_nil(actual_facts = actual_host['facts'].first['facts'])
|
443
|
+
assert_not_equal true, actual_facts['is_hostname_obfuscated']
|
444
|
+
end
|
445
|
+
|
446
|
+
test 'generates obfuscated ip_address fields when insights-client facts are present' do
|
422
447
|
nic = FactoryBot.build(:nic_managed)
|
423
448
|
@host.interfaces << nic
|
424
449
|
|
425
|
-
FactoryBot.create(:fact_value, fact_name: fact_names['insights_client::
|
450
|
+
FactoryBot.create(:fact_value, fact_name: fact_names['insights_client::obfuscate_ipv4_enabled'], value: 'true', host: @host)
|
426
451
|
FactoryBot.create(
|
427
452
|
:fact_value,
|
428
|
-
fact_name: fact_names['insights_client::
|
453
|
+
fact_name: fact_names['insights_client::obfuscated_ipv4'],
|
429
454
|
value: "[{\"obfuscated\": \"10.230.230.100\", \"original\": \"#{nic.ip}\"}]",
|
430
455
|
host: @host
|
431
456
|
)
|
@@ -448,9 +473,17 @@ class SliceGeneratorTest < ActiveSupport::TestCase
|
|
448
473
|
assert_equal 1, generator.hosts_count
|
449
474
|
end
|
450
475
|
|
451
|
-
test 'obfuscates fqdn when
|
476
|
+
test 'obfuscates fqdn when insights-client facts are present' do
|
477
|
+
obfuscated_hostname_data = [
|
478
|
+
{ 'original' => @host.fqdn, 'obfuscated' => '0dd449d0a027.example.com' },
|
479
|
+
{ 'original' => 'satellite.theforeman.org', 'obfuscated' => 'host2.example.com' },
|
480
|
+
]
|
481
|
+
obfuscated_hostname_value = JSON.generate(obfuscated_hostname_data)
|
482
|
+
FactoryBot.create(:fact_value,
|
483
|
+
fact_name: fact_names['insights_client::obfuscated_hostname'],
|
484
|
+
value: obfuscated_hostname_value,
|
485
|
+
host: @host)
|
452
486
|
FactoryBot.create(:fact_value, fact_name: fact_names['insights_client::obfuscate_hostname_enabled'], value: 'true', host: @host)
|
453
|
-
FactoryBot.create(:fact_value, fact_name: fact_names['insights_client::hostname'], value: 'obfuscated_name', host: @host)
|
454
487
|
|
455
488
|
batch = Host.where(id: @host.id).in_batches.first
|
456
489
|
generator = create_generator(batch)
|
@@ -460,7 +493,7 @@ class SliceGeneratorTest < ActiveSupport::TestCase
|
|
460
493
|
|
461
494
|
assert_equal '00000000-0000-0000-0000-000000000000', actual['report_slice_id']
|
462
495
|
assert_not_nil(actual_host = actual['hosts'].first)
|
463
|
-
assert_equal '
|
496
|
+
assert_equal obfuscated_hostname_data.first['obfuscated'], actual_host['fqdn']
|
464
497
|
assert_equal '1234', actual_host['account']
|
465
498
|
assert_not_nil(actual_facts = actual_host['facts'].first['facts'])
|
466
499
|
assert_equal true, actual_facts['is_hostname_obfuscated']
|
@@ -487,9 +520,35 @@ class SliceGeneratorTest < ActiveSupport::TestCase
|
|
487
520
|
assert_equal 1, generator.hosts_count
|
488
521
|
end
|
489
522
|
|
490
|
-
test '
|
523
|
+
test 'obfuscates host fqdn with insights-client when setting set' do
|
524
|
+
Setting[:obfuscate_inventory_hostnames] = true
|
525
|
+
FactoryBot.create(:fact_value, fact_name: fact_names['insights_client::hostname'], value: @host.fqdn, host: @host)
|
526
|
+
|
527
|
+
batch = Host.where(id: @host.id).in_batches.first
|
528
|
+
generator = create_generator(batch)
|
529
|
+
|
530
|
+
json_str = generator.render
|
531
|
+
actual = JSON.parse(json_str.join("\n"))
|
532
|
+
|
533
|
+
obfuscated_fqdn = Digest::SHA1.hexdigest(@host.fqdn) + '.example.com'
|
534
|
+
|
535
|
+
assert_equal '00000000-0000-0000-0000-000000000000', actual['report_slice_id']
|
536
|
+
assert_not_nil(actual_host = actual['hosts'].first)
|
537
|
+
assert_equal obfuscated_fqdn, actual_host['fqdn']
|
538
|
+
assert_equal '1234', actual_host['account']
|
539
|
+
assert_not_nil(actual_facts = actual_host['facts'].first['facts'])
|
540
|
+
assert_equal true, actual_facts['is_hostname_obfuscated']
|
541
|
+
assert_equal 1, generator.hosts_count
|
542
|
+
end
|
543
|
+
|
544
|
+
test 'does not obfuscate fqdn when host fact from insights-client has a value of false' do
|
545
|
+
obfuscated_hostname_data = [
|
546
|
+
{ 'original' => @host.fqdn, 'obfuscated' => '0dd449d0a027.example.com' },
|
547
|
+
{ 'original' => 'satellite.theforeman.org', 'obfuscated' => 'host2.example.com' },
|
548
|
+
]
|
549
|
+
obfuscated_hostname_value = JSON.generate(obfuscated_hostname_data)
|
491
550
|
FactoryBot.create(:fact_value, fact_name: fact_names['insights_client::obfuscate_hostname_enabled'], value: 'false', host: @host)
|
492
|
-
FactoryBot.create(:fact_value, fact_name: fact_names['insights_client::
|
551
|
+
FactoryBot.create(:fact_value, fact_name: fact_names['insights_client::obfuscated_hostname'], value: obfuscated_hostname_value, host: @host)
|
493
552
|
|
494
553
|
batch = Host.where(id: @host.id).in_batches.first
|
495
554
|
generator = create_generator(batch)
|
@@ -61,6 +61,7 @@ class TagsGeneratorTest < ActiveSupport::TestCase
|
|
61
61
|
assert_equal @host.content_views.pluck(:name).max, actual['content_view'].map(&:second).max
|
62
62
|
assert_equal Foreman.instance_id, actual['satellite_instance_id'].first.last
|
63
63
|
assert_equal @host.organization_id.to_s, actual['organization_id'].first.last
|
64
|
+
assert_equal @host.organization.label, actual['organization_label'].first.last
|
64
65
|
end
|
65
66
|
|
66
67
|
test 'filters tags with empty values' do
|
@@ -0,0 +1,41 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { translate as __ } from 'foremanReact/common/I18n';
|
3
|
+
import { propsToCamelCase } from 'foremanReact/common/helpers';
|
4
|
+
|
5
|
+
const RecommendationsCell = hostDetails => {
|
6
|
+
const insightsAttributes = propsToCamelCase(
|
7
|
+
// eslint-disable-next-line camelcase
|
8
|
+
hostDetails?.insights_attributes ?? {}
|
9
|
+
);
|
10
|
+
// Local insights advisor
|
11
|
+
if (insightsAttributes.useLocalAdvisorEngine) {
|
12
|
+
// TODO: Replace this placeholder with the actual local advisor integration
|
13
|
+
return <span>Local advisor placeholder</span>;
|
14
|
+
}
|
15
|
+
|
16
|
+
// Hosted insights advisor
|
17
|
+
const { insightsHitsCount: hitsCount } = insightsAttributes;
|
18
|
+
if (hitsCount === undefined || hitsCount === null) return '—';
|
19
|
+
const hostname = hostDetails?.name;
|
20
|
+
const encodedHostname = encodeURIComponent(hostname);
|
21
|
+
const hitsUrl = `/foreman_rh_cloud/insights_cloud?search=hostname+%3D+${encodedHostname}`;
|
22
|
+
return <a href={hitsUrl}>{hitsCount}</a>;
|
23
|
+
};
|
24
|
+
|
25
|
+
const hostsIndexColumnExtensions = [
|
26
|
+
{
|
27
|
+
columnName: 'insights_recommendations_count',
|
28
|
+
title: __('Recommendations'),
|
29
|
+
wrapper: RecommendationsCell,
|
30
|
+
weight: 1500,
|
31
|
+
isSorted: true,
|
32
|
+
},
|
33
|
+
];
|
34
|
+
|
35
|
+
hostsIndexColumnExtensions.forEach(column => {
|
36
|
+
column.tableName = 'hosts';
|
37
|
+
column.categoryName = 'Insights';
|
38
|
+
column.categoryKey = 'insights';
|
39
|
+
});
|
40
|
+
|
41
|
+
export default hostsIndexColumnExtensions;
|
data/webpack/global_index.js
CHANGED
@@ -1,7 +1,10 @@
|
|
1
|
+
import { registerColumns } from 'foremanReact/components/HostsIndex/Columns/core';
|
1
2
|
import { registerReducers } from './ForemanRhCloudReducers';
|
2
3
|
import { registerFills } from './ForemanRhCloudFills';
|
3
4
|
import { registerRoutes } from './ForemanRhCloudPages';
|
5
|
+
import hostsIndexColumnExtensions from './ForemanColumnExtensions/index';
|
4
6
|
|
5
7
|
registerReducers();
|
6
8
|
registerFills();
|
7
9
|
registerRoutes();
|
10
|
+
registerColumns(hostsIndexColumnExtensions);
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foreman_rh_cloud
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 12.1.
|
4
|
+
version: 12.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Foreman Red Hat Cloud team
|
@@ -100,6 +100,7 @@ files:
|
|
100
100
|
- app/controllers/api/v2/rh_cloud/inventory_controller.rb
|
101
101
|
- app/controllers/concerns/insights_cloud/candlepin_cache.rb
|
102
102
|
- app/controllers/concerns/insights_cloud/client_authentication.rb
|
103
|
+
- app/controllers/concerns/insights_cloud/package_profile_upload_extensions.rb
|
103
104
|
- app/controllers/concerns/inventory_upload/report_actions.rb
|
104
105
|
- app/controllers/concerns/inventory_upload/task_actions.rb
|
105
106
|
- app/controllers/foreman_inventory_upload/accounts_controller.rb
|
@@ -173,6 +174,7 @@ files:
|
|
173
174
|
- db/migrate/20241220184900_change_sync_insights_recommendations_to_true.rb
|
174
175
|
- db/seeds.d/179_ui_notifications.rb
|
175
176
|
- db/seeds.d/189_add_host_inventory_param.rb
|
177
|
+
- db/seeds.d/200_features.rb
|
176
178
|
- db/seeds.d/50_job_templates.rb
|
177
179
|
- lib/foreman_inventory_upload.rb
|
178
180
|
- lib/foreman_inventory_upload/async/async_helpers.rb
|
@@ -283,6 +285,7 @@ files:
|
|
283
285
|
- webpack/CVEsHostDetailsTab/CVEsHostDetailsTab.js
|
284
286
|
- webpack/CVEsHostDetailsTab/__tests__/CVEsHostDetailsTab.test.js
|
285
287
|
- webpack/CVEsHostDetailsTab/index.js
|
288
|
+
- webpack/ForemanColumnExtensions/index.js
|
286
289
|
- webpack/ForemanInventoryUpload/Components/AccountList/AccountList.fixtures.js
|
287
290
|
- webpack/ForemanInventoryUpload/Components/AccountList/AccountList.js
|
288
291
|
- webpack/ForemanInventoryUpload/Components/AccountList/AccountList.stories.js
|