hammer_cli_katello 1.1.3 → 1.2.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/foreman_search_options_creators.rb +0 -12
- data/lib/hammer_cli_katello/host_collection.rb +6 -0
- data/lib/hammer_cli_katello/host_errata.rb +1 -1
- data/lib/hammer_cli_katello/repository.rb +0 -27
- data/lib/hammer_cli_katello/version.rb +1 -1
- 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/Readme.md +5 -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/version_test.rb +252 -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/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_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 +34 -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 +40 -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/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/delete_test.rb +26 -0
- data/test/functional/organization/info_test.rb +22 -0
- data/test/functional/organization/organization_helpers.rb +10 -0
- data/test/functional/package/list_test.rb +158 -0
- data/test/functional/package_group/list_test.rb +38 -0
- data/test/functional/ping_test.rb +59 -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/remove_content_test.rb +108 -0
- data/test/functional/repository/repository_helpers.rb +18 -0
- data/test/functional/repository/synchronize_test.rb +57 -0
- data/test/functional/repository/update_test.rb +149 -0
- data/test/functional/repository/upload_test.rb +345 -0
- data/test/functional/repository_set/available_repositories_test.rb +18 -0
- data/test/functional/repository_set/disable_test.rb +42 -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/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 +388 -6
data/test/data/Readme.md
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
require_relative '../test_helper'
|
2
|
+
require 'hammer_cli_katello/associating_commands'
|
3
|
+
|
4
|
+
module HammerCLIKatello
|
5
|
+
module AssociatingCommands
|
6
|
+
module HostCollection
|
7
|
+
describe AddHostCollectionCommand do
|
8
|
+
it 'allows minimal options' do
|
9
|
+
ex = api_expects(:activation_keys, :show) do |p|
|
10
|
+
p[:id] == '1'
|
11
|
+
end
|
12
|
+
ex.returns('id' => 1, host_collections: [{}])
|
13
|
+
|
14
|
+
api_expects(:activation_keys, :update) do |p|
|
15
|
+
p['id'] == '1' && p['organization_id'] == 1 && p['host_collection_ids'] == ['3']
|
16
|
+
end
|
17
|
+
|
18
|
+
run_cmd(%w(activation-key add-host-collection --organization-id 1
|
19
|
+
--host-collection-id 3 --id 1))
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'allows resolving host collection name' do
|
23
|
+
ex = api_expects(:host_collections, :index) do |p|
|
24
|
+
p['name'] == 'hc3' && p['organization_id'] == 1
|
25
|
+
end
|
26
|
+
ex.returns(index_response([{'id' => 3}]))
|
27
|
+
|
28
|
+
ex = api_expects(:activation_keys, :show) do |p|
|
29
|
+
p[:id] == '1'
|
30
|
+
end
|
31
|
+
ex.returns(id: 1, host_collection_ids: [])
|
32
|
+
|
33
|
+
api_expects(:activation_keys, :update) do |p|
|
34
|
+
p['id'] == '1' && p['organization_id'] == 1 && p['host_collection_ids'] == ['3']
|
35
|
+
end
|
36
|
+
|
37
|
+
run_cmd(%w(activation-key add-host-collection --organization-id 1
|
38
|
+
--host-collection hc3 --id 1))
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'allows resolving activation key name' do
|
42
|
+
ex = api_expects(:activation_keys, :index) do |p|
|
43
|
+
p['name'] == 'ak1' && p['organization_id'] == 1
|
44
|
+
end
|
45
|
+
ex.at_least_once.returns(index_response([{'id' => 1}]))
|
46
|
+
|
47
|
+
ex = api_expects(:activation_keys, :show) do |p|
|
48
|
+
p[:id] == 1
|
49
|
+
end
|
50
|
+
ex.returns(id: 1, host_collections: [])
|
51
|
+
|
52
|
+
api_expects(:activation_keys, :update) do |p|
|
53
|
+
p['id'] == 1 && p['organization_id'] == 1 && p['host_collection_ids'] == ['3']
|
54
|
+
end
|
55
|
+
|
56
|
+
run_cmd(%w(activation-key add-host-collection --organization-id 1
|
57
|
+
--host-collection-id 3 --name ak1))
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '../../test_helper')
|
2
|
+
require 'hammer_cli_katello/activation_key'
|
3
|
+
|
4
|
+
describe 'activation-key content-override' do
|
5
|
+
before do
|
6
|
+
@cmd = %w(activation-key content-override)
|
7
|
+
end
|
8
|
+
it "attaches a content label" do
|
9
|
+
label = "foo"
|
10
|
+
value = '1'
|
11
|
+
id = 20
|
12
|
+
params = ["--id=#{id}", "--content-label=#{label}", "--value=#{value}"]
|
13
|
+
ex = api_expects(:activation_keys, :content_override) do |par|
|
14
|
+
par['id'] == id && par["content_overrides"][0]['content_label'] == label &&
|
15
|
+
par['content_overrides'][0]['value'] == value &&
|
16
|
+
par['content_overrides'][0]['name'] == "enabled"
|
17
|
+
end
|
18
|
+
ex.returns({})
|
19
|
+
|
20
|
+
expected_result = success_result("Updated content override.\n")
|
21
|
+
|
22
|
+
result = run_cmd(@cmd + params)
|
23
|
+
assert_cmd(expected_result, result)
|
24
|
+
end
|
25
|
+
|
26
|
+
it "attaches a content label with name" do
|
27
|
+
label = "foo"
|
28
|
+
value = '1'
|
29
|
+
id = 20
|
30
|
+
name = 'protected'
|
31
|
+
params = ["--id=#{id}", "--content-label=#{label}", "--value=#{value}",
|
32
|
+
"--override-name=#{name}"]
|
33
|
+
ex = api_expects(:activation_keys, :content_override) do |par|
|
34
|
+
par['id'] == id && par["content_overrides"][0]['content_label'] == label &&
|
35
|
+
par['content_overrides'][0]['value'] == value &&
|
36
|
+
par['content_overrides'][0]['name'] == name
|
37
|
+
end
|
38
|
+
ex.returns({})
|
39
|
+
|
40
|
+
expected_result = success_result("Updated content override.\n")
|
41
|
+
|
42
|
+
result = run_cmd(@cmd + params)
|
43
|
+
assert_cmd(expected_result, result)
|
44
|
+
end
|
45
|
+
|
46
|
+
it "removes override" do
|
47
|
+
label = "foo"
|
48
|
+
id = 20
|
49
|
+
params = ["--id=#{id}", "--content-label=#{label}", "--remove"]
|
50
|
+
ex = api_expects(:activation_keys, :content_override) do |par|
|
51
|
+
par['id'] == id && par["content_overrides"][0]['content_label'] == label &&
|
52
|
+
par['content_overrides'][0]['remove'] == true &&
|
53
|
+
par['content_overrides'][0]['name'] == "enabled"
|
54
|
+
end
|
55
|
+
ex.returns({})
|
56
|
+
|
57
|
+
expected_result = success_result("Updated content override.\n")
|
58
|
+
|
59
|
+
result = run_cmd(@cmd + params)
|
60
|
+
assert_cmd(expected_result, result)
|
61
|
+
end
|
62
|
+
|
63
|
+
it "removes override with name" do
|
64
|
+
label = "foo"
|
65
|
+
id = 20
|
66
|
+
name = 'protected'
|
67
|
+
params = ["--id=#{id}", "--content-label=#{label}", "--override-name=#{name}", "--remove"]
|
68
|
+
ex = api_expects(:activation_keys, :content_override) do |par|
|
69
|
+
par['id'] == id && par["content_overrides"][0]['content_label'] == label &&
|
70
|
+
par['content_overrides'][0]['remove'] == true &&
|
71
|
+
par['content_overrides'][0]['name'] == name
|
72
|
+
end
|
73
|
+
ex.returns({})
|
74
|
+
|
75
|
+
expected_result = success_result("Updated content override.\n")
|
76
|
+
|
77
|
+
result = run_cmd(@cmd + params)
|
78
|
+
assert_cmd(expected_result, result)
|
79
|
+
end
|
80
|
+
|
81
|
+
it "validation fails on no override value or remove" do
|
82
|
+
api_expects_no_call
|
83
|
+
label = "foo"
|
84
|
+
id = 20
|
85
|
+
name = 'protected'
|
86
|
+
params = ["--id=#{id}", "--content-label=#{label}", "--override-name=#{name}"]
|
87
|
+
result = run_cmd(@cmd + params)
|
88
|
+
|
89
|
+
assert(result.err[/At least one of options --remove, --value is required/],
|
90
|
+
"Remove or Value must be provided")
|
91
|
+
end
|
92
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require_relative '../test_helper'
|
2
|
+
require 'hammer_cli_katello/activation_key'
|
3
|
+
|
4
|
+
module HammerCLIKatello
|
5
|
+
describe ActivationKeyCommand do
|
6
|
+
describe CreateCommand do
|
7
|
+
it 'allows promoting a content view' do
|
8
|
+
ex = api_expects(:organizations, :index) do |p|
|
9
|
+
p[:search] == "name = \"org1\""
|
10
|
+
end
|
11
|
+
ex.at_least_once.returns(index_response([{'id' => 1}]))
|
12
|
+
|
13
|
+
ex = api_expects(:lifecycle_environments, :index) do |p|
|
14
|
+
p['organization_id'] == 1 && p['name'] == 'test'
|
15
|
+
end
|
16
|
+
ex.returns(index_response([{'id' => 9}]))
|
17
|
+
|
18
|
+
ex = api_expects(:content_views, :index) do |p|
|
19
|
+
p['name'] == 'cv' && p['organization_id'] == 1
|
20
|
+
end
|
21
|
+
ex.returns(index_response([{'id' => 3}]))
|
22
|
+
|
23
|
+
api_expects(:activation_keys, :create) do |p|
|
24
|
+
p['name'] == 'ak' && p['environment_id'] == 9 && p['organization_id'] == 1 &&
|
25
|
+
p['content_view_id'] == 3
|
26
|
+
end
|
27
|
+
|
28
|
+
run_cmd(%w(activation-key create --organization org1 --name ak --content-view cv
|
29
|
+
--lifecycle-environment test --unlimited-hosts))
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
{
|
2
|
+
"service_level": null,
|
3
|
+
"id": "1",
|
4
|
+
"organization_id": "1",
|
5
|
+
"name": "test key2",
|
6
|
+
"description": "Activation key",
|
7
|
+
"unlimited_hosts": true,
|
8
|
+
"auto_attach": true,
|
9
|
+
"release_version": null,
|
10
|
+
"purpose_usage": "Usage",
|
11
|
+
"purpose_role": "Role",
|
12
|
+
"environment": {
|
13
|
+
"name": "Library",
|
14
|
+
"id": 1
|
15
|
+
},
|
16
|
+
"purpose_addons": "Test Addon1, Test Addon2"
|
17
|
+
}
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require_relative '../test_helper'
|
2
|
+
require 'hammer_cli_katello/associating_commands'
|
3
|
+
|
4
|
+
describe 'activation-key info' do
|
5
|
+
before do
|
6
|
+
@cmd = %w(activation-key info)
|
7
|
+
end
|
8
|
+
|
9
|
+
it "includes katello attributes" do
|
10
|
+
params = ['--id=1']
|
11
|
+
ex = api_expects(:activation_keys, :show, "Activation key") do |par|
|
12
|
+
par['id'] == 1
|
13
|
+
end
|
14
|
+
|
15
|
+
json_file = File.join(File.dirname(__FILE__), 'data', 'activation_key.json')
|
16
|
+
ex.returns(JSON.parse(File.read(json_file)))
|
17
|
+
|
18
|
+
result = run_cmd(@cmd + params)
|
19
|
+
|
20
|
+
expected_fields = [['Description', 'Activation key'],
|
21
|
+
['Purpose Usage', 'Usage'],
|
22
|
+
['Purpose Role', 'Role'],
|
23
|
+
['Purpose Addons', 'Test Addon1, Test Addon2'],
|
24
|
+
['Lifecycle Environment', 'Library']]
|
25
|
+
|
26
|
+
expected_results = expected_fields.map { |field| success_result(FieldMatcher.new(*field)) }
|
27
|
+
expected_results.each { |expected| assert_cmd(expected, result) }
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '../test_helper')
|
2
|
+
require File.join(File.dirname(__FILE__), '../lifecycle_environment/lifecycle_environment_helpers')
|
3
|
+
|
4
|
+
describe 'listing activation-keys' do
|
5
|
+
include LifecycleEnvironmentHelpers
|
6
|
+
|
7
|
+
before do
|
8
|
+
@cmd = %w(activation-key list)
|
9
|
+
end
|
10
|
+
|
11
|
+
let(:org_id) { 1 }
|
12
|
+
let(:lifecycle_env_id) { 1 }
|
13
|
+
let(:empty_response) do
|
14
|
+
{
|
15
|
+
"total" => 0,
|
16
|
+
"subtotal" => 0,
|
17
|
+
"page" => "1",
|
18
|
+
"per_page" => "1000",
|
19
|
+
"error" => nil,
|
20
|
+
"search" => nil,
|
21
|
+
"sort" => {
|
22
|
+
"by" => nil,
|
23
|
+
"order" => nil
|
24
|
+
},
|
25
|
+
"results" => []
|
26
|
+
}
|
27
|
+
end
|
28
|
+
|
29
|
+
it "lists an organizations activation-keys" do
|
30
|
+
params = ["--organization-id=#{org_id}"]
|
31
|
+
|
32
|
+
ex = api_expects(:activation_keys, :index, 'Organization activation-key list') do |par|
|
33
|
+
par['organization_id'] == org_id && par['page'] == 1 &&
|
34
|
+
par['per_page'] == 1000
|
35
|
+
end
|
36
|
+
|
37
|
+
ex.returns(empty_response)
|
38
|
+
|
39
|
+
expected_result = success_result("---|------|------------|-----------------------|-------------
|
40
|
+
ID | NAME | HOST LIMIT | LIFECYCLE ENVIRONMENT | CONTENT VIEW
|
41
|
+
---|------|------------|-----------------------|-------------
|
42
|
+
")
|
43
|
+
|
44
|
+
result = run_cmd(@cmd + params)
|
45
|
+
assert_cmd(expected_result, result)
|
46
|
+
end
|
47
|
+
|
48
|
+
it "lists the activation-keys belonging to a lifecycle environment by name" do
|
49
|
+
params = ["--organization-id=#{org_id}", '--lifecycle-environment=test']
|
50
|
+
|
51
|
+
expect_lifecycle_environment_search(org_id, 'test', lifecycle_env_id)
|
52
|
+
|
53
|
+
ex = api_expects(:activation_keys, :index, 'lifecycle activation-key list') do |par|
|
54
|
+
par['organization_id'] == org_id && par['page'] == 1 &&
|
55
|
+
par['per_page'] == 1000
|
56
|
+
end
|
57
|
+
|
58
|
+
ex.returns(empty_response)
|
59
|
+
|
60
|
+
expected_result = success_result("---|------|------------|-----------------------|-------------
|
61
|
+
ID | NAME | HOST LIMIT | LIFECYCLE ENVIRONMENT | CONTENT VIEW
|
62
|
+
---|------|------------|-----------------------|-------------
|
63
|
+
")
|
64
|
+
|
65
|
+
result = run_cmd(@cmd + params)
|
66
|
+
assert_cmd(expected_result, result)
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '../test_helper')
|
2
|
+
|
3
|
+
describe 'listing available product content' do
|
4
|
+
let(:activation_key_id) { 1 }
|
5
|
+
let(:empty_response_table) do
|
6
|
+
<<eostring
|
7
|
+
---|------|------|-----|---------|-------|------------------|---------
|
8
|
+
ID | NAME | TYPE | URL | GPG KEY | LABEL | DEFAULT ENABLED? | OVERRIDE
|
9
|
+
---|------|------|-----|---------|-------|------------------|---------
|
10
|
+
eostring
|
11
|
+
end
|
12
|
+
|
13
|
+
it "lists content available for an activation key" do
|
14
|
+
ex = api_expects(:activation_keys, :product_content) do |p|
|
15
|
+
p['id'] = activation_key_id
|
16
|
+
end
|
17
|
+
ex.returns(index_response([]))
|
18
|
+
assert_cmd(
|
19
|
+
success_result(empty_response_table),
|
20
|
+
run_cmd(%w(activation-key product-content --id 1))
|
21
|
+
)
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require_relative '../test_helper'
|
2
|
+
require 'hammer_cli_katello/associating_commands'
|
3
|
+
|
4
|
+
module HammerCLIKatello
|
5
|
+
module AssociatingCommands
|
6
|
+
module HostCollection
|
7
|
+
describe RemoveHostCollectionCommand do
|
8
|
+
it 'allows minimal options' do
|
9
|
+
ex = api_expects(:activation_keys, :show) do |p|
|
10
|
+
p[:id] == '1'
|
11
|
+
end
|
12
|
+
ex.returns('id' => 1, host_collections: [{'id' => 3}])
|
13
|
+
|
14
|
+
api_expects(:activation_keys, :update) do |p|
|
15
|
+
p['id'] == '1' && p['organization_id'] == 1 && p['host_collection_ids'] == []
|
16
|
+
end
|
17
|
+
|
18
|
+
run_cmd(%w(activation-key remove-host-collection --organization-id 1
|
19
|
+
--host-collection-id 3 --id 1))
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'allows resolving host collection name' do
|
23
|
+
ex = api_expects(:host_collections, :index) do |p|
|
24
|
+
p['name'] == 'hc3' && p['organization_id'] == 1
|
25
|
+
end
|
26
|
+
ex.returns(index_response([{id: 1}]))
|
27
|
+
|
28
|
+
ex = api_expects(:activation_keys, :show) do |p|
|
29
|
+
p[:id] == '1'
|
30
|
+
end
|
31
|
+
ex.returns(id: 1, host_collections: [{'id' => 3}])
|
32
|
+
|
33
|
+
api_expects(:activation_keys, :update) do |p|
|
34
|
+
p['id'] == '1' && p['organization_id'] == 1 && p['host_collection_ids'] == []
|
35
|
+
end
|
36
|
+
|
37
|
+
run_cmd(%w(activation-key remove-host-collection --organization-id 1
|
38
|
+
--host-collection hc3 --id 1))
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'allows resolving activation key name' do
|
42
|
+
ex = api_expects(:activation_keys, :index) do |p|
|
43
|
+
p['name'] == 'ak1' && p['organization_id'] == 1
|
44
|
+
end
|
45
|
+
ex.at_least_once.returns(index_response([{'id' => 1}]))
|
46
|
+
|
47
|
+
ex = api_expects(:activation_keys, :show) do |p|
|
48
|
+
p[:id] == 1
|
49
|
+
end
|
50
|
+
ex.returns(id: 1, host_collections: [{'id' => 3}])
|
51
|
+
|
52
|
+
api_expects(:activation_keys, :update) do |p|
|
53
|
+
p['id'] == 1 && p['organization_id'] == 1 && p['host_collection_ids'] == []
|
54
|
+
end
|
55
|
+
|
56
|
+
run_cmd(%w(activation-key remove-host-collection --organization-id 1
|
57
|
+
--host-collection-id 3 --name ak1))
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
require_relative '../test_helper'
|
2
|
+
require 'hammer_cli_katello/activation_key'
|
3
|
+
|
4
|
+
module HammerCLIKatello
|
5
|
+
describe ActivationKeyCommand::SubscriptionsCommand do
|
6
|
+
it 'requires organization options' do
|
7
|
+
expected_error = "Could not find organization"
|
8
|
+
result = run_cmd(%w(activation-key subscriptions --name test))
|
9
|
+
assert_equal(result.err[/#{expected_error}/], expected_error)
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'allows organization name' do
|
13
|
+
api_expects(:organizations, :index) { |par| par[:search] == "name = \"org1\"" }
|
14
|
+
.returns(index_response([{'id' => 1}]))
|
15
|
+
|
16
|
+
api_expects(:subscriptions, :index) { |par| par['organization_id'].to_i == 1 }
|
17
|
+
|
18
|
+
run_cmd(%w(activation-key subscriptions --id 1 --organization org1))
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'allows organization label' do
|
22
|
+
api_expects(:organizations, :index) { |par| par[:search] == "label = \"org1\"" }
|
23
|
+
.returns(index_response([{'id' => 1}]))
|
24
|
+
|
25
|
+
api_expects(:subscriptions, :index) { |par| par['organization_id'].to_i == 1 }
|
26
|
+
|
27
|
+
run_cmd(%w(activation-key subscriptions --id 1 --organization-label org1))
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'lists subscriptions available for the activation key' do
|
31
|
+
api_expects(:subscriptions, :index) do |p|
|
32
|
+
p['available_for'] == 'activation_key'
|
33
|
+
end
|
34
|
+
run_cmd(%w(activation-key subscriptions --organization-id 1 --id 1
|
35
|
+
--available-for activation_key))
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'lists subscriptions used by the activation key' do
|
39
|
+
api_expects(:subscriptions, :index) { |p| p['activation_key_id'] == 1 }
|
40
|
+
run_cmd(%w(activation-key subscriptions --organization-id 1 --id 1))
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'allows activation_key_name' do
|
44
|
+
api_expects(:activation_keys, :index) { |p| p['name'] == 'ak1' }
|
45
|
+
.returns(index_response([{'id' => 1}]))
|
46
|
+
api_expects(:subscriptions, :index) { |p| p['activation_key_id'] == 1 }
|
47
|
+
run_cmd(%w(activation-key subscriptions --organization-id 1 --name ak1))
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'allows a subscription to be added to an activation key' do
|
51
|
+
api_expects(:activation_keys, :add_subscriptions) do |p|
|
52
|
+
p['id'] == 1 && p['subscription_id'] == 3
|
53
|
+
end
|
54
|
+
run_cmd(%w(activation-key add-subscription --id 1 --subscription-id 3))
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'allows a subscription to be added by name to an activation key with org label' do
|
58
|
+
api_expects(:organizations, :index) { |par| par[:search] == "label = \"org1\"" }
|
59
|
+
.returns(index_response([{'id' => 1}]))
|
60
|
+
api_expects(:subscriptions, :index) { |p| p['name'] == 'sub' }
|
61
|
+
.returns(index_response([{'name' => 'sub'}]))
|
62
|
+
api_expects(:activation_keys, :add_subscriptions) { |p| p['id'] == 1 }
|
63
|
+
run_cmd(%w(activation-key add-subscription --id 1 --subscription sub
|
64
|
+
--organization-label org1))
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'allows multiple subscriptions to be added to an activation key' do
|
68
|
+
api_expects(:activation_keys, :add_subscriptions) do |p|
|
69
|
+
p['id'] == 1 && p['subscriptions'] == [{'id' => '3'}, {'id' => '4'}]
|
70
|
+
end
|
71
|
+
run_cmd(%w(activation-key add-subscription --id 1 --subscriptions id=3,id=4))
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require_relative '../test_helper'
|
2
|
+
require 'hammer_cli_katello/activation_key'
|
3
|
+
|
4
|
+
module HammerCLIKatello
|
5
|
+
describe ActivationKeyCommand do
|
6
|
+
describe UpdateCommand do
|
7
|
+
it 'allows promoting a content view' do
|
8
|
+
ex = api_expects(:organizations, :index) do |p|
|
9
|
+
p[:search] == "name = \"org1\""
|
10
|
+
end
|
11
|
+
ex.at_least_once.returns(index_response([{'id' => 1}]))
|
12
|
+
|
13
|
+
ex = api_expects(:activation_keys, :index) do |p|
|
14
|
+
p['name'] == 'ak' && p['organization_id'] == 1
|
15
|
+
end
|
16
|
+
ex.returns(index_response([{'id' => 6}]))
|
17
|
+
|
18
|
+
api_expects(:activation_keys, :update) do |p|
|
19
|
+
p['id'] == 6 && p['organization_id'] == 1
|
20
|
+
end
|
21
|
+
|
22
|
+
run_cmd(%w(activation-key update --organization org1 --name ak --auto-attach false))
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '../test_helper')
|
2
|
+
|
3
|
+
describe 'apipie helper' do
|
4
|
+
before do
|
5
|
+
class ApipieTestHelper
|
6
|
+
include HammerCLIKatello::ApipieHelper
|
7
|
+
end
|
8
|
+
|
9
|
+
@apipie_helper = ApipieTestHelper.new
|
10
|
+
end
|
11
|
+
|
12
|
+
it "calls show method apipie resource" do
|
13
|
+
api_expects(:repositories, :show).with_params('id' => '1').returns({})
|
14
|
+
assert @apipie_helper.show(:repositories, 'id' => '1')
|
15
|
+
end
|
16
|
+
|
17
|
+
it "calls index method apipie resource" do
|
18
|
+
api_expects(:repositories, :index).with_params('name' => 'foo').returns('results' => [])
|
19
|
+
assert @apipie_helper.index(:repositories, 'name' => 'foo')
|
20
|
+
end
|
21
|
+
|
22
|
+
it "calls destroy method apipie resource" do
|
23
|
+
api_expects(:repositories, :destroy).with_params('id' => '1').returns({})
|
24
|
+
assert @apipie_helper.destroy(:repositories, 'id' => '1')
|
25
|
+
end
|
26
|
+
|
27
|
+
it "call method for apipie resources works" do
|
28
|
+
api_expects(:repositories, :index).with_params('name' => 'foo').returns('results' => [])
|
29
|
+
assert @apipie_helper.call(:index, :repositories, 'name' => 'foo')
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require_relative '../search_helpers'
|
2
|
+
|
3
|
+
module CapsuleHelpers
|
4
|
+
include SearchHelpers
|
5
|
+
|
6
|
+
def expect_generic_capsule_search(opts = {params: {}, returns: {}})
|
7
|
+
expect_generic_search(:smart_proxies, opts)
|
8
|
+
end
|
9
|
+
|
10
|
+
def expect_capsule_info(params = {})
|
11
|
+
api_expects(:smart_proxies, :show).with_params(params)
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require_relative '../../test_helper'
|
2
|
+
require_relative 'capsule_content_helpers'
|
3
|
+
require_relative '../../lifecycle_environment/lifecycle_environment_helpers'
|
4
|
+
require_relative '../../organization/organization_helpers'
|
5
|
+
require 'hammer_cli_katello/capsule'
|
6
|
+
|
7
|
+
module HammerCLIKatello
|
8
|
+
module Capsule
|
9
|
+
class Content
|
10
|
+
describe Content::AddLifecycleEnvironmentCommand do
|
11
|
+
include CapsuleContentHelpers
|
12
|
+
include LifecycleEnvironmentHelpers
|
13
|
+
include OrganizationHelpers
|
14
|
+
|
15
|
+
it 'allows minimal options' do
|
16
|
+
expect_lifecycle_environment_add('id' => 1, 'environment_id' => 2)
|
17
|
+
|
18
|
+
run_cmd(%w(capsule content add-lifecycle-environment --id 1 --environment-id 2))
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'resolves environment ID from name' do
|
22
|
+
expect_lifecycle_environment_search('3', 'env2', 2)
|
23
|
+
expect_lifecycle_environment_add('id' => 1, 'environment_id' => 2)
|
24
|
+
|
25
|
+
run_cmd(%w(capsule content add-lifecycle-environment --id 1 --environment env2
|
26
|
+
--organization-id 3))
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'resolves organization ID from name' do
|
30
|
+
expect_organization_search('org3', 3)
|
31
|
+
expect_lifecycle_environment_search(3, 'env2', 2)
|
32
|
+
expect_lifecycle_environment_add('id' => 1, 'environment_id' => 2)
|
33
|
+
|
34
|
+
run_cmd(%w(capsule content add-lifecycle-environment --id 1 --environment env2
|
35
|
+
--organization org3))
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '../../test_helper')
|
2
|
+
require File.join(File.dirname(__FILE__), './capsule_content_helpers')
|
3
|
+
|
4
|
+
describe 'capsule content cancel-synchronization' do
|
5
|
+
include CapsuleContentHelpers
|
6
|
+
|
7
|
+
before do
|
8
|
+
@cmd = ['capsule', 'content', 'cancel-synchronization']
|
9
|
+
end
|
10
|
+
|
11
|
+
MESSAGE = "There's no running synchronization for this capsule.".freeze
|
12
|
+
|
13
|
+
it "triggers the cancel" do
|
14
|
+
expected_result = success_result("#{MESSAGE}\n")
|
15
|
+
params = ['--id=3']
|
16
|
+
|
17
|
+
ex = api_expects(:capsule_content, :cancel_sync, 'Cancel sync') do |par|
|
18
|
+
par['id'] == 3
|
19
|
+
end
|
20
|
+
ex.returns("message" => MESSAGE)
|
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 = ['--name=capsule1']
|
28
|
+
|
29
|
+
ex = api_expects(:capsule_content, :cancel_sync, 'Cancel sync') do |par|
|
30
|
+
par['id'] == 3
|
31
|
+
end
|
32
|
+
ex.returns("message" => MESSAGE)
|
33
|
+
expect_capsule_search('capsule1', 3)
|
34
|
+
|
35
|
+
run_cmd(@cmd + params)
|
36
|
+
end
|
37
|
+
|
38
|
+
it "is mounted under proxy too" do
|
39
|
+
result = run_cmd(['proxy', 'content', 'cancel-synchronization', '-h'])
|
40
|
+
assert_exit_code_equal(HammerCLI::EX_OK, result.exit_code)
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require_relative '../capsule_helpers'
|
2
|
+
|
3
|
+
module CapsuleContentHelpers
|
4
|
+
include CapsuleHelpers
|
5
|
+
|
6
|
+
def expect_capsule_search(name, id)
|
7
|
+
expect_generic_capsule_search(params: {search: "name = \"#{name}\""}, returns: {'id' => id})
|
8
|
+
end
|
9
|
+
|
10
|
+
def expect_lifecycle_environments_list(args = {params: {}, returns: []})
|
11
|
+
api_expects(:capsule_content, :lifecycle_environments)
|
12
|
+
.with_params(args[:params]).returns(index_response(args[:returns]))
|
13
|
+
end
|
14
|
+
|
15
|
+
def expect_lifecycle_environment_add(params = {})
|
16
|
+
api_expects(:capsule_content, :add_lifecycle_environment)
|
17
|
+
.with_params(params)
|
18
|
+
end
|
19
|
+
|
20
|
+
def expect_lifecycle_environment_remove(params = {})
|
21
|
+
api_expects(:capsule_content, :remove_lifecycle_environment)
|
22
|
+
.with_params(params)
|
23
|
+
end
|
24
|
+
end
|