hammer_cli_katello 1.4.0 → 1.5.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.
- checksums.yaml +4 -4
- data/lib/hammer_cli_katello/acs.rb +79 -0
- data/lib/hammer_cli_katello/content_export_complete.rb +8 -0
- data/lib/hammer_cli_katello/content_export_helper.rb +55 -3
- data/lib/hammer_cli_katello/content_export_incremental.rb +8 -0
- data/lib/hammer_cli_katello/content_import.rb +9 -0
- data/lib/hammer_cli_katello/host_collection.rb +2 -0
- data/lib/hammer_cli_katello/id_resolver.rb +3 -2
- data/lib/hammer_cli_katello/organization.rb +11 -0
- data/lib/hammer_cli_katello/repository.rb +65 -3
- data/lib/hammer_cli_katello/version.rb +1 -1
- data/lib/hammer_cli_katello.rb +5 -0
- data/test/data/4.4/foreman_api.json +1 -0
- data/test/data/4.5/foreman_api.json +1 -0
- data/test/data/4.6/foreman_api.json +1 -0
- data/test/functional/acs/create_test.rb +27 -0
- data/test/functional/acs/delete_test.rb +13 -0
- data/test/functional/acs/info_test.rb +55 -0
- data/test/functional/acs/list_test.rb +62 -0
- data/test/functional/acs/update_test.rb +23 -0
- data/test/functional/content_export/complete/repository_test.rb +226 -0
- data/test/functional/content_export/content_export_helpers.rb +7 -0
- data/test/functional/content_export/incremental/repository_test.rb +212 -0
- data/test/functional/module_stream/info_test.rb +2 -2
- data/test/functional/organization/cdn_configuration_test.rb +5 -2
- data/test/functional/organization/info_test.rb +8 -2
- data/test/functional/repository/info_test.rb +4 -4
- data/test/functional/repository/reclaim_space_test.rb +105 -0
- data/test/functional/repository/republish_test.rb +37 -0
- data/test/functional/repository/update_test.rb +1 -0
- data/test/functional/repository_set/disable_test.rb +7 -1
- data/test/test_helper.rb +1 -1
- metadata +27 -2
@@ -7,6 +7,10 @@ describe HammerCLIKatello::Organization::InfoCommand do
|
|
7
7
|
@cmd = %w(organization info)
|
8
8
|
end
|
9
9
|
|
10
|
+
let(:cdn_configuration) do
|
11
|
+
{ "type" => 'network_sync' }
|
12
|
+
end
|
13
|
+
|
10
14
|
it "includes simple content access attributes" do
|
11
15
|
org_id = 2
|
12
16
|
params = ["--id=#{org_id}"]
|
@@ -14,7 +18,8 @@ describe HammerCLIKatello::Organization::InfoCommand do
|
|
14
18
|
|
15
19
|
api_expects(:organizations, :show)
|
16
20
|
.with_params('id' => org_id.to_s)
|
17
|
-
.returns("simple_content_access" => true, "id" => org_id
|
21
|
+
.returns("simple_content_access" => true, "id" => org_id,
|
22
|
+
"cdn_configuration" => cdn_configuration)
|
18
23
|
result = run_cmd(@cmd + params)
|
19
24
|
expected = success_result(FieldMatcher.new('Simple Content Access', 'Enabled'))
|
20
25
|
assert_cmd(expected, result)
|
@@ -26,7 +31,8 @@ describe HammerCLIKatello::Organization::InfoCommand do
|
|
26
31
|
api_expects(:organizations, :index).returns(index_response([{'id' => org_id}]))
|
27
32
|
|
28
33
|
cdn_configuration = {
|
29
|
-
"url" => "https://cdn.redhat.com"
|
34
|
+
"url" => "https://cdn.redhat.com",
|
35
|
+
"type" => "redhat_cdn"
|
30
36
|
}
|
31
37
|
|
32
38
|
api_expects(:organizations, :show)
|
@@ -34,7 +34,7 @@ describe "get repository info" do
|
|
34
34
|
'download_policy' => 'immediate',
|
35
35
|
'unprotected' => true,
|
36
36
|
'last_sync_words' => '3 minutes',
|
37
|
-
'
|
37
|
+
'mirroring_policy' => 'additive',
|
38
38
|
'relative_path' => 'Default_Organization/Library/Test_Repo',
|
39
39
|
'content_counts' => {
|
40
40
|
'rpm' => 1,
|
@@ -53,7 +53,7 @@ describe "get repository info" do
|
|
53
53
|
['Organization', 'Default Organization'],
|
54
54
|
['Red Hat Repository', 'no'],
|
55
55
|
['Content Type', 'yum'],
|
56
|
-
['
|
56
|
+
['Mirroring Policy', 'Additive'],
|
57
57
|
['Publish Via HTTP', 'yes'],
|
58
58
|
['Relative Path', 'Default_Organization/Library/Test_Repo'],
|
59
59
|
['Download Policy', 'immediate'],
|
@@ -110,7 +110,7 @@ describe "get repository info" do
|
|
110
110
|
'download_policy' => 'immediate',
|
111
111
|
'unprotected' => true,
|
112
112
|
'last_sync_words' => '3 minutes',
|
113
|
-
'
|
113
|
+
'mirroring_policy' => 'mirror_complete',
|
114
114
|
'relative_path' => 'Default_Organization/Library/Test_Repo',
|
115
115
|
'content_counts' => {
|
116
116
|
'rpm' => 1,
|
@@ -129,7 +129,7 @@ describe "get repository info" do
|
|
129
129
|
['Organization', 'Default Organization'],
|
130
130
|
['Red Hat Repository', 'no'],
|
131
131
|
['Content Type', 'yum'],
|
132
|
-
['
|
132
|
+
['Mirroring Policy', 'Complete Mirroring'],
|
133
133
|
['Publish Via HTTP', 'yes'],
|
134
134
|
['Relative Path', 'Default_Organization/Library/Test_Repo'],
|
135
135
|
['Download Policy', 'immediate'],
|
@@ -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
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '../test_helper')
|
2
|
+
require File.join(File.dirname(__FILE__), './repository_helpers')
|
3
|
+
require File.join(File.dirname(__FILE__), '../product/product_helpers')
|
4
|
+
|
5
|
+
describe 'Republish a repository' do
|
6
|
+
include RepositoryHelpers
|
7
|
+
include ForemanTaskHelpers
|
8
|
+
include ProductHelpers
|
9
|
+
|
10
|
+
before do
|
11
|
+
@cmd = %w(repository republish)
|
12
|
+
end
|
13
|
+
|
14
|
+
let(:repo_id) { 1 }
|
15
|
+
let(:sync_response) do
|
16
|
+
{
|
17
|
+
'id' => repo_id.to_s,
|
18
|
+
'label' => 'Actions::Katello::Repository::MetadataGenerate',
|
19
|
+
'state' => 'planned'
|
20
|
+
}
|
21
|
+
end
|
22
|
+
|
23
|
+
it "republishes a repository" do
|
24
|
+
params = ["--id=#{repo_id}", "--force=true"]
|
25
|
+
|
26
|
+
ex = api_expects(:repositories, :republish, 'Repository republished.') do |par|
|
27
|
+
par['id'] == repo_id && par['force'] == true
|
28
|
+
end
|
29
|
+
|
30
|
+
ex.returns(sync_response)
|
31
|
+
|
32
|
+
expect_foreman_task('3')
|
33
|
+
|
34
|
+
result = run_cmd(@cmd + params)
|
35
|
+
assert_equal(result.exit_code, 0)
|
36
|
+
end
|
37
|
+
end
|
@@ -27,6 +27,7 @@ module HammerCLIKatello # rubocop:disable Metrics/ModuleLength
|
|
27
27
|
}
|
28
28
|
end
|
29
29
|
it "adds a tag to an image" do
|
30
|
+
skip "Until we https://projects.theforeman.org/issues/34817 is resolved"
|
30
31
|
ex = api_expects(:content_uploads, :create)
|
31
32
|
.with_params('repository_id' => repo_id, :size => 0)
|
32
33
|
|
@@ -32,9 +32,15 @@ module HammerCLIKatello
|
|
32
32
|
end
|
33
33
|
|
34
34
|
it 'from product options' do
|
35
|
+
repo_id = 1001
|
36
|
+
product_id = 3
|
37
|
+
api_expects(:repositories, :index, 'Find a repository')
|
38
|
+
.with_params('product_id' => product_id)
|
39
|
+
.returns(index_response([{'id' => repo_id}]))
|
40
|
+
|
35
41
|
expect_repository_set_search('reposet1', 1, product_id: 3)
|
36
42
|
api_expects(:repository_sets, :disable)
|
37
|
-
.with_params('id' => 1)
|
43
|
+
.with_params('id' => 1, 'repository_id' => repo_id)
|
38
44
|
assert_success run_cmd(%w(repository-set disable --name reposet1 --product-id 3))
|
39
45
|
end
|
40
46
|
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.
|
20
|
+
KATELLO_VERSION = Gem::Version.new(ENV['TEST_API_VERSION'] || '4.6')
|
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
|
+
version: 1.5.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-
|
38
|
+
date: 2022-06-09 00:00:00.000000000 Z
|
39
39
|
dependencies:
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
41
|
name: hammer_cli_foreman
|
@@ -201,6 +201,7 @@ extra_rdoc_files: []
|
|
201
201
|
files:
|
202
202
|
- config/katello.yml
|
203
203
|
- lib/hammer_cli_katello.rb
|
204
|
+
- lib/hammer_cli_katello/acs.rb
|
204
205
|
- lib/hammer_cli_katello/activation_key.rb
|
205
206
|
- lib/hammer_cli_katello/apipie_helper.rb
|
206
207
|
- lib/hammer_cli_katello/associating_commands.rb
|
@@ -318,7 +319,15 @@ files:
|
|
318
319
|
- test/data/4.0/foreman_api.json
|
319
320
|
- test/data/4.1/foreman_api.json
|
320
321
|
- test/data/4.3/foreman_api.json
|
322
|
+
- test/data/4.4/foreman_api.json
|
323
|
+
- test/data/4.5/foreman_api.json
|
324
|
+
- test/data/4.6/foreman_api.json
|
321
325
|
- test/data/Readme.md
|
326
|
+
- test/functional/acs/create_test.rb
|
327
|
+
- test/functional/acs/delete_test.rb
|
328
|
+
- test/functional/acs/info_test.rb
|
329
|
+
- test/functional/acs/list_test.rb
|
330
|
+
- test/functional/acs/update_test.rb
|
322
331
|
- test/functional/activation_key/add_host_collection_test.rb
|
323
332
|
- test/functional/activation_key/content_override_test.rb
|
324
333
|
- test/functional/activation_key/create_test.rb
|
@@ -348,10 +357,12 @@ files:
|
|
348
357
|
- test/functional/content_credentials/info_test.rb
|
349
358
|
- test/functional/content_credentials/list_test.rb
|
350
359
|
- test/functional/content_export/complete/library_test.rb
|
360
|
+
- test/functional/content_export/complete/repository_test.rb
|
351
361
|
- test/functional/content_export/complete/version_test.rb
|
352
362
|
- test/functional/content_export/content_export_helpers.rb
|
353
363
|
- test/functional/content_export/generate_metadata_test.rb
|
354
364
|
- test/functional/content_export/incremental/library_test.rb
|
365
|
+
- test/functional/content_export/incremental/repository_test.rb
|
355
366
|
- test/functional/content_export/incremental/version_test.rb
|
356
367
|
- test/functional/content_export/list_test.rb
|
357
368
|
- test/functional/content_import/library_test.rb
|
@@ -462,8 +473,10 @@ files:
|
|
462
473
|
- test/functional/repository/delete_test.rb
|
463
474
|
- test/functional/repository/info_test.rb
|
464
475
|
- test/functional/repository/list_test.rb
|
476
|
+
- test/functional/repository/reclaim_space_test.rb
|
465
477
|
- test/functional/repository/remove_content_test.rb
|
466
478
|
- test/functional/repository/repository_helpers.rb
|
479
|
+
- test/functional/repository/republish_test.rb
|
467
480
|
- test/functional/repository/synchronize_test.rb
|
468
481
|
- test/functional/repository/update_test.rb
|
469
482
|
- test/functional/repository/upload_test.rb
|
@@ -537,7 +550,15 @@ test_files:
|
|
537
550
|
- test/data/4.0/foreman_api.json
|
538
551
|
- test/data/4.1/foreman_api.json
|
539
552
|
- test/data/4.3/foreman_api.json
|
553
|
+
- test/data/4.4/foreman_api.json
|
554
|
+
- test/data/4.5/foreman_api.json
|
555
|
+
- test/data/4.6/foreman_api.json
|
540
556
|
- test/data/Readme.md
|
557
|
+
- test/functional/acs/create_test.rb
|
558
|
+
- test/functional/acs/delete_test.rb
|
559
|
+
- test/functional/acs/info_test.rb
|
560
|
+
- test/functional/acs/list_test.rb
|
561
|
+
- test/functional/acs/update_test.rb
|
541
562
|
- test/functional/activation_key/add_host_collection_test.rb
|
542
563
|
- test/functional/activation_key/content_override_test.rb
|
543
564
|
- test/functional/activation_key/create_test.rb
|
@@ -567,10 +588,12 @@ test_files:
|
|
567
588
|
- test/functional/content_credentials/info_test.rb
|
568
589
|
- test/functional/content_credentials/list_test.rb
|
569
590
|
- test/functional/content_export/complete/library_test.rb
|
591
|
+
- test/functional/content_export/complete/repository_test.rb
|
570
592
|
- test/functional/content_export/complete/version_test.rb
|
571
593
|
- test/functional/content_export/content_export_helpers.rb
|
572
594
|
- test/functional/content_export/generate_metadata_test.rb
|
573
595
|
- test/functional/content_export/incremental/library_test.rb
|
596
|
+
- test/functional/content_export/incremental/repository_test.rb
|
574
597
|
- test/functional/content_export/incremental/version_test.rb
|
575
598
|
- test/functional/content_export/list_test.rb
|
576
599
|
- test/functional/content_import/library_test.rb
|
@@ -681,8 +704,10 @@ test_files:
|
|
681
704
|
- test/functional/repository/delete_test.rb
|
682
705
|
- test/functional/repository/info_test.rb
|
683
706
|
- test/functional/repository/list_test.rb
|
707
|
+
- test/functional/repository/reclaim_space_test.rb
|
684
708
|
- test/functional/repository/remove_content_test.rb
|
685
709
|
- test/functional/repository/repository_helpers.rb
|
710
|
+
- test/functional/repository/republish_test.rb
|
686
711
|
- test/functional/repository/synchronize_test.rb
|
687
712
|
- test/functional/repository/update_test.rb
|
688
713
|
- test/functional/repository/upload_test.rb
|