foreman_rh_cloud 5.0.41 → 5.0.43

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: 4520a12619aad77a5d0ddeafd83203d8281e0ff7d3e9fcc2eef10a2a779bad27
4
- data.tar.gz: 7e6d55970f4c0742328e5a5e9159b084a391cc98305cf67cff6555a1575b6fe1
3
+ metadata.gz: afcac5b540e90c5a058847cad9490d79746b687f52d2023c800aa7a44d3d5bf6
4
+ data.tar.gz: 191387083ba26385acae71a88e7ee09a3c6763418b662746e54d37dfff6871a3
5
5
  SHA512:
6
- metadata.gz: f55b1b61ed73778bc62c7cf1819b1eac363417a6f929cbc1f6e9b8043f45904b2dec26f1c9294ab68e1b175a4cbda091ef7091d755180649d0f2e242784092c5
7
- data.tar.gz: 5b7fe9198f6c0172f93638f8315274158471169033de6f6c9113aa94dd2de8ab5ac0a0c9b32b0c1bb374cfb3303ab9d7915519139919799d9a88531bb280f024
6
+ metadata.gz: ad17c8398f353411da4de2ae49e4e50b59994eedb6534749da9e6e93048df44ae1b986ef767023402f1f53f01a2cd7126c8aeac8816e52274c8dfe7af7f86dc5
7
+ data.tar.gz: 27a983cf15776f3bf86b70bf2e169185e9da765036fef4b2885faed7e3231feb7289c76b91c111ba8f4cf1e7de1d72df6afa7843c339ca80db039e2fa5105c0b
@@ -33,10 +33,6 @@ module InsightsCloud::Api
33
33
  }, status: @cloud_response.code
34
34
  end
35
35
 
36
- if @cloud_response.headers[:content_disposition]
37
- return send_data @cloud_response, disposition: @cloud_response.headers[:content_disposition], type: @cloud_response.headers[:content_type]
38
- end
39
-
40
36
  # Append redhat-specific headers
41
37
  @cloud_response.headers.each do |key, value|
42
38
  assign_header(response, @cloud_response, key, false) if key.to_s.start_with?('x_rh_')
@@ -45,7 +41,17 @@ module InsightsCloud::Api
45
41
  assign_header(response, @cloud_response, :x_resource_count, true)
46
42
  headers[Rack::ETAG] = @cloud_response.headers[:etag]
47
43
 
48
- render json: @cloud_response, status: @cloud_response.code
44
+ if @cloud_response.headers[:content_disposition]
45
+ # If there is a Content-Disposition header, it means we are forwarding binary data, send the raw data with proper
46
+ # content type
47
+ send_data @cloud_response, disposition: @cloud_response.headers[:content_disposition], type: @cloud_response.headers[:content_type]
48
+ elsif @cloud_response.headers[:content_type] =~ /zip/
49
+ # if there is no Content-Disposition, but the content type is binary according the content type,
50
+ # forward the request as binry too
51
+ send_data @cloud_response, type: @cloud_response.headers[:content_type]
52
+ else
53
+ render json: @cloud_response, status: @cloud_response.code
54
+ end
49
55
  end
50
56
 
51
57
  def branch_info
@@ -1,3 +1,3 @@
1
1
  module ForemanRhCloud
2
- VERSION = '5.0.41'.freeze
2
+ VERSION = '5.0.43'.freeze
3
3
  end
@@ -67,7 +67,6 @@ module InsightsCloud
67
67
  private
68
68
 
69
69
  def connector_playbook_job?(job_invocation)
70
- puts "Job invocation id: #{job_invocation&.remote_execution_feature_id}, feature id: #{connector_feature_id}"
71
70
  job_invocation&.remote_execution_feature_id == connector_feature_id
72
71
  end
73
72
 
@@ -1,3 +1,4 @@
1
+ require 'cgi'
1
2
  require 'rest-client'
2
3
 
3
4
  module InsightsCloud
@@ -122,7 +123,7 @@ module InsightsCloud
122
123
  end
123
124
 
124
125
  def to_rule_id(results_url)
125
- URI.decode(safe_results_match(results_url)[:id] || '')
126
+ CGI.unescape(safe_results_match(results_url)[:id] || '')
126
127
  end
127
128
 
128
129
  def safe_results_match(results_url)
data/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "foreman_rh_cloud",
3
- "version": "5.0.41",
3
+ "version": "5.0.43",
4
4
  "description": "Inventory Upload =============",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -72,6 +72,17 @@ module InsightsCloud::Api
72
72
  assert_equal etag, @response.headers[Rack::ETAG]
73
73
  end
74
74
 
75
+ test "should set content type header to response from cloud" do
76
+ req = RestClient::Request.new(:method => 'GET', :url => 'http://test.theforeman.org')
77
+ net_http_resp = Net::HTTPResponse.new(1.0, 200, "OK")
78
+ net_http_resp['Content-Type'] = 'application/zip'
79
+ res = RestClient::Response.create(@body, net_http_resp, req)
80
+ ::ForemanRhCloud::CloudRequestForwarder.any_instance.stubs(:forward_request).returns(res)
81
+
82
+ get :forward_request, params: { "path" => "static/v1/release/insights-core.egg" }
83
+ assert_equal net_http_resp['Content-Type'], @response.headers['Content-Type']
84
+ end
85
+
75
86
  test "should handle failed authentication to cloud" do
76
87
  net_http_resp = Net::HTTPResponse.new(1.0, 401, "Unauthorized")
77
88
  res = RestClient::Response.create(@body, net_http_resp, @http_req)
@@ -14,7 +14,7 @@ class ConnectorPlaybookExecutionReporterTaskTest < ActiveSupport::TestCase
14
14
  end
15
15
 
16
16
  setup do
17
- feature = RemoteExecutionFeature.register(
17
+ RemoteExecutionFeature.register(
18
18
  :rh_cloud_connector_run_playbook,
19
19
  N_('Run RH Cloud playbook'),
20
20
  description: N_('Run playbook genrated by Red Hat remediations app'),
@@ -22,14 +22,10 @@ class ConnectorPlaybookExecutionReporterTaskTest < ActiveSupport::TestCase
22
22
  provided_inputs: ['playbook_url', 'report_url', 'correlation_id', 'report_interval']
23
23
  )
24
24
 
25
- puts "REX Register: #{feature.id}"
26
-
27
25
  @job_invocation = generate_job_invocation
28
26
 
29
27
  # reset connector feature ID cache
30
28
  TestConnectorPlaybookExecutionReporterTask.instance_variable_set(:@connector_feature_id, nil)
31
-
32
- puts RemoteExecutionFeature.all.to_a
33
29
  end
34
30
 
35
31
  test 'It reports finish playbook messages' do
@@ -115,8 +111,6 @@ class ConnectorPlaybookExecutionReporterTaskTest < ActiveSupport::TestCase
115
111
  )
116
112
  feature = RemoteExecutionFeature.feature!(:rh_cloud_connector_run_playbook).id
117
113
 
118
- puts "Generated feature: #{feature}"
119
-
120
114
  job_invocation = FactoryBot.create(
121
115
  :job_invocation,
122
116
  remote_execution_feature_id: feature,
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.41
4
+ version: 5.0.43
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-08-02 00:00:00.000000000 Z
11
+ date: 2022-11-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: katello