foreman_remote_execution 3.0.2 → 3.2.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 (112) hide show
  1. checksums.yaml +4 -4
  2. data/.hound.yml +2 -1
  3. data/.rubocop.yml +80 -50
  4. data/.rubocop_todo.yml +113 -73
  5. data/Gemfile +4 -0
  6. data/app/controllers/api/v2/foreign_input_sets_controller.rb +3 -2
  7. data/app/controllers/api/v2/job_invocations_controller.rb +12 -7
  8. data/app/controllers/api/v2/job_templates_controller.rb +3 -2
  9. data/app/controllers/api/v2/remote_execution_features_controller.rb +3 -2
  10. data/app/controllers/api/v2/template_invocations_controller.rb +5 -2
  11. data/app/controllers/cockpit_controller.rb +1 -0
  12. data/app/controllers/concerns/foreman/controller/parameters/foreign_input_set.rb +1 -1
  13. data/app/controllers/concerns/foreman/controller/parameters/job_template.rb +4 -4
  14. data/app/controllers/job_invocations_controller.rb +10 -6
  15. data/app/controllers/job_templates_controller.rb +1 -1
  16. data/app/controllers/remote_execution_features_controller.rb +3 -2
  17. data/app/helpers/concerns/foreman_remote_execution/hosts_helper_extensions.rb +16 -5
  18. data/app/helpers/job_invocations_chart_helper.rb +13 -10
  19. data/app/helpers/job_invocations_helper.rb +19 -6
  20. data/app/helpers/remote_execution_helper.rb +49 -48
  21. data/app/lib/actions/remote_execution/run_host_job.rb +5 -6
  22. data/app/lib/actions/remote_execution/run_hosts_job.rb +2 -2
  23. data/app/lib/foreman_remote_execution/renderer/scope/input.rb +1 -0
  24. data/app/lib/proxy_api/remote_execution_ssh.rb +6 -0
  25. data/app/models/concerns/foreman_remote_execution/errors_flattener.rb +0 -2
  26. data/app/models/concerns/foreman_remote_execution/host_extensions.rb +4 -6
  27. data/app/models/concerns/foreman_remote_execution/nic_extensions.rb +1 -0
  28. data/app/models/concerns/foreman_remote_execution/orchestration/ssh.rb +63 -0
  29. data/app/models/concerns/foreman_remote_execution/smart_proxy_extensions.rb +5 -0
  30. data/app/models/foreign_input_set.rb +3 -2
  31. data/app/models/host_status/execution_status.rb +9 -1
  32. data/app/models/input_template_renderer.rb +1 -1
  33. data/app/models/job_invocation.rb +10 -12
  34. data/app/models/job_invocation_composer.rb +20 -14
  35. data/app/models/job_invocation_task_group.rb +1 -1
  36. data/app/models/job_template.rb +3 -3
  37. data/app/models/remote_execution_feature.rb +0 -2
  38. data/app/models/remote_execution_provider.rb +4 -2
  39. data/app/models/setting/remote_execution.rb +54 -56
  40. data/app/models/ssh_execution_provider.rb +2 -2
  41. data/app/models/targeting.rb +1 -0
  42. data/app/models/template_invocation.rb +2 -3
  43. data/app/views/api/v2/job_invocations/base.json.rabl +1 -1
  44. data/app/views/api/v2/job_invocations/main.json.rabl +7 -4
  45. data/app/views/job_invocations/_card_results.html.erb +1 -0
  46. data/app/views/job_invocations/_card_target_hosts.html.erb +12 -0
  47. data/app/views/job_invocations/_card_user_input.html.erb +1 -1
  48. data/app/views/job_invocations/_form.html.erb +3 -2
  49. data/app/views/job_invocations/_host_status_td.html.erb +1 -1
  50. data/app/views/job_invocations/_rerun_taxonomies.html.erb +22 -0
  51. data/app/views/job_invocations/_tab_overview.html.erb +1 -1
  52. data/app/views/job_invocations/_user_input.html.erb +1 -1
  53. data/app/views/job_invocations/show.html.erb +3 -1
  54. data/config/routes.rb +2 -1
  55. data/db/migrate/20151215114631_add_host_id_to_template_invocation.rb +1 -0
  56. data/db/migrate/20180110104432_rename_template_invocation_permission.rb +1 -0
  57. data/db/seeds.d/50-notification_blueprints.rb +4 -4
  58. data/db/seeds.d/90-bookmarks.rb +1 -0
  59. data/extra/cockpit/foreman-cockpit-session +7 -2
  60. data/foreman_remote_execution.gemspec +1 -1
  61. data/lib/foreman_remote_execution/engine.rb +20 -17
  62. data/lib/foreman_remote_execution/version.rb +1 -1
  63. data/locale/action_names.rb +4 -3
  64. data/locale/de/LC_MESSAGES/foreman_remote_execution.mo +0 -0
  65. data/locale/de/foreman_remote_execution.po +65 -16
  66. data/locale/en/foreman_remote_execution.po +63 -15
  67. data/locale/en_GB/LC_MESSAGES/foreman_remote_execution.mo +0 -0
  68. data/locale/en_GB/foreman_remote_execution.po +64 -15
  69. data/locale/es/LC_MESSAGES/foreman_remote_execution.mo +0 -0
  70. data/locale/es/foreman_remote_execution.po +66 -17
  71. data/locale/foreman_remote_execution.pot +193 -148
  72. data/locale/fr/LC_MESSAGES/foreman_remote_execution.mo +0 -0
  73. data/locale/fr/foreman_remote_execution.po +66 -17
  74. data/locale/ja/LC_MESSAGES/foreman_remote_execution.mo +0 -0
  75. data/locale/ja/foreman_remote_execution.po +66 -17
  76. data/locale/ko/LC_MESSAGES/foreman_remote_execution.mo +0 -0
  77. data/locale/ko/foreman_remote_execution.po +65 -15
  78. data/locale/pt_BR/LC_MESSAGES/foreman_remote_execution.mo +0 -0
  79. data/locale/pt_BR/foreman_remote_execution.po +66 -17
  80. data/locale/ru/LC_MESSAGES/foreman_remote_execution.mo +0 -0
  81. data/locale/ru/foreman_remote_execution.po +65 -18
  82. data/locale/zh_CN/LC_MESSAGES/foreman_remote_execution.mo +0 -0
  83. data/locale/zh_CN/foreman_remote_execution.po +66 -17
  84. data/locale/zh_TW/LC_MESSAGES/foreman_remote_execution.mo +0 -0
  85. data/locale/zh_TW/foreman_remote_execution.po +65 -16
  86. data/package.json +2 -3
  87. data/test/benchmark/run_hosts_job_benchmark.rb +1 -1
  88. data/test/factories/foreman_remote_execution_factories.rb +1 -1
  89. data/test/functional/api/v2/job_invocations_controller_test.rb +51 -23
  90. data/test/functional/api/v2/job_templates_controller_test.rb +1 -1
  91. data/test/functional/api/v2/remote_execution_features_controller_test.rb +2 -2
  92. data/test/functional/api/v2/template_invocations_controller_test.rb +4 -4
  93. data/test/functional/job_invocations_controller_test.rb +23 -11
  94. data/test/functional/job_templates_controller_test.rb +1 -1
  95. data/test/models/orchestration/ssh_test.rb +56 -0
  96. data/test/unit/actions/run_hosts_job_test.rb +8 -8
  97. data/test/unit/concerns/foreman_tasks_cleaner_extensions_test.rb +3 -3
  98. data/test/unit/concerns/host_extensions_test.rb +26 -19
  99. data/test/unit/concerns/nic_extensions_test.rb +1 -1
  100. data/test/unit/execution_task_status_mapper_test.rb +10 -10
  101. data/test/unit/input_template_renderer_test.rb +77 -77
  102. data/test/unit/job_invocation_composer_test.rb +100 -96
  103. data/test/unit/job_invocation_test.rb +29 -29
  104. data/test/unit/job_template_effective_user_test.rb +3 -3
  105. data/test/unit/job_template_test.rb +31 -31
  106. data/test/unit/remote_execution_feature_test.rb +19 -19
  107. data/test/unit/remote_execution_provider_test.rb +33 -30
  108. data/test/unit/renderer_scope_input.rb +6 -6
  109. data/test/unit/targeting_test.rb +6 -6
  110. data/test/unit/template_invocation_input_value_test.rb +3 -3
  111. data/webpack/index.js +0 -15
  112. metadata +8 -4
@@ -26,11 +26,6 @@ msgstr "%s 之前"
26
26
  msgid "%{description} on %{host}"
27
27
  msgstr "%{description} 於 %{host} 之上"
28
28
 
29
- msgid "...and %{count} more"
30
- msgid_plural "...and %{count} more"
31
- msgstr[0] ""
32
- msgstr[1] ""
33
-
34
29
  msgid "A comma separated list of input names to be excluded from the foreign template."
35
30
  msgstr "從外部範本排除的輸入名稱清單,以逗號隔開。"
36
31
 
@@ -58,12 +53,21 @@ msgstr "動作"
58
53
  msgid "Add Foreign Input Set"
59
54
  msgstr "新增外部輸入集"
60
55
 
56
+ msgid "Alphabetical"
57
+ msgstr ""
58
+
61
59
  msgid "Amount of workers in the pool to handle the execution of the remote execution jobs. Restart of the dynflowd/foreman-tasks service is required."
62
60
  msgstr ""
63
61
 
64
62
  msgid "Another interface is already set as execution. Are you sure you want to use this one instead?"
65
63
  msgstr "另一個介面已設為執行。行您是否確定要使用此介面?"
66
64
 
65
+ msgid "Any Location"
66
+ msgstr ""
67
+
68
+ msgid "Any Organization"
69
+ msgstr ""
70
+
67
71
  msgid "Back to Job"
68
72
  msgstr "回到工作"
69
73
 
@@ -91,6 +95,9 @@ msgstr "無法指定 bookmark_id 和 search_query"
91
95
  msgid "Cannot specify both recurrence and scheduling"
92
96
  msgstr "無法指定 recurrence 和 scheduling"
93
97
 
98
+ msgid "Choose a job template that is pre-selected in job invocation form"
99
+ msgstr ""
100
+
94
101
  msgid "Circular dependency detected in foreign input set '%{template}' -> '%{target_template}'. Templates stack: %{templates_stack}"
95
102
  msgstr "在外部輸入集偵測到環狀相依性: '%{template}' -> '%{target_template}'。範本堆疊:%{templates_stack}"
96
103
 
@@ -145,6 +152,12 @@ msgstr "建立工作範本"
145
152
  msgid "Create a recurring job"
146
153
  msgstr "建立週期性工作"
147
154
 
155
+ msgid "Current location %{loc_c} is different from job's location %{loc_j}."
156
+ msgstr ""
157
+
158
+ msgid "Current organization %{org_c} is different from job's organization %{org_j}."
159
+ msgstr ""
160
+
148
161
  msgid "Default SSH key passphrase"
149
162
  msgstr ""
150
163
 
@@ -178,8 +191,8 @@ msgstr "描述範本"
178
191
  msgid "Display advanced fields"
179
192
  msgstr "顯示進階欄位"
180
193
 
181
- msgid "Distribute execution over N seconds"
182
- msgstr "在幾秒間散佈執行"
194
+ msgid "Distribute execution over N seconds. If this is set and proxy batch triggering is enabled, then tasks are triggered on the smart proxy in batches of size 1."
195
+ msgstr ""
183
196
 
184
197
  msgid "Distribute tasks over N seconds"
185
198
  msgstr "在幾秒間散佈工作"
@@ -223,9 +236,21 @@ msgstr "從代理載入資料時發生錯誤"
223
236
  msgid "Evaluated at:"
224
237
  msgstr "評量於:"
225
238
 
239
+ msgid "Execute the jobs on hosts in randomized order"
240
+ msgstr ""
241
+
226
242
  msgid "Execution"
227
243
  msgstr "執行"
228
244
 
245
+ msgid "Execution order"
246
+ msgstr ""
247
+
248
+ msgid "Execution ordering"
249
+ msgstr ""
250
+
251
+ msgid "Execution ordering determines whether the jobs should be executed on hosts in alphabetical order or in randomized order.<br><ul><li><b>Ordered</b> - executes the jobs on hosts in alphabetical order</li><li><b>Randomized</b> - randomizes the order in which jobs are executed on hosts</li></ul>"
252
+ msgstr ""
253
+
229
254
  msgid "Exit status: %s"
230
255
  msgstr "退出狀態:%s"
231
256
 
@@ -256,6 +281,9 @@ msgstr "外部輸入集"
256
281
  msgid "Foreman can run arbitrary commands on remote hosts using different providers, such as SSH or Ansible. Communication goes through the Smart Proxy so Foreman does not have to have direct access to the target hosts and can scale to control many hosts."
257
282
  msgstr ""
258
283
 
284
+ msgid "Form Job Template"
285
+ msgstr ""
286
+
259
287
  msgid "Get output for a host"
260
288
  msgstr "取得主機輸出"
261
289
 
@@ -376,6 +404,9 @@ msgstr ""
376
404
  msgid "Label"
377
405
  msgstr "標籤"
378
406
 
407
+ msgid "Last execution cancelled"
408
+ msgstr ""
409
+
379
410
  msgid "Last execution failed"
380
411
  msgstr "最後的執行失敗"
381
412
 
@@ -406,6 +437,9 @@ msgstr "列出遠端執行功能"
406
437
  msgid "List template invocations belonging to job invocation"
407
438
  msgstr ""
408
439
 
440
+ msgid "Location"
441
+ msgstr ""
442
+
409
443
  msgid "Manual selection"
410
444
  msgstr "手動選擇"
411
445
 
@@ -424,15 +458,15 @@ msgstr "新工作範本"
424
458
  msgid "No execution finished yet"
425
459
  msgstr "尚無執行完成"
426
460
 
427
- msgid "No hosts found."
428
- msgstr "找不到主機。"
429
-
430
461
  msgid "No template mapped to feature %{feature_name}"
431
462
  msgstr "沒有範本定義至功能 %{feature_name}"
432
463
 
433
464
  msgid "Not all required inputs have values. Missing inputs: %s"
434
465
  msgstr "並不是所需的輸入都有值。缺少的輸入:%s"
435
466
 
467
+ msgid "Organization"
468
+ msgstr ""
469
+
436
470
  msgid "Override the description format from the template for this invocation only"
437
471
  msgstr "僅為這祈願從範本覆寫描述格式"
438
472
 
@@ -457,6 +491,9 @@ msgstr ""
457
491
  msgid "Pending"
458
492
  msgstr "等待處理中"
459
493
 
494
+ msgid "Perform a single Puppet run"
495
+ msgstr ""
496
+
460
497
  msgid "Perform no more executions after this time"
461
498
  msgstr "此時間之後不再進行任何執行"
462
499
 
@@ -484,6 +521,9 @@ msgstr "供應者與範本"
484
521
  msgid "Proxies"
485
522
  msgstr "代理伺服器"
486
523
 
524
+ msgid "Randomized"
525
+ msgstr ""
526
+
487
527
  msgid "Recurring logic"
488
528
  msgstr "週期邏輯"
489
529
 
@@ -508,6 +548,9 @@ msgstr "遠端執行"
508
548
  msgid "Remote execution feature label that should be triggered, job template assigned to this feature will be used"
509
549
  msgstr ""
510
550
 
551
+ msgid "Remove SSH known hosts for %s"
552
+ msgstr ""
553
+
511
554
  msgid "Repeat a maximum of N times"
512
555
  msgstr "重複最多 N 次"
513
556
 
@@ -541,9 +584,15 @@ msgstr "執行"
541
584
  msgid "Run Job"
542
585
  msgstr "執行工作"
543
586
 
587
+ msgid "Run Puppet Once"
588
+ msgstr ""
589
+
544
590
  msgid "Run at most N tasks at a time"
545
591
  msgstr "一次最多執行 N 個任務"
546
592
 
593
+ msgid "Run at most N tasks at a time. If this is set and proxy batch triggering is enabled, then tasks are triggered on the smart proxy in batches of size 1."
594
+ msgstr ""
595
+
547
596
  msgid "SSH"
548
597
  msgstr "SSH"
549
598
 
@@ -586,8 +635,8 @@ msgstr "搜尋"
586
635
  msgid "Search Query"
587
636
  msgstr ""
588
637
 
589
- msgid "Search for remote execution proxy outside of the proxies assigned to the host. If locations or organizations are enabled, the search will be limited to the host's organization or location."
590
- msgstr "搜尋指定給主機的代理之外的遠端執行代理。如果位置或組織都已啟用,搜尋會被限制至主機的組織或地點。"
638
+ msgid "Search for remote execution proxy outside of the proxies assigned to the host. The search will be limited to the host's organization and location."
639
+ msgstr ""
591
640
 
592
641
  msgid "Search the host for any proxy with Remote Execution, useful when the host has no subnet or the subnet does not have an execution proxy"
593
642
  msgstr "使用遠端執行為代理搜尋主機,這在主機沒有子網路、或子網路沒有執行代理時很有用"
@@ -607,7 +656,7 @@ msgstr "為此子網路儘可能選擇遠端執行代理。加入有著同樣供
607
656
  msgid "Set to distribute over"
608
657
  msgstr ""
609
658
 
610
- msgid "Should the ip addresses on host interfaces be preferred over the fqdn? It is useful, when DNS not resolving the fqdns properly. You may override this per host by setting a parameter called remote_execution_connect_by_ip."
659
+ msgid "Should the ip addresses on host interfaces be preferred over the fqdn? It is useful when DNS not resolving the fqdns properly. You may override this per host by setting a parameter called remote_execution_connect_by_ip. This setting only applies to IPv4. When the host has only an IPv6 address on the interface used for remote execution, hostname will be used even if this setting is set to true."
611
660
  msgstr ""
612
661
 
613
662
  msgid "Show foreign input set details"
@@ -679,9 +728,6 @@ msgstr "範本版本"
679
728
  msgid "Template with id '%{id}' was not found"
680
729
  msgstr "找不到 ID 為 '%{id}' 的範本"
681
730
 
682
- msgid "The dynamic query '#{job_invocation.targeting.search_query}' was not resolved yet. The list of hosts to which it would resolve now can be seen"
683
- msgstr ""
684
-
685
731
  msgid "The dynamic query '%{query}' was not resolved yet. The list of hosts to which it would resolve now can be seen %{here}."
686
732
  msgstr "動態查詢 '%{query}' 尚未被解析。該解析的主機清單可以在 %{here} 找到。"
687
733
 
@@ -783,6 +829,9 @@ msgstr "查詢類型"
783
829
  msgid "Unable to fetch public key"
784
830
  msgstr "無法取得公開金鑰"
785
831
 
832
+ msgid "Unable to remove host from known hosts"
833
+ msgstr ""
834
+
786
835
  msgid "Unable to save template. Correct highlighted errors"
787
836
  msgstr ""
788
837
 
@@ -32,9 +32,8 @@
32
32
  },
33
33
  "devDependencies": {
34
34
  "@babel/core": "^7.7.0",
35
- "@theforeman/env": "^3.3.2",
36
35
  "@theforeman/builder": "^4.0.2",
37
- "@theforeman/vendor-dev": "^3.3.2",
36
+ "@theforeman/vendor-dev": "^4.0.2",
38
37
  "babel-eslint": "^10.0.0",
39
38
  "babel-jest": "^24.9.0",
40
39
  "enzyme": "^3.2.0",
@@ -49,6 +48,6 @@
49
48
  "jest": "^24.9.0"
50
49
  },
51
50
  "peerDependencies": {
52
- "@theforeman/vendor": ">= 3.3.2"
51
+ "@theforeman/vendor": ">= 4.0.2"
53
52
  }
54
53
  }
@@ -37,7 +37,7 @@ class ActionTester
37
37
 
38
38
  def run_action(*args)
39
39
  action = create_action(Actions::RemoteExecution::RunHostsJob)
40
- @task.update_attributes(:external_id => action.execution_plan_id)
40
+ @task.update(:external_id => action.execution_plan_id)
41
41
  plan_action(action, *args)
42
42
  end
43
43
  end
@@ -128,7 +128,7 @@ FactoryBot.modify do
128
128
  domain
129
129
  subnet do
130
130
  overrides = {
131
- :remote_execution_proxies => [FactoryBot.create(:smart_proxy, :ssh)]
131
+ :remote_execution_proxies => [FactoryBot.create(:smart_proxy, :ssh)],
132
132
  }
133
133
 
134
134
  overrides[:locations] = [location] unless location.nil?
@@ -4,7 +4,7 @@ module Api
4
4
  module V2
5
5
  class JobInvocationsControllerTest < ActionController::TestCase
6
6
  setup do
7
- @invocation = FactoryBot.create(:job_invocation, :with_template, :with_task)
7
+ @invocation = FactoryBot.create(:job_invocation, :with_template, :with_task, :with_unplanned_host)
8
8
  @template = FactoryBot.create(:job_template, :with_input)
9
9
 
10
10
  # Without this the template in template_invocations and in pattern_template_invocations
@@ -20,18 +20,32 @@ module Api
20
20
  assert_response :success
21
21
  end
22
22
 
23
- test 'should get invocation detail' do
24
- get :show, params: { :id => @invocation.id }
25
- assert_response :success
26
- template = ActiveSupport::JSON.decode(@response.body)
27
- assert_not_empty template
28
- assert_equal template['job_category'], @invocation.job_category
29
- end
23
+ describe 'show' do
24
+ test 'should get invocation detail' do
25
+ get :show, params: { :id => @invocation.id }
26
+ assert_response :success
27
+ template = ActiveSupport::JSON.decode(@response.body)
28
+ assert_not_empty template
29
+ assert_equal template['job_category'], @invocation.job_category
30
+ assert_not_empty template['targeting']['hosts']
31
+ end
30
32
 
31
- test 'should get invocation detail when taxonomies are set' do
32
- taxonomy_params = %w(organization location).reduce({}) { |acc, cur| acc.merge("#{cur}_id" => FactoryBot.create(cur)) }
33
- get :show, params: taxonomy_params.merge(:id => @invocation.id)
34
- assert_response :success
33
+ test 'should get invocation detail when taxonomies are set' do
34
+ taxonomy_params = %w(organization location).reduce({}) { |acc, cur| acc.merge("#{cur}_id" => FactoryBot.create(cur)) }
35
+ get :show, params: taxonomy_params.merge(:id => @invocation.id)
36
+ assert_response :success
37
+ end
38
+
39
+ test 'should see only permitted hosts' do
40
+ @user = FactoryBot.create(:user, admin: false)
41
+ setup_user('view', 'job_invocations', nil, @user)
42
+ setup_user('view', 'hosts', 'name ~ nope.example.com', @user)
43
+
44
+ get :show, params: { :id => @invocation.id }, session: set_session_user(@user)
45
+ assert_response :success
46
+ response = ActiveSupport::JSON.decode(@response.body)
47
+ assert_empty response['targeting']['hosts']
48
+ end
35
49
  end
36
50
 
37
51
  context 'creation' do
@@ -78,9 +92,9 @@ module Api
78
92
  context 'with_feature' do
79
93
  setup do
80
94
  @feature = FactoryBot.create(:remote_execution_feature,
81
- :job_template => @template)
95
+ :job_template => @template)
82
96
  @attrs = {
83
- feature: @feature.label
97
+ feature: @feature.label,
84
98
  }
85
99
  end
86
100
 
@@ -108,7 +122,7 @@ module Api
108
122
  end
109
123
 
110
124
  describe '#output' do
111
- let(:host) { @invocation.template_invocations_hosts.first }
125
+ let(:host) { @invocation.targeting.hosts.first }
112
126
 
113
127
  test 'should provide output for delayed task' do
114
128
  ForemanTasks::Task.any_instance.expects(:scheduled?).returns(true)
@@ -137,6 +151,12 @@ module Api
137
151
  assert_equal result['message'], "Job invocation not found by id '#{invocation_id}'"
138
152
  assert_response :missing
139
153
  end
154
+
155
+ test 'should get output only for host in job invocation' do
156
+ get :output, params: { job_invocation_id: @invocation.id,
157
+ host_id: FactoryBot.create(:host).id }
158
+ assert_response :missing
159
+ end
140
160
  end
141
161
 
142
162
  describe 'raw output' do
@@ -148,7 +168,7 @@ module Api
148
168
  let(:fake_task) do
149
169
  OpenStruct.new :pending? => false, :main_action => OpenStruct.new(:live_output => fake_output)
150
170
  end
151
- let(:host) { @invocation.template_invocations_hosts.first }
171
+ let(:host) { @invocation.targeting.hosts.first }
152
172
 
153
173
  test 'should provide raw output for a host' do
154
174
  JobInvocation.any_instance.expects(:task).returns(OpenStruct.new(:scheduled? => false))
@@ -171,7 +191,7 @@ module Api
171
191
  assert_equal result['complete'], false
172
192
  assert_equal result['delayed'], true
173
193
  assert_nil result['output']
174
- Time.parse(result['start_at']).to_f.must_be_close_to start_time.to_f
194
+ _(Time.parse(result['start_at']).to_f).must_be_close_to start_time.to_f
175
195
  assert_response :success
176
196
  end
177
197
 
@@ -184,6 +204,12 @@ module Api
184
204
  assert_nil result['output']
185
205
  assert_response :success
186
206
  end
207
+
208
+ test 'should get raw output only for host in job invocation' do
209
+ get :raw_output, params: { job_invocation_id: @invocation.id,
210
+ host_id: FactoryBot.create(:host).id }
211
+ assert_response :missing
212
+ end
187
213
  end
188
214
 
189
215
  test 'should cancel a job' do
@@ -227,22 +253,24 @@ module Api
227
253
  assert_response :success
228
254
  result = ActiveSupport::JSON.decode(@response.body)
229
255
  targeting = Targeting.find(result['targeting_id'])
230
- targeting.user_id.must_equal users(:admin).id
231
- targeting.search_query.must_equal @invocation.targeting.search_query
256
+ _(targeting.user_id).must_equal users(:admin).id
257
+ _(targeting.search_query).must_equal @invocation.targeting.search_query
232
258
  end
233
259
 
234
260
  test 'should not raise an exception when reruning failed has no hosts' do
261
+ @invocation.targeting.hosts.first.destroy
235
262
  JobInvocation.any_instance.expects(:generate_description)
236
263
  JobInvocationComposer.any_instance
237
264
  .expects(:validate_job_category)
238
265
  .with(@invocation.job_category)
239
266
  .returns(@invocation.job_category)
267
+
240
268
  post :rerun, params: { :id => @invocation.id, :failed_only => true }
241
269
  assert_response :success
242
270
  result = ActiveSupport::JSON.decode(@response.body)
243
271
  targeting = Targeting.find(result['targeting_id'])
244
- targeting.user_id.must_equal users(:admin).id
245
- targeting.search_query.must_equal 'name ^ ()'
272
+ _(targeting.user_id).must_equal users(:admin).id
273
+ _(targeting.search_query).must_equal 'name ^ ()'
246
274
  end
247
275
 
248
276
  test 'should rerun failed only' do
@@ -260,8 +288,8 @@ module Api
260
288
  result = ActiveSupport::JSON.decode(@response.body)
261
289
  targeting = Targeting.find(result['targeting_id'])
262
290
  hostnames = @invocation.template_invocations.map { |ti| ti.host.name }
263
- targeting.user_id.must_equal users(:admin).id
264
- targeting.search_query.must_equal "name ^ (#{hostnames.join(',')})"
291
+ _(targeting.user_id).must_equal users(:admin).id
292
+ _(targeting.search_query).must_equal "name ^ (#{hostnames.join(',')})"
265
293
  end
266
294
 
267
295
  test 'should return 404 if template is not found' do
@@ -39,7 +39,7 @@ module Api
39
39
  valid_attrs = { :template => 'This is a test template', :name => 'RandomName', :provider_type => 'ssh' }
40
40
  post :create, params: { :job_template => valid_attrs }
41
41
  template = ActiveSupport::JSON.decode(@response.body)
42
- assert template['name'] == 'RandomName'
42
+ assert_equal template['name'], 'RandomName'
43
43
  assert_response :success
44
44
  end
45
45
 
@@ -5,8 +5,8 @@ module Api
5
5
  class RemoteExecutionFeaturesControllerTest < ActionController::TestCase
6
6
  setup do
7
7
  @remote_execution_feature = RemoteExecutionFeature.register(:my_awesome_feature, 'My awesome feature',
8
- :description => 'You will not believe what it does',
9
- :provided_inputs => ['awesomeness_level'])
8
+ :description => 'You will not believe what it does',
9
+ :provided_inputs => ['awesomeness_level'])
10
10
  @template = FactoryBot.create(:job_template, :with_input)
11
11
  end
12
12
 
@@ -13,8 +13,8 @@ module Api
13
13
  test 'should get template invocations belonging to job invocation' do
14
14
  get :template_invocations, params: { :id => @job.id }
15
15
  invocations = ActiveSupport::JSON.decode(@response.body)
16
- invocations['results'].count.must_equal @job.template_invocations.count
17
- invocations['total'].must_equal @job.template_invocations.count
16
+ _(invocations['results'].count).must_equal @job.template_invocations.count
17
+ _(invocations['total']).must_equal @job.template_invocations.count
18
18
 
19
19
  expected_result = {
20
20
  'id' => @template_invocation.id,
@@ -23,9 +23,9 @@ module Api
23
23
  'template_id' => @template_invocation.template_id,
24
24
  'effective_user' => @template_invocation.effective_user,
25
25
  'job_invocation_id' => @job.id,
26
- 'run_host_job_task_id' => @template_invocation.run_host_job_task_id
26
+ 'run_host_job_task_id' => @template_invocation.run_host_job_task_id,
27
27
  }
28
- invocations['results'].must_equal [expected_result]
28
+ _(invocations['results']).must_equal [expected_result]
29
29
  assert_response :success
30
30
  end
31
31
  end