hammer_cli_katello 1.5.0 → 1.6.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/acs.rb +82 -0
- data/lib/hammer_cli_katello/activation_key.rb +8 -2
- data/lib/hammer_cli_katello/content_export.rb +39 -0
- data/lib/hammer_cli_katello/content_export_helper.rb +64 -6
- data/lib/hammer_cli_katello/host_subscription.rb +32 -0
- data/lib/hammer_cli_katello/organization.rb +4 -0
- data/lib/hammer_cli_katello/repository.rb +1 -1
- data/lib/hammer_cli_katello/simple_content_access.rb +10 -0
- data/lib/hammer_cli_katello/version.rb +1 -1
- data/lib/hammer_cli_katello.rb +5 -0
- data/test/data/2.5/foreman_api.json +1 -0
- data/test/data/3.0/foreman_api.json +1 -0
- data/test/data/3.10/foreman_api.json +1 -0
- data/test/data/3.11/foreman_api.json +1 -0
- data/test/data/3.12/foreman_api.json +1 -0
- data/test/data/3.13/foreman_api.json +1 -0
- data/test/data/3.14/foreman_api.json +1 -0
- data/test/data/3.15/foreman_api.json +1 -0
- data/test/data/3.16/foreman_api.json +1 -0
- data/test/data/3.17/foreman_api.json +1 -0
- data/test/data/3.18/foreman_api.json +1 -0
- data/test/data/3.19/foreman_api.json +1 -0
- data/test/data/3.2/foreman_api.json +1 -0
- data/test/data/3.4/foreman_api.json +1 -0
- data/test/data/3.5/foreman_api.json +1 -0
- data/test/data/3.6/foreman_api.json +1 -0
- data/test/data/3.7/foreman_api.json +1 -0
- data/test/data/3.8/foreman_api.json +1 -0
- data/test/data/3.9/foreman_api.json +1 -0
- data/test/data/4.0/foreman_api.json +1 -0
- data/test/data/4.1/foreman_api.json +1 -0
- data/test/data/4.3/foreman_api.json +1 -0
- data/test/data/4.4/foreman_api.json +1 -0
- data/test/data/4.5/foreman_api.json +1 -0
- data/test/data/4.6/foreman_api.json +1 -0
- data/test/data/Readme.md +5 -0
- data/test/functional/acs/create_test.rb +27 -0
- data/test/functional/acs/delete_test.rb +13 -0
- data/test/functional/acs/info_test.rb +94 -0
- data/test/functional/acs/list_test.rb +62 -0
- data/test/functional/acs/update_test.rb +23 -0
- data/test/functional/activation_key/add_host_collection_test.rb +62 -0
- data/test/functional/activation_key/content_override_test.rb +92 -0
- data/test/functional/activation_key/create_test.rb +33 -0
- data/test/functional/activation_key/data/activation_key.json +17 -0
- data/test/functional/activation_key/info_test.rb +29 -0
- data/test/functional/activation_key/list_test.rb +68 -0
- data/test/functional/activation_key/product_content_test.rb +23 -0
- data/test/functional/activation_key/remove_host_collection_test.rb +62 -0
- data/test/functional/activation_key/subscriptions_test.rb +74 -0
- data/test/functional/activation_key/update_test.rb +26 -0
- data/test/functional/apipie_helper_test.rb +31 -0
- data/test/functional/capsule/capsule_helpers.rb +13 -0
- data/test/functional/capsule/content/add_lifecycle_environment_test.rb +40 -0
- data/test/functional/capsule/content/cancel_synchronization_test.rb +42 -0
- data/test/functional/capsule/content/capsule_content_helpers.rb +24 -0
- data/test/functional/capsule/content/data/library_env.json +47 -0
- data/test/functional/capsule/content/data/sync_status.json +6 -0
- data/test/functional/capsule/content/data/sync_tasks.json +62 -0
- data/test/functional/capsule/content/info_test.rb +61 -0
- data/test/functional/capsule/content/lifecycle_environments_test.rb +19 -0
- data/test/functional/capsule/content/remove_lifecycle_environment_test.rb +40 -0
- data/test/functional/capsule/content/synchronization_status_test.rb +107 -0
- data/test/functional/capsule/info_test.rb +25 -0
- data/test/functional/capsule/list_test.rb +24 -0
- data/test/functional/content_credentials/create_test.rb +32 -0
- data/test/functional/content_credentials/data/test_cert.json +43 -0
- data/test/functional/content_credentials/info_test.rb +50 -0
- data/test/functional/content_credentials/list_test.rb +66 -0
- data/test/functional/content_export/complete/library_test.rb +155 -0
- data/test/functional/content_export/complete/repository_test.rb +226 -0
- data/test/functional/content_export/complete/version_test.rb +297 -0
- data/test/functional/content_export/content_export_helpers.rb +33 -0
- data/test/functional/content_export/generate_listing_test.rb +62 -0
- data/test/functional/content_export/generate_metadata_test.rb +64 -0
- data/test/functional/content_export/incremental/library_test.rb +172 -0
- data/test/functional/content_export/incremental/repository_test.rb +212 -0
- data/test/functional/content_export/incremental/version_test.rb +268 -0
- data/test/functional/content_export/list_test.rb +64 -0
- data/test/functional/content_import/library_test.rb +85 -0
- data/test/functional/content_import/list_test.rb +65 -0
- data/test/functional/content_import/metadata.json +1 -0
- data/test/functional/content_import/version_test.rb +85 -0
- data/test/functional/content_units/info_test.rb +29 -0
- data/test/functional/content_units/list_test.rb +106 -0
- data/test/functional/content_view/add_content_view_version_test.rb +88 -0
- data/test/functional/content_view/add_repository_test.rb +21 -0
- data/test/functional/content_view/component/add_test.rb +177 -0
- data/test/functional/content_view/component/list_test.rb +55 -0
- data/test/functional/content_view/component/remove_test.rb +107 -0
- data/test/functional/content_view/component/update_test.rb +134 -0
- data/test/functional/content_view/content_view_helpers.rb +20 -0
- data/test/functional/content_view/copy_test.rb +53 -0
- data/test/functional/content_view/create_test.rb +34 -0
- data/test/functional/content_view/delete_test.rb +62 -0
- data/test/functional/content_view/filter/create_test.rb +57 -0
- data/test/functional/content_view/filter/delete_test.rb +90 -0
- data/test/functional/content_view/filter/info_test.rb +89 -0
- data/test/functional/content_view/filter/list_test.rb +98 -0
- data/test/functional/content_view/filter/update_test.rb +91 -0
- data/test/functional/content_view/list_test.rb +68 -0
- data/test/functional/content_view/publish_test.rb +24 -0
- data/test/functional/content_view/purge_test.rb +97 -0
- data/test/functional/content_view/remove_content_view_version_test.rb +88 -0
- data/test/functional/content_view/remove_test.rb +79 -0
- data/test/functional/content_view/update_test.rb +53 -0
- data/test/functional/content_view/version/incremental_update_test.rb +108 -0
- data/test/functional/content_view/version/list_test.rb +44 -0
- data/test/functional/content_view/version/promote_test.rb +75 -0
- data/test/functional/content_view/version/republish_repositories_test.rb +34 -0
- data/test/functional/content_view/version/update_test.rb +48 -0
- data/test/functional/erratum/erratum_helpers.rb +91 -0
- data/test/functional/erratum/info_test.rb +29 -0
- data/test/functional/erratum/list_test.rb +108 -0
- data/test/functional/file/file_helpers.rb +13 -0
- data/test/functional/file/info_test.rb +162 -0
- data/test/functional/file/list_test.rb +112 -0
- data/test/functional/filter_rule/create_test.rb +99 -0
- data/test/functional/filter_rule/delete_test.rb +104 -0
- data/test/functional/filter_rule/filter_rule_helpers.rb +12 -0
- data/test/functional/filter_rule/info_test.rb +104 -0
- data/test/functional/filter_rule/list_test.rb +91 -0
- data/test/functional/filter_rule/update_test.rb +104 -0
- data/test/functional/host/errata/apply_test.rb +45 -0
- data/test/functional/host/errata/info_test.rb +27 -0
- data/test/functional/host/errata/list_test.rb +49 -0
- data/test/functional/host/errata/recalculate_test.rb +26 -0
- data/test/functional/host/extensions/create_test.rb +95 -0
- data/test/functional/host/extensions/data/host.json +320 -0
- data/test/functional/host/extensions/data/host_list.json +117 -0
- data/test/functional/host/extensions/info_test.rb +35 -0
- data/test/functional/host/extensions/list_test.rb +21 -0
- data/test/functional/host/extensions/update_test.rb +70 -0
- data/test/functional/host/host_helpers.rb +8 -0
- data/test/functional/host/subscription/attach_test.rb +54 -0
- data/test/functional/host/subscription/auto_attach_test.rb +35 -0
- data/test/functional/host/subscription/content_override_test.rb +96 -0
- data/test/functional/host/subscription/enabled_repositories_test.rb +39 -0
- data/test/functional/host/subscription/product_content_test.rb +27 -0
- data/test/functional/host/subscription/register_test.rb +53 -0
- data/test/functional/host/subscription/remove_test.rb +52 -0
- data/test/functional/host/subscription/unregister_test.rb +37 -0
- data/test/functional/host/traces/list_test.rb +37 -0
- data/test/functional/host/traces/resolve_test.rb +31 -0
- data/test/functional/host_collection/add_host_test.rb +90 -0
- data/test/functional/host_collection/content_api_expectations.rb +35 -0
- data/test/functional/host_collection/content_install_test.rb +62 -0
- data/test/functional/host_collection/content_remove_test.rb +37 -0
- data/test/functional/host_collection/content_update_test.rb +37 -0
- data/test/functional/host_collection/copy_test.rb +64 -0
- data/test/functional/host_collection/create_test.rb +54 -0
- data/test/functional/host_collection/delete_test.rb +57 -0
- data/test/functional/host_collection/hosts_test.rb +39 -0
- data/test/functional/host_collection/info_test.rb +57 -0
- data/test/functional/host_collection/list_test.rb +63 -0
- data/test/functional/host_collection/remove_host_test.rb +90 -0
- data/test/functional/host_collection/update_test.rb +57 -0
- data/test/functional/hostgroup/create_test.rb +112 -0
- data/test/functional/hostgroup/data/hostgroup.json +50 -0
- data/test/functional/hostgroup/info_test.rb +33 -0
- data/test/functional/hostgroup/update_test.rb +120 -0
- data/test/functional/lifecycle_environment/create_test.rb +14 -0
- data/test/functional/lifecycle_environment/lifecycle_environment_helpers.rb +18 -0
- data/test/functional/lifecycle_environment/list_test.rb +38 -0
- data/test/functional/lifecycle_environment/update_test.rb +14 -0
- data/test/functional/local_helper_test.rb +30 -0
- data/test/functional/module_stream/info_test.rb +58 -0
- data/test/functional/module_stream/list_test.rb +53 -0
- data/test/functional/organization/cdn_configuration_test.rb +45 -0
- data/test/functional/organization/delete_test.rb +26 -0
- data/test/functional/organization/info_test.rb +45 -0
- data/test/functional/organization/organization_helpers.rb +10 -0
- data/test/functional/package/list_test.rb +160 -0
- data/test/functional/package_group/list_test.rb +38 -0
- data/test/functional/ping_test.rb +61 -0
- data/test/functional/product/create_test.rb +54 -0
- data/test/functional/product/delete_test.rb +41 -0
- data/test/functional/product/info_test.rb +33 -0
- data/test/functional/product/list_test.rb +58 -0
- data/test/functional/product/product_helpers.rb +24 -0
- data/test/functional/product/remove_sync_plan_test.rb +35 -0
- data/test/functional/product/set_sync_plan_test.rb +49 -0
- data/test/functional/product/update_proxy.rb +48 -0
- data/test/functional/product/update_test.rb +46 -0
- data/test/functional/repository/create_test.rb +21 -0
- data/test/functional/repository/delete_test.rb +95 -0
- data/test/functional/repository/info_test.rb +156 -0
- data/test/functional/repository/list_test.rb +68 -0
- data/test/functional/repository/reclaim_space_test.rb +105 -0
- data/test/functional/repository/remove_content_test.rb +108 -0
- data/test/functional/repository/repository_helpers.rb +18 -0
- data/test/functional/repository/republish_test.rb +37 -0
- data/test/functional/repository/synchronize_test.rb +57 -0
- data/test/functional/repository/update_test.rb +150 -0
- data/test/functional/repository/upload_test.rb +368 -0
- data/test/functional/repository_set/available_repositories_test.rb +18 -0
- data/test/functional/repository_set/disable_test.rb +48 -0
- data/test/functional/repository_set/enable_test.rb +42 -0
- data/test/functional/repository_set/info_test.rb +17 -0
- data/test/functional/repository_set/list_test.rb +18 -0
- data/test/functional/repository_set/repository_set_helpers.rb +20 -0
- data/test/functional/search_helpers.rb +17 -0
- data/test/functional/simple_content_access/disable_test.rb +48 -0
- data/test/functional/simple_content_access/enable_test.rb +46 -0
- data/test/functional/simple_content_access/status_test.rb +29 -0
- data/test/functional/srpm/list_test.rb +92 -0
- data/test/functional/subscription/list_test.rb +86 -0
- data/test/functional/sync_plan/create_test.rb +60 -0
- data/test/functional/sync_plan/delete_test.rb +46 -0
- data/test/functional/sync_plan/info_test.rb +37 -0
- data/test/functional/sync_plan/list_test.rb +31 -0
- data/test/functional/sync_plan/sync_plan_helpers.rb +8 -0
- data/test/functional/sync_plan/update_test.rb +44 -0
- data/test/functional/test_helper.rb +24 -0
- data/test/task_helper.rb +7 -0
- data/test/test_helper.rb +38 -0
- data/test/unit/id_name_options_validator_test.rb +96 -0
- data/test/unit/id_resolver_test.rb +58 -0
- data/test/unit/messages_test.rb +7 -0
- data/test/unit/search_options_creators_test.rb +145 -0
- metadata +425 -4
@@ -0,0 +1,17 @@
|
|
1
|
+
module SearchHelpers
|
2
|
+
def expect_generic_search(resource, args)
|
3
|
+
ex = api_expects(resource, :index, "Find the #{resource}").with_params(args[:params])
|
4
|
+
ex.returns(index_response([args[:returns]]))
|
5
|
+
end
|
6
|
+
|
7
|
+
def expect_lenient_search(resource, params:, returns:)
|
8
|
+
ex = api_expects(resource, :index, "Find the #{resource}") do |p|
|
9
|
+
params.each do |key, expected|
|
10
|
+
actual = p[key] || p[key.to_sym] || p[key.to_s]
|
11
|
+
assert_equal expected.to_s, actual.to_s, "key: '#{key}', resource: #{resource}"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
returns = [returns] unless returns.is_a? Array
|
15
|
+
ex.returns(index_response(returns))
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '../../test_helper')
|
2
|
+
|
3
|
+
describe 'simple-content-access disable' do
|
4
|
+
before do
|
5
|
+
@cmd = %w(simple-content-access disable)
|
6
|
+
end
|
7
|
+
|
8
|
+
let(:organization_id) { 3 }
|
9
|
+
|
10
|
+
it "disables with required options" do
|
11
|
+
params = ["--organization-id=#{organization_id}"]
|
12
|
+
|
13
|
+
api_expects(:simple_content_access, :eligible).
|
14
|
+
with_params('organization_id' => organization_id).
|
15
|
+
returns("simple_content_access_eligible" => true)
|
16
|
+
|
17
|
+
api_expects(:simple_content_access, :disable)
|
18
|
+
.with_params('organization_id' => organization_id)
|
19
|
+
run_cmd(@cmd + params)
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'fails on missing required params' do
|
23
|
+
params = []
|
24
|
+
|
25
|
+
result = run_cmd(@cmd + params)
|
26
|
+
expected_error = "Could not disable Simple Content Access for this organization"
|
27
|
+
|
28
|
+
assert_equal(result.exit_code, HammerCLI::EX_SOFTWARE)
|
29
|
+
assert_equal(result.err[/#{expected_error}/], expected_error)
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'fails on non eligible org' do
|
33
|
+
params = ["--organization-id=#{organization_id}"]
|
34
|
+
|
35
|
+
api_expects(:simple_content_access, :eligible).
|
36
|
+
with_params('organization_id' => organization_id).
|
37
|
+
returns("simple_content_access_eligible" => false)
|
38
|
+
|
39
|
+
api_expects(:simple_content_access, :disable)
|
40
|
+
.with_params('organization_id' => organization_id).never
|
41
|
+
result = run_cmd(@cmd + params)
|
42
|
+
|
43
|
+
expected_error = "Could not disable Simple Content Access for this organization"
|
44
|
+
|
45
|
+
assert_equal(result.exit_code, HammerCLI::EX_SOFTWARE)
|
46
|
+
assert_equal(result.err[/#{expected_error}/], expected_error)
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '../../test_helper')
|
2
|
+
|
3
|
+
describe 'simple-content-access enable' do
|
4
|
+
before do
|
5
|
+
@cmd = %w(simple-content-access enable)
|
6
|
+
end
|
7
|
+
|
8
|
+
let(:organization_id) { 3 }
|
9
|
+
|
10
|
+
it "enables with required options" do
|
11
|
+
params = ["--organization-id=#{organization_id}"]
|
12
|
+
api_expects(:simple_content_access, :eligible).
|
13
|
+
with_params('organization_id' => organization_id).
|
14
|
+
returns("simple_content_access_eligible" => true)
|
15
|
+
|
16
|
+
api_expects(:simple_content_access, :enable)
|
17
|
+
.with_params('organization_id' => organization_id)
|
18
|
+
run_cmd(@cmd + params)
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'fails on missing required params' do
|
22
|
+
params = []
|
23
|
+
result = run_cmd(@cmd + params)
|
24
|
+
expected_error = "Could not enable Simple Content Access for this organization"
|
25
|
+
|
26
|
+
assert_equal(result.exit_code, HammerCLI::EX_SOFTWARE)
|
27
|
+
assert_equal(result.err[/#{expected_error}/], expected_error)
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'fails on non eligible org' do
|
31
|
+
params = ["--organization-id=#{organization_id}"]
|
32
|
+
|
33
|
+
api_expects(:simple_content_access, :eligible).
|
34
|
+
with_params('organization_id' => organization_id).
|
35
|
+
returns("simple_content_access_eligible" => false)
|
36
|
+
|
37
|
+
api_expects(:simple_content_access, :enable)
|
38
|
+
.with_params('organization_id' => organization_id).never
|
39
|
+
result = run_cmd(@cmd + params)
|
40
|
+
|
41
|
+
expected_error = "Could not enable Simple Content Access for this organization"
|
42
|
+
|
43
|
+
assert_equal(result.exit_code, HammerCLI::EX_SOFTWARE)
|
44
|
+
assert_equal(result.err[/#{expected_error}/], expected_error)
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '../../test_helper')
|
2
|
+
|
3
|
+
describe 'simple-content-access status' do
|
4
|
+
before do
|
5
|
+
@cmd = %w(simple-content-access status)
|
6
|
+
end
|
7
|
+
|
8
|
+
let(:organization_id) { 3 }
|
9
|
+
|
10
|
+
it 'list status with required options' do
|
11
|
+
params = ["--organization-id=#{organization_id}"]
|
12
|
+
api_expects(:simple_content_access, :status).
|
13
|
+
with_params('organization_id' => organization_id).
|
14
|
+
returns('simple_content_access' => true)
|
15
|
+
|
16
|
+
run_cmd(@cmd + params)
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'fails on missing required params' do
|
20
|
+
params = []
|
21
|
+
result = run_cmd(@cmd + params)
|
22
|
+
# rubocop:disable Layout/LineLength
|
23
|
+
expected_error = 'Could not find organization, please set one of options --organization-id, --organization, --organization-title, --organization-label.'
|
24
|
+
# rubocop:enable Layout/LineLength
|
25
|
+
|
26
|
+
assert_equal(result.exit_code, HammerCLI::EX_SOFTWARE)
|
27
|
+
assert_equal(result.err[/#{expected_error}/], expected_error)
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
require_relative '../test_helper'
|
2
|
+
require_relative '../repository/repository_helpers'
|
3
|
+
require_relative '../product/product_helpers'
|
4
|
+
require_relative '../organization/organization_helpers'
|
5
|
+
require 'hammer_cli_katello/package'
|
6
|
+
require 'hammer_cli_katello/srpm'
|
7
|
+
|
8
|
+
module HammerCLIKatello
|
9
|
+
describe SrpmCommand::ListCommand do
|
10
|
+
include OrganizationHelpers
|
11
|
+
include RepositoryHelpers
|
12
|
+
include ProductHelpers
|
13
|
+
|
14
|
+
it 'allows minimal options' do
|
15
|
+
api_expects(:srpms, :index)
|
16
|
+
|
17
|
+
run_cmd(%w(srpm list))
|
18
|
+
end
|
19
|
+
|
20
|
+
describe 'repository options' do
|
21
|
+
it 'may be specified by ID' do
|
22
|
+
api_expects(:srpms, :index).with_params('repository_id' => 1)
|
23
|
+
|
24
|
+
run_cmd(%w(srpm list --repository-id 1))
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'require product ID when given repository name' do
|
28
|
+
api_expects_no_call
|
29
|
+
|
30
|
+
r = run_cmd(%w(srpm list --repository repo1))
|
31
|
+
assert(r.err.include?("--product-id, --product is required"), "Invalid error message")
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'may be specified by name and product ID' do
|
35
|
+
expect_repository_search(2, 'repo1', 1)
|
36
|
+
|
37
|
+
api_expects(:srpms, :index).with_params('repository_id' => 1)
|
38
|
+
|
39
|
+
run_cmd(%w(srpm list --repository repo1 --product-id 2))
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe 'organization options' do
|
44
|
+
it 'may be specified by ID' do
|
45
|
+
api_expects(:srpms, :index).with_params('organization_id' => 1)
|
46
|
+
|
47
|
+
run_cmd(%w(srpm list --organization-id 1))
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'may be specified by name' do
|
51
|
+
expect_organization_search('org3', 1)
|
52
|
+
api_expects(:srpms, :index).with_params('organization_id' => 1)
|
53
|
+
|
54
|
+
run_cmd(%w(srpm list --organization org3))
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'may be specified by label' do
|
58
|
+
expect_organization_search('org3', 1, field: 'label')
|
59
|
+
api_expects(:srpms, :index).with_params('organization_id' => 1)
|
60
|
+
|
61
|
+
run_cmd(%w(srpm list --organization-label org3))
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
describe 'content-view options' do
|
66
|
+
it 'may be specified by ID' do
|
67
|
+
api_expects(:content_view_versions, :index)
|
68
|
+
.with_params('content_view_id' => 1, 'version' => '2.1')
|
69
|
+
.returns(index_response([{'id' => 5}]))
|
70
|
+
api_expects(:srpms, :index).with_params('content_view_version_id' => 5)
|
71
|
+
|
72
|
+
run_cmd(%w(srpm list --content-view-id 1 --content-view-version 2.1))
|
73
|
+
end
|
74
|
+
|
75
|
+
it 'requires organization ID when given content view name' do
|
76
|
+
api_expects_no_call
|
77
|
+
|
78
|
+
r = run_cmd(%w(srpm list --content-view cv1 --content-view-version 2.1))
|
79
|
+
expected_error = "--organization-id, --organization, --organization-label is required"
|
80
|
+
assert(r.err.include?(expected_error), "Invalid error message")
|
81
|
+
end
|
82
|
+
|
83
|
+
it 'requires content view ID when given content view version number' do
|
84
|
+
api_expects_no_call
|
85
|
+
|
86
|
+
r = run_cmd(%w(srpm list --content-view-version cvv1))
|
87
|
+
assert(r.err.include?("--content-view-id, --content-view is required"),
|
88
|
+
"Invalid error message")
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
require_relative '../test_helper'
|
2
|
+
require 'hammer_cli_katello/subscription'
|
3
|
+
|
4
|
+
module HammerCLIKatello
|
5
|
+
describe SubscriptionCommand::ListCommand do
|
6
|
+
before do
|
7
|
+
@cmd = %w(subscription list)
|
8
|
+
end
|
9
|
+
|
10
|
+
let(:org_id) { 1 }
|
11
|
+
|
12
|
+
it "returns the correct subscription type" do
|
13
|
+
cmd = SubscriptionCommand::ListCommand.new({})
|
14
|
+
assert_equal("Physical", cmd.get_subscription_type("virt_only" => false))
|
15
|
+
|
16
|
+
hostname = "boo.com"
|
17
|
+
with_hostname = cmd.get_subscription_type("virt_only" => true, "host" => {"name" => hostname})
|
18
|
+
assert(with_hostname.include?(hostname))
|
19
|
+
|
20
|
+
assert_equal("Temporary",
|
21
|
+
cmd.get_subscription_type("virt_only" => true, "unmapper_guest" => true))
|
22
|
+
|
23
|
+
assert_equal("Virtual",
|
24
|
+
cmd.get_subscription_type("virt_only" => true))
|
25
|
+
end
|
26
|
+
|
27
|
+
it "lists an organizations subscriptions" do
|
28
|
+
params = ["--organization-id=#{org_id}"]
|
29
|
+
|
30
|
+
ex = api_expects(:subscriptions, :index, 'Subscription list') do |par|
|
31
|
+
par['organization_id'] == org_id
|
32
|
+
end
|
33
|
+
|
34
|
+
ex.returns(index_response([]))
|
35
|
+
|
36
|
+
result = run_cmd(@cmd + params)
|
37
|
+
|
38
|
+
fields = ['ID', 'UUID', 'NAME', 'TYPE', 'CONTRACT', 'ACCOUNT', 'SUPPORT',
|
39
|
+
'START DATE', 'END DATE', 'QUANTITY', 'CONSUMED']
|
40
|
+
expected_result = success_result(IndexMatcher.new([fields, []]))
|
41
|
+
assert_cmd(expected_result, result)
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'allows organization name' do
|
45
|
+
api_expects(:organizations, :index) { |par| par[:search] == "name = \"org1\"" }
|
46
|
+
.returns(index_response([{'id' => 1}]))
|
47
|
+
|
48
|
+
api_expects(:subscriptions, :index) { |par| par['organization_id'].to_i == 1 }
|
49
|
+
|
50
|
+
run_cmd(%w(subscription list --organization org1))
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'allows organization label' do
|
54
|
+
api_expects(:organizations, :index) { |par| par[:search] == "label = \"org1\"" }
|
55
|
+
.returns(index_response([{'id' => 1}]))
|
56
|
+
|
57
|
+
api_expects(:subscriptions, :index) { |par| par['organization_id'].to_i == 1 }
|
58
|
+
|
59
|
+
run_cmd(%w(subscription list --organization-label org1))
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'allows host id' do
|
63
|
+
api_expects(:subscriptions, :index) { |par| par['host_id'] == '1' }
|
64
|
+
run_cmd(%w(subscription list --organization-id 1 --host-id 1))
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'allows host name' do
|
68
|
+
api_expects(:hosts, :index) { |par| par[:search] == "name = \"host1\"" }
|
69
|
+
.returns(index_response([{'id' => 1}]))
|
70
|
+
api_expects(:subscriptions, :index) { |par| par['host_id'] == 1 }
|
71
|
+
run_cmd(%w(subscription list --organization-id 1 --host host1))
|
72
|
+
end
|
73
|
+
|
74
|
+
it 'allows activation key id' do
|
75
|
+
api_expects(:subscriptions, :index) { |par| par['activation_key_id'] == '1' }
|
76
|
+
run_cmd(%w(subscription list --organization-id 1 --activation-key-id 1))
|
77
|
+
end
|
78
|
+
|
79
|
+
it 'allows activation key name' do
|
80
|
+
api_expects(:activation_keys, :index) { |par| par['name'] == "ak1" }
|
81
|
+
.returns(index_response([{'id' => 1}]))
|
82
|
+
api_expects(:subscriptions, :index) { |par| par['activation_key_id'] == 1 }
|
83
|
+
run_cmd(%w(subscription list --organization-id 1 --activation-key ak1))
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require_relative '../test_helper'
|
2
|
+
|
3
|
+
describe "create sync plan" do
|
4
|
+
let(:org_id) { 1 }
|
5
|
+
let(:name) { "sync_plan1" }
|
6
|
+
let(:hourly) { "hourly" }
|
7
|
+
let(:custom) { "custom cron" }
|
8
|
+
let(:cron) { "10 * * * *" }
|
9
|
+
let(:date) { "2018-09-08T00:00:00+00:00" }
|
10
|
+
|
11
|
+
it 'with organization ID,name,interval,date and enabled' do
|
12
|
+
api_expects(:sync_plans, :create, 'create a sync plan').
|
13
|
+
with_params('organization_id' => org_id,
|
14
|
+
'name' => name,
|
15
|
+
'interval' => hourly,
|
16
|
+
'sync_date' => date,
|
17
|
+
'enabled' => true)
|
18
|
+
command = %W(sync-plan create --organization-id #{org_id} --name #{name}
|
19
|
+
--interval #{hourly} --enabled 1 --sync-date #{date})
|
20
|
+
assert_equal(0, run_cmd(command).exit_code)
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'with custom cron' do
|
24
|
+
api_expects(:sync_plans, :create, 'create a sync plan').
|
25
|
+
with_params('organization_id' => org_id,
|
26
|
+
'name' => name,
|
27
|
+
'interval' => custom,
|
28
|
+
'cron_expression' => cron,
|
29
|
+
'sync_date' => date,
|
30
|
+
'enabled' => true)
|
31
|
+
# end
|
32
|
+
command = %W(sync-plan create --organization-id #{org_id} --name #{name} --interval #{custom}
|
33
|
+
--cron-expression #{cron} --enabled 1 --sync-date #{date})
|
34
|
+
assert_equal(0, run_cmd(command).exit_code)
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'fails without organization-id' do
|
38
|
+
command = %w(sync-plan create --name #{name}
|
39
|
+
--interval #{hourly} --enabled 1 --sync-date #{date})
|
40
|
+
refute_equal(0, run_cmd(command).exit_code)
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'fails without name' do
|
44
|
+
command = %w(sync-plan create --organization-id #{org_id}
|
45
|
+
--interval #{hourly} --enabled 1 --sync-date #{date})
|
46
|
+
refute_equal(0, run_cmd(command).err)
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'fails without interval' do
|
50
|
+
command = %w(sync-plan create --organization-id #{org_id} --name #{name}
|
51
|
+
--enabled 1 --sync-date #{date})
|
52
|
+
refute_equal(0, run_cmd(command).exit_code)
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'fails without enabled' do
|
56
|
+
command = %w(sync-plan create --organization-id #{org_id} --name #{name}
|
57
|
+
--interval #{hourly} --sync-date #{date})
|
58
|
+
refute_equal(0, run_cmd(command).exit_code)
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require_relative '../test_helper'
|
2
|
+
require_relative 'sync_plan_helpers'
|
3
|
+
require_relative '../organization/organization_helpers'
|
4
|
+
|
5
|
+
describe 'delete a sync plan' do
|
6
|
+
include OrganizationHelpers
|
7
|
+
include SyncPlanHelpers
|
8
|
+
|
9
|
+
let(:org_id) { 1 }
|
10
|
+
let(:id) { 1 }
|
11
|
+
let(:name) { "sync_plan1" }
|
12
|
+
let(:org_name) { "org1" }
|
13
|
+
|
14
|
+
it 'by organization ID and sync plan id' do
|
15
|
+
api_expects(:sync_plans, :destroy, 'delete a sync plan').
|
16
|
+
with_params('organization_id' => org_id,
|
17
|
+
'id' => id)
|
18
|
+
command = %W(sync-plan delete --organization-id #{org_id} --id #{id})
|
19
|
+
assert_equal(0, run_cmd(command).exit_code)
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'by organization ID and sync plan name' do
|
23
|
+
expect_sync_plan_search(1, 'sync_plan1', 1)
|
24
|
+
api_expects(:sync_plans, :destroy, 'delete a sync plan').
|
25
|
+
with_params('id' => id)
|
26
|
+
command = %W(sync-plan delete --organization-id #{org_id} --name #{name})
|
27
|
+
assert_equal(0, run_cmd(command).exit_code)
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'by organization name and sync plan name' do
|
31
|
+
expect_organization_search('org1', 1)
|
32
|
+
expect_sync_plan_search(1, 'sync_plan1', 1)
|
33
|
+
api_expects(:sync_plans, :destroy, 'delete a sync plan').
|
34
|
+
with_params('id' => id)
|
35
|
+
command = %W(sync-plan delete --organization #{org_name} --name #{name})
|
36
|
+
assert_equal(0, run_cmd(command).exit_code)
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'by organization name and sync plan id' do
|
40
|
+
expect_organization_search(org_name, org_id)
|
41
|
+
api_expects(:sync_plans, :destroy, 'delete a sync plan').
|
42
|
+
with_params('id' => id)
|
43
|
+
command = %W(sync-plan delete --organization #{org_name} --id #{id})
|
44
|
+
assert_equal(0, run_cmd(command).exit_code)
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require_relative '../test_helper'
|
2
|
+
require 'hammer_cli_katello/sync_plan'
|
3
|
+
require_relative 'sync_plan_helpers'
|
4
|
+
require_relative '../organization/organization_helpers'
|
5
|
+
module HammerCLIKatello
|
6
|
+
describe SyncPlan::InfoCommand do
|
7
|
+
include OrganizationHelpers
|
8
|
+
include SyncPlanHelpers
|
9
|
+
|
10
|
+
it 'allows ID' do
|
11
|
+
api_expects(:sync_plans, :show).with_params('id' => 1)
|
12
|
+
|
13
|
+
run_cmd(%w(sync-plan info --id 1))
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'allows organization id and sync plan name' do
|
17
|
+
org_id = 1
|
18
|
+
name = "SyncPlan1"
|
19
|
+
id = 100
|
20
|
+
expect_sync_plan_search(org_id, name, id)
|
21
|
+
api_expects(:sync_plans, :show).with_params('id' => id)
|
22
|
+
run_cmd("sync-plan info --organization-id #{org_id} --name #{name}".split)
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'allows organization name and sync plan name' do
|
26
|
+
org_id = 1
|
27
|
+
org_label = "org"
|
28
|
+
name = "SyncPlan1"
|
29
|
+
id = 100
|
30
|
+
|
31
|
+
expect_organization_search(org_label, org_id, field: 'label')
|
32
|
+
expect_sync_plan_search(org_id, name, id)
|
33
|
+
api_expects(:sync_plans, :show).with_params('id' => id)
|
34
|
+
run_cmd("sync-plan info --organization-label #{org_label} --name #{name}".split)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require_relative '../test_helper'
|
2
|
+
require 'hammer_cli_katello/sync_plan'
|
3
|
+
require_relative 'sync_plan_helpers'
|
4
|
+
require_relative '../organization/organization_helpers'
|
5
|
+
|
6
|
+
module HammerCLIKatello
|
7
|
+
describe SyncPlan::ListCommand do
|
8
|
+
include SyncPlanHelpers
|
9
|
+
include OrganizationHelpers
|
10
|
+
|
11
|
+
it 'allows minimal options' do
|
12
|
+
expect_sync_plan_search(1, nil, nil)
|
13
|
+
|
14
|
+
run_cmd(%w(sync-plan list --organization-id 1))
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'allows org name' do
|
18
|
+
expect_organization_search('org1', 1)
|
19
|
+
expect_sync_plan_search(1, nil, nil)
|
20
|
+
|
21
|
+
run_cmd(%w(sync-plan list --organization org1))
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'allows org label' do
|
25
|
+
expect_organization_search('org1', 1, field: 'label')
|
26
|
+
expect_sync_plan_search(1, nil, nil)
|
27
|
+
|
28
|
+
run_cmd(%w(sync-plan list --organization-label org1))
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require_relative '../test_helper'
|
2
|
+
require_relative 'sync_plan_helpers'
|
3
|
+
require_relative '../organization/organization_helpers'
|
4
|
+
|
5
|
+
describe 'update a sync plan' do
|
6
|
+
include OrganizationHelpers
|
7
|
+
include SyncPlanHelpers
|
8
|
+
|
9
|
+
let(:org_id) { 1 }
|
10
|
+
let(:id) { 1 }
|
11
|
+
let(:name) { "sync_plan1" }
|
12
|
+
let(:org_name) { "org1" }
|
13
|
+
let(:desc) { "New Description" }
|
14
|
+
|
15
|
+
it 'with organization id and sync plan ID' do
|
16
|
+
api_expects(:sync_plans, :update, 'update a sync plan').
|
17
|
+
with_params('description' => desc,
|
18
|
+
'id' => id)
|
19
|
+
command = %W(sync-plan update --organization-id #{org_id} --id #{id}
|
20
|
+
--description #{desc})
|
21
|
+
assert_equal(0, run_cmd(command).exit_code)
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'with organization ID and sync plan name' do
|
25
|
+
expect_sync_plan_search(org_id, name, id)
|
26
|
+
api_expects(:sync_plans, :update, 'update a sync plan').
|
27
|
+
with_params('description' => desc,
|
28
|
+
'id' => id)
|
29
|
+
command = %W(sync-plan update --organization-id #{org_id} --name #{name}
|
30
|
+
--description #{desc})
|
31
|
+
assert_equal(0, run_cmd(command).exit_code)
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'with organization name and sync plan name' do
|
35
|
+
expect_organization_search(org_name, org_id)
|
36
|
+
expect_sync_plan_search(org_id, name, id)
|
37
|
+
api_expects(:sync_plans, :update, 'update a sync plan').
|
38
|
+
with_params('description' => desc,
|
39
|
+
'id' => id)
|
40
|
+
command = %W(sync-plan update --organization #{org_name} --name #{name}
|
41
|
+
--description #{desc})
|
42
|
+
assert_equal(0, run_cmd(command).exit_code)
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '../test_helper')
|
2
|
+
|
3
|
+
require 'hammer_cli/testing/output_matchers'
|
4
|
+
require 'hammer_cli/testing/command_assertions'
|
5
|
+
require 'hammer_cli/testing/data_helpers'
|
6
|
+
require 'hammer_cli_foreman/testing/api_expectations'
|
7
|
+
|
8
|
+
include HammerCLI::Testing::OutputMatchers
|
9
|
+
include HammerCLI::Testing::CommandAssertions
|
10
|
+
include HammerCLI::Testing::DataHelpers
|
11
|
+
include HammerCLIForeman::Testing::APIExpectations
|
12
|
+
|
13
|
+
def assert_success(command_run_result)
|
14
|
+
assert command_run_result.exit_code.zero?,
|
15
|
+
"Nonzero exit code (#{command_run_result.exit_code}): #{command_run_result.err}"
|
16
|
+
end
|
17
|
+
|
18
|
+
def assert_failure(command_run_result, msg = nil)
|
19
|
+
assert !command_run_result.exit_code.zero?, "Success exit code (0) when expecting failure"
|
20
|
+
if msg
|
21
|
+
assert command_run_result.err[msg],
|
22
|
+
"Actual:\n#{command_run_result.err}\nExpected:\n#{msg.inspect}"
|
23
|
+
end
|
24
|
+
end
|
data/test/task_helper.rb
ADDED
data/test/test_helper.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
if RUBY_VERSION > "2.2"
|
2
|
+
# Coverage - Keep these two lines at the top of this file
|
3
|
+
require 'simplecov'
|
4
|
+
require 'coveralls'
|
5
|
+
SimpleCov.formatters = [SimpleCov::Formatter::HTMLFormatter, Coveralls::SimpleCov::Formatter]
|
6
|
+
SimpleCov.start do
|
7
|
+
minimum_coverage 70
|
8
|
+
maximum_coverage_drop 0.1
|
9
|
+
track_files "lib/**/*.rb"
|
10
|
+
add_filter '/test/'
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
require File.join(File.dirname(__FILE__), './task_helper.rb')
|
15
|
+
require 'minitest/autorun'
|
16
|
+
require 'minitest/spec'
|
17
|
+
require 'mocha/minitest'
|
18
|
+
require 'hammer_cli'
|
19
|
+
|
20
|
+
KATELLO_VERSION = Gem::Version.new(ENV['TEST_API_VERSION'] || '4.6')
|
21
|
+
|
22
|
+
if HammerCLI.context[:api_connection]
|
23
|
+
HammerCLI.context[:api_connection].create('foreman') do
|
24
|
+
HammerCLI::Apipie::ApiConnection.new(
|
25
|
+
:apidoc_cache_dir => 'test/data/' + KATELLO_VERSION.to_s,
|
26
|
+
:apidoc_cache_name => 'foreman_api',
|
27
|
+
:dry_run => true
|
28
|
+
)
|
29
|
+
end
|
30
|
+
else
|
31
|
+
HammerCLIForeman.stubs(:resource_config).returns(
|
32
|
+
:apidoc_cache_dir => 'test/data/' + KATELLO_VERSION.to_s,
|
33
|
+
:apidoc_cache_name => 'foreman_api',
|
34
|
+
:dry_run => true
|
35
|
+
)
|
36
|
+
end
|
37
|
+
|
38
|
+
require 'hammer_cli_katello'
|