hammer_cli_katello 1.1.3 → 1.2.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/foreman_search_options_creators.rb +0 -12
- data/lib/hammer_cli_katello/host_collection.rb +6 -0
- data/lib/hammer_cli_katello/host_errata.rb +1 -1
- data/lib/hammer_cli_katello/repository.rb +0 -27
- data/lib/hammer_cli_katello/version.rb +1 -1
- 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/Readme.md +5 -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/version_test.rb +252 -0
- data/test/functional/content_export/content_export_helpers.rb +26 -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/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_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 +34 -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 +40 -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/delete_test.rb +26 -0
- data/test/functional/organization/info_test.rb +22 -0
- data/test/functional/organization/organization_helpers.rb +10 -0
- data/test/functional/package/list_test.rb +158 -0
- data/test/functional/package_group/list_test.rb +38 -0
- data/test/functional/ping_test.rb +59 -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/remove_content_test.rb +108 -0
- data/test/functional/repository/repository_helpers.rb +18 -0
- data/test/functional/repository/synchronize_test.rb +57 -0
- data/test/functional/repository/update_test.rb +149 -0
- data/test/functional/repository/upload_test.rb +345 -0
- data/test/functional/repository_set/available_repositories_test.rb +18 -0
- data/test/functional/repository_set/disable_test.rb +42 -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 +388 -6
@@ -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
|
@@ -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
|