foreman_rh_cloud 4.0.25.1 → 4.0.26

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.
Files changed (30) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/api/v2/rh_cloud/inventory_controller.rb +4 -1
  3. data/app/controllers/insights_cloud/api/machine_telemetries_controller.rb +8 -0
  4. data/app/services/foreman_rh_cloud/cloud_request_forwarder.rb +14 -2
  5. data/config/Gemfile.lock.gh_test +74 -76
  6. data/config/routes.rb +1 -1
  7. data/lib/foreman_rh_cloud/engine.rb +2 -0
  8. data/lib/foreman_rh_cloud/version.rb +1 -1
  9. data/lib/insights_cloud/async/insights_client_status_aging.rb +4 -0
  10. data/lib/insights_cloud/async/insights_full_sync.rb +4 -0
  11. data/lib/insights_cloud/async/insights_generate_notifications.rb +4 -0
  12. data/lib/insights_cloud/async/insights_resolutions_sync.rb +7 -2
  13. data/lib/insights_cloud/async/insights_rules_sync.rb +10 -2
  14. data/lib/inventory_sync/async/inventory_full_sync.rb +4 -0
  15. data/lib/inventory_sync/async/inventory_hosts_sync.rb +4 -0
  16. data/lib/inventory_sync/async/inventory_scheduled_sync.rb +4 -0
  17. data/lib/inventory_sync/async/inventory_self_host_sync.rb +4 -0
  18. data/lib/inventory_sync/async/query_inventory_job.rb +4 -0
  19. data/package.json +2 -2
  20. data/test/controllers/insights_cloud/api/machine_telemetries_controller_test.rb +16 -39
  21. data/test/jobs/insights_resolutions_sync_test.rb +10 -1
  22. data/test/unit/services/foreman_rh_cloud/cloud_request_forwarder_test.rb +26 -0
  23. data/webpack/InsightsCloudSync/Components/InsightsHeader/index.js +0 -2
  24. data/webpack/InsightsCloudSync/Components/InsightsSettings/insightsSettings.scss +1 -0
  25. data/webpack/InsightsCloudSync/Components/__tests__/__snapshots__/InsightsHeader.test.js.snap +0 -1
  26. data/webpack/InsightsCloudSync/InsightsCloudSync.js +2 -0
  27. data/webpack/InsightsCloudSync/__snapshots__/InsightsCloudSync.test.js.snap +1 -0
  28. data/webpack/common/Switcher/HelpLabel.js +1 -1
  29. data/webpack/common/Switcher/__tests__/__snapshots__/HelpLabel.test.js.snap +1 -1
  30. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cf14938ab96483d5b90b699ad095664ccda999db645f3d0e4b868b8e6066f268
4
- data.tar.gz: 90062d9c4bf632a9d856d17e16639d6920e6a9b9d0bbad1334202041122fd19f
3
+ metadata.gz: 713d1737fd81e7a54efa8a300fe4c0765c1d2a31b796218bcc1f447b473921af
4
+ data.tar.gz: a47efbe51980f47c71e57af619f73a08d214f7af3bb84632946189a1aabe81f3
5
5
  SHA512:
6
- metadata.gz: 46eb0bfffd3853da3d4d0254756469e07f6f690166e96732bcb77a027d9cf3370cbe3d3f72e59a801cf85338fd2b2a042e45dd4a74907df3b66969a1006cb8c8
7
- data.tar.gz: 1464b0f05e778e6b0a002114175b0c0a3f95b51c78af5fecd00395c42d6cd4196dffb0362724bcc62989403500e9994afe9012552e6e0ad00f0c0fe8f2e2fc5e
6
+ metadata.gz: c7419f0e5583f02038cf784e38d67f15dd0dfa3a392a72cd19000c0f51f41fc97a29ed2e9387bfee4e1fe7a91addb563db53167c98343b640f52e3b17a729387
7
+ data.tar.gz: 2eb4fea115c546084e2365807e87933e60a102f1ec7455cfc5a368a1ae5a20587bf7c12206e40816a2893c19d02a035a2cee3c2262982a53f88542599bda629d
@@ -7,6 +7,7 @@ module Api
7
7
  include InventoryUpload::TaskActions
8
8
 
9
9
  api :GET, "/organizations/:organization_id/rh_cloud/report", N_("Download latest report")
10
+ param :organization_id, Integer, required: true, desc: N_("Set the current organization context for the request")
10
11
  def download_file
11
12
  filename, file = report_file(params[:organization_id])
12
13
 
@@ -16,6 +17,7 @@ module Api
16
17
  end
17
18
 
18
19
  api :POST, "/organizations/:organization_id/rh_cloud/report", N_("Start report generation")
20
+ param :organization_id, Integer, required: true, desc: N_("Set the current organization context for the request")
19
21
  def generate_report
20
22
  organization_id = params[:organization_id]
21
23
 
@@ -27,6 +29,7 @@ module Api
27
29
  end
28
30
 
29
31
  api :POST, "/organizations/:organization_id/rh_cloud/inventory_sync", N_("Start inventory synchronization")
32
+ param :organization_id, Integer, required: true, desc: N_("Set the current organization context for the request")
30
33
  def sync_inventory_status
31
34
  selected_org = Organization.find(params[:organization_id])
32
35
 
@@ -39,7 +42,7 @@ module Api
39
42
  render json: { message: error.message }, status: :bad_request
40
43
  end
41
44
 
42
- api :POST, "rh_cloud/enable_connector", N_("Enable cloud connector")
45
+ api :POST, "/rh_cloud/enable_connector", N_("Enable cloud connector")
43
46
  def enable_cloud_connector
44
47
  cloud_connector = ForemanRhCloud::CloudConnector.new
45
48
  render json: cloud_connector.install.to_json
@@ -25,6 +25,14 @@ module InsightsCloud::Api
25
25
  }, status: :bad_gateway
26
26
  end
27
27
 
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
34
+ end
35
+
28
36
  if @cloud_response.headers[:content_disposition]
29
37
  return send_data @cloud_response, disposition: @cloud_response.headers[:content_disposition], type: @cloud_response.headers[:content_type]
30
38
  end
@@ -17,6 +17,8 @@ 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)
@@ -62,6 +64,12 @@ module ForemanRhCloud
62
64
  ssl_client_cert: OpenSSL::X509::Certificate.new(certs[:cert]),
63
65
  ssl_client_key: OpenSSL::PKey::RSA.new(certs[:key]),
64
66
  }
67
+ when connection_test_request?
68
+ {
69
+ url: ForemanRhCloud.cert_base_url + '/api/apicast-tests/ping',
70
+ ssl_client_cert: OpenSSL::X509::Certificate.new(certs[:cert]),
71
+ ssl_client_key: OpenSSL::PKey::RSA.new(certs[:key]),
72
+ }
65
73
  else # Legacy insights API
66
74
  {
67
75
  url: ForemanRhCloud.legacy_insights_url + request_path.sub('/redhat_access/r/insights', '/r/insights'),
@@ -76,6 +84,10 @@ module ForemanRhCloud
76
84
  ->(request_path) { request_path.include? '/platform' }
77
85
  end
78
86
 
87
+ def connection_test_request?
88
+ ->(request_path) { request_path =~ /redhat_access\/r\/insights\/?$/ }
89
+ end
90
+
79
91
  def prepare_forward_cloud_url(base_url, request_path)
80
92
  cloud_path = request_path.sub('/redhat_access/r/insights/platform/', '')
81
93
  .sub('/redhat_access/r/insights/', '')
@@ -84,11 +96,11 @@ module ForemanRhCloud
84
96
  end
85
97
 
86
98
  def core_app_name
87
- 'Foreman'
99
+ BranchInfo.new.core_app_name
88
100
  end
89
101
 
90
102
  def core_app_version
91
- Foreman::Version.new
103
+ BranchInfo.new.core_app_version
92
104
  end
93
105
 
94
106
  def http_user_agent(original_request)
@@ -40,66 +40,66 @@ PATH
40
40
  GEM
41
41
  remote: https://rubygems.org/
42
42
  specs:
43
- actioncable (6.0.3.4)
44
- actionpack (= 6.0.3.4)
43
+ actioncable (6.0.3.6)
44
+ actionpack (= 6.0.3.6)
45
45
  nio4r (~> 2.0)
46
46
  websocket-driver (>= 0.6.1)
47
- actionmailbox (6.0.3.4)
48
- actionpack (= 6.0.3.4)
49
- activejob (= 6.0.3.4)
50
- activerecord (= 6.0.3.4)
51
- activestorage (= 6.0.3.4)
52
- activesupport (= 6.0.3.4)
47
+ actionmailbox (6.0.3.6)
48
+ actionpack (= 6.0.3.6)
49
+ activejob (= 6.0.3.6)
50
+ activerecord (= 6.0.3.6)
51
+ activestorage (= 6.0.3.6)
52
+ activesupport (= 6.0.3.6)
53
53
  mail (>= 2.7.1)
54
- actionmailer (6.0.3.4)
55
- actionpack (= 6.0.3.4)
56
- actionview (= 6.0.3.4)
57
- activejob (= 6.0.3.4)
54
+ actionmailer (6.0.3.6)
55
+ actionpack (= 6.0.3.6)
56
+ actionview (= 6.0.3.6)
57
+ activejob (= 6.0.3.6)
58
58
  mail (~> 2.5, >= 2.5.4)
59
59
  rails-dom-testing (~> 2.0)
60
- actionpack (6.0.3.4)
61
- actionview (= 6.0.3.4)
62
- activesupport (= 6.0.3.4)
60
+ actionpack (6.0.3.6)
61
+ actionview (= 6.0.3.6)
62
+ activesupport (= 6.0.3.6)
63
63
  rack (~> 2.0, >= 2.0.8)
64
64
  rack-test (>= 0.6.3)
65
65
  rails-dom-testing (~> 2.0)
66
66
  rails-html-sanitizer (~> 1.0, >= 1.2.0)
67
- actiontext (6.0.3.4)
68
- actionpack (= 6.0.3.4)
69
- activerecord (= 6.0.3.4)
70
- activestorage (= 6.0.3.4)
71
- activesupport (= 6.0.3.4)
67
+ actiontext (6.0.3.6)
68
+ actionpack (= 6.0.3.6)
69
+ activerecord (= 6.0.3.6)
70
+ activestorage (= 6.0.3.6)
71
+ activesupport (= 6.0.3.6)
72
72
  nokogiri (>= 1.8.5)
73
- actionview (6.0.3.4)
74
- activesupport (= 6.0.3.4)
73
+ actionview (6.0.3.6)
74
+ activesupport (= 6.0.3.6)
75
75
  builder (~> 3.1)
76
76
  erubi (~> 1.4)
77
77
  rails-dom-testing (~> 2.0)
78
78
  rails-html-sanitizer (~> 1.1, >= 1.2.0)
79
- activejob (6.0.3.4)
80
- activesupport (= 6.0.3.4)
79
+ activejob (6.0.3.6)
80
+ activesupport (= 6.0.3.6)
81
81
  globalid (>= 0.3.6)
82
- activemodel (6.0.3.4)
83
- activesupport (= 6.0.3.4)
84
- activerecord (6.0.3.4)
85
- activemodel (= 6.0.3.4)
86
- activesupport (= 6.0.3.4)
87
- activerecord-import (1.0.7)
82
+ activemodel (6.0.3.6)
83
+ activesupport (= 6.0.3.6)
84
+ activerecord (6.0.3.6)
85
+ activemodel (= 6.0.3.6)
86
+ activesupport (= 6.0.3.6)
87
+ activerecord-import (1.0.8)
88
88
  activerecord (>= 3.2)
89
89
  activerecord-nulldb-adapter (0.7.0)
90
90
  activerecord (>= 5.2.0, < 6.3)
91
- activerecord-session_store (1.1.3)
92
- actionpack (>= 4.0)
93
- activerecord (>= 4.0)
91
+ activerecord-session_store (2.0.0)
92
+ actionpack (>= 5.2.4.1)
93
+ activerecord (>= 5.2.4.1)
94
94
  multi_json (~> 1.11, >= 1.11.2)
95
- rack (>= 1.5.2, < 3)
96
- railties (>= 4.0)
97
- activestorage (6.0.3.4)
98
- actionpack (= 6.0.3.4)
99
- activejob (= 6.0.3.4)
100
- activerecord (= 6.0.3.4)
101
- marcel (~> 0.3.1)
102
- activesupport (6.0.3.4)
95
+ rack (>= 2.0.8, < 3)
96
+ railties (>= 5.2.4.1)
97
+ activestorage (6.0.3.6)
98
+ actionpack (= 6.0.3.6)
99
+ activejob (= 6.0.3.6)
100
+ activerecord (= 6.0.3.6)
101
+ marcel (~> 1.0.0)
102
+ activesupport (6.0.3.6)
103
103
  concurrent-ruby (~> 1.0, >= 1.0.2)
104
104
  i18n (>= 0.7, < 2)
105
105
  minitest (~> 5.1)
@@ -108,7 +108,7 @@ GEM
108
108
  addressable (2.7.0)
109
109
  public_suffix (>= 2.0.2, < 5.0)
110
110
  algebrick (0.7.5)
111
- amazing_print (1.2.2)
111
+ amazing_print (1.3.0)
112
112
  ancestry (3.2.1)
113
113
  activerecord (>= 4.2.0)
114
114
  anemone (0.7.2)
@@ -135,13 +135,13 @@ GEM
135
135
  benchmark-ips (2.8.4)
136
136
  binding_of_caller (1.0.0)
137
137
  debug_inspector (>= 0.0.1)
138
- bootsnap (1.7.1)
138
+ bootsnap (1.7.3)
139
139
  msgpack (~> 1.0)
140
140
  bootstrap-sass (3.4.1)
141
141
  autoprefixer-rails (>= 5.2.1)
142
142
  sassc (>= 2.0.0)
143
143
  builder (3.2.4)
144
- bullet (6.1.3)
144
+ bullet (6.1.4)
145
145
  activesupport (>= 3.0.0)
146
146
  uniform_notifier (~> 1.11)
147
147
  byebug (11.1.3)
@@ -167,7 +167,7 @@ GEM
167
167
  coffee-script-source
168
168
  execjs
169
169
  coffee-script-source (1.12.2)
170
- concurrent-ruby (1.1.8)
170
+ concurrent-ruby (1.1.9)
171
171
  concurrent-ruby-edge (0.6.0)
172
172
  concurrent-ruby (~> 1.1.6)
173
173
  connection_pool (2.2.3)
@@ -179,12 +179,12 @@ GEM
179
179
  daemons (1.3.1)
180
180
  database_cleaner (1.99.0)
181
181
  deacon (1.0.0)
182
- debug_inspector (1.0.0)
182
+ debug_inspector (1.1.0)
183
183
  declarative (0.0.20)
184
184
  declarative-option (0.1.0)
185
- deep_cloneable (3.0.0)
185
+ deep_cloneable (3.1.0)
186
186
  activerecord (>= 3.1.0, < 7)
187
- deface (1.6.1)
187
+ deface (1.8.1)
188
188
  nokogiri (>= 1.6)
189
189
  polyglot
190
190
  rails (>= 5.2)
@@ -337,7 +337,7 @@ GEM
337
337
  http-cookie (1.0.3)
338
338
  domain_name (~> 0.5)
339
339
  httpclient (2.8.3)
340
- i18n (1.8.8)
340
+ i18n (1.8.10)
341
341
  concurrent-ruby (~> 1.0)
342
342
  immigrant (0.3.6)
343
343
  activerecord (>= 3.0)
@@ -368,16 +368,14 @@ GEM
368
368
  nokogiri (>= 1.5.9)
369
369
  mail (2.7.1)
370
370
  mini_mime (>= 0.1.1)
371
- marcel (0.3.3)
372
- mimemagic (~> 0.3.2)
371
+ marcel (1.0.0)
373
372
  maruku (0.7.3)
374
373
  memoist (0.16.2)
375
374
  method_source (1.0.0)
376
375
  mime-types (3.3.1)
377
376
  mime-types-data (~> 3.2015)
378
- mime-types-data (3.2020.1104)
379
- mimemagic (0.3.5)
380
- mini_mime (1.0.2)
377
+ mime-types-data (3.2021.0225)
378
+ mini_mime (1.0.3)
381
379
  mini_portile2 (2.5.0)
382
380
  minitest (5.10.3)
383
381
  minitest-reporters (1.4.3)
@@ -403,8 +401,8 @@ GEM
403
401
  net-ssh (>= 2.6.5, < 7.0.0)
404
402
  net-ssh (4.2.0)
405
403
  netrc (0.11.0)
406
- nio4r (2.5.5)
407
- nokogiri (1.11.1)
404
+ nio4r (2.5.7)
405
+ nokogiri (1.11.2)
408
406
  mini_portile2 (~> 2.5.0)
409
407
  racc (~> 1.4)
410
408
  oauth (0.5.5)
@@ -414,7 +412,7 @@ GEM
414
412
  json (>= 1, < 3)
415
413
  paint (2.2.1)
416
414
  parallel (1.20.1)
417
- parallel_tests (3.4.0)
415
+ parallel_tests (3.6.0)
418
416
  parallel
419
417
  parse-cron (0.1.4)
420
418
  parser (3.0.0.0)
@@ -491,20 +489,20 @@ GEM
491
489
  rack
492
490
  rack-test (1.1.0)
493
491
  rack (>= 1.0, < 3)
494
- rails (6.0.3.4)
495
- actioncable (= 6.0.3.4)
496
- actionmailbox (= 6.0.3.4)
497
- actionmailer (= 6.0.3.4)
498
- actionpack (= 6.0.3.4)
499
- actiontext (= 6.0.3.4)
500
- actionview (= 6.0.3.4)
501
- activejob (= 6.0.3.4)
502
- activemodel (= 6.0.3.4)
503
- activerecord (= 6.0.3.4)
504
- activestorage (= 6.0.3.4)
505
- activesupport (= 6.0.3.4)
492
+ rails (6.0.3.6)
493
+ actioncable (= 6.0.3.6)
494
+ actionmailbox (= 6.0.3.6)
495
+ actionmailer (= 6.0.3.6)
496
+ actionpack (= 6.0.3.6)
497
+ actiontext (= 6.0.3.6)
498
+ actionview (= 6.0.3.6)
499
+ activejob (= 6.0.3.6)
500
+ activemodel (= 6.0.3.6)
501
+ activerecord (= 6.0.3.6)
502
+ activestorage (= 6.0.3.6)
503
+ activesupport (= 6.0.3.6)
506
504
  bundler (>= 1.3.0)
507
- railties (= 6.0.3.4)
505
+ railties (= 6.0.3.6)
508
506
  sprockets-rails (>= 2.0.0)
509
507
  rails-controller-testing (1.0.5)
510
508
  actionpack (>= 5.0.1.rc1)
@@ -518,9 +516,9 @@ GEM
518
516
  rails-i18n (6.0.0)
519
517
  i18n (>= 0.7, < 2)
520
518
  railties (>= 6.0.0, < 7)
521
- railties (6.0.3.4)
522
- actionpack (= 6.0.3.4)
523
- activesupport (= 6.0.3.4)
519
+ railties (6.0.3.6)
520
+ actionpack (= 6.0.3.6)
521
+ activesupport (= 6.0.3.6)
524
522
  method_source
525
523
  rake (>= 0.8.7)
526
524
  thor (>= 0.20.3, < 2.0)
@@ -620,8 +618,8 @@ GEM
620
618
  tilt
621
619
  scoped_search (4.1.9)
622
620
  activerecord (>= 4.2.0)
623
- sd_notify (0.1.0)
624
- secure_headers (6.3.1)
621
+ sd_notify (0.1.1)
622
+ secure_headers (6.3.2)
625
623
  selenium-webdriver (3.142.7)
626
624
  childprocess (>= 0.5, < 4.0)
627
625
  rubyzip (>= 1.2.2)
@@ -708,7 +706,7 @@ PLATFORMS
708
706
 
709
707
  DEPENDENCIES
710
708
  activerecord-nulldb-adapter
711
- activerecord-session_store (>= 1.1.0, < 2)
709
+ activerecord-session_store (>= 2.0.0, < 3)
712
710
  amazing_print (~> 1.1)
713
711
  ancestry (>= 3.0.7, < 4, != 3.2.0)
714
712
  apipie-dsl (>= 2.2.6)
data/config/routes.rb CHANGED
@@ -39,7 +39,7 @@ Rails.application.routes.draw do
39
39
  end
40
40
 
41
41
  scope '/r/insights' do
42
- match '/*path', :constraints => lambda { |req| !req.path.include?('view/api') }, to: 'machine_telemetries#forward_request', via: [:get, :post, :delete,:put, :patch]
42
+ match '(/*path)(/)', :constraints => lambda { |req| !req.path.include?('view/api') }, to: 'machine_telemetries#forward_request', via: [:get, :post, :delete,:put, :patch]
43
43
  end
44
44
  end
45
45
 
@@ -42,6 +42,8 @@ module ForemanRhCloud
42
42
  Foreman::Plugin.register :foreman_rh_cloud do
43
43
  requires_foreman '>= 2.3'
44
44
 
45
+ apipie_documented_controllers ["#{ForemanRhCloud::Engine.root}/app/controllers/api/v2/**/*.rb"]
46
+
45
47
  # Add permissions
46
48
  security_block :foreman_rh_cloud do
47
49
  permission(
@@ -1,3 +1,3 @@
1
1
  module ForemanRhCloud
2
- VERSION = '4.0.25.1'.freeze
2
+ VERSION = '4.0.26'.freeze
3
3
  end
@@ -18,6 +18,10 @@ module InsightsCloud
18
18
  def logger
19
19
  action_logger
20
20
  end
21
+
22
+ def rescue_strategy_for_self
23
+ Dynflow::Action::Rescue::Fail
24
+ end
21
25
  end
22
26
  end
23
27
  end
@@ -118,6 +118,10 @@ module InsightsCloud
118
118
 
119
119
  match || { id: nil }
120
120
  end
121
+
122
+ def rescue_strategy_for_self
123
+ Dynflow::Action::Rescue::Fail
124
+ end
121
125
  end
122
126
  end
123
127
  end
@@ -53,6 +53,10 @@ module InsightsCloud
53
53
  }
54
54
  )
55
55
  end
56
+
57
+ def rescue_strategy_for_self
58
+ Dynflow::Action::Rescue::Fail
59
+ end
56
60
  end
57
61
  end
58
62
  end
@@ -19,8 +19,9 @@ module InsightsCloud
19
19
  def run
20
20
  InsightsResolution.transaction do
21
21
  InsightsResolution.delete_all
22
- api_response = query_insights_resolutions(relevant_rules)
23
- write_resolutions(api_response)
22
+ rule_ids = relevant_rules
23
+ api_response = query_insights_resolutions(rule_ids) unless rule_ids.empty?
24
+ write_resolutions(api_response) if api_response
24
25
  end
25
26
  end
26
27
 
@@ -70,6 +71,10 @@ module InsightsCloud
70
71
  def to_rule_id(resolution_rule_id)
71
72
  RULE_ID_REGEX.match(resolution_rule_id).named_captures.fetch('id', resolution_rule_id)
72
73
  end
74
+
75
+ def rescue_strategy_for_self
76
+ Dynflow::Action::Rescue::Fail
77
+ end
73
78
  end
74
79
  end
75
80
  end
@@ -11,8 +11,12 @@ module InsightsCloud
11
11
  return
12
12
  end
13
13
 
14
- plan_self
15
- plan_resolutions
14
+ # since the tasks are not connected, we need to force sequence execution here
15
+ # to make sure we don't run resolutions until we synced all our rules
16
+ sequence do
17
+ plan_self
18
+ plan_resolutions
19
+ end
16
20
  end
17
21
 
18
22
  def plan_resolutions
@@ -71,6 +75,10 @@ module InsightsCloud
71
75
  rating: rule_hash['rating'],
72
76
  }
73
77
  end
78
+
79
+ def rescue_strategy_for_self
80
+ Dynflow::Action::Rescue::Fail
81
+ end
74
82
  end
75
83
  end
76
84
  end
@@ -39,6 +39,10 @@ module InventorySync
39
39
  host_statuses[:sync] += results.touched.size
40
40
  end
41
41
 
42
+ def rescue_strategy_for_self
43
+ Dynflow::Action::Rescue::Fail
44
+ end
45
+
42
46
  private
43
47
 
44
48
  def update_hosts_status(status_hashes, touched)
@@ -28,6 +28,10 @@ module InventorySync
28
28
  results
29
29
  end
30
30
 
31
+ def rescue_strategy_for_self
32
+ Dynflow::Action::Rescue::Fail
33
+ end
34
+
31
35
  private
32
36
 
33
37
  def add_missing_insights_facets(uuids_hash)
@@ -24,6 +24,10 @@ module InventorySync
24
24
  def logger
25
25
  action_logger
26
26
  end
27
+
28
+ def rescue_strategy_for_self
29
+ Dynflow::Action::Rescue::Fail
30
+ end
27
31
  end
28
32
  end
29
33
  end
@@ -20,6 +20,10 @@ module InventorySync
20
20
  results
21
21
  end
22
22
 
23
+ def rescue_strategy_for_self
24
+ Dynflow::Action::Rescue::Fail
25
+ end
26
+
23
27
  private
24
28
 
25
29
  def add_missing_insights_facet(uuids_hash)
@@ -50,6 +50,10 @@ module InventorySync
50
50
  def request_url
51
51
  ForemanInventoryUpload.inventory_export_url
52
52
  end
53
+
54
+ def rescue_strategy_for_self
55
+ Dynflow::Action::Rescue::Fail
56
+ end
53
57
  end
54
58
  end
55
59
  end
data/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "foreman_rh_cloud",
3
- "version": "4.0.25.1",
3
+ "version": "4.0.26",
4
4
  "description": "Inventory Upload =============",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -45,4 +45,4 @@
45
45
  "jed": "~1.1.1",
46
46
  "react-intl": "~2.8.0"
47
47
  }
48
- }
48
+ }
@@ -7,6 +7,8 @@ module InsightsCloud::Api
7
7
  end
8
8
 
9
9
  context '#forward_request' do
10
+ include MockCerts
11
+
10
12
  setup do
11
13
  @body = 'Cloud response body'
12
14
  @http_req = RestClient::Request.new(:method => 'GET', :url => 'http://test.theforeman.org')
@@ -16,38 +18,9 @@ module InsightsCloud::Api
16
18
  User.current = ::Katello::CpConsumerUser.new(:uuid => host.subscription_facet.uuid, :login => host.subscription_facet.uuid)
17
19
  InsightsCloud::Api::MachineTelemetriesController.any_instance.stubs(:upstream_owner).returns({ 'uuid' => 'abcdefg' })
18
20
 
19
- @cert1 = "-----BEGIN CERTIFICATE-----\r\n" +
20
- "MIIFdDCCA1ygAwIBAgIJAM5Uqykb3EAtMA0GCSqGSIb3DQEBCwUAME8xCzAJBgNV\r\n" +
21
- "BAYTAklMMREwDwYDVQQIDAhUZWwgQXZpdjEUMBIGA1UECgwLVGhlIEZvcmVtYW4x\r\n" +
22
- "FzAVBgNVBAMMDnRoZWZvcmVtYW4ub3JnMB4XDTE4MDMyNDEyMzYyOFoXDTI4MDMy\r\n" +
23
- "MTEyMzYyOFowTzELMAkGA1UEBhMCSUwxETAPBgNVBAgMCFRlbCBBdml2MRQwEgYD\r\n" +
24
- "VQQKDAtUaGUgRm9yZW1hbjEXMBUGA1UEAwwOdGhlZm9yZW1hbi5vcmcwggIiMA0G\r\n" +
25
- "CSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDF04/s4h+BgHPG1HDZ/sDlYq925pkc\r\n" +
26
- "RTVAfnE2EXDAmZ6W4Q9ueDY65MHe3ZWO5Dg72kNSP2sK9kRI7Dk5CAFOgyw1rH8t\r\n" +
27
- "Hd1+0xp/lv6e4SvSYghxIL68vFe0ftKkm1usqejBM5ZTgKr7JCI+XSIN36F65Kde\r\n" +
28
- "c+vxwBnayuhP04r9/aaE/709SXML4eRVYW8I3qFy9FPtUOm+bY8U2PIv5fHayqbG\r\n" +
29
- "cL/4t3+MCtMhHJsLzdBXya+1P5t+HcKjUNlmwoUF961YAktVuEFloGd0RMRlqF3/\r\n" +
30
- "itU3QNlXgA5QBIciE5VPr/PiqgMC3zgd5avjF4OribZ+N9AATLiQMW78il5wSfcc\r\n" +
31
- "kQjU9ChOLrzku455vQ8KE4bc0qvpCWGfUah6MvL9JB+TQkRl/8kxl0b9ZinIvJDH\r\n" +
32
- "ynVMb4cB/TDEjrjOfzn9mWLH0ZJqjmc2bER/G12WQxOaYLxdVwRStD3Yh6PtiFWu\r\n" +
33
- "sXOk19UOTVkeuvGFVtvzLfEwQ1lDEo7+VBQz8FG/HBu2Hpq3IwCFrHuicikwjQJk\r\n" +
34
- "nfturgD0rBOKEc1qWNZRCvovYOLL6ihvv5Orujsx5ZCHOAtnVNxkvIlFt2RS45LF\r\n" +
35
- "MtPJyhAc6SjitllfUEirxprsbmeSZqrIfzcGaEhgOSnyik1WMv6bYiqPfBg8Fzjh\r\n" +
36
- "vOCbtiDNPmvgOwIDAQABo1MwUTAdBgNVHQ4EFgQUtkAgQopsTtG9zSG3MgW2IxHD\r\n" +
37
- "MDwwHwYDVR0jBBgwFoAUtkAgQopsTtG9zSG3MgW2IxHDMDwwDwYDVR0TAQH/BAUw\r\n" +
38
- "AwEB/zANBgkqhkiG9w0BAQsFAAOCAgEAJq7iN+ZroRBweNhvUobxs75bLIV6tNn1\r\n" +
39
- "MdNHDRA+hezwf+gxHZhFyaAHfTpst2/9leK5Qe5Zd6gZLr3E5/8ppQuRod72H39B\r\n" +
40
- "vxMlG5zxDss0WMo3vZeKZbTY6QhXi/lY2IZ6OGV4feSvCsYxn27GTjjrRUSLFeHH\r\n" +
41
- "JVemCwCDMavaE3+OIY4v2P4FcG+MjUvfOB9ahI24TWL7YgrsNVmJjCILq+EeUj0t\r\n" +
42
- "Gde1SXVyLkqt7PoxHRJAE0BCEMJSnjxaVB329acJgeehBUxjj4CCPqtDxtbz9HEH\r\n" +
43
- "mOKfNdaKpFor+DUeEKUWVGnr9U9xOaC+Ws+oX7MIEUCDM7p2ob4JwcjnFs1jZgHh\r\n" +
44
- "Hwig+i7doTlc701PvKWO96fuNHK3B3/jTb1fVvSZ49O/RvY1VWODdUdxWmXGHNh3\r\n" +
45
- "LoR8tSPEb46lC2DXGaIQumqQt8PnBG+vL1qkQa1SGTV7dJ8TTbxbv0S+sS+igkk9\r\n" +
46
- "zsIEK8Ea3Ep935cXximz0faAAKHSA+It+xHLAyDtqy2KaAEBgGsBuuWlUfK6TaP3\r\n" +
47
- "Gwdjct3y4yYUO45lUsUfHqX8vk/4ttW5zYeDiW+HArJz+9VUXNbEdury4kGuHgBj\r\n" +
48
- "xHD4Bsul65+hHZ9QywKU26F1A6TLkYpQ2rk/Dx9LGICM4m4IlHjWJPFsQdtkyOor\r\n" +
49
- "osxMtcaZZ1E=\r\n" +
50
- "-----END CERTIFICATE-----"
21
+ setup_certs_expectation do
22
+ InsightsCloud::Api::MachineTelemetriesController.any_instance.stubs(:candlepin_id_cert)
23
+ end
51
24
  end
52
25
 
53
26
  test "should respond with response from cloud" do
@@ -67,13 +40,6 @@ module InsightsCloud::Api
67
40
  ::ForemanRhCloud::CloudRequestForwarder.any_instance.expects(:execute_cloud_request).with do |opts|
68
41
  opts[:headers][:content_type] == 'application/json'
69
42
  end.returns(res)
70
- InsightsCloud::Api::MachineTelemetriesController.any_instance.expects(:candlepin_id_cert)
71
- .returns(
72
- {
73
- cert: @cert1,
74
- key: OpenSSL::PKey::RSA.new(1024).to_pem,
75
- }
76
- )
77
43
  InsightsCloud::Api::MachineTelemetriesController.any_instance.expects(:cp_owner_id).returns('123')
78
44
 
79
45
  post :forward_request, as: :json, params: { "path" => "static/v1/test", "machine_telemetry" => {"foo" => "bar"} }
@@ -103,6 +69,17 @@ module InsightsCloud::Api
103
69
  assert_equal 502, @response.status
104
70
  assert_equal 'Authentication to the Insights Service failed.', JSON.parse(@response.body)['message']
105
71
  end
72
+
73
+ test "should forward errors to the client" do
74
+ net_http_resp = Net::HTTPResponse.new(1.0, 500, "TEST_RESPONSE")
75
+ res = RestClient::Response.create(@body, net_http_resp, @http_req)
76
+ ::ForemanRhCloud::CloudRequestForwarder.any_instance.stubs(:execute_cloud_request).raises(RestClient::InternalServerError.new(res))
77
+
78
+ get :forward_request, params: { "path" => "platform/module-update-router/v1/channel" }
79
+ assert_equal 500, @response.status
80
+ assert_equal 'Cloud request failed', JSON.parse(@response.body)['message']
81
+ assert_match /#{@body}/, JSON.parse(@response.body)['response']
82
+ end
106
83
  end
107
84
 
108
85
  context '#branch_info' do
@@ -1,4 +1,4 @@
1
- require 'test_helper'
1
+ require 'test_plugin_helper'
2
2
  require 'foreman_tasks/test_helpers'
3
3
 
4
4
  class InsightsResolutionsSyncTest < ActiveSupport::TestCase
@@ -75,4 +75,13 @@ class InsightsResolutionsSyncTest < ActiveSupport::TestCase
75
75
  assert_equal 5, InsightsResolution.all.count
76
76
  assert_equal 2, @rule.resolutions.count
77
77
  end
78
+
79
+ test 'Skips pinging the cloud if no rule ids were found' do
80
+ InsightsCloud::Async::InsightsResolutionsSync.any_instance.expects(:query_insights_resolutions).never
81
+ InsightsRule.all.delete_all
82
+
83
+ ForemanTasks.sync_task(InsightsCloud::Async::InsightsResolutionsSync)
84
+
85
+ assert_equal 0, InsightsResolution.all.count
86
+ end
78
87
  end
@@ -17,6 +17,7 @@ class CloudRequestForwarderTest < ActiveSupport::TestCase
17
17
  "/redhat_access/r/insights/platform/inventory/v1/hosts" => "https://cert.cloud.redhat.com/api/inventory/v1/hosts",
18
18
  "/redhat_access/r/insights/platform/ingress/v1/upload" => "https://cert.cloud.redhat.com/api/ingress/v1/upload",
19
19
  "/redhat_access/r/insights/uploads/67200803-132b-474b-a6f9-37be74185df4" => "https://cert-api.access.redhat.com/r/insights/uploads/67200803-132b-474b-a6f9-37be74185df4",
20
+ "/redhat_access/r/insights/" => "https://cert.cloud.redhat.com/api/apicast-tests/ping",
20
21
  }
21
22
 
22
23
  paths.each do |key, value|
@@ -107,4 +108,29 @@ class CloudRequestForwarderTest < ActiveSupport::TestCase
107
108
  )
108
109
  assert_equal params.merge(:branch_id => 74), @forwarder.prepare_forward_params(req, 74)
109
110
  end
111
+
112
+ test 'should reuse BranchInfo identifiers for user_agent' do
113
+ user_agent = { :foo => :bar }
114
+ params = { :page => 5, :per_page => 42 }
115
+ ForemanRhCloud::BranchInfo.any_instance.expects(:core_app_name).returns('test_app')
116
+ ForemanRhCloud::BranchInfo.any_instance.expects(:core_app_version).returns('test_ver')
117
+
118
+ req = ActionDispatch::Request.new(
119
+ 'REQUEST_URI' => '/foo/bar',
120
+ 'REQUEST_METHOD' => 'GET',
121
+ 'HTTP_USER_AGENT' => user_agent,
122
+ 'rack.input' => ::Puma::NullIO.new,
123
+ 'action_dispatch.request.query_parameters' => params
124
+ )
125
+
126
+ actual = @forwarder.prepare_request_opts(req, 'TEST PAYLOAD', params, generate_certs_hash)
127
+
128
+ assert_match /foo/, actual[:headers][:user_agent]
129
+ assert_match /bar/, actual[:headers][:user_agent]
130
+ assert_match /test_app/, actual[:headers][:user_agent]
131
+ assert_match /test_ver/, actual[:headers][:user_agent]
132
+ assert_equal 'TEST PAYLOAD', actual[:payload]
133
+ assert_equal 'GET', actual[:method]
134
+ assert_equal params, actual[:headers][:params]
135
+ end
110
136
  end
@@ -1,12 +1,10 @@
1
1
  import React from 'react';
2
2
  import { Text, TextVariants } from '@patternfly/react-core';
3
3
  import { translate as __ } from 'foremanReact/common/I18n';
4
- import InsightsSettings from '../InsightsSettings';
5
4
  import './InsightsHeader.scss';
6
5
 
7
6
  const InsightsHeader = () => (
8
7
  <div className="insights-header">
9
- <InsightsSettings />
10
8
  <Text component={TextVariants.p}>
11
9
  {__(
12
10
  'Insights synchronization process is used to provide Insights recommendations output for hosts managed here.'
@@ -1,3 +1,4 @@
1
1
  .insights_settings {
2
2
  float: right;
3
+ margin-top: 22px;
3
4
  }
@@ -4,7 +4,6 @@ exports[`InsightsHeader render 1`] = `
4
4
  <div
5
5
  className="insights-header"
6
6
  >
7
- <Connect(InsightsSettings) />
8
7
  <Text
9
8
  component="p"
10
9
  >
@@ -12,6 +12,7 @@ import {
12
12
  import './InsightsCloudSync.scss';
13
13
  import Pagination from './Components/InsightsTable/Pagination';
14
14
  import ToolbarDropdown from './Components/ToolbarDropdown';
15
+ import InsightsSettings from './Components/InsightsSettings';
15
16
 
16
17
  const InsightsCloudSync = ({
17
18
  syncInsights,
@@ -42,6 +43,7 @@ const InsightsCloudSync = ({
42
43
 
43
44
  return (
44
45
  <div className="rh-cloud-insights">
46
+ <InsightsSettings />
45
47
  <PageLayout
46
48
  searchable
47
49
  searchProps={INSIGHTS_SEARCH_PROPS}
@@ -4,6 +4,7 @@ exports[`InsightsCloudSync render 1`] = `
4
4
  <div
5
5
  className="rh-cloud-insights"
6
6
  >
7
+ <Connect(InsightsSettings) />
7
8
  <PageLayout
8
9
  beforeToolbarComponent={<InsightsHeader />}
9
10
  header="Red Hat Insights"
@@ -11,7 +11,7 @@ export const HelpLabel = ({ text, id, className }) => {
11
11
  onClick={e => e.preventDefault()}
12
12
  className={`pf-c-form__group-label-help ${className}`}
13
13
  >
14
- <HelpIcon noVerticalAlign />
14
+ <HelpIcon />
15
15
  </button>
16
16
  </Popover>
17
17
  );
@@ -12,7 +12,7 @@ exports[`InsightsCloudSync helpers should return insights cloud Url 1`] = `
12
12
  >
13
13
  <HelpIcon
14
14
  color="currentColor"
15
- noVerticalAlign={true}
15
+ noVerticalAlign={false}
16
16
  size="sm"
17
17
  />
18
18
  </button>
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.25.1
4
+ version: 4.0.26
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: 2021-08-05 00:00:00.000000000 Z
11
+ date: 2021-08-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: katello
@@ -657,7 +657,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
657
657
  - !ruby/object:Gem::Version
658
658
  version: '0'
659
659
  requirements: []
660
- rubygems_version: 3.2.15
660
+ rubygems_version: 3.2.22
661
661
  signing_key:
662
662
  specification_version: 4
663
663
  summary: Summary of ForemanRhCloud.