foreman_salt 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -8
- data/Rakefile +1 -1
- data/app/controllers/foreman_salt/api/v2/jobs_controller.rb +4 -4
- data/app/controllers/foreman_salt/concerns/hosts_controller_extensions.rb +4 -4
- data/app/controllers/foreman_salt/concerns/smart_proxy_auth_extensions.rb +2 -2
- data/app/controllers/foreman_salt/concerns/unattended_controller_extensions.rb +1 -1
- data/app/controllers/foreman_salt/salt_environments_controller.rb +1 -1
- data/app/controllers/foreman_salt/salt_keys_controller.rb +4 -4
- data/app/controllers/foreman_salt/salt_modules_controller.rb +1 -1
- data/app/helpers/concerns/foreman_salt/hosts_helper_extensions.rb +4 -4
- data/app/helpers/concerns/foreman_salt/smart_proxies_helper_extensions.rb +2 -2
- data/app/helpers/foreman_salt/salt_keys_helper.rb +1 -1
- data/app/lib/proxy_api/salt.rb +21 -21
- data/app/models/foreman_salt/concerns/host_managed_extensions.rb +7 -7
- data/app/models/foreman_salt/concerns/hostgroup_extensions.rb +5 -5
- data/app/models/foreman_salt/concerns/orchestration/salt.rb +12 -12
- data/app/models/foreman_salt/salt_environment.rb +4 -4
- data/app/models/foreman_salt/salt_module.rb +4 -4
- data/app/overrides/foreman/salt_modules/_host_tab_pane.html.erb +2 -2
- data/app/overrides/salt_environment_selector.rb +4 -4
- data/app/overrides/salt_modules_selector.rb +9 -9
- data/app/overrides/salt_proxy_selector.rb +4 -4
- data/app/services/foreman_salt/fact_importer.rb +5 -5
- data/app/services/foreman_salt/report_importer.rb +14 -14
- data/app/services/foreman_salt/smart_proxies/salt_keys.rb +6 -6
- data/app/views/foreman_salt/salt_autosign/_form.html.erb +1 -1
- data/app/views/foreman_salt/salt_autosign/index.html.erb +3 -3
- data/app/views/foreman_salt/salt_autosign/new.html.erb +1 -1
- data/app/views/foreman_salt/salt_environments/edit.html.erb +1 -1
- data/app/views/foreman_salt/salt_environments/index.html.erb +4 -4
- data/app/views/foreman_salt/salt_environments/new.html.erb +1 -1
- data/app/views/foreman_salt/salt_keys/index.erb +9 -9
- data/app/views/foreman_salt/salt_modules/edit.html.erb +1 -1
- data/app/views/foreman_salt/salt_modules/index.html.erb +4 -4
- data/app/views/foreman_salt/salt_modules/new.html.erb +1 -1
- data/config/routes.rb +1 -1
- data/db/migrate/20140817210214_create_salt_modules.rb +1 -1
- data/db/migrate/20140920232200_create_salt_environments.rb +1 -1
- data/db/seeds.d/75-salt-seeds.rb +1 -1
- data/lib/foreman_salt/engine.rb +20 -20
- data/lib/foreman_salt/version.rb +1 -1
- data/lib/foreman_salt.rb +1 -1
- data/lib/tasks/foreman_salt_tasks.rake +16 -9
- data/test/factories/foreman_salt_factories.rb +2 -2
- data/test/functional/hosts_controller_test.rb +1 -1
- data/test/integration/salt_autosign_test.rb +8 -8
- data/test/integration/salt_environment_test.rb +7 -7
- data/test/integration/salt_keys_test.rb +17 -17
- data/test/integration/salt_module_test.rb +8 -8
- data/test/test_plugin_helper.rb +1 -1
- data/test/unit/grains_importer_test.rb +9 -9
- data/test/unit/host_extensions_test.rb +7 -7
- data/test/unit/hostgroup_extensions_test.rb +7 -7
- data/test/unit/report_importer_test.rb +1 -1
- data/test/unit/salt_keys_test.rb +13 -13
- data/test/unit/salt_modules_test.rb +5 -5
- metadata +58 -58
@@ -57,22 +57,22 @@ module ForemanSalt
|
|
57
57
|
def import_log_messages
|
58
58
|
@raw.each do |resource, result|
|
59
59
|
level = if result['changes'].blank? && result['result']
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
60
|
+
:info
|
61
|
+
elsif !result['result']
|
62
|
+
:err
|
63
|
+
else
|
64
|
+
:notice
|
65
|
+
end
|
66
66
|
|
67
67
|
source = Source.find_or_create(resource)
|
68
68
|
|
69
69
|
message = if result['changes']['diff']
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
70
|
+
result['changes']['diff']
|
71
|
+
elsif !result['comment'].blank?
|
72
|
+
result['comment']
|
73
|
+
else
|
74
|
+
'No message available'
|
75
|
+
end
|
76
76
|
|
77
77
|
message = Message.find_or_create(message)
|
78
78
|
Log.create(:message_id => message.id, :source_id => source.id, :report => @report, :level => level)
|
@@ -91,14 +91,14 @@ module ForemanSalt
|
|
91
91
|
@raw.each do |resource, result|
|
92
92
|
next unless result.is_a? Hash
|
93
93
|
|
94
|
-
if result['result']
|
94
|
+
if result['result']
|
95
95
|
success += 1
|
96
96
|
if resource.match(/^service_/) && result['comment'].include?('restarted')
|
97
97
|
restarted += 1
|
98
98
|
elsif !result['changes'].blank?
|
99
99
|
changed += 1
|
100
100
|
end
|
101
|
-
elsif result['result']
|
101
|
+
elsif !result['result']
|
102
102
|
if resource.match(/^service_/) && result['comment'].include?('restarted')
|
103
103
|
restarted_failed += 1
|
104
104
|
else
|
@@ -3,14 +3,14 @@ module ForemanSalt
|
|
3
3
|
|
4
4
|
attr_reader :name, :state, :fingerprint, :smart_proxy_id
|
5
5
|
|
6
|
-
def initialize
|
6
|
+
def initialize(opts)
|
7
7
|
@name, @state, @fingerprint, @smart_proxy_id = opts.flatten
|
8
8
|
end
|
9
9
|
|
10
10
|
class << self
|
11
11
|
|
12
12
|
def all(proxy)
|
13
|
-
raise ::Foreman::Exception.new(N_(
|
13
|
+
raise ::Foreman::Exception.new(N_('Must specify a Smart Proxy to use')) if proxy.nil?
|
14
14
|
|
15
15
|
unless (keys = Rails.cache.read("saltkeys_#{proxy.id}"))
|
16
16
|
api = ProxyAPI::Salt.new({:url => proxy.url})
|
@@ -33,14 +33,14 @@ module ForemanSalt
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def accept
|
36
|
-
raise ::Foreman::Exception.new(N_(
|
36
|
+
raise ::Foreman::Exception.new(N_('unable to re-accept an accepted key')) unless state == 'unaccepted'
|
37
37
|
proxy = SmartProxy.find(smart_proxy_id)
|
38
38
|
Rails.cache.delete("saltkeys_#{proxy.id}") if Rails.env.production?
|
39
39
|
ProxyAPI::Salt.new({:url => proxy.url}).key_accept name
|
40
40
|
end
|
41
41
|
|
42
42
|
def reject
|
43
|
-
raise ::Foreman::Exception.new(N_(
|
43
|
+
raise ::Foreman::Exception.new(N_('unable to reject an accepted key')) unless state == 'unaccepted'
|
44
44
|
proxy = SmartProxy.find(smart_proxy_id)
|
45
45
|
Rails.cache.delete("saltkeys_#{proxy.id}") if Rails.env.production?
|
46
46
|
ProxyAPI::Salt.new({:url => proxy.url}).key_reject name
|
@@ -56,12 +56,12 @@ module ForemanSalt
|
|
56
56
|
def to_param
|
57
57
|
name
|
58
58
|
end
|
59
|
-
|
59
|
+
|
60
60
|
def to_s
|
61
61
|
name
|
62
62
|
end
|
63
63
|
|
64
|
-
def <=>
|
64
|
+
def <=>(other)
|
65
65
|
self.name <=> other.name
|
66
66
|
end
|
67
67
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
<%= form_tag url_for(:controller => 'foreman_salt/salt_autosign', :smart_proxy_id => @proxy, :action => 'index') do |f| %>
|
2
2
|
<div class="clearfix">
|
3
3
|
<div class="input">
|
4
|
-
<%= label_tag(_(
|
4
|
+
<%= label_tag(_('Name')) %> <%= text_field_tag(:id, '', :size => 60) %> <%= submit_tag _('Save'), :class => 'btn btn-success' %>
|
5
5
|
</div>
|
6
6
|
</div>
|
7
7
|
<% end %>
|
@@ -1,10 +1,10 @@
|
|
1
|
-
<% title _(
|
1
|
+
<% title _('Autosign entries for %s') % @proxy %>
|
2
2
|
|
3
|
-
<% title_actions display_link_if_authorized(_(
|
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'}) %>
|
4
4
|
|
5
5
|
<table class='table table-bordered table-striped table-condensed'>
|
6
6
|
<tr>
|
7
|
-
<th><%= _(
|
7
|
+
<th><%= _('Name') %></th>
|
8
8
|
<th></th>
|
9
9
|
</tr>
|
10
10
|
<% @autosign.each do |key| %>
|
@@ -1,10 +1,10 @@
|
|
1
|
-
<% title _(
|
1
|
+
<% title _('Salt Environments') %>
|
2
2
|
|
3
|
-
<% title_actions button_group(display_link_if_authorized(_(
|
3
|
+
<% title_actions button_group(display_link_if_authorized(_('New Salt Environment'), hash_for_new_salt_environment_path)) %>
|
4
4
|
|
5
5
|
<table class="table table-bordered table-striped">
|
6
6
|
<tr>
|
7
|
-
<th><%= sort :name, :as => s_(
|
7
|
+
<th><%= sort :name, :as => s_('SaltEnvironment|Name') %></th>
|
8
8
|
<th></th>
|
9
9
|
</tr>
|
10
10
|
<% for salt_environment in @salt_environments %>
|
@@ -12,7 +12,7 @@
|
|
12
12
|
<td><%=link_to_if_authorized h(salt_environment.name), hash_for_edit_salt_environment_path(:id => salt_environment).merge(:auth_object => salt_environment, :authorizer => authorizer) %></td>
|
13
13
|
<td>
|
14
14
|
<%= action_buttons(display_delete_if_authorized hash_for_salt_environment_path(:id => salt_environment).merge(:auth_object => salt_environment, :authorizer => authorizer),
|
15
|
-
:confirm => _(
|
15
|
+
:confirm => _('Delete %s?') % salt_environment.name) %>
|
16
16
|
</td>
|
17
17
|
</tr>
|
18
18
|
<% end %>
|
@@ -1,13 +1,13 @@
|
|
1
|
-
<% title _(
|
2
|
-
<% search_bar _(
|
1
|
+
<% title _('Salt Keys on %s') % @proxy %>
|
2
|
+
<% search_bar _('Filter %s') % salt_keys_state_filter %>
|
3
3
|
|
4
|
-
<% title_actions display_link_if_authorized(_(
|
4
|
+
<% title_actions display_link_if_authorized(_('Autosign'), hash_for_smart_proxy_salt_autosign_index_path) %>
|
5
5
|
|
6
6
|
<table class='table table-bordered table-striped table-condensed'>
|
7
7
|
<tr>
|
8
|
-
<th><%= _(
|
9
|
-
<th><%= _(
|
10
|
-
<th><%= _(
|
8
|
+
<th><%= _('Key Name') %></th>
|
9
|
+
<th><%= _('State') %></th>
|
10
|
+
<th><%= _('Fingerprint') %></th>
|
11
11
|
<th></th>
|
12
12
|
</tr>
|
13
13
|
<% @keys.each do |key| %>
|
@@ -17,9 +17,9 @@
|
|
17
17
|
<td><%= key.fingerprint %></td>
|
18
18
|
<td>
|
19
19
|
<%= action_buttons(
|
20
|
-
if key.state ==
|
21
|
-
[display_link_if_authorized(_(
|
22
|
-
display_link_if_authorized(_(
|
20
|
+
if key.state == 'unaccepted'
|
21
|
+
[display_link_if_authorized(_('Accept'), hash_for_smart_proxy_salt_key_accept_path.merge(:state => params[:state], :salt_key_id => key)),
|
22
|
+
display_link_if_authorized(_('Reject'), hash_for_smart_proxy_salt_key_reject_path.merge(:state => params[:state], :salt_key_id => key))]
|
23
23
|
end,
|
24
24
|
display_delete_if_authorized(hash_for_smart_proxy_salt_key_path(:smart_proxy_id => @proxy, :id => key, :state => params[:state], :class => 'delete'))
|
25
25
|
)
|
@@ -1,10 +1,10 @@
|
|
1
|
-
<% title _(
|
1
|
+
<% title _('Salt States') %>
|
2
2
|
|
3
|
-
<% title_actions button_group(display_link_if_authorized(_(
|
3
|
+
<% title_actions button_group(display_link_if_authorized(_('New Salt State'), hash_for_new_salt_module_path)) %>
|
4
4
|
|
5
5
|
<table class="table table-bordered table-striped">
|
6
6
|
<tr>
|
7
|
-
<th><%= sort :name, :as => s_(
|
7
|
+
<th><%= sort :name, :as => s_('SaltModule|Name') %></th>
|
8
8
|
<th></th>
|
9
9
|
</tr>
|
10
10
|
<% for salt_module in @salt_modules %>
|
@@ -12,7 +12,7 @@
|
|
12
12
|
<td><%=link_to_if_authorized h(salt_module.name), hash_for_edit_salt_module_path(:id => salt_module).merge(:auth_object => salt_module, :authorizer => authorizer) %></td>
|
13
13
|
<td>
|
14
14
|
<%= action_buttons(display_delete_if_authorized hash_for_salt_module_path(:id => salt_module).merge(:auth_object => salt_module, :authorizer => authorizer),
|
15
|
-
:confirm => _(
|
15
|
+
:confirm => _('Delete %s?') % salt_module.name) %>
|
16
16
|
</td>
|
17
17
|
</tr>
|
18
18
|
<% end %>
|
data/config/routes.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Rails.application.routes.draw do
|
2
2
|
|
3
3
|
scope :salt, :path => '/salt' do
|
4
|
-
match
|
4
|
+
match '/node/:name' => 'hosts#salt_external_node', :constraints => { :name => /[^\.][\w\.-]+/ }
|
5
5
|
|
6
6
|
resources :salt_environments, :controller => 'foreman_salt/salt_environments' do
|
7
7
|
collection do
|
data/db/seeds.d/75-salt-seeds.rb
CHANGED
data/lib/foreman_salt/engine.rb
CHANGED
@@ -11,13 +11,13 @@ module ForemanSalt
|
|
11
11
|
config.autoload_paths += Dir["#{config.root}/app/lib"]
|
12
12
|
|
13
13
|
if defined? ForemanTasks
|
14
|
-
initializer
|
14
|
+
initializer 'foreman_salt.require_dynflow', :before => 'foreman_tasks.initialize_dynflow' do |app|
|
15
15
|
ForemanTasks.dynflow.require!
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
19
|
# Add any db migrations
|
20
|
-
initializer
|
20
|
+
initializer 'foreman_salt.load_app_instance_data' do |app|
|
21
21
|
app.config.paths['db/migrate'] += ForemanSalt::Engine.paths['db/migrate'].existent
|
22
22
|
end
|
23
23
|
|
@@ -38,7 +38,7 @@ module ForemanSalt
|
|
38
38
|
:after => :common_parameters
|
39
39
|
|
40
40
|
divider :top_menu, :parent => :configure_menu,
|
41
|
-
:caption =>
|
41
|
+
:caption => 'Salt',
|
42
42
|
:after => :common_parameters
|
43
43
|
|
44
44
|
security_block :hosts do |map|
|
@@ -47,36 +47,36 @@ module ForemanSalt
|
|
47
47
|
end
|
48
48
|
|
49
49
|
security_block :salt_environments do |map|
|
50
|
-
permission :create_salt_environments, {:'foreman_salt/salt_environments' => [:new, :create]}, :resource_type =>
|
51
|
-
permission :view_salt_environments, {:'foreman_salt/salt_environments' => [:index, :show, :auto_complete_search]}, :resource_type =>
|
52
|
-
permission :edit_salt_environments, {:'foreman_salt/salt_environments' => [:update, :edit]},:resource_type =>
|
53
|
-
permission :destroy_salt_environments, {:'foreman_salt/salt_environments' => [:destroy]}, :resource_type =>
|
50
|
+
permission :create_salt_environments, {:'foreman_salt/salt_environments' => [:new, :create]}, :resource_type => 'ForemanSalt::SaltEnvironment'
|
51
|
+
permission :view_salt_environments, {:'foreman_salt/salt_environments' => [:index, :show, :auto_complete_search]}, :resource_type => 'ForemanSalt::SaltEnvironment'
|
52
|
+
permission :edit_salt_environments, {:'foreman_salt/salt_environments' => [:update, :edit]},:resource_type => 'ForemanSalt::SaltEnvironment'
|
53
|
+
permission :destroy_salt_environments, {:'foreman_salt/salt_environments' => [:destroy]}, :resource_type => 'ForemanSalt::SaltEnvironment'
|
54
54
|
end
|
55
55
|
|
56
56
|
security_block :salt_modules do |map|
|
57
|
-
permission :create_salt_modules, {:'foreman_salt/salt_modules' => [:new, :create]}, :resource_type =>
|
58
|
-
permission :view_salt_modules, {:'foreman_salt/salt_modules' => [:index, :show, :auto_complete_search]}, :resource_type =>
|
59
|
-
permission :edit_salt_modules, {:'foreman_salt/salt_modules' => [:update, :edit]},:resource_type =>
|
60
|
-
permission :destroy_salt_modules, {:'foreman_salt/salt_modules' => [:destroy]}, :resource_type =>
|
57
|
+
permission :create_salt_modules, {:'foreman_salt/salt_modules' => [:new, :create]}, :resource_type => 'ForemanSalt::SaltModule'
|
58
|
+
permission :view_salt_modules, {:'foreman_salt/salt_modules' => [:index, :show, :auto_complete_search]}, :resource_type => 'ForemanSalt::SaltModule'
|
59
|
+
permission :edit_salt_modules, {:'foreman_salt/salt_modules' => [:update, :edit]},:resource_type => 'ForemanSalt::SaltModule'
|
60
|
+
permission :destroy_salt_modules, {:'foreman_salt/salt_modules' => [:destroy]}, :resource_type => 'ForemanSalt::SaltModule'
|
61
61
|
end
|
62
62
|
|
63
63
|
security_block :salt_keys do |map|
|
64
|
-
permission :view_smart_proxies_salt_keys, {:'foreman_salt/salt_keys' => [:index]}, :resource_type =>
|
65
|
-
permission :destroy_smart_proxies_salt_keys, {:'foreman_salt/salt_keys' => [:destroy]},:resource_type =>
|
66
|
-
permission :edit_smart_proxies_salt_keys, {:'foreman_salt/salt_keys' => [:accept, :reject]}, :resource_type =>
|
64
|
+
permission :view_smart_proxies_salt_keys, {:'foreman_salt/salt_keys' => [:index]}, :resource_type => 'SmartProxy'
|
65
|
+
permission :destroy_smart_proxies_salt_keys, {:'foreman_salt/salt_keys' => [:destroy]},:resource_type => 'SmartProxy'
|
66
|
+
permission :edit_smart_proxies_salt_keys, {:'foreman_salt/salt_keys' => [:accept, :reject]}, :resource_type => 'SmartProxy'
|
67
67
|
end
|
68
68
|
|
69
69
|
security_block :salt_autosign do |map|
|
70
|
-
permission :destroy_smart_proxies_salt_autosign, {:'foreman_salt/salt_autosign' => [:destroy]}, :resource_type =>
|
71
|
-
permission :create_smart_proxies_salt_autosign, {:'foreman_salt/salt_autosign' => [:new, :create]}, :resource_type =>
|
72
|
-
permission :view_smart_proxies_salt_autosign, {:'foreman_salt/salt_autosign' => [:index]}, :resource_type =>
|
70
|
+
permission :destroy_smart_proxies_salt_autosign, {:'foreman_salt/salt_autosign' => [:destroy]}, :resource_type => 'SmartProxy'
|
71
|
+
permission :create_smart_proxies_salt_autosign, {:'foreman_salt/salt_autosign' => [:new, :create]}, :resource_type => 'SmartProxy'
|
72
|
+
permission :view_smart_proxies_salt_autosign, {:'foreman_salt/salt_autosign' => [:index]}, :resource_type => 'SmartProxy'
|
73
73
|
end
|
74
74
|
|
75
75
|
security_block :api do |map|
|
76
|
-
permission :create_reports, {:'foreman_salt/api/v2/jobs' => [:upload]}, :resource_type =>
|
76
|
+
permission :create_reports, {:'foreman_salt/api/v2/jobs' => [:upload]}, :resource_type => 'Report'
|
77
77
|
end
|
78
78
|
|
79
|
-
role
|
79
|
+
role 'Salt admin', [:saltrun_hosts, :create_salt_modules, :view_salt_modules, :edit_salt_modules, :destroy_salt_modules,
|
80
80
|
:view_smart_proxies_salt_keys, :destroy_smart_proxies_salt_keys, :edit_smart_proxies_salt_keys,
|
81
81
|
:create_smart_proxies_salt_autosign, :view_smart_proxies_salt_autosign, :destroy_smart_proxies_salt_autosign,
|
82
82
|
:create_salt_environments, :view_salt_environments, :edit_salt_environments, :destroy_salt_environments]
|
@@ -107,7 +107,7 @@ module ForemanSalt
|
|
107
107
|
::Api::V2::HostsController.send :include, ForemanSalt::Concerns::SmartProxyAuthExtensions
|
108
108
|
::Api::V2::ReportsController.send :include, ForemanSalt::Concerns::SmartProxyAuthExtensions
|
109
109
|
rescue => e
|
110
|
-
puts "ForemanSalt: skipping engine hook (#{e
|
110
|
+
puts "ForemanSalt: skipping engine hook (#{e})"
|
111
111
|
end
|
112
112
|
end
|
113
113
|
end
|
data/lib/foreman_salt/version.rb
CHANGED
data/lib/foreman_salt.rb
CHANGED
@@ -1,19 +1,25 @@
|
|
1
|
-
# Tasks
|
2
1
|
namespace :foreman_salt do
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
2
|
+
task :rubocop do
|
3
|
+
begin
|
4
|
+
require 'rubocop/rake_task'
|
5
|
+
RuboCop::RakeTask.new(:rubocop_salt) do |task|
|
6
|
+
task.patterns = ["#{ForemanSalt::Engine.root}/app/**/*.rb",
|
7
|
+
"#{ForemanSalt::Engine.root}/lib/**/*.rb",
|
8
|
+
"#{ForemanSalt::Engine.root}/test/**/*.rb"]
|
9
|
+
end
|
10
|
+
rescue
|
11
|
+
puts "Rubocop not loaded."
|
7
12
|
end
|
13
|
+
|
14
|
+
Rake::Task['rubocop_salt'].invoke
|
8
15
|
end
|
9
16
|
end
|
10
17
|
|
11
|
-
# Tests
|
12
18
|
namespace :test do
|
13
|
-
desc
|
19
|
+
desc 'Test ForemanSalt'
|
14
20
|
Rake::TestTask.new(:foreman_salt) do |t|
|
15
21
|
test_dir = File.join(File.dirname(__FILE__), '../..', 'test')
|
16
|
-
t.libs << [
|
22
|
+
t.libs << ['test',test_dir]
|
17
23
|
t.pattern = "#{test_dir}/**/*_test.rb"
|
18
24
|
t.verbose = true
|
19
25
|
end
|
@@ -25,7 +31,8 @@ end
|
|
25
31
|
|
26
32
|
load 'tasks/jenkins.rake'
|
27
33
|
if Rake::Task.task_defined?(:'jenkins:unit')
|
28
|
-
Rake::Task[
|
34
|
+
Rake::Task['jenkins:unit'].enhance do
|
29
35
|
Rake::Task['test:foreman_salt'].invoke
|
36
|
+
Rake::Task['foreman_salt:rubocop'].invoke
|
30
37
|
end
|
31
38
|
end
|
@@ -1,9 +1,9 @@
|
|
1
1
|
FactoryGirl.define do
|
2
|
-
factory :salt_module, :class =>
|
2
|
+
factory :salt_module, :class => 'ForemanSalt::SaltModule' do
|
3
3
|
sequence(:name) { |n| "module#{n}" }
|
4
4
|
end
|
5
5
|
|
6
|
-
factory :salt_environment, :class =>
|
6
|
+
factory :salt_environment, :class => 'ForemanSalt::SaltEnvironment' do
|
7
7
|
sequence(:name) { |n| "module#{n}" }
|
8
8
|
end
|
9
9
|
end
|
@@ -10,7 +10,7 @@ class HostsControllerTest < ActionController::TestCase
|
|
10
10
|
Resolv.any_instance.stubs(:getnames).returns([proxy.to_s])
|
11
11
|
|
12
12
|
host = FactoryGirl.create :host
|
13
|
-
get :salt_external_node, {:name => host.name, :format =>
|
13
|
+
get :salt_external_node, {:name => host.name, :format => 'yml'}
|
14
14
|
assert_response :success
|
15
15
|
end
|
16
16
|
end
|
@@ -10,20 +10,20 @@ module ForemanSalt
|
|
10
10
|
)
|
11
11
|
end
|
12
12
|
|
13
|
-
test
|
14
|
-
assert_row_button(smart_proxies_path, @proxy.name, 'Salt Autosign',
|
13
|
+
test 'smart proxy page has autosign link' do
|
14
|
+
assert_row_button(smart_proxies_path, @proxy.name, 'Salt Autosign', true)
|
15
15
|
end
|
16
16
|
|
17
|
-
test
|
17
|
+
test 'index page' do
|
18
18
|
visit smart_proxy_salt_autosign_index_path(:smart_proxy_id => @proxy.id)
|
19
|
-
assert find_link('Keys').visible?,
|
20
|
-
assert has_content?("Autosign entries for #{@proxy.hostname}"),
|
21
|
-
assert has_content?(
|
19
|
+
assert find_link('Keys').visible?, 'Keys is not visible'
|
20
|
+
assert has_content?("Autosign entries for #{@proxy.hostname}"), 'Page title does not appear'
|
21
|
+
assert has_content?('Displaying'), 'Pagination "Display ..." does not appear'
|
22
22
|
end
|
23
23
|
|
24
|
-
test
|
24
|
+
test 'has list of autosign' do
|
25
25
|
visit smart_proxy_salt_autosign_index_path(:smart_proxy_id => @proxy.id)
|
26
|
-
assert has_content?(
|
26
|
+
assert has_content?('foo.example.com'), 'Missing autosign entry on index page'
|
27
27
|
end
|
28
28
|
end
|
29
29
|
end
|
@@ -3,23 +3,23 @@ require 'test_plugin_helper'
|
|
3
3
|
module ForemanSalt
|
4
4
|
class SaltEnvironmentTest < ActionDispatch::IntegrationTest
|
5
5
|
|
6
|
-
test
|
6
|
+
test 'index page' do
|
7
7
|
FactoryGirl.create_list :salt_environment, 50
|
8
|
-
assert_index_page(salt_environments_path,
|
8
|
+
assert_index_page(salt_environments_path, 'Salt Environment', 'New Salt Environment')
|
9
9
|
end
|
10
10
|
|
11
|
-
test
|
12
|
-
assert_new_button(salt_environments_path,
|
13
|
-
fill_in
|
11
|
+
test 'create new page' do
|
12
|
+
assert_new_button(salt_environments_path, 'New Salt Environment', new_salt_environment_path)
|
13
|
+
fill_in 'foreman_salt_salt_environment_name', :with => 'common'
|
14
14
|
assert_submit_button(salt_environments_path)
|
15
15
|
assert page.has_link? 'common'
|
16
16
|
end
|
17
17
|
|
18
|
-
test
|
18
|
+
test 'edit page' do
|
19
19
|
salt_environment = FactoryGirl.create :salt_environment
|
20
20
|
visit salt_environments_path
|
21
21
|
click_link salt_environment.name
|
22
|
-
fill_in
|
22
|
+
fill_in 'foreman_salt_salt_environment_name', :with => 'some_other_name'
|
23
23
|
assert_submit_button(salt_environments_path)
|
24
24
|
assert page.has_link? 'some_other_name'
|
25
25
|
end
|
@@ -7,39 +7,39 @@ module ForemanSalt
|
|
7
7
|
|
8
8
|
::ProxyAPI::Salt.any_instance.stubs(:key_list).returns(
|
9
9
|
{
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
10
|
+
'saltstack.example.com' => {'state'=>'accepted', 'fingerprint'=>'98:c2:63:c1:57:59:bc:bd:f1:ef:5a:38:b2:e9:71:c0'},
|
11
|
+
'saltclient01.example.com'=> {'state'=>'unaccepted', 'fingerprint'=>'98:c2:63:c1:57:59:bc:bd:f1:ef:5a:38:b2:e9:71:c1'},
|
12
|
+
'saltclient02.example.com'=> {'state'=>'unaccepted', 'fingerprint'=>'98:c2:63:c1:57:59:bc:bd:f1:ef:5a:38:b2:e9:71:c2'},
|
13
|
+
'saltclient03.example.com' => {'state'=>'rejected', 'fingerprint'=>'98:c2:63:c1:57:59:bc:bd:f1:ef:5a:38:b2:e9:71:c3'}
|
14
14
|
}
|
15
15
|
)
|
16
16
|
end
|
17
17
|
|
18
|
-
test
|
19
|
-
assert_row_button(smart_proxies_path, @proxy.name, 'Salt Keys',
|
18
|
+
test 'smart proxy page has keys link' do
|
19
|
+
assert_row_button(smart_proxies_path, @proxy.name, 'Salt Keys', true)
|
20
20
|
end
|
21
21
|
|
22
|
-
test
|
22
|
+
test 'index page' do
|
23
23
|
visit smart_proxy_salt_keys_path(:smart_proxy_id => @proxy.id)
|
24
|
-
assert find_link('Autosign').visible?,
|
25
|
-
assert has_content?("Salt Keys on #{@proxy.hostname}"),
|
26
|
-
assert has_content?(
|
24
|
+
assert find_link('Autosign').visible?, 'Autosign is not visible'
|
25
|
+
assert has_content?("Salt Keys on #{@proxy.hostname}"), 'Page title does not appear'
|
26
|
+
assert has_content?('Displaying'), 'Pagination "Display ..." does not appear'
|
27
27
|
end
|
28
28
|
|
29
|
-
test
|
29
|
+
test 'has list of keys' do
|
30
30
|
visit smart_proxy_salt_keys_path(:smart_proxy_id => @proxy.id)
|
31
|
-
assert has_content?(
|
32
|
-
assert has_content?(
|
31
|
+
assert has_content?('saltclient01.example.com'), 'Missing key on index page'
|
32
|
+
assert has_content?('98:c2:63:c1:57:59:bc:bd:f1:ef:5a:38:b2:e9:71:c1'), 'Missing fingerprint on index page'
|
33
33
|
end
|
34
34
|
|
35
|
-
test
|
35
|
+
test 'has accept link' do
|
36
36
|
::ProxyAPI::Salt.any_instance.stubs(:key_accept).returns(true)
|
37
|
-
assert_row_button(smart_proxy_salt_keys_path(:smart_proxy_id => @proxy.id), 'saltclient01.example.com', 'Accept',
|
37
|
+
assert_row_button(smart_proxy_salt_keys_path(:smart_proxy_id => @proxy.id), 'saltclient01.example.com', 'Accept', true)
|
38
38
|
end
|
39
39
|
|
40
|
-
test
|
40
|
+
test 'has reject link' do
|
41
41
|
::ProxyAPI::Salt.any_instance.stubs(:key_reject).returns(true)
|
42
|
-
assert_row_button(smart_proxy_salt_keys_path(:smart_proxy_id => @proxy.id), 'saltclient01.example.com', 'Reject',
|
42
|
+
assert_row_button(smart_proxy_salt_keys_path(:smart_proxy_id => @proxy.id), 'saltclient01.example.com', 'Reject', true)
|
43
43
|
end
|
44
44
|
end
|
45
45
|
end
|
@@ -3,23 +3,23 @@ require 'test_plugin_helper'
|
|
3
3
|
module ForemanSalt
|
4
4
|
class SaltModuleTest < ActionDispatch::IntegrationTest
|
5
5
|
|
6
|
-
test
|
6
|
+
test 'index page' do
|
7
7
|
FactoryGirl.create_list :salt_module, 50
|
8
|
-
assert_index_page(salt_modules_path,
|
8
|
+
assert_index_page(salt_modules_path, 'Salt State', 'New Salt State')
|
9
9
|
end
|
10
10
|
|
11
|
-
test
|
12
|
-
assert_new_button(salt_modules_path,
|
13
|
-
fill_in
|
11
|
+
test 'create new page' do
|
12
|
+
assert_new_button(salt_modules_path, 'New Salt State', new_salt_module_path)
|
13
|
+
fill_in 'foreman_salt_salt_module_name', :with => 'common'
|
14
14
|
assert_submit_button(salt_modules_path)
|
15
15
|
assert page.has_link? 'common'
|
16
16
|
end
|
17
17
|
|
18
|
-
test
|
18
|
+
test 'edit page' do
|
19
19
|
salt_module = FactoryGirl.create :salt_module
|
20
20
|
visit salt_modules_path
|
21
|
-
click_link salt_module.name
|
22
|
-
fill_in
|
21
|
+
click_link salt_module.name
|
22
|
+
fill_in :foreman_salt_salt_module_name, :with => 'some_other_name'
|
23
23
|
assert_submit_button(salt_modules_path)
|
24
24
|
assert page.has_link? 'some_other_name'
|
25
25
|
end
|
data/test/test_plugin_helper.rb
CHANGED
@@ -4,7 +4,7 @@ require 'test_helper'
|
|
4
4
|
def assert_row_button(index_path, link_text, button_text, dropdown = false)
|
5
5
|
visit index_path
|
6
6
|
within(:xpath, "//tr[contains(.,'#{link_text}')]") do
|
7
|
-
find(
|
7
|
+
find('i.caret').click if dropdown
|
8
8
|
click_link(button_text)
|
9
9
|
end
|
10
10
|
end
|