hammer_cli_katello 1.4.0 → 1.4.1

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.
@@ -16,12 +16,14 @@ describe HammerCLIKatello::Organization::ConfigureCdnCommand do
16
16
  username = "foo"
17
17
  url = "https://goo.com"
18
18
  upstream_label = "GreatOrg"
19
+ type = 'upstream_server'
19
20
  params = ["--label=#{org_label}",
20
21
  "--url=#{url}",
21
22
  "--username=#{username}",
22
23
  "--upstream-organization-label=#{upstream_label}",
23
24
  "--password=#{password}",
24
- "--ssl-ca-credential-id=#{ssl_cred_id}"
25
+ "--ssl-ca-credential-id=#{ssl_cred_id}",
26
+ "--type=#{type}"
25
27
  ]
26
28
  expect_organization_search(org_label, org_id, field: 'label')
27
29
 
@@ -31,7 +33,8 @@ describe HammerCLIKatello::Organization::ConfigureCdnCommand do
31
33
  par['url'] == url &&
32
34
  par['password'] == password &&
33
35
  par['ssl_ca_credential_id'].to_s == ssl_cred_id &&
34
- par['upstream_organization_label'] == upstream_label
36
+ par['upstream_organization_label'] == upstream_label &&
37
+ par['type'] == type
35
38
  end
36
39
 
37
40
  assert_equal(
@@ -42,6 +42,10 @@ describe "get repository info" do
42
42
  'package_group' => 0,
43
43
  'erratum' => 1,
44
44
  'module_stream' => 0
45
+ },
46
+ 'content_credential' => {
47
+ 'id' => 1,
48
+ 'name' => 'pizza'
45
49
  }
46
50
  )
47
51
  result = run_cmd(@cmd + params)
@@ -62,6 +66,8 @@ describe "get repository info" do
62
66
  ['Id', '79'],
63
67
  ['Name', 'test'],
64
68
  ['GPG Key', ''],
69
+ ['Id', '1'],
70
+ ['Name', 'pizza'],
65
71
  ['Sync', ''],
66
72
  ['Status', 'Not Synced'],
67
73
  ['Last Sync Date', '3 minutes'],
@@ -0,0 +1,105 @@
1
+ require_relative '../test_helper'
2
+ require_relative '../organization/organization_helpers'
3
+ require 'hammer_cli_katello/repository'
4
+ module HammerCLIKatello
5
+ describe Repository::ReclaimSpaceCommand do
6
+ include OrganizationHelpers
7
+ it 'allows minimal options' do
8
+ api_expects(:repositories, :reclaim_space) do |p|
9
+ p['id'] == 1
10
+ end
11
+ run_cmd(%w(repository reclaim-space --id 1))
12
+ end
13
+
14
+ describe 'resolves repository ID' do
15
+ it 'by requiring product' do
16
+ api_expects_no_call
17
+ result = run_cmd(%w(repository reclaim-space --name repo1))
18
+ assert(result.err[/--product, --product-id is required/], 'Incorrect error message')
19
+ end
20
+
21
+ it 'by product ID' do
22
+ ex = api_expects(:repositories, :index) do |p|
23
+ p['name'] == 'repo1' && p['product_id'] == 3
24
+ end
25
+ ex.returns(index_response([{'id' => 1}]))
26
+
27
+ api_expects(:repositories, :reclaim_space) do |p|
28
+ p['id'] == 1
29
+ end
30
+
31
+ run_cmd(%w(repository reclaim-space --name repo1 --product-id 3))
32
+ end
33
+ end
34
+
35
+ describe 'resolves product ID' do
36
+ it 'by requiring organization options' do
37
+ api_expects_no_call
38
+ result = run_cmd(%w(repository reclaim-space --name repo1 --product prod1))
39
+ assert(result.err[/--organization-id, --organization, --organization-label is required/],
40
+ "Organization option requirements must be validated")
41
+ end
42
+
43
+ it 'by organization ID' do
44
+ ex = api_expects(:products, :index) do |p|
45
+ p['name'] == 'prod3' && p['organization_id'] == '5'
46
+ end
47
+ ex.returns(index_response([{'id' => 3}]))
48
+
49
+ ex = api_expects(:repositories, :index) do |p|
50
+ p['name'] == 'repo1' && p['product_id'] == 3
51
+ end
52
+ ex.returns(index_response([{'id' => 1}]))
53
+
54
+ api_expects(:repositories, :reclaim_space) do |p|
55
+ p['id'] == 1
56
+ end
57
+
58
+ run_cmd(%w(repository reclaim-space --name repo1 --product prod3 --organization-id 5
59
+ ))
60
+ end
61
+
62
+ it 'by organization name' do
63
+ expect_organization_search('org5', 5)
64
+
65
+ ex = api_expects(:products, :index) do |p|
66
+ p['name'] == 'prod3' && p['organization_id'] == 5
67
+ end
68
+ ex.returns(index_response([{'id' => 3}]))
69
+
70
+ ex = api_expects(:repositories, :index) do |p|
71
+ p['name'] == 'repo1' && p['product_id'] == 3
72
+ end
73
+ ex.returns(index_response([{'id' => 1}]))
74
+
75
+ api_expects(:repositories, :reclaim_space) do |p|
76
+ p['id'] == 1
77
+ end
78
+
79
+ run_cmd(%w(repository reclaim-space --name repo1 --product prod3 --organization org5
80
+ ))
81
+ end
82
+
83
+ it 'by organization label' do
84
+ expect_organization_search('org5', 5, field: 'label')
85
+
86
+ ex = api_expects(:products, :index) do |p|
87
+ p['name'] == 'prod3' && p['organization_id'] == 5
88
+ end
89
+ ex.returns(index_response([{'id' => 3}]))
90
+
91
+ ex = api_expects(:repositories, :index) do |p|
92
+ p['name'] == 'repo1' && p['product_id'] == 3
93
+ end
94
+ ex.returns(index_response([{'id' => 1}]))
95
+
96
+ api_expects(:repositories, :reclaim_space) do |p|
97
+ p['id'] == 1
98
+ end
99
+
100
+ run_cmd(%w(repository reclaim-space --name repo1 --product prod3 --organization-label org5
101
+ ))
102
+ end
103
+ end
104
+ end
105
+ end
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.3')
20
+ KATELLO_VERSION = Gem::Version.new(ENV['TEST_API_VERSION'] || '4.4')
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.4.0
4
+ version: 1.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Price
@@ -35,7 +35,7 @@ authors:
35
35
  autorequire:
36
36
  bindir: bin
37
37
  cert_chain: []
38
- date: 2022-02-13 00:00:00.000000000 Z
38
+ date: 2022-03-03 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: hammer_cli_foreman
@@ -318,6 +318,7 @@ files:
318
318
  - test/data/4.0/foreman_api.json
319
319
  - test/data/4.1/foreman_api.json
320
320
  - test/data/4.3/foreman_api.json
321
+ - test/data/4.4/foreman_api.json
321
322
  - test/data/Readme.md
322
323
  - test/functional/activation_key/add_host_collection_test.rb
323
324
  - test/functional/activation_key/content_override_test.rb
@@ -462,6 +463,7 @@ files:
462
463
  - test/functional/repository/delete_test.rb
463
464
  - test/functional/repository/info_test.rb
464
465
  - test/functional/repository/list_test.rb
466
+ - test/functional/repository/reclaim_space_test.rb
465
467
  - test/functional/repository/remove_content_test.rb
466
468
  - test/functional/repository/repository_helpers.rb
467
469
  - test/functional/repository/synchronize_test.rb
@@ -537,6 +539,7 @@ test_files:
537
539
  - test/data/4.0/foreman_api.json
538
540
  - test/data/4.1/foreman_api.json
539
541
  - test/data/4.3/foreman_api.json
542
+ - test/data/4.4/foreman_api.json
540
543
  - test/data/Readme.md
541
544
  - test/functional/activation_key/add_host_collection_test.rb
542
545
  - test/functional/activation_key/content_override_test.rb
@@ -681,6 +684,7 @@ test_files:
681
684
  - test/functional/repository/delete_test.rb
682
685
  - test/functional/repository/info_test.rb
683
686
  - test/functional/repository/list_test.rb
687
+ - test/functional/repository/reclaim_space_test.rb
684
688
  - test/functional/repository/remove_content_test.rb
685
689
  - test/functional/repository/repository_helpers.rb
686
690
  - test/functional/repository/synchronize_test.rb