foreman_scc_manager 1.3.1 → 1.4.0

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: bd1877e55ef5915c8b11be58c142ee73292f450a0681cabfe0d4b0d410a977b3
4
- data.tar.gz: 93678d164b05f4a4fa6a6f5a31ea17f43200acf071a0de58a8266e470b1c90ae
3
+ metadata.gz: 67a2884348925699e2aadc5796abe4ec48adee8458c577c035c564c1fbd9f950
4
+ data.tar.gz: 2ea193e0dbc07d41706f908870c610e1411ec200df1c6f10435f8ddc2dde0a4f
5
5
  SHA512:
6
- metadata.gz: d6e11f9a75def00e1752330fcb7288081f1d2730ac6f0ae865b6ddb711ea545ccfd2db98094d9b71ba7d234669b2cb1491fd688dc34d4feca28cd1ad4bb11e5a
7
- data.tar.gz: 4ff67012a62baf789859ccc57f9b450a49446e185dda4520c4ecac387b8b9755f69ffc30a43a93196d15500efc88b9ffd56627c56f2c4d698f881a6449c4cd41
6
+ metadata.gz: cbac716765fccb60766e4e3a6a205d596bbfd08b1349efe1e9ed56a70bb84696835895520d2b93c6bf079f8ae9d0aebab169d541b5d6291f9519f24347b407c9
7
+ data.tar.gz: 6419f3962cc8355300132eb6ea01719e5a912a66f18051922e2edc8db482a0d46d224f88bd6c5dbef501c06b877dbe6dc44cfc4e48d4438e62251c46cf6599c3
data/README.md CHANGED
@@ -7,13 +7,13 @@ Foreman plugin to sync SUSE Customer Center products and repositories into Katel
7
7
  See [How_to_Install_a_Plugin](http://projects.theforeman.org/projects/foreman/wiki/How_to_Install_a_Plugin)
8
8
  for how to install Foreman plugins
9
9
 
10
- ## Usage
10
+ ## Compatibility
11
11
 
12
- *Usage here*
13
-
14
- ## TODO
15
-
16
- *Todo list here*
12
+ | Foreman Version | Katello Version | Plugin Version |
13
+ | --------------- | --------------- | -------------- |
14
+ | 1.17 | 3.6 | >= 1.3.1 |
15
+ | 1.16 | 3.5 | <= 1.3.0 |
16
+ | 1.15 | 3.4 | ~> 1.1.0 |
17
17
 
18
18
  ## Contributing
19
19
 
data/Rakefile CHANGED
@@ -20,7 +20,7 @@ RDoc::Task.new(:rdoc) do |rdoc|
20
20
  rdoc.rdoc_files.include('lib/**/*.rb')
21
21
  end
22
22
 
23
- APP_RAKEFILE = File.expand_path('../test/dummy/Rakefile', __FILE__)
23
+ APP_RAKEFILE = File.expand_path('test/dummy/Rakefile', __dir__)
24
24
 
25
25
  Bundler::GemHelper.install_tasks
26
26
 
@@ -38,7 +38,7 @@ task default: :test
38
38
  begin
39
39
  require 'rubocop/rake_task'
40
40
  RuboCop::RakeTask.new
41
- rescue => _
41
+ rescue StandardError => _
42
42
  puts 'Rubocop not loaded.'
43
43
  end
44
44
 
@@ -1,7 +1,6 @@
1
1
  class SccAccountsController < ApplicationController
2
2
  before_action :find_organization
3
3
  before_action :find_resource, only: %i[show edit update destroy sync bulk_subscribe]
4
- include Api::TaxonomyScope
5
4
  include Foreman::Controller::AutoCompleteSearch
6
5
 
7
6
  # GET /scc_accounts
@@ -32,14 +31,12 @@ class SccAccountsController < ApplicationController
32
31
  # POST /scc_accounts/test_connection
33
32
  def test_connection
34
33
  @scc_account = SccAccount.new(scc_account_params)
35
- if params[:scc_account_id].present? && scc_account_params[:password].empty?
36
- @scc_account.password = SccAccount.find_by!(id: params[:scc_account_id]).password
37
- end
34
+ @scc_account.password = SccAccount.find_by!(id: params[:scc_account_id]).password if params[:scc_account_id].present? && scc_account_params[:password].empty?
38
35
  respond_to do |format|
39
36
  if @scc_account.test_connection
40
37
  format.json { render json: nil, status: :ok }
41
38
  else
42
- format.json { render json: nil, status: 404 }
39
+ format.json { render json: nil, status: :not_found }
43
40
  end
44
41
  end
45
42
  end
@@ -79,7 +76,7 @@ class SccAccountsController < ApplicationController
79
76
  scc_products_to_subscribe =
80
77
  @scc_account.scc_products.where(id: scc_bulk_subscribe_params[:scc_subscribe_product_ids])
81
78
 
82
- if (scc_products_to_subscribe.count > 0)
79
+ if scc_products_to_subscribe.count > 0
83
80
  ForemanTasks.async_task(::Actions::BulkAction,
84
81
  ::Actions::SccManager::SubscribeProduct,
85
82
  scc_products_to_subscribe)
@@ -99,9 +96,7 @@ class SccAccountsController < ApplicationController
99
96
 
100
97
  def find_organization
101
98
  @organization = Organization.current
102
- unless @organization
103
- redirect_to '/select_organization?toState=' + request.path
104
- end
99
+ redirect_to '/select_organization?toState=' + request.path unless @organization
105
100
  end
106
101
 
107
102
  # Use callbacks to share common setup or constraints between actions.
@@ -1,6 +1,5 @@
1
1
  class SccProductsController < ApplicationController
2
2
  before_action :find_resource, only: %i[show subscribe unsubscribe]
3
- include Api::TaxonomyScope
4
3
  include Foreman::Controller::AutoCompleteSearch
5
4
 
6
5
  def index
@@ -61,15 +61,14 @@ module Actions
61
61
  label = ::Katello::Util::Model.labelize(uniq_name)
62
62
  unprotected = true
63
63
  gpg_key = product.gpg_key
64
- repo_param = { :label => label,
65
- :name => uniq_name,
66
- :url => input[:url],
67
- :content_type => 'yum',
68
- :unprotected => unprotected,
69
- :gpg_key => gpg_key,
70
- :arch => input[:arch],
71
- :download_policy => ::Runcible::Models::YumImporter::DOWNLOAD_IMMEDIATE
72
- }
64
+ repo_param = { :label => label,
65
+ :name => uniq_name,
66
+ :url => input[:url],
67
+ :content_type => 'yum',
68
+ :unprotected => unprotected,
69
+ :gpg_key => gpg_key,
70
+ :arch => input[:arch],
71
+ :download_policy => ::Runcible::Models::YumImporter::DOWNLOAD_IMMEDIATE }
73
72
  repository = product.add_repo(repo_param)
74
73
  repository.mirror_on_sync = true
75
74
  repository.verify_ssl_on_sync = true
@@ -14,11 +14,8 @@ module Actions
14
14
 
15
15
  def finalize
16
16
  scc_account = SccAccount.find(input[:scc_account][:id])
17
- if input[:repo_status] == 'SUCCESS' && input[:prod_status] == 'SUCCESS'
18
- scc_account.update! synced: DateTime.current
19
- else
20
- raise 'Updating failed'
21
- end
17
+ raise 'Updating failed' unless input[:repo_status] == 'SUCCESS' && input[:prod_status] == 'SUCCESS'
18
+ scc_account.update! synced: Time.current
22
19
  end
23
20
 
24
21
  def rescue_strategy
@@ -16,7 +16,7 @@ module Actions
16
16
  '/connect/organizations/products',
17
17
  input.fetch(:login),
18
18
  input.fetch(:password))
19
- rescue
19
+ rescue StandardError
20
20
  output[:status] = 'FAILURE'
21
21
  end
22
22
  end
@@ -15,7 +15,7 @@ module Actions
15
15
  '/connect/organizations/repositories',
16
16
  input[:login],
17
17
  input[:password])
18
- rescue
18
+ rescue StandardError
19
19
  output[:status] = 'FAILURE'
20
20
  end
21
21
  end
@@ -26,24 +26,24 @@ class SccAccount < ApplicationRecord
26
26
  name
27
27
  end
28
28
 
29
- def get_sync_status
29
+ def sync_status
30
30
  if sync_task.nil?
31
- return _('never synced')
31
+ _('never synced')
32
32
  elsif sync_task.state == 'stopped'
33
33
  if sync_task.result == 'success'
34
- return synced
34
+ synced
35
35
  else
36
- return sync_task.result
36
+ sync_task.result
37
37
  end
38
38
  else
39
- return sync_task.state
39
+ sync_task.state
40
40
  end
41
41
  end
42
42
 
43
43
  def test_connection
44
44
  SccManager.get_scc_data(base_url, '/connect/organizations/subscriptions', login, password)
45
45
  true
46
- rescue
46
+ rescue StandardError
47
47
  false
48
48
  end
49
49
 
@@ -67,10 +67,14 @@ class SccAccount < ApplicationRecord
67
67
  if upstream_repo_ids.empty?
68
68
  urid_query_fragment = ''
69
69
  else
70
- upstream_repo_ids_str = upstream_repo_ids.map{ |id| ActiveRecord::Base.connection.quote(id) }.join(',')
70
+ upstream_repo_ids_str = upstream_repo_ids.map do |id|
71
+ ActiveRecord::Base.connection.quote(id)
72
+ end.join(',')
71
73
  urid_query_fragment = " and scc_repositories.scc_id not in (#{upstream_repo_ids_str})"
72
74
  end
73
- ActiveRecord::Base.connection.execute("delete from scc_repositories where scc_repositories.scc_account_id = #{ActiveRecord::Base.connection.quote(id)}#{urid_query_fragment};")
75
+ ActiveRecord::Base.connection.execute(
76
+ "delete from scc_repositories where scc_repositories.scc_account_id = #{ActiveRecord::Base.connection.quote(id)}#{urid_query_fragment};"
77
+ )
74
78
  end
75
79
 
76
80
  def update_scc_products(upstream_products)
@@ -94,10 +98,14 @@ class SccAccount < ApplicationRecord
94
98
  if upstream_product_ids.empty?
95
99
  upid_query_fragment = ''
96
100
  else
97
- upstream_product_ids_str = upstream_product_ids.map{ |id| ActiveRecord::Base.connection.quote(id) }.join(',')
101
+ upstream_product_ids_str = upstream_product_ids.map do |id|
102
+ ActiveRecord::Base.connection.quote(id)
103
+ end.join(',')
98
104
  upid_query_fragment = " and scc_products.scc_id not in (#{upstream_product_ids_str})"
99
105
  end
100
- ActiveRecord::Base.connection.execute("delete from scc_products where scc_products.scc_account_id = #{ActiveRecord::Base.connection.quote(id)}#{upid_query_fragment};")
106
+ ActiveRecord::Base.connection.execute(
107
+ "delete from scc_products where scc_products.scc_account_id = #{ActiveRecord::Base.connection.quote(id)}#{upid_query_fragment};"
108
+ )
101
109
  # rewire product to product relationships
102
110
  upstream_products.each do |up|
103
111
  extensions = scc_products.where(scc_id: up['extensions'].map { |ext| ext['id'] })
@@ -12,7 +12,7 @@ class SccRepository < ApplicationRecord
12
12
  end
13
13
 
14
14
  def token_changed_callback
15
- User.current = User.anonymous_admin unless User.current
15
+ User.current ||= User.anonymous_admin
16
16
  scc_products.where.not(product: nil).find_each do |sp|
17
17
  reponame = sp.friendly_name + ' ' + description
18
18
  repository = sp.product.repositories.find_by(name: reponame)
@@ -18,7 +18,7 @@
18
18
  <%= link_to_if_authorized(scc_account.name, hash_for_edit_scc_account_path(:id => scc_account).merge(:auth_object => scc_account, :authorizer => authorizer)) %>
19
19
  </td>
20
20
  <td><%= scc_account.scc_products.count.to_s %></td>
21
- <td><%= link_to_if(scc_account.sync_task, scc_account.get_sync_status, scc_account.sync_task) %></td>
21
+ <td><%= link_to_if(scc_account.sync_task, scc_account.sync_status, scc_account.sync_task) %></td>
22
22
  <td>
23
23
  <%= action_buttons(
24
24
  display_link_if_authorized(_("Select products"), hash_for_scc_account_path(:id => scc_account).merge(:auth_object => scc_account, :authorizer => authorizer)),
@@ -18,8 +18,8 @@ module ForemanSccManager
18
18
 
19
19
  initializer 'foreman_scc_manager.register_plugin', :before => :finisher_hook do |_app|
20
20
  Foreman::Plugin.register :foreman_scc_manager do
21
- requires_foreman '>= 1.16'
22
- requires_foreman_plugin 'katello', '>= 3.5.0'
21
+ requires_foreman '>= 1.18'
22
+ requires_foreman_plugin 'katello', '>= 3.7.0'
23
23
 
24
24
  # Add permissions
25
25
  security_block :foreman_scc_manager do
@@ -75,7 +75,7 @@ module ForemanSccManager
75
75
  end
76
76
 
77
77
  initializer 'foreman_scc_manager.register_gettext', after: :load_config_initializers do |_app|
78
- locale_dir = File.join(File.expand_path('../../..', __FILE__), 'locale')
78
+ locale_dir = File.join(File.expand_path('../..', __dir__), 'locale')
79
79
  locale_domain = 'foreman_scc_manager'
80
80
  Foreman::Gettext::Support.add_text_domain locale_domain, locale_dir
81
81
  end
@@ -1,3 +1,3 @@
1
1
  module ForemanSccManager
2
- VERSION = '1.3.1'.freeze
2
+ VERSION = '1.4.0'.freeze
3
3
  end
@@ -31,7 +31,7 @@ namespace :foreman_scc_manager do
31
31
  "#{ForemanSccManager::Engine.root}/lib/**/*.rb",
32
32
  "#{ForemanSccManager::Engine.root}/test/**/*.rb"]
33
33
  end
34
- rescue
34
+ rescue StandardError
35
35
  puts 'Rubocop not loaded.'
36
36
  end
37
37
 
@@ -42,6 +42,4 @@ end
42
42
  Rake::Task[:test].enhance ['test:foreman_scc_manager']
43
43
 
44
44
  load 'tasks/jenkins.rake'
45
- if Rake::Task.task_defined?(:'jenkins:unit')
46
- Rake::Task['jenkins:unit'].enhance ['test:foreman_scc_manager', 'foreman_scc_manager:rubocop']
47
- end
45
+ Rake::Task['jenkins:unit'].enhance ['test:foreman_scc_manager', 'foreman_scc_manager:rubocop'] if Rake::Task.task_defined?(:'jenkins:unit')
@@ -1,61 +1,61 @@
1
1
  # Autogenerated!
2
- _("Delete Lifecycle Environment")
3
- _("Destroy Content Host")
4
- _("Hypervisors")
5
- _("Hypervisors update")
6
- _("Install package")
7
- _("Remove package")
8
- _("Update for host")
9
- _("Install Applicable Errata")
10
- _("Update package")
11
- _("Update")
12
- _("Install package group")
13
- _("Package Profile Update")
14
- _("Configure capsule")
15
- _("Auto-attach subscriptions")
16
- _("Create repos")
17
- _("Create")
18
- _("Remove package group")
19
- _("Install erratum")
20
- _("Register Host")
21
- _("Remove subscriptions")
22
- _("Unregister Host")
23
- _("Delete Activation Key")
24
- _("Abstract async task")
25
- _("Incremental Update")
26
- _("Destroy")
27
- _("Synchronize capsule content")
28
- _("Product Create")
29
- _("Export")
30
- _("Delete Product")
31
- _("Delete")
32
- _("Auto attach subscriptions")
33
- _("Reindex subscriptions")
34
- _("Errata mail")
35
- _("Attach subscriptions")
36
- _("Incremental Update of 0 Content View Version(s) ")
37
- _("Import Puppet classes")
38
- _("Import facts")
39
- _("Filtered index content")
40
- _("Upload into")
41
- _("Action with sub plans")
42
- _("Upload errata into")
43
- _("Remove from Environment")
44
- _("Sync SUSE subscriptions")
45
- _("Enable")
46
- _("Index errata")
47
- _("Remove Version")
48
- _("Index package groups")
49
- _("Add Sync Plan Products")
50
- _("Sync SUSE subscriptions (Products)")
51
- _("Remove Content")
52
- _("Index content")
53
- _("Disable")
54
- _("Sync SUSE subscriptions (Repositories)")
55
- _("Subscribe SCC Product")
56
- _("Remove Versions and Associations")
57
- _("Synchronize")
58
- _("Publish")
59
- _("Update Sync Plan Products")
60
- _("Promotion")
61
- _("Update Sync Plan")
2
+ _('Delete Lifecycle Environment')
3
+ _('Destroy Content Host')
4
+ _('Hypervisors')
5
+ _('Hypervisors update')
6
+ _('Install package')
7
+ _('Remove package')
8
+ _('Update for host')
9
+ _('Install Applicable Errata')
10
+ _('Update package')
11
+ _('Update')
12
+ _('Install package group')
13
+ _('Package Profile Update')
14
+ _('Configure capsule')
15
+ _('Auto-attach subscriptions')
16
+ _('Create repos')
17
+ _('Create')
18
+ _('Remove package group')
19
+ _('Install erratum')
20
+ _('Register Host')
21
+ _('Remove subscriptions')
22
+ _('Unregister Host')
23
+ _('Delete Activation Key')
24
+ _('Abstract async task')
25
+ _('Incremental Update')
26
+ _('Destroy')
27
+ _('Synchronize capsule content')
28
+ _('Product Create')
29
+ _('Export')
30
+ _('Delete Product')
31
+ _('Delete')
32
+ _('Auto attach subscriptions')
33
+ _('Reindex subscriptions')
34
+ _('Errata mail')
35
+ _('Attach subscriptions')
36
+ _('Incremental Update of 0 Content View Version(s) ')
37
+ _('Import Puppet classes')
38
+ _('Import facts')
39
+ _('Filtered index content')
40
+ _('Upload into')
41
+ _('Action with sub plans')
42
+ _('Upload errata into')
43
+ _('Remove from Environment')
44
+ _('Sync SUSE subscriptions')
45
+ _('Enable')
46
+ _('Index errata')
47
+ _('Remove Version')
48
+ _('Index package groups')
49
+ _('Add Sync Plan Products')
50
+ _('Sync SUSE subscriptions (Products)')
51
+ _('Remove Content')
52
+ _('Index content')
53
+ _('Disable')
54
+ _('Sync SUSE subscriptions (Repositories)')
55
+ _('Subscribe SCC Product')
56
+ _('Remove Versions and Associations')
57
+ _('Synchronize')
58
+ _('Publish')
59
+ _('Update Sync Plan Products')
60
+ _('Promotion')
61
+ _('Update Sync Plan')
@@ -0,0 +1,10 @@
1
+ require 'test_helper'
2
+
3
+ module ForemanSccManager
4
+ class SccAccountsControllerTest < ActionController::TestCase
5
+ context 'GET #index' do
6
+ test 'should get index' do
7
+ end
8
+ end
9
+ end
10
+ end
@@ -1,4 +1,4 @@
1
- FactoryGirl.define do
1
+ FactoryBot.define do
2
2
  factory :host do
3
3
  name 'foreman_scc_manager'
4
4
  end
@@ -1,6 +1,2 @@
1
1
  # This calls the main test_helper in Foreman-core
2
2
  require 'test_helper'
3
-
4
- # Add plugin to FactoryGirl's paths
5
- FactoryGirl.definition_file_paths << File.join(File.dirname(__FILE__), 'factories')
6
- FactoryGirl.reload
metadata CHANGED
@@ -1,71 +1,71 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman_scc_manager
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ATIX AG
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-05-16 00:00:00.000000000 Z
11
+ date: 2018-08-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: rubocop
14
+ name: rdoc
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.49'
19
+ version: '4'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0.49'
26
+ version: '4'
27
27
  - !ruby/object:Gem::Dependency
28
- name: rdoc
28
+ name: rubocop
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '4'
33
+ version: '0.49'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '4'
40
+ version: '0.49'
41
41
  - !ruby/object:Gem::Dependency
42
- name: rails
42
+ name: foreman-tasks
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '5.1'
47
+ version: '0.10'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '5.1'
54
+ version: '0.10'
55
55
  - !ruby/object:Gem::Dependency
56
- name: foreman-tasks
56
+ name: rails
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '0.10'
61
+ version: '5.1'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '0.10'
68
+ version: '5.1'
69
69
  description: Foreman plugin to sync SUSE Customer Center products and repositories
70
70
  into Katello.
71
71
  email:
@@ -122,6 +122,7 @@ files:
122
122
  - locale/en/foreman_scc_manager.po
123
123
  - locale/foreman_scc_manager.pot
124
124
  - locale/gemspec.rb
125
+ - test/controllers/foreman_scc_manager/scc_accounts_controller_test.rb
125
126
  - test/factories/foreman_scc_manager_factories.rb
126
127
  - test/test_plugin_helper.rb
127
128
  - test/unit/foreman_scc_manager_test.rb
@@ -150,6 +151,7 @@ signing_key:
150
151
  specification_version: 4
151
152
  summary: Suse Customer Center plugin for Foreman
152
153
  test_files:
154
+ - test/controllers/foreman_scc_manager/scc_accounts_controller_test.rb
153
155
  - test/test_plugin_helper.rb
154
156
  - test/unit/foreman_scc_manager_test.rb
155
157
  - test/factories/foreman_scc_manager_factories.rb