foreman_remote_execution 1.4.1 → 1.4.2

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.
Files changed (125) hide show
  1. checksums.yaml +5 -5
  2. data/.rubocop.yml +11 -9
  3. data/.rubocop_todo.yml +146 -116
  4. data/app/controllers/api/v2/job_invocations_controller.rb +6 -1
  5. data/app/controllers/api/v2/job_templates_controller.rb +0 -1
  6. data/app/controllers/job_invocations_controller.rb +6 -1
  7. data/app/lib/actions/remote_execution/run_host_job.rb +1 -1
  8. data/app/models/concerns/foreman_remote_execution/errors_flattener.rb +3 -0
  9. data/app/models/concerns/foreman_remote_execution/host_extensions.rb +1 -1
  10. data/app/models/concerns/foreman_remote_execution/subnet_extensions.rb +1 -1
  11. data/app/models/foreign_input_set.rb +1 -1
  12. data/app/models/job_invocation.rb +1 -1
  13. data/app/models/job_invocation_composer.rb +2 -2
  14. data/app/models/job_invocation_task_group.rb +1 -1
  15. data/app/models/job_template.rb +3 -3
  16. data/app/models/job_template_effective_user.rb +1 -1
  17. data/app/models/remote_execution_feature.rb +1 -1
  18. data/app/models/target_remote_execution_proxy.rb +1 -1
  19. data/app/models/targeting.rb +2 -2
  20. data/app/models/targeting_host.rb +1 -1
  21. data/app/models/template_input.rb +1 -1
  22. data/app/models/template_invocation.rb +1 -1
  23. data/app/models/template_invocation_input_value.rb +1 -1
  24. data/db/migrate/20150612121541_add_job_template_to_template.rb +1 -1
  25. data/db/migrate/20150616080015_create_template_input.rb +1 -1
  26. data/db/migrate/20150708133241_add_targeting.rb +1 -1
  27. data/db/migrate/20150708133242_add_invocation.rb +1 -1
  28. data/db/migrate/20150708133305_add_template_invocation.rb +1 -1
  29. data/db/migrate/20150812110800_add_resolved_at_to_targeting.rb +1 -1
  30. data/db/migrate/20150812145900_add_last_task_id_to_job_invocation.rb +1 -1
  31. data/db/migrate/20150826191632_create_target_remote_execution_proxies.rb +1 -1
  32. data/db/migrate/20150827144500_change_targeting_search_query_type.rb +1 -1
  33. data/db/migrate/20150827152730_add_options_to_template_input.rb +1 -1
  34. data/db/migrate/20150903192731_add_execution_to_interface.rb +2 -2
  35. data/db/migrate/20150923125825_add_job_invocation_task_group.rb +1 -1
  36. data/db/migrate/20151013135415_add_pub_key_to_smart_proxy.rb +1 -1
  37. data/db/migrate/20151022105508_rename_last_task_id_column.rb +1 -1
  38. data/db/migrate/20151116105412_add_triggering_to_job_invocation.rb +1 -1
  39. data/db/migrate/20151120171100_add_effective_user_to_template_invocation.rb +1 -1
  40. data/db/migrate/20151124162300_create_job_template_effective_users.rb +1 -1
  41. data/db/migrate/20151203100824_add_description_to_job_invocation.rb +1 -1
  42. data/db/migrate/20151215114631_add_host_id_to_template_invocation.rb +2 -2
  43. data/db/migrate/20151217092555_migrate_to_task_groups.rb +2 -2
  44. data/db/migrate/20160108134600_create_template_input_sets.rb +1 -1
  45. data/db/migrate/20160108141144_make_job_name_default_to_something.rb +1 -1
  46. data/db/migrate/20160111113032_upcase_ssh_feature.rb +2 -2
  47. data/db/migrate/20160113161916_add_run_host_job_task_id_to_template_invocation.rb +1 -1
  48. data/db/migrate/20160113162007_expand_all_template_invocations.rb +3 -3
  49. data/db/migrate/20160114120200_rename_job_categories.rb +1 -1
  50. data/db/migrate/20160114125628_rename_job_name_to_job_category.rb +1 -1
  51. data/db/migrate/20160118124600_create_remote_execution_features.rb +1 -1
  52. data/db/migrate/20160125155108_make_job_template_name_unique.rb +1 -1
  53. data/db/migrate/20160127134031_add_advanced_to_template_input.rb +1 -1
  54. data/db/migrate/20160127162711_reword_puppet_template_description.rb +1 -1
  55. data/db/migrate/20160203104056_add_concurrency_options_to_job_invocation.rb +1 -1
  56. data/db/migrate/20160926225841_update_template_input_value.rb +1 -1
  57. data/db/migrate/20170110145641_add_host_action_button_to_remote_execution_feature.rb +1 -1
  58. data/db/migrate/20170613101039_add_timeout_to_job_templates_and_job_invocations.rb +1 -1
  59. data/db/migrate/20180110104432_rename_template_invocation_permission.rb +25 -0
  60. data/db/migrate/20180112125015_fix_taxable_taxonomies_job_template.rb +14 -0
  61. data/db/seeds.d/90-bookmarks.rb +1 -1
  62. data/foreman_remote_execution.gemspec +2 -1
  63. data/lib/foreman_remote_execution/engine.rb +3 -3
  64. data/lib/foreman_remote_execution/version.rb +1 -1
  65. data/test/benchmark/run_hosts_job_benchmark.rb +10 -10
  66. data/test/benchmark/targeting_benchmark.rb +6 -6
  67. data/test/factories/foreman_remote_execution_factories.rb +14 -14
  68. data/test/functional/api/v2/foreign_input_sets_controller_test.rb +10 -15
  69. data/test/functional/api/v2/job_invocations_controller_test.rb +19 -8
  70. data/test/functional/api/v2/job_templates_controller_test.rb +12 -16
  71. data/test/functional/api/v2/remote_execution_features_controller_test.rb +3 -4
  72. data/test/functional/api/v2/template_inputs_controller_test.rb +8 -13
  73. data/test/test_plugin_helper.rb +4 -4
  74. data/test/unit/actions/run_hosts_job_test.rb +3 -3
  75. data/test/unit/concerns/exportable_test.rb +1 -1
  76. data/test/unit/concerns/foreman_tasks_cleaner_extensions_test.rb +2 -2
  77. data/test/unit/concerns/host_extensions_test.rb +20 -20
  78. data/test/unit/concerns/nic_extensions_test.rb +1 -1
  79. data/test/unit/input_template_renderer_test.rb +86 -86
  80. data/test/unit/job_invocation_composer_test.rb +17 -16
  81. data/test/unit/job_invocation_test.rb +10 -10
  82. data/test/unit/job_template_effective_user_test.rb +2 -2
  83. data/test/unit/job_template_importer_test.rb +3 -3
  84. data/test/unit/job_template_test.rb +15 -15
  85. data/test/unit/remote_execution_feature_test.rb +3 -3
  86. data/test/unit/remote_execution_provider_test.rb +15 -15
  87. data/test/unit/targeting_test.rb +3 -3
  88. data/test/unit/template_input_test.rb +1 -1
  89. data/test/unit/template_invocation_input_value_test.rb +17 -17
  90. metadata +19 -77
  91. data/doc/.gitignore +0 -7
  92. data/doc/Gemfile +0 -7
  93. data/doc/Rakefile +0 -41
  94. data/doc/_config.yml +0 -33
  95. data/doc/plugins/alert_block.rb +0 -27
  96. data/doc/plugins/div_tag.rb +0 -24
  97. data/doc/plugins/graphviz.rb +0 -121
  98. data/doc/plugins/plantuml.rb +0 -84
  99. data/doc/plugins/play.rb +0 -13
  100. data/doc/plugins/tags.rb +0 -137
  101. data/doc/plugins/toc.rb +0 -19
  102. data/doc/source/.nojekyll +0 -0
  103. data/doc/source/404.md +0 -6
  104. data/doc/source/_includes/footer.html +0 -21
  105. data/doc/source/_includes/header.html +0 -59
  106. data/doc/source/_includes/tocify.html +0 -6
  107. data/doc/source/_layouts/default.html +0 -9
  108. data/doc/source/_layouts/page.html +0 -25
  109. data/doc/source/atom.xml +0 -32
  110. data/doc/source/design/index.md +0 -1322
  111. data/doc/source/design/wireframes.pdf +0 -0
  112. data/doc/source/index.md +0 -18
  113. data/doc/source/static/css/bootstrap-responsive.min.css +0 -9
  114. data/doc/source/static/css/bootstrap.min.css +0 -866
  115. data/doc/source/static/css/jquery.tocify.css +0 -128
  116. data/doc/source/static/css/style.css +0 -285
  117. data/doc/source/static/css/syntax.css +0 -60
  118. data/doc/source/static/images/foreman.png +0 -0
  119. data/doc/source/static/images/glyphicons-halflings-white.png +0 -0
  120. data/doc/source/static/images/glyphicons-halflings.png +0 -0
  121. data/doc/source/static/js/bootstrap.min.js +0 -7
  122. data/doc/source/static/js/jquery-ui-1.9.2.custom.min.js +0 -6
  123. data/doc/source/static/js/jquery.js +0 -2
  124. data/doc/source/static/js/jquery.tocify.min.js +0 -3
  125. data/doc/source/static/js/scroll.js +0 -24
@@ -4,6 +4,7 @@ RemoteExecutionProvider.register(:Mcollective, OpenStruct)
4
4
 
5
5
  class JobInvocationComposerTest < ActiveSupport::TestCase
6
6
  before do
7
+ setup_user('create', 'template_invocations')
7
8
  setup_user('view', 'job_templates', 'name ~ trying*')
8
9
  setup_user('create', 'job_templates', 'name ~ trying*')
9
10
  setup_user('view', 'job_invocations')
@@ -15,17 +16,17 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
15
16
  setup_user('create', 'hosts')
16
17
  end
17
18
 
18
- let(:trying_job_template_1) { FactoryGirl.create(:job_template, :job_category => 'trying_job_template_1', :name => 'trying1', :provider_type => 'SSH') }
19
- let(:trying_job_template_2) { FactoryGirl.create(:job_template, :job_category => 'trying_job_template_2', :name => 'trying2', :provider_type => 'Mcollective') }
20
- let(:trying_job_template_3) { FactoryGirl.create(:job_template, :job_category => 'trying_job_template_1', :name => 'trying3', :provider_type => 'SSH') }
21
- let(:unauthorized_job_template_1) { FactoryGirl.create(:job_template, :job_category => 'trying_job_template_1', :name => 'unauth1', :provider_type => 'SSH') }
22
- let(:unauthorized_job_template_2) { FactoryGirl.create(:job_template, :job_category => 'unauthorized_job_template_2', :name => 'unauth2', :provider_type => 'Ansible') }
19
+ let(:trying_job_template_1) { FactoryBot.create(:job_template, :job_category => 'trying_job_template_1', :name => 'trying1', :provider_type => 'SSH') }
20
+ let(:trying_job_template_2) { FactoryBot.create(:job_template, :job_category => 'trying_job_template_2', :name => 'trying2', :provider_type => 'Mcollective') }
21
+ let(:trying_job_template_3) { FactoryBot.create(:job_template, :job_category => 'trying_job_template_1', :name => 'trying3', :provider_type => 'SSH') }
22
+ let(:unauthorized_job_template_1) { FactoryBot.create(:job_template, :job_category => 'trying_job_template_1', :name => 'unauth1', :provider_type => 'SSH') }
23
+ let(:unauthorized_job_template_2) { FactoryBot.create(:job_template, :job_category => 'unauthorized_job_template_2', :name => 'unauth2', :provider_type => 'Ansible') }
23
24
 
24
25
 
25
- let(:input1) { FactoryGirl.create(:template_input, :template => trying_job_template_1, :input_type => 'user') }
26
- let(:input2) { FactoryGirl.create(:template_input, :template => trying_job_template_3, :input_type => 'user') }
27
- let(:input3) { FactoryGirl.create(:template_input, :template => trying_job_template_1, :input_type => 'user', :required => true) }
28
- let(:unauthorized_input1) { FactoryGirl.create(:template_input, :template => unauthorized_job_template_1, :input_type => 'user') }
26
+ let(:input1) { FactoryBot.create(:template_input, :template => trying_job_template_1, :input_type => 'user') }
27
+ let(:input2) { FactoryBot.create(:template_input, :template => trying_job_template_3, :input_type => 'user') }
28
+ let(:input3) { FactoryBot.create(:template_input, :template => trying_job_template_1, :input_type => 'user', :required => true) }
29
+ let(:unauthorized_input1) { FactoryBot.create(:template_input, :template => unauthorized_job_template_1, :input_type => 'user') }
29
30
 
30
31
  let(:ansible_params) { { } }
31
32
  let(:ssh_params) { { } }
@@ -140,7 +141,7 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
140
141
 
141
142
  describe '#templates_for_provider(provider_type)' do
142
143
  it 'returns all templates for a given provider respecting template permissions' do
143
- trying_job_template_4 = FactoryGirl.create(:job_template, :job_category => 'trying_job_template_1', :name => 'trying4', :provider_type => 'Ansible')
144
+ trying_job_template_4 = FactoryBot.create(:job_template, :job_category => 'trying_job_template_1', :name => 'trying4', :provider_type => 'Ansible')
144
145
  result = composer.templates_for_provider('SSH')
145
146
  result.must_include trying_job_template_1
146
147
  result.must_include trying_job_template_3
@@ -161,8 +162,8 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
161
162
  end
162
163
 
163
164
  context 'extra unavailable templates id were selected' do
164
- let(:unauthorized) { FactoryGirl.create(:job_template, :job_category => 'trying_job_template_1', :name => 'unauth3', :provider_type => 'Ansible') }
165
- let(:mcollective_authorized) { FactoryGirl.create(:job_template, :job_category => 'trying_job_template_1', :name => 'trying4', :provider_type => 'Mcollective') }
165
+ let(:unauthorized) { FactoryBot.create(:job_template, :job_category => 'trying_job_template_1', :name => 'unauth3', :provider_type => 'Ansible') }
166
+ let(:mcollective_authorized) { FactoryBot.create(:job_template, :job_category => 'trying_job_template_1', :name => 'trying4', :provider_type => 'Mcollective') }
166
167
  let(:ssh_params) { { :job_template_id => trying_job_template_1.id.to_s } }
167
168
  let(:ansible_params) { { :job_template_id => unauthorized.id.to_s } }
168
169
  let(:mcollective_params) { { :job_template_id => mcollective_authorized.id.to_s } }
@@ -270,7 +271,7 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
270
271
  composer.displayed_search_query.must_be_empty
271
272
  end
272
273
 
273
- let(:host) { FactoryGirl.create(:host) }
274
+ let(:host) { FactoryBot.create(:host) }
274
275
  let(:bookmark) { Bookmark.create!(:query => 'b', :name => 'bookmark', :public => true, :controller => 'hosts') }
275
276
 
276
277
  context 'all targetings parameters are present' do
@@ -336,7 +337,7 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
336
337
  end
337
338
 
338
339
  describe '#targeted_hosts_count' do
339
- let(:host) { FactoryGirl.create(:host) }
340
+ let(:host) { FactoryBot.create(:host) }
340
341
 
341
342
  it 'obeys authorization' do
342
343
  composer.stubs(:displayed_search_query => "name = #{host.name}")
@@ -402,7 +403,7 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
402
403
  end
403
404
 
404
405
  describe '#valid?' do
405
- let(:host) { FactoryGirl.create(:host) }
406
+ let(:host) { FactoryBot.create(:host) }
406
407
  let(:ssh_params) do
407
408
  { :job_template_id => trying_job_template_1.id.to_s,
408
409
  :job_templates => {
@@ -484,7 +485,7 @@ class JobInvocationComposerTest < ActiveSupport::TestCase
484
485
  end
485
486
 
486
487
  describe '#compose_from_invocation(existing_invocation)' do
487
- let(:host) { FactoryGirl.create(:host) }
488
+ let(:host) { FactoryBot.create(:host) }
488
489
  let(:ssh_params) do
489
490
  { :job_template_id => trying_job_template_1.id.to_s,
490
491
  :job_templates => {
@@ -1,8 +1,8 @@
1
1
  require 'test_plugin_helper'
2
2
 
3
3
  class JobInvocationTest < ActiveSupport::TestCase
4
- let(:job_invocation) { FactoryGirl.build(:job_invocation) }
5
- let(:template) { FactoryGirl.create(:job_template, :with_input) }
4
+ let(:job_invocation) { FactoryBot.build(:job_invocation) }
5
+ let(:template) { FactoryBot.create(:job_template, :with_input) }
6
6
 
7
7
  context 'search for job invocations' do
8
8
  before do
@@ -27,7 +27,7 @@ class JobInvocationTest < ActiveSupport::TestCase
27
27
 
28
28
  context 'can delete a host' do
29
29
  let(:host) do
30
- FactoryGirl.create(:host)
30
+ FactoryBot.create(:host)
31
31
  end
32
32
 
33
33
  it 'can remove a host' do
@@ -40,17 +40,17 @@ class JobInvocationTest < ActiveSupport::TestCase
40
40
  end
41
41
 
42
42
  context 'has template invocations with input values' do
43
- let(:job_invocation) { FactoryGirl.create(:job_invocation, :with_template) }
43
+ let(:job_invocation) { FactoryBot.create(:job_invocation, :with_template) }
44
44
 
45
45
  before do
46
46
  input = job_invocation.pattern_template_invocations.first.template.template_inputs.create!(:name => 'foo', :required => true, :input_type => 'user')
47
47
  input2 = job_invocation.pattern_template_invocations.first.template.template_inputs.create!(:name => 'bar', :required => true, :input_type => 'user')
48
- FactoryGirl.create(:template_invocation_input_value,
49
- :template_invocation => job_invocation.pattern_template_invocations.first,
50
- :template_input => input2)
51
- @input_value = FactoryGirl.create(:template_invocation_input_value,
52
- :template_invocation => job_invocation.pattern_template_invocations.first,
53
- :template_input => input)
48
+ FactoryBot.create(:template_invocation_input_value,
49
+ :template_invocation => job_invocation.pattern_template_invocations.first,
50
+ :template_input => input2)
51
+ @input_value = FactoryBot.create(:template_invocation_input_value,
52
+ :template_invocation => job_invocation.pattern_template_invocations.first,
53
+ :template_input => input)
54
54
  job_invocation.reload
55
55
  job_invocation.pattern_template_invocations.first.reload
56
56
  end
@@ -1,7 +1,7 @@
1
1
  require 'test_plugin_helper'
2
2
 
3
3
  class JobTemplateEffectiveUserTest < ActiveSupport::TestCase
4
- let(:job_template) { FactoryGirl.build(:job_template, :job_category => '') }
4
+ let(:job_template) { FactoryBot.build(:job_template, :job_category => '') }
5
5
  let(:effective_user) { job_template.effective_user }
6
6
 
7
7
  before do
@@ -20,7 +20,7 @@ class JobTemplateEffectiveUserTest < ActiveSupport::TestCase
20
20
 
21
21
  describe 'compute value' do
22
22
  it 'computes the value based on the current user when current_user set to true' do
23
- user = FactoryGirl.create(:user)
23
+ user = FactoryBot.create(:user)
24
24
  User.current = user
25
25
  effective_user.current_user = true
26
26
  effective_user.compute_value.must_equal user.login
@@ -5,7 +5,7 @@ class JobTemplateImporterTest < ActiveSupport::TestCase
5
5
  # JobTemplate tests handle most of this, we just check that the shim
6
6
  # correctly loads a template returns a hash
7
7
  let(:remote_execution_feature) do
8
- FactoryGirl.create(:remote_execution_feature)
8
+ FactoryBot.create(:remote_execution_feature)
9
9
  end
10
10
 
11
11
  let(:result) do
@@ -46,7 +46,7 @@ class JobTemplateImporterTest < ActiveSupport::TestCase
46
46
  context 'updating locked template' do
47
47
  it 'does not update locked template' do
48
48
  name = 'Locked job template'
49
- template = FactoryGirl.create(:job_template, :locked => true, :name => name)
49
+ template = FactoryBot.create(:job_template, :locked => true, :name => name)
50
50
  res = JobTemplateImporter.import!(name, 'some text', 'metadata')
51
51
  assert_equal "Skipping Template #{template.id}:#{template.name} - template is locked", res[:result]
52
52
  end
@@ -58,7 +58,7 @@ class JobTemplateImporterTest < ActiveSupport::TestCase
58
58
  'kind' => 'job_template',
59
59
  'name' => name
60
60
  }
61
- template = FactoryGirl.create(:job_template, :locked => true, :name => name)
61
+ template = FactoryBot.create(:job_template, :locked => true, :name => name)
62
62
  res = JobTemplateImporter.import!(name, 'some text', metadata, true)
63
63
  assert_equal " Updated Template #{template.id}:Locked job template again", res[:result]
64
64
  end
@@ -2,17 +2,17 @@ require 'test_plugin_helper'
2
2
 
3
3
  class JobTemplateTest < ActiveSupport::TestCase
4
4
  context 'when creating a template' do
5
- let(:job_template) { FactoryGirl.build(:job_template, :job_category => '') }
5
+ let(:job_template) { FactoryBot.build(:job_template, :job_category => '') }
6
6
  let(:template_with_inputs) do
7
- FactoryGirl.build(:job_template, :template => 'test').tap do |template|
8
- template.template_inputs << FactoryGirl.build(:template_input, :name => 'command', :input_type => 'user')
7
+ FactoryBot.build(:job_template, :template => 'test').tap do |template|
8
+ template.template_inputs << FactoryBot.build(:template_input, :name => 'command', :input_type => 'user')
9
9
  template.save!
10
10
  end
11
11
  end
12
12
 
13
13
  it 'has a unique name' do
14
- template1 = FactoryGirl.create(:job_template)
15
- template2 = FactoryGirl.build(:job_template, :name => template1.name)
14
+ template1 = FactoryBot.create(:job_template)
15
+ template2 = FactoryBot.build(:job_template, :name => template1.name)
16
16
  refute template2.valid?
17
17
  end
18
18
 
@@ -27,17 +27,17 @@ class JobTemplateTest < ActiveSupport::TestCase
27
27
 
28
28
  it 'validates the inputs are uniq in the template' do
29
29
  job_template.job_category = 'Miscellaneous'
30
- job_template.foreign_input_sets << FactoryGirl.build(:foreign_input_set, :target_template => template_with_inputs)
31
- job_template.foreign_input_sets << FactoryGirl.build(:foreign_input_set, :target_template => template_with_inputs)
30
+ job_template.foreign_input_sets << FactoryBot.build(:foreign_input_set, :target_template => template_with_inputs)
31
+ job_template.foreign_input_sets << FactoryBot.build(:foreign_input_set, :target_template => template_with_inputs)
32
32
  refute job_template.valid?
33
33
  job_template.errors.full_messages.first.must_include 'Duplicated inputs detected: ["command"]'
34
34
  end
35
35
  end
36
36
 
37
37
  context 'description format' do
38
- let(:template_with_description) { FactoryGirl.build(:job_template, :with_description_format, :job_category => 'test job') }
39
- let(:template) { FactoryGirl.build(:job_template, :with_input, :job_category => 'test job') }
40
- let(:minimal_template) { FactoryGirl.build(:job_template) }
38
+ let(:template_with_description) { FactoryBot.build(:job_template, :with_description_format, :job_category => 'test job') }
39
+ let(:template) { FactoryBot.build(:job_template, :with_input, :job_category => 'test job') }
40
+ let(:minimal_template) { FactoryBot.build(:job_template) }
41
41
 
42
42
  it 'uses the description_format attribute if set' do
43
43
  template_with_description.generate_description_format.must_equal template_with_description.description_format
@@ -59,7 +59,7 @@ class JobTemplateTest < ActiveSupport::TestCase
59
59
  end
60
60
 
61
61
  context 'cloning' do
62
- let(:job_template) { FactoryGirl.build(:job_template, :with_input) }
62
+ let(:job_template) { FactoryBot.build(:job_template, :with_input) }
63
63
 
64
64
  describe '#dup' do
65
65
  it 'duplicates also template inputs' do
@@ -74,7 +74,7 @@ class JobTemplateTest < ActiveSupport::TestCase
74
74
 
75
75
  context 'importing a new template' do
76
76
  let(:remote_execution_feature) do
77
- FactoryGirl.create(:remote_execution_feature)
77
+ FactoryBot.create(:remote_execution_feature)
78
78
  end
79
79
 
80
80
  let(:template) do
@@ -239,7 +239,7 @@ class JobTemplateTest < ActiveSupport::TestCase
239
239
 
240
240
  context 'template export' do
241
241
  let(:exportable_template) do
242
- FactoryGirl.create(:job_template, :with_input)
242
+ FactoryBot.create(:job_template, :with_input)
243
243
  end
244
244
 
245
245
  let(:erb) do
@@ -270,7 +270,7 @@ class JobTemplateTest < ActiveSupport::TestCase
270
270
  end
271
271
 
272
272
  context 'there is existing template invocation of a job template' do
273
- let(:job_invocation) { FactoryGirl.create(:job_invocation, :with_template) }
273
+ let(:job_invocation) { FactoryBot.create(:job_invocation, :with_template) }
274
274
  let(:job_template) { job_invocation.pattern_template_invocations.first.template }
275
275
 
276
276
  describe 'job template deletion' do
@@ -283,7 +283,7 @@ class JobTemplateTest < ActiveSupport::TestCase
283
283
 
284
284
  context 'template locked' do
285
285
  it 'inputs cannot be changed' do
286
- job_template = FactoryGirl.create(:job_template, :with_input, :locked => true)
286
+ job_template = FactoryBot.create(:job_template, :with_input, :locked => true)
287
287
  Foreman.expects(:in_rake?).returns(false).at_least_once
288
288
  assert_valid job_template
289
289
  job_template.template_inputs.first.name = 'something else'
@@ -13,14 +13,14 @@ class RemoteExecutionFeatureTest < ActiveSupport::TestCase
13
13
  end
14
14
 
15
15
  let(:package_template) do
16
- FactoryGirl.create(:job_template).tap do |job_template|
16
+ FactoryBot.create(:job_template).tap do |job_template|
17
17
  job_template.job_category = 'Package Action'
18
18
  job_template.name = 'Package Action - SSH Default'
19
19
  job_template.template_inputs.create(:name => 'package', :input_type => 'user')
20
20
  end
21
21
  end
22
22
 
23
- let(:host) { FactoryGirl.create(:host) }
23
+ let(:host) { FactoryBot.create(:host) }
24
24
 
25
25
  before do
26
26
  User.current = users :admin
@@ -76,7 +76,7 @@ class RemoteExecutionFeatureTest < ActiveSupport::TestCase
76
76
 
77
77
 
78
78
  it 'updates a feature if it exists' do
79
- existing = FactoryGirl.create(:remote_execution_feature, :name => 'existing_feature_withou_action_button')
79
+ existing = FactoryBot.create(:remote_execution_feature, :name => 'existing_feature_withou_action_button')
80
80
  feature = RemoteExecutionFeature.register(existing.label, existing.name, :host_action_button => true)
81
81
  feature.must_be :persisted?
82
82
  existing.reload
@@ -51,16 +51,16 @@ class RemoteExecutionProviderTest < ActiveSupport::TestCase
51
51
  end
52
52
 
53
53
  describe SSHExecutionProvider do
54
- before { User.current = FactoryGirl.build(:user, :admin) }
54
+ before { User.current = FactoryBot.build(:user, :admin) }
55
55
  after { User.current = nil }
56
56
 
57
57
  before do
58
58
  Setting::RemoteExecution.load_defaults
59
59
  end
60
60
 
61
- let(:job_invocation) { FactoryGirl.create(:job_invocation, :with_template) }
61
+ let(:job_invocation) { FactoryBot.create(:job_invocation, :with_template) }
62
62
  let(:template_invocation) { job_invocation.pattern_template_invocations.first }
63
- let(:host) { FactoryGirl.create(:host) }
63
+ let(:host) { FactoryBot.create(:host) }
64
64
  let(:proxy_options) { SSHExecutionProvider.proxy_command_options(template_invocation, host) }
65
65
 
66
66
  describe 'effective user' do
@@ -73,7 +73,7 @@ class RemoteExecutionProviderTest < ActiveSupport::TestCase
73
73
  describe 'ssh user' do
74
74
  it 'uses the remote_execution_ssh_user on the host param' do
75
75
  host.params['remote_execution_ssh_user'] = 'my user'
76
- host.host_parameters << FactoryGirl.create(:host_parameter, :host => host, :name => 'remote_execution_ssh_user', :value => 'my user')
76
+ host.host_parameters << FactoryBot.create(:host_parameter, :host => host, :name => 'remote_execution_ssh_user', :value => 'my user')
77
77
  proxy_options[:ssh_user].must_equal 'my user'
78
78
  end
79
79
  end
@@ -81,7 +81,7 @@ class RemoteExecutionProviderTest < ActiveSupport::TestCase
81
81
  describe 'sudo' do
82
82
  it 'uses the remote_execution_ssh_user on the host param' do
83
83
  host.params['remote_execution_effective_user_method'] = 'sudo'
84
- method_param = FactoryGirl.create(:host_parameter, :host => host, :name => 'remote_execution_effective_user_method', :value => 'sudo')
84
+ method_param = FactoryBot.create(:host_parameter, :host => host, :name => 'remote_execution_effective_user_method', :value => 'sudo')
85
85
  host.host_parameters << method_param
86
86
  proxy_options[:effective_user_method].must_equal 'sudo'
87
87
  method_param.update_attributes!(:value => 'su')
@@ -105,7 +105,7 @@ class RemoteExecutionProviderTest < ActiveSupport::TestCase
105
105
  describe 'ssh port from params' do
106
106
  it 'takes ssh port number from params and check return type' do
107
107
  host.params['remote_execution_ssh_port'] = '30'
108
- host.host_parameters << FactoryGirl.build(:host_parameter, :name => 'remote_execution_ssh_port', :value => '30')
108
+ host.host_parameters << FactoryBot.build(:host_parameter, :name => 'remote_execution_ssh_port', :value => '30')
109
109
  host.clear_host_parameters_cache!
110
110
  proxy_options[:ssh_port].must_be_kind_of Integer
111
111
  proxy_options[:ssh_port].must_equal 30
@@ -114,9 +114,9 @@ class RemoteExecutionProviderTest < ActiveSupport::TestCase
114
114
 
115
115
  describe '#find_ip_or_hostname' do
116
116
  let(:host) do
117
- FactoryGirl.create(:host) do |host|
118
- host.interfaces = [FactoryGirl.build(:nic_managed, flags.merge(:ip => nil, :name => 'somehost.somedomain.org', :primary => true)),
119
- FactoryGirl.build(:nic_managed, flags.merge(:ip => '127.0.0.1'))]
117
+ FactoryBot.create(:host) do |host|
118
+ host.interfaces = [FactoryBot.build(:nic_managed, flags.merge(:ip => nil, :name => 'somehost.somedomain.org', :primary => true)),
119
+ FactoryBot.build(:nic_managed, flags.merge(:ip => '127.0.0.1'))]
120
120
  end
121
121
  end
122
122
 
@@ -129,8 +129,8 @@ class RemoteExecutionProviderTest < ActiveSupport::TestCase
129
129
  SSHExecutionProvider.find_ip_or_hostname(host).must_equal 'somehost.somedomain.org'
130
130
 
131
131
  # execution wins if present
132
- execution_interface = FactoryGirl.build(:nic_managed,
133
- flags.merge(:execution => true, :name => 'special.somedomain.org'))
132
+ execution_interface = FactoryBot.build(:nic_managed,
133
+ flags.merge(:execution => true, :name => 'special.somedomain.org'))
134
134
  host.interfaces << execution_interface
135
135
  host.primary_interface.update_attributes(:execution => false)
136
136
  host.interfaces.each(&:save)
@@ -144,8 +144,8 @@ class RemoteExecutionProviderTest < ActiveSupport::TestCase
144
144
  SSHExecutionProvider.find_ip_or_hostname(host).must_equal 'somehost.somedomain.org'
145
145
 
146
146
  # provision interface with ip while primary without
147
- provision_interface = FactoryGirl.build(:nic_managed,
148
- flags.merge(:provision => true, :ip => '10.0.0.1'))
147
+ provision_interface = FactoryBot.build(:nic_managed,
148
+ flags.merge(:provision => true, :ip => '10.0.0.1'))
149
149
  host.interfaces << provision_interface
150
150
  host.primary_interface.update_attributes(:provision => false)
151
151
  host.interfaces.each(&:save)
@@ -158,8 +158,8 @@ class RemoteExecutionProviderTest < ActiveSupport::TestCase
158
158
  SSHExecutionProvider.find_ip_or_hostname(host).must_equal host.primary_interface.ip
159
159
 
160
160
  # there is an execution interface with IP: it wins
161
- execution_interface = FactoryGirl.build(:nic_managed,
162
- flags.merge(:execution => true, :ip => '10.0.0.3'))
161
+ execution_interface = FactoryBot.build(:nic_managed,
162
+ flags.merge(:execution => true, :ip => '10.0.0.3'))
163
163
  host.interfaces << execution_interface
164
164
  host.primary_interface.update_attributes(:execution => false)
165
165
  host.interfaces.each(&:save)
@@ -1,9 +1,9 @@
1
1
  require 'test_plugin_helper'
2
2
 
3
3
  class TargetingTest < ActiveSupport::TestCase
4
- let(:targeting) { FactoryGirl.build(:targeting) }
4
+ let(:targeting) { FactoryBot.build(:targeting) }
5
5
  let(:bookmark) { bookmarks(:one) }
6
- let(:host) { FactoryGirl.create(:host) }
6
+ let(:host) { FactoryBot.create(:host) }
7
7
 
8
8
  before do
9
9
  bookmark.query = 'name = bar'
@@ -78,7 +78,7 @@ class TargetingTest < ActiveSupport::TestCase
78
78
  end
79
79
 
80
80
  describe '#build_query_from_hosts(ids)' do
81
- let(:second_host) { FactoryGirl.create(:host) }
81
+ let(:second_host) { FactoryBot.create(:host) }
82
82
 
83
83
  before do
84
84
  host
@@ -1,7 +1,7 @@
1
1
  require 'test_plugin_helper'
2
2
 
3
3
  class TemplateInputTest < ActiveSupport::TestCase
4
- let(:template_input) { FactoryGirl.build(:template_input) }
4
+ let(:template_input) { FactoryBot.build(:template_input) }
5
5
 
6
6
  context 'export' do
7
7
  before do
@@ -1,38 +1,38 @@
1
1
  require 'test_plugin_helper'
2
2
 
3
3
  class TemplateInvocationInputTest < ActiveSupport::TestCase
4
- let(:template) { FactoryGirl.build(:job_template, :template => 'service restart <%= input("service_name") -%>') }
4
+ let(:template) { FactoryBot.build(:job_template, :template => 'service restart <%= input("service_name") -%>') }
5
5
  let(:renderer) { InputTemplateRenderer.new(template) }
6
- let(:job_invocation) { FactoryGirl.create(:job_invocation) }
7
- let(:template_invocation) { FactoryGirl.build(:template_invocation, :template => template) }
6
+ let(:job_invocation) { FactoryBot.create(:job_invocation) }
7
+ let(:template_invocation) { FactoryBot.build(:template_invocation, :template => template) }
8
8
  let(:result) { renderer.render }
9
9
 
10
10
  context 'with selectable options' do
11
11
  before do
12
12
  result # let is lazy
13
- template.template_inputs << FactoryGirl.build(:template_input, :name => 'service_name', :input_type => 'user',
14
- :required => true, :options => "foreman\nhttpd")
13
+ template.template_inputs << FactoryBot.build(:template_input, :name => 'service_name', :input_type => 'user',
14
+ :required => true, :options => "foreman\nhttpd")
15
15
  end
16
16
 
17
17
  it 'fails with an invalid option' do
18
- refute_valid FactoryGirl.build(:template_invocation_input_value, :template_invocation => template_invocation,
19
- :template_input => template.template_inputs.first,
20
- :value => 'sendmail')
18
+ refute_valid FactoryBot.build(:template_invocation_input_value, :template_invocation => template_invocation,
19
+ :template_input => template.template_inputs.first,
20
+ :value => 'sendmail')
21
21
  end
22
22
 
23
23
  it 'succeeds with valid option' do
24
- assert_valid FactoryGirl.build(:template_invocation_input_value, :template_invocation => template_invocation,
25
- :template_input => template.template_inputs.first,
26
- :value => 'foreman')
24
+ assert_valid FactoryBot.build(:template_invocation_input_value, :template_invocation => template_invocation,
25
+ :template_input => template.template_inputs.first,
26
+ :value => 'foreman')
27
27
  end
28
28
  end
29
29
 
30
30
  it 'supports large inputs' do
31
- template.template_inputs << FactoryGirl.build(:template_input, :name => 'service_name',
32
- :input_type => 'user', :required => true)
33
- assert_valid FactoryGirl.create(:template_invocation_input_value,
34
- :template_invocation => template_invocation,
35
- :template_input => template.template_inputs.first,
36
- :value => 'foreman' * 1_000_000)
31
+ template.template_inputs << FactoryBot.build(:template_input, :name => 'service_name',
32
+ :input_type => 'user', :required => true)
33
+ assert_valid FactoryBot.create(:template_invocation_input_value,
34
+ :template_invocation => template_invocation,
35
+ :template_input => template.template_inputs.first,
36
+ :value => 'foreman' * 1_000_000)
37
37
  end
38
38
  end