foreman_remote_execution 7.1.0 → 7.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b7c8e05850731a1f10e902deaa2e6797b869bb3363607af339e6a683225fa78a
4
- data.tar.gz: b5a2001957310aeb3a7353efa65592bae1dbb3fcabb68677516220674cea94b2
3
+ metadata.gz: 58d5205206634382e90cd1d8c9a75248fb6eb0268671a01cd03a3fc2f9ff1c25
4
+ data.tar.gz: a417fc114ad51630e41874b4dcb95e791d9ae26bcae087654ec13fcd984c4ba3
5
5
  SHA512:
6
- metadata.gz: 03daea7eb15788a97f841d80fddeb3c40c89e79bba550ca7ef9a2eab5ad6646ec13de8d134490a5fb5171d8aeb937e792a88f62588a468613a71948cb0212ba3
7
- data.tar.gz: e1ed8ff83ae15794ca4bcca7bdeb7cd7fef930f6c41394538e14fafa5fcb5f738535a3e1096bd6ee1856f3b95a4299ebdb6cf50aafa94ea233724599cea67395
6
+ metadata.gz: f438ba4b0c67b2c12b541fc76d0c17ef235df5f3573e45c3a5ebb70a8a05242da62e4de32989e59d5eb94c3473647f49447b602d4474bb83cb7aaa765c54d6f7
7
+ data.tar.gz: c43babb00b2d921701cbe300da9f3ec8fa59c4bec8b75a58d0f19d1fd1a3d1debcda02474e8701a35aa6d95293063b1d781d82564a7d1b76093504db221a29c2
@@ -50,7 +50,8 @@ class HostStatus::ExecutionStatus < HostStatus::Status
50
50
  end
51
51
 
52
52
  def status_link
53
- job_invocation = last_stopped_task.parent_task.job_invocations.first
53
+ job_invocation = last_stopped_task&.parent_task&.job_invocations&.first
54
+ return unless job_invocation
54
55
  return nil unless User.current.can?(:view_job_invocations, job_invocation)
55
56
 
56
57
  Rails.application.routes.url_helpers.job_invocation_path(job_invocation)
@@ -25,7 +25,7 @@ class JobInvocation < ApplicationRecord
25
25
  validates :job_category, :presence => true
26
26
  validates_associated :targeting, :all_template_invocations
27
27
 
28
- scoped_search :on => :id, :complete_value => true
28
+ scoped_search :on => :id, :complete_value => true, :validator => ScopedSearch::Validators::INTEGER
29
29
  scoped_search :on => :job_category, :complete_value => true
30
30
  scoped_search :on => :description, :complete_value => true
31
31
 
@@ -219,7 +219,7 @@ class JobInvocationComposer
219
219
  def format_datetime(datetime)
220
220
  return datetime if datetime.blank?
221
221
 
222
- Time.parse(datetime).in_time_zone.strftime('%Y-%m-%d %H:%M')
222
+ Time.zone.parse(datetime).strftime('%Y-%m-%d %H:%M')
223
223
  end
224
224
  end
225
225
 
@@ -28,6 +28,10 @@ class RemoteExecutionProvider
28
28
  providers.keys.map(&:to_s)
29
29
  end
30
30
 
31
+ def provider_proxy_features
32
+ providers.values.map(&:proxy_feature).flatten.uniq.compact
33
+ end
34
+
31
35
  def proxy_command_options(template_invocation, host)
32
36
  {:proxy_operation_name => proxy_operation_name}.merge(proxy_command_provider_inputs(template_invocation))
33
37
  end
@@ -7,7 +7,7 @@ class RemoteExecutionProxySelector < ::ForemanTasks::ProxySelector
7
7
  return proxies if capability.nil?
8
8
 
9
9
  proxies.reduce({}) do |acc, (strategy, possible_proxies)|
10
- acc.merge(strategy => possible_proxies.select { |proxy| proxy.has_capability?(capability) })
10
+ acc.merge(strategy => possible_proxies.select { |proxy| proxy.has_capability?(provider, capability) })
11
11
  end
12
12
  end
13
13
  end
@@ -1,5 +1,5 @@
1
1
  <div class="tab-pane" id="rex_proxies">
2
2
  <%= fields_for :subnet do |f| %>
3
- <%= multiple_selects f, :remote_execution_proxies, SmartProxy.authorized.with_features(*RemoteExecutionProvider.provider_names).distinct, @subnet.remote_execution_proxy_ids, {:label => _("Proxies"), :help_inline => _("Select as many remote execution proxies as applicable for this subnet. When multiple proxies with the same provider are added, actions will be load balanced among them.")} %>
3
+ <%= multiple_selects f, :remote_execution_proxies, SmartProxy.authorized.with_features(*RemoteExecutionProvider.provider_proxy_features).distinct, @subnet.remote_execution_proxy_ids, {:label => _("Proxies"), :help_inline => _("Select as many remote execution proxies as applicable for this subnet. When multiple proxies with the same provider are added, actions will be load balanced among them.")} %>
4
4
  <% end %>
5
5
  </div>
@@ -1,3 +1,3 @@
1
1
  module ForemanRemoteExecution
2
- VERSION = '7.1.0'.freeze
2
+ VERSION = '7.1.1'.freeze
3
3
  end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'test_plugin_helper'
4
+
5
+ class ApiParamsTest < ActiveSupport::TestCase
6
+ describe '#format_datetime' do
7
+ let(:params) { JobInvocationComposer::ApiParams.allocate }
8
+
9
+ it 'leaves empty string as is' do
10
+ assert_equal params.send(:format_datetime, ''), ''
11
+ end
12
+
13
+ it 'honors explicitly supplied time zone' do
14
+ in_time_zone(ActiveSupport::TimeZone['America/New_York']) do
15
+ assert_equal '2022-07-08 08:53', params.send(:format_datetime, '2022-07-08 12:53:20 UTC')
16
+ end
17
+ end
18
+
19
+ it 'implicitly honors current user\'s time zone' do
20
+ in_time_zone(ActiveSupport::TimeZone['America/New_York']) do
21
+ assert_equal '2022-07-08 12:53', params.send(:format_datetime, '2022-07-08 12:53:20')
22
+ end
23
+ end
24
+ end
25
+
26
+ def in_time_zone(zone)
27
+ old_tz = Time.zone
28
+ Time.zone = zone
29
+ yield
30
+ ensure
31
+ Time.zone = old_tz
32
+ end
33
+ end
@@ -33,6 +33,10 @@ class RemoteExecutionProviderTest < ActiveSupport::TestCase
33
33
  it 'accepts strings' do
34
34
  RemoteExecutionProvider.provider_for('SSH').must_equal SSHExecutionProvider
35
35
  end
36
+
37
+ it 'returns a default one if unknown value is provided' do
38
+ RemoteExecutionProvider.provider_for('WinRM').must_equal ScriptExecutionProvider
39
+ end
36
40
  end
37
41
 
38
42
  describe '.provider_names' do
@@ -52,6 +56,28 @@ class RemoteExecutionProviderTest < ActiveSupport::TestCase
52
56
  end
53
57
  end
54
58
 
59
+ describe '.provider_proxy_features' do
60
+ it 'returns correct values' do
61
+ RemoteExecutionProvider.stubs(:providers).returns(
62
+ :SSH => SSHExecutionProvider,
63
+ :script => ScriptExecutionProvider
64
+ )
65
+
66
+ features = RemoteExecutionProvider.provider_proxy_features
67
+ _(features).must_include 'SSH'
68
+ _(features).must_include 'Script'
69
+ RemoteExecutionProvider.unstub(:providers)
70
+ end
71
+
72
+ it 'can deal with non-arrays' do
73
+ provider = OpenStruct.new(proxy_feature: 'Testing')
74
+ RemoteExecutionProvider.stubs(:providers).returns(:testing => provider)
75
+ features = RemoteExecutionProvider.provider_proxy_features
76
+ _(features).must_include 'Testing'
77
+ RemoteExecutionProvider.unstub(:providers)
78
+ end
79
+ end
80
+
55
81
  describe '.host_setting' do
56
82
  let(:host) { FactoryBot.create(:host) }
57
83
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman_remote_execution
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.1.0
4
+ version: 7.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Foreman Remote Execution team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-06-13 00:00:00.000000000 Z
11
+ date: 2022-08-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: deface
@@ -389,6 +389,7 @@ files:
389
389
  - test/test_plugin_helper.rb
390
390
  - test/unit/actions/run_host_job_test.rb
391
391
  - test/unit/actions/run_hosts_job_test.rb
392
+ - test/unit/api_params_test.rb
392
393
  - test/unit/concerns/foreman_tasks_cleaner_extensions_test.rb
393
394
  - test/unit/concerns/host_extensions_test.rb
394
395
  - test/unit/concerns/nic_extensions_test.rb
@@ -544,7 +545,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
544
545
  - !ruby/object:Gem::Version
545
546
  version: '0'
546
547
  requirements: []
547
- rubygems_version: 3.1.4
548
+ rubygems_version: 3.2.26
548
549
  signing_key:
549
550
  specification_version: 4
550
551
  summary: A plugin bringing remote execution to the Foreman, completing the config
@@ -571,6 +572,7 @@ test_files:
571
572
  - test/test_plugin_helper.rb
572
573
  - test/unit/actions/run_host_job_test.rb
573
574
  - test/unit/actions/run_hosts_job_test.rb
575
+ - test/unit/api_params_test.rb
574
576
  - test/unit/concerns/foreman_tasks_cleaner_extensions_test.rb
575
577
  - test/unit/concerns/host_extensions_test.rb
576
578
  - test/unit/concerns/nic_extensions_test.rb