hammer_cli_katello 1.5.0 → 1.6.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/acs.rb +82 -0
- data/lib/hammer_cli_katello/activation_key.rb +8 -2
- data/lib/hammer_cli_katello/content_export.rb +39 -0
- data/lib/hammer_cli_katello/content_export_helper.rb +64 -6
- data/lib/hammer_cli_katello/host_subscription.rb +32 -0
- data/lib/hammer_cli_katello/organization.rb +4 -0
- data/lib/hammer_cli_katello/repository.rb +1 -1
- data/lib/hammer_cli_katello/simple_content_access.rb +10 -0
- data/lib/hammer_cli_katello/version.rb +1 -1
- data/lib/hammer_cli_katello.rb +5 -0
- data/test/data/2.5/foreman_api.json +1 -0
- data/test/data/3.0/foreman_api.json +1 -0
- data/test/data/3.10/foreman_api.json +1 -0
- data/test/data/3.11/foreman_api.json +1 -0
- data/test/data/3.12/foreman_api.json +1 -0
- data/test/data/3.13/foreman_api.json +1 -0
- data/test/data/3.14/foreman_api.json +1 -0
- data/test/data/3.15/foreman_api.json +1 -0
- data/test/data/3.16/foreman_api.json +1 -0
- data/test/data/3.17/foreman_api.json +1 -0
- data/test/data/3.18/foreman_api.json +1 -0
- data/test/data/3.19/foreman_api.json +1 -0
- data/test/data/3.2/foreman_api.json +1 -0
- data/test/data/3.4/foreman_api.json +1 -0
- data/test/data/3.5/foreman_api.json +1 -0
- data/test/data/3.6/foreman_api.json +1 -0
- data/test/data/3.7/foreman_api.json +1 -0
- data/test/data/3.8/foreman_api.json +1 -0
- data/test/data/3.9/foreman_api.json +1 -0
- data/test/data/4.0/foreman_api.json +1 -0
- data/test/data/4.1/foreman_api.json +1 -0
- data/test/data/4.3/foreman_api.json +1 -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/data/Readme.md +5 -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 +94 -0
- data/test/functional/acs/list_test.rb +62 -0
- data/test/functional/acs/update_test.rb +23 -0
- data/test/functional/activation_key/add_host_collection_test.rb +62 -0
- data/test/functional/activation_key/content_override_test.rb +92 -0
- data/test/functional/activation_key/create_test.rb +33 -0
- data/test/functional/activation_key/data/activation_key.json +17 -0
- data/test/functional/activation_key/info_test.rb +29 -0
- data/test/functional/activation_key/list_test.rb +68 -0
- data/test/functional/activation_key/product_content_test.rb +23 -0
- data/test/functional/activation_key/remove_host_collection_test.rb +62 -0
- data/test/functional/activation_key/subscriptions_test.rb +74 -0
- data/test/functional/activation_key/update_test.rb +26 -0
- data/test/functional/apipie_helper_test.rb +31 -0
- data/test/functional/capsule/capsule_helpers.rb +13 -0
- data/test/functional/capsule/content/add_lifecycle_environment_test.rb +40 -0
- data/test/functional/capsule/content/cancel_synchronization_test.rb +42 -0
- data/test/functional/capsule/content/capsule_content_helpers.rb +24 -0
- data/test/functional/capsule/content/data/library_env.json +47 -0
- data/test/functional/capsule/content/data/sync_status.json +6 -0
- data/test/functional/capsule/content/data/sync_tasks.json +62 -0
- data/test/functional/capsule/content/info_test.rb +61 -0
- data/test/functional/capsule/content/lifecycle_environments_test.rb +19 -0
- data/test/functional/capsule/content/remove_lifecycle_environment_test.rb +40 -0
- data/test/functional/capsule/content/synchronization_status_test.rb +107 -0
- data/test/functional/capsule/info_test.rb +25 -0
- data/test/functional/capsule/list_test.rb +24 -0
- data/test/functional/content_credentials/create_test.rb +32 -0
- data/test/functional/content_credentials/data/test_cert.json +43 -0
- data/test/functional/content_credentials/info_test.rb +50 -0
- data/test/functional/content_credentials/list_test.rb +66 -0
- data/test/functional/content_export/complete/library_test.rb +155 -0
- data/test/functional/content_export/complete/repository_test.rb +226 -0
- data/test/functional/content_export/complete/version_test.rb +297 -0
- data/test/functional/content_export/content_export_helpers.rb +33 -0
- data/test/functional/content_export/generate_listing_test.rb +62 -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/repository_test.rb +212 -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/list_test.rb +65 -0
- data/test/functional/content_import/metadata.json +1 -0
- data/test/functional/content_import/version_test.rb +85 -0
- data/test/functional/content_units/info_test.rb +29 -0
- data/test/functional/content_units/list_test.rb +106 -0
- data/test/functional/content_view/add_content_view_version_test.rb +88 -0
- data/test/functional/content_view/add_repository_test.rb +21 -0
- data/test/functional/content_view/component/add_test.rb +177 -0
- data/test/functional/content_view/component/list_test.rb +55 -0
- data/test/functional/content_view/component/remove_test.rb +107 -0
- data/test/functional/content_view/component/update_test.rb +134 -0
- data/test/functional/content_view/content_view_helpers.rb +20 -0
- data/test/functional/content_view/copy_test.rb +53 -0
- data/test/functional/content_view/create_test.rb +34 -0
- data/test/functional/content_view/delete_test.rb +62 -0
- data/test/functional/content_view/filter/create_test.rb +57 -0
- data/test/functional/content_view/filter/delete_test.rb +90 -0
- data/test/functional/content_view/filter/info_test.rb +89 -0
- data/test/functional/content_view/filter/list_test.rb +98 -0
- data/test/functional/content_view/filter/update_test.rb +91 -0
- data/test/functional/content_view/list_test.rb +68 -0
- data/test/functional/content_view/publish_test.rb +24 -0
- data/test/functional/content_view/purge_test.rb +97 -0
- data/test/functional/content_view/remove_content_view_version_test.rb +88 -0
- data/test/functional/content_view/remove_test.rb +79 -0
- data/test/functional/content_view/update_test.rb +53 -0
- data/test/functional/content_view/version/incremental_update_test.rb +108 -0
- data/test/functional/content_view/version/list_test.rb +44 -0
- data/test/functional/content_view/version/promote_test.rb +75 -0
- data/test/functional/content_view/version/republish_repositories_test.rb +34 -0
- data/test/functional/content_view/version/update_test.rb +48 -0
- data/test/functional/erratum/erratum_helpers.rb +91 -0
- data/test/functional/erratum/info_test.rb +29 -0
- data/test/functional/erratum/list_test.rb +108 -0
- data/test/functional/file/file_helpers.rb +13 -0
- data/test/functional/file/info_test.rb +162 -0
- data/test/functional/file/list_test.rb +112 -0
- data/test/functional/filter_rule/create_test.rb +99 -0
- data/test/functional/filter_rule/delete_test.rb +104 -0
- data/test/functional/filter_rule/filter_rule_helpers.rb +12 -0
- data/test/functional/filter_rule/info_test.rb +104 -0
- data/test/functional/filter_rule/list_test.rb +91 -0
- data/test/functional/filter_rule/update_test.rb +104 -0
- data/test/functional/host/errata/apply_test.rb +45 -0
- data/test/functional/host/errata/info_test.rb +27 -0
- data/test/functional/host/errata/list_test.rb +49 -0
- data/test/functional/host/errata/recalculate_test.rb +26 -0
- data/test/functional/host/extensions/create_test.rb +95 -0
- data/test/functional/host/extensions/data/host.json +320 -0
- data/test/functional/host/extensions/data/host_list.json +117 -0
- data/test/functional/host/extensions/info_test.rb +35 -0
- data/test/functional/host/extensions/list_test.rb +21 -0
- data/test/functional/host/extensions/update_test.rb +70 -0
- data/test/functional/host/host_helpers.rb +8 -0
- data/test/functional/host/subscription/attach_test.rb +54 -0
- data/test/functional/host/subscription/auto_attach_test.rb +35 -0
- data/test/functional/host/subscription/content_override_test.rb +96 -0
- data/test/functional/host/subscription/enabled_repositories_test.rb +39 -0
- data/test/functional/host/subscription/product_content_test.rb +27 -0
- data/test/functional/host/subscription/register_test.rb +53 -0
- data/test/functional/host/subscription/remove_test.rb +52 -0
- data/test/functional/host/subscription/unregister_test.rb +37 -0
- data/test/functional/host/traces/list_test.rb +37 -0
- data/test/functional/host/traces/resolve_test.rb +31 -0
- data/test/functional/host_collection/add_host_test.rb +90 -0
- data/test/functional/host_collection/content_api_expectations.rb +35 -0
- data/test/functional/host_collection/content_install_test.rb +62 -0
- data/test/functional/host_collection/content_remove_test.rb +37 -0
- data/test/functional/host_collection/content_update_test.rb +37 -0
- data/test/functional/host_collection/copy_test.rb +64 -0
- data/test/functional/host_collection/create_test.rb +54 -0
- data/test/functional/host_collection/delete_test.rb +57 -0
- data/test/functional/host_collection/hosts_test.rb +39 -0
- data/test/functional/host_collection/info_test.rb +57 -0
- data/test/functional/host_collection/list_test.rb +63 -0
- data/test/functional/host_collection/remove_host_test.rb +90 -0
- data/test/functional/host_collection/update_test.rb +57 -0
- data/test/functional/hostgroup/create_test.rb +112 -0
- data/test/functional/hostgroup/data/hostgroup.json +50 -0
- data/test/functional/hostgroup/info_test.rb +33 -0
- data/test/functional/hostgroup/update_test.rb +120 -0
- data/test/functional/lifecycle_environment/create_test.rb +14 -0
- data/test/functional/lifecycle_environment/lifecycle_environment_helpers.rb +18 -0
- data/test/functional/lifecycle_environment/list_test.rb +38 -0
- data/test/functional/lifecycle_environment/update_test.rb +14 -0
- data/test/functional/local_helper_test.rb +30 -0
- data/test/functional/module_stream/info_test.rb +58 -0
- data/test/functional/module_stream/list_test.rb +53 -0
- data/test/functional/organization/cdn_configuration_test.rb +45 -0
- data/test/functional/organization/delete_test.rb +26 -0
- data/test/functional/organization/info_test.rb +45 -0
- data/test/functional/organization/organization_helpers.rb +10 -0
- data/test/functional/package/list_test.rb +160 -0
- data/test/functional/package_group/list_test.rb +38 -0
- data/test/functional/ping_test.rb +61 -0
- data/test/functional/product/create_test.rb +54 -0
- data/test/functional/product/delete_test.rb +41 -0
- data/test/functional/product/info_test.rb +33 -0
- data/test/functional/product/list_test.rb +58 -0
- data/test/functional/product/product_helpers.rb +24 -0
- data/test/functional/product/remove_sync_plan_test.rb +35 -0
- data/test/functional/product/set_sync_plan_test.rb +49 -0
- data/test/functional/product/update_proxy.rb +48 -0
- data/test/functional/product/update_test.rb +46 -0
- data/test/functional/repository/create_test.rb +21 -0
- data/test/functional/repository/delete_test.rb +95 -0
- data/test/functional/repository/info_test.rb +156 -0
- data/test/functional/repository/list_test.rb +68 -0
- data/test/functional/repository/reclaim_space_test.rb +105 -0
- data/test/functional/repository/remove_content_test.rb +108 -0
- data/test/functional/repository/repository_helpers.rb +18 -0
- data/test/functional/repository/republish_test.rb +37 -0
- data/test/functional/repository/synchronize_test.rb +57 -0
- data/test/functional/repository/update_test.rb +150 -0
- data/test/functional/repository/upload_test.rb +368 -0
- data/test/functional/repository_set/available_repositories_test.rb +18 -0
- data/test/functional/repository_set/disable_test.rb +48 -0
- data/test/functional/repository_set/enable_test.rb +42 -0
- data/test/functional/repository_set/info_test.rb +17 -0
- data/test/functional/repository_set/list_test.rb +18 -0
- data/test/functional/repository_set/repository_set_helpers.rb +20 -0
- data/test/functional/search_helpers.rb +17 -0
- data/test/functional/simple_content_access/disable_test.rb +48 -0
- data/test/functional/simple_content_access/enable_test.rb +46 -0
- data/test/functional/simple_content_access/status_test.rb +29 -0
- data/test/functional/srpm/list_test.rb +92 -0
- data/test/functional/subscription/list_test.rb +86 -0
- data/test/functional/sync_plan/create_test.rb +60 -0
- data/test/functional/sync_plan/delete_test.rb +46 -0
- data/test/functional/sync_plan/info_test.rb +37 -0
- data/test/functional/sync_plan/list_test.rb +31 -0
- data/test/functional/sync_plan/sync_plan_helpers.rb +8 -0
- data/test/functional/sync_plan/update_test.rb +44 -0
- data/test/functional/test_helper.rb +24 -0
- data/test/task_helper.rb +7 -0
- data/test/test_helper.rb +38 -0
- data/test/unit/id_name_options_validator_test.rb +96 -0
- data/test/unit/id_resolver_test.rb +58 -0
- data/test/unit/messages_test.rb +7 -0
- data/test/unit/search_options_creators_test.rb +145 -0
- metadata +425 -4
@@ -0,0 +1,54 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '../../test_helper')
|
2
|
+
require File.join(File.dirname(__FILE__), '../host_helpers')
|
3
|
+
|
4
|
+
describe 'host subscription attach' do
|
5
|
+
include HostHelpers
|
6
|
+
|
7
|
+
before do
|
8
|
+
@cmd = %w(host subscription attach)
|
9
|
+
end
|
10
|
+
it "attach a subscription to a host No Quantity" do
|
11
|
+
params = ['--host-id=3', '--subscription-id=100']
|
12
|
+
ex = api_expects(:host_subscriptions, :add_subscriptions, "attach host") do |par|
|
13
|
+
par['host_id'] == 3 && par[:subscriptions][0][:id].to_s == '100' &&
|
14
|
+
par[:subscriptions][0][:quantity].to_s == '1'
|
15
|
+
end
|
16
|
+
ex.returns({})
|
17
|
+
|
18
|
+
expected_result = success_result(
|
19
|
+
'Subscription attached to the host successfully.
|
20
|
+
'
|
21
|
+
)
|
22
|
+
|
23
|
+
result = run_cmd(@cmd + params)
|
24
|
+
assert_cmd(expected_result, result)
|
25
|
+
end
|
26
|
+
|
27
|
+
it "attach a subscription to a host with Quantity" do
|
28
|
+
params = ['--host-id=3', '--subscription-id=100', "--quantity=10"]
|
29
|
+
ex = api_expects(:host_subscriptions, :add_subscriptions, "attach host") do |par|
|
30
|
+
par['host_id'] == 3 && par[:subscriptions][0][:id].to_s == '100' &&
|
31
|
+
par[:subscriptions][0][:quantity].to_s == '10'
|
32
|
+
end
|
33
|
+
ex.returns({})
|
34
|
+
|
35
|
+
expected_result = success_result(
|
36
|
+
'Subscription attached to the host successfully.
|
37
|
+
'
|
38
|
+
)
|
39
|
+
|
40
|
+
result = run_cmd(@cmd + params)
|
41
|
+
assert_cmd(expected_result, result)
|
42
|
+
end
|
43
|
+
|
44
|
+
it "resolves id from name" do
|
45
|
+
params = ['--host=boo', '--subscription-id=100']
|
46
|
+
api_expects(:host_subscriptions, :add_subscriptions, "attach host") do |par|
|
47
|
+
par['host_id'].to_s == "3" && par[:subscriptions][0][:id].to_s == '100' &&
|
48
|
+
par[:subscriptions][0][:quantity].to_s == '1'
|
49
|
+
end
|
50
|
+
expect_host_search('boo', '3')
|
51
|
+
|
52
|
+
run_cmd(@cmd + params)
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '../../test_helper')
|
2
|
+
require File.join(File.dirname(__FILE__), '../host_helpers')
|
3
|
+
|
4
|
+
describe 'host subscription auto-attach' do
|
5
|
+
include HostHelpers
|
6
|
+
|
7
|
+
before do
|
8
|
+
@cmd = %w(host subscription auto-attach)
|
9
|
+
end
|
10
|
+
it "auto-attach to a host" do
|
11
|
+
params = ['--host-id=3']
|
12
|
+
ex = api_expects(:host_subscriptions, :auto_attach, "auto-attach subs host") do |par|
|
13
|
+
par['host_id'] == 3
|
14
|
+
end
|
15
|
+
ex.returns({})
|
16
|
+
|
17
|
+
expected_result = success_result(
|
18
|
+
'Auto attached subscriptions to the host successfully.
|
19
|
+
'
|
20
|
+
)
|
21
|
+
|
22
|
+
result = run_cmd(@cmd + params)
|
23
|
+
assert_cmd(expected_result, result)
|
24
|
+
end
|
25
|
+
|
26
|
+
it "resolves id from name" do
|
27
|
+
params = ['--host=boo']
|
28
|
+
api_expects(:host_subscriptions, :auto_attach, "auto-attach subs host") do |par|
|
29
|
+
par['host_id'].to_s == "3"
|
30
|
+
end
|
31
|
+
expect_host_search('boo', '3')
|
32
|
+
|
33
|
+
run_cmd(@cmd + params)
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,96 @@
|
|
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}",
|
36
|
+
"--override-name=#{name}"]
|
37
|
+
ex = api_expects(:host_subscriptions, :content_override, "content override") do |par|
|
38
|
+
par['host_id'].to_s == id && par["content_overrides"][0]['content_label'] == label &&
|
39
|
+
par['content_overrides'][0]['value'] == value &&
|
40
|
+
par['content_overrides'][0]['name'] == name
|
41
|
+
end
|
42
|
+
ex.returns({})
|
43
|
+
|
44
|
+
expected_result = success_result("Updated content override.\n")
|
45
|
+
|
46
|
+
result = run_cmd(@cmd + params)
|
47
|
+
assert_cmd(expected_result, result)
|
48
|
+
end
|
49
|
+
|
50
|
+
it "removes override" do
|
51
|
+
label = "foo"
|
52
|
+
id = '20'
|
53
|
+
params = ["--host-id=#{id}", "--content-label=#{label}", "--remove"]
|
54
|
+
ex = api_expects(:host_subscriptions, :content_override, "content override") do |par|
|
55
|
+
par['host_id'].to_s == id && par["content_overrides"][0]['content_label'] == label &&
|
56
|
+
par['content_overrides'][0]['remove'] == true &&
|
57
|
+
par['content_overrides'][0]['name'] == "enabled"
|
58
|
+
end
|
59
|
+
ex.returns({})
|
60
|
+
|
61
|
+
expected_result = success_result("Updated content override.\n")
|
62
|
+
|
63
|
+
result = run_cmd(@cmd + params)
|
64
|
+
assert_cmd(expected_result, result)
|
65
|
+
end
|
66
|
+
|
67
|
+
it "removes override with name" do
|
68
|
+
label = "foo"
|
69
|
+
id = '20'
|
70
|
+
name = 'protected'
|
71
|
+
params = ["--host-id=#{id}", "--content-label=#{label}", "--override-name=#{name}", "--remove"]
|
72
|
+
ex = api_expects(:host_subscriptions, :content_override, "content override") do |par|
|
73
|
+
par['host_id'].to_s == id && par["content_overrides"][0]['content_label'] == label &&
|
74
|
+
par['content_overrides'][0]['remove'] == true &&
|
75
|
+
par['content_overrides'][0]['name'] == name
|
76
|
+
end
|
77
|
+
ex.returns({})
|
78
|
+
|
79
|
+
expected_result = success_result("Updated content override.\n")
|
80
|
+
|
81
|
+
result = run_cmd(@cmd + params)
|
82
|
+
assert_cmd(expected_result, result)
|
83
|
+
end
|
84
|
+
|
85
|
+
it "validation fails on no override value or remove" do
|
86
|
+
api_expects_no_call
|
87
|
+
label = "foo"
|
88
|
+
id = '20'
|
89
|
+
name = 'protected'
|
90
|
+
params = ["--host-id=#{id}", "--content-label=#{label}", "--override-name=#{name}"]
|
91
|
+
result = run_cmd(@cmd + params)
|
92
|
+
|
93
|
+
assert(result.err[/At least one of options --remove, --value is required/],
|
94
|
+
"Remove or Value must be provided")
|
95
|
+
end
|
96
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '../../test_helper')
|
2
|
+
|
3
|
+
describe 'host enabled-repositories listing' do
|
4
|
+
before do
|
5
|
+
@cmd = %w(host subscription enabled-repositories)
|
6
|
+
end
|
7
|
+
|
8
|
+
let(:host_id) { 1 }
|
9
|
+
let(:empty_response) do
|
10
|
+
{
|
11
|
+
"total" => 0,
|
12
|
+
"subtotal" => 0,
|
13
|
+
"page" => "1",
|
14
|
+
"per_page" => "1000",
|
15
|
+
"error" => nil,
|
16
|
+
"search" => nil,
|
17
|
+
"sort" => {
|
18
|
+
"by" => nil,
|
19
|
+
"order" => nil
|
20
|
+
},
|
21
|
+
"results" => []
|
22
|
+
}
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'allows listing by host' do
|
26
|
+
params = ["--host-id=#{host_id}"]
|
27
|
+
ex = api_expects(:host_subscriptions,
|
28
|
+
:enabled_repositories, 'host subscription enabled-repositories')
|
29
|
+
ex.returns(empty_response)
|
30
|
+
# rubocop:disable Layout/LineLength
|
31
|
+
expected_result = success_result("---|------|-------|--------------|----------|-----------------|-------------------|----------------------|------------------|-------------
|
32
|
+
ID | NAME | LABEL | CONTENT TYPE | CHECKSUM | CONTENT VIEW ID | CONTENT VIEW NAME | CONTENT VIEW VERSION | ENVIRONMENT NAME | PRODUCT NAME
|
33
|
+
---|------|-------|--------------|----------|-----------------|-------------------|----------------------|------------------|-------------
|
34
|
+
")
|
35
|
+
# rubocop:enable Layout/LineLength
|
36
|
+
result = run_cmd(@cmd + params)
|
37
|
+
assert_cmd(expected_result, result)
|
38
|
+
end
|
39
|
+
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 | DEFAULT 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,53 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '../../test_helper')
|
2
|
+
require File.join(File.dirname(__FILE__), '../../content_view/content_view_helpers')
|
3
|
+
require File.join(File.dirname(__FILE__), '../../organization/organization_helpers')
|
4
|
+
require File.join(File.dirname(__FILE__),
|
5
|
+
'../../lifecycle_environment/lifecycle_environment_helpers')
|
6
|
+
|
7
|
+
describe 'host subscription register' do
|
8
|
+
include OrganizationHelpers
|
9
|
+
include ContentViewHelpers
|
10
|
+
include LifecycleEnvironmentHelpers
|
11
|
+
|
12
|
+
before do
|
13
|
+
@cmd = %w(host subscription register)
|
14
|
+
end
|
15
|
+
|
16
|
+
it "subscribe a host" do
|
17
|
+
params = ['--name=trump.wall.com', '--content-view-id=1', '--lifecycle-environment-id=2']
|
18
|
+
ex = api_expects(:host_subscriptions, :create, 'Host subscription register') do |par|
|
19
|
+
par['name'] == 'trump.wall.com' && par['content_view_id'] == 1 &&
|
20
|
+
par['lifecycle_environment_id'] == 2
|
21
|
+
end
|
22
|
+
ex.returns({})
|
23
|
+
|
24
|
+
expected_result = success_result(
|
25
|
+
'Host successfully registered.
|
26
|
+
'
|
27
|
+
)
|
28
|
+
|
29
|
+
result = run_cmd(@cmd + params)
|
30
|
+
assert_cmd(expected_result, result)
|
31
|
+
end
|
32
|
+
|
33
|
+
it "resolves ids from names" do
|
34
|
+
params = ['--name=trump.wall.com', '--content-view=someview', '--lifecycle-environment=someenv',
|
35
|
+
'--organization=trumporg']
|
36
|
+
|
37
|
+
api_expects(:host_subscriptions, :create, 'Host subscription register') do |par|
|
38
|
+
par['name'] == 'trump.wall.com' && par['content_view_id'] == 1 &&
|
39
|
+
par['lifecycle_environment_id'] == 2
|
40
|
+
end
|
41
|
+
|
42
|
+
expect_organization_search('trumporg', 3)
|
43
|
+
expect_content_view_search(3, 'someview', 1)
|
44
|
+
expect_lifecycle_environment_search(3, 'someenv', 2)
|
45
|
+
|
46
|
+
expected_result = success_result(
|
47
|
+
'Host successfully registered.
|
48
|
+
'
|
49
|
+
)
|
50
|
+
result = run_cmd(@cmd + params)
|
51
|
+
assert_cmd(expected_result, result)
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '../../test_helper')
|
2
|
+
require File.join(File.dirname(__FILE__), '../host_helpers')
|
3
|
+
|
4
|
+
describe 'host subscription remove' do
|
5
|
+
include HostHelpers
|
6
|
+
|
7
|
+
before do
|
8
|
+
@cmd = %w(host subscription remove)
|
9
|
+
end
|
10
|
+
it "remove a subscription to a host No Quantity" do
|
11
|
+
params = ['--host-id=3', '--subscription-id=100']
|
12
|
+
ex = api_expects(:host_subscriptions, :remove_subscriptions, "remove subs host") do |par|
|
13
|
+
par['host_id'] == 3 && par[:subscriptions][0][:id].to_s == '100'
|
14
|
+
end
|
15
|
+
ex.returns({})
|
16
|
+
|
17
|
+
expected_result = success_result(
|
18
|
+
'Subscription removed from the host successfully.
|
19
|
+
'
|
20
|
+
)
|
21
|
+
|
22
|
+
result = run_cmd(@cmd + params)
|
23
|
+
assert_cmd(expected_result, result)
|
24
|
+
end
|
25
|
+
|
26
|
+
it "remove a subscription to a host with Quantity" do
|
27
|
+
params = ['--host-id=3', '--subscription-id=100', "--quantity=10"]
|
28
|
+
ex = api_expects(:host_subscriptions, :remove_subscriptions, "remove subs host") do |par|
|
29
|
+
par['host_id'] == 3 && par[:subscriptions][0][:id].to_s == '100' &&
|
30
|
+
par[:subscriptions][0][:quantity].to_s == '10'
|
31
|
+
end
|
32
|
+
ex.returns({})
|
33
|
+
|
34
|
+
expected_result = success_result(
|
35
|
+
'Subscription removed from the host successfully.
|
36
|
+
'
|
37
|
+
)
|
38
|
+
|
39
|
+
result = run_cmd(@cmd + params)
|
40
|
+
assert_cmd(expected_result, result)
|
41
|
+
end
|
42
|
+
|
43
|
+
it "resolves id from name" do
|
44
|
+
params = ['--host=boo', '--subscription-id=100']
|
45
|
+
api_expects(:host_subscriptions, :remove_subscriptions, "remove subs host") do |par|
|
46
|
+
par['host_id'].to_s == "3" && par[:subscriptions][0][:id].to_s == '100'
|
47
|
+
end
|
48
|
+
expect_host_search('boo', '3')
|
49
|
+
|
50
|
+
run_cmd(@cmd + params)
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '../../test_helper')
|
2
|
+
require File.join(File.dirname(__FILE__), '../host_helpers')
|
3
|
+
|
4
|
+
describe 'host subscription unregister' do
|
5
|
+
include HostHelpers
|
6
|
+
|
7
|
+
before do
|
8
|
+
@cmd = %w(host subscription unregister)
|
9
|
+
end
|
10
|
+
|
11
|
+
it "unregisters the host" do
|
12
|
+
params = ['--host-id=3']
|
13
|
+
ex = api_expects(:host_subscriptions, :destroy, 'Host unregister') do |par|
|
14
|
+
par['host_id'] == 3
|
15
|
+
end
|
16
|
+
ex.returns({})
|
17
|
+
|
18
|
+
expected_result = success_result(
|
19
|
+
'Host unregistered.
|
20
|
+
'
|
21
|
+
)
|
22
|
+
|
23
|
+
result = run_cmd(@cmd + params)
|
24
|
+
assert_cmd(expected_result, result)
|
25
|
+
end
|
26
|
+
|
27
|
+
it "resolves id from name" do
|
28
|
+
params = ['--host=host1']
|
29
|
+
|
30
|
+
api_expects(:host_subscriptions, :destroy, 'Host unregister') do |par|
|
31
|
+
par['host_id'].to_i == 3
|
32
|
+
end
|
33
|
+
expect_host_search('host1', '3')
|
34
|
+
|
35
|
+
run_cmd(@cmd + params)
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '../../test_helper')
|
2
|
+
|
3
|
+
describe 'host trace listing' do
|
4
|
+
before do
|
5
|
+
@cmd = %w(host traces list)
|
6
|
+
end
|
7
|
+
|
8
|
+
let(:host_id) { 2 }
|
9
|
+
let(:empty_response) do
|
10
|
+
{
|
11
|
+
"total" => 0,
|
12
|
+
"subtotal" => 0,
|
13
|
+
"page" => "1",
|
14
|
+
"per_page" => "1000",
|
15
|
+
"error" => nil,
|
16
|
+
"search" => nil,
|
17
|
+
"sort" => {
|
18
|
+
"by" => nil,
|
19
|
+
"order" => nil
|
20
|
+
},
|
21
|
+
"results" => []
|
22
|
+
}
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'allows listing by host' do
|
26
|
+
params = ["--host-id=#{host_id}"]
|
27
|
+
ex = api_expects(:host_tracer, :index, 'host traces list')
|
28
|
+
|
29
|
+
ex.returns(empty_response)
|
30
|
+
expected_result = success_result("---------|-------------|--------|-----
|
31
|
+
TRACE ID | APPLICATION | HELPER | TYPE
|
32
|
+
---------|-------------|--------|-----
|
33
|
+
")
|
34
|
+
result = run_cmd(@cmd + params)
|
35
|
+
assert_cmd(expected_result, result)
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '../../test_helper')
|
2
|
+
|
3
|
+
describe 'host trace resolve' do
|
4
|
+
include ForemanTaskHelpers
|
5
|
+
|
6
|
+
before do
|
7
|
+
@cmd = %w(host traces resolve)
|
8
|
+
end
|
9
|
+
|
10
|
+
let(:host_id) { '2' }
|
11
|
+
let(:task_id) { '5' }
|
12
|
+
let(:response) do
|
13
|
+
{
|
14
|
+
'id' => task_id,
|
15
|
+
'state' => 'stopped'
|
16
|
+
}
|
17
|
+
end
|
18
|
+
|
19
|
+
it "resolves traces on a host" do
|
20
|
+
trace_ids = [3]
|
21
|
+
params = ["--host-id=#{host_id}", "--trace-ids=#{trace_ids}"]
|
22
|
+
|
23
|
+
ex = api_expects(:host_tracer, :resolve)
|
24
|
+
|
25
|
+
ex.returns(response)
|
26
|
+
|
27
|
+
expect_foreman_task(task_id)
|
28
|
+
|
29
|
+
run_cmd(@cmd + params)
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,90 @@
|
|
1
|
+
require_relative '../test_helper'
|
2
|
+
require 'hammer_cli_katello/host_collection'
|
3
|
+
|
4
|
+
module HammerCLIKatello
|
5
|
+
describe HostCollection::AddHostCommand do
|
6
|
+
describe 'handles individual host errors' do
|
7
|
+
it 'for successful results' do
|
8
|
+
api_expects(:host_collections, :add_hosts)
|
9
|
+
.with_params('id' => 1, 'host_ids' => %w(2 3))
|
10
|
+
.returns("displayMessages" => {"success" => ["Successfully added 2 Host(s)."],
|
11
|
+
"error" => []})
|
12
|
+
result = run_cmd(%w(host-collection add-host --id 1 --host-ids 2,3))
|
13
|
+
assert_match("The host(s) has been added", result.out)
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'for mixed results' do
|
17
|
+
api_expects(:host_collections, :add_hosts)
|
18
|
+
.with_params('id' => 1, 'host_ids' => %w(2 3))
|
19
|
+
.returns("displayMessages" => {"success" => ["Successfully added 1 Host(s)."],
|
20
|
+
"error" => ["Host with ID 3 not found."]})
|
21
|
+
result = run_cmd(%w(host-collection add-host --id 1 --host-ids 2,3))
|
22
|
+
assert_match("Could not add host(s)", result.out)
|
23
|
+
assert_match("Host with ID 3 not found.", result.out)
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'for errored results' do
|
27
|
+
api_expects(:host_collections, :add_hosts)
|
28
|
+
.with_params('id' => 1, 'host_ids' => %w(2 3))
|
29
|
+
.returns("displayMessages" => {"success" => [], "error" => [
|
30
|
+
"Host with ID 1 already exists in the host collection.",
|
31
|
+
"Host with ID 3 not found."]})
|
32
|
+
result = run_cmd(%w(host-collection add-host --id 1 --host-ids 2,3))
|
33
|
+
assert_match("Could not add host(s)", result.out)
|
34
|
+
assert_match("Host with ID 1 already exists in the host collection.", result.out)
|
35
|
+
assert_match("Host with ID 3 not found.", result.out)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'does not require organization options if id is specified' do
|
40
|
+
api_expects(:host_collections, :add_hosts)
|
41
|
+
run_cmd(%w(host-collection add-host --id 1))
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'requires organization options if name is specified' do
|
45
|
+
result = run_cmd(%w(host-collection add-host --name hc1))
|
46
|
+
expected_error = "Missing options to search organization"
|
47
|
+
assert_equal(HammerCLI::EX_SOFTWARE, result.exit_code)
|
48
|
+
assert_equal(expected_error, result.err[/#{expected_error}/])
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'allows organization id' do
|
52
|
+
api_expects(:host_collections, :index) { |par| par['organization_id'].to_i == 1 }
|
53
|
+
.returns(index_response([{'id' => 2}]))
|
54
|
+
|
55
|
+
api_expects(:host_collections, :add_hosts) do |par|
|
56
|
+
par['id'].to_i == 2
|
57
|
+
end
|
58
|
+
|
59
|
+
run_cmd(%w(host-collection add-host --name hc1 --organization-id 1))
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'allows organization name' do
|
63
|
+
api_expects(:organizations, :index) { |par| par[:search] == "name = \"org1\"" }
|
64
|
+
.returns(index_response([{'id' => 1}]))
|
65
|
+
|
66
|
+
api_expects(:host_collections, :index) { |par| par['organization_id'].to_i == 1 }
|
67
|
+
.returns(index_response([{'id' => 2}]))
|
68
|
+
|
69
|
+
api_expects(:host_collections, :add_hosts) do |par|
|
70
|
+
par['id'].to_i == 2
|
71
|
+
end
|
72
|
+
|
73
|
+
run_cmd(%w(host-collection add-host --name hc1 --organization org1))
|
74
|
+
end
|
75
|
+
|
76
|
+
it 'allows organization label' do
|
77
|
+
api_expects(:organizations, :index) { |par| par[:search] == "label = \"org1\"" }
|
78
|
+
.returns(index_response([{'id' => 1}]))
|
79
|
+
|
80
|
+
api_expects(:host_collections, :index) { |par| par['organization_id'].to_i == 1 }
|
81
|
+
.returns(index_response([{'id' => 2}]))
|
82
|
+
|
83
|
+
api_expects(:host_collections, :add_hosts) do |par|
|
84
|
+
par['id'].to_i == 2
|
85
|
+
end
|
86
|
+
|
87
|
+
run_cmd(%w(host-collection add-host --name hc1 --organization-label org1))
|
88
|
+
end
|
89
|
+
end
|
90
|
+
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
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require_relative '../test_helper'
|
2
|
+
require_relative './content_api_expectations'
|
3
|
+
require 'hammer_cli_katello/host_collection'
|
4
|
+
|
5
|
+
module HammerCLIKatello
|
6
|
+
describe HostCollection::InstallContentBaseCommand do
|
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
|
+
|
13
|
+
it 'installs packages to hosts in a host collection' do
|
14
|
+
api_expects_content_install('package', :content => ['wget'])
|
15
|
+
run_cmd(%w(host-collection package install --id 3 --packages wget --organization-id 1))
|
16
|
+
end
|
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
|
+
|
24
|
+
it 'installs package groups to hosts in a host collection' do
|
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
|
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'])
|
39
|
+
run_cmd(%w(host-collection package-group install --id 3
|
40
|
+
--package-groups birds --organization-id 1))
|
41
|
+
end
|
42
|
+
|
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
|
49
|
+
|
50
|
+
it 'installs erratum to hosts in a host collection' do
|
51
|
+
api_expects_content_install('errata', :content => ['Bird_Erratum'])
|
52
|
+
run_cmd(%w(host-collection erratum install --id 3 --errata Bird_Erratum --organization-id 1))
|
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
|
61
|
+
end
|
62
|
+
end
|