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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '0389d4bf9e9af791b23a3ea7b271feca1385e2fcf4fc6acc7d954283477c8706'
4
- data.tar.gz: 839cc45d7b92a308841f995152ae4a68503acd69feb95cd95b19772f99cec6c9
3
+ metadata.gz: 437d70d98a43e88f7835426bf1a8ae7995a2b759038e3a5908dc41e122544ed1
4
+ data.tar.gz: a655276cda12b06662db3670019747c518e9204c22ca8ad3591024945dd48fb8
5
5
  SHA512:
6
- metadata.gz: 7b37d242c63e0260a76d06a6096ac569423237bf62f6e8685f79d6cf7b3e85246cfa92f35f0907a18b10539deb09f991189ea5914fa519236786aa2456e8aed6
7
- data.tar.gz: e2baeab2eceeae447276db3ce9c8fa6c7236ff082eab418b835afea4c97ea9172a86eabeeb8ba430012f9662c26bd5a95cc86cc5f45e67a8f6ee4bb2d3a76ac8
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
- render :json => ForemanRhCloud::BranchInfo.new.generate(@uuid, @host, @branch_id, request.host).to_json
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
- return if ForemanTasks::RecurringLogic.joins(:tasks)
10
- .merge(ForemanTasks::Task.where(label: task_class.name))
11
- .exists?
12
-
13
- User.as_anonymous_admin do
14
- recurring_logic = ForemanTasks::RecurringLogic.new_from_cronline(cronline)
15
- recurring_logic.save!
16
- recurring_logic.start(task_class)
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
- config.to_prepare do
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'),
@@ -1,3 +1,3 @@
1
1
  module ForemanRhCloud
2
- VERSION = '5.0.34'.freeze
2
+ VERSION = '5.0.35'.freeze
3
3
  end
@@ -22,6 +22,10 @@ module InsightsCloud
22
22
  def rescue_strategy_for_self
23
23
  Dynflow::Action::Rescue::Fail
24
24
  end
25
+
26
+ def logger
27
+ action_logger
28
+ end
25
29
  end
26
30
  end
27
31
  end
data/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "foreman_rh_cloud",
3
- "version": "5.0.34",
3
+ "version": "5.0.35",
4
4
  "description": "Inventory Upload =============",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -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.redhat.com/api/module-update-router/v1/channel?module=insights-core",
14
- "/redhat_access/r/insights/v1/static/release/insights-core.egg" => "https://cert-api.access.redhat.com/r/insights/v1/static/release/insights-core.egg",
15
- "/redhat_access/r/insights/v1/static/uploader.v2.json" => "https://cert-api.access.redhat.com/r/insights/v1/static/uploader.v2.json",
16
- "/redhat_access/r/insights/v1/static/uploader.v2.json.asc" => "https://cert-api.access.redhat.com/r/insights/v1/static/uploader.v2.json.asc",
17
- "/redhat_access/r/insights/platform/inventory/v1/hosts" => "https://cert.cloud.redhat.com/api/inventory/v1/hosts",
18
- "/redhat_access/r/insights/platform/ingress/v1/upload" => "https://cert.cloud.redhat.com/api/ingress/v1/upload",
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",
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.34
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-04-26 00:00:00.000000000 Z
11
+ date: 2022-05-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: katello