foreman_virt_who_configure 0.1.9 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (25) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/stylesheets/foreman_virt_who_configure/config.css.scss +19 -1
  3. data/app/controllers/foreman_virt_who_configure/api/v2/configs_controller.rb +2 -2
  4. data/app/controllers/foreman_virt_who_configure/configs_controller.rb +1 -1
  5. data/app/helpers/foreman_virt_who_configure/configs_helper.rb +22 -0
  6. data/app/models/foreman_virt_who_configure/config.rb +36 -21
  7. data/app/models/foreman_virt_who_configure/output_generator.rb +2 -2
  8. data/app/views/dashboard/_foreman_virt_who_configs_status_widget.html.erb +2 -2
  9. data/app/views/foreman_virt_who_configure/configs/show.html.erb +79 -49
  10. data/db/migrate/20170102152649_create_service_users.rb +1 -1
  11. data/db/migrate/20170102152650_create_configs.rb +1 -1
  12. data/db/migrate/20170102152751_add_lab_attrs_to_config.rb +1 -1
  13. data/db/migrate/20170102152851_add_satellite_url_to_config.rb +1 -1
  14. data/db/migrate/20170215152851_change_default_interval.rb +1 -1
  15. data/db/migrate/20170309161551_add_proxy_and_no_proxy_to_config.rb +1 -1
  16. data/db/migrate/20170404152851_add_last_report_info_to_config.rb +1 -1
  17. data/db/migrate/20170407152851_add_name_to_config.rb +1 -1
  18. data/lib/foreman_virt_who_configure/engine.rb +1 -1
  19. data/lib/foreman_virt_who_configure/version.rb +1 -1
  20. data/test/factories/foreman_virt_who_configure_factories.rb +1 -1
  21. data/test/functional/api/v2/configs_controller_test.rb +15 -15
  22. data/test/test_plugin_helper.rb +3 -3
  23. data/test/unit/config_test.rb +7 -7
  24. data/test/unit/output_generator_test.rb +2 -2
  25. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8355464b93318e276c9ad72c0f65aa8a2f6cae67
4
- data.tar.gz: d89ea732217fd7f6130fa053ee4e7dce8cf799a7
3
+ metadata.gz: fbec596d63b0929f914715bae800aa6bccefb034
4
+ data.tar.gz: 82878e9e9b51c0ebcade48897398456082a11b5c
5
5
  SHA512:
6
- metadata.gz: 2cdca574bc96c5758f60e8fe50ef6cda5697b0625b07a0d00927c442a5d90b7bf5db9d202b2c6394a1d025ccc9f524600d58f21618d9675d1160d74e49669d10
7
- data.tar.gz: 1e5d4b2f4ecff060df3718c57a7102d03177fe536cd9c4b7f53763b10c5d0a6231dedc82804a686698e1442a261a2f7bf6898afd776b995ead8a4886aef8891f
6
+ metadata.gz: db056b2ccc2260d4aa2ed880e036538f591848e6e1afe1c8514381f61492af33e1e07e2c91275613e12b69017cebb43be1855b71f9dd4ff40dd80225440f3a02
7
+ data.tar.gz: 42c181ac286dd6444c1a815e3d319a1c575894b9ef1278b819f88142f16378050ea3558a5f0fafd5cdbce36528516c53e77fe23b030920f576d7479e91525b1c
@@ -12,6 +12,24 @@ pre.terminal {
12
12
  border-radius: 0px;
13
13
  font-family: Menlo, Monaco, Consolas, monospace;
14
14
  }
15
- .terminal-buttons {
15
+
16
+ .terminal-buttons {
16
17
  margin-bottom: 10px;
17
18
  }
19
+
20
+ #config-tab.nav {
21
+ margin-bottom: 0;
22
+ }
23
+
24
+ #config-tab.nav {
25
+ clear: both;
26
+ }
27
+
28
+ .config-tab-content {
29
+ padding: 20px;
30
+ border: 1px solid #ddd;
31
+ border-radius: 2px;
32
+ border-top: 0;
33
+ display: inline-block;
34
+ width: 100%;
35
+ }
@@ -29,8 +29,8 @@ module ForemanVirtWhoConfigure
29
29
  param :id, :identifier, :required => true
30
30
  def deploy_script
31
31
  respond_to do |format|
32
- format.text { render :text => @config.virt_who_bash_script }
33
- format.sh { render :text => @config.virt_who_bash_script }
32
+ format.text { send_data @config.virt_who_bash_script, :filename => "deploy_virt_who_config_#{@config.id}.sh", :type => 'text/x-shellscript', :disposition => :attachment }
33
+ format.sh { send_data @config.virt_who_bash_script, :filename => "deploy_virt_who_config_#{@config.id}.sh", :type => 'text/x-shellscript', :disposition => :attachment }
34
34
  format.json
35
35
  end
36
36
  end
@@ -36,7 +36,7 @@ module ForemanVirtWhoConfigure
36
36
  def create
37
37
  @config = Config.new(config_params)
38
38
  if @config.save
39
- process_success :success_redirect => foreman_virt_who_configure_config_path(@config)
39
+ process_success :success_redirect => foreman_virt_who_configure_config_path(@config), :object => @config
40
40
  else
41
41
  render 'new'
42
42
  end
@@ -62,5 +62,27 @@ module ForemanVirtWhoConfigure
62
62
  'status-warn'.html_safe
63
63
  end
64
64
  end
65
+
66
+ def config_attribute_default_label(attr)
67
+ s_(ForemanVirtWhoConfigure::Config.gettext_translation_for_attribute_name(attr).titleize)
68
+ end
69
+
70
+ def config_attribute_label(attr, label)
71
+ content_tag :div, :class => 'col-md-2' do
72
+ content_tag :strong, (label || config_attribute_default_label(attr))
73
+ end
74
+ end
75
+
76
+ def config_attribute_value(attribute, value)
77
+ content_tag :div, :class => 'config-status' do
78
+ content_tag :span, value, :class => "config-#{attribute}"
79
+ end
80
+ end
81
+
82
+ def config_attribute(attribute, value, label = nil)
83
+ content_tag :div, :class => 'row' do
84
+ config_attribute_label(attribute, label) + config_attribute_value(attribute, value)
85
+ end
86
+ end
65
87
  end
66
88
  end
@@ -8,8 +8,8 @@ module ForemanVirtWhoConfigure
8
8
  # We keep both params permitted for compatibility with 1.11
9
9
  :listing_mode, :filtering_mode
10
10
  ]
11
- include Authorizable
12
11
  audited :except => [ :hypervisor_password, :last_report_at, :out_of_date_at ]
12
+ include Authorizable
13
13
  validates_lengths_from_database
14
14
 
15
15
  UNLIMITED = 0
@@ -111,36 +111,51 @@ module ForemanVirtWhoConfigure
111
111
  when 'ok'
112
112
  sanitize_sql_for_conditions([' out_of_date_at >= ? ', DateTime.now.utc.to_s(:db)])
113
113
  when 'unknown'
114
- sanitize_sql_for_conditions({:last_report_at => nil})
114
+ sanitize_sql_for_conditions([' last_report_at IS NULL'])
115
115
  when 'out_of_date'
116
116
  sanitize_sql_for_conditions([' out_of_date_at < ? ', DateTime.now.utc.to_s(:db)])
117
117
  end
118
118
  { :conditions => condition }
119
119
  end
120
120
 
121
- def create_service_user
122
- password = User.random_password
123
- service_user = self.build_service_user
124
- user = service_user.build_user
125
- user.auth_source = AuthSourceHiddenWithAuthentication.default
126
- user.password = password
127
- user.login = "virt_who_reporter_#{self.id}"
128
- user.organizations = [ self.organization ]
129
- user.roles = [ Role.where(:name => 'Virt-who Reporter').first ]
130
- user.valid? # to trigger password hashing
131
- user.save!(:validate => false)
132
-
133
- service_user.encrypted_password = password
134
- service_user.save!
121
+ def permission_name(action)
122
+ case action
123
+ when :create
124
+ 'create_virt_who_config'
125
+ when :edit
126
+ 'edit_virt_who_config'
127
+ else
128
+ raise "unknown permission for action #{action}"
129
+ end
130
+ end
135
131
 
136
- self.update_attribute :service_user_id, service_user.id
132
+ def create_service_user
133
+ User.skip_permission_check do
134
+ password = User.random_password
135
+ service_user = self.build_service_user
136
+ user = service_user.build_user
137
+ user.auth_source = AuthSourceHiddenWithAuthentication.default
138
+ user.password = password
139
+ user.login = "virt_who_reporter_#{self.id}"
140
+ user.organizations = [self.organization]
141
+ user.roles = [Role.where(:name => 'Virt-who Reporter').first]
142
+ user.valid? # to trigger password hashing
143
+ user.save!(:validate => false)
144
+
145
+ service_user.encrypted_password = password
146
+ service_user.save!
147
+
148
+ self.update_attribute :service_user_id, service_user.id
149
+ end
137
150
  end
138
151
 
139
152
  def destroy_service_user
140
- # skip validation that prevents hidden user deletion
141
- user = User.unscoped.find_by_id(service_user.user_id)
142
- service_user.destroy
143
- user.delete
153
+ User.skip_permission_check do
154
+ # skip validation that prevents hidden user deletion
155
+ user = User.unscoped.find_by_id(service_user.user_id)
156
+ service_user.destroy
157
+ user.delete
158
+ end
144
159
  end
145
160
 
146
161
  # mapping of supported CR types
@@ -84,8 +84,8 @@ yum install -y virt-who || result_code=$(($result_code|#{error_code(:virt_who_in
84
84
 
85
85
  if verify_minimal_version; then
86
86
  step 2 "Encrypting password"
87
- cr_password=`virt-who-password --password "#{cr_password}" 2> /dev/null`
88
- user_password=`virt-who-password --password "#{service_user_password}" 2> /dev/null`
87
+ cr_password=`virt-who-password --password '#{cr_password}' 2> /dev/null`
88
+ user_password=`virt-who-password --password '#{service_user_password}' 2> /dev/null`
89
89
 
90
90
  step 3 "Creating virt-who configuration"
91
91
  cat > #{config_file_path} << EOF
@@ -3,7 +3,7 @@
3
3
  <% out_of_date = scope.out_of_date.order('out_of_date_at DESC') %>
4
4
 
5
5
  <h4 class="header"><%= _('Virt-who Configurations Status') %></h4>
6
- <table class="table table-striped ellipsis">
6
+ <table class="<%= table_css_classes 'ellipsis' %>">
7
7
  <thead>
8
8
  <tr>
9
9
  <th><%= _("Configuration Status") %></th>
@@ -34,7 +34,7 @@
34
34
  <% if out_of_date.empty? %>
35
35
  <div class="ca"><%= _("No configuration found") %></div>
36
36
  <% else %>
37
- <table class="table table-striped ellipsis">
37
+ <table class="<%= table_css_classes 'ellipsis' %>">
38
38
  <thead>
39
39
  <tr>
40
40
  <th><%= s_("Config|Name") %></th>
@@ -1,61 +1,91 @@
1
1
  <% stylesheet 'foreman_virt_who_configure/config' %>
2
2
  <% javascript 'foreman_virt_who_configure/config_copy_and_paste' %>
3
+ <% title(_("Virt-who Configuration %s") % @config.name) %>
4
+ <%= title_actions(
5
+ display_link_if_authorized(_('Edit'), hash_for_edit_foreman_virt_who_configure_config_path(@config).merge(:permission => 'edit_virt_who_config', :auth_object => @config), :class => 'btn btn-default'),
6
+ display_delete_if_authorized(hash_for_foreman_virt_who_configure_config_path(@config).merge(:permission => 'destroy_virt_who_config', :auth_object => @config), :class => 'btn btn-default', :data => {:confirm => _("Delete virt-who configuration %s?") % config.name})
7
+ ) %>
3
8
 
4
- <div class="clearfix">
5
- <div class="form-group">
6
- <div class="row">
7
- <div class="col-md-12">
8
- <h1><%= _("Virt-who Configuration %s") % @config.name %></h1>
9
- </div>
10
- <div class="col-md-6">
11
- <%= _("Use either hammer command or the script below to deploy this configuration. Both require root privileges. Run one of them on the target host which has access to Red Hat Satellite Tools repository and will run virt-who reporting, preferably Satellite host:") %>
12
- </div>
13
- <div class="col-md-2">
14
- <div class="pull-right">
15
- <p>
16
- <%= display_link_if_authorized _('Edit this configuration'), hash_for_edit_foreman_virt_who_configure_config_path(@config).merge(:permission => 'show_virt_who_config', :auth_object => @config), :class => 'btn btn-default' %>
17
- </p>
9
+ <ul id="config-tab" class="nav nav-tabs">
10
+ <li class="active"><a href="#overview" data-toggle="tab"><%= _('Overview') %></a></li>
11
+ <li><a href="#deploy" data-toggle="tab"><%= _('Deploy') %></a></li>
12
+ </ul>
13
+
14
+ <div id="config-tab-content" class="config-tab-content tab-content">
15
+ <div class="tab-pane active in" id="overview">
16
+ <div class="clearfix">
17
+ <div class="form-group">
18
+ <div class="col-md-12">
19
+ <div class="row">
20
+ <h3><%= _('Details') %></h3>
21
+ </div>
22
+
23
+ <%= config_attribute :status, config_report_status(@config), _('Status') %>
24
+ <%= config_attribute :hypervisor_type, _(ForemanVirtWhoConfigure::Config::HYPERVISOR_TYPES[@config.hypervisor_type]) %>
25
+ <%= config_attribute :hypervisor_server, @config.hypervisor_server %>
26
+ <%= config_attribute :hypervisor_username, @config.hypervisor_username %>
27
+ <%= config_attribute :interval, _(ForemanVirtWhoConfigure::Config::AVAILABLE_INTERVALS[@config.interval.to_s]) %>
28
+ <%= config_attribute :satellite_url, @config.satellite_url, _('Satellite server FQDN')%>
29
+ <%= config_attribute :hypervisor_id, @config.hypervisor_id, _('Hypervisor ID') %>
30
+ <%= config_attribute :listing_mode, _(ForemanVirtWhoConfigure::Config::FILTERING_MODES[@config.listing_mode.to_s]), _('Filtering') %>
31
+ <%= config_attribute :whitelist, @config.whitelist if @config.whitelist.present? %>
32
+ <%= config_attribute :blacklist, @config.blacklist if @config.blacklist.present? %>
33
+ <%= config_attribute :debug, checked_icon(@config.debug), _('Enable debugging output?') %>
34
+ <%= config_attribute :proxy, @config.proxy if @config.proxy.present? %>
35
+ <%= config_attribute :no_proxy, @config.no_proxy if @config.no_proxy.present? %>
18
36
  </div>
19
37
  </div>
20
38
  </div>
39
+ </div>
21
40
 
22
- <div class="row">
23
- <div class="col-md-12">
24
- <h2><%= 'a) ' + _('Hammer command: ') %></h2>
25
- </div>
26
- </div>
27
- <div class="row">
28
- <div class="col-md-8">
29
- <pre class="terminal" id="config_command"><%= @config.virt_who_config_command %></pre>
30
- </div>
31
- <div class="col-md-8">
32
- <div class="terminal-buttons">
33
- <%= link_to _('Copy to clipboard'), nil, :class => 'btn btn-default', :onclick => 'virt_who_copy_configuration_to_clipboard($("#config_command").html())' %>
41
+ <div class="tab-pane in" id="deploy">
42
+ <div class="clearfix">
43
+ <div class="form-group">
44
+ <div class="row">
45
+ <div class="col-md-6">
46
+ <%= _("Use either hammer command or the script below to deploy this configuration. Both require root privileges. Run one of them on the target host which has access to Red Hat Satellite Tools repository and will run virt-who reporting, preferably Satellite host:") %>
47
+ </div>
34
48
  </div>
35
- </div>
36
- </div>
37
49
 
38
- <div class="row">
39
- <div class="col-md-12">
40
- <h2><%= 'b) ' + _('Configuration script: ') %></h2>
41
- </div>
42
- <div class="col-md-8">
43
- <p>
44
- <%= _("On the target virt-who host:") %></br>
45
- <%= _("1. Copy this configuration script to a safe directory.") %></br>
46
- <%= _("2. Make the script executable and run it.") %></br>
47
- <%= _("3. Delete the script.") %></br>
48
- </p>
49
- </div>
50
- </div>
51
- <div class="row">
52
- <div class="col-md-8">
53
- <pre class="terminal" id="config_script"><%= @config.virt_who_config_script %></pre>
54
- </div>
55
- <div class="col-md-8">
56
- <div class="terminal-buttons">
57
- <%= link_to _('Copy to clipboard'), nil, :class => 'btn btn-default', :onclick => 'virt_who_copy_configuration_to_clipboard($("#config_script").html())' %>
58
- <%= link_to _('Download the script'), deploy_script_foreman_virt_who_configure_config_path(@config), :class => 'btn btn-default' %>
50
+ <div class="row">
51
+ <div class="col-md-12">
52
+ <h3><%= 'a) ' + _('Hammer command: ') %></h3>
53
+ </div>
54
+ </div>
55
+ <div class="row">
56
+ <div class="col-md-8">
57
+ <pre class="terminal" id="config_command"><%= @config.virt_who_config_command %></pre>
58
+ </div>
59
+ <div class="col-md-8">
60
+ <div class="terminal-buttons">
61
+ <%= link_to _('Copy to clipboard'), nil, :class => 'btn btn-default', :onclick => 'virt_who_copy_configuration_to_clipboard($("#config_command").html()); return false' %>
62
+ </div>
63
+ </div>
64
+ </div>
65
+
66
+ <div class="row">
67
+ <div class="col-md-12">
68
+ <h3><%= 'b) ' + _('Configuration script: ') %></h3>
69
+ </div>
70
+ <div class="col-md-8">
71
+ <p>
72
+ <%= _("On the target virt-who host:") %></br>
73
+ <%= _("1. Copy this configuration script to a safe directory.") %></br>
74
+ <%= _("2. Make the script executable and run it.") %></br>
75
+ <%= _("3. Delete the script.") %></br>
76
+ </p>
77
+ </div>
78
+ </div>
79
+ <div class="row">
80
+ <div class="col-md-8">
81
+ <pre class="terminal" id="config_script"><%= @config.virt_who_config_script %></pre>
82
+ </div>
83
+ <div class="col-md-8">
84
+ <div class="terminal-buttons">
85
+ <%= link_to _('Copy to clipboard'), nil, :class => 'btn btn-default', :onclick => 'virt_who_copy_configuration_to_clipboard($("#config_script").html()); return false' %>
86
+ <%= link_to _('Download the script'), deploy_script_foreman_virt_who_configure_config_path(@config), :class => 'btn btn-default' %>
87
+ </div>
88
+ </div>
59
89
  </div>
60
90
  </div>
61
91
  </div>
@@ -1,4 +1,4 @@
1
- class CreateServiceUsers < ActiveRecord::Migration
1
+ class CreateServiceUsers < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  create_table :foreman_virt_who_configure_service_users do |t|
4
4
  t.string :encrypted_password, :null => false
@@ -1,4 +1,4 @@
1
- class CreateConfigs < ActiveRecord::Migration
1
+ class CreateConfigs < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  create_table :foreman_virt_who_configure_configs do |t|
4
4
  t.integer :interval, :default => 60, :null => true
@@ -1,4 +1,4 @@
1
- class AddLabAttrsToConfig < ActiveRecord::Migration
1
+ class AddLabAttrsToConfig < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  add_column :foreman_virt_who_configure_configs, :debug, :boolean, :default => false, :null => true
4
4
  add_column :foreman_virt_who_configure_configs, :hypervisor_type, :string, :null => true
@@ -1,4 +1,4 @@
1
- class AddSatelliteUrlToConfig < ActiveRecord::Migration
1
+ class AddSatelliteUrlToConfig < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  add_column :foreman_virt_who_configure_configs, :satellite_url, :string, :null => true
4
4
  end
@@ -1,4 +1,4 @@
1
- class ChangeDefaultInterval < ActiveRecord::Migration
1
+ class ChangeDefaultInterval < ActiveRecord::Migration[4.2]
2
2
  def up
3
3
  change_column :foreman_virt_who_configure_configs, :interval, :integer, :default => 120
4
4
  end
@@ -1,4 +1,4 @@
1
- class AddProxyAndNoProxyToConfig < ActiveRecord::Migration
1
+ class AddProxyAndNoProxyToConfig < ActiveRecord::Migration[4.2]
2
2
  def up
3
3
  add_column :foreman_virt_who_configure_configs, :proxy, :string
4
4
  add_column :foreman_virt_who_configure_configs, :no_proxy, :string
@@ -1,4 +1,4 @@
1
- class AddLastReportInfoToConfig < ActiveRecord::Migration
1
+ class AddLastReportInfoToConfig < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  add_column :foreman_virt_who_configure_configs, :last_report_at, :datetime
4
4
  add_column :foreman_virt_who_configure_configs, :out_of_date_at, :datetime
@@ -1,4 +1,4 @@
1
- class AddNameToConfig < ActiveRecord::Migration
1
+ class AddNameToConfig < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  add_column :foreman_virt_who_configure_configs, :name, :string, :null => false, :default => ''
4
4
  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.11'
30
+ requires_foreman '>= 1.16'
31
31
  requires_foreman_plugin 'katello', '>= 3.0.0'
32
32
 
33
33
  apipie_documented_controllers ["#{ForemanVirtWhoConfigure::Engine.root}/app/controllers/foreman_virt_who_configure/api/v2/*.rb"]
@@ -1,3 +1,3 @@
1
1
  module ForemanVirtWhoConfigure
2
- VERSION = '0.1.9'.freeze
2
+ VERSION = '0.2.0'.freeze
3
3
  end
@@ -1,4 +1,4 @@
1
- FactoryGirl.define do
1
+ FactoryBot.define do
2
2
  factory :virt_who_config, :class => ::ForemanVirtWhoConfigure::Config do
3
3
  sequence(:name) { |n| "config #{n}" }
4
4
  organization
@@ -2,7 +2,7 @@ require 'test_plugin_helper'
2
2
 
3
3
  class ForemanVirtWhoConfigure::Api::V2::ConfigsControllerTest < ActionController::TestCase
4
4
  setup do
5
- @new_config = FactoryGirl.create(:virt_who_config,
5
+ @new_config = FactoryBot.create(:virt_who_config,
6
6
  :name => 'my vmware',
7
7
  :interval => 120,
8
8
  :listing_mode => ForemanVirtWhoConfigure::Config::WHITELIST,
@@ -17,12 +17,12 @@ class ForemanVirtWhoConfigure::Api::V2::ConfigsControllerTest < ActionController
17
17
  :no_proxy => nil
18
18
  )
19
19
 
20
- @out_of_date_config = FactoryGirl.create(:virt_who_config, :out_of_date)
21
- @ok_config = FactoryGirl.create(:virt_who_config, :ok)
20
+ @out_of_date_config = FactoryBot.create(:virt_who_config, :out_of_date)
21
+ @ok_config = FactoryBot.create(:virt_who_config, :ok)
22
22
  end
23
23
 
24
24
  test "should get index" do
25
- get :index, {}, set_session_user
25
+ get :index, :params => {}, :session => set_session_user
26
26
  response = ActiveSupport::JSON.decode(@response.body)
27
27
  assert_not response['results'].empty?
28
28
  assert_response :success
@@ -59,7 +59,7 @@ class ForemanVirtWhoConfigure::Api::V2::ConfigsControllerTest < ActionController
59
59
  end
60
60
 
61
61
  test "should get show for new config" do
62
- get :show, { :id => @new_config.to_param }, set_session_user
62
+ get :show, :params => { :id => @new_config.to_param }, :session => set_session_user
63
63
  response = ActiveSupport::JSON.decode(@response.body)
64
64
 
65
65
  assert_equal 'my vmware', response['name']
@@ -84,7 +84,7 @@ class ForemanVirtWhoConfigure::Api::V2::ConfigsControllerTest < ActionController
84
84
  end
85
85
 
86
86
  test "should get show for ok config" do
87
- get :show, { :id => @ok_config.to_param }, set_session_user
87
+ get :show, :params => { :id => @ok_config.to_param }, :session => set_session_user
88
88
  response = ActiveSupport::JSON.decode(@response.body)
89
89
 
90
90
  assert_equal 'ok', response['status']
@@ -94,7 +94,7 @@ class ForemanVirtWhoConfigure::Api::V2::ConfigsControllerTest < ActionController
94
94
  end
95
95
 
96
96
  test "should get show for out of date config" do
97
- get :show, { :id => @out_of_date_config.to_param }, set_session_user
97
+ get :show, :params => { :id => @out_of_date_config.to_param }, :session => set_session_user
98
98
  response = ActiveSupport::JSON.decode(@response.body)
99
99
 
100
100
  assert_equal 'out_of_date', response['status']
@@ -104,7 +104,7 @@ class ForemanVirtWhoConfigure::Api::V2::ConfigsControllerTest < ActionController
104
104
  end
105
105
 
106
106
  test "should get deploy script for config" do
107
- get :deploy_script, { :id => @out_of_date_config.to_param }, set_session_user
107
+ get :deploy_script, :params => { :id => @out_of_date_config.to_param }, :session => set_session_user
108
108
  response = ActiveSupport::JSON.decode(@response.body)
109
109
 
110
110
  assert_response :success
@@ -112,7 +112,7 @@ class ForemanVirtWhoConfigure::Api::V2::ConfigsControllerTest < ActionController
112
112
  end
113
113
 
114
114
  test "should get deploy script for plain/text format" do
115
- get :deploy_script, { :id => @out_of_date_config.to_param, :format => 'txt' }, set_session_user
115
+ get :deploy_script, :params => { :id => @out_of_date_config.to_param }, :session => set_session_user, :format => :txt
116
116
  response = @response.body
117
117
 
118
118
  assert_response :success
@@ -120,7 +120,7 @@ class ForemanVirtWhoConfigure::Api::V2::ConfigsControllerTest < ActionController
120
120
  end
121
121
 
122
122
  test "should get deploy script for shell script format" do
123
- get :deploy_script, { :id => @out_of_date_config.to_param, :format => 'sh' }, set_session_user
123
+ get :deploy_script, :params => { :id => @out_of_date_config.to_param }, :session => set_session_user, :format => :sh
124
124
  response = @response.body
125
125
 
126
126
  assert_response :success
@@ -128,8 +128,8 @@ class ForemanVirtWhoConfigure::Api::V2::ConfigsControllerTest < ActionController
128
128
  end
129
129
 
130
130
  test "should create the config" do
131
- org = FactoryGirl.create(:organization)
132
- post :create, { :foreman_virt_who_configure_config => { :name => 'my new config',
131
+ org = FactoryBot.create(:organization)
132
+ post :create, :params => { :foreman_virt_who_configure_config => { :name => 'my new config',
133
133
  :interval => 240,
134
134
  :filtering_mode => ForemanVirtWhoConfigure::Config::BLACKLIST,
135
135
  :blacklist => ' a,b ',
@@ -141,7 +141,7 @@ class ForemanVirtWhoConfigure::Api::V2::ConfigsControllerTest < ActionController
141
141
  :debug => true,
142
142
  :satellite_url => "foreman.example.com",
143
143
  :organization_id => org.id }
144
- }, set_session_user
144
+ }, :session => set_session_user
145
145
 
146
146
  assert_response :success
147
147
 
@@ -161,7 +161,7 @@ class ForemanVirtWhoConfigure::Api::V2::ConfigsControllerTest < ActionController
161
161
  end
162
162
 
163
163
  test "should update the config" do
164
- put :update, { :id => @ok_config.to_param, :foreman_virt_who_configure_config => { :name => 'updated', :interval => 240, :hypervisor_password => 'new_pass' } }, set_session_user
164
+ put :update, :params => { :id => @ok_config.to_param, :foreman_virt_who_configure_config => { :name => 'updated', :interval => 240, :hypervisor_password => 'new_pass' } }, :session => set_session_user
165
165
  assert_response :success
166
166
  @ok_config.reload
167
167
  assert_equal 'updated', @ok_config.name
@@ -170,7 +170,7 @@ class ForemanVirtWhoConfigure::Api::V2::ConfigsControllerTest < ActionController
170
170
  end
171
171
 
172
172
  test "should destroy the config" do
173
- delete :destroy, { :id => @ok_config.to_param }, set_session_user
173
+ delete :destroy, :params => { :id => @ok_config.to_param }, :session => set_session_user
174
174
  assert_response :success
175
175
 
176
176
  assert_empty ForemanVirtWhoConfigure::Config.where(:id => @ok_config.id).all
@@ -1,6 +1,6 @@
1
1
  # This calls the main test_helper in Foreman-core
2
2
  require 'test_helper'
3
3
 
4
- # Add plugin to FactoryGirl's paths
5
- FactoryGirl.definition_file_paths << File.join(File.dirname(__FILE__), 'factories')
6
- FactoryGirl.reload
4
+ # Add plugin to FactoryBot's paths
5
+ FactoryBot.definition_file_paths << File.join(File.dirname(__FILE__), 'factories')
6
+ FactoryBot.reload
@@ -2,7 +2,7 @@ require 'test_plugin_helper'
2
2
 
3
3
  module ForemanVirtWhoConfigure
4
4
  class ConfigTest < ActiveSupport::TestCase
5
- let(:config) { FactoryGirl.build(:virt_who_config) }
5
+ let(:config) { FactoryBot.build(:virt_who_config) }
6
6
 
7
7
  test 'config can be saved' do
8
8
  config.save
@@ -63,9 +63,9 @@ module ForemanVirtWhoConfigure
63
63
  end
64
64
 
65
65
  describe 'organization scoping' do
66
- let(:another_org) { FactoryGirl.create(:organization) }
67
- let(:config_1) { FactoryGirl.create(:virt_who_config) }
68
- let(:config_2) { FactoryGirl.create(:virt_who_config, :organization => another_org) }
66
+ let(:another_org) { FactoryBot.create(:organization) }
67
+ let(:config_1) { FactoryBot.create(:virt_who_config) }
68
+ let(:config_2) { FactoryBot.create(:virt_who_config, :organization => another_org) }
69
69
 
70
70
  before do
71
71
  # let is lazy
@@ -86,9 +86,9 @@ module ForemanVirtWhoConfigure
86
86
  end
87
87
 
88
88
  describe 'statuses and expiration' do
89
- let(:out_of_date_config) { FactoryGirl.create(:virt_who_config, :out_of_date) }
90
- let(:ok_config) { FactoryGirl.create(:virt_who_config, :ok) }
91
- let(:unknown_config) { FactoryGirl.create(:virt_who_config) }
89
+ let(:out_of_date_config) { FactoryBot.create(:virt_who_config, :out_of_date) }
90
+ let(:ok_config) { FactoryBot.create(:virt_who_config, :ok) }
91
+ let(:unknown_config) { FactoryBot.create(:virt_who_config) }
92
92
  before do
93
93
  # let is lazy
94
94
  preload = out_of_date_config, ok_config, unknown_config
@@ -1,7 +1,7 @@
1
1
  require 'test_plugin_helper'
2
2
  module ForemanVirtWhoConfigure
3
3
  class OutputGeneratorTest < ActiveSupport::TestCase
4
- let(:config) { FactoryGirl.create(:virt_who_config) }
4
+ let(:config) { FactoryBot.create(:virt_who_config) }
5
5
  let(:generator) { OutputGenerator.new(config) }
6
6
  let(:output) { generator.virt_who_output }
7
7
  let(:bash_script_output) { generator.virt_who_output(:bash_script) }
@@ -10,7 +10,7 @@ module ForemanVirtWhoConfigure
10
10
  test 'empty password is replaced by fake value so that virt-who runs in an non-interactive mode' do
11
11
  config.hypervisor_password = nil
12
12
  config.hypervisor_type = 'libvirt'
13
- assert_includes output, 'virt-who-password --password "' + OutputGenerator::LIBVIRT_FAKE_PASSWORD + '"'
13
+ assert_includes output, 'virt-who-password --password \'' + OutputGenerator::LIBVIRT_FAKE_PASSWORD + '\''
14
14
  end
15
15
  end
16
16
 
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.1.9
4
+ version: 0.2.0
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: 2017-12-20 00:00:00.000000000 Z
11
+ date: 2018-04-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: katello