hammer_cli_katello 0.3.0 → 0.10.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.
- 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
@@ -0,0 +1,78 @@
|
|
1
|
+
require_relative '../test_helper'
|
2
|
+
require 'hammer_cli_katello/content_view'
|
3
|
+
|
4
|
+
module HammerCLIKatello
|
5
|
+
describe ContentView::RemoveCommand do
|
6
|
+
include ForemanTaskHelpers
|
7
|
+
|
8
|
+
describe 'content view version options' do
|
9
|
+
it 'allows removing versions by ID' do
|
10
|
+
ex = api_expects(:content_views, :remove) do |p|
|
11
|
+
p['id'] == 1 && p['content_view_version_ids'] == %w(6 7 8)
|
12
|
+
end
|
13
|
+
ex.returns(id: 9)
|
14
|
+
|
15
|
+
expect_foreman_task('9')
|
16
|
+
|
17
|
+
run_cmd(%w(content-view remove --id 1 --content-view-version-ids 6,7,8))
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'allows removing versions by version number' do
|
21
|
+
%w(6.0 7.0 8.0).each do |version|
|
22
|
+
ex = api_expects(:content_view_versions, :index) do |p|
|
23
|
+
p['version'] == version && p['content_view_id'] == 1
|
24
|
+
end
|
25
|
+
ex.returns(index_response('id' => version.to_i))
|
26
|
+
end
|
27
|
+
ex = api_expects(:content_views, :remove) do |p|
|
28
|
+
p['id'] == 1 && p['content_view_version_ids'] == %w(6 7 8)
|
29
|
+
end
|
30
|
+
ex.returns(id: 9)
|
31
|
+
|
32
|
+
expect_foreman_task('9')
|
33
|
+
|
34
|
+
run_cmd(%w(content-view remove --id 1 --content-view-versions 6.0,7.0,8.0))
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe 'environment options' do
|
39
|
+
it 'allows removing versions by ID' do
|
40
|
+
ex = api_expects(:content_views, :remove) do |p|
|
41
|
+
p['id'] == 1 && p['environment_ids'] == %w(6 7 8)
|
42
|
+
end
|
43
|
+
ex.returns(id: 9)
|
44
|
+
|
45
|
+
expect_foreman_task('9')
|
46
|
+
|
47
|
+
run_cmd(%w(content-view remove --id 1 --environment-ids 6,7,8))
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'requires organization options when removing environments by name' do
|
51
|
+
api_expects_no_call
|
52
|
+
|
53
|
+
run_cmd(%w(content-view remove --id 1 --environments env6,env7,env8))
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'allows removing environments by name' do
|
57
|
+
environment_ids = [6, 7, 8]
|
58
|
+
all_environment_ids = [3, 4, 5, 6, 7, 8]
|
59
|
+
|
60
|
+
ex = api_expects(:lifecycle_environments, :index) do |p|
|
61
|
+
p['organization_id'] == '1'
|
62
|
+
end
|
63
|
+
ex.returns(index_response(all_environment_ids.map do |id|
|
64
|
+
{'id' => id, 'name' => "env#{id}"}
|
65
|
+
end))
|
66
|
+
|
67
|
+
ex = api_expects(:content_views, :remove) do |p|
|
68
|
+
p['id'] == 1 && p['environment_ids'] == environment_ids
|
69
|
+
end
|
70
|
+
ex.returns(id: 9)
|
71
|
+
|
72
|
+
expect_foreman_task('9')
|
73
|
+
|
74
|
+
run_cmd(%w(content-view remove --id 1 --environments env6,env7,env8 --organization-id 1))
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require_relative '../test_helper'
|
2
|
+
require_relative '../organization/organization_helpers'
|
3
|
+
require_relative '../content_view/content_view_helpers'
|
4
|
+
require 'hammer_cli_katello/content_view'
|
5
|
+
|
6
|
+
module HammerCLIKatello
|
7
|
+
describe ContentView::UpdateCommand do
|
8
|
+
include OrganizationHelpers
|
9
|
+
include ContentViewHelpers
|
10
|
+
|
11
|
+
it 'allows minimal options' do
|
12
|
+
api_expects(:content_views, :update) do |p|
|
13
|
+
p['id'] == 2
|
14
|
+
end
|
15
|
+
run_cmd(%w(content-view update --id 2))
|
16
|
+
end
|
17
|
+
|
18
|
+
describe 'OrganizationOptions' do
|
19
|
+
it 'requires organization if content view name is supplied' do
|
20
|
+
api_expects_no_call
|
21
|
+
result = run_cmd(%w(content-view update --name cv2))
|
22
|
+
assert(result.err[/--organization-id, --organization, --organization-label is required/],
|
23
|
+
"Organization option requirements are validated")
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'allows organization id' do
|
27
|
+
expect_content_view_search('1', 'cv2', 2)
|
28
|
+
api_expects(:content_views, :update) do |p|
|
29
|
+
p['id'] == 2
|
30
|
+
end
|
31
|
+
run_cmd(%w(content-view update --name cv2 --organization-id 1))
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'allows organization name' do
|
35
|
+
expect_organization_search('org1', 1)
|
36
|
+
expect_content_view_search(1, 'cv2', 2)
|
37
|
+
api_expects(:content_views, :update) do |p|
|
38
|
+
p['id'] == 2
|
39
|
+
end
|
40
|
+
run_cmd(%w(content-view update --name cv2 --organization org1))
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'allows organization label' do
|
44
|
+
expect_organization_search('org1', 1, field: 'label')
|
45
|
+
expect_content_view_search(1, 'cv2', 2)
|
46
|
+
api_expects(:content_views, :update) do |p|
|
47
|
+
p['id'] == 2
|
48
|
+
end
|
49
|
+
run_cmd(%w(content-view update --name cv2 --organization-label org1))
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require_relative '../../test_helper'
|
2
|
+
require 'hammer_cli_katello/content_view_puppet_module'
|
3
|
+
|
4
|
+
module HammerCLIKatello
|
5
|
+
describe ContentViewPuppetModule do
|
6
|
+
include ForemanTaskHelpers
|
7
|
+
include OrganizationHelpers
|
8
|
+
|
9
|
+
it 'allows republishing repositories on a content view version' do
|
10
|
+
expect_organization_search('org1', 1)
|
11
|
+
|
12
|
+
ex = api_expects(:content_views, :index) do |p|
|
13
|
+
p['name'] == 'cv' && p['organization_id'] == 1
|
14
|
+
end
|
15
|
+
ex.returns(index_response([{'id' => 3}]))
|
16
|
+
|
17
|
+
ex = api_expects(:content_view_versions, :index) do |p|
|
18
|
+
p['version'] == '1' && p['content_view_id'] == 3
|
19
|
+
end
|
20
|
+
ex.returns(index_response([{'id' => 6}]))
|
21
|
+
|
22
|
+
ex = api_expects(:content_view_versions, :republish_repositories) do |p|
|
23
|
+
p['id'] == 6
|
24
|
+
end
|
25
|
+
ex.returns('state' => 'pending', 'id' => '3')
|
26
|
+
|
27
|
+
expect_foreman_task('3')
|
28
|
+
|
29
|
+
result = run_cmd(%w(content-view version republish-repositories --organization org1
|
30
|
+
--content-view cv --version 1))
|
31
|
+
|
32
|
+
assert_equal(result.exit_code, 0)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,108 @@
|
|
1
|
+
require_relative '../test_helper'
|
2
|
+
require 'hammer_cli_katello/erratum'
|
3
|
+
|
4
|
+
module HammerCLIKatello
|
5
|
+
describe ErratumCommand::ListCommand do
|
6
|
+
it 'allows minimal options' do
|
7
|
+
api_expects(:errata, :index)
|
8
|
+
|
9
|
+
run_cmd(%w(erratum list))
|
10
|
+
end
|
11
|
+
|
12
|
+
describe 'product options' do
|
13
|
+
it 'may be specified by ID' do
|
14
|
+
ex = api_expects(:repositories, :index) do |p|
|
15
|
+
p['product_id'] == 1
|
16
|
+
end
|
17
|
+
ex.returns(index_response([{'id' => 2}]))
|
18
|
+
|
19
|
+
api_expects(:errata, :index) do |p|
|
20
|
+
p['repository_id'] = 2
|
21
|
+
end
|
22
|
+
|
23
|
+
run_cmd(%w(erratum list --product-id 1))
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'fail if more than one repository is found' do
|
27
|
+
ex = api_expects(:repositories, :index) do |p|
|
28
|
+
p['product_id'] == 1
|
29
|
+
end
|
30
|
+
ex.returns(index_response([{'id' => 2}, {'id' => 3}]))
|
31
|
+
|
32
|
+
r = run_cmd(%w(erratum list --product-id 1))
|
33
|
+
assert r.err.include? "found more than one repository"
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'requires organization options to resolve ID by name' do
|
37
|
+
api_expects_no_call
|
38
|
+
|
39
|
+
r = run_cmd(%w(erratum list --product product1))
|
40
|
+
assert r.err.include? "--organization-id, --organization, --organization-label is required"
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'allows organization ID when resolving ID by name' do
|
44
|
+
ex = api_expects(:products, :index) do |p|
|
45
|
+
p['name'] == 'product1' && p['organization_id'] == 3
|
46
|
+
end
|
47
|
+
ex.returns(index_response([{'id' => 1}]))
|
48
|
+
|
49
|
+
ex = api_expects(:repositories, :index) do |p|
|
50
|
+
p['product_id'] == 1
|
51
|
+
end
|
52
|
+
ex.returns(index_response([{'id' => 2}]))
|
53
|
+
|
54
|
+
api_expects(:errata, :index) do |p|
|
55
|
+
p['repository_id'] = 2
|
56
|
+
end
|
57
|
+
|
58
|
+
run_cmd(%w(erratum list --product product1 --organization-id 3))
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'allows organization name when resolving ID by name' do
|
62
|
+
ex = api_expects(:organizations, :index) do |p|
|
63
|
+
p[:search] == "name = \"org3\""
|
64
|
+
end
|
65
|
+
ex.at_least_once.returns(index_response([{'id' => 3}]))
|
66
|
+
|
67
|
+
ex = api_expects(:products, :index) do |p|
|
68
|
+
p['name'] == 'product1' && p['organization_id'] == 3
|
69
|
+
end
|
70
|
+
ex.returns(index_response([{'id' => 1}]))
|
71
|
+
|
72
|
+
ex = api_expects(:repositories, :index) do |p|
|
73
|
+
p['product_id'] == 1
|
74
|
+
end
|
75
|
+
ex.returns(index_response([{'id' => 2}]))
|
76
|
+
|
77
|
+
api_expects(:errata, :index) do |p|
|
78
|
+
p['repository_id'] = 2
|
79
|
+
end
|
80
|
+
|
81
|
+
run_cmd(%w(erratum list --product product1 --organization org3))
|
82
|
+
end
|
83
|
+
|
84
|
+
it 'allows organization label when resolving ID by name' do
|
85
|
+
ex = api_expects(:organizations, :index) do |p|
|
86
|
+
p[:search] == "label = \"org3\""
|
87
|
+
end
|
88
|
+
ex.at_least_once.returns(index_response([{'id' => 3}]))
|
89
|
+
|
90
|
+
ex = api_expects(:products, :index) do |p|
|
91
|
+
p['name'] == 'product1' && p['organization_id'] == 3
|
92
|
+
end
|
93
|
+
ex.returns(index_response([{'id' => 1}]))
|
94
|
+
|
95
|
+
ex = api_expects(:repositories, :index) do |p|
|
96
|
+
p['product_id'] == 1
|
97
|
+
end
|
98
|
+
ex.returns(index_response([{'id' => 2}]))
|
99
|
+
|
100
|
+
api_expects(:errata, :index) do |p|
|
101
|
+
p['repository_id'] = 2
|
102
|
+
end
|
103
|
+
|
104
|
+
run_cmd(%w(erratum list --product product1 --organization-label org3))
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
@@ -0,0 +1,95 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '../../test_helper')
|
2
|
+
require File.join(File.dirname(__FILE__), '../host_helpers')
|
3
|
+
require 'hammer_cli_katello/host_subscription'
|
4
|
+
|
5
|
+
describe 'host subscription content-override' do
|
6
|
+
include HostHelpers
|
7
|
+
|
8
|
+
before do
|
9
|
+
@cmd = %w(host subscription content-override)
|
10
|
+
end
|
11
|
+
|
12
|
+
it "attaches a content label" do
|
13
|
+
label = "foo"
|
14
|
+
value = 'default'
|
15
|
+
id = '20'
|
16
|
+
params = ["--host-id=#{id}", "--content-label=#{label}", "--value=#{value}"]
|
17
|
+
ex = api_expects(:host_subscriptions, :content_override, "content override") do |par|
|
18
|
+
par['host_id'].to_s == id && par["content_overrides"][0]['content_label'] == label &&
|
19
|
+
par['content_overrides'][0]['value'] == value &&
|
20
|
+
par['content_overrides'][0]['name'] == "enabled"
|
21
|
+
end
|
22
|
+
ex.returns({})
|
23
|
+
|
24
|
+
expected_result = success_result("Updated content override\n")
|
25
|
+
|
26
|
+
result = run_cmd(@cmd + params)
|
27
|
+
assert_cmd(expected_result, result)
|
28
|
+
end
|
29
|
+
|
30
|
+
it "attaches a content label with name" do
|
31
|
+
label = "foo"
|
32
|
+
value = '1'
|
33
|
+
id = '20'
|
34
|
+
name = 'protected'
|
35
|
+
params = ["--host-id=#{id}", "--content-label=#{label}", "--value=#{value}", "--name=#{name}"]
|
36
|
+
ex = api_expects(:host_subscriptions, :content_override, "content override") do |par|
|
37
|
+
par['host_id'].to_s == id && par["content_overrides"][0]['content_label'] == label &&
|
38
|
+
par['content_overrides'][0]['value'] == value &&
|
39
|
+
par['content_overrides'][0]['name'] == name
|
40
|
+
end
|
41
|
+
ex.returns({})
|
42
|
+
|
43
|
+
expected_result = success_result("Updated content override\n")
|
44
|
+
|
45
|
+
result = run_cmd(@cmd + params)
|
46
|
+
assert_cmd(expected_result, result)
|
47
|
+
end
|
48
|
+
|
49
|
+
it "removes override" do
|
50
|
+
label = "foo"
|
51
|
+
id = '20'
|
52
|
+
params = ["--host-id=#{id}", "--content-label=#{label}", "--remove"]
|
53
|
+
ex = api_expects(:host_subscriptions, :content_override, "content override") do |par|
|
54
|
+
par['host_id'].to_s == id && par["content_overrides"][0]['content_label'] == label &&
|
55
|
+
par['content_overrides'][0]['remove'] == true &&
|
56
|
+
par['content_overrides'][0]['name'] == "enabled"
|
57
|
+
end
|
58
|
+
ex.returns({})
|
59
|
+
|
60
|
+
expected_result = success_result("Updated content override\n")
|
61
|
+
|
62
|
+
result = run_cmd(@cmd + params)
|
63
|
+
assert_cmd(expected_result, result)
|
64
|
+
end
|
65
|
+
|
66
|
+
it "removes override with name" do
|
67
|
+
label = "foo"
|
68
|
+
id = '20'
|
69
|
+
name = 'protected'
|
70
|
+
params = ["--host-id=#{id}", "--content-label=#{label}", "--name=#{name}", "--remove"]
|
71
|
+
ex = api_expects(:host_subscriptions, :content_override, "content override") do |par|
|
72
|
+
par['host_id'].to_s == id && par["content_overrides"][0]['content_label'] == label &&
|
73
|
+
par['content_overrides'][0]['remove'] == true &&
|
74
|
+
par['content_overrides'][0]['name'] == name
|
75
|
+
end
|
76
|
+
ex.returns({})
|
77
|
+
|
78
|
+
expected_result = success_result("Updated content override\n")
|
79
|
+
|
80
|
+
result = run_cmd(@cmd + params)
|
81
|
+
assert_cmd(expected_result, result)
|
82
|
+
end
|
83
|
+
|
84
|
+
it "validation fails on no override value or remove" do
|
85
|
+
api_expects_no_call
|
86
|
+
label = "foo"
|
87
|
+
id = '20'
|
88
|
+
name = 'protected'
|
89
|
+
params = ["--host-id=#{id}", "--content-label=#{label}", "--name=#{name}"]
|
90
|
+
result = run_cmd(@cmd + params)
|
91
|
+
|
92
|
+
assert(result.err[/At least one of options --remove, --value is required/],
|
93
|
+
"Remove or Value must be provided")
|
94
|
+
end
|
95
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '../../test_helper')
|
2
|
+
require File.join(File.dirname(__FILE__), '../host_helpers')
|
3
|
+
require 'hammer_cli_katello/host_subscription'
|
4
|
+
|
5
|
+
describe 'listing available product content' do
|
6
|
+
include HostHelpers
|
7
|
+
|
8
|
+
let(:host_id) { 1 }
|
9
|
+
let(:empty_response_table) do
|
10
|
+
<<eostring
|
11
|
+
---|------|------|-----|---------|-------|----------|---------
|
12
|
+
ID | NAME | TYPE | URL | GPG KEY | LABEL | ENABLED? | OVERRIDE
|
13
|
+
---|------|------|-----|---------|-------|----------|---------
|
14
|
+
eostring
|
15
|
+
end
|
16
|
+
|
17
|
+
it "lists content available for a host" do
|
18
|
+
ex = api_expects(:host_subscriptions, :product_content) do |p|
|
19
|
+
p['id'] = host_id
|
20
|
+
end
|
21
|
+
ex.returns(index_response([]))
|
22
|
+
assert_cmd(
|
23
|
+
success_result(empty_response_table),
|
24
|
+
run_cmd(%w(host subscription product-content --host-id 1))
|
25
|
+
)
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module HammerCLIKatello
|
2
|
+
module ContentAPIExpectations
|
3
|
+
ORGANIZATION_ID = 1
|
4
|
+
HOST_COLLECTION_ID = 3
|
5
|
+
HOST_COLLECTION_NAME = 'Test'.freeze
|
6
|
+
|
7
|
+
def host_collection
|
8
|
+
{
|
9
|
+
'id' => HOST_COLLECTION_ID,
|
10
|
+
'name' => HOST_COLLECTION_NAME
|
11
|
+
}
|
12
|
+
end
|
13
|
+
|
14
|
+
def api_expects_content_action(action, content_type, expected_params)
|
15
|
+
expected_params[:organization_id] ||= ORGANIZATION_ID
|
16
|
+
expected_params[:host_collection_id] ||= HOST_COLLECTION_ID
|
17
|
+
|
18
|
+
api_expects(:hosts_bulk_actions, action) do |p|
|
19
|
+
search_query = "host_collection_id=\"#{expected_params[:host_collection_id]}\""
|
20
|
+
p['organization_id'] == expected_params[:organization_id] &&
|
21
|
+
p['included'] == { search: search_query } &&
|
22
|
+
p['content'] == expected_params[:content] &&
|
23
|
+
p['content_type'] == content_type
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def api_expects_collection_search
|
28
|
+
expectation = api_expects(:host_collections, :index) do |p|
|
29
|
+
p["name"] == HOST_COLLECTION_NAME &&
|
30
|
+
p["organization_id"] == ORGANIZATION_ID
|
31
|
+
end
|
32
|
+
expectation.returns(index_response([host_collection]))
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -1,37 +1,62 @@
|
|
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::InstallContentBaseCommand do
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
end
|
7
|
+
include HammerCLIKatello::ContentAPIExpectations
|
8
|
+
|
9
|
+
def api_expects_content_install(content_type, expected_params)
|
10
|
+
api_expects_content_action(:install_content, content_type, expected_params)
|
11
|
+
end
|
12
12
|
|
13
|
+
it 'installs packages to hosts in a host collection' do
|
14
|
+
api_expects_content_install('package', :content => ['wget'])
|
13
15
|
run_cmd(%w(host-collection package install --id 3 --packages wget --organization-id 1))
|
14
16
|
end
|
15
17
|
|
18
|
+
it 'installs packages to hosts in a host collection specified by name' do
|
19
|
+
api_expects_collection_search
|
20
|
+
api_expects_content_install('package', :content => ['wget'])
|
21
|
+
run_cmd(%w(host-collection package install --name Test --packages wget --organization-id 1))
|
22
|
+
end
|
23
|
+
|
16
24
|
it 'installs package groups to hosts in a host collection' do
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
end
|
25
|
+
api_expects_content_install('package_group', :content => ['birds'])
|
26
|
+
run_cmd(%w(host-collection package-group install --id 3
|
27
|
+
--package-groups birds --organization-id 1))
|
28
|
+
end
|
22
29
|
|
30
|
+
it 'installs package groups to hosts in a host collection specified by name' do
|
31
|
+
api_expects_collection_search
|
32
|
+
api_expects_content_install('package_group', :content => ['birds'])
|
33
|
+
run_cmd(%w(host-collection package-group install --name Test
|
34
|
+
--package-groups birds --organization-id 1))
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'installs package groups to hosts in a host collection' do
|
38
|
+
api_expects_content_install('package_group', :content => ['birds'])
|
23
39
|
run_cmd(%w(host-collection package-group install --id 3
|
24
40
|
--package-groups birds --organization-id 1))
|
25
41
|
end
|
26
42
|
|
27
|
-
it 'installs
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
43
|
+
it 'installs package groups to hosts in a host collection specified by name' do
|
44
|
+
api_expects_collection_search
|
45
|
+
api_expects_content_install('package_group', :content => ['birds'])
|
46
|
+
run_cmd(%w(host-collection package-group install --name Test
|
47
|
+
--package-groups birds --organization-id 1))
|
48
|
+
end
|
33
49
|
|
50
|
+
it 'installs erratum to hosts in a host collection' do
|
51
|
+
api_expects_content_install('errata', :content => ['Bird_Erratum'])
|
34
52
|
run_cmd(%w(host-collection erratum install --id 3 --errata Bird_Erratum --organization-id 1))
|
35
53
|
end
|
54
|
+
|
55
|
+
it 'installs erratum to hosts in a host collection specified by name' do
|
56
|
+
api_expects_collection_search
|
57
|
+
api_expects_content_install('errata', :content => ['Bird_Erratum'])
|
58
|
+
run_cmd(%w(host-collection erratum install --name Test --errata Bird_Erratum
|
59
|
+
--organization-id 1))
|
60
|
+
end
|
36
61
|
end
|
37
62
|
end
|