hammer_cli_katello 0.3.0 → 0.10.0
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 +0 -1
- data/lib/hammer_cli_katello/activation_key.rb +12 -29
- data/lib/hammer_cli_katello/composite_content_view_name_resolvable.rb +6 -8
- data/lib/hammer_cli_katello/content_override.rb +48 -0
- data/lib/hammer_cli_katello/content_view.rb +98 -5
- data/lib/hammer_cli_katello/content_view_name_resolvable.rb +4 -6
- data/lib/hammer_cli_katello/content_view_purge.rb +92 -0
- data/lib/hammer_cli_katello/content_view_version.rb +13 -0
- data/lib/hammer_cli_katello/erratum.rb +9 -0
- data/lib/hammer_cli_katello/filter_rule.rb +3 -4
- data/lib/hammer_cli_katello/host_collection.rb +8 -2
- data/lib/hammer_cli_katello/host_errata.rb +1 -1
- data/lib/hammer_cli_katello/host_subscription.rb +25 -0
- data/lib/hammer_cli_katello/hostgroup_extensions.rb +7 -6
- data/lib/hammer_cli_katello/id_resolver.rb +13 -4
- data/lib/hammer_cli_katello/katello_environment_name_resolvable.rb +4 -6
- data/lib/hammer_cli_katello/lifecycle_environment_name_resolvable.rb +4 -6
- data/lib/hammer_cli_katello/organization.rb +1 -0
- data/lib/hammer_cli_katello/package.rb +16 -3
- data/lib/hammer_cli_katello/package_group.rb +16 -2
- data/lib/hammer_cli_katello/product_content.rb +36 -0
- data/lib/hammer_cli_katello/repository.rb +48 -7
- data/lib/hammer_cli_katello/version.rb +1 -1
- data/test/data/3.4/foreman_api.json +1 -0
- data/test/functional/{activaton_key → activation_key}/add_host_collection_test.rb +0 -0
- data/test/functional/activation_key/content_override_test.rb +91 -0
- data/test/functional/{activaton_key → activation_key}/create_test.rb +0 -0
- data/test/functional/{activaton_key → activation_key}/list_test.rb +0 -0
- data/test/functional/{activaton_key → activation_key}/product_content_test.rb +0 -0
- data/test/functional/{activaton_key → activation_key}/remove_host_collection_test.rb +0 -0
- data/test/functional/{activaton_key → activation_key}/subscriptions_test.rb +0 -0
- data/test/functional/{activaton_key → activation_key}/update_test.rb +0 -0
- data/test/functional/content_view/add_content_view_version_test.rb +57 -3
- data/test/functional/content_view/add_repository_test.rb +1 -0
- data/test/functional/content_view/copy_test.rb +53 -0
- data/test/functional/content_view/delete_test.rb +62 -0
- data/test/functional/content_view/publish_test.rb +1 -0
- data/test/functional/content_view/puppet_module/add_test.rb +1 -0
- data/test/functional/content_view/purge_test.rb +72 -0
- data/test/functional/content_view/remove_content_view_version_test.rb +57 -3
- data/test/functional/content_view/remove_test.rb +78 -0
- data/test/functional/content_view/update_test.rb +53 -0
- data/test/functional/content_view/version/republish_repositories_test.rb +35 -0
- data/test/functional/erratum/list_test.rb +108 -0
- data/test/functional/host/subscription/content_override_test.rb +95 -0
- data/test/functional/host/subscription/product_content_test.rb +27 -0
- data/test/functional/host_collection/content_api_expectations.rb +35 -0
- data/test/functional/host_collection/content_install_test.rb +42 -17
- data/test/functional/host_collection/content_remove_test.rb +22 -12
- data/test/functional/host_collection/content_update_test.rb +22 -12
- data/test/functional/hostgroup/create_test.rb +6 -0
- data/test/functional/hostgroup/data/hostgroup.json +2 -2
- data/test/functional/hostgroup/info_test.rb +2 -1
- data/test/functional/hostgroup/update_test.rb +12 -0
- data/test/functional/package/list_test.rb +89 -18
- data/test/functional/package_group/list_test.rb +33 -0
- data/test/functional/repository/export_test.rb +121 -0
- data/test/functional/repository/remove_content_test.rb +98 -8
- data/test/functional/repository/update_test.rb +108 -0
- data/test/functional/repository/upload_test.rb +73 -3
- data/test/test_helper.rb +1 -1
- data/test/unit/id_resolver_test.rb +26 -0
- metadata +54 -21
@@ -1,27 +1,37 @@
|
|
1
1
|
require_relative '../test_helper'
|
2
|
+
require_relative './content_api_expectations'
|
2
3
|
require 'hammer_cli_katello/host_collection'
|
3
4
|
|
4
5
|
module HammerCLIKatello
|
5
6
|
describe HostCollection::RemoveContentBaseCommand do
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
end
|
7
|
+
include HammerCLIKatello::ContentAPIExpectations
|
8
|
+
|
9
|
+
def api_expects_content_remove(content_type, expected_params)
|
10
|
+
api_expects_content_action(:remove_content, content_type, expected_params)
|
11
|
+
end
|
12
12
|
|
13
|
+
it 'removes packages from hosts in a host collection' do
|
14
|
+
api_expects_content_remove('package', :content => ['wget'])
|
13
15
|
run_cmd(%w(host-collection package remove --id 3 --packages wget --organization-id 1))
|
14
16
|
end
|
15
17
|
|
16
|
-
it 'removes
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
end
|
18
|
+
it 'removes packages from hosts in a host collection specified by name' do
|
19
|
+
api_expects_collection_search
|
20
|
+
api_expects_content_remove('package', :content => ['wget'])
|
21
|
+
run_cmd(%w(host-collection package remove --name Test --packages wget --organization-id 1))
|
22
|
+
end
|
22
23
|
|
24
|
+
it 'removes package groups from hosts in a host collection' do
|
25
|
+
api_expects_content_remove('package_group', :content => ['birds'])
|
23
26
|
run_cmd(%w(host-collection package-group remove --id 3
|
24
27
|
--package-groups birds --organization-id 1))
|
25
28
|
end
|
29
|
+
|
30
|
+
it 'removes package groups from hosts in a host collection specified by name' do
|
31
|
+
api_expects_collection_search
|
32
|
+
api_expects_content_remove('package_group', :content => ['birds'])
|
33
|
+
run_cmd(%w(host-collection package-group remove --name Test
|
34
|
+
--package-groups birds --organization-id 1))
|
35
|
+
end
|
26
36
|
end
|
27
37
|
end
|
@@ -1,27 +1,37 @@
|
|
1
1
|
require_relative '../test_helper'
|
2
|
+
require_relative './content_api_expectations'
|
2
3
|
require 'hammer_cli_katello/host_collection'
|
3
4
|
|
4
5
|
module HammerCLIKatello
|
5
6
|
describe HostCollection::UpdateContentBaseCommand do
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
end
|
7
|
+
include HammerCLIKatello::ContentAPIExpectations
|
8
|
+
|
9
|
+
def api_expects_content_update(content_type, expected_params)
|
10
|
+
api_expects_content_action(:update_content, content_type, expected_params)
|
11
|
+
end
|
12
12
|
|
13
|
+
it 'updates packages on hosts in a host collection' do
|
14
|
+
api_expects_content_update('package', :content => ['wget'])
|
13
15
|
run_cmd(%w(host-collection package update --id 3 --packages wget --organization-id 1))
|
14
16
|
end
|
15
17
|
|
16
|
-
it 'updates
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
end
|
18
|
+
it 'updates packages on hosts in a host collection specified by name' do
|
19
|
+
api_expects_collection_search
|
20
|
+
api_expects_content_update('package', :content => ['wget'])
|
21
|
+
run_cmd(%w(host-collection package update --name Test --packages wget --organization-id 1))
|
22
|
+
end
|
22
23
|
|
24
|
+
it 'updates package groups on hosts in a host collection' do
|
25
|
+
api_expects_content_update('package_group', :content => ['birds'])
|
23
26
|
run_cmd(%w(host-collection package-group update --id 3
|
24
27
|
--package-groups birds --organization-id 1))
|
25
28
|
end
|
29
|
+
|
30
|
+
it 'updates package groups on hosts in a host collection specified by name' do
|
31
|
+
api_expects_collection_search
|
32
|
+
api_expects_content_update('package_group', :content => ['birds'])
|
33
|
+
run_cmd(%w(host-collection package-group update --name Test
|
34
|
+
--package-groups birds --organization-id 1))
|
35
|
+
end
|
26
36
|
end
|
27
37
|
end
|
@@ -31,6 +31,12 @@ module HammerCLIForeman
|
|
31
31
|
run_cmd(%w(hostgroup create --name hg1 --content-view cv1 --query-organization-id 1))
|
32
32
|
end
|
33
33
|
|
34
|
+
it 'requires organization options to resolve content view name' do
|
35
|
+
api_expects_no_call
|
36
|
+
result = run_cmd(%w(hostgroup create --name hg1 --content-view cv1))
|
37
|
+
assert_match(/--query-organization/, result.err)
|
38
|
+
end
|
39
|
+
|
34
40
|
it 'allows lifecycle environment id' do
|
35
41
|
api_expects(:hostgroups, :create) do |p|
|
36
42
|
p['hostgroup']['name'] == 'hg1' && p['hostgroup']['lifecycle_environment_id'] == 1 &&
|
@@ -21,7 +21,8 @@ module HammerCLIForeman
|
|
21
21
|
|
22
22
|
result = run_cmd(@cmd + params)
|
23
23
|
expected_fields = [['Lifecycle Environment', 'Library'],
|
24
|
-
['Content View', 'Default Organization View']
|
24
|
+
['Content View', 'Default Organization View'],
|
25
|
+
['Content Source', 'foreman.example.com']]
|
25
26
|
expected_results = expected_fields.map { |field| success_result(FieldMatcher.new(*field)) }
|
26
27
|
expected_results.each { |expected| assert_cmd(expected, result) }
|
27
28
|
end
|
@@ -31,6 +31,12 @@ module HammerCLIForeman
|
|
31
31
|
run_cmd(%w(hostgroup update --id 1 --content-view cv1 --query-organization-id 1))
|
32
32
|
end
|
33
33
|
|
34
|
+
it 'requires organization options to resolve content view name' do
|
35
|
+
api_expects_no_call
|
36
|
+
result = run_cmd(%w(hostgroup update --id 1 --content-view cv1))
|
37
|
+
assert_match(/--query-organization/, result.err)
|
38
|
+
end
|
39
|
+
|
34
40
|
it 'allows lifecycle environment id' do
|
35
41
|
api_expects(:hostgroups, :update) do |p|
|
36
42
|
p['id'] == '1' && p['hostgroup']['lifecycle_environment_id'] == 1 &&
|
@@ -56,6 +62,12 @@ module HammerCLIForeman
|
|
56
62
|
result = run_cmd(%w(hostgroup update --name hg1 --lifecycle-environment le1))
|
57
63
|
assert_match(/--query-organization/, result.err)
|
58
64
|
end
|
65
|
+
|
66
|
+
it 'requires organization options to resolve lifecycle environment name' do
|
67
|
+
api_expects_no_call
|
68
|
+
result = run_cmd(%w(hostgroup update --id 1 --lifecycle-environment le1))
|
69
|
+
assert_match(/--query-organization/, result.err)
|
70
|
+
end
|
59
71
|
end
|
60
72
|
end
|
61
73
|
end
|
@@ -1,47 +1,118 @@
|
|
1
1
|
require_relative '../test_helper'
|
2
|
+
require_relative '../repository/repository_helpers'
|
3
|
+
require_relative '../product/product_helpers'
|
4
|
+
require_relative '../organization/organization_helpers'
|
2
5
|
require 'hammer_cli_katello/package'
|
3
6
|
|
4
7
|
module HammerCLIKatello
|
5
8
|
describe PackageCommand::ListCommand do
|
9
|
+
include OrganizationHelpers
|
10
|
+
include RepositoryHelpers
|
11
|
+
include ProductHelpers
|
12
|
+
|
6
13
|
it 'allows minimal options' do
|
7
14
|
api_expects(:packages, :index)
|
8
15
|
|
9
16
|
run_cmd(%w(package list))
|
10
17
|
end
|
11
18
|
|
12
|
-
describe '
|
13
|
-
it '
|
19
|
+
describe 'repository options' do
|
20
|
+
it 'may be specified by ID' do
|
14
21
|
api_expects(:packages, :index) do |params|
|
15
|
-
params['
|
22
|
+
params['repository_id'] == 1
|
16
23
|
end
|
17
24
|
|
18
|
-
run_cmd(%w(package list --
|
25
|
+
run_cmd(%w(package list --repository-id 1))
|
19
26
|
end
|
20
27
|
|
21
|
-
it '
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
28
|
+
it 'require product ID when given repository name' do
|
29
|
+
api_expects_no_call
|
30
|
+
|
31
|
+
r = run_cmd(%w(package list --repository repo1))
|
32
|
+
assert(r.err.include?("--product-id, --product is required"), "Invalid error message")
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'may be specified by name and product ID' do
|
36
|
+
expect_repository_search(2, 'repo1', 1)
|
26
37
|
|
27
38
|
api_expects(:packages, :index) do |params|
|
28
|
-
params['
|
39
|
+
params['repository_id'] == 1
|
29
40
|
end
|
30
41
|
|
31
|
-
run_cmd(%w(package list --
|
42
|
+
run_cmd(%w(package list --repository repo1 --product-id 2))
|
32
43
|
end
|
44
|
+
end
|
33
45
|
|
34
|
-
|
35
|
-
|
36
|
-
|
46
|
+
describe 'product options' do
|
47
|
+
it 'may be specified by ID' do
|
48
|
+
ex = api_expects(:repositories, :index) do |p|
|
49
|
+
p['product_id'] == 1
|
37
50
|
end
|
38
|
-
ex.
|
51
|
+
ex.returns(index_response([{'id' => 2}]))
|
39
52
|
|
40
|
-
api_expects(:packages, :index) do |
|
41
|
-
|
53
|
+
api_expects(:packages, :index) do |p|
|
54
|
+
p['repository_id'] = 2
|
55
|
+
end
|
56
|
+
|
57
|
+
run_cmd(%w(package list --product-id 1))
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'fail if more than one repository is found' do
|
61
|
+
ex = api_expects(:repositories, :index) do |p|
|
62
|
+
p['product_id'] == 1
|
63
|
+
end
|
64
|
+
ex.returns(index_response([{'id' => 2}, {'id' => 3}]))
|
65
|
+
|
66
|
+
r = run_cmd(%w(package list --product-id 1))
|
67
|
+
assert(r.err.include?("found more than one repository"), "Invalid error message")
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'requires organization options to resolve ID by name' do
|
71
|
+
api_expects_no_call
|
72
|
+
|
73
|
+
r = run_cmd(%w(package list --product product1))
|
74
|
+
expected_error = "--organization-id, --organization, --organization-label is required"
|
75
|
+
assert(r.err.include?(expected_error), "Invalid error message")
|
76
|
+
end
|
77
|
+
|
78
|
+
it 'allows organization ID when resolving ID by name' do
|
79
|
+
expect_product_search(3, 'product1', 1)
|
80
|
+
|
81
|
+
expect_repository_search(1, nil, 2)
|
82
|
+
|
83
|
+
api_expects(:packages, :index) do |p|
|
84
|
+
p['repository_id'] = 2
|
85
|
+
end
|
86
|
+
|
87
|
+
run_cmd(%w(package list --product product1 --organization-id 3))
|
88
|
+
end
|
89
|
+
|
90
|
+
it 'allows organization name when resolving ID by name' do
|
91
|
+
expect_organization_search('org3', 3)
|
92
|
+
|
93
|
+
expect_product_search(3, 'product1', 1)
|
94
|
+
|
95
|
+
expect_repository_search(1, nil, 2)
|
96
|
+
|
97
|
+
api_expects(:packages, :index) do |p|
|
98
|
+
p['repository_id'] = 2
|
99
|
+
end
|
100
|
+
|
101
|
+
run_cmd(%w(package list --product product1 --organization org3))
|
102
|
+
end
|
103
|
+
|
104
|
+
it 'allows organization label when resolving ID by name' do
|
105
|
+
expect_organization_search('org3', 3, field: 'label')
|
106
|
+
|
107
|
+
expect_product_search(3, 'product1', 1)
|
108
|
+
|
109
|
+
expect_repository_search(1, nil, 2)
|
110
|
+
|
111
|
+
api_expects(:packages, :index) do |p|
|
112
|
+
p['repository_id'] = 2
|
42
113
|
end
|
43
114
|
|
44
|
-
run_cmd(%w(package list --organization-label
|
115
|
+
run_cmd(%w(package list --product product1 --organization-label org3))
|
45
116
|
end
|
46
117
|
end
|
47
118
|
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require_relative '../test_helper'
|
2
|
+
require 'hammer_cli_katello/package_group'
|
3
|
+
|
4
|
+
module HammerCLIKatello
|
5
|
+
describe PackageGroupCommand::ListCommand do
|
6
|
+
it 'allows minimal options' do
|
7
|
+
api_expects(:package_groups, :index)
|
8
|
+
|
9
|
+
run_cmd(%w(package-group list))
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'can be provided by repository ID' do
|
13
|
+
api_expects(:package_groups, :index) do |params|
|
14
|
+
params['repository_id'] == 1
|
15
|
+
end
|
16
|
+
|
17
|
+
run_cmd(%w(package-group list --repository-id 1))
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'can be provided by repository name' do
|
21
|
+
ex = api_expects(:repositories, :index) do |params|
|
22
|
+
params['name'] = 'Repo'
|
23
|
+
end
|
24
|
+
ex.returns(index_response([{'id' => 1}]))
|
25
|
+
|
26
|
+
api_expects(:package_groups, :index) do |params|
|
27
|
+
params['repository_id'] == 1
|
28
|
+
end
|
29
|
+
|
30
|
+
run_cmd(%w(package-group list --repository Repo))
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,121 @@
|
|
1
|
+
require_relative '../test_helper'
|
2
|
+
require_relative '../organization/organization_helpers'
|
3
|
+
require 'hammer_cli_katello/repository'
|
4
|
+
|
5
|
+
module HammerCLIKatello
|
6
|
+
describe Repository::ExportCommand do
|
7
|
+
include ForemanTaskHelpers
|
8
|
+
include OrganizationHelpers
|
9
|
+
|
10
|
+
it 'allows minimal options' do
|
11
|
+
ex = api_expects(:repositories, :export) do |p|
|
12
|
+
p['id'] == '1'
|
13
|
+
end
|
14
|
+
ex.returns(id: 2)
|
15
|
+
|
16
|
+
expect_foreman_task('2')
|
17
|
+
|
18
|
+
run_cmd(%w(repository export --id 1))
|
19
|
+
end
|
20
|
+
|
21
|
+
describe 'resolves repository ID' do
|
22
|
+
it 'by requiring product' do
|
23
|
+
api_expects_no_call
|
24
|
+
result = run_cmd(%w(repository export --name repo1))
|
25
|
+
assert(result.err[/--product, --product-id is required/], 'Incorrect error message')
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'by product ID' do
|
29
|
+
ex = api_expects(:repositories, :index) do |p|
|
30
|
+
p['name'] == 'repo1' && p['product_id'] == 3
|
31
|
+
end
|
32
|
+
ex.returns(index_response([{'id' => 1}]))
|
33
|
+
|
34
|
+
ex = api_expects(:repositories, :export) do |p|
|
35
|
+
p['id'] == 1
|
36
|
+
end
|
37
|
+
ex.returns(id: 2)
|
38
|
+
|
39
|
+
expect_foreman_task('2')
|
40
|
+
|
41
|
+
run_cmd(%w(repository export --name repo1 --product-id 3))
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe 'resolves product ID' do
|
46
|
+
it 'by requiring organization options' do
|
47
|
+
api_expects_no_call
|
48
|
+
result = run_cmd(%w(repository export --name repo1 --product prod1))
|
49
|
+
assert(result.err[/--organization-id, --organization, --organization-label is required/],
|
50
|
+
"Organization option requirements must be validated")
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'by organization ID' do
|
54
|
+
ex = api_expects(:products, :index) do |p|
|
55
|
+
p['name'] == 'prod3' && p['organization_id'] == '5'
|
56
|
+
end
|
57
|
+
ex.returns(index_response([{'id' => 3}]))
|
58
|
+
|
59
|
+
ex = api_expects(:repositories, :index) do |p|
|
60
|
+
p['name'] == 'repo1' && p['product_id'] == 3
|
61
|
+
end
|
62
|
+
ex.returns(index_response([{'id' => 1}]))
|
63
|
+
|
64
|
+
ex = api_expects(:repositories, :export) do |p|
|
65
|
+
p['id'] == 1
|
66
|
+
end
|
67
|
+
ex.returns(id: 2)
|
68
|
+
|
69
|
+
expect_foreman_task('2')
|
70
|
+
|
71
|
+
run_cmd(%w(repository export --name repo1 --product prod3 --organization-id 5))
|
72
|
+
end
|
73
|
+
|
74
|
+
it 'by organization name' do
|
75
|
+
expect_organization_search('org5', 5)
|
76
|
+
|
77
|
+
ex = api_expects(:products, :index) do |p|
|
78
|
+
p['name'] == 'prod3' && p['organization_id'] == 5
|
79
|
+
end
|
80
|
+
ex.returns(index_response([{'id' => 3}]))
|
81
|
+
|
82
|
+
ex = api_expects(:repositories, :index) do |p|
|
83
|
+
p['name'] == 'repo1' && p['product_id'] == 3
|
84
|
+
end
|
85
|
+
ex.returns(index_response([{'id' => 1}]))
|
86
|
+
|
87
|
+
ex = api_expects(:repositories, :export) do |p|
|
88
|
+
p['id'] == 1
|
89
|
+
end
|
90
|
+
ex.returns(id: 2)
|
91
|
+
|
92
|
+
expect_foreman_task('2')
|
93
|
+
|
94
|
+
run_cmd(%w(repository export --name repo1 --product prod3 --organization org5))
|
95
|
+
end
|
96
|
+
|
97
|
+
it 'by organization label' do
|
98
|
+
expect_organization_search('org5', 5, field: 'label')
|
99
|
+
|
100
|
+
ex = api_expects(:products, :index) do |p|
|
101
|
+
p['name'] == 'prod3' && p['organization_id'] == 5
|
102
|
+
end
|
103
|
+
ex.returns(index_response([{'id' => 3}]))
|
104
|
+
|
105
|
+
ex = api_expects(:repositories, :index) do |p|
|
106
|
+
p['name'] == 'repo1' && p['product_id'] == 3
|
107
|
+
end
|
108
|
+
ex.returns(index_response([{'id' => 1}]))
|
109
|
+
|
110
|
+
ex = api_expects(:repositories, :export) do |p|
|
111
|
+
p['id'] == 1
|
112
|
+
end
|
113
|
+
ex.returns(id: 2)
|
114
|
+
|
115
|
+
expect_foreman_task('2')
|
116
|
+
|
117
|
+
run_cmd(%w(repository export --name repo1 --product prod3 --organization-label org5))
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|