foreman_remote_execution 17.2.3 → 17.2.4

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: 77aa754bb168fcb40607e826343a3756377d48a840904845ff64c1817984a4d3
4
- data.tar.gz: fdc4371d3ec2cded84c761265944d910c9c9441edb10cf8d47969ec48b274021
3
+ metadata.gz: a5da040374fbd586bbda1134944cd2b2d2bb936d0174c2366a550708f9fc8e01
4
+ data.tar.gz: 77e81c8da2fe46a219e3f15162d2324d9cf56cfcd79c3ae98ae381525feeb0f3
5
5
  SHA512:
6
- metadata.gz: 7ff8259753704f5a2e01135c62fe1c20b9efe92ad29f49b3a37cd24b32541aa5e0801f44f82576932c33e236f46191addcc11867f970f61f9523277444a650a5
7
- data.tar.gz: 6124f7e80f7e60a33bfce4c1fc0f2124260da4e094515bebe84fc94f49e80eea58ace6b134170499759641d5924a34721516c669e2fa00ccff7b59fa5428fd63
6
+ metadata.gz: 6ef1cda08b002d99687bacc34e93651a384bf3f43fd9e3b526e4fec358d28031d269ad888bbcea9ee37031b9da0c4464dd6329bf7ad10571b67404041dc6f76a
7
+ data.tar.gz: efe31fa1fd10699c96c71788565bfe6cb0b0be8d7f9bef5fcba53cb9caa620157c2c320d00a68bcffe9654436a89d921330c8b8cf947d3f50543d6de029f8ca3
@@ -150,7 +150,7 @@ class JobInvocationsController < ApplicationController
150
150
 
151
151
  job_invocations = job_invocations.map do |job|
152
152
  @job_invocation = job
153
- template_invocation = job.template_invocations.find { |template_inv| template_inv.host_id == params[:host_id].to_i }
153
+ template_invocation = job.template_invocations.find_by(:host_id => params[:host_id].to_i)
154
154
  task = template_invocation.try(:run_host_job_task)
155
155
  status_mapper = task ? HostStatus::ExecutionStatus::ExecutionTaskStatusMapper.new(task) : job
156
156
  {
@@ -24,7 +24,7 @@ class TemplateInvocationsController < ApplicationController
24
24
  end
25
25
 
26
26
  def show_template_invocation_by_host
27
- @template_invocation = @job_invocation.template_invocations.find { |template_inv| template_inv.host_id == @host.id }
27
+ @template_invocation = @job_invocation.template_invocations.find_by(host_id: @host.id)
28
28
  if @template_invocation.nil?
29
29
  render :json => { :error => _('Template invocation not found') }, :status => :not_found
30
30
  end
@@ -60,13 +60,15 @@ class TemplateInvocationsController < ApplicationController
60
60
  private
61
61
 
62
62
  def find_job_invocation
63
- @job_invocation = JobInvocation.find(params[:id])
63
+ @job_invocation = JobInvocation.authorized(:view_job_invocations)
64
+ .joins(:template_invocations)
65
+ .find_by!(id: params[:id], template_invocations: { host_id: params[:host_id] })
64
66
  rescue ActiveRecord::RecordNotFound
65
67
  render :json => { :error => { :message => format(_("Job with id '%{id}' was not found"), :id => params['id']) } }, :status => :not_found
66
68
  end
67
69
 
68
70
  def find_host
69
- @host = Host.find(params[:host_id])
71
+ @host = Host.authorized(:view_hosts, Host).find(params[:host_id])
70
72
  rescue ActiveRecord::RecordNotFound
71
73
  render :json => { :error => { :message => format(_("Host with id '%{id}' was not found"), :id => params['host_id']) } }, :status => :not_found
72
74
  end
@@ -1,3 +1,3 @@
1
1
  module ForemanRemoteExecution
2
- VERSION = '17.2.3'.freeze
2
+ VERSION = '17.2.4'.freeze
3
3
  end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'test_plugin_helper'
4
+
5
+ class TemplateInvocationsControllerTest < ActionController::TestCase
6
+ setup do
7
+ @invocation = FactoryBot.create(:job_invocation, :with_template, :with_task)
8
+ @template_invocation = @invocation.template_invocations.first
9
+ ForemanTasks::Task.any_instance.stubs(:main_action).returns(OpenStruct.new(:live_output => [], :output => {}))
10
+ ForemanTasks::Task.any_instance.stubs(:execution_plan).returns(OpenStruct.new(:actions => [nil, OpenStruct.new(:input => { 'script' => '' })]))
11
+ ForemanTasks::Task.any_instance.stubs(:cancellable?).returns(false)
12
+ end
13
+
14
+ test 'should not show template invocation for a job invocation outside the permission filter' do
15
+ user = setup_user 'view', 'hosts'
16
+ setup_user 'view', 'job_invocations', "id != #{@invocation.id}"
17
+
18
+ get :show_template_invocation_by_host,
19
+ params: { id: @invocation.id, host_id: @template_invocation.host_id },
20
+ session: set_session_user(user)
21
+
22
+ assert_response :not_found
23
+ end
24
+
25
+ test 'should not show template invocation for a host outside the permission filter' do
26
+ user = setup_user 'view', 'job_invocations'
27
+ setup_user 'view', 'hosts', "name != #{@template_invocation.host.name}"
28
+
29
+ get :show_template_invocation_by_host,
30
+ params: { id: @invocation.id, host_id: @template_invocation.host_id },
31
+ session: set_session_user(user)
32
+
33
+ assert_response :not_found
34
+ end
35
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman_remote_execution
3
3
  version: !ruby/object:Gem::Version
4
- version: 17.2.3
4
+ version: 17.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Foreman Remote Execution team
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2026-10-20 00:00:00.000000000 Z
10
+ date: 2026-11-13 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: deface
@@ -356,6 +356,7 @@ files:
356
356
  - test/functional/cockpit_controller_test.rb
357
357
  - test/functional/job_invocations_controller_test.rb
358
358
  - test/functional/job_templates_controller_test.rb
359
+ - test/functional/template_invocations_controller_test.rb
359
360
  - test/functional/ui_job_wizard_controller_test.rb
360
361
  - test/graphql/mutations/job_invocations/create_test.rb
361
362
  - test/graphql/queries/job_invocation_query_test.rb