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,134 @@
|
|
1
|
+
require_relative '../../test_helper'
|
2
|
+
require 'hammer_cli_katello/content_view_component'
|
3
|
+
# rubocop:disable Metrics/ModuleLength
|
4
|
+
module HammerCLIKatello
|
5
|
+
describe ContentViewComponent::UpdateCommand do
|
6
|
+
before do
|
7
|
+
@cmd = %w(content-view component update)
|
8
|
+
@component_version = OpenStruct.new(:id => 666, :version => "1.0")
|
9
|
+
@component = OpenStruct.new(:id => 6, :name => "component",
|
10
|
+
:content_view_version => @component_version)
|
11
|
+
@content_view_component = OpenStruct.new(:id => 1444,
|
12
|
+
:content_view => @component,
|
13
|
+
:content_view_version => @component_version)
|
14
|
+
|
15
|
+
@composite = OpenStruct.new(:id => 2, :name => "composite",
|
16
|
+
:content_view_components => [@content_view_component])
|
17
|
+
@organization = OpenStruct.new(:id => 1, :name => "great", :label => "label")
|
18
|
+
end
|
19
|
+
|
20
|
+
def setup_org_expectations
|
21
|
+
org_expect = api_expects(:organizations, :index) do |par|
|
22
|
+
par[:search] == "name = \"#{@organization.name}\""
|
23
|
+
end
|
24
|
+
org_expect.at_least_once.returns(index_response([{'id' => @organization.id.to_s}]))
|
25
|
+
end
|
26
|
+
|
27
|
+
def setup_content_view_expectations(content_view)
|
28
|
+
cv_expect = api_expects(:content_views, :index) do |p|
|
29
|
+
p['name'] == content_view.name && p["organization_id"].to_s == @organization.id.to_s
|
30
|
+
end
|
31
|
+
cv_expect.at_least_once.returns(index_response([{"id" => content_view.id}]))
|
32
|
+
end
|
33
|
+
|
34
|
+
def setup_content_view_components_expectations
|
35
|
+
cvc_expect = api_expects(:content_view_components, :index) do |p|
|
36
|
+
p[:composite_content_view_id].to_s == @composite.id.to_s
|
37
|
+
end
|
38
|
+
ret = {
|
39
|
+
"id" => @content_view_component.id,
|
40
|
+
"content_view" => {"id" => @content_view_component.content_view.id},
|
41
|
+
"content_view_version" => {"id" => @content_view_component.content_view_version.id}
|
42
|
+
}
|
43
|
+
|
44
|
+
cvc_expect.at_least_once.returns(index_response([ret]))
|
45
|
+
end
|
46
|
+
|
47
|
+
describe 'allows updating a component with' do
|
48
|
+
it 'id and component-content-view-id and latest=true' do
|
49
|
+
latest = true
|
50
|
+
params = ["--composite-content-view-id=#{@composite.id}",
|
51
|
+
"--id=#{@content_view_component.id}",
|
52
|
+
"--component-content-view-id=#{@component.id}",
|
53
|
+
"--latest"]
|
54
|
+
|
55
|
+
api_expects(:content_view_components, :update) do |p|
|
56
|
+
p['composite_content_view_id'].to_s == @composite.id.to_s &&
|
57
|
+
p['id'].to_s == @content_view_component.id.to_s &&
|
58
|
+
p['latest'] == latest &&
|
59
|
+
p['content_view_id'].to_s == @component.id.to_s &&
|
60
|
+
!p.key?('content_view_version_id')
|
61
|
+
end
|
62
|
+
run_cmd(@cmd + params)
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'id and component-content-view-version-id and latest=false' do
|
66
|
+
latest = false
|
67
|
+
params = ["--composite-content-view-id=#{@composite.id}",
|
68
|
+
"--id=#{@content_view_component.id}",
|
69
|
+
"--component-content-view-version-id=#{@component.content_view_version.id}"]
|
70
|
+
|
71
|
+
api_expects(:content_view_components, :update) do |p|
|
72
|
+
p['composite_content_view_id'].to_s == @composite.id.to_s &&
|
73
|
+
p['id'].to_s == @content_view_component.id.to_s &&
|
74
|
+
p['latest'] == latest &&
|
75
|
+
p['content_view_version_id'].to_s == @component.content_view_version.id.to_s &&
|
76
|
+
!p.key?('content_view_id')
|
77
|
+
end
|
78
|
+
run_cmd(@cmd + params)
|
79
|
+
end
|
80
|
+
|
81
|
+
it 'component-content-view-id and latest=true' do
|
82
|
+
latest = true
|
83
|
+
params = ["--composite-content-view-id=#{@composite.id}",
|
84
|
+
"--component-content-view-id=#{@component.id}",
|
85
|
+
"--latest"]
|
86
|
+
setup_content_view_components_expectations
|
87
|
+
api_expects(:content_view_components, :update) do |p|
|
88
|
+
p['composite_content_view_id'].to_s == @composite.id.to_s &&
|
89
|
+
p['id'].to_s == @content_view_component.id.to_s &&
|
90
|
+
p['latest'] == latest &&
|
91
|
+
p['content_view_id'].to_s == @component.id.to_s &&
|
92
|
+
!p.key?('content_view_version_id')
|
93
|
+
end
|
94
|
+
run_cmd(@cmd + params)
|
95
|
+
end
|
96
|
+
|
97
|
+
it 'by names and orgs' do
|
98
|
+
latest = false
|
99
|
+
params = ["--composite-content-view=#{@composite.name}",
|
100
|
+
"--component-content-view=#{@component.name}",
|
101
|
+
"--component-content-view-version=#{@component.content_view_version.version}",
|
102
|
+
"--organization=#{@organization.name}"]
|
103
|
+
# 1) Should fetch the org using org name specified in --organization
|
104
|
+
# 2) Should fetch composite content view using name in --composite-content-view
|
105
|
+
# 3) Should fetch component content view using name in --component-content-view
|
106
|
+
# 4) Should fetch the component_content_view_version_id
|
107
|
+
# using cv specified in --component-content-view-id and version specified in
|
108
|
+
# --component-content-view-version
|
109
|
+
# 5) Should set the component[:content_view_id] && component[:content_view_version_id]
|
110
|
+
# correctly
|
111
|
+
|
112
|
+
setup_org_expectations
|
113
|
+
setup_content_view_expectations(@component)
|
114
|
+
setup_content_view_expectations(@composite)
|
115
|
+
setup_content_view_components_expectations
|
116
|
+
cvv_expect = api_expects(:content_view_versions, :index) do |p|
|
117
|
+
p['content_view_id'].to_s == @component.id.to_s &&
|
118
|
+
p["version"].to_s == @component.content_view_version.version.to_s
|
119
|
+
end
|
120
|
+
cvv_expect.at_least_once.
|
121
|
+
returns(index_response([{'id' => @component.content_view_version.id}]))
|
122
|
+
|
123
|
+
api_expects(:content_view_components, :update) do |p|
|
124
|
+
p['composite_content_view_id'].to_s == @composite.id.to_s &&
|
125
|
+
p['id'].to_s == @content_view_component.id.to_s &&
|
126
|
+
p['latest'] == latest &&
|
127
|
+
p['content_view_id'].to_s == @component.id.to_s &&
|
128
|
+
p['content_view_version_id'].to_s == @component.content_view_version.id.to_s
|
129
|
+
end
|
130
|
+
run_cmd(@cmd + params)
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require_relative '../search_helpers'
|
2
|
+
|
3
|
+
module ContentViewHelpers
|
4
|
+
include SearchHelpers
|
5
|
+
|
6
|
+
def expect_content_view_search(org_id, name, id)
|
7
|
+
expect_generic_content_view_search(params: {'name' => name, 'organization_id' => org_id},
|
8
|
+
returns: {'id' => id})
|
9
|
+
end
|
10
|
+
|
11
|
+
def expect_generic_content_view_search(args)
|
12
|
+
expect_generic_search(:content_views, args)
|
13
|
+
end
|
14
|
+
|
15
|
+
def expect_content_view_version_search(params, returns)
|
16
|
+
expect_lenient_search(:content_view_versions,
|
17
|
+
params: params,
|
18
|
+
returns: returns)
|
19
|
+
end
|
20
|
+
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::CopyCommand do
|
8
|
+
include OrganizationHelpers
|
9
|
+
include ContentViewHelpers
|
10
|
+
|
11
|
+
it 'allows minimal options' do
|
12
|
+
api_expects(:content_views, :copy) do |p|
|
13
|
+
p['id'] == 2 && p['name'] == 'cv2-dup'
|
14
|
+
end
|
15
|
+
run_cmd(%w(content-view copy --id 2 --new-name cv2-dup))
|
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 copy --new-name cv2-dup --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, :copy) do |p|
|
29
|
+
p['id'] == 2 && p['name'] == 'cv2-dup'
|
30
|
+
end
|
31
|
+
run_cmd(%w(content-view copy --name cv2 --new-name cv2-dup --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, :copy) do |p|
|
38
|
+
p['id'] == 2 && p['name'] == 'cv2-dup'
|
39
|
+
end
|
40
|
+
run_cmd(%w(content-view copy --name cv2 --new-name cv2-dup --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, :copy) do |p|
|
47
|
+
p['id'] == 2 && p['name'] == 'cv2-dup'
|
48
|
+
end
|
49
|
+
run_cmd(%w(content-view copy --name cv2 --new-name cv2-dup --organization-label org1))
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require_relative '../test_helper'
|
2
|
+
|
3
|
+
describe 'content-view create' do
|
4
|
+
before do
|
5
|
+
@cmd = %w(content-view create)
|
6
|
+
@base_params = ["--organization-id=#{org_id}", "--name=#{name}"]
|
7
|
+
end
|
8
|
+
let(:error_heading) { "Could not create the content view" }
|
9
|
+
let(:name) { 'test-cv' }
|
10
|
+
let(:org_id) { 1 }
|
11
|
+
let(:repositories) do
|
12
|
+
[
|
13
|
+
{'id' => '1'},
|
14
|
+
{'id' => '2'},
|
15
|
+
{'id' => '3'}
|
16
|
+
]
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'creates the content view with repositories specified by ids' do
|
20
|
+
wanted = repositories.take(2)
|
21
|
+
ids = wanted.map { |repo| repo['id'] }
|
22
|
+
params = %W(--repository-ids=#{ids.join(',')})
|
23
|
+
|
24
|
+
api_expects(:content_views, :create, 'Create content view') do |par|
|
25
|
+
par['name'] == name &&
|
26
|
+
par['repository_ids'] == ids &&
|
27
|
+
par['organization_id'] == org_id
|
28
|
+
end
|
29
|
+
|
30
|
+
expected_result = success_result("Content view created.\n")
|
31
|
+
result = run_cmd(@cmd + @base_params + params)
|
32
|
+
assert_cmd(expected_result, result)
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,62 @@
|
|
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::DeleteCommand do
|
8
|
+
include OrganizationHelpers
|
9
|
+
include ContentViewHelpers
|
10
|
+
include ForemanTaskHelpers
|
11
|
+
|
12
|
+
it 'allows minimal options' do
|
13
|
+
ex = api_expects(:content_views, :destroy) do |p|
|
14
|
+
p['id'] == 2
|
15
|
+
end
|
16
|
+
ex.returns(id: '8')
|
17
|
+
expect_foreman_task('8')
|
18
|
+
run_cmd(%w(content-view delete --id 2))
|
19
|
+
end
|
20
|
+
|
21
|
+
describe 'OrganizationOptions' do
|
22
|
+
it 'requires organization if content view name is supplied' do
|
23
|
+
api_expects_no_call
|
24
|
+
result = run_cmd(%w(content-view delete --name cv2))
|
25
|
+
assert(result.err[/--organization-id, --organization, --organization-label is required/],
|
26
|
+
"Organization option requirements are validated")
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'allows organization id' do
|
30
|
+
expect_content_view_search('1', 'cv2', 2)
|
31
|
+
ex = api_expects(:content_views, :destroy) do |p|
|
32
|
+
p['id'] == 2
|
33
|
+
end
|
34
|
+
ex.returns(id: '8')
|
35
|
+
expect_foreman_task('8')
|
36
|
+
run_cmd(%w(content-view delete --name cv2 --organization-id 1))
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'allows organization name' do
|
40
|
+
expect_organization_search('org1', 1)
|
41
|
+
expect_content_view_search(1, 'cv2', 2)
|
42
|
+
ex = api_expects(:content_views, :destroy) do |p|
|
43
|
+
p['id'] == 2
|
44
|
+
end
|
45
|
+
ex.returns(id: '8')
|
46
|
+
expect_foreman_task('8')
|
47
|
+
run_cmd(%w(content-view delete --name cv2 --organization org1))
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'allows organization label' do
|
51
|
+
expect_organization_search('org1', 1, field: 'label')
|
52
|
+
expect_content_view_search(1, 'cv2', 2)
|
53
|
+
ex = api_expects(:content_views, :destroy) do |p|
|
54
|
+
p['id'] == 2
|
55
|
+
end
|
56
|
+
ex.returns(id: '8')
|
57
|
+
expect_foreman_task('8')
|
58
|
+
run_cmd(%w(content-view delete --name cv2 --organization-label org1))
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require_relative '../../test_helper'
|
2
|
+
require_relative '../../repository/repository_helpers'
|
3
|
+
|
4
|
+
describe 'content-view filter create' do
|
5
|
+
include RepositoryHelpers
|
6
|
+
before do
|
7
|
+
@cmd = %w(content-view filter create)
|
8
|
+
@base_params = ["--name=#{filter_name}", "--content-view-id=#{content_view_id}", "--type=rpm"]
|
9
|
+
end
|
10
|
+
|
11
|
+
let(:org_id) { 1 }
|
12
|
+
let(:filter_name) { 'test_filter' }
|
13
|
+
let(:content_view_id) { 1 }
|
14
|
+
let(:repositories) do
|
15
|
+
[
|
16
|
+
{'name' => 'repo-1', 'id' => 1},
|
17
|
+
{'name' => 'repo-2', 'id' => 2},
|
18
|
+
{'name' => 'repo-3', 'id' => 3}
|
19
|
+
]
|
20
|
+
end
|
21
|
+
let(:repo_ids) { repositories.map { |repo| repo['id'] } }
|
22
|
+
let(:repo_names) { repositories.map { |repo| repo['name'] } }
|
23
|
+
|
24
|
+
it 'creates a content-view filter with repository ids' do
|
25
|
+
ids = repo_ids.join(',')
|
26
|
+
params = %W(--repository-ids=#{ids})
|
27
|
+
|
28
|
+
api_expects(:content_view_filters, :create, 'Create content-view filter')
|
29
|
+
.with_params('name' => filter_name, 'repository_ids' => repo_ids.map(&:to_s))
|
30
|
+
.returns({})
|
31
|
+
|
32
|
+
expected_result = success_result("Filter created.\n")
|
33
|
+
result = run_cmd(@cmd + @base_params + params)
|
34
|
+
assert_cmd(expected_result, result)
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'creates a content-view filter with repository names' do
|
38
|
+
params = %W(--repositories=#{repo_names.join(',')} --product-id 3)
|
39
|
+
|
40
|
+
expect_generic_repositories_search({'names' => repo_names, 'product_id' => 3}, repositories)
|
41
|
+
|
42
|
+
api_expects(:content_view_filters, :create, "Create content-view filter")
|
43
|
+
.with_params('name' => filter_name, 'repository_ids' => repo_ids, 'type' => 'rpm')
|
44
|
+
|
45
|
+
expected_result = success_result("Filter created.\n")
|
46
|
+
result = run_cmd(@cmd + @base_params + params)
|
47
|
+
assert_cmd(expected_result, result)
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'should fail with no product specified' do
|
51
|
+
ids = repo_ids.join(',')
|
52
|
+
params = ["--repositories=#{ids}", "--name=#{filter_name}", \
|
53
|
+
"--content-view-id=#{content_view_id}", "--type=rpm"]
|
54
|
+
result = run_cmd(@cmd + params)
|
55
|
+
assert(result.err[/--product-id, --product is required/])
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,90 @@
|
|
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::DeleteCommand' do
|
7
|
+
include ContentViewHelpers
|
8
|
+
include OrganizationHelpers
|
9
|
+
|
10
|
+
before do
|
11
|
+
@cmd = %w(content-view filter delete)
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'accepts filter id' do
|
15
|
+
params = ['--id=1']
|
16
|
+
|
17
|
+
api_expects(:content_view_filters, :destroy) do |par|
|
18
|
+
par['id'] == 1
|
19
|
+
end
|
20
|
+
|
21
|
+
run_cmd(@cmd + params)
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'accepts filter name, content view name, and org name' do
|
25
|
+
params = ['--name=scanner', '--content-view=darkly', '--organization=pkd']
|
26
|
+
|
27
|
+
expect_organization_search('pkd', 1)
|
28
|
+
expect_content_view_search(1, 'darkly', 1)
|
29
|
+
|
30
|
+
ex = api_expects(:content_view_filters, :index, 'Content view filters list') do |par|
|
31
|
+
par['content_view_id'] == 1 && par['name'] == 'scanner'
|
32
|
+
end
|
33
|
+
ex.returns(index_response([{'id' => '1'}]))
|
34
|
+
|
35
|
+
api_expects(:content_view_filters, :destroy) do |par|
|
36
|
+
par['id'] == '1'
|
37
|
+
end
|
38
|
+
|
39
|
+
run_cmd(@cmd + params)
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'accepts filter name, content view name, and org label' do
|
43
|
+
params = ['--name=scanner', '--content-view=darkly', '--organization-label=pkd']
|
44
|
+
|
45
|
+
expect_organization_search('pkd', 1, field: 'label')
|
46
|
+
expect_content_view_search(1, 'darkly', 1)
|
47
|
+
|
48
|
+
ex = api_expects(:content_view_filters, :index, 'Content view filters list') do |par|
|
49
|
+
par['content_view_id'] == 1 && par['name'] == 'scanner'
|
50
|
+
end
|
51
|
+
ex.returns(index_response([{'id' => '1'}]))
|
52
|
+
|
53
|
+
api_expects(:content_view_filters, :destroy) do |par|
|
54
|
+
par['id'] == '1'
|
55
|
+
end
|
56
|
+
|
57
|
+
run_cmd(@cmd + params)
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'accepts filter name, content view name, and org id' do
|
61
|
+
params = ['--name=scanner', '--content-view=darkly', '--organization-id=1']
|
62
|
+
|
63
|
+
expect_content_view_search('1', 'darkly', 1)
|
64
|
+
|
65
|
+
ex = api_expects(:content_view_filters, :index, 'Content view filters list') do |par|
|
66
|
+
par['content_view_id'] == 1 && par['name'] == 'scanner'
|
67
|
+
end
|
68
|
+
ex.returns(index_response([{'id' => '1'}]))
|
69
|
+
|
70
|
+
api_expects(:content_view_filters, :destroy) do |par|
|
71
|
+
par['id'] == '1'
|
72
|
+
end
|
73
|
+
|
74
|
+
run_cmd(@cmd + params)
|
75
|
+
end
|
76
|
+
|
77
|
+
it 'requires organization name or id if content view name is supplied' do
|
78
|
+
params = ["--name=high-castle", "--content-view=grasshopper"]
|
79
|
+
expected_result = usage_error_result(
|
80
|
+
@cmd,
|
81
|
+
'At least one of options --organization-id, --organization, --organization-label ' \
|
82
|
+
'is required.',
|
83
|
+
'Could not delete the filter'
|
84
|
+
)
|
85
|
+
api_expects_no_call
|
86
|
+
result = run_cmd(@cmd + params)
|
87
|
+
assert_cmd(expected_result, result)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
@@ -0,0 +1,89 @@
|
|
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::InfoCommand' do
|
7
|
+
include ContentViewHelpers
|
8
|
+
include OrganizationHelpers
|
9
|
+
|
10
|
+
before do
|
11
|
+
@cmd = %w(content-view filter info)
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'accepts filter id' do
|
15
|
+
params = ['--id=1']
|
16
|
+
|
17
|
+
api_expects(:content_view_filters, :show) do |par|
|
18
|
+
par['id'] == 1
|
19
|
+
end
|
20
|
+
|
21
|
+
run_cmd(@cmd + params)
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'accepts filter name, content view name, and org name' do
|
25
|
+
params = ['--name=scanner', '--content-view=darkly', '--organization=pkd']
|
26
|
+
|
27
|
+
expect_organization_search('pkd', 1)
|
28
|
+
expect_content_view_search(1, 'darkly', 1)
|
29
|
+
|
30
|
+
ex = api_expects(:content_view_filters, :index, 'Content view filters list') do |par|
|
31
|
+
par['content_view_id'] == 1 && par['name'] == 'scanner'
|
32
|
+
end
|
33
|
+
ex.returns(index_response([{'id' => '1'}]))
|
34
|
+
|
35
|
+
api_expects(:content_view_filters, :show) do |par|
|
36
|
+
par['id'] == '1'
|
37
|
+
end
|
38
|
+
|
39
|
+
run_cmd(@cmd + params)
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'accepts filter name, content view name, and org label' do
|
43
|
+
params = ['--name=scanner', '--content-view=darkly', '--organization-label=pkd']
|
44
|
+
|
45
|
+
expect_organization_search('pkd', 1, field: 'label')
|
46
|
+
expect_content_view_search(1, 'darkly', 1)
|
47
|
+
|
48
|
+
ex = api_expects(:content_view_filters, :index, 'Content view filters list') do |par|
|
49
|
+
par['content_view_id'] == 1 && par['name'] == 'scanner'
|
50
|
+
end
|
51
|
+
ex.returns(index_response([{'id' => '1'}]))
|
52
|
+
|
53
|
+
api_expects(:content_view_filters, :show) do |par|
|
54
|
+
par['id'] == '1'
|
55
|
+
end
|
56
|
+
|
57
|
+
run_cmd(@cmd + params)
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'accepts filter name, content view name, and org id' do
|
61
|
+
params = ['--name=scanner', '--content-view=darkly', '--organization-id=1']
|
62
|
+
|
63
|
+
expect_content_view_search('1', 'darkly', 1)
|
64
|
+
|
65
|
+
ex = api_expects(:content_view_filters, :index, 'Content view filters list') do |par|
|
66
|
+
par['content_view_id'] == 1 && par['name'] == 'scanner'
|
67
|
+
end
|
68
|
+
ex.returns(index_response([{'id' => '1'}]))
|
69
|
+
|
70
|
+
api_expects(:content_view_filters, :show) do |par|
|
71
|
+
par['id'] == '1'
|
72
|
+
end
|
73
|
+
|
74
|
+
run_cmd(@cmd + params)
|
75
|
+
end
|
76
|
+
|
77
|
+
it 'requires organization name or id if content view name is supplied' do
|
78
|
+
params = ["--name=high-castle", "--content-view=grasshopper"]
|
79
|
+
expected_result = usage_error_result(
|
80
|
+
@cmd,
|
81
|
+
'At least one of options --organization-id, --organization, --organization-label ' \
|
82
|
+
'is required.'
|
83
|
+
)
|
84
|
+
api_expects_no_call
|
85
|
+
result = run_cmd(@cmd + params)
|
86
|
+
assert_cmd(expected_result, result)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
@@ -0,0 +1,98 @@
|
|
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
|
+
describe 'listing content view filters' do
|
6
|
+
include ContentViewHelpers
|
7
|
+
include OrganizationHelpers
|
8
|
+
|
9
|
+
before do
|
10
|
+
@cmd = %w(content-view filter list)
|
11
|
+
end
|
12
|
+
|
13
|
+
let(:org_id) { 1 }
|
14
|
+
let(:org_label) { 'Ubik' }
|
15
|
+
let(:cv_name) { "Trystero" }
|
16
|
+
let(:empty_response) do
|
17
|
+
{
|
18
|
+
"total" => 0,
|
19
|
+
"subtotal" => 0,
|
20
|
+
"page" => "1",
|
21
|
+
"per_page" => "1000",
|
22
|
+
"error" => nil,
|
23
|
+
"search" => nil,
|
24
|
+
"sort" => {
|
25
|
+
"by" => nil,
|
26
|
+
"order" => nil
|
27
|
+
},
|
28
|
+
"results" => []
|
29
|
+
}
|
30
|
+
end
|
31
|
+
|
32
|
+
it "lists content view filters" do
|
33
|
+
params = ["--content-view-id=1"]
|
34
|
+
|
35
|
+
ex = api_expects(:content_view_filters, :index, 'Content view filters list') do |par|
|
36
|
+
par['content_view_id'] == 1 && par['page'] == 1 && par['per_page'] == 1000
|
37
|
+
end
|
38
|
+
ex.returns(empty_response)
|
39
|
+
|
40
|
+
expected_result = success_result("----------|------|-------------|------|----------
|
41
|
+
FILTER ID | NAME | DESCRIPTION | TYPE | INCLUSION
|
42
|
+
----------|------|-------------|------|----------
|
43
|
+
")
|
44
|
+
|
45
|
+
result = run_cmd(@cmd + params)
|
46
|
+
assert_cmd(expected_result, result)
|
47
|
+
end
|
48
|
+
|
49
|
+
it "lists content view filters for a content view name and org id" do
|
50
|
+
params = ["--organization-id=#{org_id}", "--content-view=#{cv_name}"]
|
51
|
+
|
52
|
+
expect_content_view_search(org_id.to_s, cv_name, 1)
|
53
|
+
|
54
|
+
ex = api_expects(:content_view_filters, :index, 'Content view filters list') do |par|
|
55
|
+
par['content_view_id'] == 1 && par['page'] == 1 && par['per_page'] == 1000
|
56
|
+
end
|
57
|
+
ex.returns(empty_response)
|
58
|
+
|
59
|
+
expected_result = success_result("----------|------|-------------|------|----------
|
60
|
+
FILTER ID | NAME | DESCRIPTION | TYPE | INCLUSION
|
61
|
+
----------|------|-------------|------|----------
|
62
|
+
")
|
63
|
+
|
64
|
+
result = run_cmd(@cmd + params)
|
65
|
+
assert_cmd(expected_result, result)
|
66
|
+
end
|
67
|
+
|
68
|
+
it "lists content view filters for a content view name and org label" do
|
69
|
+
params = ["--organization-label=#{org_label}", "--content-view=#{cv_name}"]
|
70
|
+
|
71
|
+
expect_organization_search(org_label, org_id, field: 'label')
|
72
|
+
expect_content_view_search(org_id, cv_name, 1)
|
73
|
+
|
74
|
+
ex = api_expects(:content_view_filters, :index, 'Content view filters list') do |par|
|
75
|
+
par['content_view_id'] == 1 && par['page'] == 1 && par['per_page'] == 1000
|
76
|
+
end
|
77
|
+
ex.returns(empty_response)
|
78
|
+
|
79
|
+
expected_result = success_result("----------|------|-------------|------|----------
|
80
|
+
FILTER ID | NAME | DESCRIPTION | TYPE | INCLUSION
|
81
|
+
----------|------|-------------|------|----------
|
82
|
+
")
|
83
|
+
|
84
|
+
result = run_cmd(@cmd + params)
|
85
|
+
assert_cmd(expected_result, result)
|
86
|
+
end
|
87
|
+
|
88
|
+
it 'requires org name, label, or id if content view name is supplied' do
|
89
|
+
params = ["--content-view=#{cv_name}"]
|
90
|
+
expected_result = usage_error_result(
|
91
|
+
@cmd,
|
92
|
+
'At least one of options --organization-id, --organization, --organization-label is required.'
|
93
|
+
)
|
94
|
+
api_expects_no_call
|
95
|
+
result = run_cmd(@cmd + params)
|
96
|
+
assert_cmd(expected_result, result)
|
97
|
+
end
|
98
|
+
end
|