foreman_leapp 2.0.1 → 2.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 43c59a1ab80e574f5c262115fcb2a438c73be6a7d78f087143b17d0722326fde
4
- data.tar.gz: 13683be8ba8d390aa8b284cf24a0b33908881338a33ce794e43cc4adfd734ecf
3
+ metadata.gz: 5db26b0ee1b2fb8d0340d2f6d74fb12405132035aafa2ea2a468f1aadc57b2d8
4
+ data.tar.gz: 524b28fa0526892def9a392506e97ba55822142b731019cdee5eaf42e968cfdd
5
5
  SHA512:
6
- metadata.gz: ee1bb633e4ad8d3d5311f527fbc57e3d669cb91fbf8359cf500b8ae848aa7b143d7186637add46a1deec39c1367385441d8fb1927af425c4e5c266d6c9ac63d0
7
- data.tar.gz: 2814bfb36de2d66fcee36c3e5d31edf9ce5d3b97c679afcda34418b8eedd1140c4ea581fae5e31dac068da34297f87553ac80e164bf484a88c9d9a377e1188d6
6
+ metadata.gz: cf8566bbe37390c366a03775bddbf36d0f817d03146d558b9eb772c0d69c41de10f482878815075a715d84dc13fdf05c04f4a42eb8d928de4ad9a3c318e13736
7
+ data.tar.gz: 64faec40a8cbce07b31ecf4fc782ba9f9ed9b22b093d6e184aaa9710a966ec1ae1a0608a1db4116ba8920efdf76bf3f72509b685c2b6d0c77863e0f37c97d8f5
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Api
4
+ module V2
5
+ module ApiAuthorizer
6
+ extend ActiveSupport::Concern
7
+
8
+ included do
9
+ before_action :hosts_permission
10
+ end
11
+
12
+ private
13
+
14
+ def hosts_permission
15
+ return if User.current.can?('view_hosts')
16
+
17
+ render_error 'access_denied', status: :forbidden,
18
+ locals: { details: N_('Missing one of the required permissions: view_hosts'),
19
+ missing_permissions: 'view_hosts' }
20
+ end
21
+
22
+ def resource_scope(_options = {})
23
+ @resource_scope ||= begin
24
+ scope = PreupgradeReport.joins(:host).merge(Host.authorized(:view_hosts, Host))
25
+ scope = scope.where(job_invocation_id: params[:id]) if action_name == 'job_invocation'
26
+ scope
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class PreupgradeReportsController < ::Api::V2::BaseController
4
- include ApiAuthorizer
4
+ include Api::V2::ApiAuthorizer
5
5
 
6
6
  def index
7
7
  @preupgrade_reports = resource_scope.includes(:preupgrade_report_entries).search_for(*search_options)
@@ -8,8 +8,8 @@ module Actions
8
8
  end
9
9
 
10
10
  def plan(job_invocation, host, *_args)
11
- return unless ::JobHelper.correct_feature?(job_invocation, 'leapp_preupgrade') ||
12
- ::JobHelper.correct_feature?(job_invocation, 'leapp_remediation_plan')
11
+ return unless ::Helpers::JobHelper.correct_feature?(job_invocation, 'leapp_preupgrade') ||
12
+ ::Helpers::JobHelper.correct_feature?(job_invocation, 'leapp_remediation_plan')
13
13
 
14
14
  plan_self(host_id: host.id, job_invocation_id: job_invocation.id)
15
15
  end
@@ -1,11 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module JobHelper
4
- class << self
5
- def correct_feature?(job_invocation, feature)
6
- RemoteExecutionFeature.where(job_template_id: job_invocation.pattern_template_invocations
7
- .first
8
- .template_id, label: feature).any?
3
+ module Helpers
4
+ module JobHelper
5
+ class << self
6
+ def correct_feature?(job_invocation, feature)
7
+ RemoteExecutionFeature.where(job_template_id: job_invocation.pattern_template_invocations
8
+ .first
9
+ .template_id, label: feature).any?
10
+ end
9
11
  end
10
12
  end
11
13
  end
@@ -7,17 +7,6 @@ module ForemanLeapp
7
7
  class Engine < ::Rails::Engine
8
8
  engine_name 'foreman_leapp'
9
9
 
10
- config.eager_load_paths += Dir["#{config.root}/app/controllers/api/v2/concerns"]
11
- config.eager_load_paths += Dir["#{config.root}/app/lib/helpers"]
12
-
13
- config.autoload_paths += Dir["#{config.root}/app/controllers/concerns"]
14
- config.autoload_paths += Dir["#{config.root}/app/controllers/api/v2/concerns"]
15
- config.autoload_paths += Dir["#{config.root}/app/helpers/concerns"]
16
- config.autoload_paths += Dir["#{config.root}/app/models/concerns"]
17
- config.autoload_paths += Dir["#{config.root}/app/overrides"]
18
- config.autoload_paths += Dir["#{config.root}/app/lib/helpers"]
19
- config.autoload_paths += Dir["#{config.root}/test/"]
20
-
21
10
  # Add any db migrations
22
11
  initializer 'foreman_leapp.load_app_instance_data' do |app|
23
12
  ForemanLeapp::Engine.paths['db/migrate'].existent.each do |path|
@@ -25,32 +14,35 @@ module ForemanLeapp
25
14
  end
26
15
  end
27
16
 
28
- initializer 'foreman_leapp.register_plugin', before: :finisher_hook do |_app|
29
- Foreman::Plugin.register :foreman_leapp do
30
- requires_foreman '>= 3.7'
31
- register_gettext
32
-
33
- apipie_documented_controllers ["#{ForemanLeapp::Engine.root}/app/controllers/api/v2/*.rb"]
34
- extend_template_helpers ForemanLeapp::TemplateHelper
35
-
36
- extend_page 'job_invocations/show' do |cx|
37
- cx.add_pagelet :main_tabs,
38
- partial: 'job_invocations/leapp_preupgrade_report',
39
- name: _('Leapp preupgrade report'),
40
- id: 'leapp_preupgrade_report',
41
- onlyif: proc { |subject|
42
- ::JobHelper.correct_feature?(subject, 'leapp_preupgrade') ||
43
- ::JobHelper.correct_feature?(subject, 'leapp_remediation_plan')
44
- }
45
- end
46
-
47
- security_block :foreman_leapp do
48
- permission :view_job_invocations, { :preupgrade_reports => %i[index show job_invocation],
49
- 'api/v2/preupgrade_reports' => %i[index show job_invocation] }
50
- end
51
-
52
- describe_host do
53
- multiple_actions_provider :leapp_hosts_multiple_actions
17
+ initializer 'foreman_leapp.register_plugin', before: :finisher_hook do |app|
18
+ app.reloader.to_prepare do
19
+ Foreman::Plugin.register :foreman_leapp do
20
+ requires_foreman '>= 3.13'
21
+ register_gettext
22
+
23
+ apipie_documented_controllers ["#{ForemanLeapp::Engine.root}/app/controllers/api/v2/*.rb"]
24
+ extend_template_helpers ForemanLeapp::TemplateHelper
25
+
26
+ extend_page 'job_invocations/show' do |cx|
27
+ cx.add_pagelet :main_tabs,
28
+ partial: 'job_invocations/leapp_preupgrade_report',
29
+ name: _('Leapp preupgrade report'),
30
+ id: 'leapp_preupgrade_report',
31
+ onlyif: proc { |subject|
32
+ ::Helpers::JobHelper.correct_feature?(subject, 'leapp_preupgrade') ||
33
+ ::Helpers::JobHelper.correct_feature?(subject, 'leapp_remediation_plan')
34
+ }
35
+ end
36
+
37
+ security_block :foreman_leapp do
38
+ permission :view_job_invocations, { :preupgrade_reports => %i[index show job_invocation],
39
+ 'api/v2/preupgrade_reports' => %i[index show job_invocation] },
40
+ :resource_type => 'JobInvocation'
41
+ end
42
+
43
+ describe_host do
44
+ multiple_actions_provider :leapp_hosts_multiple_actions
45
+ end
54
46
  end
55
47
  end
56
48
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ForemanLeapp
4
- VERSION = '2.0.1'
4
+ VERSION = '2.0.2'
5
5
  end
@@ -4,7 +4,7 @@ require 'test_plugin_helper'
4
4
 
5
5
  module Helpers
6
6
  class JobHelperTest < ActionView::TestCase
7
- let(:helper) { ::JobHelper }
7
+ let(:helper) { ::Helpers::JobHelper }
8
8
 
9
9
  let(:job_template) do
10
10
  FactoryBot.create(:job_template, template: 'echo "1"', job_category: 'leapp',
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman_leapp
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Foreman Leapp team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-10-07 00:00:00.000000000 Z
11
+ date: 2024-12-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: foreman_remote_execution
@@ -68,8 +68,8 @@ files:
68
68
  - app/assets/javascripts/foreman_leapp/locale/ja/foreman_leapp.js
69
69
  - app/assets/javascripts/foreman_leapp/locale/ka/foreman_leapp.js
70
70
  - app/assets/javascripts/foreman_leapp/locale/zh_CN/foreman_leapp.js
71
- - app/controllers/api/v2/concerns/api_authorizer.rb
72
71
  - app/controllers/api/v2/preupgrade_reports_controller.rb
72
+ - app/controllers/concerns/api/v2/api_authorizer.rb
73
73
  - app/controllers/preupgrade_reports_controller.rb
74
74
  - app/helpers/foreman_leapp/hosts_helper.rb
75
75
  - app/helpers/foreman_leapp/template_helper.rb
@@ -213,7 +213,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
213
213
  - !ruby/object:Gem::Version
214
214
  version: '0'
215
215
  requirements: []
216
- rubygems_version: 3.2.33
216
+ rubygems_version: 3.5.23
217
217
  signing_key:
218
218
  specification_version: 4
219
219
  summary: A Foreman plugin for Leapp utility.
@@ -1,27 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module ApiAuthorizer
4
- extend ActiveSupport::Concern
5
-
6
- included do
7
- before_action :hosts_permission
8
- end
9
-
10
- private
11
-
12
- def hosts_permission
13
- return if User.current.can?('view_hosts')
14
-
15
- render_error 'access_denied', status: :forbidden,
16
- locals: { details: N_('Missing one of the required permissions: view_hosts'),
17
- missing_permissions: 'view_hosts' }
18
- end
19
-
20
- def resource_scope(_options = {})
21
- @resource_scope ||= begin
22
- scope = PreupgradeReport.joins(:host).merge(Host.authorized(:view_hosts, Host))
23
- scope = scope.where(job_invocation_id: params[:id]) if action_name == 'job_invocation'
24
- scope
25
- end
26
- end
27
- end