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
data/test/data/Readme.md
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '../test_helper')
|
2
|
+
|
3
|
+
describe 'create content-credentials' do
|
4
|
+
before do
|
5
|
+
@cmd = %w(alternate-content-source create)
|
6
|
+
end
|
7
|
+
|
8
|
+
let(:name) { 'pizza' }
|
9
|
+
let(:url) { 'http://proxy.example.com' }
|
10
|
+
let(:acs_type) { 'custom' }
|
11
|
+
let(:acs_content) { 'yum' }
|
12
|
+
let(:verify_ssl) { false }
|
13
|
+
let(:proxy_id) { 1 }
|
14
|
+
let(:subpaths) { ['test/repo1/'] }
|
15
|
+
|
16
|
+
it 'Creates an ACS' do
|
17
|
+
params = ["--name=#{name}", "--alternate-content-source-type=#{acs_type}",
|
18
|
+
"--base-url=#{url}", "--content-type=#{acs_content}", "--verify-ssl=#{verify_ssl}",
|
19
|
+
"--smart-proxy-ids=#{proxy_id}", "--subpaths=#{subpaths}"]
|
20
|
+
|
21
|
+
api_expects(:alternate_content_sources, :create, 'Create an ACS')
|
22
|
+
|
23
|
+
expected_result = success_result("Alternate Content Source created.\n")
|
24
|
+
result = run_cmd(@cmd + params)
|
25
|
+
assert_cmd(expected_result, result)
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '../test_helper')
|
2
|
+
|
3
|
+
describe 'delete an acs' do
|
4
|
+
let(:id) { 1 }
|
5
|
+
|
6
|
+
it 'by id' do
|
7
|
+
api_expects(:alternate_content_sources, :destroy, 'delete acs').
|
8
|
+
with_params('id' => id)
|
9
|
+
|
10
|
+
command = %W(alternate-content-source delete --id #{id})
|
11
|
+
assert_equal(0, run_cmd(command).exit_code)
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,94 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '../test_helper')
|
2
|
+
require 'hammer_cli_katello/associating_commands'
|
3
|
+
|
4
|
+
describe 'get acs info' do
|
5
|
+
before do
|
6
|
+
@cmd = %w(alternate-content-source info)
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'shows acs info by id' do
|
10
|
+
params = ['--id=1']
|
11
|
+
ex = api_expects(:alternate_content_sources, :show, 'Get info')
|
12
|
+
ex.returns(
|
13
|
+
'id' => 1,
|
14
|
+
'name' => 'Pizza ACS',
|
15
|
+
'label' => 'Pizza ACS',
|
16
|
+
'base_url' => 'https://proxy.example.com',
|
17
|
+
'content_type' => 'yum',
|
18
|
+
'alternate_content_source_type' => 'custom',
|
19
|
+
'subpaths' => [
|
20
|
+
'test/repo1'
|
21
|
+
],
|
22
|
+
'smart_proxies' => {
|
23
|
+
'id' => 1,
|
24
|
+
'name' => 'centos7.example.com',
|
25
|
+
'url' => 'https://centos7.example.com:9090',
|
26
|
+
'download_policy' => 'on_demand'
|
27
|
+
}
|
28
|
+
)
|
29
|
+
result = run_cmd(@cmd + params)
|
30
|
+
# rubocop:disable Style/WordArray
|
31
|
+
expected_fields = [['ID', '1'],
|
32
|
+
['Name', 'Pizza ACS'],
|
33
|
+
['Label', 'Pizza ACS'],
|
34
|
+
['Base URL', 'https://proxy.example.com'],
|
35
|
+
['Content type', 'yum'],
|
36
|
+
['Alternate content source type', 'custom'],
|
37
|
+
['Subpaths', ''],
|
38
|
+
['', 'test/repo1'],
|
39
|
+
['Smart proxies', ''],
|
40
|
+
['Id', '1'],
|
41
|
+
['Name', 'centos7.example.com'],
|
42
|
+
['URL', 'https://centos7.example.com:9090'],
|
43
|
+
['Download policy', 'on_demand']]
|
44
|
+
|
45
|
+
# rubocop:enable Style/WordArray
|
46
|
+
expected_results = expected_fields.map { |field| success_result(FieldMatcher.new(*field)) }
|
47
|
+
expected_results.each { |expected| assert_cmd(expected, result) }
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'shows simplified acs info by id' do
|
51
|
+
params = ['--id=2']
|
52
|
+
ex = api_expects(:alternate_content_sources, :show, 'Get info')
|
53
|
+
ex.returns(
|
54
|
+
'id' => 2,
|
55
|
+
'name' => 'Pizza ACS',
|
56
|
+
'label' => 'Pizza ACS',
|
57
|
+
'content_type' => 'yum',
|
58
|
+
'alternate_content_source_type' => 'simplified',
|
59
|
+
'products' => {
|
60
|
+
'id' => 999,
|
61
|
+
'organization_id' => 9,
|
62
|
+
'name' => 'Buttermilk Biscuits',
|
63
|
+
'label' => 'Buttermilk_Biscuits'
|
64
|
+
},
|
65
|
+
'smart_proxies' => {
|
66
|
+
'id' => 1,
|
67
|
+
'name' => 'centos7.example.com',
|
68
|
+
'url' => 'https://centos7.example.com:9090',
|
69
|
+
'download_policy' => 'on_demand'
|
70
|
+
}
|
71
|
+
)
|
72
|
+
result = run_cmd(@cmd + params)
|
73
|
+
# rubocop:disable Style/WordArray
|
74
|
+
expected_fields = [['ID', '2'],
|
75
|
+
['Name', 'Pizza ACS'],
|
76
|
+
['Label', 'Pizza ACS'],
|
77
|
+
['Content type', 'yum'],
|
78
|
+
['Alternate content source type', 'simplified'],
|
79
|
+
['Products', ''],
|
80
|
+
['Id', '999'],
|
81
|
+
['Organization ID', '9'],
|
82
|
+
['Name', 'Buttermilk Biscuits'],
|
83
|
+
['Label', 'Buttermilk_Biscuits'],
|
84
|
+
['Smart proxies', ''],
|
85
|
+
['Id', '1'],
|
86
|
+
['Name', 'centos7.example.com'],
|
87
|
+
['URL', 'https://centos7.example.com:9090'],
|
88
|
+
['Download policy', 'on_demand']]
|
89
|
+
|
90
|
+
# rubocop:enable Style/WordArray
|
91
|
+
expected_results = expected_fields.map { |field| success_result(FieldMatcher.new(*field)) }
|
92
|
+
expected_results.each { |expected| assert_cmd(expected, result) }
|
93
|
+
end
|
94
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '../test_helper')
|
2
|
+
|
3
|
+
describe 'listing acs' do
|
4
|
+
before do
|
5
|
+
@cmd = %w(alternate-content-source list)
|
6
|
+
end
|
7
|
+
|
8
|
+
let(:empty_response) do
|
9
|
+
{
|
10
|
+
"total" => 0,
|
11
|
+
"subtotal" => 0,
|
12
|
+
"page" => "1",
|
13
|
+
"per_page" => "1000",
|
14
|
+
"error" => nil,
|
15
|
+
"search" => nil,
|
16
|
+
"sort" => {
|
17
|
+
"by" => nil,
|
18
|
+
"order" => nil
|
19
|
+
},
|
20
|
+
"results" => []
|
21
|
+
}
|
22
|
+
end
|
23
|
+
|
24
|
+
let(:acs_response) do
|
25
|
+
{
|
26
|
+
'id' => 1,
|
27
|
+
'name' => 'pizza',
|
28
|
+
'alternate_content_source_type' => 'custom'
|
29
|
+
}
|
30
|
+
end
|
31
|
+
|
32
|
+
it "lists acs and returns empty response" do
|
33
|
+
ex = api_expects(:alternate_content_sources, :index, 'acs list') do |par|
|
34
|
+
par['page'] == 1 && par['per_page'] == 1000
|
35
|
+
end
|
36
|
+
|
37
|
+
ex.returns(empty_response)
|
38
|
+
|
39
|
+
expected_result = success_result("---|------|-----
|
40
|
+
ID | NAME | TYPE
|
41
|
+
---|------|-----
|
42
|
+
")
|
43
|
+
|
44
|
+
result = run_cmd(@cmd)
|
45
|
+
assert_cmd(expected_result, result)
|
46
|
+
end
|
47
|
+
|
48
|
+
it "lists acs and returns response" do
|
49
|
+
ex = api_expects(:alternate_content_sources, :index, 'acs list') do |par|
|
50
|
+
par['page'] == 1 && par['per_page'] == 1000
|
51
|
+
end
|
52
|
+
|
53
|
+
ex.returns(acs_response)
|
54
|
+
|
55
|
+
expected_result = success_result("1 | pizza | custom
|
56
|
+
---|-------|-------
|
57
|
+
")
|
58
|
+
|
59
|
+
result = run_cmd(@cmd)
|
60
|
+
assert_cmd(expected_result, result)
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '../test_helper')
|
2
|
+
|
3
|
+
describe 'listing acs' do
|
4
|
+
before do
|
5
|
+
@cmd = %w(alternate-content-source update)
|
6
|
+
end
|
7
|
+
|
8
|
+
let(:id) { 1 }
|
9
|
+
let(:desc) { 'pizza' }
|
10
|
+
|
11
|
+
it 'update acs' do
|
12
|
+
params = ["--id=#{id}", "--description=#{desc}"]
|
13
|
+
|
14
|
+
ex = api_expects(:alternate_content_sources, :update, 'acs update') do |par|
|
15
|
+
par['id'] == 1 && par['description'] == 'pizza'
|
16
|
+
end
|
17
|
+
|
18
|
+
ex.returns({})
|
19
|
+
|
20
|
+
result = run_cmd(@cmd + params)
|
21
|
+
assert_equal(result.exit_code, 0)
|
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 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 activation key creation' 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
|