hammer_cli_katello 1.5.0 → 1.5.1
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 +79 -0
- data/lib/hammer_cli_katello/repository.rb +1 -1
- 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 +55 -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 +252 -0
- data/test/functional/content_export/content_export_helpers.rb +33 -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/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/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 +419 -4
@@ -0,0 +1,91 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '../../test_helper')
|
2
|
+
require File.join(File.dirname(__FILE__), '../content_view_helpers')
|
3
|
+
require File.join(File.dirname(__FILE__), '../../organization/organization_helpers')
|
4
|
+
|
5
|
+
module HammerCLIKatello
|
6
|
+
describe 'Filter::UpdateCommand' do
|
7
|
+
include ContentViewHelpers
|
8
|
+
include OrganizationHelpers
|
9
|
+
|
10
|
+
before do
|
11
|
+
@cmd = %w(content-view filter update)
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'accepts filter id' do
|
15
|
+
params = ['--id=1', '--new-name=valis']
|
16
|
+
|
17
|
+
api_expects(:content_view_filters, :update) do |par|
|
18
|
+
par['id'] == 1 && par['name'] == 'valis'
|
19
|
+
end
|
20
|
+
|
21
|
+
run_cmd(@cmd + params)
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'accepts filter name, content view name, description , and org name' do
|
25
|
+
params = ['--name=scanner', '--content-view=darkly', '--organization=pkd', '--new-name=ubik',
|
26
|
+
'--description=zoo']
|
27
|
+
|
28
|
+
expect_organization_search('pkd', 1)
|
29
|
+
expect_content_view_search(1, 'darkly', 1)
|
30
|
+
|
31
|
+
ex = api_expects(:content_view_filters, :index, 'Content view filters list') do |par|
|
32
|
+
par['content_view_id'] == 1 && par['name'] == 'scanner'
|
33
|
+
end
|
34
|
+
ex.returns(index_response([{'id' => '1'}]))
|
35
|
+
|
36
|
+
api_expects(:content_view_filters, :update) do |par|
|
37
|
+
par['id'] == '1' && par['name'] == 'ubik' && par['description'] == 'zoo'
|
38
|
+
end
|
39
|
+
|
40
|
+
run_cmd(@cmd + params)
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'accepts filter name, content view name, and org label' do
|
44
|
+
params = ['--name=scanner', '--content-view=darkly',
|
45
|
+
'--organization-label=pkd', '--new-name=ubik']
|
46
|
+
|
47
|
+
expect_organization_search('pkd', 1, field: 'label')
|
48
|
+
expect_content_view_search(1, 'darkly', 1)
|
49
|
+
|
50
|
+
ex = api_expects(:content_view_filters, :index, 'Content view filters list') do |par|
|
51
|
+
par['content_view_id'] == 1 && par['name'] == 'scanner'
|
52
|
+
end
|
53
|
+
ex.returns(index_response([{'id' => '1'}]))
|
54
|
+
|
55
|
+
api_expects(:content_view_filters, :update) do |par|
|
56
|
+
par['id'] == '1' && par['name'] == 'ubik'
|
57
|
+
end
|
58
|
+
|
59
|
+
run_cmd(@cmd + params)
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'accepts filter name, content view name, and org id' do
|
63
|
+
params = ['--name=scanner', '--content-view=darkly', '--organization-id=1', '--new-name=ubik']
|
64
|
+
|
65
|
+
expect_content_view_search('1', 'darkly', 1)
|
66
|
+
|
67
|
+
ex = api_expects(:content_view_filters, :index, 'Content view filters list') do |par|
|
68
|
+
par['content_view_id'] == 1 && par['name'] == 'scanner'
|
69
|
+
end
|
70
|
+
ex.returns(index_response([{'id' => '1'}]))
|
71
|
+
|
72
|
+
api_expects(:content_view_filters, :update) do |par|
|
73
|
+
par['id'] == '1' && par['name'] == 'ubik'
|
74
|
+
end
|
75
|
+
|
76
|
+
run_cmd(@cmd + params)
|
77
|
+
end
|
78
|
+
|
79
|
+
it 'requires content view name or id if name is supplied' do
|
80
|
+
params = ["--name=high-castle"]
|
81
|
+
expected_result = usage_error_result(
|
82
|
+
@cmd,
|
83
|
+
'At least one of options --content-view-id, --content-view is required.',
|
84
|
+
'Could not update the filter'
|
85
|
+
)
|
86
|
+
api_expects_no_call
|
87
|
+
result = run_cmd(@cmd + params)
|
88
|
+
assert_cmd(expected_result, result)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '../test_helper')
|
2
|
+
require File.join(File.dirname(__FILE__), '../lifecycle_environment/lifecycle_environment_helpers')
|
3
|
+
|
4
|
+
describe 'listing content-views' do
|
5
|
+
include LifecycleEnvironmentHelpers
|
6
|
+
|
7
|
+
before do
|
8
|
+
@cmd = %w(content-view list)
|
9
|
+
end
|
10
|
+
|
11
|
+
let(:org_id) { 1 }
|
12
|
+
let(:lifecycle_env_id) { 1 }
|
13
|
+
let(:empty_response) do
|
14
|
+
{
|
15
|
+
"total" => 0,
|
16
|
+
"subtotal" => 0,
|
17
|
+
"page" => "1",
|
18
|
+
"per_page" => "1000",
|
19
|
+
"error" => nil,
|
20
|
+
"search" => nil,
|
21
|
+
"sort" => {
|
22
|
+
"by" => nil,
|
23
|
+
"order" => nil
|
24
|
+
},
|
25
|
+
"results" => []
|
26
|
+
}
|
27
|
+
end
|
28
|
+
|
29
|
+
it "lists an organizations content-views" do
|
30
|
+
params = ["--organization-id=#{org_id}"]
|
31
|
+
|
32
|
+
ex = api_expects(:content_views, :index, 'Organizations content-views list') do |par|
|
33
|
+
par['organization_id'] == org_id && par['page'] == 1 &&
|
34
|
+
par['per_page'] == 1000
|
35
|
+
end
|
36
|
+
|
37
|
+
ex.returns(empty_response)
|
38
|
+
expected_result = success_result(
|
39
|
+
"----------------|------|-------|-----------|----------------|---------------
|
40
|
+
CONTENT VIEW ID | NAME | LABEL | COMPOSITE | LAST PUBLISHED | REPOSITORY IDS
|
41
|
+
----------------|------|-------|-----------|----------------|---------------
|
42
|
+
")
|
43
|
+
|
44
|
+
result = run_cmd(@cmd + params)
|
45
|
+
assert_cmd(expected_result, result)
|
46
|
+
end
|
47
|
+
|
48
|
+
it "lists the content-views belonging to a lifecycle-environment by name" do
|
49
|
+
params = ["--organization-id=#{org_id}", '--lifecycle-environment=test']
|
50
|
+
|
51
|
+
expect_lifecycle_environment_search(org_id, 'test', lifecycle_env_id)
|
52
|
+
|
53
|
+
ex = api_expects(:content_views, :index, 'lifecycles content-views list') do |par|
|
54
|
+
par['organization_id'] == org_id && par['page'] == 1 &&
|
55
|
+
par['per_page'] == 1000
|
56
|
+
end
|
57
|
+
|
58
|
+
ex.returns(empty_response)
|
59
|
+
expected_result = success_result(
|
60
|
+
"----------------|------|-------|-----------|----------------|---------------
|
61
|
+
CONTENT VIEW ID | NAME | LABEL | COMPOSITE | LAST PUBLISHED | REPOSITORY IDS
|
62
|
+
----------------|------|-------|-----------|----------------|---------------
|
63
|
+
")
|
64
|
+
|
65
|
+
result = run_cmd(@cmd + params)
|
66
|
+
assert_cmd(expected_result, result)
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require_relative '../test_helper'
|
2
|
+
require 'hammer_cli_katello/content_view'
|
3
|
+
|
4
|
+
module HammerCLIKatello
|
5
|
+
describe ContentView do
|
6
|
+
it 'allows major & minor' do
|
7
|
+
ex = api_expects(:organizations, :index) do |p|
|
8
|
+
p[:search] == "name = \"org1\""
|
9
|
+
end
|
10
|
+
ex.returns(index_response([{'id' => 1}]))
|
11
|
+
|
12
|
+
ex = api_expects(:content_views, :index) do |p|
|
13
|
+
p['name'] == 'cv' && p['organization_id'] == 1
|
14
|
+
end
|
15
|
+
ex.returns(index_response([{'id' => 3}]))
|
16
|
+
|
17
|
+
api_expects(:content_views, :publish) do |p|
|
18
|
+
p['id'] == 3 && p['major'] == 5 && p['minor'] == 1
|
19
|
+
end
|
20
|
+
|
21
|
+
run_cmd(%w(content-view publish --major 5 --minor 1 --organization org1 --name cv --async))
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,97 @@
|
|
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
|
+
require 'hammer_cli_katello/content_view_purge'
|
6
|
+
|
7
|
+
module HammerCLIKatello
|
8
|
+
describe ContentViewPurgeCommand do
|
9
|
+
include ForemanTaskHelpers
|
10
|
+
|
11
|
+
let(:versions) do
|
12
|
+
{'results' => [
|
13
|
+
{"id" => 23,
|
14
|
+
"version" => "1.0",
|
15
|
+
"content_view" => {"id" => 7, "name" => "test cv"},
|
16
|
+
"composite_content_views" => [{"id" => 14, "name" => "comp_view"}],
|
17
|
+
"composite_content_view_versions" => [],
|
18
|
+
"environments" => [{"id" => 1, "name" => "Library"}]},
|
19
|
+
{"id" => 34,
|
20
|
+
"version" => "2.0",
|
21
|
+
"content_view" => {"id" => 7, "name" => "test cv"},
|
22
|
+
"composite_content_views" => [],
|
23
|
+
"composite_content_view_versions" => [],
|
24
|
+
"environments" => []},
|
25
|
+
{"id" => 45,
|
26
|
+
"version" => "2.10",
|
27
|
+
"content_view" => {"id" => 7, "name" => "test cv"},
|
28
|
+
"composite_content_views" => [],
|
29
|
+
"composite_content_view_versions" => [],
|
30
|
+
"environments" => [{"id" => 1, "name" => "Library"}]},
|
31
|
+
{"id" => 56,
|
32
|
+
"version" => "3.0",
|
33
|
+
"content_view" => {"id" => 7, "name" => "test cv"},
|
34
|
+
"composite_content_views" => [{"id" => 14, "name" => "comp_view"}],
|
35
|
+
"composite_content_view_versions" => [],
|
36
|
+
"environments" => []},
|
37
|
+
{"id" => 67,
|
38
|
+
"version" => "7.0",
|
39
|
+
"content_view" => {"id" => 7, "name" => "test cv"},
|
40
|
+
"composite_content_views" => [],
|
41
|
+
"composite_content_view_versions" => [],
|
42
|
+
"environments" => []},
|
43
|
+
{"id" => 78,
|
44
|
+
"version" => "2.0",
|
45
|
+
"content_view" => {"id" => 7, "name" => "test cv"},
|
46
|
+
"composite_content_views" => [],
|
47
|
+
"composite_content_view_versions" => [{"id" => 87, "version" => "1.0"}],
|
48
|
+
"environments" => []}
|
49
|
+
]}
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'fails gracefully if count <= 0' do
|
53
|
+
api_expects_no_call
|
54
|
+
|
55
|
+
r = run_cmd(%w(content-view purge --id 2 --count -1))
|
56
|
+
assert(r.err.include?('Invalid value for --count option'), 'Incorrect error message')
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'fails gracefully when there are no versions to delete' do
|
60
|
+
ex = api_expects(:content_view_versions, :index)
|
61
|
+
ex = ex.with_params("content_view_id" => '2')
|
62
|
+
ex.returns(versions)
|
63
|
+
|
64
|
+
r = run_cmd(%w(content-view purge --id 2 --count 3))
|
65
|
+
assert(r.err.include?('No versions to delete.'), 'Incorrect error message')
|
66
|
+
end
|
67
|
+
|
68
|
+
it 'only deletes unassociated versions' do
|
69
|
+
ex = api_expects(:content_view_versions, :index)
|
70
|
+
ex = ex.with_params("content_view_id" => '2')
|
71
|
+
ex.returns(versions)
|
72
|
+
|
73
|
+
[34, 67].each do |version_id|
|
74
|
+
ex = api_expects(:content_view_versions, :destroy)
|
75
|
+
ex = ex.with_params("id" => version_id)
|
76
|
+
ex.returns('id' => '3', 'state' => 'stopped')
|
77
|
+
expect_foreman_task('3')
|
78
|
+
end
|
79
|
+
|
80
|
+
run_cmd(%w(content-view purge --id 2 --count 0))
|
81
|
+
end
|
82
|
+
|
83
|
+
it 'allows for async purge of versions' do
|
84
|
+
ex = api_expects(:content_view_versions, :index)
|
85
|
+
ex = ex.with_params("content_view_id" => '2')
|
86
|
+
ex.returns(versions)
|
87
|
+
|
88
|
+
[34, 67].each do |version_id|
|
89
|
+
ex = api_expects(:content_view_versions, :destroy)
|
90
|
+
ex = ex.with_params("id" => version_id)
|
91
|
+
ex.returns('id' => '3')
|
92
|
+
end
|
93
|
+
|
94
|
+
run_cmd(%w(content-view purge --id 2 --count 0 --async))
|
95
|
+
end
|
96
|
+
end
|
97
|
+
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::RemoveContentViewVersionCommand 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, 6])
|
16
|
+
api_expects(:content_views, :update) do |p|
|
17
|
+
p['id'] == '1' && p['component_ids'] == %w(1 3)
|
18
|
+
end
|
19
|
+
run_cmd(%w(content-view remove-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, 6])
|
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)
|
34
|
+
end
|
35
|
+
run_cmd(%w(content-view remove-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 remove-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, 3])
|
52
|
+
api_expects(:content_views, :update) do |p|
|
53
|
+
p['id'] == 2 && p['component_ids'] == %w(1 2)
|
54
|
+
end
|
55
|
+
run_cmd(%w(content-view remove-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, 3])
|
66
|
+
api_expects(:content_views, :update) do |p|
|
67
|
+
p['id'] == 2 && p['component_ids'] == %w(1 2)
|
68
|
+
end
|
69
|
+
run_cmd(%w(content-view remove-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, 3])
|
80
|
+
api_expects(:content_views, :update) do |p|
|
81
|
+
p['id'] == 2 && p['component_ids'] == %w(1 2)
|
82
|
+
end
|
83
|
+
run_cmd(%w(content-view remove-version --name cv2 --organization-label org1
|
84
|
+
--content-view-version-id 3))
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
require_relative '../test_helper'
|
2
|
+
require 'hammer_cli_katello/content_view'
|
3
|
+
|
4
|
+
module HammerCLIKatello
|
5
|
+
describe ContentView::RemoveCommand do
|
6
|
+
include ForemanTaskHelpers
|
7
|
+
|
8
|
+
describe 'content view version options' do
|
9
|
+
it 'allows removing versions by ID' do
|
10
|
+
ex = api_expects(:content_views, :remove) do |p|
|
11
|
+
p['id'] == 1 && p['content_view_version_ids'] == %w(6 7 8)
|
12
|
+
end
|
13
|
+
ex.returns(id: '9')
|
14
|
+
|
15
|
+
expect_foreman_task('9')
|
16
|
+
|
17
|
+
run_cmd(%w(content-view remove --id 1 --content-view-version-ids 6,7,8))
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'allows removing versions by version number' do
|
21
|
+
versions = %w(6.0 7.0 8.0)
|
22
|
+
ids = [6, 7, 8]
|
23
|
+
|
24
|
+
api_expects(:content_view_versions, :index).with_params(
|
25
|
+
'search' => %(version = "#{versions.join('" or version = "')}"),
|
26
|
+
'content_view_id' => 1
|
27
|
+
).returns(index_response(ids.map { |v| { 'id' => v } }))
|
28
|
+
|
29
|
+
api_expects(:content_views, :remove).with_params(
|
30
|
+
'id' => 1, 'content_view_version_ids' => ids
|
31
|
+
).returns(id: '9')
|
32
|
+
|
33
|
+
expect_foreman_task('9')
|
34
|
+
|
35
|
+
run_cmd(%w(content-view remove --id 1 --content-view-versions 6.0,7.0,8.0))
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe 'environment options' do
|
40
|
+
it 'allows removing versions by ID' do
|
41
|
+
ex = api_expects(:content_views, :remove) do |p|
|
42
|
+
p['id'] == 1 && p['environment_ids'] == %w(6 7 8)
|
43
|
+
end
|
44
|
+
ex.returns(id: '9')
|
45
|
+
|
46
|
+
expect_foreman_task('9')
|
47
|
+
|
48
|
+
run_cmd(%w(content-view remove --id 1 --environment-ids 6,7,8))
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'requires organization options when removing environments by name' do
|
52
|
+
api_expects_no_call
|
53
|
+
|
54
|
+
run_cmd(%w(content-view remove --id 1 --environments env6,env7,env8))
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'allows removing environments by name' do
|
58
|
+
environment_ids = [6, 7, 8]
|
59
|
+
all_environment_ids = [3, 4, 5, 6, 7, 8]
|
60
|
+
|
61
|
+
ex = api_expects(:lifecycle_environments, :index) do |p|
|
62
|
+
p['organization_id'] == '1'
|
63
|
+
end
|
64
|
+
ex.returns(index_response(all_environment_ids.map do |id|
|
65
|
+
{'id' => id, 'name' => "env#{id}"}
|
66
|
+
end))
|
67
|
+
|
68
|
+
ex = api_expects(:content_views, :remove) do |p|
|
69
|
+
p['id'] == 1 && p['environment_ids'] == environment_ids
|
70
|
+
end
|
71
|
+
ex.returns(id: '9')
|
72
|
+
|
73
|
+
expect_foreman_task('9')
|
74
|
+
|
75
|
+
run_cmd(%w(content-view remove --id 1 --environments env6,env7,env8 --organization-id 1))
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,53 @@
|
|
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::UpdateCommand do
|
8
|
+
include OrganizationHelpers
|
9
|
+
include ContentViewHelpers
|
10
|
+
|
11
|
+
it 'allows minimal options' do
|
12
|
+
api_expects(:content_views, :update) do |p|
|
13
|
+
p['id'] == 2
|
14
|
+
end
|
15
|
+
run_cmd(%w(content-view update --id 2))
|
16
|
+
end
|
17
|
+
|
18
|
+
describe 'OrganizationOptions' do
|
19
|
+
it 'requires organization if content view name is supplied' do
|
20
|
+
api_expects_no_call
|
21
|
+
result = run_cmd(%w(content-view update --name cv2))
|
22
|
+
assert(result.err[/--organization-id, --organization, --organization-label is required/],
|
23
|
+
"Organization option requirements are validated")
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'allows organization id' do
|
27
|
+
expect_content_view_search('1', 'cv2', 2)
|
28
|
+
api_expects(:content_views, :update) do |p|
|
29
|
+
p['id'] == 2
|
30
|
+
end
|
31
|
+
run_cmd(%w(content-view update --name cv2 --organization-id 1))
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'allows organization name' do
|
35
|
+
expect_organization_search('org1', 1)
|
36
|
+
expect_content_view_search(1, 'cv2', 2)
|
37
|
+
api_expects(:content_views, :update) do |p|
|
38
|
+
p['id'] == 2
|
39
|
+
end
|
40
|
+
run_cmd(%w(content-view update --name cv2 --organization org1))
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'allows organization label' do
|
44
|
+
expect_organization_search('org1', 1, field: 'label')
|
45
|
+
expect_content_view_search(1, 'cv2', 2)
|
46
|
+
api_expects(:content_views, :update) do |p|
|
47
|
+
p['id'] == 2
|
48
|
+
end
|
49
|
+
run_cmd(%w(content-view update --name cv2 --organization-label org1))
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,108 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '../../test_helper')
|
2
|
+
require File.join(File.dirname(__FILE__), '../../organization/organization_helpers')
|
3
|
+
require File.join(File.dirname(__FILE__),
|
4
|
+
'../../lifecycle_environment/lifecycle_environment_helpers')
|
5
|
+
|
6
|
+
describe 'content-view version incremental-update' do
|
7
|
+
include OrganizationHelpers
|
8
|
+
include LifecycleEnvironmentHelpers
|
9
|
+
include ForemanTaskHelpers
|
10
|
+
|
11
|
+
before do
|
12
|
+
@cmd = %w(content-view version incremental-update)
|
13
|
+
end
|
14
|
+
|
15
|
+
it "performs incremental update with no updates" do
|
16
|
+
params = ['--errata-ids=FOO2012', '--lifecycle-environment-ids=1,2,3',
|
17
|
+
'--content-view-version-id=5']
|
18
|
+
|
19
|
+
ex = api_expects(:content_view_versions, :incremental_update, 'Incremental Update') do |par|
|
20
|
+
par['update_hosts'].nil? &&
|
21
|
+
par[:content_view_version_environments][0][:environment_ids] == %w(1 2 3) &&
|
22
|
+
par[:content_view_version_environments][0][:content_view_version_id] == 5 &&
|
23
|
+
par['add_content']['errata_ids'] == ['FOO2012']
|
24
|
+
end
|
25
|
+
ex.returns('id' => '3', 'state' => 'stopped')
|
26
|
+
|
27
|
+
expect_foreman_task('3')
|
28
|
+
|
29
|
+
result = run_cmd(@cmd + params)
|
30
|
+
assert_equal(result.exit_code, 0)
|
31
|
+
end
|
32
|
+
|
33
|
+
it "performs incremental update with update all hosts" do
|
34
|
+
params = ['--update-all-hosts=true', '--errata-ids=FOO2012',
|
35
|
+
'--lifecycle-environment-ids=1,2,3', '--content-view-version-id=5']
|
36
|
+
|
37
|
+
ex = api_expects(:content_view_versions, :incremental_update, 'Incremental Update') do |par|
|
38
|
+
par['update_hosts']['included'][:search] == '' &&
|
39
|
+
par[:content_view_version_environments][0][:environment_ids] == %w(1 2 3) &&
|
40
|
+
par[:content_view_version_environments][0][:content_view_version_id] == 5 &&
|
41
|
+
par['add_content']['errata_ids'] == ['FOO2012']
|
42
|
+
end
|
43
|
+
ex.returns('id' => '3', 'state' => 'stopped')
|
44
|
+
|
45
|
+
expect_foreman_task('3')
|
46
|
+
|
47
|
+
result = run_cmd(@cmd + params)
|
48
|
+
assert_equal(result.exit_code, 0)
|
49
|
+
end
|
50
|
+
|
51
|
+
it "performs incremental update with no environment" do
|
52
|
+
params = ['--update-all-hosts=true', '--errata-ids=FOO2012', '--content-view-version-id=5']
|
53
|
+
|
54
|
+
ex = api_expects(:content_view_versions, :incremental_update, 'Incremental Update') do |par|
|
55
|
+
par['update_hosts']['included'][:search] == '' &&
|
56
|
+
par[:content_view_version_environments][0][:environment_ids].nil? &&
|
57
|
+
par[:content_view_version_environments][0][:content_view_version_id] == 5 &&
|
58
|
+
par['add_content']['errata_ids'] == ['FOO2012']
|
59
|
+
end
|
60
|
+
ex.returns('id' => '3', 'state' => 'stopped')
|
61
|
+
|
62
|
+
expect_foreman_task('3')
|
63
|
+
|
64
|
+
result = run_cmd(@cmd + params)
|
65
|
+
assert_equal(result.exit_code, 0)
|
66
|
+
end
|
67
|
+
|
68
|
+
it "performs incremental update with names" do
|
69
|
+
params = ['--update-all-hosts=true', '--errata-ids=FOO2012',
|
70
|
+
'--lifecycle-environments=trump,cruz,bernie',
|
71
|
+
'--content-view-version-id=5', '--organization=USA']
|
72
|
+
|
73
|
+
expect_organization_search('USA', 5)
|
74
|
+
expect_lifecycle_environments_request(5, [{'name' => 'trump', 'id' => 1},
|
75
|
+
{'name' => 'cruz', 'id' => 2},
|
76
|
+
{'name' => 'bernie', 'id' => 3}])
|
77
|
+
|
78
|
+
ex = api_expects(:content_view_versions, :incremental_update, 'Incremental Update') do |par|
|
79
|
+
par['update_hosts']['included'][:search] == '' &&
|
80
|
+
par[:content_view_version_environments][0][:environment_ids] == [1, 2, 3] &&
|
81
|
+
par[:content_view_version_environments][0][:content_view_version_id] == 5 &&
|
82
|
+
par['add_content']['errata_ids'] == ['FOO2012']
|
83
|
+
end
|
84
|
+
ex.returns('id' => '3', 'state' => 'stopped')
|
85
|
+
|
86
|
+
expect_foreman_task('3')
|
87
|
+
|
88
|
+
result = run_cmd(@cmd + params)
|
89
|
+
assert_equal(result.exit_code, 0)
|
90
|
+
end
|
91
|
+
|
92
|
+
it "performs incremental update with packages" do
|
93
|
+
params = ['--content-view-version-id=5', '--packages=bla', '--lifecycle-environment-ids=1']
|
94
|
+
|
95
|
+
expect_generic_search(
|
96
|
+
:packages, params: {search: "name = \"bla\""}, returns: {'id' => 15}
|
97
|
+
)
|
98
|
+
|
99
|
+
ex = api_expects(:content_view_versions, :incremental_update, 'Incremental Update') do |par|
|
100
|
+
par[:content_view_version_environments][0][:content_view_version_id] == 5 &&
|
101
|
+
par["add_content"]["package_ids"] == [15]
|
102
|
+
end
|
103
|
+
ex.returns('id' => '3', 'state' => 'stopped')
|
104
|
+
expect_foreman_task('3')
|
105
|
+
result = run_cmd(@cmd + params)
|
106
|
+
assert_equal(result.exit_code, 0)
|
107
|
+
end
|
108
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require_relative '../../test_helper'
|
2
|
+
require 'hammer_cli_katello/content_view_version'
|
3
|
+
|
4
|
+
module HammerCLIKatello
|
5
|
+
describe ContentViewVersion::ListCommand do
|
6
|
+
it 'allows minimal options' do
|
7
|
+
api_expects(:content_view_versions, :index)
|
8
|
+
|
9
|
+
run_cmd(%w(content-view version list))
|
10
|
+
end
|
11
|
+
|
12
|
+
describe 'allows organization' do
|
13
|
+
it 'id' do
|
14
|
+
api_expects(:content_view_versions, :index) do |p|
|
15
|
+
p['organization_id'] == 1
|
16
|
+
end
|
17
|
+
|
18
|
+
run_cmd(%w(content-view version list --organization-id 1))
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'name' do
|
22
|
+
api_expects(:organizations, :index) { |par| par[:search] == "name = \"org1\"" }
|
23
|
+
.at_least_once.returns(index_response([{'id' => 1}]))
|
24
|
+
|
25
|
+
api_expects(:content_view_versions, :index) do |p|
|
26
|
+
p['organization_id'] == 1
|
27
|
+
end
|
28
|
+
|
29
|
+
run_cmd(%w(content-view version list --organization org1))
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'label' do
|
33
|
+
api_expects(:organizations, :index) { |par| par[:search] == "label = \"org1\"" }
|
34
|
+
.at_least_once.returns(index_response([{'id' => 1}]))
|
35
|
+
|
36
|
+
api_expects(:content_view_versions, :index) do |p|
|
37
|
+
p['organization_id'] == 1
|
38
|
+
end
|
39
|
+
|
40
|
+
run_cmd(%w(content-view version list --organization-label org1))
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|