hammer_cli_katello 0.23.2 → 0.24.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/hammer_cli_katello.rb +14 -2
- data/lib/hammer_cli_katello/content_export.rb +72 -0
- data/lib/hammer_cli_katello/content_export_complete.rb +25 -0
- data/lib/hammer_cli_katello/content_export_helper.rb +181 -0
- data/lib/hammer_cli_katello/content_export_incremental.rb +25 -0
- data/lib/hammer_cli_katello/content_import.rb +63 -0
- data/lib/hammer_cli_katello/content_view.rb +3 -1
- data/lib/hammer_cli_katello/content_view_version.rb +2 -1
- data/lib/hammer_cli_katello/id_resolver.rb +5 -1
- data/lib/hammer_cli_katello/ping.rb +10 -3
- data/lib/hammer_cli_katello/version.rb +1 -1
- data/test/data/3.17/foreman_api.json +1 -1
- data/test/data/3.18/foreman_api.json +1 -0
- data/test/functional/content_export/complete/library_test.rb +155 -0
- data/test/functional/content_export/complete/version_test.rb +217 -0
- data/test/functional/content_export/content_export_helpers.rb +26 -0
- data/test/functional/content_export/generate_metadata_test.rb +64 -0
- data/test/functional/content_export/incremental/library_test.rb +172 -0
- data/test/functional/content_export/incremental/version_test.rb +268 -0
- data/test/functional/content_export/list_test.rb +64 -0
- data/test/functional/content_import/library_test.rb +85 -0
- data/test/functional/content_import/metadata.json +1 -0
- data/test/functional/content_import/version_test.rb +85 -0
- data/test/functional/content_view/content_view_helpers.rb +3 -1
- data/test/functional/lifecycle_environment/lifecycle_environment_helpers.rb +1 -1
- data/test/functional/ping_test.rb +2 -1
- data/test/functional/search_helpers.rb +11 -0
- data/test/test_helper.rb +1 -1
- metadata +30 -4
@@ -0,0 +1,64 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '../../test_helper')
|
2
|
+
require 'hammer_cli_katello/content_export'
|
3
|
+
|
4
|
+
describe 'content-export list' do
|
5
|
+
let(:empty_response) do
|
6
|
+
{
|
7
|
+
"total" => 0,
|
8
|
+
"subtotal" => 0,
|
9
|
+
"page" => "1",
|
10
|
+
"per_page" => "1000",
|
11
|
+
"error" => nil,
|
12
|
+
"search" => nil,
|
13
|
+
"sort" => {
|
14
|
+
"by" => nil,
|
15
|
+
"order" => nil
|
16
|
+
},
|
17
|
+
"results" => []
|
18
|
+
}
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'allows minimal options' do
|
22
|
+
ex = api_expects(:content_exports, :index)
|
23
|
+
|
24
|
+
ex.returns(empty_response)
|
25
|
+
# rubocop:disable LineLength
|
26
|
+
expected_result = success_result('---|--------------------|------|----------------------|-------------------------|------------|-----------
|
27
|
+
ID | DESTINATION SERVER | PATH | CONTENT VIEW VERSION | CONTENT VIEW VERSION ID | CREATED AT | UPDATED AT
|
28
|
+
---|--------------------|------|----------------------|-------------------------|------------|-----------
|
29
|
+
')
|
30
|
+
# rubocop:enable LineLength
|
31
|
+
result = run_cmd(%w(content-export list))
|
32
|
+
assert_cmd(expected_result, result)
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'works with content-view-id only' do
|
36
|
+
api_expects(:content_view_versions, :index).returns(empty_response)
|
37
|
+
|
38
|
+
ex = api_expects(:content_exports, :index)
|
39
|
+
|
40
|
+
ex.returns(empty_response)
|
41
|
+
# rubocop:disable LineLength
|
42
|
+
expected_result = success_result('---|--------------------|------|----------------------|-------------------------|------------|-----------
|
43
|
+
ID | DESTINATION SERVER | PATH | CONTENT VIEW VERSION | CONTENT VIEW VERSION ID | CREATED AT | UPDATED AT
|
44
|
+
---|--------------------|------|----------------------|-------------------------|------------|-----------
|
45
|
+
')
|
46
|
+
# rubocop:enable LineLength
|
47
|
+
result = run_cmd(%w(content-export list --content-view-id=1))
|
48
|
+
assert_cmd(expected_result, result)
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'works with content-view-version-id only' do
|
52
|
+
ex = api_expects(:content_exports, :index)
|
53
|
+
|
54
|
+
ex.returns(empty_response)
|
55
|
+
# rubocop:disable LineLength
|
56
|
+
expected_result = success_result('---|--------------------|------|----------------------|-------------------------|------------|-----------
|
57
|
+
ID | DESTINATION SERVER | PATH | CONTENT VIEW VERSION | CONTENT VIEW VERSION ID | CREATED AT | UPDATED AT
|
58
|
+
---|--------------------|------|----------------------|-------------------------|------------|-----------
|
59
|
+
')
|
60
|
+
# rubocop:enable LineLength
|
61
|
+
result = run_cmd(%w(content-export list --content-view-version-id=1))
|
62
|
+
assert_cmd(expected_result, result)
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '../../test_helper')
|
2
|
+
require 'hammer_cli_katello/content_import'
|
3
|
+
|
4
|
+
describe 'content-import library' do
|
5
|
+
include ForemanTaskHelpers
|
6
|
+
|
7
|
+
before do
|
8
|
+
@cmd = %w(content-import library)
|
9
|
+
end
|
10
|
+
|
11
|
+
let(:task_id) { '5' }
|
12
|
+
|
13
|
+
let(:response) do
|
14
|
+
{
|
15
|
+
'id' => task_id,
|
16
|
+
'state' => 'planned'
|
17
|
+
}
|
18
|
+
end
|
19
|
+
|
20
|
+
let(:path) do
|
21
|
+
File.dirname(__FILE__)
|
22
|
+
end
|
23
|
+
|
24
|
+
let(:metadata) do
|
25
|
+
JSON.parse(File.read("#{path}/metadata.json"))
|
26
|
+
end
|
27
|
+
|
28
|
+
let(:organization_id) { 3 }
|
29
|
+
|
30
|
+
it "performs import with required options and async" do
|
31
|
+
params = [
|
32
|
+
"--organization-id=#{organization_id}",
|
33
|
+
"--path=#{path}",
|
34
|
+
'--async'
|
35
|
+
]
|
36
|
+
api_expects(:content_imports, :library)
|
37
|
+
.with_params('organization_id' => organization_id, 'path' => path, 'metadata' => metadata)
|
38
|
+
.returns(response)
|
39
|
+
|
40
|
+
result = run_cmd(@cmd + params)
|
41
|
+
|
42
|
+
assert_equal("Archive is being imported in task #{task_id}.\n", result.out)
|
43
|
+
assert_equal(HammerCLI::EX_OK, result.exit_code)
|
44
|
+
end
|
45
|
+
|
46
|
+
it "performs import with required options" do
|
47
|
+
params = [
|
48
|
+
"--organization-id=#{organization_id}",
|
49
|
+
"--path=#{path}"
|
50
|
+
]
|
51
|
+
|
52
|
+
api_expects(:content_imports, :library)
|
53
|
+
.with_params('organization_id' => organization_id, 'path' => path, 'metadata' => metadata)
|
54
|
+
.returns(response)
|
55
|
+
|
56
|
+
expect_foreman_task(task_id)
|
57
|
+
|
58
|
+
result = run_cmd(@cmd + params)
|
59
|
+
assert_equal(HammerCLI::EX_OK, result.exit_code)
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'fails on missing required params' do
|
63
|
+
params = [
|
64
|
+
'--id=2'
|
65
|
+
]
|
66
|
+
|
67
|
+
result = run_cmd(@cmd + params)
|
68
|
+
expected_error = "Could not import the archive."
|
69
|
+
|
70
|
+
assert_equal(result.exit_code, HammerCLI::EX_USAGE)
|
71
|
+
assert_equal(result.err[/#{expected_error}/], expected_error)
|
72
|
+
end
|
73
|
+
|
74
|
+
it 'fails on missing metadata.json' do
|
75
|
+
bad_path = "/nosuchdir"
|
76
|
+
params = [
|
77
|
+
"--organization-id=#{organization_id}",
|
78
|
+
"--path=#{bad_path}"
|
79
|
+
]
|
80
|
+
result = run_cmd(@cmd + params)
|
81
|
+
expected_error = "Unable to find '#{bad_path}/metadata.json'."
|
82
|
+
|
83
|
+
assert_match(/#{expected_error}/, result.err)
|
84
|
+
end
|
85
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
{"organization":"export-9697","repository_mapping":{"katello-15062":{"repository":"katello","product":"prod","redhat":false},"misc-28137":{"repository":"misc","product":"prod","redhat":false},"candlepin-37918":{"repository":"candlepin","product":"prod","redhat":false}},"content_view":"view","content_view_version":{"major":1,"minor":0},"incremental":false,"toc":"export-24d91ced-3d11-4fa2-b5ea-19a41f7b97a5-20201118_1523-toc.json"}
|
@@ -0,0 +1,85 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '../../test_helper')
|
2
|
+
require 'hammer_cli_katello/content_import'
|
3
|
+
|
4
|
+
describe 'content-import version' do
|
5
|
+
include ForemanTaskHelpers
|
6
|
+
|
7
|
+
before do
|
8
|
+
@cmd = %w(content-import version)
|
9
|
+
end
|
10
|
+
|
11
|
+
let(:task_id) { '5' }
|
12
|
+
|
13
|
+
let(:response) do
|
14
|
+
{
|
15
|
+
'id' => task_id,
|
16
|
+
'state' => 'planned'
|
17
|
+
}
|
18
|
+
end
|
19
|
+
|
20
|
+
let(:path) do
|
21
|
+
File.dirname(__FILE__)
|
22
|
+
end
|
23
|
+
|
24
|
+
let(:metadata) do
|
25
|
+
JSON.parse(File.read("#{path}/metadata.json"))
|
26
|
+
end
|
27
|
+
|
28
|
+
let(:content_view_id) { 3 }
|
29
|
+
|
30
|
+
it "performs import with required options and async" do
|
31
|
+
params = [
|
32
|
+
"--content-view-id=#{content_view_id}",
|
33
|
+
"--path=#{path}",
|
34
|
+
'--async'
|
35
|
+
]
|
36
|
+
api_expects(:content_imports, :version)
|
37
|
+
.with_params('content_view_id' => content_view_id, 'path' => path, 'metadata' => metadata)
|
38
|
+
.returns(response)
|
39
|
+
|
40
|
+
result = run_cmd(@cmd + params)
|
41
|
+
|
42
|
+
assert_equal("Archive is being imported in task #{task_id}.\n", result.out)
|
43
|
+
assert_equal(HammerCLI::EX_OK, result.exit_code)
|
44
|
+
end
|
45
|
+
|
46
|
+
it "performs import with required options" do
|
47
|
+
params = [
|
48
|
+
"--content-view-id=#{content_view_id}",
|
49
|
+
"--path=#{path}"
|
50
|
+
]
|
51
|
+
|
52
|
+
api_expects(:content_imports, :version)
|
53
|
+
.with_params('content_view_id' => content_view_id, 'path' => path, 'metadata' => metadata)
|
54
|
+
.returns(response)
|
55
|
+
|
56
|
+
expect_foreman_task(task_id)
|
57
|
+
|
58
|
+
result = run_cmd(@cmd + params)
|
59
|
+
assert_equal(HammerCLI::EX_OK, result.exit_code)
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'fails on missing required params' do
|
63
|
+
params = [
|
64
|
+
'--id=2'
|
65
|
+
]
|
66
|
+
|
67
|
+
result = run_cmd(@cmd + params)
|
68
|
+
expected_error = "Could not import the archive."
|
69
|
+
|
70
|
+
assert_equal(result.exit_code, HammerCLI::EX_USAGE)
|
71
|
+
assert_equal(result.err[/#{expected_error}/], expected_error)
|
72
|
+
end
|
73
|
+
|
74
|
+
it 'fails on missing metadata.json' do
|
75
|
+
bad_path = "/nosuchdir"
|
76
|
+
params = [
|
77
|
+
"--content-view-id=#{content_view_id}",
|
78
|
+
"--path=#{bad_path}"
|
79
|
+
]
|
80
|
+
result = run_cmd(@cmd + params)
|
81
|
+
expected_error = "Unable to find '#{bad_path}/metadata.json'."
|
82
|
+
|
83
|
+
assert_match(/#{expected_error}/, result.err)
|
84
|
+
end
|
85
|
+
end
|
@@ -13,6 +13,8 @@ module ContentViewHelpers
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def expect_content_view_version_search(params, returns)
|
16
|
-
|
16
|
+
expect_lenient_search(:content_view_versions,
|
17
|
+
params: params,
|
18
|
+
returns: returns)
|
17
19
|
end
|
18
20
|
end
|
@@ -4,7 +4,7 @@ module LifecycleEnvironmentHelpers
|
|
4
4
|
include SearchHelpers
|
5
5
|
|
6
6
|
def expect_lifecycle_environment_search(org_id, name, id)
|
7
|
-
|
7
|
+
expect_lenient_search(:lifecycle_environments,
|
8
8
|
params: {'name' => name, 'organization_id' => org_id},
|
9
9
|
returns: {'id' => id})
|
10
10
|
end
|
@@ -12,7 +12,8 @@ describe 'ping' do
|
|
12
12
|
'candlepin_auth' => {'status' => 'ok', 'duration_ms' => '34'},
|
13
13
|
'katello_events' => {'status' => 'ok', 'message' => '0 messages', 'duration_ms' => '34'},
|
14
14
|
'pulp' => {'status' => 'ok', 'duration_ms' => '34'},
|
15
|
-
'pulp_auth' => {'status' => 'ok', 'duration_ms' => '34'}
|
15
|
+
'pulp_auth' => {'status' => 'ok', 'duration_ms' => '34'},
|
16
|
+
'pulp3' => {'status' => 'ok', 'duration_ms' => '34'}
|
16
17
|
}
|
17
18
|
)
|
18
19
|
|
@@ -3,4 +3,15 @@ module SearchHelpers
|
|
3
3
|
ex = api_expects(resource, :index, "Find the #{resource}").with_params(args[:params])
|
4
4
|
ex.returns(index_response([args[:returns]]))
|
5
5
|
end
|
6
|
+
|
7
|
+
def expect_lenient_search(resource, params:, returns:)
|
8
|
+
ex = api_expects(resource, :index, "Find the #{resource}") do |p|
|
9
|
+
params.each do |key, expected|
|
10
|
+
actual = p[key] || p[key.to_sym] || p[key.to_s]
|
11
|
+
assert_equal expected.to_s, actual.to_s, "key: '#{key}', resource: #{resource}"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
returns = [returns] unless returns.is_a? Array
|
15
|
+
ex.returns(index_response(returns))
|
16
|
+
end
|
6
17
|
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'] || '3.
|
20
|
+
KATELLO_VERSION = Gem::Version.new(ENV['TEST_API_VERSION'] || '3.18')
|
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: 0.
|
4
|
+
version: 0.24.4
|
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:
|
38
|
+
date: 2021-05-12 00:00:00.000000000 Z
|
39
39
|
dependencies:
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
41
|
name: hammer_cli_foreman
|
@@ -240,6 +240,11 @@ files:
|
|
240
240
|
- lib/hammer_cli_katello/commands.rb
|
241
241
|
- lib/hammer_cli_katello/composite_content_view_name_resolvable.rb
|
242
242
|
- lib/hammer_cli_katello/content_credential.rb
|
243
|
+
- lib/hammer_cli_katello/content_export.rb
|
244
|
+
- lib/hammer_cli_katello/content_export_complete.rb
|
245
|
+
- lib/hammer_cli_katello/content_export_helper.rb
|
246
|
+
- lib/hammer_cli_katello/content_export_incremental.rb
|
247
|
+
- lib/hammer_cli_katello/content_import.rb
|
243
248
|
- lib/hammer_cli_katello/content_override.rb
|
244
249
|
- lib/hammer_cli_katello/content_view.rb
|
245
250
|
- lib/hammer_cli_katello/content_view_component.rb
|
@@ -329,6 +334,7 @@ files:
|
|
329
334
|
- test/data/3.15/foreman_api.json
|
330
335
|
- test/data/3.16/foreman_api.json
|
331
336
|
- test/data/3.17/foreman_api.json
|
337
|
+
- test/data/3.18/foreman_api.json
|
332
338
|
- test/data/3.2/foreman_api.json
|
333
339
|
- test/data/3.4/foreman_api.json
|
334
340
|
- test/data/3.5/foreman_api.json
|
@@ -363,6 +369,16 @@ files:
|
|
363
369
|
- test/functional/capsule/list_test.rb
|
364
370
|
- test/functional/content_credentials/info_test.rb
|
365
371
|
- test/functional/content_credentials/list_test.rb
|
372
|
+
- test/functional/content_export/complete/library_test.rb
|
373
|
+
- test/functional/content_export/complete/version_test.rb
|
374
|
+
- test/functional/content_export/content_export_helpers.rb
|
375
|
+
- test/functional/content_export/generate_metadata_test.rb
|
376
|
+
- test/functional/content_export/incremental/library_test.rb
|
377
|
+
- test/functional/content_export/incremental/version_test.rb
|
378
|
+
- test/functional/content_export/list_test.rb
|
379
|
+
- test/functional/content_import/library_test.rb
|
380
|
+
- test/functional/content_import/metadata.json
|
381
|
+
- test/functional/content_import/version_test.rb
|
366
382
|
- test/functional/content_view/add_content_view_version_test.rb
|
367
383
|
- test/functional/content_view/add_repository_test.rb
|
368
384
|
- test/functional/content_view/component/add_test.rb
|
@@ -519,8 +535,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
519
535
|
- !ruby/object:Gem::Version
|
520
536
|
version: '0'
|
521
537
|
requirements: []
|
522
|
-
|
523
|
-
rubygems_version: 2.7.6.2
|
538
|
+
rubygems_version: 3.1.2
|
524
539
|
signing_key:
|
525
540
|
specification_version: 4
|
526
541
|
summary: Katello commands for Hammer
|
@@ -535,6 +550,7 @@ test_files:
|
|
535
550
|
- test/data/3.15/foreman_api.json
|
536
551
|
- test/data/3.16/foreman_api.json
|
537
552
|
- test/data/3.17/foreman_api.json
|
553
|
+
- test/data/3.18/foreman_api.json
|
538
554
|
- test/data/3.2/foreman_api.json
|
539
555
|
- test/data/3.4/foreman_api.json
|
540
556
|
- test/data/3.5/foreman_api.json
|
@@ -569,6 +585,16 @@ test_files:
|
|
569
585
|
- test/functional/capsule/list_test.rb
|
570
586
|
- test/functional/content_credentials/info_test.rb
|
571
587
|
- test/functional/content_credentials/list_test.rb
|
588
|
+
- test/functional/content_export/complete/library_test.rb
|
589
|
+
- test/functional/content_export/complete/version_test.rb
|
590
|
+
- test/functional/content_export/content_export_helpers.rb
|
591
|
+
- test/functional/content_export/generate_metadata_test.rb
|
592
|
+
- test/functional/content_export/incremental/library_test.rb
|
593
|
+
- test/functional/content_export/incremental/version_test.rb
|
594
|
+
- test/functional/content_export/list_test.rb
|
595
|
+
- test/functional/content_import/library_test.rb
|
596
|
+
- test/functional/content_import/metadata.json
|
597
|
+
- test/functional/content_import/version_test.rb
|
572
598
|
- test/functional/content_view/add_content_view_version_test.rb
|
573
599
|
- test/functional/content_view/add_repository_test.rb
|
574
600
|
- test/functional/content_view/component/add_test.rb
|