hammer_cli_katello 1.5.0 → 1.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/hammer_cli_katello/acs.rb +82 -0
- data/lib/hammer_cli_katello/activation_key.rb +8 -2
- data/lib/hammer_cli_katello/content_export.rb +39 -0
- data/lib/hammer_cli_katello/content_export_helper.rb +64 -6
- data/lib/hammer_cli_katello/host_subscription.rb +32 -0
- data/lib/hammer_cli_katello/organization.rb +4 -0
- data/lib/hammer_cli_katello/repository.rb +1 -1
- data/lib/hammer_cli_katello/simple_content_access.rb +10 -0
- data/lib/hammer_cli_katello/version.rb +1 -1
- data/lib/hammer_cli_katello.rb +5 -0
- data/test/data/2.5/foreman_api.json +1 -0
- data/test/data/3.0/foreman_api.json +1 -0
- data/test/data/3.10/foreman_api.json +1 -0
- data/test/data/3.11/foreman_api.json +1 -0
- data/test/data/3.12/foreman_api.json +1 -0
- data/test/data/3.13/foreman_api.json +1 -0
- data/test/data/3.14/foreman_api.json +1 -0
- data/test/data/3.15/foreman_api.json +1 -0
- data/test/data/3.16/foreman_api.json +1 -0
- data/test/data/3.17/foreman_api.json +1 -0
- data/test/data/3.18/foreman_api.json +1 -0
- data/test/data/3.19/foreman_api.json +1 -0
- data/test/data/3.2/foreman_api.json +1 -0
- data/test/data/3.4/foreman_api.json +1 -0
- data/test/data/3.5/foreman_api.json +1 -0
- data/test/data/3.6/foreman_api.json +1 -0
- data/test/data/3.7/foreman_api.json +1 -0
- data/test/data/3.8/foreman_api.json +1 -0
- data/test/data/3.9/foreman_api.json +1 -0
- data/test/data/4.0/foreman_api.json +1 -0
- data/test/data/4.1/foreman_api.json +1 -0
- data/test/data/4.3/foreman_api.json +1 -0
- data/test/data/4.4/foreman_api.json +1 -0
- data/test/data/4.5/foreman_api.json +1 -0
- data/test/data/4.6/foreman_api.json +1 -0
- data/test/data/Readme.md +5 -0
- data/test/functional/acs/create_test.rb +27 -0
- data/test/functional/acs/delete_test.rb +13 -0
- data/test/functional/acs/info_test.rb +94 -0
- data/test/functional/acs/list_test.rb +62 -0
- data/test/functional/acs/update_test.rb +23 -0
- data/test/functional/activation_key/add_host_collection_test.rb +62 -0
- data/test/functional/activation_key/content_override_test.rb +92 -0
- data/test/functional/activation_key/create_test.rb +33 -0
- data/test/functional/activation_key/data/activation_key.json +17 -0
- data/test/functional/activation_key/info_test.rb +29 -0
- data/test/functional/activation_key/list_test.rb +68 -0
- data/test/functional/activation_key/product_content_test.rb +23 -0
- data/test/functional/activation_key/remove_host_collection_test.rb +62 -0
- data/test/functional/activation_key/subscriptions_test.rb +74 -0
- data/test/functional/activation_key/update_test.rb +26 -0
- data/test/functional/apipie_helper_test.rb +31 -0
- data/test/functional/capsule/capsule_helpers.rb +13 -0
- data/test/functional/capsule/content/add_lifecycle_environment_test.rb +40 -0
- data/test/functional/capsule/content/cancel_synchronization_test.rb +42 -0
- data/test/functional/capsule/content/capsule_content_helpers.rb +24 -0
- data/test/functional/capsule/content/data/library_env.json +47 -0
- data/test/functional/capsule/content/data/sync_status.json +6 -0
- data/test/functional/capsule/content/data/sync_tasks.json +62 -0
- data/test/functional/capsule/content/info_test.rb +61 -0
- data/test/functional/capsule/content/lifecycle_environments_test.rb +19 -0
- data/test/functional/capsule/content/remove_lifecycle_environment_test.rb +40 -0
- data/test/functional/capsule/content/synchronization_status_test.rb +107 -0
- data/test/functional/capsule/info_test.rb +25 -0
- data/test/functional/capsule/list_test.rb +24 -0
- data/test/functional/content_credentials/create_test.rb +32 -0
- data/test/functional/content_credentials/data/test_cert.json +43 -0
- data/test/functional/content_credentials/info_test.rb +50 -0
- data/test/functional/content_credentials/list_test.rb +66 -0
- data/test/functional/content_export/complete/library_test.rb +155 -0
- data/test/functional/content_export/complete/repository_test.rb +226 -0
- data/test/functional/content_export/complete/version_test.rb +297 -0
- data/test/functional/content_export/content_export_helpers.rb +33 -0
- data/test/functional/content_export/generate_listing_test.rb +62 -0
- data/test/functional/content_export/generate_metadata_test.rb +64 -0
- data/test/functional/content_export/incremental/library_test.rb +172 -0
- data/test/functional/content_export/incremental/repository_test.rb +212 -0
- data/test/functional/content_export/incremental/version_test.rb +268 -0
- data/test/functional/content_export/list_test.rb +64 -0
- data/test/functional/content_import/library_test.rb +85 -0
- data/test/functional/content_import/list_test.rb +65 -0
- data/test/functional/content_import/metadata.json +1 -0
- data/test/functional/content_import/version_test.rb +85 -0
- data/test/functional/content_units/info_test.rb +29 -0
- data/test/functional/content_units/list_test.rb +106 -0
- data/test/functional/content_view/add_content_view_version_test.rb +88 -0
- data/test/functional/content_view/add_repository_test.rb +21 -0
- data/test/functional/content_view/component/add_test.rb +177 -0
- data/test/functional/content_view/component/list_test.rb +55 -0
- data/test/functional/content_view/component/remove_test.rb +107 -0
- data/test/functional/content_view/component/update_test.rb +134 -0
- data/test/functional/content_view/content_view_helpers.rb +20 -0
- data/test/functional/content_view/copy_test.rb +53 -0
- data/test/functional/content_view/create_test.rb +34 -0
- data/test/functional/content_view/delete_test.rb +62 -0
- data/test/functional/content_view/filter/create_test.rb +57 -0
- data/test/functional/content_view/filter/delete_test.rb +90 -0
- data/test/functional/content_view/filter/info_test.rb +89 -0
- data/test/functional/content_view/filter/list_test.rb +98 -0
- data/test/functional/content_view/filter/update_test.rb +91 -0
- data/test/functional/content_view/list_test.rb +68 -0
- data/test/functional/content_view/publish_test.rb +24 -0
- data/test/functional/content_view/purge_test.rb +97 -0
- data/test/functional/content_view/remove_content_view_version_test.rb +88 -0
- data/test/functional/content_view/remove_test.rb +79 -0
- data/test/functional/content_view/update_test.rb +53 -0
- data/test/functional/content_view/version/incremental_update_test.rb +108 -0
- data/test/functional/content_view/version/list_test.rb +44 -0
- data/test/functional/content_view/version/promote_test.rb +75 -0
- data/test/functional/content_view/version/republish_repositories_test.rb +34 -0
- data/test/functional/content_view/version/update_test.rb +48 -0
- data/test/functional/erratum/erratum_helpers.rb +91 -0
- data/test/functional/erratum/info_test.rb +29 -0
- data/test/functional/erratum/list_test.rb +108 -0
- data/test/functional/file/file_helpers.rb +13 -0
- data/test/functional/file/info_test.rb +162 -0
- data/test/functional/file/list_test.rb +112 -0
- data/test/functional/filter_rule/create_test.rb +99 -0
- data/test/functional/filter_rule/delete_test.rb +104 -0
- data/test/functional/filter_rule/filter_rule_helpers.rb +12 -0
- data/test/functional/filter_rule/info_test.rb +104 -0
- data/test/functional/filter_rule/list_test.rb +91 -0
- data/test/functional/filter_rule/update_test.rb +104 -0
- data/test/functional/host/errata/apply_test.rb +45 -0
- data/test/functional/host/errata/info_test.rb +27 -0
- data/test/functional/host/errata/list_test.rb +49 -0
- data/test/functional/host/errata/recalculate_test.rb +26 -0
- data/test/functional/host/extensions/create_test.rb +95 -0
- data/test/functional/host/extensions/data/host.json +320 -0
- data/test/functional/host/extensions/data/host_list.json +117 -0
- data/test/functional/host/extensions/info_test.rb +35 -0
- data/test/functional/host/extensions/list_test.rb +21 -0
- data/test/functional/host/extensions/update_test.rb +70 -0
- data/test/functional/host/host_helpers.rb +8 -0
- data/test/functional/host/subscription/attach_test.rb +54 -0
- data/test/functional/host/subscription/auto_attach_test.rb +35 -0
- data/test/functional/host/subscription/content_override_test.rb +96 -0
- data/test/functional/host/subscription/enabled_repositories_test.rb +39 -0
- data/test/functional/host/subscription/product_content_test.rb +27 -0
- data/test/functional/host/subscription/register_test.rb +53 -0
- data/test/functional/host/subscription/remove_test.rb +52 -0
- data/test/functional/host/subscription/unregister_test.rb +37 -0
- data/test/functional/host/traces/list_test.rb +37 -0
- data/test/functional/host/traces/resolve_test.rb +31 -0
- data/test/functional/host_collection/add_host_test.rb +90 -0
- data/test/functional/host_collection/content_api_expectations.rb +35 -0
- data/test/functional/host_collection/content_install_test.rb +62 -0
- data/test/functional/host_collection/content_remove_test.rb +37 -0
- data/test/functional/host_collection/content_update_test.rb +37 -0
- data/test/functional/host_collection/copy_test.rb +64 -0
- data/test/functional/host_collection/create_test.rb +54 -0
- data/test/functional/host_collection/delete_test.rb +57 -0
- data/test/functional/host_collection/hosts_test.rb +39 -0
- data/test/functional/host_collection/info_test.rb +57 -0
- data/test/functional/host_collection/list_test.rb +63 -0
- data/test/functional/host_collection/remove_host_test.rb +90 -0
- data/test/functional/host_collection/update_test.rb +57 -0
- data/test/functional/hostgroup/create_test.rb +112 -0
- data/test/functional/hostgroup/data/hostgroup.json +50 -0
- data/test/functional/hostgroup/info_test.rb +33 -0
- data/test/functional/hostgroup/update_test.rb +120 -0
- data/test/functional/lifecycle_environment/create_test.rb +14 -0
- data/test/functional/lifecycle_environment/lifecycle_environment_helpers.rb +18 -0
- data/test/functional/lifecycle_environment/list_test.rb +38 -0
- data/test/functional/lifecycle_environment/update_test.rb +14 -0
- data/test/functional/local_helper_test.rb +30 -0
- data/test/functional/module_stream/info_test.rb +58 -0
- data/test/functional/module_stream/list_test.rb +53 -0
- data/test/functional/organization/cdn_configuration_test.rb +45 -0
- data/test/functional/organization/delete_test.rb +26 -0
- data/test/functional/organization/info_test.rb +45 -0
- data/test/functional/organization/organization_helpers.rb +10 -0
- data/test/functional/package/list_test.rb +160 -0
- data/test/functional/package_group/list_test.rb +38 -0
- data/test/functional/ping_test.rb +61 -0
- data/test/functional/product/create_test.rb +54 -0
- data/test/functional/product/delete_test.rb +41 -0
- data/test/functional/product/info_test.rb +33 -0
- data/test/functional/product/list_test.rb +58 -0
- data/test/functional/product/product_helpers.rb +24 -0
- data/test/functional/product/remove_sync_plan_test.rb +35 -0
- data/test/functional/product/set_sync_plan_test.rb +49 -0
- data/test/functional/product/update_proxy.rb +48 -0
- data/test/functional/product/update_test.rb +46 -0
- data/test/functional/repository/create_test.rb +21 -0
- data/test/functional/repository/delete_test.rb +95 -0
- data/test/functional/repository/info_test.rb +156 -0
- data/test/functional/repository/list_test.rb +68 -0
- data/test/functional/repository/reclaim_space_test.rb +105 -0
- data/test/functional/repository/remove_content_test.rb +108 -0
- data/test/functional/repository/repository_helpers.rb +18 -0
- data/test/functional/repository/republish_test.rb +37 -0
- data/test/functional/repository/synchronize_test.rb +57 -0
- data/test/functional/repository/update_test.rb +150 -0
- data/test/functional/repository/upload_test.rb +368 -0
- data/test/functional/repository_set/available_repositories_test.rb +18 -0
- data/test/functional/repository_set/disable_test.rb +48 -0
- data/test/functional/repository_set/enable_test.rb +42 -0
- data/test/functional/repository_set/info_test.rb +17 -0
- data/test/functional/repository_set/list_test.rb +18 -0
- data/test/functional/repository_set/repository_set_helpers.rb +20 -0
- data/test/functional/search_helpers.rb +17 -0
- data/test/functional/simple_content_access/disable_test.rb +48 -0
- data/test/functional/simple_content_access/enable_test.rb +46 -0
- data/test/functional/simple_content_access/status_test.rb +29 -0
- data/test/functional/srpm/list_test.rb +92 -0
- data/test/functional/subscription/list_test.rb +86 -0
- data/test/functional/sync_plan/create_test.rb +60 -0
- data/test/functional/sync_plan/delete_test.rb +46 -0
- data/test/functional/sync_plan/info_test.rb +37 -0
- data/test/functional/sync_plan/list_test.rb +31 -0
- data/test/functional/sync_plan/sync_plan_helpers.rb +8 -0
- data/test/functional/sync_plan/update_test.rb +44 -0
- data/test/functional/test_helper.rb +24 -0
- data/test/task_helper.rb +7 -0
- data/test/test_helper.rb +38 -0
- data/test/unit/id_name_options_validator_test.rb +96 -0
- data/test/unit/id_resolver_test.rb +58 -0
- data/test/unit/messages_test.rb +7 -0
- data/test/unit/search_options_creators_test.rb +145 -0
- metadata +425 -4
@@ -0,0 +1,85 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '../../test_helper')
|
2
|
+
require 'hammer_cli_katello/content_import'
|
3
|
+
|
4
|
+
describe 'content-import version' do
|
5
|
+
include ForemanTaskHelpers
|
6
|
+
|
7
|
+
before do
|
8
|
+
@cmd = %w(content-import version)
|
9
|
+
end
|
10
|
+
|
11
|
+
let(:task_id) { '5' }
|
12
|
+
|
13
|
+
let(:response) do
|
14
|
+
{
|
15
|
+
'id' => task_id,
|
16
|
+
'state' => 'planned'
|
17
|
+
}
|
18
|
+
end
|
19
|
+
|
20
|
+
let(:path) do
|
21
|
+
File.dirname(__FILE__)
|
22
|
+
end
|
23
|
+
|
24
|
+
let(:metadata) do
|
25
|
+
JSON.parse(File.read("#{path}/metadata.json"))
|
26
|
+
end
|
27
|
+
|
28
|
+
let(:organization_id) { 3 }
|
29
|
+
|
30
|
+
it "performs import with required options and async" do
|
31
|
+
params = [
|
32
|
+
"--organization-id=#{organization_id}",
|
33
|
+
"--path=#{path}",
|
34
|
+
'--async'
|
35
|
+
]
|
36
|
+
api_expects(:content_imports, :version)
|
37
|
+
.with_params('organization_id' => organization_id, 'path' => path, 'metadata' => metadata)
|
38
|
+
.returns(response)
|
39
|
+
|
40
|
+
result = run_cmd(@cmd + params)
|
41
|
+
|
42
|
+
assert_equal("Archive is being imported in task #{task_id}.\n", result.out)
|
43
|
+
assert_equal(HammerCLI::EX_OK, result.exit_code)
|
44
|
+
end
|
45
|
+
|
46
|
+
it "performs import with required options" do
|
47
|
+
params = [
|
48
|
+
"--organization-id=#{organization_id}",
|
49
|
+
"--path=#{path}"
|
50
|
+
]
|
51
|
+
|
52
|
+
api_expects(:content_imports, :version)
|
53
|
+
.with_params('organization_id' => organization_id, 'path' => path, 'metadata' => metadata)
|
54
|
+
.returns(response)
|
55
|
+
|
56
|
+
expect_foreman_task(task_id)
|
57
|
+
|
58
|
+
result = run_cmd(@cmd + params)
|
59
|
+
assert_equal(HammerCLI::EX_OK, result.exit_code)
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'fails on missing required params' do
|
63
|
+
params = [
|
64
|
+
'--id=2'
|
65
|
+
]
|
66
|
+
|
67
|
+
result = run_cmd(@cmd + params)
|
68
|
+
expected_error = "Could not import the archive."
|
69
|
+
|
70
|
+
assert_equal(result.exit_code, HammerCLI::EX_USAGE)
|
71
|
+
assert_equal(result.err[/#{expected_error}/], expected_error)
|
72
|
+
end
|
73
|
+
|
74
|
+
it 'fails on missing metadata.json' do
|
75
|
+
bad_path = "/nosuchdir"
|
76
|
+
params = [
|
77
|
+
"--organization-id=#{organization_id}",
|
78
|
+
"--path=#{bad_path}"
|
79
|
+
]
|
80
|
+
result = run_cmd(@cmd + params)
|
81
|
+
expected_error = "Unable to find '#{bad_path}/metadata.json'."
|
82
|
+
|
83
|
+
assert_match(/#{expected_error}/, result.err)
|
84
|
+
end
|
85
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require_relative '../test_helper.rb'
|
2
|
+
require_relative '../organization/organization_helpers'
|
3
|
+
require_relative '../content_view/content_view_helpers'
|
4
|
+
require_relative '../repository/repository_helpers'
|
5
|
+
require_relative '../product/product_helpers'
|
6
|
+
require 'hammer_cli_katello/content_units'
|
7
|
+
|
8
|
+
module HammerCLIKatello
|
9
|
+
describe ContentUnitsCommand::InfoCommand do
|
10
|
+
include ContentViewHelpers
|
11
|
+
include RepositoryHelpers
|
12
|
+
include ProductHelpers
|
13
|
+
include OrganizationHelpers
|
14
|
+
|
15
|
+
it 'allows minimal options' do
|
16
|
+
api_expects(:generic_content_units, :show)
|
17
|
+
.with_params('content_type' => 'python_package', 'id' => '1492')
|
18
|
+
|
19
|
+
run_cmd(%w(content-units info --content-type python_package --id 1492))
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'requires content_type param' do
|
23
|
+
api_expects_no_call
|
24
|
+
|
25
|
+
r = run_cmd(%w(content-units info --id 1492))
|
26
|
+
assert(r.err.include?("Missing arguments for '--content-type'"), "Invalid error message")
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,106 @@
|
|
1
|
+
require_relative '../test_helper.rb'
|
2
|
+
require_relative '../organization/organization_helpers'
|
3
|
+
require_relative '../content_view/content_view_helpers'
|
4
|
+
require_relative '../repository/repository_helpers'
|
5
|
+
require_relative '../product/product_helpers'
|
6
|
+
require 'hammer_cli_katello/content_units'
|
7
|
+
|
8
|
+
module HammerCLIKatello
|
9
|
+
describe ContentUnitsCommand::ListCommand do
|
10
|
+
include ContentViewHelpers
|
11
|
+
include RepositoryHelpers
|
12
|
+
include ProductHelpers
|
13
|
+
include OrganizationHelpers
|
14
|
+
|
15
|
+
it 'allows minimal options' do
|
16
|
+
api_expects(:generic_content_units, :index)
|
17
|
+
.with_params('content_type' => 'python_package')
|
18
|
+
|
19
|
+
run_cmd(%w(content-units list --content-type python_package))
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'requires content_type param' do
|
23
|
+
api_expects_no_call
|
24
|
+
|
25
|
+
r = run_cmd(%w(content-units list))
|
26
|
+
assert(r.err.include?("Missing arguments for '--content-type'"), "Invalid error message")
|
27
|
+
end
|
28
|
+
|
29
|
+
describe 'repository options' do
|
30
|
+
it 'may be specified by ID' do
|
31
|
+
api_expects(:generic_content_units, :index)
|
32
|
+
.with_params('content_type' => 'python_package', 'repository_id' => 1)
|
33
|
+
|
34
|
+
run_cmd(%w(content-units list --content-type python_package --repository-id 1))
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'require product ID when given repository name' do
|
38
|
+
api_expects_no_call
|
39
|
+
|
40
|
+
r = run_cmd(%w(content-units list --content-type python_package --repository repo1))
|
41
|
+
assert(r.err.include?("--product, --product-id is required"), "Invalid error message")
|
42
|
+
end
|
43
|
+
|
44
|
+
# rubocop:disable LineLength
|
45
|
+
it 'may be specified by name and product ID' do
|
46
|
+
expect_repository_search(2, 'repo1', 1)
|
47
|
+
|
48
|
+
api_expects(:generic_content_units, :index)
|
49
|
+
.with_params('content_type' => 'python_package', 'repository_id' => 1)
|
50
|
+
run_cmd(%w(content-units list --content-type python_package --repository repo1 --product-id 2))
|
51
|
+
end
|
52
|
+
# rubocop:enable LineLength
|
53
|
+
end
|
54
|
+
|
55
|
+
describe 'organization options' do
|
56
|
+
it 'may be specified by ID' do
|
57
|
+
api_expects(:generic_content_units, :index)
|
58
|
+
.with_params('organization_id' => 1, 'content_type' => 'python_package')
|
59
|
+
|
60
|
+
run_cmd(%w(content-units list --organization-id 1 --content-type python_package))
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'may be specified by name' do
|
64
|
+
expect_organization_search('org3', 1)
|
65
|
+
api_expects(:generic_content_units, :index)
|
66
|
+
.with_params('organization_id' => 1, 'content_type' => 'python_package')
|
67
|
+
|
68
|
+
run_cmd(%w(content-units list --organization org3 --content-type python_package))
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'may be specified by label' do
|
72
|
+
expect_organization_search('org3', 1, field: 'label')
|
73
|
+
api_expects(:generic_content_units, :index)
|
74
|
+
.with_params('organization_id' => 1, 'content_type' => 'python_package')
|
75
|
+
|
76
|
+
run_cmd(%w(content-units list --organization-label org3 --content-type python_package))
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
describe 'content-view options' do
|
81
|
+
# rubocop:disable LineLength
|
82
|
+
it 'may be specified by ID' do
|
83
|
+
api_expects(:content_view_versions, :index)
|
84
|
+
.with_params('content_view_id' => 1, 'version' => '2.1')
|
85
|
+
.returns(index_response([{'id' => 5}]))
|
86
|
+
api_expects(:generic_content_units, :index)
|
87
|
+
.with_params('content_view_version_id' => 5, 'content_type' => 'python_package')
|
88
|
+
|
89
|
+
run_cmd(
|
90
|
+
%w(
|
91
|
+
content-units list --content-view-id 1 --content-view-version 2.1 --content-type python_package
|
92
|
+
)
|
93
|
+
)
|
94
|
+
end
|
95
|
+
|
96
|
+
it 'requires organization ID when given content view name' do
|
97
|
+
api_expects_no_call
|
98
|
+
|
99
|
+
r = run_cmd(%w(content-units list --content-view cv1 --content-view-version 2.1 --content-type python_package))
|
100
|
+
expected_error = "--organization-id, --organization, --organization-label is required"
|
101
|
+
assert(r.err.include?(expected_error), "Invalid error message")
|
102
|
+
end
|
103
|
+
# rubocop:enable LineLength
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
require_relative '../test_helper'
|
2
|
+
require_relative '../organization/organization_helpers'
|
3
|
+
require_relative '../content_view/content_view_helpers'
|
4
|
+
require 'hammer_cli_katello/content_view'
|
5
|
+
|
6
|
+
module HammerCLIKatello
|
7
|
+
describe ContentView::AddContentViewVersionCommand do
|
8
|
+
include OrganizationHelpers
|
9
|
+
include ContentViewHelpers
|
10
|
+
|
11
|
+
it 'allows minimal options' do
|
12
|
+
ex = api_expects(:content_views, :show) do |p|
|
13
|
+
p[:id] == '1'
|
14
|
+
end
|
15
|
+
ex.returns('id' => 1, 'component_ids' => [1, 3])
|
16
|
+
api_expects(:content_views, :update) do |p|
|
17
|
+
p['id'] == '1' && p['component_ids'] == %w(1 3 6)
|
18
|
+
end
|
19
|
+
run_cmd(%w(content-view add-version --id 1 --content-view-version-id 6))
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'resolves content view version ID' do
|
23
|
+
ex = api_expects(:content_view_versions, :index) do |p|
|
24
|
+
p['content_view_id'] == 3 && p['version'] == '2.1'
|
25
|
+
end
|
26
|
+
ex.returns(index_response([{'id' => 6}]))
|
27
|
+
ex.returns('id' => 1, 'component_ids' => [1, 3])
|
28
|
+
ex = api_expects(:content_views, :show) do |p|
|
29
|
+
p[:id] == '1'
|
30
|
+
end
|
31
|
+
ex.returns('id' => 1, 'component_ids' => [1, 3])
|
32
|
+
api_expects(:content_views, :update) do |p|
|
33
|
+
p['id'] == '1' && p['component_ids'] == %w(1 3 6)
|
34
|
+
end
|
35
|
+
run_cmd(%w(content-view add-version --id 1 --content-view-id 3 --content-view-version 2.1))
|
36
|
+
end
|
37
|
+
|
38
|
+
describe 'OrganizationOptions' do
|
39
|
+
it 'requires organization if content view name is supplied' do
|
40
|
+
api_expects_no_call
|
41
|
+
result = run_cmd(%w(content-view add-version --name cv1))
|
42
|
+
assert(result.err[/--organization-id, --organization, --organization-label is required/],
|
43
|
+
"Organization option requirements are validated")
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'allows organization id' do
|
47
|
+
expect_content_view_search('1', 'cv2', 2)
|
48
|
+
ex = api_expects(:content_views, :show) do |p|
|
49
|
+
p[:id] == 2
|
50
|
+
end
|
51
|
+
ex.returns('id' => 2, 'component_ids' => [1, 2])
|
52
|
+
api_expects(:content_views, :update) do |p|
|
53
|
+
p['id'] == 2 && p['component_ids'] == %w(1 2 3)
|
54
|
+
end
|
55
|
+
run_cmd(%w(content-view add-version --name cv2 --organization-id 1
|
56
|
+
--content-view-version-id 3))
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'allows organization name' do
|
60
|
+
expect_organization_search('org1', 1)
|
61
|
+
expect_content_view_search(1, 'cv2', 2)
|
62
|
+
ex = api_expects(:content_views, :show) do |p|
|
63
|
+
p[:id] == 2
|
64
|
+
end
|
65
|
+
ex.returns('id' => 2, 'component_ids' => [1, 2])
|
66
|
+
api_expects(:content_views, :update) do |p|
|
67
|
+
p['id'] == 2 && p['component_ids'] == %w(1 2 3)
|
68
|
+
end
|
69
|
+
run_cmd(%w(content-view add-version --name cv2 --organization org1
|
70
|
+
--content-view-version-id 3))
|
71
|
+
end
|
72
|
+
|
73
|
+
it 'allows organization label' do
|
74
|
+
expect_organization_search('org1', 1, field: 'label')
|
75
|
+
expect_content_view_search(1, 'cv2', 2)
|
76
|
+
ex = api_expects(:content_views, :show) do |p|
|
77
|
+
p[:id] == 2
|
78
|
+
end
|
79
|
+
ex.returns('id' => 2, 'component_ids' => [1, 2])
|
80
|
+
api_expects(:content_views, :update) do |p|
|
81
|
+
p['id'] == 2 && p['component_ids'] == %w(1 2 3)
|
82
|
+
end
|
83
|
+
run_cmd(%w(content-view add-version --name cv2 --organization-label org1
|
84
|
+
--content-view-version-id 3))
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require_relative '../test_helper'
|
2
|
+
require 'hammer_cli_katello/content_view'
|
3
|
+
|
4
|
+
module HammerCLIKatello
|
5
|
+
describe ContentView do
|
6
|
+
describe 'AddRepositoryCommand' do
|
7
|
+
it 'allows adding a repository by ID' do
|
8
|
+
ex = api_expects(:organizations, :index) do |p|
|
9
|
+
p[:search] == "name = \"org1\""
|
10
|
+
end
|
11
|
+
ex.returns(index_response([{'id' => 1}]))
|
12
|
+
|
13
|
+
api_expects(:content_views, :index) do |p|
|
14
|
+
p['name'] == 'cv' && p['organization_id'] == 1
|
15
|
+
end
|
16
|
+
|
17
|
+
run_cmd(%w(content-view add-repository --organization org1 --name cv --repository-id 1))
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,177 @@
|
|
1
|
+
require_relative '../../test_helper'
|
2
|
+
require 'hammer_cli_katello/content_view_component'
|
3
|
+
# rubocop:disable Metrics/ModuleLength
|
4
|
+
module HammerCLIKatello
|
5
|
+
describe ContentViewComponent::AddComponents do
|
6
|
+
before do
|
7
|
+
@cmd = %w(content-view component add)
|
8
|
+
@composite = OpenStruct.new(:id => 2, :name => "composite")
|
9
|
+
@component_version = OpenStruct.new(:id => 666, :version => "1.0")
|
10
|
+
@component = OpenStruct.new(:id => 6, :name => "component",
|
11
|
+
:content_view_version => @component_version)
|
12
|
+
@organization = OpenStruct.new(:id => 1, :name => "great", :label => "label")
|
13
|
+
end
|
14
|
+
|
15
|
+
def setup_org_expectations
|
16
|
+
org_expect = api_expects(:organizations, :index) do |par|
|
17
|
+
par[:search] == "name = \"#{@organization.name}\""
|
18
|
+
end
|
19
|
+
org_expect.at_least_once.returns(index_response([{'id' => @organization.id.to_s}]))
|
20
|
+
end
|
21
|
+
|
22
|
+
def setup_content_view_expectations(content_view)
|
23
|
+
cv_expect = api_expects(:content_views, :index) do |p|
|
24
|
+
p['name'] == content_view.name && p["organization_id"].to_s == @organization.id.to_s
|
25
|
+
end
|
26
|
+
cv_expect.at_least_once.returns(index_response([{'id' => content_view.id}]))
|
27
|
+
end
|
28
|
+
|
29
|
+
describe 'allows adding a component with' do
|
30
|
+
it 'component-content-view-id and latest=true' do
|
31
|
+
latest = true
|
32
|
+
params = ["--composite-content-view-id=#{@composite.id}",
|
33
|
+
"--component-content-view-id=#{@component.id}",
|
34
|
+
"--latest"]
|
35
|
+
|
36
|
+
api_expects(:content_view_components, :add_components) do |p|
|
37
|
+
component = p['components'].first
|
38
|
+
p['composite_content_view_id'] == @composite.id &&
|
39
|
+
component[:latest] == latest &&
|
40
|
+
component[:content_view_id] == @component.id.to_s
|
41
|
+
end
|
42
|
+
run_cmd(@cmd + params)
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'component-content-view-version-id and latest=false' do
|
46
|
+
latest = false
|
47
|
+
params = ["--composite-content-view-id=#{@composite.id}",
|
48
|
+
"--component-content-view-version-id=#{@component_version.id}"]
|
49
|
+
|
50
|
+
api_expects(:content_view_components, :add_components) do |p|
|
51
|
+
component = p['components'].first
|
52
|
+
p['composite_content_view_id'] == @composite.id &&
|
53
|
+
component[:latest] == latest &&
|
54
|
+
component[:content_view_version_id] == @component_version.id.to_s
|
55
|
+
end
|
56
|
+
run_cmd(@cmd + params)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
describe 'allows adding a component with composite name and org' do
|
61
|
+
before do
|
62
|
+
setup_org_expectations
|
63
|
+
setup_content_view_expectations(@composite)
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'component-content-view-id and latest=true' do
|
67
|
+
latest = true
|
68
|
+
params = ["--composite-content-view=#{@composite.name}",
|
69
|
+
"--component-content-view-id=#{@component.id}",
|
70
|
+
"--organization=#{@organization.name}",
|
71
|
+
"--latest"]
|
72
|
+
|
73
|
+
api_expects(:content_view_components, :add_components) do |p|
|
74
|
+
component = p['components'].first
|
75
|
+
p['composite_content_view_id'] == @composite.id &&
|
76
|
+
component[:latest] == latest &&
|
77
|
+
component[:content_view_id] == @component.id.to_s
|
78
|
+
end
|
79
|
+
run_cmd(@cmd + params)
|
80
|
+
end
|
81
|
+
|
82
|
+
it 'component-content-view-version-id and latest=false' do
|
83
|
+
latest = false
|
84
|
+
params = ["--composite-content-view=#{@composite.name}",
|
85
|
+
"--organization=#{@organization.name}",
|
86
|
+
"--component-content-view-version-id=#{@component_version.id}"]
|
87
|
+
|
88
|
+
api_expects(:content_view_components, :add_components) do |p|
|
89
|
+
component = p['components'].first
|
90
|
+
p['composite_content_view_id'] == @composite.id &&
|
91
|
+
component[:latest] == latest &&
|
92
|
+
component[:content_view_version_id] == @component_version.id.to_s
|
93
|
+
end
|
94
|
+
run_cmd(@cmd + params)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
describe 'allows adding a component with component name and org' do
|
99
|
+
it 'component-content-view and latest=true' do
|
100
|
+
latest = true
|
101
|
+
params = ["--composite-content-view-id=#{@composite.id}",
|
102
|
+
"--component-content-view=#{@component.name}",
|
103
|
+
"--organization=#{@organization.name}",
|
104
|
+
"--latest"]
|
105
|
+
setup_org_expectations
|
106
|
+
setup_content_view_expectations(@component)
|
107
|
+
api_expects(:content_view_components, :add_components) do |p|
|
108
|
+
component = p['components'].first
|
109
|
+
p['composite_content_view_id'] == @composite.id &&
|
110
|
+
component[:latest] == latest &&
|
111
|
+
component[:content_view_id] == @component.id
|
112
|
+
end
|
113
|
+
run_cmd(@cmd + params)
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
describe 'allows adding a component with component version number org component content_view' do
|
118
|
+
before do
|
119
|
+
cvv_expect = api_expects(:content_view_versions, :index) do |p|
|
120
|
+
p['content_view_id'].to_s == @component.id.to_s &&
|
121
|
+
p["version"] == @component.content_view_version.version
|
122
|
+
end
|
123
|
+
cvv_expect.at_least_once.
|
124
|
+
returns(index_response([{'id' => @component.content_view_version.id}]))
|
125
|
+
end
|
126
|
+
|
127
|
+
it 'component-content-view-id and component version number' do
|
128
|
+
latest = false
|
129
|
+
params = ["--composite-content-view-id=#{@composite.id}",
|
130
|
+
"--component-content-view-id=#{@component.id}",
|
131
|
+
"--component-content-view-version=#{@component.content_view_version.version}"]
|
132
|
+
|
133
|
+
# 1) Should fetch the component_content_view_version_id
|
134
|
+
# using cv specified in --component-content-view-id and version specified in
|
135
|
+
# --component-content-view-version
|
136
|
+
# 2) Should set the component[:content_view_id] && component[:content_view_version_id]
|
137
|
+
# correctly
|
138
|
+
|
139
|
+
api_expects(:content_view_components, :add_components) do |p|
|
140
|
+
component = p['components'].first
|
141
|
+
p['composite_content_view_id'] == @composite.id &&
|
142
|
+
component[:latest] == latest &&
|
143
|
+
component[:content_view_id] == @component.id.to_s &&
|
144
|
+
component[:content_view_version_id] == @component.content_view_version.id
|
145
|
+
end
|
146
|
+
run_cmd(@cmd + params)
|
147
|
+
end
|
148
|
+
|
149
|
+
it 'component-content-view and component version number' do
|
150
|
+
latest = false
|
151
|
+
params = ["--composite-content-view=#{@composite.name}",
|
152
|
+
"--component-content-view=#{@component.name}",
|
153
|
+
"--component-content-view-version=#{@component.content_view_version.version}",
|
154
|
+
"--organization=#{@organization.name}"]
|
155
|
+
# 1) Should fetch the org using org name specified in --organization
|
156
|
+
# 2) Should fetch composite content view using name in --composite-content-view
|
157
|
+
# 3) Should fetch component content view using name in --component-content-view
|
158
|
+
# 4) Should fetch the component_content_view_version_id
|
159
|
+
# using cv specified in --component-content-view-id and version specified in
|
160
|
+
# --component-content-view-version
|
161
|
+
# 5) Should set the component[:content_view_id] && component[:content_view_version_id]
|
162
|
+
# correctly
|
163
|
+
setup_org_expectations
|
164
|
+
setup_content_view_expectations(@component)
|
165
|
+
setup_content_view_expectations(@composite)
|
166
|
+
api_expects(:content_view_components, :add_components) do |p|
|
167
|
+
component = p['components'].first
|
168
|
+
p['composite_content_view_id'] == @composite.id &&
|
169
|
+
component[:latest] == latest &&
|
170
|
+
component[:content_view_id] == @component.id &&
|
171
|
+
component[:content_view_version_id] == @component.content_view_version.id
|
172
|
+
end
|
173
|
+
run_cmd(@cmd + params)
|
174
|
+
end
|
175
|
+
end
|
176
|
+
end
|
177
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require_relative '../../test_helper'
|
2
|
+
require 'hammer_cli_katello/content_view_component'
|
3
|
+
module HammerCLIKatello
|
4
|
+
describe ContentViewComponent::ListCommand do
|
5
|
+
before do
|
6
|
+
@cmd = %w(content-view component list)
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'expects composite_content_view_id as minimal options' do
|
10
|
+
api_expects(:content_view_components, :index, "component list") do |p|
|
11
|
+
p["composite_content_view_id"].to_s == "1"
|
12
|
+
end
|
13
|
+
run_cmd(@cmd + ["--composite-content-view-id=1"])
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'expects composite_content_view and organization_id as other options' do
|
17
|
+
api_expects(:content_views, :index) do |p|
|
18
|
+
p['name'] == "lol" && p["organization_id"].to_s == "1"
|
19
|
+
end
|
20
|
+
run_cmd(@cmd + %w(--composite-content-view=lol --organization-id=1))
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'label' do
|
24
|
+
api_expects(:organizations, :index) { |par| par[:search] == "label = \"org1\"" }
|
25
|
+
.at_least_once.returns(index_response([{'id' => 1}]))
|
26
|
+
|
27
|
+
api_expects(:content_view_components, :index) do |p|
|
28
|
+
p["composite_content_view_id"].to_s == "1"
|
29
|
+
end
|
30
|
+
|
31
|
+
api_expects(:content_views, :index).
|
32
|
+
at_least_once.returns(index_response([{'id' => 1}])) do |p|
|
33
|
+
p['name'] == "lol" && p["organization_id"].to_s == "1"
|
34
|
+
end
|
35
|
+
|
36
|
+
run_cmd(@cmd + %w(--composite-content-view=lol --organization-label=org1))
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'name' do
|
40
|
+
api_expects(:organizations, :index) { |par| par[:search] == "name = \"org1\"" }
|
41
|
+
.at_least_once.returns(index_response([{'id' => 1}]))
|
42
|
+
|
43
|
+
api_expects(:content_view_components, :index) do |p|
|
44
|
+
p["composite_content_view_id"].to_s == "1"
|
45
|
+
end
|
46
|
+
|
47
|
+
api_expects(:content_views, :index).
|
48
|
+
at_least_once.returns(index_response([{'id' => 1}])) do |p|
|
49
|
+
p['name'] == "lol" && p["organization_id"].to_s == "1"
|
50
|
+
end
|
51
|
+
|
52
|
+
run_cmd(@cmd + %w(--composite-content-view=lol --organization=org1))
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,107 @@
|
|
1
|
+
require_relative '../../test_helper'
|
2
|
+
require 'hammer_cli_katello/content_view_component'
|
3
|
+
module HammerCLIKatello
|
4
|
+
describe ContentViewComponent::RemoveComponents do
|
5
|
+
before do
|
6
|
+
@cmd = %w(content-view component remove)
|
7
|
+
|
8
|
+
@component = OpenStruct.new(:id => 6, :name => "component")
|
9
|
+
@component2 = OpenStruct.new(:id => 7, :name => "component2")
|
10
|
+
|
11
|
+
@content_view_component = OpenStruct.new(:id => 1444,
|
12
|
+
:content_view => @component)
|
13
|
+
|
14
|
+
@content_view_component2 = OpenStruct.new(:id => 1445,
|
15
|
+
:content_view => @component2)
|
16
|
+
|
17
|
+
@composite = OpenStruct.new(:id => 2, :name => "composite",
|
18
|
+
:content_view_components => [@content_view_component])
|
19
|
+
@organization = OpenStruct.new(:id => 1, :name => "great", :label => "label")
|
20
|
+
@content_view_components = [@content_view_component, @content_view_component2]
|
21
|
+
end
|
22
|
+
|
23
|
+
def setup_org_expectations
|
24
|
+
org_expect = api_expects(:organizations, :index) do |par|
|
25
|
+
par[:search] == "name = \"#{@organization.name}\""
|
26
|
+
end
|
27
|
+
org_expect.at_least_once.returns(index_response([{'id' => @organization.id.to_s}]))
|
28
|
+
end
|
29
|
+
|
30
|
+
def setup_content_view_expectations(content_view)
|
31
|
+
cv_expect = api_expects(:content_views, :index) do |p|
|
32
|
+
p['name'] == content_view.name && p["organization_id"].to_s == @organization.id.to_s
|
33
|
+
end
|
34
|
+
cv_expect.at_least_once.returns(index_response([{"id" => content_view.id}]))
|
35
|
+
end
|
36
|
+
|
37
|
+
def setup_content_view_components_expectations
|
38
|
+
cvc_expect = api_expects(:content_view_components, :index) do |p|
|
39
|
+
p[:composite_content_view_id].to_s == @composite.id.to_s
|
40
|
+
end
|
41
|
+
ret = @content_view_components.map do |cvc|
|
42
|
+
{ "id" => cvc.id,
|
43
|
+
"content_view" => {"id" => cvc.content_view.id,
|
44
|
+
"name" => cvc.content_view.name}}
|
45
|
+
end
|
46
|
+
cvc_expect.at_least_once.returns(index_response(ret))
|
47
|
+
end
|
48
|
+
|
49
|
+
describe 'allows deleting component with' do
|
50
|
+
it 'id and component-ids' do
|
51
|
+
params = ["--composite-content-view-id=#{@composite.id}",
|
52
|
+
"--component-ids=#{@content_view_components.map(&:id).join(',')}"]
|
53
|
+
|
54
|
+
api_expects(:content_view_components, :remove_components) do |p|
|
55
|
+
component_ids = p['component_ids'].map(&:to_s)
|
56
|
+
p['composite_content_view_id'].to_s == @composite.id.to_s &&
|
57
|
+
component_ids.include?(@content_view_component.id.to_s) &&
|
58
|
+
component_ids.include?(@content_view_component2.id.to_s)
|
59
|
+
end
|
60
|
+
run_cmd(@cmd + params)
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'id and component-content-view-id' do
|
64
|
+
component_cv_ids = @content_view_components.map do |cvc|
|
65
|
+
cvc["content_view"]["id"]
|
66
|
+
end
|
67
|
+
|
68
|
+
params = ["--composite-content-view-id=#{@composite.id}",
|
69
|
+
"--component-content-view-ids=#{component_cv_ids.join(',')}"]
|
70
|
+
setup_content_view_components_expectations
|
71
|
+
|
72
|
+
api_expects(:content_view_components, :remove_components) do |p|
|
73
|
+
component_ids = p['component_ids'].map(&:to_s)
|
74
|
+
p['composite_content_view_id'].to_s == @composite.id.to_s &&
|
75
|
+
component_ids.include?(@content_view_component.id.to_s) &&
|
76
|
+
component_ids.include?(@content_view_component2.id.to_s)
|
77
|
+
end
|
78
|
+
run_cmd(@cmd + params)
|
79
|
+
end
|
80
|
+
|
81
|
+
it 'orgs and component-content-view-names' do
|
82
|
+
component_cv_names = @content_view_components.map do |cvc|
|
83
|
+
cvc["content_view"]["name"]
|
84
|
+
end
|
85
|
+
|
86
|
+
params = ["--composite-content-view=#{@composite.name}",
|
87
|
+
"--component-content-views=#{component_cv_names.join(',')}",
|
88
|
+
"--organization=#{@organization.name}"]
|
89
|
+
# 1) Should fetch the org using org name specified in --organization
|
90
|
+
# 2) Should fetch composite content view using name in --composite-content-view
|
91
|
+
# 3) Should fetch component content view using name in --component-content-view
|
92
|
+
|
93
|
+
setup_org_expectations
|
94
|
+
setup_content_view_expectations(@composite)
|
95
|
+
setup_content_view_components_expectations
|
96
|
+
|
97
|
+
api_expects(:content_view_components, :remove_components) do |p|
|
98
|
+
component_ids = p['component_ids'].map(&:to_s)
|
99
|
+
p['composite_content_view_id'].to_s == @composite.id.to_s &&
|
100
|
+
component_ids.include?(@content_view_component.id.to_s) &&
|
101
|
+
component_ids.include?(@content_view_component2.id.to_s)
|
102
|
+
end
|
103
|
+
run_cmd(@cmd + params)
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|