hammer_cli_katello 1.0.1 → 1.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (216) hide show
  1. checksums.yaml +4 -4
  2. data/lib/hammer_cli_katello/content_import.rb +16 -1
  3. data/lib/hammer_cli_katello/content_view_version.rb +0 -273
  4. data/lib/hammer_cli_katello/docker.rb +13 -0
  5. data/lib/hammer_cli_katello/docker_manifest.rb +53 -0
  6. data/lib/hammer_cli_katello/docker_tag.rb +40 -0
  7. data/lib/hammer_cli_katello/foreman_search_options_creators.rb +12 -0
  8. data/lib/hammer_cli_katello/host_collection_erratum.rb +10 -0
  9. data/lib/hammer_cli_katello/host_collection_package.rb +30 -0
  10. data/lib/hammer_cli_katello/host_collection_package_group.rb +30 -0
  11. data/lib/hammer_cli_katello/host_errata.rb +8 -0
  12. data/lib/hammer_cli_katello/host_package.rb +32 -0
  13. data/lib/hammer_cli_katello/host_package_group.rb +16 -0
  14. data/lib/hammer_cli_katello/id_resolver.rb +3 -1
  15. data/lib/hammer_cli_katello/organization.rb +10 -0
  16. data/lib/hammer_cli_katello/ping.rb +13 -5
  17. data/lib/hammer_cli_katello/repository.rb +21 -0
  18. data/lib/hammer_cli_katello/simple_content_access.rb +2 -0
  19. data/lib/hammer_cli_katello/version.rb +1 -1
  20. data/lib/hammer_cli_katello.rb +5 -1
  21. data/locale/hammer-cli-katello.pot +0 -25
  22. metadata +7 -419
  23. data/lib/hammer_cli_katello/cv_import_export_helper.rb +0 -187
  24. data/test/data/2.5/foreman_api.json +0 -1
  25. data/test/data/3.0/foreman_api.json +0 -1
  26. data/test/data/3.10/foreman_api.json +0 -1
  27. data/test/data/3.11/foreman_api.json +0 -1
  28. data/test/data/3.12/foreman_api.json +0 -1
  29. data/test/data/3.13/foreman_api.json +0 -1
  30. data/test/data/3.14/foreman_api.json +0 -1
  31. data/test/data/3.15/foreman_api.json +0 -1
  32. data/test/data/3.16/foreman_api.json +0 -1
  33. data/test/data/3.17/foreman_api.json +0 -1
  34. data/test/data/3.18/foreman_api.json +0 -1
  35. data/test/data/3.19/foreman_api.json +0 -1
  36. data/test/data/3.2/foreman_api.json +0 -1
  37. data/test/data/3.4/foreman_api.json +0 -1
  38. data/test/data/3.5/foreman_api.json +0 -1
  39. data/test/data/3.6/foreman_api.json +0 -1
  40. data/test/data/3.7/foreman_api.json +0 -1
  41. data/test/data/3.8/foreman_api.json +0 -1
  42. data/test/data/3.9/foreman_api.json +0 -1
  43. data/test/data/4.0/foreman_api.json +0 -1
  44. data/test/data/Readme.md +0 -5
  45. data/test/functional/activation_key/add_host_collection_test.rb +0 -62
  46. data/test/functional/activation_key/content_override_test.rb +0 -92
  47. data/test/functional/activation_key/create_test.rb +0 -33
  48. data/test/functional/activation_key/data/activation_key.json +0 -17
  49. data/test/functional/activation_key/info_test.rb +0 -29
  50. data/test/functional/activation_key/list_test.rb +0 -68
  51. data/test/functional/activation_key/product_content_test.rb +0 -23
  52. data/test/functional/activation_key/remove_host_collection_test.rb +0 -62
  53. data/test/functional/activation_key/subscriptions_test.rb +0 -71
  54. data/test/functional/activation_key/update_test.rb +0 -26
  55. data/test/functional/apipie_helper_test.rb +0 -31
  56. data/test/functional/capsule/capsule_helpers.rb +0 -13
  57. data/test/functional/capsule/content/add_lifecycle_environment_test.rb +0 -40
  58. data/test/functional/capsule/content/cancel_synchronization_test.rb +0 -42
  59. data/test/functional/capsule/content/capsule_content_helpers.rb +0 -24
  60. data/test/functional/capsule/content/data/library_env.json +0 -47
  61. data/test/functional/capsule/content/data/sync_status.json +0 -6
  62. data/test/functional/capsule/content/data/sync_tasks.json +0 -62
  63. data/test/functional/capsule/content/info_test.rb +0 -61
  64. data/test/functional/capsule/content/lifecycle_environments_test.rb +0 -19
  65. data/test/functional/capsule/content/remove_lifecycle_environment_test.rb +0 -40
  66. data/test/functional/capsule/content/synchronization_status_test.rb +0 -107
  67. data/test/functional/capsule/info_test.rb +0 -25
  68. data/test/functional/capsule/list_test.rb +0 -24
  69. data/test/functional/content_credentials/create_test.rb +0 -32
  70. data/test/functional/content_credentials/data/test_cert.json +0 -43
  71. data/test/functional/content_credentials/info_test.rb +0 -50
  72. data/test/functional/content_credentials/list_test.rb +0 -66
  73. data/test/functional/content_export/complete/library_test.rb +0 -155
  74. data/test/functional/content_export/complete/version_test.rb +0 -217
  75. data/test/functional/content_export/content_export_helpers.rb +0 -26
  76. data/test/functional/content_export/generate_metadata_test.rb +0 -64
  77. data/test/functional/content_export/incremental/library_test.rb +0 -172
  78. data/test/functional/content_export/incremental/version_test.rb +0 -268
  79. data/test/functional/content_export/list_test.rb +0 -64
  80. data/test/functional/content_import/library_test.rb +0 -85
  81. data/test/functional/content_import/metadata.json +0 -1
  82. data/test/functional/content_import/version_test.rb +0 -85
  83. data/test/functional/content_view/add_content_view_version_test.rb +0 -88
  84. data/test/functional/content_view/add_repository_test.rb +0 -21
  85. data/test/functional/content_view/component/add_test.rb +0 -177
  86. data/test/functional/content_view/component/list_test.rb +0 -55
  87. data/test/functional/content_view/component/remove_test.rb +0 -107
  88. data/test/functional/content_view/component/update_test.rb +0 -134
  89. data/test/functional/content_view/content_view_helpers.rb +0 -20
  90. data/test/functional/content_view/copy_test.rb +0 -53
  91. data/test/functional/content_view/create_test.rb +0 -34
  92. data/test/functional/content_view/delete_test.rb +0 -62
  93. data/test/functional/content_view/filter/create_test.rb +0 -57
  94. data/test/functional/content_view/filter/delete_test.rb +0 -90
  95. data/test/functional/content_view/filter/info_test.rb +0 -89
  96. data/test/functional/content_view/filter/list_test.rb +0 -98
  97. data/test/functional/content_view/filter/update_test.rb +0 -91
  98. data/test/functional/content_view/list_test.rb +0 -68
  99. data/test/functional/content_view/publish_test.rb +0 -24
  100. data/test/functional/content_view/purge_test.rb +0 -97
  101. data/test/functional/content_view/remove_content_view_version_test.rb +0 -88
  102. data/test/functional/content_view/remove_test.rb +0 -79
  103. data/test/functional/content_view/update_test.rb +0 -53
  104. data/test/functional/content_view/version/cv_import_export_helper_test.rb +0 -20
  105. data/test/functional/content_view/version/default_export_test.rb +0 -40
  106. data/test/functional/content_view/version/export_test.rb +0 -148
  107. data/test/functional/content_view/version/import_test.rb +0 -346
  108. data/test/functional/content_view/version/incremental_update_test.rb +0 -108
  109. data/test/functional/content_view/version/list_test.rb +0 -44
  110. data/test/functional/content_view/version/promote_test.rb +0 -34
  111. data/test/functional/content_view/version/republish_repositories_test.rb +0 -34
  112. data/test/functional/content_view/version/update_test.rb +0 -48
  113. data/test/functional/erratum/erratum_helpers.rb +0 -91
  114. data/test/functional/erratum/info_test.rb +0 -29
  115. data/test/functional/erratum/list_test.rb +0 -108
  116. data/test/functional/file/file_helpers.rb +0 -13
  117. data/test/functional/file/info_test.rb +0 -162
  118. data/test/functional/file/list_test.rb +0 -112
  119. data/test/functional/filter_rule/create_test.rb +0 -99
  120. data/test/functional/filter_rule/delete_test.rb +0 -104
  121. data/test/functional/filter_rule/filter_rule_helpers.rb +0 -12
  122. data/test/functional/filter_rule/info_test.rb +0 -104
  123. data/test/functional/filter_rule/list_test.rb +0 -91
  124. data/test/functional/filter_rule/update_test.rb +0 -104
  125. data/test/functional/host/errata/apply_test.rb +0 -45
  126. data/test/functional/host/errata/info_test.rb +0 -27
  127. data/test/functional/host/errata/list_test.rb +0 -49
  128. data/test/functional/host/errata/recalculate_test.rb +0 -40
  129. data/test/functional/host/extensions/create_test.rb +0 -95
  130. data/test/functional/host/extensions/data/host.json +0 -320
  131. data/test/functional/host/extensions/data/host_list.json +0 -117
  132. data/test/functional/host/extensions/info_test.rb +0 -35
  133. data/test/functional/host/extensions/list_test.rb +0 -21
  134. data/test/functional/host/extensions/update_test.rb +0 -70
  135. data/test/functional/host/host_helpers.rb +0 -8
  136. data/test/functional/host/subscription/attach_test.rb +0 -54
  137. data/test/functional/host/subscription/auto_attach_test.rb +0 -35
  138. data/test/functional/host/subscription/content_override_test.rb +0 -96
  139. data/test/functional/host/subscription/product_content_test.rb +0 -27
  140. data/test/functional/host/subscription/register_test.rb +0 -53
  141. data/test/functional/host/subscription/remove_test.rb +0 -52
  142. data/test/functional/host/subscription/unregister_test.rb +0 -37
  143. data/test/functional/host/traces/list_test.rb +0 -37
  144. data/test/functional/host/traces/resolve_test.rb +0 -31
  145. data/test/functional/host_collection/add_host_test.rb +0 -90
  146. data/test/functional/host_collection/content_api_expectations.rb +0 -35
  147. data/test/functional/host_collection/content_install_test.rb +0 -62
  148. data/test/functional/host_collection/content_remove_test.rb +0 -37
  149. data/test/functional/host_collection/content_update_test.rb +0 -37
  150. data/test/functional/host_collection/copy_test.rb +0 -64
  151. data/test/functional/host_collection/create_test.rb +0 -43
  152. data/test/functional/host_collection/delete_test.rb +0 -57
  153. data/test/functional/host_collection/hosts_test.rb +0 -39
  154. data/test/functional/host_collection/info_test.rb +0 -57
  155. data/test/functional/host_collection/list_test.rb +0 -63
  156. data/test/functional/host_collection/remove_host_test.rb +0 -90
  157. data/test/functional/host_collection/update_test.rb +0 -57
  158. data/test/functional/hostgroup/create_test.rb +0 -112
  159. data/test/functional/hostgroup/data/hostgroup.json +0 -50
  160. data/test/functional/hostgroup/info_test.rb +0 -33
  161. data/test/functional/hostgroup/update_test.rb +0 -120
  162. data/test/functional/lifecycle_environment/create_test.rb +0 -14
  163. data/test/functional/lifecycle_environment/lifecycle_environment_helpers.rb +0 -18
  164. data/test/functional/lifecycle_environment/list_test.rb +0 -38
  165. data/test/functional/lifecycle_environment/update_test.rb +0 -14
  166. data/test/functional/local_helper_test.rb +0 -30
  167. data/test/functional/module_stream/info_test.rb +0 -58
  168. data/test/functional/module_stream/list_test.rb +0 -53
  169. data/test/functional/organization/delete_test.rb +0 -26
  170. data/test/functional/organization/organization_helpers.rb +0 -10
  171. data/test/functional/package/list_test.rb +0 -158
  172. data/test/functional/package_group/list_test.rb +0 -38
  173. data/test/functional/ping_test.rb +0 -20
  174. data/test/functional/product/create_test.rb +0 -54
  175. data/test/functional/product/delete_test.rb +0 -41
  176. data/test/functional/product/info_test.rb +0 -33
  177. data/test/functional/product/list_test.rb +0 -58
  178. data/test/functional/product/product_helpers.rb +0 -24
  179. data/test/functional/product/remove_sync_plan_test.rb +0 -35
  180. data/test/functional/product/set_sync_plan_test.rb +0 -49
  181. data/test/functional/product/update_proxy.rb +0 -48
  182. data/test/functional/product/update_test.rb +0 -46
  183. data/test/functional/repository/create_test.rb +0 -21
  184. data/test/functional/repository/delete_test.rb +0 -95
  185. data/test/functional/repository/export_test.rb +0 -121
  186. data/test/functional/repository/info_test.rb +0 -156
  187. data/test/functional/repository/list_test.rb +0 -68
  188. data/test/functional/repository/remove_content_test.rb +0 -108
  189. data/test/functional/repository/repository_helpers.rb +0 -18
  190. data/test/functional/repository/synchronize_test.rb +0 -57
  191. data/test/functional/repository/update_test.rb +0 -149
  192. data/test/functional/repository/upload_test.rb +0 -345
  193. data/test/functional/repository_set/available_repositories_test.rb +0 -18
  194. data/test/functional/repository_set/disable_test.rb +0 -42
  195. data/test/functional/repository_set/enable_test.rb +0 -42
  196. data/test/functional/repository_set/info_test.rb +0 -17
  197. data/test/functional/repository_set/list_test.rb +0 -18
  198. data/test/functional/repository_set/repository_set_helpers.rb +0 -20
  199. data/test/functional/search_helpers.rb +0 -17
  200. data/test/functional/simple_content_access/disable_test.rb +0 -48
  201. data/test/functional/simple_content_access/enable_test.rb +0 -46
  202. data/test/functional/srpm/list_test.rb +0 -92
  203. data/test/functional/subscription/list_test.rb +0 -86
  204. data/test/functional/sync_plan/create_test.rb +0 -60
  205. data/test/functional/sync_plan/delete_test.rb +0 -46
  206. data/test/functional/sync_plan/info_test.rb +0 -37
  207. data/test/functional/sync_plan/list_test.rb +0 -31
  208. data/test/functional/sync_plan/sync_plan_helpers.rb +0 -8
  209. data/test/functional/sync_plan/update_test.rb +0 -44
  210. data/test/functional/test_helper.rb +0 -24
  211. data/test/task_helper.rb +0 -7
  212. data/test/test_helper.rb +0 -38
  213. data/test/unit/id_name_options_validator_test.rb +0 -96
  214. data/test/unit/id_resolver_test.rb +0 -58
  215. data/test/unit/messages_test.rb +0 -7
  216. data/test/unit/search_options_creators_test.rb +0 -145
@@ -1,346 +0,0 @@
1
- require File.join(File.dirname(__FILE__), '../../test_helper')
2
-
3
- describe 'content-view version import' do
4
- include ForemanTaskHelpers
5
-
6
- before do
7
- @cmd = %w(content-view version import)
8
- end
9
-
10
- it "performs import" do
11
- HammerCLIKatello::ContentViewVersion::ImportCommand
12
- .any_instance
13
- .expects(:validate_pulp3_not_enabled)
14
- .returns(true)
15
- params = [
16
- '--export-tar=/tmp/exports/export-2.tar',
17
- '--organization-id=1'
18
- ]
19
-
20
- File.expects(:exist?).with('/usr/share/foreman').returns(true)
21
- File.stubs(:exist?).with('/var/log/hammer/hammer.log._copy_').returns(false)
22
-
23
- File.expects(:exist?).with("/tmp/exports/export-2.tar").returns(true)
24
- Dir.expects(:chdir).with('/tmp/exports').returns(0)
25
- Dir.expects(:chdir).with('/tmp/exports/export-2').returns(0)
26
- File.expects(:read).with("/tmp/exports/export-2/export-2.json").returns(
27
- JSON.dump(
28
- 'name' => 'Foo View',
29
- 'major' => '5',
30
- 'minor' => '0',
31
- 'repositories' => [{
32
- 'label' => 'foo',
33
- 'rpm_filenames' => ['foo-1.0-1.el7']
34
- }]
35
- )
36
- )
37
-
38
- ex = api_expects(:content_views, :index)
39
- ex = ex.with_params('name' => 'Foo View', 'organization_id' => '1')
40
- ex.returns(
41
- 'results' => [{
42
- 'id' => '5',
43
- 'repositories' => [{'id' => '2', 'label' => 'foo'}],
44
- 'content_view' => {'name' => 'cv'}
45
- }]
46
- )
47
-
48
- ex = api_expects(:repositories, :index)
49
- ex = ex.with_params('organization_id' => '1', 'library' => true)
50
- ex.returns(
51
- 'results' => [{
52
- 'id' => '2',
53
- 'label' => 'foo'
54
- }]
55
- )
56
-
57
- ex = api_expects(:repositories, :sync)
58
- ex = ex.with_params('id' => '2', 'source_url' => "file:///tmp/exports/export-2/")
59
- ex.returns('id' => '2', 'state' => 'planned')
60
-
61
- expect_foreman_task('3')
62
-
63
- ex = api_expects(:content_views, :publish)
64
- ex = ex.with_params(
65
- 'id' => '5',
66
- 'major' => '5',
67
- 'minor' => '0',
68
- 'repos_units' => [{
69
- 'label' => 'foo',
70
- 'rpm_filenames' => ['foo-1.0-1.el7']
71
- }]
72
- )
73
- ex.returns('id' => '2', 'state' => 'planned')
74
-
75
- expect_foreman_task('3')
76
-
77
- result = run_cmd(@cmd + params)
78
- assert_equal(HammerCLI::EX_OK, result.exit_code)
79
- end
80
-
81
- it "performs composite import" do
82
- HammerCLIKatello::ContentViewVersion::ImportCommand
83
- .any_instance
84
- .expects(:validate_pulp3_not_enabled)
85
- .returns(true)
86
- params = [
87
- '--export-tar=/tmp/exports/export-999.tar',
88
- '--organization-id=1'
89
- ]
90
-
91
- File.expects(:exist?).with('/usr/share/foreman').returns(true)
92
- File.stubs(:exist?).with('/var/log/hammer/hammer.log._copy_').returns(false)
93
-
94
- File.expects(:exist?).with("/tmp/exports/export-999.tar").returns(true)
95
- Dir.expects(:chdir).with('/tmp/exports').returns(0)
96
- Dir.expects(:chdir).with('/tmp/exports/export-999').returns(0)
97
- File.expects(:read).with("/tmp/exports/export-999/export-999.json").returns(
98
- JSON.dump(
99
- 'name' => 'Foo Composite View',
100
- 'major' => '10',
101
- 'minor' => '0',
102
- 'composite_components' => ["berbere 55.32"]
103
- )
104
- )
105
-
106
- ex = api_expects(:content_views, :index)
107
- ex = ex.with_params('name' => 'berbere', 'organization_id' => '1')
108
- ex.returns(
109
- 'results' => [{'versions' => [{'version' => '10.0', 'id' => '654'},
110
- {'version' => '55.32', 'id' => '876'}]
111
- }]
112
- )
113
-
114
- ex = api_expects(:content_views, :index)
115
- ex = ex.with_params('name' => 'Foo Composite View', 'organization_id' => '1')
116
- ex.returns(
117
- 'results' => [{
118
- 'id' => '5',
119
- 'repositories' => [{'id' => '2', 'label' => 'foo'}],
120
- 'content_view' => {'name' => 'cv'}
121
- }]
122
- )
123
-
124
- ex = api_expects(:content_views, :update)
125
- ex = ex.with_params(
126
- 'id' => '5',
127
- 'component_ids' => ['876']
128
- )
129
- ex.returns('id' => '5', 'state' => 'planned')
130
-
131
- ex = api_expects(:content_views, :publish)
132
- ex = ex.with_params(
133
- 'id' => '5',
134
- 'major' => '10',
135
- 'minor' => '0'
136
- )
137
- ex.returns('id' => '2', 'state' => 'planned')
138
-
139
- expect_foreman_task('3')
140
-
141
- result = run_cmd(@cmd + params)
142
- assert_equal(HammerCLI::EX_OK, result.exit_code)
143
- end
144
-
145
- it "performs composite import, component not found" do
146
- HammerCLIKatello::ContentViewVersion::ImportCommand
147
- .any_instance
148
- .expects(:validate_pulp3_not_enabled)
149
- .returns(true)
150
- params = [
151
- '--export-tar=/tmp/exports/export-999.tar',
152
- '--organization-id=1'
153
- ]
154
-
155
- File.expects(:exist?).with('/usr/share/foreman').returns(true)
156
- File.stubs(:exist?).with('/var/log/hammer/hammer.log._copy_').returns(false)
157
-
158
- File.expects(:exist?).with("/tmp/exports/export-999.tar").returns(true)
159
- Dir.expects(:chdir).with('/tmp/exports').returns(0)
160
- Dir.expects(:chdir).with('/tmp/exports/export-999').returns(0)
161
- File.expects(:read).with("/tmp/exports/export-999/export-999.json").returns(
162
- JSON.dump(
163
- 'name' => 'Foo Composite View',
164
- 'major' => '10',
165
- 'minor' => '0',
166
- 'composite_components' => ["berbere 55.32", "unicorn 99.99"]
167
- )
168
- )
169
-
170
- ex = api_expects(:content_views, :index)
171
- ex = ex.with_params('name' => 'berbere', 'organization_id' => '1')
172
- ex.returns(
173
- 'results' => [{'versions' => [{'version' => '10.0', 'id' => '654'},
174
- {'version' => '55.32', 'id' => '876'}]
175
- }]
176
- )
177
-
178
- ex = api_expects(:content_views, :index)
179
- ex = ex.with_params('name' => 'unicorn', 'organization_id' => '1')
180
- ex.returns(
181
- 'results' => []
182
- )
183
-
184
- ex = api_expects(:content_views, :index)
185
- ex = ex.with_params('name' => 'Foo Composite View', 'organization_id' => '1')
186
- ex.returns(
187
- 'results' => [{
188
- 'id' => '5',
189
- 'repositories' => [{'id' => '2', 'label' => 'foo'}],
190
- 'content_view' => {'name' => 'cv'}
191
- }]
192
- )
193
-
194
- result = run_cmd(@cmd + params)
195
- assert_equal(HammerCLI::EX_SOFTWARE, result.exit_code)
196
- end
197
-
198
- it "fails import if cv has not been created" do
199
- HammerCLIKatello::ContentViewVersion::ImportCommand
200
- .any_instance
201
- .expects(:validate_pulp3_not_enabled)
202
- .returns(true)
203
- params = [
204
- '--export-tar=/tmp/exports/export-2.tar',
205
- '--organization-id=1'
206
- ]
207
-
208
- File.expects(:exist?).with('/usr/share/foreman').returns(true)
209
- File.stubs(:exist?).with('/var/log/hammer/hammer.log._copy_').returns(false)
210
-
211
- File.expects(:exist?).with("/tmp/exports/export-2.tar").returns(true)
212
- Dir.expects(:chdir).with('/tmp/exports').returns(0)
213
- Dir.expects(:chdir).with('/tmp/exports/export-2').returns(0)
214
- File.expects(:read).with("/tmp/exports/export-2/export-2.json").returns(
215
- JSON.dump(
216
- 'name' => 'Foo View'
217
- )
218
- )
219
-
220
- ex = api_expects(:content_views, :index)
221
- ex = ex.with_params('name' => 'Foo View', 'organization_id' => '1')
222
- ex.returns([])
223
-
224
- result = run_cmd(@cmd + params)
225
- assert_equal(HammerCLI::EX_SOFTWARE, result.exit_code)
226
- end
227
-
228
- it "fails import if repo is set to mirror-on-sync" do
229
- HammerCLIKatello::ContentViewVersion::ImportCommand
230
- .any_instance
231
- .expects(:validate_pulp3_not_enabled)
232
- .returns(true)
233
- params = [
234
- '--export-tar=/tmp/exports/export-2.tar',
235
- '--organization-id=1'
236
- ]
237
-
238
- File.expects(:exist?).with('/usr/share/foreman').returns(true)
239
- File.stubs(:exist?).with('/var/log/hammer/hammer.log._copy_').returns(false)
240
-
241
- File.expects(:exist?).with("/tmp/exports/export-2.tar").returns(true)
242
- Dir.expects(:chdir).with('/tmp/exports').returns(0)
243
- Dir.expects(:chdir).with('/tmp/exports/export-2').returns(0)
244
- File.expects(:read).with("/tmp/exports/export-2/export-2.json").returns(
245
- JSON.dump(
246
- 'name' => 'Foo View',
247
- 'major' => '2',
248
- 'minor' => '1'
249
- )
250
- )
251
-
252
- ex = api_expects(:content_views, :index)
253
- ex = ex.with_params('name' => 'Foo View', 'organization_id' => '1')
254
- ex.returns(
255
- 'results' => [{
256
- 'id' => '5',
257
- 'repositories' => [{'id' => '2', 'label' => 'foo', 'mirror_on_sync' => 'true'}],
258
- 'content_view' => {'name' => 'cv'}
259
- }]
260
- )
261
-
262
- result = run_cmd(@cmd + params)
263
- assert_equal(result.exit_code, 70)
264
- end
265
-
266
- it "fails import if cv version already exists" do
267
- HammerCLIKatello::ContentViewVersion::ImportCommand
268
- .any_instance
269
- .expects(:validate_pulp3_not_enabled)
270
- .returns(true)
271
- params = [
272
- '--export-tar=/tmp/exports/export-2.tar',
273
- '--organization-id=1'
274
- ]
275
-
276
- File.expects(:exist?).with('/usr/share/foreman').returns(true)
277
- File.stubs(:exist?).with('/var/log/hammer/hammer.log._copy_').returns(false)
278
-
279
- File.expects(:exist?).with("/tmp/exports/export-2.tar").returns(true)
280
- Dir.expects(:chdir).with('/tmp/exports').returns(0)
281
- Dir.expects(:chdir).with('/tmp/exports/export-2').returns(0)
282
- File.expects(:read).with("/tmp/exports/export-2/export-2.json").returns(
283
- JSON.dump(
284
- 'name' => 'Foo View',
285
- 'major' => '2',
286
- 'minor' => '1'
287
- )
288
- )
289
-
290
- ex = api_expects(:content_views, :index)
291
- ex = ex.with_params('name' => 'Foo View', 'organization_id' => '1')
292
- ex.returns(
293
- 'results' => [{
294
- 'id' => '5',
295
- 'content_view' => {'name' => 'cv'},
296
- 'versions' => [{'version' => '2.1', 'id' => '654'}]
297
- }]
298
- )
299
-
300
- result = run_cmd(@cmd + params)
301
- assert_equal(result.exit_code, 70)
302
- end
303
-
304
- it "fails import if any repository does not exist" do
305
- HammerCLIKatello::ContentViewVersion::ImportCommand
306
- .any_instance
307
- .expects(:validate_pulp3_not_enabled)
308
- .returns(true)
309
- params = [
310
- '--export-tar=/tmp/exports/export-2.tar',
311
- '--organization-id=1'
312
- ]
313
-
314
- File.expects(:exist?).with('/usr/share/foreman').returns(true)
315
- File.stubs(:exist?).with('/var/log/hammer/hammer.log._copy_').returns(false)
316
-
317
- File.expects(:exist?).with("/tmp/exports/export-2.tar").returns(true)
318
- Dir.expects(:chdir).with('/tmp/exports').returns(0)
319
- Dir.expects(:chdir).with('/tmp/exports/export-2').returns(0)
320
- File.expects(:read).with("/tmp/exports/export-2/export-2.json").returns(
321
- JSON.dump(
322
- 'name' => 'Foo View',
323
- 'repositories' => ['label' => 'foo'],
324
- 'major' => '2',
325
- 'minor' => '1'
326
- )
327
- )
328
-
329
- ex = api_expects(:content_views, :index)
330
- ex = ex.with_params('name' => 'Foo View', 'organization_id' => '1')
331
- ex.returns(
332
- 'results' => [{
333
- 'id' => '5',
334
- 'repositories' => [{'id' => '2', 'label' => 'foo'}],
335
- 'content_view' => {'name' => 'cv'}
336
- }]
337
- )
338
-
339
- ex = api_expects(:repositories, :index)
340
- ex = ex.with_params('organization_id' => '1', 'library' => true)
341
- ex.returns([])
342
-
343
- result = run_cmd(@cmd + params)
344
- assert_equal(HammerCLI::EX_SOFTWARE, result.exit_code)
345
- end
346
- end
@@ -1,108 +0,0 @@
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
@@ -1,44 +0,0 @@
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
@@ -1,34 +0,0 @@
1
- require_relative '../../test_helper'
2
-
3
- module HammerCLIKatello
4
- describe ContentViewVersion::PromoteCommand do
5
- it 'allows promoting a content view' do
6
- ex = api_expects(:organizations, :index) do |p|
7
- p[:search] == "name = \"org1\""
8
- end
9
- ex.at_least_once.returns(index_response([{'id' => 1}]))
10
-
11
- ex = api_expects(:content_views, :index) do |p|
12
- p['name'] == 'cv' && p['organization_id'] == 1
13
- end
14
- ex.returns(index_response([{'id' => 3}]))
15
-
16
- ex = api_expects(:content_view_versions, :index) do |p|
17
- p['version'] == '1' && p['content_view_id'] == 3
18
- end
19
- ex.returns(index_response([{'id' => 6}]))
20
-
21
- ex = api_expects(:lifecycle_environments, :index) do |p|
22
- p['organization_id'] == 1 && p['name'] == 'test'
23
- end
24
- ex.returns(index_response([{'id' => 9}]))
25
-
26
- api_expects(:content_view_versions, :promote) do |p|
27
- p['id'] == 6 && p['environment_ids'] == [9]
28
- end
29
-
30
- run_cmd(%w(content-view version promote --organization org1 --content-view cv
31
- --to-lifecycle-environment test --version 1 --async))
32
- end
33
- end
34
- end
@@ -1,34 +0,0 @@
1
- require_relative '../../test_helper'
2
-
3
- module HammerCLIKatello
4
- describe ContentViewVersion::RepublishRepositoriesCommand do
5
- include ForemanTaskHelpers
6
- include OrganizationHelpers
7
-
8
- it 'allows republishing repositories on a content view version' do
9
- expect_organization_search('org1', 1)
10
-
11
- ex = api_expects(:content_views, :index) do |p|
12
- p['name'] == 'cv' && p['organization_id'] == 1
13
- end
14
- ex.returns(index_response([{'id' => 3}]))
15
-
16
- ex = api_expects(:content_view_versions, :index) do |p|
17
- p['version'] == '1' && p['content_view_id'] == 3
18
- end
19
- ex.returns(index_response([{'id' => 6}]))
20
-
21
- ex = api_expects(:content_view_versions, :republish_repositories) do |p|
22
- p['id'] == 6
23
- end
24
- ex.returns('state' => 'pending', 'id' => '3')
25
-
26
- expect_foreman_task('3')
27
-
28
- result = run_cmd(%w(content-view version republish-repositories --organization org1
29
- --content-view cv --version 1))
30
-
31
- assert_equal(result.exit_code, 0)
32
- end
33
- end
34
- end
@@ -1,48 +0,0 @@
1
- require_relative '../../test_helper'
2
- require 'hammer_cli_katello/content_view_version'
3
-
4
- module HammerCLIKatello
5
- describe ContentViewVersion::UpdateCommand do
6
- include OrganizationHelpers
7
- it 'allows minimal options' do
8
- ex = api_expects(:content_view_versions, :update).with_params('description' => 'pizza')
9
- ex.returns('id' => '2', 'description' => 'pizza')
10
-
11
- result = run_cmd(%w(content-view version update --id 2 --description pizza))
12
- assert_equal(result.exit_code, 0)
13
- end
14
- end
15
-
16
- describe 'content view options' do
17
- it 'allows content view id with one version' do
18
- ex = api_expects(:content_view_versions, :index)
19
- ex.returns('id' => '1', 'content_view' => [{'id' => '2'}])
20
-
21
- ex = api_expects(:content_view_versions, :update).with_params('description' => 'pizza')
22
- ex.returns('id' => '1', 'description' => 'pizza', 'content_view' => [{'id' => '2'}])
23
-
24
- result = run_cmd(%w(content-view version update --description pizza --content-view-id 2))
25
- assert_equal(result.exit_code, 0)
26
- end
27
-
28
- it 'allows content view id with multiple versions' do
29
- ex = api_expects(:content_view_versions, :index)
30
- ex.returns('id' => '2', 'content_view' => [{'id' => '3'}])
31
-
32
- ex = api_expects(:content_view_versions, :update).with_params('description' => 'pizza')
33
- ex.returns('id' => '2', 'description' => 'pizza', 'content_view' => [{'id' => '3'}])
34
-
35
- result = run_cmd(%w(content-view version update --description pizza
36
- --content-view-id 3 --version 2))
37
- assert_equal(result.exit_code, 0)
38
- end
39
-
40
- it 'blocks update without description' do
41
- ex = api_expects(:content_view_versions, :index)
42
- ex.returns('id' => '1', 'content_view' => [{'id' => '2'}])
43
-
44
- result = run_cmd(%w(content-view version update --content-view-id 2))
45
- assert_equal(result.exit_code, 64)
46
- end
47
- end
48
- end