foreman_salt 5.0.1 → 6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/controllers/foreman_salt/api/v2/salt_autosign_controller.rb +1 -1
- data/app/controllers/foreman_salt/api/v2/salt_environments_controller.rb +1 -1
- data/app/controllers/foreman_salt/api/v2/salt_keys_controller.rb +2 -2
- data/app/controllers/foreman_salt/api/v2/salt_minions_controller.rb +1 -1
- data/app/controllers/foreman_salt/api/v2/salt_states_controller.rb +3 -3
- data/app/controllers/foreman_salt/minions_controller.rb +1 -40
- data/app/controllers/foreman_salt/salt_environments_controller.rb +1 -1
- data/app/controllers/foreman_salt/salt_modules_controller.rb +3 -4
- data/app/controllers/foreman_salt/state_importer.rb +1 -1
- data/app/models/foreman_salt/concerns/host_managed_extensions.rb +2 -2
- data/app/services/foreman_salt/fact_importer.rb +1 -1
- data/app/services/foreman_salt/report_importer.rb +2 -4
- data/app/views/foreman_salt/salt_autosign/index.html.erb +1 -1
- data/app/views/foreman_salt/salt_environments/index.html.erb +1 -1
- data/app/views/foreman_salt/salt_keys/index.erb +1 -1
- data/app/views/foreman_salt/salt_modules/index.html.erb +1 -1
- data/lib/foreman_salt/engine.rb +1 -1
- data/lib/foreman_salt/plugin.rb +1 -1
- data/lib/foreman_salt/version.rb +1 -1
- data/lib/tasks/foreman_salt_tasks.rake +3 -6
- data/test/functional/api/v2/salt_autosign_controller_test.rb +18 -20
- data/test/functional/api/v2/salt_environments_controller_test.rb +23 -25
- data/test/functional/api/v2/salt_keys_controller_test.rb +19 -21
- data/test/functional/api/v2/salt_states_controller_test.rb +64 -66
- data/test/integration/salt_autosign_test.rb +1 -0
- data/test/integration/salt_environment_test.rb +2 -1
- data/test/integration/salt_keys_test.rb +1 -0
- data/test/integration/salt_module_test.rb +1 -0
- data/test/unit/grains_importer_test.rb +2 -4
- data/test/unit/host_extensions_test.rb +1 -1
- metadata +17 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: feb89e35b3867722b4e8be153d07aa9d726c39bb
|
4
|
+
data.tar.gz: c0cc7b621377daf0d949ce033c3e79d521fb3652
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
|
-
|
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
|
-
|
6
|
-
|
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
|
-
|
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
|
-
|
8
|
-
|
9
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
7
|
-
|
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
|
@@ -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
|
-
|
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
|
-
|
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|
|
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
|
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(
|
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(
|
4
|
+
button_group(new_link(_('New Salt State'))) %>
|
5
5
|
|
6
6
|
|
7
7
|
<table class="table table-bordered table-striped">
|
data/lib/foreman_salt/engine.rb
CHANGED
@@ -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', :
|
46
|
+
initializer 'foreman_salt.register_plugin', :before => :finisher_hook do
|
47
47
|
require 'foreman_salt/plugin'
|
48
48
|
end
|
49
49
|
|
data/lib/foreman_salt/plugin.rb
CHANGED
data/lib/foreman_salt/version.rb
CHANGED
@@ -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
|
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
|
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
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
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
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
9
|
+
test 'should get index' do
|
10
|
+
get :index, :smart_proxy_id => @proxy.id
|
11
|
+
assert_response :success
|
12
|
+
end
|
14
13
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
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
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
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
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
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
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
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
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
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
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
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
|
-
|
4
|
-
|
5
|
-
|
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
|
-
|
9
|
-
|
10
|
-
|
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
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
11
|
+
test 'should get index' do
|
12
|
+
get :index, :smart_proxy_id => @proxy.id
|
13
|
+
assert_response :success
|
14
|
+
end
|
16
15
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
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
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
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
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
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
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
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
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
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
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
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
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
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
|
-
|
40
|
-
|
38
|
+
::ProxyAPI::Salt.any_instance.stubs(:states_list).returns(@states)
|
39
|
+
end
|
41
40
|
|
42
|
-
|
43
|
-
|
41
|
+
test 'should import' do
|
42
|
+
post :import, :smart_proxy_id => @proxy.id
|
44
43
|
|
45
|
-
|
44
|
+
assert_response :success
|
46
45
|
|
47
|
-
|
48
|
-
|
49
|
-
|
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
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
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
|
-
|
61
|
-
|
62
|
-
|
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
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
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
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
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
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
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,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,
|
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
|
|
@@ -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
|
-
|
13
|
-
|
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:
|
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-
|
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/
|
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/
|
198
|
-
- test/unit/grains_centos.json
|
192
|
+
- test/test_plugin_helper.rb
|
199
193
|
- test/unit/grains_importer_test.rb
|
200
|
-
- test/unit/
|
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/
|
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
|