foreman_salt 5.0.1 → 6.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (32) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/foreman_salt/api/v2/salt_autosign_controller.rb +1 -1
  3. data/app/controllers/foreman_salt/api/v2/salt_environments_controller.rb +1 -1
  4. data/app/controllers/foreman_salt/api/v2/salt_keys_controller.rb +2 -2
  5. data/app/controllers/foreman_salt/api/v2/salt_minions_controller.rb +1 -1
  6. data/app/controllers/foreman_salt/api/v2/salt_states_controller.rb +3 -3
  7. data/app/controllers/foreman_salt/minions_controller.rb +1 -40
  8. data/app/controllers/foreman_salt/salt_environments_controller.rb +1 -1
  9. data/app/controllers/foreman_salt/salt_modules_controller.rb +3 -4
  10. data/app/controllers/foreman_salt/state_importer.rb +1 -1
  11. data/app/models/foreman_salt/concerns/host_managed_extensions.rb +2 -2
  12. data/app/services/foreman_salt/fact_importer.rb +1 -1
  13. data/app/services/foreman_salt/report_importer.rb +2 -4
  14. data/app/views/foreman_salt/salt_autosign/index.html.erb +1 -1
  15. data/app/views/foreman_salt/salt_environments/index.html.erb +1 -1
  16. data/app/views/foreman_salt/salt_keys/index.erb +1 -1
  17. data/app/views/foreman_salt/salt_modules/index.html.erb +1 -1
  18. data/lib/foreman_salt/engine.rb +1 -1
  19. data/lib/foreman_salt/plugin.rb +1 -1
  20. data/lib/foreman_salt/version.rb +1 -1
  21. data/lib/tasks/foreman_salt_tasks.rake +3 -6
  22. data/test/functional/api/v2/salt_autosign_controller_test.rb +18 -20
  23. data/test/functional/api/v2/salt_environments_controller_test.rb +23 -25
  24. data/test/functional/api/v2/salt_keys_controller_test.rb +19 -21
  25. data/test/functional/api/v2/salt_states_controller_test.rb +64 -66
  26. data/test/integration/salt_autosign_test.rb +1 -0
  27. data/test/integration/salt_environment_test.rb +2 -1
  28. data/test/integration/salt_keys_test.rb +1 -0
  29. data/test/integration/salt_module_test.rb +1 -0
  30. data/test/unit/grains_importer_test.rb +2 -4
  31. data/test/unit/host_extensions_test.rb +1 -1
  32. metadata +17 -17
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: db1aa26e9f75b7b0673e373a1bfb7b7c6a1e7333
4
- data.tar.gz: cb9ea975a7a1ea549cf2f6006a3ae88ce49f1361
3
+ metadata.gz: feb89e35b3867722b4e8be153d07aa9d726c39bb
4
+ data.tar.gz: c0cc7b621377daf0d949ce033c3e79d521fb3652
5
5
  SHA512:
6
- metadata.gz: af94628121430ff29a6cefaf22cd0e882d6b3f5ff80d412b8c9ce890c6338f74983f71f251716f8012012ae3c13d1e8dd1e0fd6382f29638ad8af10f61698e34
7
- data.tar.gz: 827eda4f3ef2e520e782e4f0d69b01d35bb4a8e0494e0cd93de351eba54ca373734d64d763d1685ec37ede0c397b2736c306e62db7ae5e06bf4bd256914a3cd4
6
+ metadata.gz: 3f9b14758af01ec653d545faad1547002ed3c6a8541ed4933deea5cf1254f866fc2a124cec1d29cf3a8896700bd98858d52bf8404ebe913d17ca852753df87f5
7
+ data.tar.gz: 34e8ebac0aaaabce008600299026dfa61e45652ad8e3191c0ab5e737d2736cf15d11d18d4aab642f83dfb2c0b70d2f1004664c546e9a80f6d72476579db28005
@@ -4,7 +4,7 @@ module ForemanSalt
4
4
  module Api
5
5
  module V2
6
6
  class SaltAutosignController < ::ForemanSalt::Api::V2::BaseController
7
- before_filter :find_proxy, :setup_proxy
7
+ before_action :find_proxy, :setup_proxy
8
8
 
9
9
  api :GET, '/salt_autosign/:smart_proxy_id', N_('List all autosign records')
10
10
  param :smart_proxy_id, :identifier_dottable, :required => true
@@ -2,7 +2,7 @@ module ForemanSalt
2
2
  module Api
3
3
  module V2
4
4
  class SaltEnvironmentsController < ::ForemanSalt::Api::V2::BaseController
5
- before_filter :find_resource, :except => [:index, :create]
5
+ before_action :find_resource, :except => [:index, :create]
6
6
 
7
7
  api :GET, '/salt_environments', N_('List all Salt environments')
8
8
  param_group :search_and_pagination, ::Api::V2::BaseController
@@ -2,8 +2,8 @@ module ForemanSalt
2
2
  module Api
3
3
  module V2
4
4
  class SaltKeysController < ::ForemanSalt::Api::V2::BaseController
5
- before_filter :find_proxy
6
- before_filter :find_key, :only => [:update, :destroy]
5
+ before_action :find_proxy
6
+ before_action :find_key, :only => [:update, :destroy]
7
7
 
8
8
  api :GET, '/salt_keys/:smart_proxy_id', N_('List all Salt keys')
9
9
  param :smart_proxy_id, :identifier_dottable, :required => true
@@ -2,7 +2,7 @@ module ForemanSalt
2
2
  module Api
3
3
  module V2
4
4
  class SaltMinionsController < ::ForemanSalt::Api::V2::BaseController
5
- before_filter :find_resource, :except => [:index]
5
+ before_action :find_resource, :except => [:index]
6
6
 
7
7
  api :GET, '/salt_minions', N_('List all Salt Minions')
8
8
  param_group :search_and_pagination, ::Api::V2::BaseController
@@ -4,9 +4,9 @@ module ForemanSalt
4
4
  class SaltStatesController < ::ForemanSalt::Api::V2::BaseController
5
5
  include StateImporter
6
6
 
7
- before_filter :find_resource, :except => [:index, :create, :import]
8
- before_filter :find_proxy, :only => :import
9
- before_filter :find_environment, :only => :index
7
+ before_action :find_resource, :except => [:index, :create, :import]
8
+ before_action :find_proxy, :only => :import
9
+ before_action :find_environment, :only => :index
10
10
 
11
11
  api :GET, '/salt_states', N_('List all Salt states')
12
12
  param :salt_environment_id, :identifier_dottable, :required => false, :desc => N_('Limit to a specific environment')
@@ -2,7 +2,7 @@ module ForemanSalt
2
2
  class MinionsController < ::ForemanSalt::ApplicationController
3
3
  include ::Foreman::Controller::SmartProxyAuth
4
4
 
5
- before_filter :find_resource, :only => [:node, :run]
5
+ before_action :find_resource, :only => [:node, :run]
6
6
  add_smart_proxy_filters :node, :features => 'Salt'
7
7
 
8
8
  def node
@@ -84,42 +84,3 @@ module ForemanSalt
84
84
  end
85
85
  end
86
86
  end
87
-
88
- =begin
89
- Minions controller? BANANA!!!
90
-
91
- ────────────▀▄───█───▄▀
92
- ───────────▄▄▄█▄▄█▄▄█▄▄▄
93
- ────────▄▀▀═════════════▀▀▄
94
- ───────█═══════════════════█
95
- ──────█═════════════════════█
96
- ─────█════════▄▄▄▄▄▄▄════════█
97
- ────█════════█████████════════█
98
- ────█═══════██▀─────▀██═══════█
99
- ───███████████──█▀█──███████████
100
- ───███████████──▀▀▀──███████████
101
- ────█═══════▀█▄─────▄█▀═══════█
102
- ────█═════════▀█████▀═════════█
103
- ────█═════════════════════════█
104
- ────█═════════════════════════█
105
- ────█═══════█▀█▀█▀█▀█▀█═══════█
106
- ────█═══════▀▄───────▄▀═══════█
107
- ────█═════════▀▄█▄█▄▀═════════█
108
- ────█═════════════════════════█
109
- ───▐▓▓▌═════════════════════▐▓▓▌
110
- ───▐▐▓▓▌▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▐▓▓▌▌
111
- ───█══▐▓▄▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄▓▌══█
112
- ──█══▌═▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▌═▐══█
113
- ──█══█═▐▓▓▓▓▓▓▄▄▄▄▄▄▄▓▓▓▓▓▓▌═█══█
114
- ──█══█═▐▓▓▓▓▓▓▐██▀██▌▓▓▓▓▓▓▌═█══█
115
- ──█══█═▐▓▓▓▓▓▓▓▀▀▀▀▀▓▓▓▓▓▓▓▌═█══█
116
- ──█══█▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓█══█
117
- ─▄█══█▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▌█══█▄
118
- ─█████▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▌─█████
119
- ─██████▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▌─██████
120
- ──▀█▀█──▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▌───█▀█▀
121
- ─────────▐▓▓▓▓▓▓▌▐▓▓▓▓▓▓▌
122
- ──────────▐▓▓▓▓▌──▐▓▓▓▓▌
123
- ─────────▄████▀────▀████▄
124
- ─────────▀▀▀▀────────▀▀▀▀
125
- =end
@@ -2,7 +2,7 @@ module ForemanSalt
2
2
  class SaltEnvironmentsController < ::ForemanSalt::ApplicationController
3
3
  include Foreman::Controller::AutoCompleteSearch
4
4
 
5
- before_filter :find_resource, :only => [:edit, :update, :destroy]
5
+ before_action :find_resource, :only => [:edit, :update, :destroy]
6
6
 
7
7
  def index
8
8
  @salt_environments = resource_base.search_for(params[:search], :order => params[:order]).paginate(:page => params[:page])
@@ -3,8 +3,8 @@ module ForemanSalt
3
3
  include Foreman::Controller::AutoCompleteSearch
4
4
  include StateImporter
5
5
 
6
- before_filter :find_resource, :only => [:edit, :update, :destroy]
7
- before_filter :find_proxy, :only => :import
6
+ before_action :find_resource, :only => [:edit, :update, :destroy]
7
+ before_action :find_proxy, :only => :import
8
8
 
9
9
  def index
10
10
  @salt_modules = resource_base.search_for(params[:search], :order => params[:order]).includes(:salt_environments).paginate(:page => params[:page])
@@ -70,7 +70,6 @@ module ForemanSalt
70
70
  def apply_changes
71
71
  if params[:changed].blank?
72
72
  notice _('No changes found')
73
- redirect_to salt_modules_path
74
73
  else
75
74
  params[:changed].each do |environment, states|
76
75
  next unless states[:add] || states[:remove]
@@ -81,8 +80,8 @@ module ForemanSalt
81
80
 
82
81
  clean_orphans
83
82
  notice _('Successfully imported')
84
- redirect_to salt_modules_path
85
83
  end
84
+ redirect_to salt_modules_path
86
85
  end
87
86
  end
88
87
  end
@@ -18,7 +18,7 @@ module ForemanSalt
18
18
 
19
19
  environments ||= new.keys + old.keys
20
20
 
21
- environments.each do |environment| # rubocop:disable Style/Next
21
+ environments.each do |environment|
22
22
  old_states = old[environment] || []
23
23
  new_states = new[environment] || []
24
24
 
@@ -93,7 +93,7 @@ module ForemanSalt
93
93
  key = ForemanSalt::SmartProxies::SaltKeys.find(salt_proxy, fqdn)
94
94
  key.accept unless key.nil?
95
95
  rescue Foreman::Exception => e
96
- Rails.logger.warn("Unable to accept key for #{fqdn}: #{e}")
96
+ Rails.logger.warn("Unable to accept key for #{fqdn}: #{e}")
97
97
  end
98
98
  end
99
99
 
@@ -102,7 +102,7 @@ module ForemanSalt
102
102
  key = ForemanSalt::SmartProxies::SaltKeys.find(salt_proxy, fqdn)
103
103
  key.delete unless key.nil?
104
104
  rescue Foreman::Exception => e
105
- Rails.logger.warn("Unable to delete key for #{fqdn}: #{e}")
105
+ Rails.logger.warn("Unable to delete key for #{fqdn}: #{e}")
106
106
  end
107
107
  end
108
108
  end
@@ -75,7 +75,7 @@ module ForemanSalt
75
75
  hash.each do |fact_name, value|
76
76
  name_parts = fact_name.split(FactName::SEPARATOR)
77
77
 
78
- name_parts.inject([]) do |memo, name| # rubocop:disable Style/EachWithObject
78
+ name_parts.inject([]) do |memo, name|
79
79
  memo += [name]
80
80
  key = memo.join(FactName::SEPARATOR)
81
81
  new_facts[key] ||= name_parts == memo ? value : nil
@@ -1,5 +1,5 @@
1
1
  module ForemanSalt
2
- class ReportImporter # rubocop:disable Metrics/ClassLength
2
+ class ReportImporter
3
3
  delegate :logger, :to => :Rails
4
4
  attr_reader :report
5
5
 
@@ -115,9 +115,7 @@ module ForemanSalt
115
115
  result['duration']
116
116
  end
117
117
  # Convert duration from milliseconds to seconds
118
- if duration.is_a? Float
119
- duration = duration / 1000
120
- end
118
+ duration /= 1000 if duration.is_a? Float
121
119
 
122
120
  time[resource] = duration || 0
123
121
  end
@@ -1,6 +1,6 @@
1
1
  <% title _('Autosign entries for %s') % @proxy %>
2
2
 
3
- <% title_actions display_link_if_authorized(_('Keys'), hash_for_smart_proxy_salt_keys_path), display_link_if_authorized(_('New'), {:controller => 'foreman_salt/salt_autosign', :action => 'new', :smart_proxy_id => @proxy, :auth_object => @proxy, :permission => 'create_smart_proxies_salt_keys'}) %>
3
+ <% title_actions display_link_if_authorized(_('Keys'), hash_for_smart_proxy_salt_keys_path, :class => 'btn btn-default'), display_link_if_authorized(_('New'), {:controller => 'foreman_salt/salt_autosign', :action => 'new', :smart_proxy_id => @proxy, :auth_object => @proxy, :permission => 'create_smart_proxies_salt_keys'}, :class => 'btn btn-primary') %>
4
4
 
5
5
  <table class='table table-bordered table-striped table-condensed'>
6
6
  <tr>
@@ -1,6 +1,6 @@
1
1
  <% title _('Salt Environments') %>
2
2
 
3
- <% title_actions button_group(display_link_if_authorized(_('New Salt Environment'), hash_for_new_salt_environment_path)) %>
3
+ <% title_actions button_group(new_link(_('New Salt Environment'))) %>
4
4
 
5
5
  <table class="table table-bordered table-striped">
6
6
  <tr>
@@ -1,7 +1,7 @@
1
1
  <% title _('Salt Keys on %s') % @proxy %>
2
2
  <% search_bar _('Filter %s') % salt_keys_state_filter %>
3
3
 
4
- <% title_actions display_link_if_authorized(_('Autosign'), hash_for_smart_proxy_salt_autosign_index_path) %>
4
+ <% title_actions display_link_if_authorized(_('Autosign'), hash_for_smart_proxy_salt_autosign_index_path, :class => 'btn btn-default') %>
5
5
 
6
6
  <table class='table table-bordered table-striped table-condensed'>
7
7
  <tr>
@@ -1,7 +1,7 @@
1
1
  <% title _('Salt States') %>
2
2
 
3
3
  <% title_actions import_from_proxies,
4
- button_group(display_link_if_authorized(_('New Salt State'), hash_for_new_salt_module_path)) %>
4
+ button_group(new_link(_('New Salt State'))) %>
5
5
 
6
6
 
7
7
  <table class="table table-bordered table-striped">
@@ -43,7 +43,7 @@ module ForemanSalt
43
43
  Apipie.configuration.checksum_path += ['/salt/api/']
44
44
  end
45
45
 
46
- initializer 'foreman_salt.register_plugin', :after => :finisher_hook do
46
+ initializer 'foreman_salt.register_plugin', :before => :finisher_hook do
47
47
  require 'foreman_salt/plugin'
48
48
  end
49
49
 
@@ -1,5 +1,5 @@
1
1
  Foreman::Plugin.register :foreman_salt do
2
- requires_foreman '>= 1.11'
2
+ requires_foreman '>= 1.12'
3
3
 
4
4
  apipie_documented_controllers ["#{ForemanSalt::Engine.root}/app/controllers/foreman_salt/api/v2/*.rb"]
5
5
 
@@ -1,3 +1,3 @@
1
1
  module ForemanSalt
2
- VERSION = '5.0.1'
2
+ VERSION = '6.0.0'
3
3
  end
@@ -22,16 +22,13 @@ namespace :test do
22
22
  t.libs << ['test', test_dir]
23
23
  t.pattern = "#{test_dir}/**/*_test.rb"
24
24
  t.verbose = true
25
+ t.warning = false
25
26
  end
26
27
  end
27
28
 
28
- Rake::Task[:test].enhance do
29
- Rake::Task['test:foreman_salt'].invoke
30
- end
29
+ Rake::Task[:test].enhance ['test:foreman_salt']
31
30
 
32
31
  load 'tasks/jenkins.rake'
33
32
  if Rake::Task.task_defined?(:'jenkins:unit')
34
- Rake::Task['jenkins:unit'].enhance do
35
- Rake::Task['test:foreman_salt'].invoke
36
- end
33
+ Rake::Task['jenkins:unit'].enhance ['test:foreman_salt', 'foreman_salt:rubocop']
37
34
  end
@@ -1,27 +1,25 @@
1
1
  require 'test_plugin_helper'
2
2
 
3
- module ForemanSalt
4
- class Api::V2::SaltAutosignControllerTest < ActionController::TestCase
5
- setup do
6
- @proxy = FactoryGirl.create(:smart_proxy, :with_salt_feature)
7
- ProxyAPI::Salt.any_instance.stubs(:autosign_list).returns((%w(foo bar baz)))
8
- end
3
+ class ::ForemanSalt::Api::V2::SaltAutosignControllerTest < ActionController::TestCase
4
+ setup do
5
+ @proxy = FactoryGirl.create(:smart_proxy, :with_salt_feature)
6
+ ProxyAPI::Salt.any_instance.stubs(:autosign_list).returns((%w(foo bar baz)))
7
+ end
9
8
 
10
- test 'should get index' do
11
- get :index, :smart_proxy_id => @proxy.id
12
- assert_response :success
13
- end
9
+ test 'should get index' do
10
+ get :index, :smart_proxy_id => @proxy.id
11
+ assert_response :success
12
+ end
14
13
 
15
- test 'should create autosign' do
16
- ProxyAPI::Salt.any_instance.expects(:autosign_create).once.returns(true)
17
- post :create, :smart_proxy_id => @proxy.id, :record => 'unicorn.example.com'
18
- assert_response :success
19
- end
14
+ test 'should create autosign' do
15
+ ProxyAPI::Salt.any_instance.expects(:autosign_create).once.returns(true)
16
+ post :create, :smart_proxy_id => @proxy.id, :record => 'unicorn.example.com'
17
+ assert_response :success
18
+ end
20
19
 
21
- test 'should delete autosign' do
22
- ProxyAPI::Salt.any_instance.expects(:autosign_remove).once.returns(true)
23
- delete :destroy, :smart_proxy_id => @proxy.id, :record => 'unicorn.example.com'
24
- assert_response :success
25
- end
20
+ test 'should delete autosign' do
21
+ ProxyAPI::Salt.any_instance.expects(:autosign_remove).once.returns(true)
22
+ delete :destroy, :smart_proxy_id => @proxy.id, :record => 'unicorn.example.com'
23
+ assert_response :success
26
24
  end
27
25
  end
@@ -1,33 +1,31 @@
1
1
  require 'test_plugin_helper'
2
2
 
3
- module ForemanSalt
4
- class Api::V2::SaltEnvironmentsControllerTest < ActionController::TestCase
5
- test 'should get index' do
6
- get :index, {}
7
- assert_response :success
8
- assert_template 'api/v2/salt_environments/index'
9
- end
3
+ class ::ForemanSalt::Api::V2::SaltEnvironmentsControllerTest < ActionController::TestCase
4
+ test 'should get index' do
5
+ get :index, {}
6
+ assert_response :success
7
+ assert_template 'api/v2/salt_environments/index'
8
+ end
10
9
 
11
- test 'should show environment' do
12
- environment = ForemanSalt::SaltEnvironment.create(:name => 'foo')
13
- get :show, :id => environment.id
14
- assert_response :success
15
- assert_template 'api/v2/salt_environments/show'
16
- end
10
+ test 'should show environment' do
11
+ environment = ForemanSalt::SaltEnvironment.create(:name => 'foo')
12
+ get :show, :id => environment.id
13
+ assert_response :success
14
+ assert_template 'api/v2/salt_environments/show'
15
+ end
17
16
 
18
- test 'should create environment' do
19
- post :create, :environment => { :name => 'unicorn' }
20
- assert_response :success
21
- assert ForemanSalt::SaltEnvironment.find_by_name('unicorn')
22
- assert_template 'api/v2/salt_environments/create'
23
- end
17
+ test 'should create environment' do
18
+ post :create, :environment => { :name => 'unicorn' }
19
+ assert_response :success
20
+ assert ForemanSalt::SaltEnvironment.find_by_name('unicorn')
21
+ assert_template 'api/v2/salt_environments/create'
22
+ end
24
23
 
25
- test 'should delete environment' do
26
- environment = ForemanSalt::SaltEnvironment.create(:name => 'foo.bar.baz')
27
- assert_difference('ForemanSalt::SaltEnvironment.count', -1) do
28
- delete :destroy, :id => environment.id
29
- end
30
- assert_response :success
24
+ test 'should delete environment' do
25
+ environment = ForemanSalt::SaltEnvironment.create(:name => 'foo.bar.baz')
26
+ assert_difference('ForemanSalt::SaltEnvironment.count', -1) do
27
+ delete :destroy, :id => environment.id
31
28
  end
29
+ assert_response :success
32
30
  end
33
31
  end
@@ -1,29 +1,27 @@
1
1
  require 'test_plugin_helper'
2
2
 
3
- module ForemanSalt
4
- class Api::V2::SaltKeysControllerTest < ActionController::TestCase
5
- setup do
6
- @proxy = FactoryGirl.create(:smart_proxy, :with_salt_feature)
3
+ class ::ForemanSalt::Api::V2::SaltKeysControllerTest < ActionController::TestCase
4
+ setup do
5
+ @proxy = FactoryGirl.create(:smart_proxy, :with_salt_feature)
7
6
 
8
- ProxyAPI::Salt.any_instance.stubs(:key_list).returns('saltstack.example.com' => { 'state' => 'unaccepted',
9
- 'fingerprint' => '98:c2:63:c1:57:59:bc:bd:f1:ef:5a:38:b2:e9:71:c0' })
10
- end
7
+ ProxyAPI::Salt.any_instance.stubs(:key_list).returns('saltstack.example.com' => { 'state' => 'unaccepted',
8
+ 'fingerprint' => '98:c2:63:c1:57:59:bc:bd:f1:ef:5a:38:b2:e9:71:c0' })
9
+ end
11
10
 
12
- test 'should get index' do
13
- get :index, :smart_proxy_id => @proxy.id
14
- assert_response :success
15
- end
11
+ test 'should get index' do
12
+ get :index, :smart_proxy_id => @proxy.id
13
+ assert_response :success
14
+ end
16
15
 
17
- test 'should update keys' do
18
- ProxyAPI::Salt.any_instance.expects(:key_accept).once.returns(true)
19
- put :update, :smart_proxy_id => @proxy.id, :name => 'saltstack.example.com', :key => { :state => 'accepted' }
20
- assert_response :success
21
- end
16
+ test 'should update keys' do
17
+ ProxyAPI::Salt.any_instance.expects(:key_accept).once.returns(true)
18
+ put :update, :smart_proxy_id => @proxy.id, :name => 'saltstack.example.com', :key => { :state => 'accepted' }
19
+ assert_response :success
20
+ end
22
21
 
23
- test 'should delete keys' do
24
- ProxyAPI::Salt.any_instance.expects(:key_delete).once.returns(true)
25
- delete :destroy, :smart_proxy_id => @proxy.id, :name => 'saltstack.example.com'
26
- assert_response :success
27
- end
22
+ test 'should delete keys' do
23
+ ProxyAPI::Salt.any_instance.expects(:key_delete).once.returns(true)
24
+ delete :destroy, :smart_proxy_id => @proxy.id, :name => 'saltstack.example.com'
25
+ assert_response :success
28
26
  end
29
27
  end
@@ -1,86 +1,84 @@
1
1
  require 'test_plugin_helper'
2
2
 
3
- module ForemanSalt
4
- class Api::V2::SaltStatesControllerTest < ActionController::TestCase
5
- test 'should get index' do
6
- get :index, {}
7
- assert_response :success
8
- assert_template 'api/v2/salt_states/index'
9
- end
3
+ class ::ForemanSalt::Api::V2::SaltStatesControllerTest < ActionController::TestCase
4
+ test 'should get index' do
5
+ get :index, {}
6
+ assert_response :success
7
+ assert_template 'api/v2/salt_states/index'
8
+ end
10
9
 
11
- test 'should show state' do
12
- state = ForemanSalt::SaltModule.create(:name => 'foo.bar.baz')
13
- get :show, :id => state.id
14
- assert_response :success
15
- assert_template 'api/v2/salt_states/show'
16
- end
10
+ test 'should show state' do
11
+ state = ForemanSalt::SaltModule.create(:name => 'foo.bar.baz')
12
+ get :show, :id => state.id
13
+ assert_response :success
14
+ assert_template 'api/v2/salt_states/show'
15
+ end
17
16
 
18
- test 'should create state' do
19
- post :create, :state => { :name => 'unicorn' }
20
- assert_response :success
21
- assert ForemanSalt::SaltModule.find_by_name('unicorn')
22
- assert_template 'api/v2/salt_states/create'
23
- end
17
+ test 'should create state' do
18
+ post :create, :state => { :name => 'unicorn' }
19
+ assert_response :success
20
+ assert ForemanSalt::SaltModule.find_by_name('unicorn')
21
+ assert_template 'api/v2/salt_states/create'
22
+ end
24
23
 
25
- test 'should delete state' do
26
- state = ForemanSalt::SaltModule.create(:name => 'foo.bar.baz')
27
- assert_difference('ForemanSalt::SaltModule.count', -1) do
28
- delete :destroy, :id => state.id
29
- end
30
- assert_response :success
24
+ test 'should delete state' do
25
+ state = ForemanSalt::SaltModule.create(:name => 'foo.bar.baz')
26
+ assert_difference('ForemanSalt::SaltModule.count', -1) do
27
+ delete :destroy, :id => state.id
31
28
  end
29
+ assert_response :success
30
+ end
32
31
 
33
- context 'importing' do
34
- setup do
35
- @proxy = FactoryGirl.create :smart_proxy, :with_salt_feature
36
- @states = { 'env1' => %w(state1 state2 state3),
37
- 'env2' => %w(state1 state2) }
32
+ context 'importing' do
33
+ setup do
34
+ @proxy = FactoryGirl.create :smart_proxy, :with_salt_feature
35
+ @states = { 'env1' => %w(state1 state2 state3),
36
+ 'env2' => %w(state1 state2) }
38
37
 
39
- ::ProxyAPI::Salt.any_instance.stubs(:states_list).returns(@states)
40
- end
38
+ ::ProxyAPI::Salt.any_instance.stubs(:states_list).returns(@states)
39
+ end
41
40
 
42
- test 'should import' do
43
- post :import, :smart_proxy_id => @proxy.id
41
+ test 'should import' do
42
+ post :import, :smart_proxy_id => @proxy.id
44
43
 
45
- assert_response :success
44
+ assert_response :success
46
45
 
47
- @states.each do |env, states|
48
- environment = ::ForemanSalt::SaltEnvironment.find_by_name(env)
49
- assert_empty environment.salt_modules.map(&:name) - states
50
- end
46
+ @states.each do |env, states|
47
+ environment = ::ForemanSalt::SaltEnvironment.find_by_name(env)
48
+ assert_empty environment.salt_modules.map(&:name) - states
51
49
  end
50
+ end
52
51
 
53
- test 'should import only from a given environment' do
54
- post :import, :smart_proxy_id => @proxy.id, :salt_environments => ['env2']
55
- assert_response :success
56
- refute ::ForemanSalt::SaltEnvironment.where(:name => 'env1').first
57
- assert ::ForemanSalt::SaltEnvironment.where(:name => 'env2').first
58
- end
52
+ test 'should import only from a given environment' do
53
+ post :import, :smart_proxy_id => @proxy.id, :salt_environments => ['env2']
54
+ assert_response :success
55
+ refute ::ForemanSalt::SaltEnvironment.where(:name => 'env1').first
56
+ assert ::ForemanSalt::SaltEnvironment.where(:name => 'env2').first
57
+ end
59
58
 
60
- test 'should limit actions to add' do
61
- env = FactoryGirl.create :salt_environment
62
- state = FactoryGirl.create :salt_module, :salt_environments => [env]
59
+ test 'should limit actions to add' do
60
+ env = FactoryGirl.create :salt_environment
61
+ state = FactoryGirl.create :salt_module, :salt_environments => [env]
63
62
 
64
- post :import, :smart_proxy_id => @proxy.id, :actions => ['add']
65
- assert_response :success
66
- assert ::ForemanSalt::SaltModule.where(:id => state).first
67
- assert ::ForemanSalt::SaltModule.where(:name => 'state1').first
68
- end
63
+ post :import, :smart_proxy_id => @proxy.id, :actions => ['add']
64
+ assert_response :success
65
+ assert ::ForemanSalt::SaltModule.where(:id => state).first
66
+ assert ::ForemanSalt::SaltModule.where(:name => 'state1').first
67
+ end
69
68
 
70
- test 'should limit actions to remove' do
71
- state = FactoryGirl.create :salt_module
72
- post :import, :smart_proxy_id => @proxy.id, :actions => ['remove']
73
- assert_response :success
74
- refute ::ForemanSalt::SaltModule.where(:id => state).first
75
- refute ::ForemanSalt::SaltModule.where(:name => 'state1').first
76
- end
69
+ test 'should limit actions to remove' do
70
+ state = FactoryGirl.create :salt_module
71
+ post :import, :smart_proxy_id => @proxy.id, :actions => ['remove']
72
+ assert_response :success
73
+ refute ::ForemanSalt::SaltModule.where(:id => state).first
74
+ refute ::ForemanSalt::SaltModule.where(:name => 'state1').first
75
+ end
77
76
 
78
- test 'dryrun should do nothing' do
79
- post :import, :smart_proxy_id => @proxy.id, :dryrun => true
80
- assert_response :success
81
- refute ::ForemanSalt::SaltModule.all.any?
82
- refute ::ForemanSalt::SaltEnvironment.all.any?
83
- end
77
+ test 'dryrun should do nothing' do
78
+ post :import, :smart_proxy_id => @proxy.id, :dryrun => true
79
+ assert_response :success
80
+ refute ::ForemanSalt::SaltModule.all.any?
81
+ refute ::ForemanSalt::SaltEnvironment.all.any?
84
82
  end
85
83
  end
86
84
  end
@@ -1,4 +1,5 @@
1
1
  require 'test_plugin_helper'
2
+ require 'integration_test_helper'
2
3
 
3
4
  module ForemanSalt
4
5
  class SaltKeysTest < ActionDispatch::IntegrationTest
@@ -1,9 +1,10 @@
1
1
  require 'test_plugin_helper'
2
+ require 'integration_test_helper'
2
3
 
3
4
  module ForemanSalt
4
5
  class SaltEnvironmentTest < ActionDispatch::IntegrationTest
5
6
  test 'index page' do
6
- FactoryGirl.create_list :salt_environment, 50
7
+ FactoryGirl.create_list :salt_environment, 5
7
8
  assert_index_page(salt_environments_path, 'Salt Environment', 'New Salt Environment')
8
9
  end
9
10
 
@@ -1,4 +1,5 @@
1
1
  require 'test_plugin_helper'
2
+ require 'integration_test_helper'
2
3
 
3
4
  module ForemanSalt
4
5
  class SaltKeysTest < ActionDispatch::IntegrationTest
@@ -1,4 +1,5 @@
1
1
  require 'test_plugin_helper'
2
+ require 'integration_test_helper'
2
3
 
3
4
  module ForemanSalt
4
5
  class SaltModuleTest < ActionDispatch::IntegrationTest
@@ -9,10 +9,8 @@ module ForemanSalt
9
9
  Operatingsystem.where(:name => 'CentOS', :major => '6', :minor => '5').delete_all
10
10
 
11
11
  grains = JSON.parse(File.read(File.join(Engine.root, 'test', 'unit', 'grains_centos.json')))
12
- host = grains['name']
13
- facts = HashWithIndifferentAccess.new(grains['facts'])
14
-
15
- (@imported_host, _) = ::Host::Managed.import_host_and_facts host, facts
12
+ @imported_host = ::Host::Managed.import_host grains['name'], 'salt'
13
+ @imported_host.import_facts grains['facts'].with_indifferent_access
16
14
  end
17
15
 
18
16
  test 'importing salt grains creates a host' do
@@ -54,7 +54,7 @@ module ForemanSalt
54
54
 
55
55
  context 'key handling' do
56
56
  before do
57
- @host = FactoryGirl.create(:host, :with_salt_proxy, :build => true)
57
+ @host = FactoryGirl.create(:host, :with_salt_proxy, :managed, :build => true)
58
58
  @key_stub = stub("key")
59
59
  ForemanSalt::SmartProxies::SaltKeys.expects(:find).at_least_once.with(@host.salt_proxy, @host.fqdn).returns(@key_stub)
60
60
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman_salt
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.1
4
+ version: 6.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen Benjamin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-27 00:00:00.000000000 Z
11
+ date: 2016-07-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: deface
@@ -162,7 +162,7 @@ files:
162
162
  - test/unit/salt_modules_test.rb
163
163
  homepage: http://github.com/theforeman/foreman_salt
164
164
  licenses:
165
- - GPL-3
165
+ - GPL-3.0
166
166
  metadata: {}
167
167
  post_install_message:
168
168
  rdoc_options: []
@@ -185,22 +185,22 @@ signing_key:
185
185
  specification_version: 4
186
186
  summary: Foreman Plug-in for Salt
187
187
  test_files:
188
- - test/factories/foreman_salt_factories.rb
189
- - test/functional/api/v2/salt_autosign_controller_test.rb
190
- - test/functional/api/v2/salt_environments_controller_test.rb
191
- - test/functional/api/v2/salt_keys_controller_test.rb
192
- - test/functional/api/v2/salt_states_controller_test.rb
193
- - test/functional/minions_controller_test.rb
194
- - test/integration/salt_autosign_test.rb
188
+ - test/integration/salt_module_test.rb
195
189
  - test/integration/salt_environment_test.rb
190
+ - test/integration/salt_autosign_test.rb
196
191
  - test/integration/salt_keys_test.rb
197
- - test/integration/salt_module_test.rb
198
- - test/unit/grains_centos.json
192
+ - test/test_plugin_helper.rb
199
193
  - test/unit/grains_importer_test.rb
200
- - test/unit/highstate.json
201
- - test/unit/salt_keys_test.rb
202
- - test/unit/salt_modules_test.rb
194
+ - test/unit/grains_centos.json
203
195
  - test/unit/host_extensions_test.rb
204
- - test/unit/hostgroup_extensions_test.rb
205
196
  - test/unit/report_importer_test.rb
206
- - test/test_plugin_helper.rb
197
+ - test/unit/hostgroup_extensions_test.rb
198
+ - test/unit/salt_modules_test.rb
199
+ - test/unit/highstate.json
200
+ - test/unit/salt_keys_test.rb
201
+ - test/functional/minions_controller_test.rb
202
+ - test/functional/api/v2/salt_autosign_controller_test.rb
203
+ - test/functional/api/v2/salt_states_controller_test.rb
204
+ - test/functional/api/v2/salt_keys_controller_test.rb
205
+ - test/functional/api/v2/salt_environments_controller_test.rb
206
+ - test/factories/foreman_salt_factories.rb