hammer_cli_katello 0.0.26 → 0.1.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/activation_key.rb +23 -43
- data/lib/hammer_cli_katello/associating_commands.rb +3 -5
- data/lib/hammer_cli_katello/capsule.rb +1 -3
- data/lib/hammer_cli_katello/commands.rb +1 -7
- data/lib/hammer_cli_katello/content_view.rb +6 -3
- data/lib/hammer_cli_katello/content_view_name_resolvable.rb +21 -0
- data/lib/hammer_cli_katello/content_view_puppet_module.rb +11 -7
- data/lib/hammer_cli_katello/content_view_version.rb +30 -29
- data/lib/hammer_cli_katello/erratum.rb +0 -1
- data/lib/hammer_cli_katello/exception_handler.rb +0 -2
- data/lib/hammer_cli_katello/filter.rb +11 -3
- data/lib/hammer_cli_katello/filter_rule.rb +8 -2
- data/lib/hammer_cli_katello/foreman_search_options_creators.rb +71 -0
- data/lib/hammer_cli_katello/gpg_key.rb +0 -5
- data/lib/hammer_cli_katello/host.rb +1 -0
- data/lib/hammer_cli_katello/host_collection.rb +48 -16
- data/lib/hammer_cli_katello/host_errata.rb +0 -1
- data/lib/hammer_cli_katello/host_extensions.rb +56 -0
- data/lib/hammer_cli_katello/host_package.rb +0 -3
- data/lib/hammer_cli_katello/host_package_group.rb +0 -3
- data/lib/hammer_cli_katello/host_subscription.rb +67 -1
- data/lib/hammer_cli_katello/hostgroup.rb +2 -0
- data/lib/hammer_cli_katello/hostgroup_extensions.rb +48 -0
- data/lib/hammer_cli_katello/i18n.rb +0 -3
- data/lib/hammer_cli_katello/id_resolver.rb +25 -16
- data/lib/hammer_cli_katello/katello_environment_name_resolvable.rb +4 -3
- data/lib/hammer_cli_katello/lifecycle_environment.rb +0 -3
- data/lib/hammer_cli_katello/lifecycle_environment_name_resolvable.rb +4 -3
- data/lib/hammer_cli_katello/organization.rb +0 -3
- data/lib/hammer_cli_katello/organization_options.rb +12 -0
- data/lib/hammer_cli_katello/ostree_branch.rb +0 -1
- data/lib/hammer_cli_katello/output/fields.rb +0 -2
- data/lib/hammer_cli_katello/output/formatters.rb +0 -4
- data/lib/hammer_cli_katello/package.rb +0 -1
- data/lib/hammer_cli_katello/package_group.rb +0 -1
- data/lib/hammer_cli_katello/ping.rb +0 -6
- data/lib/hammer_cli_katello/product.rb +1 -7
- data/lib/hammer_cli_katello/puppet_module.rb +0 -1
- data/lib/hammer_cli_katello/repository.rb +36 -35
- data/lib/hammer_cli_katello/repository_scoped_to_product.rb +0 -4
- data/lib/hammer_cli_katello/repository_set.rb +0 -3
- data/lib/hammer_cli_katello/search_options_creators.rb +40 -18
- data/lib/hammer_cli_katello/subscription.rb +20 -13
- data/lib/hammer_cli_katello/sync_plan.rb +4 -8
- data/lib/hammer_cli_katello/version.rb +1 -1
- data/lib/hammer_cli_katello.rb +21 -26
- data/test/data/3.0/foreman_api.json +1 -1
- data/test/data/3.2/foreman_api.json +1 -0
- data/test/data/Readme.md +5 -0
- data/test/functional/activaton_key/add_host_collection_test.rb +62 -0
- data/test/functional/activaton_key/create_test.rb +33 -0
- data/test/functional/activaton_key/list_test.rb +15 -16
- data/test/functional/activaton_key/product_content_test.rb +23 -0
- data/test/functional/activaton_key/remove_host_collection_test.rb +62 -0
- data/test/functional/activaton_key/subscriptions_test.rb +57 -0
- data/test/functional/activaton_key/update_test.rb +26 -0
- data/test/functional/capsule/content/cancel_synchronization_test.rb +1 -1
- data/test/functional/capsule/content/capsule_content_helpers.rb +0 -2
- data/test/functional/content_view/add_content_view_version_test.rb +34 -0
- data/test/functional/content_view/add_repository_test.rb +20 -0
- data/test/functional/content_view/content_view_helpers.rb +0 -2
- data/test/functional/content_view/create_test.rb +3 -3
- data/test/functional/content_view/filter/create_test.rb +63 -0
- data/test/functional/content_view/list_test.rb +23 -20
- data/test/functional/content_view/publish_test.rb +23 -0
- data/test/functional/content_view/puppet_module/add_test.rb +23 -0
- data/test/functional/content_view/remove_content_view_version_test.rb +34 -0
- data/test/functional/content_view/version/incremental_update_test.rb +4 -4
- data/test/functional/content_view/version/list_test.rb +44 -0
- data/test/functional/content_view/version/promote_test.rb +35 -0
- data/test/functional/filter_rule/create_test.rb +20 -0
- data/test/functional/host/errata/apply_test.rb +5 -4
- data/test/functional/host/extensions/data/host.json +310 -0
- data/test/functional/host/extensions/data/host_list.json +115 -0
- data/test/functional/host/extensions/info_test.rb +27 -0
- data/test/functional/host/extensions/list_test.rb +21 -0
- data/test/functional/host/host_helpers.rb +0 -2
- 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/register_test.rb +2 -2
- data/test/functional/host/subscription/remove_test.rb +52 -0
- data/test/functional/host_collection/add_host_test.rb +57 -0
- data/test/functional/host_collection/copy_test.rb +64 -0
- data/test/functional/host_collection/create_test.rb +43 -0
- data/test/functional/host_collection/delete_test.rb +57 -0
- data/test/functional/host_collection/hosts_test.rb +40 -0
- data/test/functional/host_collection/info_test.rb +57 -0
- data/test/functional/host_collection/list_test.rb +42 -0
- data/test/functional/host_collection/remove_host_test.rb +57 -0
- data/test/functional/host_collection/update_test.rb +57 -0
- data/test/functional/hostgroup/create_test.rb +55 -0
- data/test/functional/hostgroup/data/hostgroup.json +48 -0
- data/test/functional/hostgroup/info_test.rb +30 -0
- data/test/functional/hostgroup/update_test.rb +55 -0
- data/test/functional/lifecycle_environment/lifecycle_environment_helpers.rb +0 -2
- data/test/functional/organization/organization_helpers.rb +0 -2
- 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 +14 -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_test.rb +46 -0
- data/test/functional/repository/info_test.rb +3 -3
- data/test/functional/repository/list_test.rb +14 -13
- data/test/functional/repository/remove_content_test.rb +18 -0
- data/test/functional/repository/repository_helpers.rb +9 -3
- data/test/functional/repository/synchronize_test.rb +3 -3
- data/test/functional/repository/upload_test.rb +17 -5
- data/test/functional/subscription/list_test.rb +92 -0
- data/test/functional/sync_plan/sync_plan_helpers.rb +8 -0
- data/test/test_helper.rb +3 -3
- data/test/unit/id_resolver_test.rb +17 -2
- data/test/unit/search_options_creators_test.rb +49 -12
- metadata +105 -7
- data/lib/hammer_cli_katello/content_host.rb +0 -111
@@ -0,0 +1,54 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '../../test_helper')
|
2
|
+
require File.join(File.dirname(__FILE__), '../host_helpers')
|
3
|
+
|
4
|
+
describe 'host subscription attach' do
|
5
|
+
include HostHelpers
|
6
|
+
|
7
|
+
before do
|
8
|
+
@cmd = %w(host subscription attach)
|
9
|
+
end
|
10
|
+
it "attach a subscription to a host No Quantity" do
|
11
|
+
params = ['--host-id=3', '--subscription-id=100']
|
12
|
+
ex = api_expects(:host_subscriptions, :add_subscriptions, "attach host") do |par|
|
13
|
+
par['host_id'] == 3 && par[:subscriptions][0][:id].to_s == '100' &&
|
14
|
+
par[:subscriptions][0][:quantity].to_s == '1'
|
15
|
+
end
|
16
|
+
ex.returns({})
|
17
|
+
|
18
|
+
expected_result = success_result(
|
19
|
+
'Subscription attached to the host successfully
|
20
|
+
'
|
21
|
+
)
|
22
|
+
|
23
|
+
result = run_cmd(@cmd + params)
|
24
|
+
assert_cmd(expected_result, result)
|
25
|
+
end
|
26
|
+
|
27
|
+
it "attach a subscription to a host with Quantity" do
|
28
|
+
params = ['--host-id=3', '--subscription-id=100', "--quantity=10"]
|
29
|
+
ex = api_expects(:host_subscriptions, :add_subscriptions, "attach host") do |par|
|
30
|
+
par['host_id'] == 3 && par[:subscriptions][0][:id].to_s == '100' &&
|
31
|
+
par[:subscriptions][0][:quantity].to_s == '10'
|
32
|
+
end
|
33
|
+
ex.returns({})
|
34
|
+
|
35
|
+
expected_result = success_result(
|
36
|
+
'Subscription attached to the host successfully
|
37
|
+
'
|
38
|
+
)
|
39
|
+
|
40
|
+
result = run_cmd(@cmd + params)
|
41
|
+
assert_cmd(expected_result, result)
|
42
|
+
end
|
43
|
+
|
44
|
+
it "resolves id from name" do
|
45
|
+
params = ['--host=boo', '--subscription-id=100']
|
46
|
+
api_expects(:host_subscriptions, :add_subscriptions, "attach host") do |par|
|
47
|
+
par['host_id'].to_s == "3" && par[:subscriptions][0][:id].to_s == '100' &&
|
48
|
+
par[:subscriptions][0][:quantity].to_s == '1'
|
49
|
+
end
|
50
|
+
expect_host_search('boo', '3')
|
51
|
+
|
52
|
+
run_cmd(@cmd + params)
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '../../test_helper')
|
2
|
+
require File.join(File.dirname(__FILE__), '../host_helpers')
|
3
|
+
|
4
|
+
describe 'host subscription auto-attach' do
|
5
|
+
include HostHelpers
|
6
|
+
|
7
|
+
before do
|
8
|
+
@cmd = %w(host subscription auto-attach)
|
9
|
+
end
|
10
|
+
it "auto-attach to a host" do
|
11
|
+
params = ['--host-id=3']
|
12
|
+
ex = api_expects(:host_subscriptions, :auto_attach, "auto-attach subs host") do |par|
|
13
|
+
par['host_id'] == 3
|
14
|
+
end
|
15
|
+
ex.returns({})
|
16
|
+
|
17
|
+
expected_result = success_result(
|
18
|
+
'Auto attached subscriptions to the host successfully
|
19
|
+
'
|
20
|
+
)
|
21
|
+
|
22
|
+
result = run_cmd(@cmd + params)
|
23
|
+
assert_cmd(expected_result, result)
|
24
|
+
end
|
25
|
+
|
26
|
+
it "resolves id from name" do
|
27
|
+
params = ['--host=boo']
|
28
|
+
api_expects(:host_subscriptions, :auto_attach, "auto-attach subs host") do |par|
|
29
|
+
par['host_id'].to_s == "3"
|
30
|
+
end
|
31
|
+
expect_host_search('boo', '3')
|
32
|
+
|
33
|
+
run_cmd(@cmd + params)
|
34
|
+
end
|
35
|
+
end
|
@@ -17,7 +17,7 @@ describe 'host subscription register' do
|
|
17
17
|
params = ['--name=trump.wall.com', '--content-view-id=1', '--lifecycle-environment-id=2']
|
18
18
|
ex = api_expects(:host_subscriptions, :create, 'Host subscription register') do |par|
|
19
19
|
par['name'] == 'trump.wall.com' && par['content_view_id'] == 1 &&
|
20
|
-
|
20
|
+
par['lifecycle_environment_id'] == 2
|
21
21
|
end
|
22
22
|
ex.returns({})
|
23
23
|
|
@@ -36,7 +36,7 @@ describe 'host subscription register' do
|
|
36
36
|
|
37
37
|
api_expects(:host_subscriptions, :create, 'Host subscription register') do |par|
|
38
38
|
par['name'] == 'trump.wall.com' && par['content_view_id'] == 1 &&
|
39
|
-
|
39
|
+
par['lifecycle_environment_id'] == 2
|
40
40
|
end
|
41
41
|
|
42
42
|
expect_organization_search('trumporg', 3)
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '../../test_helper')
|
2
|
+
require File.join(File.dirname(__FILE__), '../host_helpers')
|
3
|
+
|
4
|
+
describe 'host subscription remove' do
|
5
|
+
include HostHelpers
|
6
|
+
|
7
|
+
before do
|
8
|
+
@cmd = %w(host subscription remove)
|
9
|
+
end
|
10
|
+
it "remove a subscription to a host No Quantity" do
|
11
|
+
params = ['--host-id=3', '--subscription-id=100']
|
12
|
+
ex = api_expects(:host_subscriptions, :remove_subscriptions, "remove subs host") do |par|
|
13
|
+
par['host_id'] == 3 && par[:subscriptions][0][:id].to_s == '100'
|
14
|
+
end
|
15
|
+
ex.returns({})
|
16
|
+
|
17
|
+
expected_result = success_result(
|
18
|
+
'Subscription removed from the host successfully
|
19
|
+
'
|
20
|
+
)
|
21
|
+
|
22
|
+
result = run_cmd(@cmd + params)
|
23
|
+
assert_cmd(expected_result, result)
|
24
|
+
end
|
25
|
+
|
26
|
+
it "remove a subscription to a host with Quantity" do
|
27
|
+
params = ['--host-id=3', '--subscription-id=100', "--quantity=10"]
|
28
|
+
ex = api_expects(:host_subscriptions, :remove_subscriptions, "remove subs host") do |par|
|
29
|
+
par['host_id'] == 3 && par[:subscriptions][0][:id].to_s == '100' &&
|
30
|
+
par[:subscriptions][0][:quantity].to_s == '10'
|
31
|
+
end
|
32
|
+
ex.returns({})
|
33
|
+
|
34
|
+
expected_result = success_result(
|
35
|
+
'Subscription removed from the host successfully
|
36
|
+
'
|
37
|
+
)
|
38
|
+
|
39
|
+
result = run_cmd(@cmd + params)
|
40
|
+
assert_cmd(expected_result, result)
|
41
|
+
end
|
42
|
+
|
43
|
+
it "resolves id from name" do
|
44
|
+
params = ['--host=boo', '--subscription-id=100']
|
45
|
+
api_expects(:host_subscriptions, :remove_subscriptions, "remove subs host") do |par|
|
46
|
+
par['host_id'].to_s == "3" && par[:subscriptions][0][:id].to_s == '100'
|
47
|
+
end
|
48
|
+
expect_host_search('boo', '3')
|
49
|
+
|
50
|
+
run_cmd(@cmd + params)
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require_relative '../test_helper'
|
2
|
+
require 'hammer_cli_katello/host_collection'
|
3
|
+
|
4
|
+
module HammerCLIKatello
|
5
|
+
describe HostCollection::AddHostCommand do
|
6
|
+
it 'does not require organization options if id is specified' do
|
7
|
+
api_expects(:host_collections, :add_hosts)
|
8
|
+
run_cmd(%w(host-collection add-host --id 1))
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'requires organization options if name is specified' do
|
12
|
+
result = run_cmd(%w(host-collection add-host --name hc1))
|
13
|
+
expected_error = "Could not find organization"
|
14
|
+
assert_equal(result.exit_code, HammerCLI::EX_SOFTWARE)
|
15
|
+
assert_equal(result.err[/#{expected_error}/], 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, :add_hosts) do |par|
|
23
|
+
par['id'].to_i == 2
|
24
|
+
end
|
25
|
+
|
26
|
+
run_cmd(%w(host-collection add-host --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, :add_hosts) do |par|
|
37
|
+
par['id'].to_i == 2
|
38
|
+
end
|
39
|
+
|
40
|
+
run_cmd(%w(host-collection add-host --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, :add_hosts) do |par|
|
51
|
+
par['id'].to_i == 2
|
52
|
+
end
|
53
|
+
|
54
|
+
run_cmd(%w(host-collection add-host --name hc1 --organization-label org1))
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require_relative '../test_helper'
|
2
|
+
require 'hammer_cli_katello/host_collection'
|
3
|
+
|
4
|
+
module HammerCLIKatello
|
5
|
+
describe HostCollection::CopyCommand do
|
6
|
+
it 'requires a new name' do
|
7
|
+
result = run_cmd(%w(host-collection copy --id 1))
|
8
|
+
expected_error = "option '--new-name' is required"
|
9
|
+
assert_equal(result.exit_code, HammerCLI::EX_USAGE)
|
10
|
+
assert_equal(result.err[/#{expected_error}/], expected_error)
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'does not require organization options if id is specified' do
|
14
|
+
api_expects(:host_collections, :copy)
|
15
|
+
run_cmd(%w(host-collection copy --id 1 --new-name foo))
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'requires organization options if name is specified' do
|
19
|
+
result = run_cmd(%w(host-collection copy --name hc1 --new-name foo))
|
20
|
+
expected_error = "Could not find organization"
|
21
|
+
assert_equal(result.exit_code, HammerCLI::EX_SOFTWARE)
|
22
|
+
assert_equal(result.err[/#{expected_error}/], expected_error)
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'allows organization id' do
|
26
|
+
api_expects(:host_collections, :index) { |par| par['organization_id'].to_i == 1 }
|
27
|
+
.returns(index_response([{'id' => 2}]))
|
28
|
+
|
29
|
+
api_expects(:host_collections, :copy) do |par|
|
30
|
+
par['id'].to_i == 2
|
31
|
+
end
|
32
|
+
|
33
|
+
run_cmd(%w(host-collection copy --name hc1 --organization-id 1 --new-name foo))
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'allows organization name' do
|
37
|
+
api_expects(:organizations, :index) { |par| par[:search] == "name = \"org1\"" }
|
38
|
+
.returns(index_response([{'id' => 1}]))
|
39
|
+
|
40
|
+
api_expects(:host_collections, :index) { |par| par['organization_id'].to_i == 1 }
|
41
|
+
.returns(index_response([{'id' => 2}]))
|
42
|
+
|
43
|
+
api_expects(:host_collections, :copy) do |par|
|
44
|
+
par['id'].to_i == 2
|
45
|
+
end
|
46
|
+
|
47
|
+
run_cmd(%w(host-collection copy --name hc1 --organization org1 --new-name foo))
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'allows organization label' do
|
51
|
+
api_expects(:organizations, :index) { |par| par[:search] == "label = \"org1\"" }
|
52
|
+
.returns(index_response([{'id' => 1}]))
|
53
|
+
|
54
|
+
api_expects(:host_collections, :index) { |par| par['organization_id'].to_i == 1 }
|
55
|
+
.returns(index_response([{'id' => 2}]))
|
56
|
+
|
57
|
+
api_expects(:host_collections, :copy) do |par|
|
58
|
+
par['id'].to_i == 2
|
59
|
+
end
|
60
|
+
|
61
|
+
run_cmd(%w(host-collection copy --name hc1 --organization-label org1 --new-name foo))
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,43 @@
|
|
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 organization label' do
|
33
|
+
api_expects(:organizations, :index) { |par| par[:search] == "label = \"org1\"" }
|
34
|
+
.returns(index_response([{'id' => 1}]))
|
35
|
+
|
36
|
+
api_expects(:host_collections, :create) do |par|
|
37
|
+
par['organization_id'].to_i == 1
|
38
|
+
end
|
39
|
+
|
40
|
+
run_cmd(%w(host-collection create --name hc1 --organization-label org1))
|
41
|
+
end
|
42
|
+
end
|
43
|
+
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 = "Could not find organization"
|
14
|
+
assert_equal(result.exit_code, HammerCLI::EX_SOFTWARE)
|
15
|
+
assert_equal(result.err[/#{expected_error}/], 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,40 @@
|
|
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 = "Error: Could not find organization, please set one of options " \
|
28
|
+
"--organization, --organization-label, --organization-id."
|
29
|
+
assert_equal(HammerCLI::EX_SOFTWARE, result.exit_code)
|
30
|
+
assert_equal(expected_error, result.err[/#{expected_error}/])
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'requires host collection name or id' do
|
34
|
+
result = run_cmd(%w(host-collection hosts))
|
35
|
+
expected_error = "Error: At least one of options --id, --name is required"
|
36
|
+
assert_equal(HammerCLI::EX_USAGE, result.exit_code)
|
37
|
+
assert_equal(expected_error, result.err[/#{expected_error}/])
|
38
|
+
end
|
39
|
+
end
|
40
|
+
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 = "Could not find organization"
|
14
|
+
assert_equal(result.exit_code, HammerCLI::EX_SOFTWARE)
|
15
|
+
assert_equal(result.err[/#{expected_error}/], 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,42 @@
|
|
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
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require_relative '../test_helper'
|
2
|
+
require 'hammer_cli_katello/host_collection'
|
3
|
+
|
4
|
+
module HammerCLIKatello
|
5
|
+
describe HostCollection::RemoveHostCommand do
|
6
|
+
it 'does not require organization options if id is specified' do
|
7
|
+
api_expects(:host_collections, :remove_hosts)
|
8
|
+
run_cmd(%w(host-collection remove-host --id 1))
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'requires organization options if name is specified' do
|
12
|
+
result = run_cmd(%w(host-collection remove-host --name hc1))
|
13
|
+
expected_error = "Could not find organization"
|
14
|
+
assert_equal(result.exit_code, HammerCLI::EX_SOFTWARE)
|
15
|
+
assert_equal(result.err[/#{expected_error}/], 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, :remove_hosts) do |par|
|
23
|
+
par['id'].to_i == 2
|
24
|
+
end
|
25
|
+
|
26
|
+
run_cmd(%w(host-collection remove-host --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, :remove_hosts) do |par|
|
37
|
+
par['id'].to_i == 2
|
38
|
+
end
|
39
|
+
|
40
|
+
run_cmd(%w(host-collection remove-host --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, :remove_hosts) do |par|
|
51
|
+
par['id'].to_i == 2
|
52
|
+
end
|
53
|
+
|
54
|
+
run_cmd(%w(host-collection remove-host --name hc1 --organization-label org1))
|
55
|
+
end
|
56
|
+
end
|
57
|
+
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 = "Could not find organization"
|
14
|
+
assert_equal(result.exit_code, HammerCLI::EX_SOFTWARE)
|
15
|
+
assert_equal(result.err[/#{expected_error}/], 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
|