foreman_virt_who_configure 0.4.5 → 0.5.4

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: 1b49618448e8a187353b80fba1a83359bdab3356d5fd61cba7d3ce4c5e46fa0d
4
- data.tar.gz: b4aa7bc48dfba7dcff8c2daeab3d50b377371c7b9357d538c01be5a98a512c0c
3
+ metadata.gz: cf3e0a6434aadcf921fa999536a024f8f2328dec8919d8ee421cc77f8b3ba64b
4
+ data.tar.gz: 730cfd8c0be2125c35ffd333d4ff24579159e558452b48a2f5f2dd22ecfa620d
5
5
  SHA512:
6
- metadata.gz: 3afe8fdd3d3a7e9afa4dd8f161d809101cf4e80197427073a99d10ec2f1c029ff62f8ff41c33be6db8a4e5cb9ce18204ad55a6ee462b554d10d2cc0b3c0e1fbc
7
- data.tar.gz: d13dd560a075d680d13ccfd395d7a7321b1b5e5f8b58bd8a51d00aa35082aec61b54c82c5a8f1b0fb970c421a08822e7b5b854b5e089215a6c17c710ee67b1b6
6
+ metadata.gz: ca602bed3b8f44f51e998324605787ccf453522b6c042786cdcc747841fa4d5981c43410f297b4173dbc362b887cc4a205857c2f0f23ae73e8fb0eeb75fd7e2c
7
+ data.tar.gz: fb0bbcbfa473562eded59bfb96725d6d49bbf66cb1e1ca319b6126c0217645fb68e20b1d6bb01be8e0c1c7476e2febe68be5337d0ddb6f72a12fca52d4c89942
@@ -3,7 +3,7 @@ module ForemanVirtWhoConfigure
3
3
  PERMITTED_PARAMS = [
4
4
  :interval, :organization_id, :compute_resource_id, :whitelist, :blacklist, :hypervisor_id,
5
5
  :hypervisor_type, :hypervisor_server, :hypervisor_username, :hypervisor_password, :debug,
6
- :satellite_url, :proxy, :no_proxy, :name,
6
+ :satellite_url, :http_proxy_id, :no_proxy, :name,
7
7
  # API parameter filtering_mode gets translated to listing_mode in the controller
8
8
  # We keep both params permitted for compatibility with 1.11
9
9
  :listing_mode, :filtering_mode, :filter_host_parents, :exclude_host_parents, :kubeconfig_path
@@ -73,6 +73,7 @@ module ForemanVirtWhoConfigure
73
73
 
74
74
  belongs_to :compute_resource
75
75
  belongs_to :organization
76
+ belongs_to :http_proxy
76
77
 
77
78
  # service user used by virt-who to report back
78
79
  belongs_to :service_user
@@ -174,6 +175,8 @@ module ForemanVirtWhoConfigure
174
175
  user = User.unscoped.find_by_id(service_user.user_id)
175
176
  service_user.destroy
176
177
  user.notification_recipients.delete_all
178
+ # we can't use destroy, because internal users can't be deleted
179
+ user.tasks.update_all :user_id => nil
177
180
  user.delete
178
181
  end
179
182
  end
@@ -83,8 +83,25 @@ verify_minimal_version() {
83
83
  }
84
84
 
85
85
  result_code=#{error_code(:success)}
86
+
87
+ compose_install_command() {
88
+ $1 packages unlock
89
+ $1 advanced procedure run packages-install --packages virt-who --assumeyes || result_code=$(($result_code|#{error_code(:virt_who_installation)}))
90
+ $1 packages lock
91
+ }
92
+
93
+ install_virt_who() {
94
+ if `rpm -q satellite-maintain > /dev/null`; then
95
+ compose_install_command satellite-maintain
96
+ elif `rpm -q rubygem-foreman_maintain > /dev/null`; then
97
+ compose_install_command foreman-maintain
98
+ else
99
+ yum install -y virt-who || result_code=$(($result_code|#{error_code(:virt_who_installation)}))
100
+ fi
101
+ }
102
+
86
103
  step 1 "Installing virt-who"
87
- yum install -y virt-who || result_code=$(($result_code|#{error_code(:virt_who_installation)}))
104
+ install_virt_who
88
105
 
89
106
  if verify_minimal_version; then
90
107
  step 2 "Encrypting password"
@@ -99,7 +116,7 @@ if verify_minimal_version; then
99
116
  type=#{type}
100
117
  hypervisor_id=#{hypervisor_id}
101
118
  owner=#{owner}
102
- env=Library#{connection_details}
119
+ env=Library#{connection_details}#{filtering}
103
120
  rhsm_hostname=#{satellite_url}
104
121
  rhsm_username=#{service_user_username}
105
122
  rhsm_encrypted_password=$user_password
@@ -142,7 +159,7 @@ EOS
142
159
  else
143
160
  "\nserver=#{cr_server}
144
161
  username=#{cr_username}
145
- encrypted_password=$cr_password#{filtering}"
162
+ encrypted_password=$cr_password"
146
163
  end
147
164
  end
148
165
 
@@ -236,7 +253,7 @@ encrypted_password=$cr_password#{filtering}"
236
253
  end
237
254
 
238
255
  def proxy
239
- config.proxy
256
+ config.http_proxy
240
257
  end
241
258
 
242
259
  def no_proxy
@@ -247,9 +264,13 @@ encrypted_password=$cr_password#{filtering}"
247
264
  sanitize(string)
248
265
  end
249
266
 
267
+ def proxy_type
268
+ "#{URI(proxy.url).scheme}_proxy"
269
+ end
270
+
250
271
  def proxy_strings
251
272
  output = ''
252
- output << "\nhttp_proxy=#{sanitize_proxy(proxy)}" if proxy.present?
273
+ output << "\n#{proxy_type}=#{sanitize_proxy(proxy.full_url)}" if proxy.present?
253
274
  output << "\nNO_PROXY=#{sanitize_proxy(no_proxy)}" if no_proxy.present?
254
275
  output << "\nNO_PROXY=*" if !proxy.present? && !no_proxy.present?
255
276
  output
@@ -2,12 +2,13 @@
2
2
 
3
3
  <%= breadcrumbs(:resource_url => foreman_virt_who_configure_api_configs_path,
4
4
  :items => [
5
- {:caption => _('Configurations'),
6
- :url => url_for(foreman_virt_who_configure_configs_path)
7
- },
8
- {:caption => _('Edit') + ' ' + @config.name,
9
- :url => (edit_foreman_virt_who_configure_config_path(@config) if authorized_for(hash_for_edit_foreman_virt_who_configure_config_path(@config)))
10
- }
5
+ {
6
+ :caption => _('Virt-who Configurations'),
7
+ :url => foreman_virt_who_configure_configs_path
8
+ },
9
+ {
10
+ :caption => _('Edit') + ' ' + @config.name
11
+ }
11
12
  ]
12
13
  ) %>
13
14
 
@@ -8,12 +8,13 @@
8
8
 
9
9
  <%= breadcrumbs(:resource_url => foreman_virt_who_configure_api_configs_path,
10
10
  :items => [
11
- {:caption => _('Configurations'),
12
- :url => url_for(foreman_virt_who_configure_configs_path)
13
- },
14
- {:caption => @config.name,
15
- :url => (edit_foreman_virt_who_configure_config_path(@config) if authorized_for(hash_for_edit_foreman_virt_who_configure_config_path(@config)))
16
- }
11
+ {
12
+ :caption => _('Virt-who Configurations'),
13
+ :url => foreman_virt_who_configure_configs_path
14
+ },
15
+ {
16
+ :caption => @config.name
17
+ }
17
18
  ]
18
19
  ) %>
19
20
 
@@ -48,7 +49,7 @@
48
49
  <%= config_attribute :exclude_host_parents, @config.exclude_host_parents if @config.exclude_host_parents.present? %>
49
50
  <% end %>
50
51
  <%= config_attribute :debug, checked_icon(@config.debug), _('Enable debugging output?') %>
51
- <%= config_attribute :proxy, @config.proxy, _('HTTP Proxy') if @config.proxy.present? %>
52
+ <%= config_attribute :http_proxy_id, @config.http_proxy.full_url, _('HTTP Proxy') if @config.http_proxy.present? %>
52
53
  <%= config_attribute :no_proxy, @config.no_proxy, _('Ignore Proxy') if @config.no_proxy.present? %>
53
54
  <%= config_attribute :kubeconfig_path, @config.kubeconfig_path if @config.hypervisor_type == 'kubevirt' %>
54
55
  </div>
@@ -18,7 +18,8 @@
18
18
  <%= textarea_f f, :exclude_host_parents, inline_help_popover(_('Hosts which parent (usually ComputeResource) name is specified in comma-separated list in this option will <b>NOT</b> be reported. Wildcards and regular expressions are supported, multiple records must be separated by comma. Put the value into the double-quotes if it contains special characters like comma. All new line characters will be removed in resulting configuration file, white spaces are removed from beginning and end.')).merge(:label => _('Exclude host parents')) %>
19
19
 
20
20
  <%= checkbox_f f, :debug, { :label => _('Enable debugging output') }.merge(inline_help_popover(_("Different debug value can't be set per hypervisor, therefore it will affect all other deployed configurations on the host on which this configuration will be deployed."))) %>
21
- <%= text_f f, :proxy, inline_help_popover(_('HTTP proxy that should be used for communication between the server on which virt-who is running and the hypervisors and virtualization managers. Leave this blank if no proxy is used.')).merge(:label => _('HTTP proxy')) %>
21
+ <%= select_f f, :http_proxy_id, HttpProxy.all, :id, :full_url, {:include_blank => true}, { :label => _('HTTP Proxy') }.merge(
22
+ inline_help_popover(_('HTTP proxy that should be used for communication between the server on which virt-who is running and the hypervisors and virtualization managers. Leave this blank if no proxy is used.').html_safe)) %>
22
23
  <%= text_f f, :no_proxy, inline_help_popover(_('A comma-separated list of hostnames or domains or ip addresses to ignore proxy settings for. Optionally this may be set to <code>*</code> to bypass proxy settings for all hostnames domains or ip addresses.')).merge(:label => _('Ignore proxy')) %>
23
24
  <%= text_f f, :kubeconfig_path, inline_help_popover(_('Configuration file containing details about how to connect to the cluster and authentication details')).merge(:label => _('Path to kubeconfig file')) %>
24
25
  </div>
@@ -1,5 +1,6 @@
1
1
  <div class="blank-slate-pf">
2
2
  <div class="blank-slate-pf-icon">
3
+ <% title _("Virt-who Configurations") %>
3
4
  <%= icon_text("globe", "", :kind => "fa") %>
4
5
  </div>
5
6
  <h1><%= _('Configs') %></h1>
@@ -0,0 +1,74 @@
1
+ class ReferConfigProxyToHttpProxy < ActiveRecord::Migration[6.0]
2
+ def up
3
+ add_column :foreman_virt_who_configure_configs, :http_proxy_id, :integer
4
+
5
+ if User.where(login: User::ANONYMOUS_ADMIN).exists?
6
+ User.as_anonymous_admin do
7
+ http_proxies = HttpProxy.all
8
+ ::ForemanVirtWhoConfigure::Config.find_each do |config|
9
+ if config.proxy.present?
10
+ migrate_config(http_proxies, config)
11
+ end
12
+ end
13
+ end
14
+ end
15
+
16
+ remove_column :foreman_virt_who_configure_configs, :proxy
17
+ end
18
+
19
+ def down
20
+ add_column :foreman_virt_who_configure_configs, :proxy, :string
21
+
22
+ if User.where(login: User::ANONYMOUS_ADMIN).exists?
23
+ User.as_anonymous_admin do
24
+ ::ForemanVirtWhoConfigure::Config.find_each do |config|
25
+ if config.http_proxy_id.present?
26
+ config.proxy = config.http_proxy.full_url
27
+ config.save!
28
+ end
29
+ end
30
+ end
31
+ end
32
+
33
+ remove_column :foreman_virt_who_configure_configs, :http_proxy_id
34
+ end
35
+
36
+ private
37
+
38
+ def migrate_config(http_proxies, config)
39
+ http_proxy = http_proxies.find { |proxy| proxy.full_url == proxy_uri(config.proxy).to_s }
40
+
41
+ if http_proxy.present?
42
+ config.http_proxy = http_proxy
43
+ else
44
+ http_proxy = build_http_proxy(config.proxy)
45
+ if http_proxy.save
46
+ config.http_proxy_id = http_proxy.id
47
+ end
48
+ end
49
+
50
+ config.save!
51
+ rescue URI::InvalidURIError
52
+ Rails.logger.debug "Config with id #{config.id} has not valid proxy #{config.proxy}"
53
+ end
54
+
55
+ def proxy_uri(config_proxy)
56
+ uri = URI(config_proxy)
57
+ unless ['http', 'https'].include? uri.scheme
58
+ config_proxy = "http://#{config_proxy}"
59
+ uri = URI(config_proxy)
60
+ end
61
+ uri
62
+ end
63
+
64
+ def build_http_proxy(proxy_url)
65
+ uri = proxy_uri(proxy_url)
66
+ url = if uri.port
67
+ "#{uri.scheme}://#{uri.host}:#{uri.port.to_s}"
68
+ else
69
+ "#{uri.scheme}://#{uri.host}"
70
+ end
71
+
72
+ HttpProxy.new(name: "virt_who_#{uri.host}", url: url, username: uri.user, password: uri.password)
73
+ end
74
+ end
@@ -27,7 +27,7 @@ module ForemanVirtWhoConfigure
27
27
 
28
28
  initializer 'foreman_virt_who_configure.register_plugin', :before => :finisher_hook do |_app|
29
29
  Foreman::Plugin.register :foreman_virt_who_configure do
30
- requires_foreman '>= 1.20'
30
+ requires_foreman '>= 1.24'
31
31
 
32
32
  apipie_documented_controllers ["#{ForemanVirtWhoConfigure::Engine.root}/app/controllers/foreman_virt_who_configure/api/v2/*.rb"]
33
33
 
@@ -1,3 +1,3 @@
1
1
  module ForemanVirtWhoConfigure
2
- VERSION = '0.4.5'.freeze
2
+ VERSION = '0.5.4'.freeze
3
3
  end
@@ -2,23 +2,23 @@ FactoryBot.define do
2
2
  factory :virt_who_config, :class => ::ForemanVirtWhoConfigure::Config do
3
3
  sequence(:name) { |n| "config #{n}" }
4
4
  organization
5
- interval 120
6
- hypervisor_id 'hostname'
7
- hypervisor_type 'esx'
8
- hypervisor_server 'vmware.example.com'
9
- hypervisor_username 'root'
10
- hypervisor_password 'changeme'
11
- satellite_url 'foreman.example.com'
12
- listing_mode ForemanVirtWhoConfigure::Config::UNLIMITED
5
+ interval { 120 }
6
+ hypervisor_id { 'hostname' }
7
+ hypervisor_type { 'esx' }
8
+ hypervisor_server { 'vmware.example.com' }
9
+ hypervisor_username { 'root' }
10
+ hypervisor_password { 'changeme' }
11
+ satellite_url { 'foreman.example.com' }
12
+ listing_mode { ForemanVirtWhoConfigure::Config::UNLIMITED }
13
13
  end
14
14
 
15
15
  trait :out_of_date do
16
- last_report_at (1.minute.ago - 120.minutes).utc
17
- out_of_date_at (1.minute.ago).utc
16
+ last_report_at { (1.minute.ago - 120.minutes).utc }
17
+ out_of_date_at { (1.minute.ago).utc }
18
18
  end
19
19
 
20
20
  trait :ok do
21
- last_report_at (1.minute.ago).utc
22
- out_of_date_at (1.minute.ago + 120.minutes).utc
21
+ last_report_at { (1.minute.ago).utc }
22
+ out_of_date_at { (1.minute.ago + 120.minutes).utc }
23
23
  end
24
24
  end
@@ -2,6 +2,7 @@ require 'test_plugin_helper'
2
2
 
3
3
  class ForemanVirtWhoConfigure::Api::V2::ConfigsControllerTest < ActionController::TestCase
4
4
  setup do
5
+ @http_proxy = FactoryBot.create(:http_proxy, name: "test", url: "http://test.com")
5
6
  @new_config = FactoryBot.create(:virt_who_config,
6
7
  :name => 'my vmware',
7
8
  :interval => 120,
@@ -13,7 +14,7 @@ class ForemanVirtWhoConfigure::Api::V2::ConfigsControllerTest < ActionController
13
14
  :hypervisor_username => "root",
14
15
  :debug => false,
15
16
  :satellite_url => "foreman.example.com",
16
- :proxy => 'proxy.example.com',
17
+ :http_proxy_id => @http_proxy.id,
17
18
  :no_proxy => nil
18
19
  )
19
20
 
@@ -41,7 +42,6 @@ class ForemanVirtWhoConfigure::Api::V2::ConfigsControllerTest < ActionController
41
42
  refute result_config['debug']
42
43
  assert_not_nil result_config['debug']
43
44
  assert_equal 'foreman.example.com', result_config['satellite_url']
44
- assert_equal 'proxy.example.com', result_config['proxy']
45
45
  assert_nil result_config['no_proxy']
46
46
  assert_equal 'unknown', result_config['status']
47
47
  assert_nil result_config['last_report_at']
@@ -74,11 +74,11 @@ class ForemanVirtWhoConfigure::Api::V2::ConfigsControllerTest < ActionController
74
74
  refute response['debug']
75
75
  assert_not_nil response['debug']
76
76
  assert_equal 'foreman.example.com', response['satellite_url']
77
- assert_equal 'proxy.example.com', response['proxy']
78
77
  assert_nil response['no_proxy']
79
78
  assert_equal 'unknown', response['status']
80
79
  assert_nil response['last_report_at']
81
80
  assert_nil response['out_of_date_at']
81
+ assert_equal @http_proxy.id, ForemanVirtWhoConfigure::Config.find(response['id']).http_proxy_id
82
82
 
83
83
  assert_response :success
84
84
  end
@@ -0,0 +1,158 @@
1
+ require 'test_plugin_helper'
2
+ require ForemanVirtWhoConfigure::Engine.root.join('db', 'migrate', '20200728054557_refer_config_proxy_to_http_proxy.rb')
3
+
4
+ module ForemanVirtWhoConfigure
5
+ class MigrateConfigProxyToHttpProxy < ActiveSupport::TestCase
6
+ let(:migration) { klass.new }
7
+
8
+ def migration_has_been_run?(version)
9
+ ActiveRecord::SchemaMigration.where(version: version).exists?
10
+ end
11
+
12
+ describe "up" do
13
+ let(:config) { FactoryBot.build(:virt_who_config) }
14
+
15
+ before do
16
+ if migration_has_been_run?('20200728054557')
17
+ migration.down
18
+ end
19
+
20
+ HttpProxy.delete_all
21
+ end
22
+
23
+ it "should create Http Proxy if already not exist" do
24
+ config.proxy = "test.example.com"
25
+ config.save!
26
+
27
+ assert_difference('HttpProxy.count', 1) do
28
+ migration.up
29
+ end
30
+
31
+ assert_equal "http://test.example.com", created_http_proxy.full_url
32
+ end
33
+
34
+ it "should create Http Proxy with user and password if already not exist" do
35
+ config.proxy = "http://user:password@test.example.com"
36
+ config.save!
37
+
38
+ assert_difference('HttpProxy.count', 1) do
39
+ migration.up
40
+ end
41
+
42
+ assert_equal "http://user:password@test.example.com", created_http_proxy.full_url
43
+ assert_equal "user", created_http_proxy.username
44
+ assert_equal "password", created_http_proxy.password
45
+ end
46
+
47
+ it "should not create Http Proxy for invalid config proxy if already not exist" do
48
+ config.proxy = "test.example.com:5000"
49
+ config.save!
50
+
51
+ assert_difference('HttpProxy.count', 1) do
52
+ migration.up
53
+ end
54
+
55
+ assert_equal "http://test.example.com:5000", created_http_proxy.full_url
56
+ end
57
+
58
+ it "should create Http Proxy with port for config proxy if already not exist" do
59
+ config.proxy = "https://test.example.com:5000"
60
+ config.save!
61
+
62
+ assert_difference('HttpProxy.count', 1) do
63
+ migration.up
64
+ end
65
+
66
+ assert_equal "https://test.example.com:5000", created_http_proxy.full_url
67
+ end
68
+
69
+ it "should refer to existed Http Proxy" do
70
+ http_proxy = FactoryBot.create(:http_proxy, name: "test", url: "http://test.com")
71
+ config.proxy = "http://test.com"
72
+ config.save!
73
+
74
+ assert_difference('HttpProxy.count', 0) do
75
+ migration.up
76
+ end
77
+
78
+ assert_equal updated_config.http_proxy_id, http_proxy.id
79
+ end
80
+
81
+ it "should refer to existed IP address http proxy" do
82
+ http_proxy = FactoryBot.create(:http_proxy, name: "test", url: "http://212.212.10.23")
83
+ config.proxy = "212.212.10.23"
84
+ config.save!
85
+
86
+ assert_difference('HttpProxy.count', 0) do
87
+ migration.up
88
+ end
89
+
90
+ assert_equal updated_config.http_proxy_id, http_proxy.id
91
+ end
92
+
93
+ it "should create new http proxy if user and password is present" do
94
+ http_proxy = FactoryBot.create(:http_proxy, name: "test", url: "http://proxy.example.com", username: "admin", password: "pass")
95
+ config.proxy = "http://proxy.example.com"
96
+ config.save!
97
+
98
+ assert_difference('HttpProxy.count', 1) do
99
+ migration.up
100
+ end
101
+
102
+ assert_not_equal updated_config.http_proxy_id, http_proxy.id
103
+ assert_equal updated_config.http_proxy_id, created_http_proxy.id
104
+ assert_equal "http://proxy.example.com", created_http_proxy.full_url
105
+ end
106
+
107
+ it "refer to http proxy if user and password is present" do
108
+ http_proxy = FactoryBot.create(:http_proxy, name: "test", url: "http://proxy.example.com", username: "admin", password: "pass")
109
+ config.proxy = "http://admin:pass@proxy.example.com"
110
+ config.save!
111
+
112
+ assert_difference('HttpProxy.count', 0) do
113
+ migration.up
114
+ end
115
+
116
+ assert_equal updated_config.http_proxy_id, http_proxy.id
117
+ end
118
+
119
+ it "should create new http proxy if port is there" do
120
+ http_proxy = FactoryBot.create(:http_proxy, name: "test", url: "http://proxy.example.com:5000")
121
+ config.proxy = "http://proxy.example.com"
122
+ config.save!
123
+
124
+ assert_difference('HttpProxy.count', 1) do
125
+ migration.up
126
+ end
127
+
128
+ assert_not_equal updated_config.http_proxy_id, http_proxy.id
129
+ assert_equal updated_config.http_proxy_id, created_http_proxy.id
130
+ assert_equal "http://proxy.example.com", created_http_proxy.full_url
131
+ end
132
+
133
+ it "should refer to existed http proxy if port is there and config proxy has also same port" do
134
+ http_proxy = FactoryBot.create(:http_proxy, name: "test", url: "http://proxy.example.com:5000")
135
+ config.proxy = "http://proxy.example.com:5000"
136
+ config.save!
137
+
138
+ assert_difference('HttpProxy.count', 0) do
139
+ migration.up
140
+ end
141
+
142
+ assert_equal updated_config.http_proxy_id, http_proxy.id
143
+ end
144
+ end
145
+
146
+ def klass
147
+ ReferConfigProxyToHttpProxy
148
+ end
149
+
150
+ def updated_config
151
+ ::ForemanVirtWhoConfigure::Config.last
152
+ end
153
+
154
+ def created_http_proxy
155
+ HttpProxy.order(:id).last
156
+ end
157
+ end
158
+ end
@@ -57,15 +57,16 @@ module ForemanVirtWhoConfigure
57
57
 
58
58
  describe 'proxy attributes' do
59
59
  test 'it does not set any proxy attributes by default and set no_proxy to * to bypass sub-man proxy' do
60
- assert_nil config.proxy
60
+ assert_nil config.http_proxy
61
61
  assert_nil config.no_proxy
62
62
  assert_not_includes output, 'http_proxy'
63
63
  assert_includes output, 'NO_PROXY=*'
64
64
  end
65
65
 
66
66
  test 'it configures proxy when set' do
67
- config.proxy = 'http://proxy.com'
68
- assert_includes output, 'http_proxy=http://proxy.com'
67
+ http_proxy = HttpProxy.create!(name: "test", url: "http://test.com")
68
+ config.http_proxy = http_proxy
69
+ assert_includes output, 'http_proxy=http://test.com'
69
70
  end
70
71
 
71
72
  test 'it configures no_proxy when set' do
@@ -74,25 +75,30 @@ module ForemanVirtWhoConfigure
74
75
  end
75
76
 
76
77
  test 'proxy_strings prints both proxy and no proxy if present' do
77
- config.proxy = 'a'
78
+ http_proxy = HttpProxy.create!(name: "test", url: "http://test.com")
79
+ config.http_proxy = http_proxy
78
80
  config.no_proxy = 'b'
79
- assert_includes generator.proxy_strings, "\nhttp_proxy=a"
81
+ assert_includes generator.proxy_strings, "\nhttp_proxy=http://test.com"
80
82
  assert_includes generator.proxy_strings, "\NO_PROXY=b"
81
83
  end
82
84
 
83
85
  test 'proxy_strings ignores empty string values' do
84
- config.proxy = ''
86
+ config.http_proxy = nil
85
87
  config.no_proxy = ''
86
88
  assert_not_includes generator.proxy_strings, 'http_proxy'
87
89
  assert_includes generator.proxy_strings, 'NO_PROXY=*'
88
90
  end
89
91
 
90
92
  test 'proxy_strings removes any new line chars' do
91
- config.proxy = "\na\nb\nc\n"
92
93
  config.no_proxy = "\nx\ny\nz"
93
- assert_includes generator.proxy_strings, "\nhttp_proxy=abc"
94
94
  assert_includes generator.proxy_strings, "\NO_PROXY=xyz"
95
95
  end
96
+
97
+ test 'it configures https proxy when https proxy is set' do
98
+ http_proxy = HttpProxy.create!(name: "test", url: "https://test.com")
99
+ config.http_proxy = http_proxy
100
+ assert_includes output, 'https_proxy=https://test.com'
101
+ end
96
102
  end
97
103
 
98
104
  describe 'error codes' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman_virt_who_configure
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.5
4
+ version: 0.5.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Foreman virt-who-configure team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-10-22 00:00:00.000000000 Z
11
+ date: 2020-11-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: katello
@@ -107,6 +107,7 @@ files:
107
107
  - db/migrate/20170407152851_add_name_to_config.rb
108
108
  - db/migrate/20181005065724_filter_and_exclude_host_parents.foreman_virt_who_configure.rb
109
109
  - db/migrate/20190104125749_add_kubeconfig_to_config.rb
110
+ - db/migrate/20200728054557_refer_config_proxy_to_http_proxy.rb
110
111
  - lib/foreman_virt_who_configure.rb
111
112
  - lib/foreman_virt_who_configure/engine.rb
112
113
  - lib/foreman_virt_who_configure/version.rb
@@ -121,6 +122,7 @@ files:
121
122
  - test/functional/api/v2/configs_controller_test.rb
122
123
  - test/test_plugin_helper.rb
123
124
  - test/unit/config_test.rb
125
+ - test/unit/migrate_config_proxy_to_http_proxy.rb
124
126
  - test/unit/output_generator_test.rb
125
127
  homepage: https://github.com/theforeman/foreman_virt_who_configure
126
128
  licenses:
@@ -141,13 +143,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
141
143
  - !ruby/object:Gem::Version
142
144
  version: '0'
143
145
  requirements: []
144
- rubygems_version: 3.0.3
146
+ rubygems_version: 3.1.4
145
147
  signing_key:
146
148
  specification_version: 4
147
149
  summary: A plugin to make virt-who configuration easy
148
150
  test_files:
149
151
  - test/factories/foreman_virt_who_configure_factories.rb
150
- - test/test_plugin_helper.rb
152
+ - test/functional/api/v2/configs_controller_test.rb
153
+ - test/unit/migrate_config_proxy_to_http_proxy.rb
151
154
  - test/unit/config_test.rb
152
155
  - test/unit/output_generator_test.rb
153
- - test/functional/api/v2/configs_controller_test.rb
156
+ - test/test_plugin_helper.rb