hammer_cli_katello 1.2.0 → 1.3.0

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.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/lib/hammer_cli_katello/command_extensions/content_source.rb +32 -0
  3. data/lib/hammer_cli_katello/command_extensions/kickstart_repository.rb +50 -0
  4. data/lib/hammer_cli_katello/command_extensions/lifecycle_environment.rb +12 -0
  5. data/lib/hammer_cli_katello/command_extensions.rb +2 -0
  6. data/lib/hammer_cli_katello/commands.rb +1 -1
  7. data/lib/hammer_cli_katello/content_export_helper.rb +6 -2
  8. data/lib/hammer_cli_katello/content_view.rb +11 -0
  9. data/lib/hammer_cli_katello/content_view_version.rb +3 -3
  10. data/lib/hammer_cli_katello/host_errata.rb +1 -2
  11. data/lib/hammer_cli_katello/host_extensions.rb +8 -6
  12. data/lib/hammer_cli_katello/hostgroup_extensions.rb +19 -12
  13. data/lib/hammer_cli_katello/id_resolver.rb +5 -2
  14. data/lib/hammer_cli_katello/option_sources/lifecycle_environment_params.rb +40 -3
  15. data/lib/hammer_cli_katello/organization.rb +28 -3
  16. data/lib/hammer_cli_katello/package.rb +2 -1
  17. data/lib/hammer_cli_katello/ping.rb +7 -0
  18. data/lib/hammer_cli_katello/repository.rb +10 -4
  19. data/lib/hammer_cli_katello/search_options_creators.rb +2 -1
  20. data/lib/hammer_cli_katello/srpm.rb +2 -0
  21. data/lib/hammer_cli_katello/version.rb +1 -1
  22. data/test/data/4.3/foreman_api.json +1 -0
  23. data/test/functional/activation_key/create_test.rb +1 -1
  24. data/test/functional/activation_key/subscriptions_test.rb +1 -1
  25. data/test/functional/content_view/version/promote_test.rb +41 -0
  26. data/test/functional/content_view/version/republish_repositories_test.rb +1 -1
  27. data/test/functional/host/errata/recalculate_test.rb +8 -22
  28. data/test/functional/module_stream/info_test.rb +1 -1
  29. data/test/functional/organization/cdn_configuration_test.rb +42 -0
  30. data/test/functional/organization/info_test.rb +17 -0
  31. data/test/functional/package/list_test.rb +4 -2
  32. data/test/functional/ping_test.rb +3 -1
  33. data/test/functional/srpm/list_test.rb +1 -1
  34. data/test/functional/subscription/list_test.rb +2 -2
  35. data/test/test_helper.rb +1 -1
  36. metadata +11 -7
  37. data/lib/hammer_cli_katello/host_content_source_options.rb +0 -28
  38. data/lib/hammer_cli_katello/host_kickstart_repository_options.rb +0 -49
@@ -4,7 +4,7 @@ require 'hammer_cli_katello/activation_key'
4
4
  module HammerCLIKatello
5
5
  describe ActivationKeyCommand do
6
6
  describe CreateCommand do
7
- it 'allows promoting a content view' do
7
+ it 'allows activation key creation' do
8
8
  ex = api_expects(:organizations, :index) do |p|
9
9
  p[:search] == "name = \"org1\""
10
10
  end
@@ -36,7 +36,7 @@ module HammerCLIKatello
36
36
  end
37
37
 
38
38
  it 'lists subscriptions used by the activation key' do
39
- api_expects(:subscriptions, :index) { |p| p['activation_key_id'] == 1 }
39
+ api_expects(:subscriptions, :index) { |p| p['activation_key_id'] == '1' }
40
40
  run_cmd(%w(activation-key subscriptions --organization-id 1 --id 1))
41
41
  end
42
42
 
@@ -30,5 +30,46 @@ module HammerCLIKatello
30
30
  run_cmd(%w(content-view version promote --organization org1 --content-view cv
31
31
  --to-lifecycle-environment test --version 1 --async))
32
32
  end
33
+
34
+ it 'allows promoting a content view without version name/id' do
35
+ ex = api_expects(:organizations, :index) do |p|
36
+ p[:search] == "name = \"org1\""
37
+ end
38
+ ex.at_least_once.returns(index_response([{'id' => 1}]))
39
+
40
+ ex = api_expects(:content_views, :index) do |p|
41
+ p['name'] == 'cv' && p['organization_id'] == 1
42
+ end
43
+ ex.returns(index_response([{'id' => 3}]))
44
+
45
+ ex = api_expects(:content_view_versions, :index) do |p|
46
+ p['content_view_id'] == 3
47
+ end
48
+ ex.returns(
49
+ index_response(
50
+ [
51
+ {'id' => 6, 'name' => 'cv', 'environments' => [{'id' => 1}]},
52
+ {'id' => 7, 'name' => 'cv2', 'environments' => [{'id' => 9}]}
53
+ ]
54
+ )
55
+ )
56
+
57
+ ex = api_expects(:lifecycle_environments, :index) do |p|
58
+ p['organization_id'] == 1 && p['name'] == 'Library'
59
+ end
60
+ ex.returns(index_response([{'id' => 1}]))
61
+
62
+ ex = api_expects(:lifecycle_environments, :index) do |p|
63
+ p['organization_id'] == 1 && p['name'] == 'test'
64
+ end
65
+ ex.returns(index_response([{'id' => 9}]))
66
+
67
+ api_expects(:content_view_versions, :promote) do |p|
68
+ p['id'] == 6 && p['environment_ids'] == [9]
69
+ end
70
+
71
+ run_cmd(%w(content-view version promote --organization org1 --content-view cv
72
+ --to-lifecycle-environment test --from-lifecycle-environment Library --async))
73
+ end
33
74
  end
34
75
  end
@@ -26,7 +26,7 @@ module HammerCLIKatello
26
26
  expect_foreman_task('3')
27
27
 
28
28
  result = run_cmd(%w(content-view version republish-repositories --organization org1
29
- --content-view cv --version 1))
29
+ --content-view cv --version 1 --force true))
30
30
 
31
31
  assert_equal(result.exit_code, 0)
32
32
  end
@@ -8,33 +8,19 @@ describe 'recalculate errata' do
8
8
  end
9
9
 
10
10
  let(:host_id) { 1 }
11
- let(:task_id) { '5' }
12
- let(:response) do
13
- {
14
- 'id' => task_id,
15
- 'state' => 'stopped'
16
- }
17
- end
18
11
 
19
12
  it "recalculates errata for a host" do
20
13
  params = ["--host-id=#{host_id}"]
21
14
 
22
15
  api_expects(:host_errata, :applicability, 'Host errata recalculate')
23
16
  .with_params('host_id' => host_id)
24
- .returns(response)
25
-
26
- expect_foreman_task(task_id)
27
-
28
- run_cmd(@cmd + params)
29
- end
30
-
31
- it "applies an errata to a host with async flag" do
32
- params = ["--host-id=#{host_id}", "--async"]
33
-
34
- api_expects(:host_errata, :applicability, 'Host errata recalculate')
35
- .with_params('host_id' => host_id)
36
- .returns(response)
37
-
38
- run_cmd(@cmd + params)
17
+ .returns({})
18
+
19
+ expected_result = success_result(
20
+ 'Errata recalculation started.
21
+ '
22
+ )
23
+ result = run_cmd(@cmd + params)
24
+ assert_cmd(expected_result, result)
39
25
  end
40
26
  end
@@ -15,7 +15,7 @@ module HammerCLIKatello
15
15
  .returns(index_response([{'id' => 1}]))
16
16
 
17
17
  api_expects(:module_streams, :show)
18
- .with_params(repository_id: "1", id: 1)
18
+ .with_params(repository_id: 1, id: 1)
19
19
 
20
20
  run_cmd(%w(module-stream info --name duck --repository-id 1))
21
21
  end
@@ -0,0 +1,42 @@
1
+ require_relative '../test_helper'
2
+ require 'hammer_cli_katello/organization'
3
+ require 'hammer_cli_katello/associating_commands'
4
+
5
+ describe HammerCLIKatello::Organization::ConfigureCdnCommand do
6
+ include OrganizationHelpers
7
+ before do
8
+ @cmd = %w(organization configure-cdn)
9
+ end
10
+
11
+ it 'by updates with the right params' do
12
+ org_id = '100'
13
+ org_label = 'org1'
14
+ ssl_cred_id = '1'
15
+ password = "pass"
16
+ username = "foo"
17
+ url = "https://goo.com"
18
+ upstream_label = "GreatOrg"
19
+ params = ["--label=#{org_label}",
20
+ "--url=#{url}",
21
+ "--username=#{username}",
22
+ "--upstream-organization-label=#{upstream_label}",
23
+ "--password=#{password}",
24
+ "--ssl-ca-credential-id=#{ssl_cred_id}"
25
+ ]
26
+ expect_organization_search(org_label, org_id, field: 'label')
27
+
28
+ api_expects(:organizations, :cdn_configuration) do |par|
29
+ par['id'].to_s == org_id &&
30
+ par['username'] == username &&
31
+ par['url'] == url &&
32
+ par['password'] == password &&
33
+ par['ssl_ca_credential_id'].to_s == ssl_cred_id &&
34
+ par['upstream_organization_label'] == upstream_label
35
+ end
36
+
37
+ assert_equal(
38
+ 0,
39
+ run_cmd(@cmd + params).exit_code
40
+ )
41
+ end
42
+ end
@@ -19,4 +19,21 @@ describe HammerCLIKatello::Organization::InfoCommand do
19
19
  expected = success_result(FieldMatcher.new('Simple Content Access', 'Enabled'))
20
20
  assert_cmd(expected, result)
21
21
  end
22
+
23
+ it "includes cdn configuration attributes" do
24
+ org_id = 2
25
+ params = ["--id=#{org_id}"]
26
+ api_expects(:organizations, :index).returns(index_response([{'id' => org_id}]))
27
+
28
+ cdn_configuration = {
29
+ "url" => "https://cdn.redhat.com"
30
+ }
31
+
32
+ api_expects(:organizations, :show)
33
+ .with_params('id' => org_id.to_s)
34
+ .returns("cdn_configuration" => cdn_configuration, "id" => org_id)
35
+ result = run_cmd(@cmd + params)
36
+ expected = success_result(FieldMatcher.new('URL', cdn_configuration["url"]))
37
+ assert_cmd(expected, result)
38
+ end
22
39
  end
@@ -24,7 +24,9 @@ module HammerCLIKatello
24
24
  api_expects(:content_view_versions, :index)
25
25
  .with_params('content_view_id' => 1, 'version' => '2.1')
26
26
  .returns(index_response([{'id' => 5}]))
27
- api_expects(:packages, :index).with_params('content_view_version_id' => 5)
27
+ api_expects(:packages, :index)
28
+ .with_params('content_view_version_id' => 5)
29
+ .returns(index_response([{'id' => 1}, {'id' => 2}]))
28
30
 
29
31
  run_cmd(%w(package list --content-view-id 1 --content-view-version 2.1))
30
32
  end
@@ -86,7 +88,7 @@ module HammerCLIKatello
86
88
  it 'may be specified environment name no org fails' do
87
89
  api_expects_no_call
88
90
  r = run_cmd(%w(package list --environment Library))
89
- expec_err = "--organization, --organization-title, --organization-label, --organization-id"
91
+ expec_err = "Missing options to search organization"
90
92
  puts r.err
91
93
  assert(r.err.include?(expec_err), "Invalid error message")
92
94
  end
@@ -15,6 +15,8 @@ describe 'ping' do
15
15
  'katello_events' =>
16
16
  {'status' => 'ok', 'message' => '0 Processed, 0 Failed', 'duration_ms' => '34'},
17
17
  'pulp3' =>
18
+ {'status' => 'ok', 'duration_ms' => '34'},
19
+ 'pulp3_content' =>
18
20
  {'status' => 'ok', 'duration_ms' => '34'}
19
21
  }
20
22
  end
@@ -26,7 +28,7 @@ describe 'ping' do
26
28
  end
27
29
  let(:standard_response_keys) do
28
30
  %w(katello_agent foreman_tasks candlepin candlepin_events
29
- candlepin_auth katello_events pulp3).sort
31
+ candlepin_auth katello_events pulp3 pulp3_content).sort
30
32
  end
31
33
  let(:hammer_ping) { %w(ping katello) }
32
34
 
@@ -6,7 +6,7 @@ require 'hammer_cli_katello/package'
6
6
  require 'hammer_cli_katello/srpm'
7
7
 
8
8
  module HammerCLIKatello
9
- describe PackageCommand::ListCommand do
9
+ describe SrpmCommand::ListCommand do
10
10
  include OrganizationHelpers
11
11
  include RepositoryHelpers
12
12
  include ProductHelpers
@@ -60,7 +60,7 @@ module HammerCLIKatello
60
60
  end
61
61
 
62
62
  it 'allows host id' do
63
- api_expects(:subscriptions, :index) { |par| par['host_id'] == 1 }
63
+ api_expects(:subscriptions, :index) { |par| par['host_id'] == '1' }
64
64
  run_cmd(%w(subscription list --organization-id 1 --host-id 1))
65
65
  end
66
66
 
@@ -72,7 +72,7 @@ module HammerCLIKatello
72
72
  end
73
73
 
74
74
  it 'allows activation key id' do
75
- api_expects(:subscriptions, :index) { |par| par['activation_key_id'] == 1 }
75
+ api_expects(:subscriptions, :index) { |par| par['activation_key_id'] == '1' }
76
76
  run_cmd(%w(subscription list --organization-id 1 --activation-key-id 1))
77
77
  end
78
78
 
data/test/test_helper.rb CHANGED
@@ -17,7 +17,7 @@ require 'minitest/spec'
17
17
  require 'mocha/minitest'
18
18
  require 'hammer_cli'
19
19
 
20
- KATELLO_VERSION = Gem::Version.new(ENV['TEST_API_VERSION'] || '4.1')
20
+ KATELLO_VERSION = Gem::Version.new(ENV['TEST_API_VERSION'] || '4.3')
21
21
 
22
22
  if HammerCLI.context[:api_connection]
23
23
  HammerCLI.context[:api_connection].create('foreman') do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hammer_cli_katello
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Price
@@ -32,10 +32,10 @@ authors:
32
32
  - Tom McKay
33
33
  - Walden Raines
34
34
  - Zach Huntington-Meath
35
- autorequire:
35
+ autorequire:
36
36
  bindir: bin
37
37
  cert_chain: []
38
- date: 2021-08-12 00:00:00.000000000 Z
38
+ date: 2021-11-11 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: hammer_cli_foreman
@@ -206,6 +206,8 @@ files:
206
206
  - lib/hammer_cli_katello/associating_commands.rb
207
207
  - lib/hammer_cli_katello/capsule.rb
208
208
  - lib/hammer_cli_katello/command_extensions.rb
209
+ - lib/hammer_cli_katello/command_extensions/content_source.rb
210
+ - lib/hammer_cli_katello/command_extensions/kickstart_repository.rb
209
211
  - lib/hammer_cli_katello/command_extensions/lifecycle_environment.rb
210
212
  - lib/hammer_cli_katello/command_extensions/lifecycle_environments.rb
211
213
  - lib/hammer_cli_katello/command_extensions/ping.rb
@@ -239,11 +241,9 @@ files:
239
241
  - lib/hammer_cli_katello/host_collection_erratum.rb
240
242
  - lib/hammer_cli_katello/host_collection_package.rb
241
243
  - lib/hammer_cli_katello/host_collection_package_group.rb
242
- - lib/hammer_cli_katello/host_content_source_options.rb
243
244
  - lib/hammer_cli_katello/host_deb.rb
244
245
  - lib/hammer_cli_katello/host_errata.rb
245
246
  - lib/hammer_cli_katello/host_extensions.rb
246
- - lib/hammer_cli_katello/host_kickstart_repository_options.rb
247
247
  - lib/hammer_cli_katello/host_package.rb
248
248
  - lib/hammer_cli_katello/host_package_group.rb
249
249
  - lib/hammer_cli_katello/host_subscription.rb
@@ -317,6 +317,7 @@ files:
317
317
  - test/data/3.9/foreman_api.json
318
318
  - test/data/4.0/foreman_api.json
319
319
  - test/data/4.1/foreman_api.json
320
+ - test/data/4.3/foreman_api.json
320
321
  - test/data/Readme.md
321
322
  - test/functional/activation_key/add_host_collection_test.rb
322
323
  - test/functional/activation_key/content_override_test.rb
@@ -439,6 +440,7 @@ files:
439
440
  - test/functional/local_helper_test.rb
440
441
  - test/functional/module_stream/info_test.rb
441
442
  - test/functional/module_stream/list_test.rb
443
+ - test/functional/organization/cdn_configuration_test.rb
442
444
  - test/functional/organization/delete_test.rb
443
445
  - test/functional/organization/info_test.rb
444
446
  - test/functional/organization/organization_helpers.rb
@@ -491,7 +493,7 @@ homepage: https://github.com/Katello/hammer-cli-katello
491
493
  licenses:
492
494
  - GPL-3.0
493
495
  metadata: {}
494
- post_install_message:
496
+ post_install_message:
495
497
  rdoc_options: []
496
498
  require_paths:
497
499
  - lib
@@ -507,7 +509,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
507
509
  version: '0'
508
510
  requirements: []
509
511
  rubygems_version: 3.1.6
510
- signing_key:
512
+ signing_key:
511
513
  specification_version: 4
512
514
  summary: Katello commands for Hammer
513
515
  test_files:
@@ -532,6 +534,7 @@ test_files:
532
534
  - test/data/3.9/foreman_api.json
533
535
  - test/data/4.0/foreman_api.json
534
536
  - test/data/4.1/foreman_api.json
537
+ - test/data/4.3/foreman_api.json
535
538
  - test/data/Readme.md
536
539
  - test/functional/activation_key/add_host_collection_test.rb
537
540
  - test/functional/activation_key/content_override_test.rb
@@ -654,6 +657,7 @@ test_files:
654
657
  - test/functional/local_helper_test.rb
655
658
  - test/functional/module_stream/info_test.rb
656
659
  - test/functional/module_stream/list_test.rb
660
+ - test/functional/organization/cdn_configuration_test.rb
657
661
  - test/functional/organization/delete_test.rb
658
662
  - test/functional/organization/info_test.rb
659
663
  - test/functional/organization/organization_helpers.rb
@@ -1,28 +0,0 @@
1
- module HammerCLIKatello
2
- module HostContentSourceOptions
3
- def self.included(base)
4
- base.option "--content-source", "CONTENT_SOURCE_NAME",
5
- _("Content Source name "),
6
- :attribute_name => :option_content_source
7
- end
8
-
9
- def request_params
10
- super.tap do |mod|
11
- resource_name = resource.singular_name
12
- if option_content_source && !option_content_source_id
13
- resource_hash = if resource_name == "hostgroup"
14
- mod[resource_name]
15
- else
16
- mod[resource_name]["content_facet_attributes"]
17
- end
18
-
19
- proxy_options = { HammerCLI.option_accessor_name('name') => option_content_source}
20
- resource_hash["content_source_id"] = resolver.smart_proxy_id(proxy_options)
21
- end
22
- end
23
- rescue HammerCLIForeman::ResolverError => e
24
- e.message.gsub!('smart_proxy', _('Content Source'))
25
- raise e
26
- end
27
- end
28
- end
@@ -1,49 +0,0 @@
1
- module HammerCLIKatello
2
- module HostKickstartRepositoryOptions
3
- def self.included(base)
4
- base.option "--kickstart-repository", "REPOSITORY_NAME",
5
- _("Kickstart repository name "),
6
- :attribute_name => :option_kickstart_repository
7
- end
8
-
9
- def request_params
10
- super.tap do |mod|
11
- resource_name = resource.singular_name
12
- if option_kickstart_repository && !option_kickstart_repository_id
13
- resource_hash = if resource_name == "hostgroup"
14
- mod[resource_name]
15
- else
16
- mod[resource_name]["content_facet_attributes"]
17
- end
18
-
19
- resource_hash ||= {}
20
-
21
- env_id = resource_hash["lifecycle_environment_id"]
22
- cv_id = resource_hash["content_view_id"]
23
-
24
- raise _("Please provide --lifecycle-environment-id") unless env_id
25
-
26
- raise _("Please provide --content-view-id") unless cv_id
27
-
28
- resource_hash["kickstart_repository_id"] = fetch_repo_id(cv_id, env_id,
29
- option_kickstart_repository)
30
- end
31
- end
32
- end
33
-
34
- def fetch_repo_id(cv_id, env_id, repo_name)
35
- repo_resource = HammerCLIForeman.foreman_resource(:repositories)
36
- index_options = {
37
- :content_view_id => cv_id,
38
- :environment_id => env_id,
39
- :name => repo_name
40
- }
41
- repos = repo_resource.call(:index, index_options)["results"]
42
- if repos.empty?
43
- raise _("No such repository with name %{name}, in lifecycle environment"\
44
- " %{environment_id} and content view %{content_view_id}" % index_options)
45
- end
46
- repos.first["id"]
47
- end
48
- end
49
- end