foreman_scc_manager 1.8.7 → 1.8.12

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: 843165a6092fcb04bf69d13131ae44acb02478ce347084c160a8f61891770eba
4
- data.tar.gz: 892025747b9572a4b31d25f4c96ab28ea9af0099ef3302fe8c7aec07935b588b
3
+ metadata.gz: f09d1fba685e2d82d20dcc19d519dfce35a1b6bd04b6c64353e2e40519b30fc9
4
+ data.tar.gz: afdb4e0f4c17546b8984c7b29d3bebfce35fa9043fb308a60423c8f113df2b84
5
5
  SHA512:
6
- metadata.gz: 0cb42eeb656e4a0cca5c93d7c83e0fed14fa73a9b0e7f2ad0ddcb07b007156405f0e91d968e4eb38aafd6376551f334340bda0a4ff9d632d13d4818766e7eb75
7
- data.tar.gz: 700546d7abfdc1ff7fc12f452c69bb6ca8869c41b63ae4e37fef99541dc229bf2287de3435ecd8c09dee32cb79465b8c896af09c78b4d0d498209e35c8a347cf
6
+ metadata.gz: 93779edde27305d62942cdcce50ba8dd548af379f0ff9b88fd7fe800b79bb3de41c58f6e873b116451ba20fbd65c89f6ab0428fbe7f8c7f25f07bc26982054f1
7
+ data.tar.gz: 0c58463cfd08bf269ae9c3a6ba2b0c833f1327d5985038cf32b38ff60a3a307377498759ca6cb11734de7a31122b2743bd9a8cb84a454cc8b6167682925c14a4
data/README.md CHANGED
@@ -1,18 +1,20 @@
1
- [![Build Status master](https://travis-ci.org/ATIX-AG/foreman_scc_manager.svg?branch=master)](https://travis-ci.org/ATIX-AG/foreman_scc_manager)
1
+ ![Rubocop](https://github.com/ATIX-AG/foreman_scc_manager/actions/workflows/rubocop.yaml/badge.svg)
2
+ ![Unit Tests](https://github.com/ATIX-AG/foreman_scc_manager/actions/workflows/unit_tests.yaml/badge.svg)
3
+ [![Gem Version](https://badge.fury.io/rb/foreman_scc_manager.svg)](https://badge.fury.io/rb/foreman_scc_manager)
2
4
 
3
- # ForemanSccManager
5
+ # Foreman SCC Manager
4
6
 
5
- Foreman plugin to sync SUSE Customer Center products and repositories into Katello
7
+ Foreman plugin to sync SUSE Customer Center products and repositories into Katello.
6
8
 
7
9
  ## Installation
8
10
 
9
- See [How_to_Install_a_Plugin](http://projects.theforeman.org/projects/foreman/wiki/How_to_Install_a_Plugin)
10
- for how to install Foreman plugins
11
+ See [Foreman Manual](https://theforeman.org/plugins/#2.Installation) on how to install Foreman plugins.
11
12
 
12
13
  ## Compatibility
13
14
 
14
15
  | Foreman Version | Katello Version | Plugin Version |
15
16
  | --------------- | --------------- | -------------- |
17
+ | 2.3 | 3.18 | ~> 1.8.9 |
16
18
  | 2.1 | 3.16 | ~> 1.8.5 |
17
19
  | 2.0 | 3.16 | ~> 1.8.4 |
18
20
  | 1.24 | 3.14 | ~> 1.8.0 |
@@ -26,7 +28,12 @@ for how to install Foreman plugins
26
28
  | 1.15 | 3.4 | ~> 1.1.0 |
27
29
 
28
30
  ## Documentation
29
- The plugin documentation can be found at https://docs.orcharhino.com/sources/management_ui/the_content_menu/suse_subscriptions.html.
31
+
32
+ [Plugin documentation](https://docs.orcharhino.com/sources/management_ui/the_content_menu/suse_subscriptions.html)
33
+
34
+ ## Hammer CLI Extension
35
+
36
+ [Hammer CLI for Foreman SCC Manager](https://github.com/ATIX-AG/hammer-cli-foreman-scc-manager)
30
37
 
31
38
  ## Contributing
32
39
 
@@ -34,7 +41,7 @@ Fork and send a Pull Request. Thanks!
34
41
 
35
42
  ## Copyright
36
43
 
37
- Copyright (c) 2017 ATIX AG - http://www.atix.de
44
+ Copyright (c) 2021 ATIX AG - https://atix.de
38
45
 
39
46
  This program is free software: you can redistribute it and/or modify
40
47
  it under the terms of the GNU General Public License as published by
@@ -48,4 +55,3 @@ GNU General Public License for more details.
48
55
 
49
56
  You should have received a copy of the GNU General Public License
50
57
  along with this program. If not, see <http://www.gnu.org/licenses/>.
51
-
@@ -2,7 +2,7 @@ class SccAccountsController < ApplicationController
2
2
  helper_method :scc_filtered_products
3
3
  before_action :find_organization
4
4
  before_action :find_resource, only: %i[show edit update destroy sync bulk_subscribe]
5
- before_action :find_available_gpg_keys, only: %i[new edit]
5
+ before_action :find_available_gpg_keys, only: %i[new edit update create]
6
6
  include Foreman::Controller::AutoCompleteSearch
7
7
 
8
8
  # GET /scc_accounts
@@ -1,14 +1,9 @@
1
1
  module SccManager
2
2
  # adapted from https://github.com/SUSE/connect
3
3
  def self.get_scc_data(base_url, rest_url, login, password)
4
- if SETTINGS[:katello][:cdn_proxy] && SETTINGS[:katello][:cdn_proxy][:host]
5
- proxy_config = SETTINGS[:katello][:cdn_proxy]
6
- uri = URI('')
7
-
8
- uri.scheme = URI.parse(proxy_config[:host]).scheme
9
- uri.host = URI.parse(proxy_config[:host]).host
10
- uri.port = proxy_config[:port].try(:to_s)
11
- uri.user = proxy_config[:user]
4
+ if (proxy_config = ::HttpProxy.default_global_content_proxy)
5
+ uri = URI(proxy_config[:url])
6
+ uri.user = proxy_config[:username]
12
7
  uri.password = proxy_config[:password] if uri.user.present?
13
8
 
14
9
  RestClient.proxy = uri.to_s
@@ -45,12 +45,7 @@ class SccAccount < ApplicationRecord
45
45
  end
46
46
 
47
47
  def sync_date_is_valid_datetime
48
- errors.add(:sync_date, 'must be a valid datetime') if interval != NEVER &&
49
- sync_date.present? &&
50
- !sync_date.respond_to?(:min) &&
51
- !sync_date.respond_to?(:hour) &&
52
- !sync_date.respond_to?(:wday) &&
53
- !sync_date.respond_to?(:day)
48
+ errors.add(:sync_date, 'must be a valid datetime') if interval != NEVER && sync_date.blank?
54
49
  end
55
50
 
56
51
  def to_s
@@ -104,7 +99,7 @@ class SccAccount < ApplicationRecord
104
99
  end
105
100
 
106
101
  def add_recurring_logic(sync_date, interval)
107
- sd = sync_date
102
+ sd = sync_date.presence || Time.now
108
103
 
109
104
  raise _('Interval cannot be nil') if interval.nil?
110
105
 
data/config/routes.rb CHANGED
@@ -23,7 +23,7 @@ Rails.application.routes.draw do
23
23
  :defaults => { :apiv => 'v2' },
24
24
  :apiv => /v1|v2/,
25
25
  :constraints => ApiConstraints.new(:version => 2, :default => true) do
26
- resources :scc_accounts do
26
+ resources :scc_accounts, except: %i[new edit] do
27
27
  collection do
28
28
  post 'test_connection'
29
29
  get 'auto_complete_search'
@@ -1,4 +1,15 @@
1
1
  class ConnectKatelloRootRepositoryToSccRepository < ActiveRecord::Migration[5.2]
2
+ # add SccRepository class, because original one triggers the token_changed_callback
3
+ # which tried to update Katello root repositories
4
+ class SccRepository < ApplicationRecord
5
+ belongs_to :katello_root_repository, class_name: 'Katello::RootRepository'
6
+ end
7
+
8
+ class SccProduct < ApplicationRecord
9
+ belongs_to :product, class_name: 'Katello::Product'
10
+ has_and_belongs_to_many :scc_repositories
11
+ end
12
+
2
13
  def up
3
14
  SccProduct.where.not(product_id: nil).each do |scc_p|
4
15
  # extract all katello root repository ids from subscribed products
@@ -0,0 +1,19 @@
1
+ class AddPermissions < ActiveRecord::Migration[6.0]
2
+ PRODUCT_PERMISSION_NAMES = [
3
+ 'view_scc_products',
4
+ 'subscribe_scc_products'
5
+ ].freeze
6
+
7
+ def up
8
+ Permission.create!(:name => 'test_connection_scc_accounts', :resource_type => 'SccAccount')
9
+ PRODUCT_PERMISSION_NAMES.each do |p|
10
+ Permission.create!(:name => p, :resource_type => SccProduct)
11
+ end
12
+ end
13
+
14
+ def down
15
+ (PRODUCT_PERMISSION_NAMES + ['test_connection_scc_accounts']).each do |p|
16
+ Permission.where(:name => p).destroy_all
17
+ end
18
+ end
19
+ end
@@ -22,16 +22,18 @@ module ForemanSccManager
22
22
 
23
23
  initializer 'foreman_scc_manager.register_plugin', :before => :finisher_hook do |_app|
24
24
  Foreman::Plugin.register :foreman_scc_manager do
25
- requires_foreman '>= 1.22'
26
- requires_foreman_plugin 'katello', '>= 3.12.0'
25
+ requires_foreman '>= 2.1'
26
+ requires_foreman_plugin 'katello', '>= 3.16.0'
27
+
28
+ precompile_assets 'foreman_scc_manager/scc_accounts.js'
27
29
 
28
30
  apipie_documented_controllers ["#{ForemanSccManager::Engine.root}/app/controllers/api/v2/*.rb"]
29
31
 
30
32
  # Add permissions
31
33
  security_block :foreman_scc_manager do
32
34
  permission :view_scc_accounts,
33
- { :scc_accounts => [:show, :index],
34
- :'api/v2/scc_accounts' => [:show, :index] },
35
+ { :scc_accounts => [:show, :index, :auto_complete_search],
36
+ :'api/v2/scc_accounts' => [:show, :index, :auto_complete_search] },
35
37
  :resource_type => 'SccAccount'
36
38
 
37
39
  permission :use_scc_accounts,
@@ -58,15 +60,33 @@ module ForemanSccManager
58
60
  { :scc_accounts => [:sync],
59
61
  :'api/v2/scc_accounts' => [:sync] },
60
62
  :resource_type => 'SccAccount'
63
+
64
+ permission :test_connection_scc_accounts,
65
+ { :scc_accounts => [:test_connection],
66
+ :'api/v2/scc_accounts' => [:test_connection] },
67
+ :resource_type => 'SccAccount'
68
+
69
+ permission :view_scc_products,
70
+ { :scc_products => [:index, :show],
71
+ :'api/v2/scc_products' => [:index, :show] },
72
+ :resource_type => 'SccProduct'
73
+
74
+ permission :subscribe_scc_products,
75
+ { :scc_products => [:subscribe, :unsubscribe],
76
+ :'api/v2/scc_products' => [:subscribe, :unsibscribe] },
77
+ :resource_type => 'SccProduct'
61
78
  end
62
79
 
63
80
  # Add a new role called 'SccManager' if it doesn't exist
64
81
  role 'SccManager',
65
- %i[view_scc_accounts use_scc_accounts new_scc_accounts edit_scc_accounts delete_scc_accounts sync_scc_accounts],
82
+ %i[view_scc_accounts use_scc_accounts new_scc_accounts edit_scc_accounts
83
+ delete_scc_accounts sync_scc_accounts test_connection_scc_accounts
84
+ view_scc_products subscribe_scc_products],
66
85
  'Role granting permissons to manage SUSE Subscriptions'
67
86
 
68
87
  role 'SccViewer',
69
- %i[view_scc_accounts use_scc_accounts sync_scc_accounts create_products view_products],
88
+ %i[view_scc_accounts use_scc_accounts sync_scc_accounts
89
+ create_products view_products subscribe_scc_products view_scc_products],
70
90
  'Role granting permissons to view and use SUSE Subscriptions'
71
91
 
72
92
  add_all_permissions_to_default_roles
@@ -1,3 +1,3 @@
1
1
  module ForemanSccManager
2
- VERSION = '1.8.7'.freeze
2
+ VERSION = '1.8.12'.freeze
3
3
  end