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
@@ -0,0 +1,54 @@
|
|
1
|
+
require_relative '../test_helper'
|
2
|
+
require 'hammer_cli_katello/host_collection'
|
3
|
+
|
4
|
+
module HammerCLIKatello
|
5
|
+
describe HostCollection::CreateCommand do
|
6
|
+
it 'requires organization options' do
|
7
|
+
result = run_cmd(%w(host-collection create --name hc1))
|
8
|
+
expected_error = "Could not find organization"
|
9
|
+
assert_equal(result.exit_code, HammerCLI::EX_SOFTWARE)
|
10
|
+
assert_equal(result.err[/#{expected_error}/], expected_error)
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'allows organization id' do
|
14
|
+
api_expects(:host_collections, :create) do |par|
|
15
|
+
par['organization_id'].to_i == 1
|
16
|
+
end
|
17
|
+
|
18
|
+
run_cmd(%w(host-collection create --name hc1 --organization-id 1))
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'allows organization name' do
|
22
|
+
api_expects(:organizations, :index) { |par| par[:search] == "name = \"org1\"" }
|
23
|
+
.returns(index_response([{'id' => 1}]))
|
24
|
+
|
25
|
+
api_expects(:host_collections, :create) do |par|
|
26
|
+
par['organization_id'].to_i == 1
|
27
|
+
end
|
28
|
+
|
29
|
+
run_cmd(%w(host-collection create --name hc1 --organization org1))
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'allows unlimited-hosts flag with no arguments' do
|
33
|
+
api_expects(:organizations, :index) { |par| par[:search] == "name = \"org1\"" }
|
34
|
+
.returns(index_response([{'id' => 1}]))
|
35
|
+
|
36
|
+
api_expects(:host_collections, :create) do |par|
|
37
|
+
par['unlimited_hosts'] == true
|
38
|
+
end
|
39
|
+
|
40
|
+
run_cmd(%w(host-collection create --name hc1 --organization org1 --unlimited-hosts))
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'allows organization label' do
|
44
|
+
api_expects(:organizations, :index) { |par| par[:search] == "label = \"org1\"" }
|
45
|
+
.returns(index_response([{'id' => 1}]))
|
46
|
+
|
47
|
+
api_expects(:host_collections, :create) do |par|
|
48
|
+
par['organization_id'].to_i == 1
|
49
|
+
end
|
50
|
+
|
51
|
+
run_cmd(%w(host-collection create --name hc1 --organization-label org1))
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require_relative '../test_helper'
|
2
|
+
require 'hammer_cli_katello/host_collection'
|
3
|
+
|
4
|
+
module HammerCLIKatello
|
5
|
+
describe HostCollection::DeleteCommand do
|
6
|
+
it 'does not require organization options if id is specified' do
|
7
|
+
api_expects(:host_collections, :destroy)
|
8
|
+
run_cmd(%w(host-collection delete --id 1))
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'requires organization options if name is specified' do
|
12
|
+
result = run_cmd(%w(host-collection delete --name hc1))
|
13
|
+
expected_error = "Missing options to search organization"
|
14
|
+
assert_equal(HammerCLI::EX_SOFTWARE, result.exit_code)
|
15
|
+
assert_equal(expected_error, result.err[/#{expected_error}/])
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'allows organization id' do
|
19
|
+
api_expects(:host_collections, :index) { |par| par['organization_id'].to_i == 1 }
|
20
|
+
.returns(index_response([{'id' => 2}]))
|
21
|
+
|
22
|
+
api_expects(:host_collections, :destroy) do |par|
|
23
|
+
par['id'].to_i == 2
|
24
|
+
end
|
25
|
+
|
26
|
+
run_cmd(%w(host-collection delete --name hc1 --organization-id 1))
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'allows organization name' do
|
30
|
+
api_expects(:organizations, :index) { |par| par[:search] == "name = \"org1\"" }
|
31
|
+
.returns(index_response([{'id' => 1}]))
|
32
|
+
|
33
|
+
api_expects(:host_collections, :index) { |par| par['organization_id'].to_i == 1 }
|
34
|
+
.returns(index_response([{'id' => 2}]))
|
35
|
+
|
36
|
+
api_expects(:host_collections, :destroy) do |par|
|
37
|
+
par['id'].to_i == 2
|
38
|
+
end
|
39
|
+
|
40
|
+
run_cmd(%w(host-collection delete --name hc1 --organization org1))
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'allows organization label' do
|
44
|
+
api_expects(:organizations, :index) { |par| par[:search] == "label = \"org1\"" }
|
45
|
+
.returns(index_response([{'id' => 1}]))
|
46
|
+
|
47
|
+
api_expects(:host_collections, :index) { |par| par['organization_id'].to_i == 1 }
|
48
|
+
.returns(index_response([{'id' => 2}]))
|
49
|
+
|
50
|
+
api_expects(:host_collections, :destroy) do |par|
|
51
|
+
par['id'].to_i == 2
|
52
|
+
end
|
53
|
+
|
54
|
+
run_cmd(%w(host-collection delete --name hc1 --organization-label org1))
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require_relative '../test_helper'
|
2
|
+
require 'hammer_cli_katello/host_collection'
|
3
|
+
|
4
|
+
module HammerCLIKatello
|
5
|
+
describe HostCollection::HostsCommand do
|
6
|
+
it 'allows host collection id' do
|
7
|
+
api_expects(:hosts, :index) do |par|
|
8
|
+
par['search'] == "host_collection_id=1"
|
9
|
+
end
|
10
|
+
|
11
|
+
run_cmd(%w(host-collection hosts --id 1))
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'allows host collection name' do
|
15
|
+
ex = api_expects(:host_collections, :index)
|
16
|
+
ex.returns(index_response([{'id' => 2}]))
|
17
|
+
|
18
|
+
api_expects(:hosts, :index) do |par|
|
19
|
+
par['search'] == "host_collection_id=2"
|
20
|
+
end
|
21
|
+
|
22
|
+
run_cmd(%w(host-collection hosts --name collection --organization-id 1))
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'requires organization with host collection name' do
|
26
|
+
result = run_cmd(%w(host-collection hosts --name collection))
|
27
|
+
expected_error = "Missing options to search organization"
|
28
|
+
assert_equal(HammerCLI::EX_SOFTWARE, result.exit_code)
|
29
|
+
assert_equal(expected_error, result.err[/#{expected_error}/])
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'requires host collection name or id' do
|
33
|
+
result = run_cmd(%w(host-collection hosts))
|
34
|
+
expected_error = "Error: At least one of options --id, --name is required"
|
35
|
+
assert_equal(HammerCLI::EX_USAGE, result.exit_code)
|
36
|
+
assert_equal(expected_error, result.err[/#{expected_error}/])
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require_relative '../test_helper'
|
2
|
+
require 'hammer_cli_katello/host_collection'
|
3
|
+
|
4
|
+
module HammerCLIKatello
|
5
|
+
describe HostCollection::InfoCommand do
|
6
|
+
it 'does not require organization options if id is specified' do
|
7
|
+
api_expects(:host_collections, :show)
|
8
|
+
run_cmd(%w(host-collection info --id 1))
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'requires organization options if id is not specified' do
|
12
|
+
result = run_cmd(%w(host-collection info --name hc1))
|
13
|
+
expected_error = "Missing options to search organization"
|
14
|
+
assert_equal(HammerCLI::EX_SOFTWARE, result.exit_code)
|
15
|
+
assert_equal(expected_error, result.err[/#{expected_error}/])
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'allows organization id' do
|
19
|
+
api_expects(:host_collections, :index) { |par| par['organization_id'].to_i == 1 }
|
20
|
+
.returns(index_response([{'id' => 2}]))
|
21
|
+
|
22
|
+
api_expects(:host_collections, :show) do |par|
|
23
|
+
par['id'].to_i == 2
|
24
|
+
end
|
25
|
+
|
26
|
+
run_cmd(%w(host-collection info --name hc1 --organization-id 1))
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'allows organization name' do
|
30
|
+
api_expects(:organizations, :index) { |par| par[:search] == "name = \"org1\"" }
|
31
|
+
.returns(index_response([{'id' => 1}]))
|
32
|
+
|
33
|
+
api_expects(:host_collections, :index) { |par| par['organization_id'].to_i == 1 }
|
34
|
+
.returns(index_response([{'id' => 2}]))
|
35
|
+
|
36
|
+
api_expects(:host_collections, :show) do |par|
|
37
|
+
par['id'].to_i == 2
|
38
|
+
end
|
39
|
+
|
40
|
+
run_cmd(%w(host-collection info --name hc1 --organization org1))
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'allows organization label' do
|
44
|
+
api_expects(:organizations, :index) { |par| par[:search] == "label = \"org1\"" }
|
45
|
+
.returns(index_response([{'id' => 1}]))
|
46
|
+
|
47
|
+
api_expects(:host_collections, :index) { |par| par['organization_id'].to_i == 1 }
|
48
|
+
.returns(index_response([{'id' => 2}]))
|
49
|
+
|
50
|
+
api_expects(:host_collections, :show) do |par|
|
51
|
+
par['id'].to_i == 2
|
52
|
+
end
|
53
|
+
|
54
|
+
run_cmd(%w(host-collection info --name hc1 --organization-label org1))
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require_relative '../test_helper'
|
2
|
+
require 'hammer_cli_katello/host_collection'
|
3
|
+
|
4
|
+
module HammerCLIKatello
|
5
|
+
describe HostCollection::ListCommand do
|
6
|
+
it 'does not require organization options' do
|
7
|
+
api_expects(:host_collections, :index)
|
8
|
+
|
9
|
+
run_cmd(%w(host-collection list))
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'allows organization id' do
|
13
|
+
api_expects(:host_collections, :index) do |par|
|
14
|
+
par['organization_id'].to_i == 1
|
15
|
+
end
|
16
|
+
|
17
|
+
run_cmd(%w(host-collection list --organization-id 1))
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'allows organization name' do
|
21
|
+
api_expects(:organizations, :index) { |par| par[:search] == "name = \"org1\"" }
|
22
|
+
.returns(index_response([{'id' => 1}]))
|
23
|
+
|
24
|
+
api_expects(:host_collections, :index) do |par|
|
25
|
+
par['organization_id'].to_i == 1
|
26
|
+
end
|
27
|
+
|
28
|
+
run_cmd(%w(host-collection list --organization org1))
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'allows organization label' do
|
32
|
+
api_expects(:organizations, :index) { |par| par[:search] == "label = \"org1\"" }
|
33
|
+
.returns(index_response([{'id' => 1}]))
|
34
|
+
|
35
|
+
api_expects(:host_collections, :index) do |par|
|
36
|
+
par['organization_id'].to_i == 1
|
37
|
+
end
|
38
|
+
|
39
|
+
run_cmd(%w(host-collection list --organization-label org1))
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'allows host id' do
|
43
|
+
api_expects(:host_collections, :index) do |par|
|
44
|
+
par['host_id'] == 1
|
45
|
+
end
|
46
|
+
|
47
|
+
run_cmd(%w(host-collection list --host-id 1 --organization-id 1))
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'allows host name' do
|
51
|
+
ex = api_expects(:hosts, :index) do |par|
|
52
|
+
par[:search] == "name = \"host1\""
|
53
|
+
end
|
54
|
+
ex.returns(index_response([{'id' => 1}]))
|
55
|
+
|
56
|
+
api_expects(:host_collections, :index) do |par|
|
57
|
+
par['host_id'] == 1
|
58
|
+
end
|
59
|
+
|
60
|
+
run_cmd(%w(host-collection list --host host1 --organization-id 1))
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,90 @@
|
|
1
|
+
require_relative '../test_helper'
|
2
|
+
require 'hammer_cli_katello/host_collection'
|
3
|
+
|
4
|
+
module HammerCLIKatello
|
5
|
+
describe HostCollection::RemoveHostCommand do
|
6
|
+
describe 'handles individual host errors' do
|
7
|
+
it 'for successful results' do
|
8
|
+
api_expects(:host_collections, :remove_hosts)
|
9
|
+
.with_params('id' => 1, 'host_ids' => %w(2 3))
|
10
|
+
.returns("displayMessages" => {"success" => ["Successfully removed 2 Host(s)."],
|
11
|
+
"error" => []})
|
12
|
+
result = run_cmd(%w(host-collection remove-host --id 1 --host-ids 2,3))
|
13
|
+
assert_match("The host(s) has been removed", result.out)
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'for mixed results' do
|
17
|
+
api_expects(:host_collections, :remove_hosts)
|
18
|
+
.with_params('id' => 1, 'host_ids' => %w(2 3))
|
19
|
+
.returns("displayMessages" => {"success" => ["Successfully removed 1 Host(s)."],
|
20
|
+
"error" => ["Host with ID 3 not found."]})
|
21
|
+
result = run_cmd(%w(host-collection remove-host --id 1 --host-ids 2,3))
|
22
|
+
assert_match("Could not remove 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, :remove_hosts)
|
28
|
+
.with_params('id' => 1, 'host_ids' => %w(2 3))
|
29
|
+
.returns("displayMessages" => {"success" => [], "error" => [
|
30
|
+
"Host with ID 1 does not exist in the host collection.",
|
31
|
+
"Host with ID 3 not found."]})
|
32
|
+
result = run_cmd(%w(host-collection remove-host --id 1 --host-ids 2,3))
|
33
|
+
assert_match("Could not remove host(s)", result.out)
|
34
|
+
assert_match("Host with ID 1 does not exist 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, :remove_hosts)
|
41
|
+
run_cmd(%w(host-collection remove-host --id 1))
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'requires organization options if name is specified' do
|
45
|
+
result = run_cmd(%w(host-collection remove-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, :remove_hosts) do |par|
|
56
|
+
par['id'].to_i == 2
|
57
|
+
end
|
58
|
+
|
59
|
+
run_cmd(%w(host-collection remove-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, :remove_hosts) do |par|
|
70
|
+
par['id'].to_i == 2
|
71
|
+
end
|
72
|
+
|
73
|
+
run_cmd(%w(host-collection remove-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, :remove_hosts) do |par|
|
84
|
+
par['id'].to_i == 2
|
85
|
+
end
|
86
|
+
|
87
|
+
run_cmd(%w(host-collection remove-host --name hc1 --organization-label org1))
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require_relative '../test_helper'
|
2
|
+
require 'hammer_cli_katello/host_collection'
|
3
|
+
|
4
|
+
module HammerCLIKatello
|
5
|
+
describe HostCollection::UpdateCommand do
|
6
|
+
it 'does not require organization options if id is specified' do
|
7
|
+
api_expects(:host_collections, :update)
|
8
|
+
run_cmd(%w(host-collection update --id 1))
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'requires organization options if name is specified' do
|
12
|
+
result = run_cmd(%w(host-collection update --name hc1))
|
13
|
+
expected_error = "Missing options to search organization"
|
14
|
+
assert_equal(HammerCLI::EX_SOFTWARE, result.exit_code)
|
15
|
+
assert_equal(expected_error, result.err[/#{expected_error}/])
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'allows organization id' do
|
19
|
+
api_expects(:host_collections, :index) { |par| par['organization_id'].to_i == 1 }
|
20
|
+
.returns(index_response([{'id' => 2}]))
|
21
|
+
|
22
|
+
api_expects(:host_collections, :update) do |par|
|
23
|
+
par['id'].to_i == 2
|
24
|
+
end
|
25
|
+
|
26
|
+
run_cmd(%w(host-collection update --name hc1 --organization-id 1))
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'allows organization name' do
|
30
|
+
api_expects(:organizations, :index) { |par| par[:search] == "name = \"org1\"" }
|
31
|
+
.returns(index_response([{'id' => 1}]))
|
32
|
+
|
33
|
+
api_expects(:host_collections, :index) { |par| par['organization_id'].to_i == 1 }
|
34
|
+
.returns(index_response([{'id' => 2}]))
|
35
|
+
|
36
|
+
api_expects(:host_collections, :update) do |par|
|
37
|
+
par['id'].to_i == 2
|
38
|
+
end
|
39
|
+
|
40
|
+
run_cmd(%w(host-collection update --name hc1 --organization org1))
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'allows organization label' do
|
44
|
+
api_expects(:organizations, :index) { |par| par[:search] == "label = \"org1\"" }
|
45
|
+
.returns(index_response([{'id' => 1}]))
|
46
|
+
|
47
|
+
api_expects(:host_collections, :index) { |par| par['organization_id'].to_i == 1 }
|
48
|
+
.returns(index_response([{'id' => 2}]))
|
49
|
+
|
50
|
+
api_expects(:host_collections, :update) do |par|
|
51
|
+
par['id'].to_i == 2
|
52
|
+
end
|
53
|
+
|
54
|
+
run_cmd(%w(host-collection update --name hc1 --organization-label org1))
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,112 @@
|
|
1
|
+
require_relative '../test_helper'
|
2
|
+
require 'hammer_cli_foreman/hostgroup'
|
3
|
+
|
4
|
+
module HammerCLIForeman
|
5
|
+
describe Hostgroup do
|
6
|
+
# These tests are only for the extensions Katello adds to the hostgroup command
|
7
|
+
# See hammer-cli-foreman for the core hostgroup tests
|
8
|
+
describe CreateCommand do
|
9
|
+
it 'allows content source id' do
|
10
|
+
api_expects(:hostgroups, :create) do |p|
|
11
|
+
p['hostgroup']['name'] == 'hg1' && p['hostgroup']['content_source_id'] == 1
|
12
|
+
end
|
13
|
+
run_cmd(%w(hostgroup create --name hg1 --content-source-id 1))
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'allows content source name' do
|
17
|
+
content_source_name = "life_of_cs"
|
18
|
+
content_source_id = 111
|
19
|
+
hg_name = "mercury"
|
20
|
+
|
21
|
+
api_expects(:smart_proxies, :index).
|
22
|
+
with_params(:search => "name = \"#{content_source_name}\"").
|
23
|
+
returns(index_response([{'id' => content_source_id}]))
|
24
|
+
|
25
|
+
api_expects(:hostgroups, :create).
|
26
|
+
with_params('hostgroup' => {'name' => hg_name,
|
27
|
+
'content_source_id' => content_source_id
|
28
|
+
})
|
29
|
+
|
30
|
+
cmd = "hostgroup create --name #{hg_name} --content-source #{content_source_name}"
|
31
|
+
run_cmd(cmd.split)
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'allows content view id' do
|
35
|
+
api_expects(:hostgroups, :create) do |p|
|
36
|
+
p['hostgroup']['name'] == 'hg1' && p['hostgroup']['content_view_id'] == 1
|
37
|
+
end
|
38
|
+
run_cmd(%w(hostgroup create --name hg1 --content-view-id 1))
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'allows content view name' do
|
42
|
+
ex = api_expects(:content_views, :index) do |p|
|
43
|
+
p[:search] = "name = \"cv1\"" && p['organization_id'] == '1'
|
44
|
+
end
|
45
|
+
ex.returns(index_response([{'id' => 1}]))
|
46
|
+
api_expects(:hostgroups, :create) do |p|
|
47
|
+
p['hostgroup']['content_view_id'] == 1 && p['hostgroup']['name'] == 'hg1'
|
48
|
+
end
|
49
|
+
run_cmd(%w(hostgroup create --name hg1 --content-view cv1 --query-organization-id 1))
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'requires organization options to resolve content view name' do
|
53
|
+
api_expects_no_call
|
54
|
+
result = run_cmd(%w(hostgroup create --name hg1 --content-view cv1))
|
55
|
+
assert_match(/--query-organization/, result.err)
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'allows lifecycle environment id' do
|
59
|
+
api_expects(:hostgroups, :create) do |p|
|
60
|
+
p['hostgroup']['name'] == 'hg1' && p['hostgroup']['lifecycle_environment_id'] == 1 &&
|
61
|
+
p['hostgroup']['organization_ids'] == %w(1 2)
|
62
|
+
end
|
63
|
+
run_cmd(%w(hostgroup create --name hg1 --lifecycle-environment-id 1 --organization-ids 1,2))
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'allows lifecycle environment name' do
|
67
|
+
ex = api_expects(:lifecycle_environments, :index) do |p|
|
68
|
+
p['name'] == 'le1' && p['organization_id'] == '1'
|
69
|
+
end
|
70
|
+
ex.returns(index_response([{'id' => 1}]))
|
71
|
+
api_expects(:hostgroups, :create) do |p|
|
72
|
+
p['hostgroup']['name'] == 'hg1' && p['hostgroup']['lifecycle_environment_id'] == 1
|
73
|
+
end
|
74
|
+
run_cmd(%w(hostgroup create --name hg1 --lifecycle-environment le1
|
75
|
+
--query-organization-id 1 --organization-ids 1,2))
|
76
|
+
end
|
77
|
+
|
78
|
+
it 'requires organization options to resolve lifecycle environment name' do
|
79
|
+
api_expects_no_call
|
80
|
+
result = run_cmd(%w(hostgroup create --name hg1 --lifecycle-environment le1))
|
81
|
+
assert_match(/--query-organization/, result.err)
|
82
|
+
end
|
83
|
+
|
84
|
+
it 'allows kickstart repository name' do
|
85
|
+
env_id = 100
|
86
|
+
cv_id = 200
|
87
|
+
repo_name = "life_of_kickstart"
|
88
|
+
repo_id = 111
|
89
|
+
hg_name = "mercury"
|
90
|
+
|
91
|
+
api_expects(:repositories, :index).
|
92
|
+
with_params('name' => repo_name,
|
93
|
+
'environment_id' => env_id,
|
94
|
+
'content_view_id' => cv_id).
|
95
|
+
returns(index_response([{'id' => repo_id}]))
|
96
|
+
|
97
|
+
expected_params = {'hostgroup' => {
|
98
|
+
'name' => hg_name,
|
99
|
+
'lifecycle_environment_id' => env_id,
|
100
|
+
'content_view_id' => cv_id,
|
101
|
+
'kickstart_repository_id' => repo_id
|
102
|
+
}
|
103
|
+
}
|
104
|
+
api_expects(:hostgroups, :create).with_params(expected_params)
|
105
|
+
|
106
|
+
cmd = "hostgroup create --name #{hg_name} --lifecycle-environment-id #{env_id}"\
|
107
|
+
" --content-view-id #{cv_id} --kickstart-repository #{repo_name}"
|
108
|
+
run_cmd(cmd.split)
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
{
|
2
|
+
"content_source_id":1,
|
3
|
+
"content_source_name":"foreman.example.com",
|
4
|
+
"content_view_id":1,
|
5
|
+
"content_view_name":"Default Organization View",
|
6
|
+
"lifecycle_environment_id":1,
|
7
|
+
"lifecycle_environment_name":"Library",
|
8
|
+
"kickstart_repository_id":10000,
|
9
|
+
"kickstart_repository_name":"Rhel 7",
|
10
|
+
"subnet_id":null,
|
11
|
+
"subnet_name":null,
|
12
|
+
"operatingsystem_id":null,
|
13
|
+
"operatingsystem_name":null,
|
14
|
+
"domain_id":null,
|
15
|
+
"domain_name":null,
|
16
|
+
"environment_id":1,
|
17
|
+
"environment_name":"Production Env",
|
18
|
+
"compute_profile_id":null,
|
19
|
+
"compute_profile_name":null,
|
20
|
+
"ancestry":null,
|
21
|
+
"parent_id":null,
|
22
|
+
"parent_name":null,
|
23
|
+
"puppet_proxy_id":null,
|
24
|
+
"puppet_ca_proxy_id":null,
|
25
|
+
"ptable_id":null,
|
26
|
+
"ptable_name":null,
|
27
|
+
"medium_id":null,
|
28
|
+
"medium_name":null,
|
29
|
+
"architecture_id":null,
|
30
|
+
"architecture_name":null,
|
31
|
+
"realm_id":null,
|
32
|
+
"realm_name":null,
|
33
|
+
"created_at":"2016-08-09 04:18:32 UTC",
|
34
|
+
"updated_at":"2016-08-09 04:18:32 UTC",
|
35
|
+
"id":1,
|
36
|
+
"parameters":[],
|
37
|
+
"template_combinations":[],
|
38
|
+
"puppetclasses":[],
|
39
|
+
"config_groups":[],
|
40
|
+
"all_puppetclasses":[],
|
41
|
+
"locations":[],
|
42
|
+
"organizations":[
|
43
|
+
{
|
44
|
+
"id":1,
|
45
|
+
"name":"Redhat",
|
46
|
+
"title":"Redhat",
|
47
|
+
"description":null
|
48
|
+
}
|
49
|
+
]
|
50
|
+
}
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require_relative '../test_helper'
|
2
|
+
require 'hammer_cli_foreman/hostgroup'
|
3
|
+
|
4
|
+
module HammerCLIForeman
|
5
|
+
describe Hostgroup do
|
6
|
+
describe InfoCommand do
|
7
|
+
before do
|
8
|
+
@cmd = %w(hostgroup info)
|
9
|
+
end
|
10
|
+
|
11
|
+
let(:hostgroup_id) { 1 }
|
12
|
+
|
13
|
+
it "Shows information about a hostgroup" do
|
14
|
+
params = ["--id=#{hostgroup_id}"]
|
15
|
+
|
16
|
+
ex = api_expects(:hostgroups, :show, "Get info") do |par|
|
17
|
+
par["id"] == hostgroup_id.to_s
|
18
|
+
end
|
19
|
+
json_file = File.join(File.dirname(__FILE__), 'data', 'hostgroup.json')
|
20
|
+
ex.returns(JSON.parse(File.read(json_file)))
|
21
|
+
|
22
|
+
result = run_cmd(@cmd + params)
|
23
|
+
# rubocop:disable Style/WordArray
|
24
|
+
expected_fields = [['Name', 'Library'],
|
25
|
+
['Name', 'Default Organization View'],
|
26
|
+
['Name', 'foreman.example.com'],
|
27
|
+
['Name', 'Rhel 7']]
|
28
|
+
expected_results = expected_fields.map { |field| success_result(FieldMatcher.new(*field)) }
|
29
|
+
expected_results.each { |expected| assert_cmd(expected, result) }
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|