foreman_remote_execution 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/template_invocation.js +48 -5
- data/app/controllers/api/v2/job_invocations_controller.rb +55 -10
- data/app/controllers/api/v2/job_templates_controller.rb +19 -4
- data/app/controllers/api/v2/template_inputs_controller.rb +88 -0
- data/app/controllers/job_invocations_controller.rb +17 -15
- data/app/controllers/template_invocations_controller.rb +2 -0
- data/app/helpers/remote_execution_helper.rb +27 -16
- data/app/lib/actions/middleware/bind_job_invocation.rb +7 -3
- data/app/lib/actions/remote_execution/run_host_job.rb +28 -17
- data/app/lib/actions/remote_execution/run_hosts_job.rb +9 -6
- data/app/models/concerns/foreman_remote_execution/foreman_tasks_task_extensions.rb +1 -1
- data/app/models/concerns/foreman_remote_execution/foreman_tasks_triggering_extensions.rb +9 -0
- data/app/models/concerns/foreman_remote_execution/host_extensions.rb +3 -1
- data/app/models/job_invocation.rb +48 -41
- data/app/models/job_invocation_composer.rb +205 -80
- data/app/models/job_invocation_task_group.rb +18 -0
- data/app/models/job_template.rb +25 -1
- data/app/models/job_template_effective_user.rb +23 -0
- data/app/models/remote_execution_provider.rb +25 -11
- data/app/models/setting/remote_execution.rb +6 -0
- data/app/models/ssh_execution_provider.rb +37 -0
- data/app/models/targeting.rb +13 -0
- data/app/models/template_input.rb +4 -1
- data/app/models/template_invocation.rb +23 -0
- data/app/views/api/v2/job_invocations/base.json.rabl +4 -0
- data/app/views/api/v2/job_invocations/index.json.rabl +1 -1
- data/app/views/api/v2/job_invocations/main.json.rabl +19 -0
- data/app/views/api/v2/job_invocations/show.json.rabl +0 -15
- data/app/views/api/v2/job_templates/base.json.rabl +1 -1
- data/app/views/api/v2/job_templates/index.json.rabl +1 -1
- data/app/views/api/v2/job_templates/main.json.rabl +5 -1
- data/app/views/api/v2/job_templates/show.json.rabl +4 -0
- data/app/views/api/v2/job_templates/update.json.rabl +3 -0
- data/app/views/api/v2/template_inputs/base.json.rabl +3 -0
- data/app/views/api/v2/template_inputs/create.json.rabl +3 -0
- data/app/views/api/v2/template_inputs/index.json.rabl +3 -0
- data/app/views/api/v2/template_inputs/main.json.rabl +9 -0
- data/app/views/api/v2/template_inputs/show.json.rabl +3 -0
- data/app/views/job_invocation_task_groups/_job_invocation_task_group.html.erb +31 -0
- data/app/views/job_invocation_task_groups/_job_invocation_task_groups.html.erb +3 -0
- data/app/views/job_invocations/_form.html.erb +102 -71
- data/app/views/job_invocations/_tab_overview.html.erb +5 -2
- data/app/views/job_invocations/index.html.erb +4 -4
- data/app/views/job_invocations/refresh.js.erb +2 -1
- data/app/views/job_invocations/show.html.erb +13 -2
- data/app/views/job_invocations/show.js.erb +1 -1
- data/app/views/job_templates/_custom_tabs.html.erb +16 -0
- data/app/views/templates/package_action.erb +1 -0
- data/app/views/templates/puppet_run_once.erb +1 -0
- data/app/views/templates/run_command.erb +1 -0
- data/app/views/templates/service_action.erb +1 -0
- data/config/routes.rb +15 -2
- data/db/migrate/20150923125825_add_job_invocation_task_group.rb +10 -0
- data/db/migrate/20151022105508_rename_last_task_id_column.rb +6 -0
- data/db/migrate/20151116105412_add_triggering_to_job_invocation.rb +10 -0
- data/db/migrate/20151120171100_add_effective_user_to_template_invocation.rb +5 -0
- data/db/migrate/20151124162300_create_job_template_effective_users.rb +13 -0
- data/db/migrate/20151203100824_add_description_to_job_invocation.rb +11 -0
- data/db/migrate/20151215114631_add_host_id_to_template_invocation.rb +29 -0
- data/db/migrate/20151217092555_migrate_to_task_groups.rb +16 -0
- data/foreman_remote_execution.gemspec +2 -1
- data/lib/foreman_remote_execution/engine.rb +30 -5
- data/lib/foreman_remote_execution/version.rb +1 -1
- data/test/factories/foreman_remote_execution_factories.rb +5 -0
- data/test/functional/api/v2/job_invocations_controller_test.rb +3 -3
- data/test/functional/api/v2/template_inputs_controller_test.rb +61 -0
- data/test/unit/actions/run_hosts_job_test.rb +10 -3
- data/test/unit/concerns/host_extensions_test.rb +10 -6
- data/test/unit/job_invocation_composer_test.rb +229 -10
- data/test/unit/job_invocation_test.rb +27 -27
- data/test/unit/job_template_effective_user_test.rb +41 -0
- data/test/unit/job_template_test.rb +24 -0
- data/test/unit/remote_execution_provider_test.rb +39 -0
- metadata +42 -7
- data/app/models/job_invocation_api_composer.rb +0 -69
- data/test/unit/job_invocation_api_composer_test.rb +0 -143
@@ -8,6 +8,10 @@
|
|
8
8
|
:id => 'search') %>
|
9
9
|
<% end %>
|
10
10
|
|
11
|
+
<%= text_f f, :description_format,
|
12
|
+
:help_inline => popover(_('Explanation'), _('Description template determines the job name once it is submitted. Input values can become part of the name
|
13
|
+
if they are specified using interpolation syntax, e.g. %{fqdn} where fqdn is the name of interpolated input.')) %>
|
14
|
+
|
11
15
|
<%= select_f f, :provider_type, providers_options, :first, :last %>
|
12
16
|
|
13
17
|
<div class="children_fields">
|
@@ -20,6 +24,18 @@
|
|
20
24
|
<%= add_child_link '+ ' + _("Add Input"), :template_inputs, { :title => _('add a input for this template')} %>
|
21
25
|
</div>
|
22
26
|
|
27
|
+
<div class="children_fields">
|
28
|
+
<%= field_set_tag _("Effective user") do %>
|
29
|
+
<%= f.fields_for :effective_user, @template.effective_user do |ff| %>
|
30
|
+
<div class="effective_user_form fields">
|
31
|
+
<%= text_f ff, :value %>
|
32
|
+
<%= checkbox_f ff, :current_user %>
|
33
|
+
<%= checkbox_f ff, :overridable %>
|
34
|
+
</div>
|
35
|
+
<% end %>
|
36
|
+
<% end %>
|
37
|
+
</div>
|
38
|
+
|
23
39
|
</div>
|
24
40
|
|
25
41
|
|
data/config/routes.rb
CHANGED
@@ -24,11 +24,20 @@ Rails.application.routes.draw do
|
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
-
|
27
|
+
# index is needed so the auto_complete_search can be constructed, otherwise autocompletion in filter does not work
|
28
|
+
resources :template_invocations, :only => [:show, :index] do
|
29
|
+
collection do
|
30
|
+
get 'auto_complete_search'
|
31
|
+
end
|
32
|
+
end
|
28
33
|
|
29
34
|
namespace :api, :defaults => {:format => 'json'} do
|
30
35
|
scope "(:apiv)", :module => :v2, :defaults => {:apiv => 'v2'}, :apiv => /v1|v2/, :constraints => ApiConstraints.new(:version => 2, :default => true) do
|
31
|
-
resources :job_invocations, :except => [:new, :edit, :update, :destroy]
|
36
|
+
resources :job_invocations, :except => [:new, :edit, :update, :destroy] do
|
37
|
+
resources :hosts, :only => :none do
|
38
|
+
get '/', :to => 'job_invocations#output'
|
39
|
+
end
|
40
|
+
end
|
32
41
|
|
33
42
|
resources :job_templates, :except => [:new, :edit] do
|
34
43
|
(resources :locations, :only => [:index, :show]) if SETTINGS[:locations_enabled]
|
@@ -38,6 +47,10 @@ Rails.application.routes.draw do
|
|
38
47
|
get 'revision'
|
39
48
|
end
|
40
49
|
end
|
50
|
+
|
51
|
+
resources :templates, :only => :none do
|
52
|
+
resources :template_inputs, :only => [:index, :show, :create, :new, :destroy, :update]
|
53
|
+
end
|
41
54
|
end
|
42
55
|
end
|
43
56
|
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
class AddJobInvocationTaskGroup < ActiveRecord::Migration
|
2
|
+
def up
|
3
|
+
add_column :job_invocations, :task_group_id, :integer, :index => true
|
4
|
+
add_foreign_key :job_invocations, :foreman_tasks_task_groups, :column => :task_group_id
|
5
|
+
end
|
6
|
+
|
7
|
+
def down
|
8
|
+
remove_column :job_invocations, :task_group_id
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
class AddTriggeringToJobInvocation < ActiveRecord::Migration
|
2
|
+
def up
|
3
|
+
add_column :job_invocations, :triggering_id, :integer, :index => true
|
4
|
+
add_foreign_key :job_invocations, :foreman_tasks_triggerings, :column => :triggering_id
|
5
|
+
end
|
6
|
+
|
7
|
+
def down
|
8
|
+
remove_column :job_invocations, :triggering_id
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class CreateJobTemplateEffectiveUsers < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :job_template_effective_users do |t|
|
4
|
+
t.integer :job_template_id
|
5
|
+
t.string :value
|
6
|
+
t.boolean :overridable
|
7
|
+
t.boolean :current_user
|
8
|
+
end
|
9
|
+
|
10
|
+
add_index :job_template_effective_users, :job_template_id, :name => 'effective_users_job_template_id'
|
11
|
+
add_foreign_key :job_template_effective_users, :templates, :column => :job_template_id
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
class AddDescriptionToJobInvocation < ActiveRecord::Migration
|
2
|
+
def up
|
3
|
+
add_column :job_invocations, :description, :string
|
4
|
+
add_column :templates, :description_format, :string
|
5
|
+
end
|
6
|
+
|
7
|
+
def down
|
8
|
+
remove_column :job_invocations, :description
|
9
|
+
remove_column :templates, :description_format
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
class AddHostIdToTemplateInvocation < ActiveRecord::Migration
|
2
|
+
class FakeTemplateInvocation < ActiveRecord::Base
|
3
|
+
set_table_name 'template_invocations'
|
4
|
+
end
|
5
|
+
|
6
|
+
def up
|
7
|
+
add_column :template_invocations, :host_id, :integer
|
8
|
+
add_foreign_key "template_invocations", "hosts", :name => "template_invocations_hosts_id_fk", :column => 'host_id'
|
9
|
+
FakeTemplateInvocation.reset_column_information
|
10
|
+
|
11
|
+
say 'Migrating existing execution locks to explicit relations, this may take a while'
|
12
|
+
FakeTemplateInvocation.all.each do |template_invocation|
|
13
|
+
task = ForemanTasks::Task.for_action_types('Actions::RemoteExecution::RunHostJob').joins(:locks).where(
|
14
|
+
:'foreman_tasks_locks.resource_type' => 'TemplateInvocation',
|
15
|
+
:'foreman_tasks_locks.resource_id' => template_invocation.id).first
|
16
|
+
next if task.nil? # skip invocations from very early versions of remote executions
|
17
|
+
host_id = task.locks.where(:'foreman_tasks_locks.resource_type' => 'Host::Managed').first.resource_id
|
18
|
+
next unless Host.find_by_id(host_id)
|
19
|
+
|
20
|
+
template_invocation.host_id = host_id
|
21
|
+
template_invocation.save!
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def down
|
26
|
+
remove_foreign_key "template_invocations", :name => "template_invocations_hosts_id_fk"
|
27
|
+
remove_column :template_invocations, :host_id
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class MigrateToTaskGroups < ActiveRecord::Migration
|
2
|
+
class FakeJobInvocation < ActiveRecord::Base
|
3
|
+
set_table_name 'job_invocations'
|
4
|
+
end
|
5
|
+
|
6
|
+
def up
|
7
|
+
say 'Migrating from locks to task groups'
|
8
|
+
FakeJobInvocation.where('task_group_id IS NULL AND task_id IS NOT NULL').each do |job_invocation|
|
9
|
+
task_group = JobInvocationTaskGroup.new
|
10
|
+
task_group.task_ids = [job_invocation.task_id]
|
11
|
+
task_group.save!
|
12
|
+
job_invocation.task_group_id = task_group.id
|
13
|
+
job_invocation.save!
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -20,7 +20,8 @@ Gem::Specification.new do |s|
|
|
20
20
|
|
21
21
|
s.add_dependency "deface"
|
22
22
|
s.add_dependency "rails", "~> 3.2.8"
|
23
|
-
s.add_dependency "
|
23
|
+
s.add_dependency "dynflow", "~> 0.8.8"
|
24
|
+
s.add_dependency "foreman-tasks", "~> 0.7.8"
|
24
25
|
|
25
26
|
s.add_development_dependency 'rubocop'
|
26
27
|
s.add_development_dependency 'rdoc'
|
@@ -34,22 +34,46 @@ module ForemanRemoteExecution
|
|
34
34
|
# Add permissions
|
35
35
|
security_block :foreman_remote_execution do
|
36
36
|
permission :view_job_templates, { :job_templates => [:index, :show, :revision, :auto_complete_search, :auto_complete_job_name, :preview],
|
37
|
-
:'api/v2/job_templates' => [:index, :show, :revision]
|
37
|
+
:'api/v2/job_templates' => [:index, :show, :revision],
|
38
|
+
:'api/v2/template_inputs' => [:index, :show]}, :resource_type => 'JobTemplate'
|
38
39
|
permission :create_job_templates, { :job_templates => [:new, :create, :clone_template],
|
39
40
|
:'api/v2/job_templates' => [:create, :clone] }, :resource_type => 'JobTemplate'
|
40
41
|
permission :edit_job_templates, { :job_templates => [:edit, :update],
|
41
|
-
:'api/v2/job_templates' => [:update]
|
42
|
+
:'api/v2/job_templates' => [:update],
|
43
|
+
:'api/v2/template_inputs' => [:update, :new, :create, :destroy]}, :resource_type => 'JobTemplate'
|
42
44
|
permission :destroy_job_templates, { :job_templates => [:destroy],
|
43
45
|
:'api/v2/job_templates' => [:destroy] }, :resource_type => 'JobTemplate'
|
44
46
|
permission :lock_job_templates, { :job_templates => [:lock, :unlock] }, :resource_type => 'JobTemplate'
|
45
47
|
permission :create_job_invocations, { :job_invocations => [:new, :create, :refresh, :rerun, :preview_hosts],
|
46
48
|
'api/v2/job_invocations' => [:create] }, :resource_type => 'JobInvocation'
|
47
49
|
permission :view_job_invocations, { :job_invocations => [:index, :show, :auto_complete_search], :template_invocations => [:show],
|
48
|
-
'api/v2/job_invocations' => [:index, :show] }, :resource_type => 'JobInvocation'
|
50
|
+
'api/v2/job_invocations' => [:index, :show, :output] }, :resource_type => 'JobInvocation'
|
51
|
+
permission :execute_template_invocation, {}, :resource_type => 'TemplateInvocation'
|
52
|
+
# this permissions grants user to get auto completion hints when setting up filters
|
53
|
+
permission :filter_autocompletion_for_template_invocation, { :template_invocations => [ :auto_complete_search, :index ] },
|
54
|
+
:resource_type => 'TemplateInvocation'
|
49
55
|
end
|
50
56
|
|
51
|
-
|
52
|
-
|
57
|
+
USER_PERMISSIONS = [
|
58
|
+
:view_job_templates,
|
59
|
+
:view_job_invocations,
|
60
|
+
:create_job_invocations,
|
61
|
+
:execute_template_invocation,
|
62
|
+
:view_hosts,
|
63
|
+
:view_smart_proxies
|
64
|
+
]
|
65
|
+
MANAGER_PERMISSIONS = USER_PERMISSIONS + [
|
66
|
+
:destroy_job_templates,
|
67
|
+
:edit_job_templates,
|
68
|
+
:create_job_templates,
|
69
|
+
:lock_job_templates,
|
70
|
+
:view_audit_logs,
|
71
|
+
:filter_autocompletion_for_template_invocation
|
72
|
+
]
|
73
|
+
|
74
|
+
# Add a new role called 'Remote Execution User ' if it doesn't exist
|
75
|
+
role 'Remote Execution User', USER_PERMISSIONS
|
76
|
+
role 'Remote Execution Manager', MANAGER_PERMISSIONS
|
53
77
|
|
54
78
|
# add menu entry
|
55
79
|
menu :top_menu, :job_templates,
|
@@ -122,6 +146,7 @@ module ForemanRemoteExecution
|
|
122
146
|
# having issues with resolving it to Rake::Task otherwise
|
123
147
|
require_dependency 'foreman_tasks/task'
|
124
148
|
ForemanTasks::Task.send(:include, ForemanRemoteExecution::ForemanTasksTaskExtensions)
|
149
|
+
RemoteExecutionProvider.register(:Ssh, SSHExecutionProvider)
|
125
150
|
end
|
126
151
|
|
127
152
|
initializer 'foreman_remote_execution.register_gettext', after: :load_config_initializers do |_app|
|
@@ -11,6 +11,10 @@ FactoryGirl.define do
|
|
11
11
|
template.template_inputs << FactoryGirl.build(:template_input)
|
12
12
|
end
|
13
13
|
end
|
14
|
+
|
15
|
+
trait :with_description_format do
|
16
|
+
description_format "Factory-built %{job_name}"
|
17
|
+
end
|
14
18
|
end
|
15
19
|
|
16
20
|
factory :template_input do |f|
|
@@ -27,6 +31,7 @@ FactoryGirl.define do
|
|
27
31
|
factory :job_invocation do |f|
|
28
32
|
targeting
|
29
33
|
f.sequence(:job_name) { |n| "Job name #{n}" }
|
34
|
+
f.description_format '%{job_name}'
|
30
35
|
trait :with_template do
|
31
36
|
after(:build) do |invocation, evaluator|
|
32
37
|
invocation.template_invocations << FactoryGirl.build(:template_invocation)
|
@@ -23,7 +23,7 @@ module Api
|
|
23
23
|
assert_equal template["job_name"], @invocation.job_name
|
24
24
|
end
|
25
25
|
|
26
|
-
test "should create valid without
|
26
|
+
test "should create valid without job_template_id" do
|
27
27
|
attrs = { :job_name => @template.job_name, :name => 'RandomName', :targeting_type => 'static_query', :search_query => "foobar"}
|
28
28
|
post :create, :job_invocation => attrs
|
29
29
|
|
@@ -32,8 +32,8 @@ module Api
|
|
32
32
|
assert_response :success
|
33
33
|
end
|
34
34
|
|
35
|
-
test "should create valid with
|
36
|
-
attrs = { :job_name => @template.job_name, :name => 'RandomName', :
|
35
|
+
test "should create valid with job_template_id" do
|
36
|
+
attrs = { :job_name => @template.job_name, :name => 'RandomName', :job_template_id => @template.id,:targeting_type => 'static_query', :search_query => "foobar"}
|
37
37
|
post :create, :job_invocation => attrs
|
38
38
|
|
39
39
|
invocation = ActiveSupport::JSON.decode(@response.body)
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require 'test_plugin_helper'
|
2
|
+
|
3
|
+
module Api
|
4
|
+
module V2
|
5
|
+
class TemplateInputsControllerTest < ActionController::TestCase
|
6
|
+
setup do
|
7
|
+
@template = FactoryGirl.create(:job_template, :with_input)
|
8
|
+
@input = @template.template_inputs.first
|
9
|
+
end
|
10
|
+
|
11
|
+
test 'should get index' do
|
12
|
+
get :index, :template_id => @template.id
|
13
|
+
inputs = ActiveSupport::JSON.decode(@response.body)
|
14
|
+
assert !inputs.empty?, "Should respond with inputs"
|
15
|
+
assert_response :success
|
16
|
+
end
|
17
|
+
|
18
|
+
test 'should get input detail' do
|
19
|
+
get :show, :template_id => @template.to_param, :id => @input.to_param
|
20
|
+
assert_response :success
|
21
|
+
input = ActiveSupport::JSON.decode(@response.body)
|
22
|
+
assert !input.empty?
|
23
|
+
assert_equal input["name"], @input.name
|
24
|
+
end
|
25
|
+
|
26
|
+
test 'should create valid' do
|
27
|
+
valid_attrs = { :name => 'is_potato', :input_type => 'user', :options => ['true', 'false'] }
|
28
|
+
post :create, :template_input => valid_attrs, :template_id => @template.to_param
|
29
|
+
input = ActiveSupport::JSON.decode(@response.body)
|
30
|
+
assert input['name'] == 'is_potato'
|
31
|
+
assert_response :success
|
32
|
+
end
|
33
|
+
|
34
|
+
test 'should not create invalid' do
|
35
|
+
post :create, :template_id => @template.to_param
|
36
|
+
assert_response :unprocessable_entity
|
37
|
+
end
|
38
|
+
|
39
|
+
test 'should update valid' do
|
40
|
+
put :update, :template_id => @template.to_param,
|
41
|
+
:id => @input.to_param,
|
42
|
+
:template_input => { :name => "blah" }
|
43
|
+
assert_response :ok
|
44
|
+
end
|
45
|
+
|
46
|
+
test 'should not update invalid' do
|
47
|
+
put :update, :template_id => @template.to_param,
|
48
|
+
:id => @input.to_param,
|
49
|
+
:template_input => { :name => '' }
|
50
|
+
assert_response :unprocessable_entity
|
51
|
+
end
|
52
|
+
|
53
|
+
test 'should destroy' do
|
54
|
+
delete :destroy, :template_id => @template.to_param,
|
55
|
+
:id => @input.to_param
|
56
|
+
assert_response :ok
|
57
|
+
refute TemplateInput.exists?(@input.id)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -14,10 +14,17 @@ module ForemanRemoteExecution
|
|
14
14
|
invocation.save
|
15
15
|
end
|
16
16
|
end
|
17
|
+
|
18
|
+
let(:task) do
|
19
|
+
OpenStruct.new(:id => '123').tap do |o|
|
20
|
+
o.stubs(:add_missing_task_groups)
|
21
|
+
o.stubs(:task_groups).returns([])
|
22
|
+
end
|
23
|
+
end
|
17
24
|
let(:action) do
|
18
25
|
action = create_action(Actions::RemoteExecution::RunHostsJob)
|
19
26
|
action.expects(:action_subject).with(job_invocation)
|
20
|
-
ForemanTasks::Task::DynflowTask.stubs(:
|
27
|
+
ForemanTasks::Task::DynflowTask.stubs(:where).returns(mock.tap { |m| m.stubs(:first! => task) })
|
21
28
|
plan_action(action, job_invocation)
|
22
29
|
end
|
23
30
|
|
@@ -33,13 +40,13 @@ module ForemanRemoteExecution
|
|
33
40
|
|
34
41
|
it 'triggers the RunHostJob actions on the resolved hosts in run phase' do
|
35
42
|
template_invocation = job_invocation.template_invocation_for_host(host)
|
36
|
-
action.expects(:trigger).with(Actions::RemoteExecution::RunHostJob, job_invocation, host, template_invocation, proxy
|
43
|
+
action.expects(:trigger).with(Actions::RemoteExecution::RunHostJob, job_invocation, host, template_invocation, proxy)
|
37
44
|
action.create_sub_plans
|
38
45
|
end
|
39
46
|
|
40
47
|
it 'uses the BindJobInvocation middleware' do
|
41
48
|
action
|
42
|
-
job_invocation.
|
49
|
+
job_invocation.task_id.must_equal '123'
|
43
50
|
end
|
44
51
|
end
|
45
52
|
end
|
@@ -9,13 +9,14 @@ describe ForemanRemoteExecution::HostExtensions do
|
|
9
9
|
|
10
10
|
after { User.current = nil }
|
11
11
|
|
12
|
-
|
12
|
+
describe 'ssh specific params' do
|
13
13
|
let(:host) { FactoryGirl.build(:host, :with_execution) }
|
14
14
|
let(:sshkey) { 'ssh-rsa AAAAB3NzaC1yc2EAAAABJQ foo@example.com' }
|
15
15
|
|
16
16
|
before do
|
17
17
|
SmartProxy.any_instance.stubs(:pubkey).returns(sshkey)
|
18
18
|
Setting[:remote_execution_ssh_user] = 'root'
|
19
|
+
Setting[:remote_execution_effective_user_method] = 'sudo'
|
19
20
|
end
|
20
21
|
|
21
22
|
it 'has ssh user in the parameters' do
|
@@ -26,14 +27,17 @@ describe ForemanRemoteExecution::HostExtensions do
|
|
26
27
|
host.host_parameters << FactoryGirl.build(:host_parameter, :name => 'remote_execution_ssh_user', :value => 'amy')
|
27
28
|
host.params['remote_execution_ssh_user'].must_equal 'amy'
|
28
29
|
end
|
29
|
-
end
|
30
30
|
|
31
|
-
|
32
|
-
|
33
|
-
|
31
|
+
it 'has effective user method in the parameters' do
|
32
|
+
host.params['remote_execution_effective_user_method'].must_equal Setting[:remote_execution_effective_user_method]
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'can override effective user method' do
|
36
|
+
host.host_parameters << FactoryGirl.build(:host_parameter, :name => 'remote_execution_effective_user_method', :value => 'su')
|
37
|
+
host.params['remote_execution_effective_user_method'].must_equal 'su'
|
38
|
+
end
|
34
39
|
|
35
40
|
it 'has ssh keys in the parameters' do
|
36
|
-
SmartProxy.any_instance.stubs(:pubkey).returns(sshkey)
|
37
41
|
host.remote_execution_ssh_keys.must_include sshkey
|
38
42
|
end
|
39
43
|
end
|