hammer_cli_katello 1.5.0 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (222) hide show
  1. checksums.yaml +4 -4
  2. data/lib/hammer_cli_katello/acs.rb +82 -0
  3. data/lib/hammer_cli_katello/activation_key.rb +8 -2
  4. data/lib/hammer_cli_katello/content_export.rb +39 -0
  5. data/lib/hammer_cli_katello/content_export_helper.rb +64 -6
  6. data/lib/hammer_cli_katello/host_subscription.rb +32 -0
  7. data/lib/hammer_cli_katello/organization.rb +4 -0
  8. data/lib/hammer_cli_katello/repository.rb +1 -1
  9. data/lib/hammer_cli_katello/simple_content_access.rb +10 -0
  10. data/lib/hammer_cli_katello/version.rb +1 -1
  11. data/lib/hammer_cli_katello.rb +5 -0
  12. data/test/data/2.5/foreman_api.json +1 -0
  13. data/test/data/3.0/foreman_api.json +1 -0
  14. data/test/data/3.10/foreman_api.json +1 -0
  15. data/test/data/3.11/foreman_api.json +1 -0
  16. data/test/data/3.12/foreman_api.json +1 -0
  17. data/test/data/3.13/foreman_api.json +1 -0
  18. data/test/data/3.14/foreman_api.json +1 -0
  19. data/test/data/3.15/foreman_api.json +1 -0
  20. data/test/data/3.16/foreman_api.json +1 -0
  21. data/test/data/3.17/foreman_api.json +1 -0
  22. data/test/data/3.18/foreman_api.json +1 -0
  23. data/test/data/3.19/foreman_api.json +1 -0
  24. data/test/data/3.2/foreman_api.json +1 -0
  25. data/test/data/3.4/foreman_api.json +1 -0
  26. data/test/data/3.5/foreman_api.json +1 -0
  27. data/test/data/3.6/foreman_api.json +1 -0
  28. data/test/data/3.7/foreman_api.json +1 -0
  29. data/test/data/3.8/foreman_api.json +1 -0
  30. data/test/data/3.9/foreman_api.json +1 -0
  31. data/test/data/4.0/foreman_api.json +1 -0
  32. data/test/data/4.1/foreman_api.json +1 -0
  33. data/test/data/4.3/foreman_api.json +1 -0
  34. data/test/data/4.4/foreman_api.json +1 -0
  35. data/test/data/4.5/foreman_api.json +1 -0
  36. data/test/data/4.6/foreman_api.json +1 -0
  37. data/test/data/Readme.md +5 -0
  38. data/test/functional/acs/create_test.rb +27 -0
  39. data/test/functional/acs/delete_test.rb +13 -0
  40. data/test/functional/acs/info_test.rb +94 -0
  41. data/test/functional/acs/list_test.rb +62 -0
  42. data/test/functional/acs/update_test.rb +23 -0
  43. data/test/functional/activation_key/add_host_collection_test.rb +62 -0
  44. data/test/functional/activation_key/content_override_test.rb +92 -0
  45. data/test/functional/activation_key/create_test.rb +33 -0
  46. data/test/functional/activation_key/data/activation_key.json +17 -0
  47. data/test/functional/activation_key/info_test.rb +29 -0
  48. data/test/functional/activation_key/list_test.rb +68 -0
  49. data/test/functional/activation_key/product_content_test.rb +23 -0
  50. data/test/functional/activation_key/remove_host_collection_test.rb +62 -0
  51. data/test/functional/activation_key/subscriptions_test.rb +74 -0
  52. data/test/functional/activation_key/update_test.rb +26 -0
  53. data/test/functional/apipie_helper_test.rb +31 -0
  54. data/test/functional/capsule/capsule_helpers.rb +13 -0
  55. data/test/functional/capsule/content/add_lifecycle_environment_test.rb +40 -0
  56. data/test/functional/capsule/content/cancel_synchronization_test.rb +42 -0
  57. data/test/functional/capsule/content/capsule_content_helpers.rb +24 -0
  58. data/test/functional/capsule/content/data/library_env.json +47 -0
  59. data/test/functional/capsule/content/data/sync_status.json +6 -0
  60. data/test/functional/capsule/content/data/sync_tasks.json +62 -0
  61. data/test/functional/capsule/content/info_test.rb +61 -0
  62. data/test/functional/capsule/content/lifecycle_environments_test.rb +19 -0
  63. data/test/functional/capsule/content/remove_lifecycle_environment_test.rb +40 -0
  64. data/test/functional/capsule/content/synchronization_status_test.rb +107 -0
  65. data/test/functional/capsule/info_test.rb +25 -0
  66. data/test/functional/capsule/list_test.rb +24 -0
  67. data/test/functional/content_credentials/create_test.rb +32 -0
  68. data/test/functional/content_credentials/data/test_cert.json +43 -0
  69. data/test/functional/content_credentials/info_test.rb +50 -0
  70. data/test/functional/content_credentials/list_test.rb +66 -0
  71. data/test/functional/content_export/complete/library_test.rb +155 -0
  72. data/test/functional/content_export/complete/repository_test.rb +226 -0
  73. data/test/functional/content_export/complete/version_test.rb +297 -0
  74. data/test/functional/content_export/content_export_helpers.rb +33 -0
  75. data/test/functional/content_export/generate_listing_test.rb +62 -0
  76. data/test/functional/content_export/generate_metadata_test.rb +64 -0
  77. data/test/functional/content_export/incremental/library_test.rb +172 -0
  78. data/test/functional/content_export/incremental/repository_test.rb +212 -0
  79. data/test/functional/content_export/incremental/version_test.rb +268 -0
  80. data/test/functional/content_export/list_test.rb +64 -0
  81. data/test/functional/content_import/library_test.rb +85 -0
  82. data/test/functional/content_import/list_test.rb +65 -0
  83. data/test/functional/content_import/metadata.json +1 -0
  84. data/test/functional/content_import/version_test.rb +85 -0
  85. data/test/functional/content_units/info_test.rb +29 -0
  86. data/test/functional/content_units/list_test.rb +106 -0
  87. data/test/functional/content_view/add_content_view_version_test.rb +88 -0
  88. data/test/functional/content_view/add_repository_test.rb +21 -0
  89. data/test/functional/content_view/component/add_test.rb +177 -0
  90. data/test/functional/content_view/component/list_test.rb +55 -0
  91. data/test/functional/content_view/component/remove_test.rb +107 -0
  92. data/test/functional/content_view/component/update_test.rb +134 -0
  93. data/test/functional/content_view/content_view_helpers.rb +20 -0
  94. data/test/functional/content_view/copy_test.rb +53 -0
  95. data/test/functional/content_view/create_test.rb +34 -0
  96. data/test/functional/content_view/delete_test.rb +62 -0
  97. data/test/functional/content_view/filter/create_test.rb +57 -0
  98. data/test/functional/content_view/filter/delete_test.rb +90 -0
  99. data/test/functional/content_view/filter/info_test.rb +89 -0
  100. data/test/functional/content_view/filter/list_test.rb +98 -0
  101. data/test/functional/content_view/filter/update_test.rb +91 -0
  102. data/test/functional/content_view/list_test.rb +68 -0
  103. data/test/functional/content_view/publish_test.rb +24 -0
  104. data/test/functional/content_view/purge_test.rb +97 -0
  105. data/test/functional/content_view/remove_content_view_version_test.rb +88 -0
  106. data/test/functional/content_view/remove_test.rb +79 -0
  107. data/test/functional/content_view/update_test.rb +53 -0
  108. data/test/functional/content_view/version/incremental_update_test.rb +108 -0
  109. data/test/functional/content_view/version/list_test.rb +44 -0
  110. data/test/functional/content_view/version/promote_test.rb +75 -0
  111. data/test/functional/content_view/version/republish_repositories_test.rb +34 -0
  112. data/test/functional/content_view/version/update_test.rb +48 -0
  113. data/test/functional/erratum/erratum_helpers.rb +91 -0
  114. data/test/functional/erratum/info_test.rb +29 -0
  115. data/test/functional/erratum/list_test.rb +108 -0
  116. data/test/functional/file/file_helpers.rb +13 -0
  117. data/test/functional/file/info_test.rb +162 -0
  118. data/test/functional/file/list_test.rb +112 -0
  119. data/test/functional/filter_rule/create_test.rb +99 -0
  120. data/test/functional/filter_rule/delete_test.rb +104 -0
  121. data/test/functional/filter_rule/filter_rule_helpers.rb +12 -0
  122. data/test/functional/filter_rule/info_test.rb +104 -0
  123. data/test/functional/filter_rule/list_test.rb +91 -0
  124. data/test/functional/filter_rule/update_test.rb +104 -0
  125. data/test/functional/host/errata/apply_test.rb +45 -0
  126. data/test/functional/host/errata/info_test.rb +27 -0
  127. data/test/functional/host/errata/list_test.rb +49 -0
  128. data/test/functional/host/errata/recalculate_test.rb +26 -0
  129. data/test/functional/host/extensions/create_test.rb +95 -0
  130. data/test/functional/host/extensions/data/host.json +320 -0
  131. data/test/functional/host/extensions/data/host_list.json +117 -0
  132. data/test/functional/host/extensions/info_test.rb +35 -0
  133. data/test/functional/host/extensions/list_test.rb +21 -0
  134. data/test/functional/host/extensions/update_test.rb +70 -0
  135. data/test/functional/host/host_helpers.rb +8 -0
  136. data/test/functional/host/subscription/attach_test.rb +54 -0
  137. data/test/functional/host/subscription/auto_attach_test.rb +35 -0
  138. data/test/functional/host/subscription/content_override_test.rb +96 -0
  139. data/test/functional/host/subscription/enabled_repositories_test.rb +39 -0
  140. data/test/functional/host/subscription/product_content_test.rb +27 -0
  141. data/test/functional/host/subscription/register_test.rb +53 -0
  142. data/test/functional/host/subscription/remove_test.rb +52 -0
  143. data/test/functional/host/subscription/unregister_test.rb +37 -0
  144. data/test/functional/host/traces/list_test.rb +37 -0
  145. data/test/functional/host/traces/resolve_test.rb +31 -0
  146. data/test/functional/host_collection/add_host_test.rb +90 -0
  147. data/test/functional/host_collection/content_api_expectations.rb +35 -0
  148. data/test/functional/host_collection/content_install_test.rb +62 -0
  149. data/test/functional/host_collection/content_remove_test.rb +37 -0
  150. data/test/functional/host_collection/content_update_test.rb +37 -0
  151. data/test/functional/host_collection/copy_test.rb +64 -0
  152. data/test/functional/host_collection/create_test.rb +54 -0
  153. data/test/functional/host_collection/delete_test.rb +57 -0
  154. data/test/functional/host_collection/hosts_test.rb +39 -0
  155. data/test/functional/host_collection/info_test.rb +57 -0
  156. data/test/functional/host_collection/list_test.rb +63 -0
  157. data/test/functional/host_collection/remove_host_test.rb +90 -0
  158. data/test/functional/host_collection/update_test.rb +57 -0
  159. data/test/functional/hostgroup/create_test.rb +112 -0
  160. data/test/functional/hostgroup/data/hostgroup.json +50 -0
  161. data/test/functional/hostgroup/info_test.rb +33 -0
  162. data/test/functional/hostgroup/update_test.rb +120 -0
  163. data/test/functional/lifecycle_environment/create_test.rb +14 -0
  164. data/test/functional/lifecycle_environment/lifecycle_environment_helpers.rb +18 -0
  165. data/test/functional/lifecycle_environment/list_test.rb +38 -0
  166. data/test/functional/lifecycle_environment/update_test.rb +14 -0
  167. data/test/functional/local_helper_test.rb +30 -0
  168. data/test/functional/module_stream/info_test.rb +58 -0
  169. data/test/functional/module_stream/list_test.rb +53 -0
  170. data/test/functional/organization/cdn_configuration_test.rb +45 -0
  171. data/test/functional/organization/delete_test.rb +26 -0
  172. data/test/functional/organization/info_test.rb +45 -0
  173. data/test/functional/organization/organization_helpers.rb +10 -0
  174. data/test/functional/package/list_test.rb +160 -0
  175. data/test/functional/package_group/list_test.rb +38 -0
  176. data/test/functional/ping_test.rb +61 -0
  177. data/test/functional/product/create_test.rb +54 -0
  178. data/test/functional/product/delete_test.rb +41 -0
  179. data/test/functional/product/info_test.rb +33 -0
  180. data/test/functional/product/list_test.rb +58 -0
  181. data/test/functional/product/product_helpers.rb +24 -0
  182. data/test/functional/product/remove_sync_plan_test.rb +35 -0
  183. data/test/functional/product/set_sync_plan_test.rb +49 -0
  184. data/test/functional/product/update_proxy.rb +48 -0
  185. data/test/functional/product/update_test.rb +46 -0
  186. data/test/functional/repository/create_test.rb +21 -0
  187. data/test/functional/repository/delete_test.rb +95 -0
  188. data/test/functional/repository/info_test.rb +156 -0
  189. data/test/functional/repository/list_test.rb +68 -0
  190. data/test/functional/repository/reclaim_space_test.rb +105 -0
  191. data/test/functional/repository/remove_content_test.rb +108 -0
  192. data/test/functional/repository/repository_helpers.rb +18 -0
  193. data/test/functional/repository/republish_test.rb +37 -0
  194. data/test/functional/repository/synchronize_test.rb +57 -0
  195. data/test/functional/repository/update_test.rb +150 -0
  196. data/test/functional/repository/upload_test.rb +368 -0
  197. data/test/functional/repository_set/available_repositories_test.rb +18 -0
  198. data/test/functional/repository_set/disable_test.rb +48 -0
  199. data/test/functional/repository_set/enable_test.rb +42 -0
  200. data/test/functional/repository_set/info_test.rb +17 -0
  201. data/test/functional/repository_set/list_test.rb +18 -0
  202. data/test/functional/repository_set/repository_set_helpers.rb +20 -0
  203. data/test/functional/search_helpers.rb +17 -0
  204. data/test/functional/simple_content_access/disable_test.rb +48 -0
  205. data/test/functional/simple_content_access/enable_test.rb +46 -0
  206. data/test/functional/simple_content_access/status_test.rb +29 -0
  207. data/test/functional/srpm/list_test.rb +92 -0
  208. data/test/functional/subscription/list_test.rb +86 -0
  209. data/test/functional/sync_plan/create_test.rb +60 -0
  210. data/test/functional/sync_plan/delete_test.rb +46 -0
  211. data/test/functional/sync_plan/info_test.rb +37 -0
  212. data/test/functional/sync_plan/list_test.rb +31 -0
  213. data/test/functional/sync_plan/sync_plan_helpers.rb +8 -0
  214. data/test/functional/sync_plan/update_test.rb +44 -0
  215. data/test/functional/test_helper.rb +24 -0
  216. data/test/task_helper.rb +7 -0
  217. data/test/test_helper.rb +38 -0
  218. data/test/unit/id_name_options_validator_test.rb +96 -0
  219. data/test/unit/id_resolver_test.rb +58 -0
  220. data/test/unit/messages_test.rb +7 -0
  221. data/test/unit/search_options_creators_test.rb +145 -0
  222. metadata +425 -4
@@ -0,0 +1,74 @@
1
+ require_relative '../test_helper'
2
+ require 'hammer_cli_katello/activation_key'
3
+
4
+ module HammerCLIKatello
5
+ describe ActivationKeyCommand::SubscriptionsCommand do
6
+ it 'requires organization options' do
7
+ expected_error = "Could not find organization"
8
+ result = run_cmd(%w(activation-key subscriptions --name test))
9
+ assert_equal(result.err[/#{expected_error}/], expected_error)
10
+ end
11
+
12
+ it 'allows organization name' do
13
+ api_expects(:organizations, :index) { |par| par[:search] == "name = \"org1\"" }
14
+ .returns(index_response([{'id' => 1}]))
15
+
16
+ api_expects(:subscriptions, :index) { |par| par['organization_id'].to_i == 1 }
17
+
18
+ run_cmd(%w(activation-key subscriptions --id 1 --organization org1))
19
+ end
20
+
21
+ it 'allows organization label' do
22
+ api_expects(:organizations, :index) { |par| par[:search] == "label = \"org1\"" }
23
+ .returns(index_response([{'id' => 1}]))
24
+
25
+ api_expects(:subscriptions, :index) { |par| par['organization_id'].to_i == 1 }
26
+
27
+ run_cmd(%w(activation-key subscriptions --id 1 --organization-label org1))
28
+ end
29
+
30
+ it 'lists subscriptions available for the activation key' do
31
+ api_expects(:subscriptions, :index) do |p|
32
+ p['available_for'] == 'activation_key'
33
+ end
34
+ run_cmd(%w(activation-key subscriptions --organization-id 1 --id 1
35
+ --available-for activation_key))
36
+ end
37
+
38
+ it 'lists subscriptions used by the activation key' do
39
+ api_expects(:subscriptions, :index) { |p| p['activation_key_id'] == '1' }
40
+ run_cmd(%w(activation-key subscriptions --organization-id 1 --id 1))
41
+ end
42
+
43
+ it 'allows activation_key_name' do
44
+ api_expects(:activation_keys, :index) { |p| p['name'] == 'ak1' }
45
+ .returns(index_response([{'id' => 1}]))
46
+ api_expects(:subscriptions, :index) { |p| p['activation_key_id'] == 1 }
47
+ run_cmd(%w(activation-key subscriptions --organization-id 1 --name ak1))
48
+ end
49
+
50
+ it 'allows a subscription to be added to an activation key' do
51
+ api_expects(:activation_keys, :add_subscriptions) do |p|
52
+ p['id'] == 1 && p['subscription_id'] == 3
53
+ end
54
+ run_cmd(%w(activation-key add-subscription --id 1 --subscription-id 3))
55
+ end
56
+
57
+ it 'allows a subscription to be added by name to an activation key with org label' do
58
+ api_expects(:organizations, :index) { |par| par[:search] == "label = \"org1\"" }
59
+ .returns(index_response([{'id' => 1}]))
60
+ api_expects(:subscriptions, :index) { |p| p['name'] == 'sub' }
61
+ .returns(index_response([{'name' => 'sub'}]))
62
+ api_expects(:activation_keys, :add_subscriptions) { |p| p['id'] == 1 }
63
+ run_cmd(%w(activation-key add-subscription --id 1 --subscription sub
64
+ --organization-label org1))
65
+ end
66
+
67
+ it 'allows multiple subscriptions to be added to an activation key' do
68
+ api_expects(:activation_keys, :add_subscriptions) do |p|
69
+ p['id'] == 1 && p['subscriptions'] == [{'id' => '3'}, {'id' => '4'}]
70
+ end
71
+ run_cmd(%w(activation-key add-subscription --id 1 --subscriptions id=3,id=4))
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,26 @@
1
+ require_relative '../test_helper'
2
+ require 'hammer_cli_katello/activation_key'
3
+
4
+ module HammerCLIKatello
5
+ describe ActivationKeyCommand do
6
+ describe UpdateCommand do
7
+ it 'allows promoting a content view' do
8
+ ex = api_expects(:organizations, :index) do |p|
9
+ p[:search] == "name = \"org1\""
10
+ end
11
+ ex.at_least_once.returns(index_response([{'id' => 1}]))
12
+
13
+ ex = api_expects(:activation_keys, :index) do |p|
14
+ p['name'] == 'ak' && p['organization_id'] == 1
15
+ end
16
+ ex.returns(index_response([{'id' => 6}]))
17
+
18
+ api_expects(:activation_keys, :update) do |p|
19
+ p['id'] == 6 && p['organization_id'] == 1
20
+ end
21
+
22
+ run_cmd(%w(activation-key update --organization org1 --name ak --auto-attach false))
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,31 @@
1
+ require File.join(File.dirname(__FILE__), '../test_helper')
2
+
3
+ describe 'apipie helper' do
4
+ before do
5
+ class ApipieTestHelper
6
+ include HammerCLIKatello::ApipieHelper
7
+ end
8
+
9
+ @apipie_helper = ApipieTestHelper.new
10
+ end
11
+
12
+ it "calls show method apipie resource" do
13
+ api_expects(:repositories, :show).with_params('id' => '1').returns({})
14
+ assert @apipie_helper.show(:repositories, 'id' => '1')
15
+ end
16
+
17
+ it "calls index method apipie resource" do
18
+ api_expects(:repositories, :index).with_params('name' => 'foo').returns('results' => [])
19
+ assert @apipie_helper.index(:repositories, 'name' => 'foo')
20
+ end
21
+
22
+ it "calls destroy method apipie resource" do
23
+ api_expects(:repositories, :destroy).with_params('id' => '1').returns({})
24
+ assert @apipie_helper.destroy(:repositories, 'id' => '1')
25
+ end
26
+
27
+ it "call method for apipie resources works" do
28
+ api_expects(:repositories, :index).with_params('name' => 'foo').returns('results' => [])
29
+ assert @apipie_helper.call(:index, :repositories, 'name' => 'foo')
30
+ end
31
+ end
@@ -0,0 +1,13 @@
1
+ require_relative '../search_helpers'
2
+
3
+ module CapsuleHelpers
4
+ include SearchHelpers
5
+
6
+ def expect_generic_capsule_search(opts = {params: {}, returns: {}})
7
+ expect_generic_search(:smart_proxies, opts)
8
+ end
9
+
10
+ def expect_capsule_info(params = {})
11
+ api_expects(:smart_proxies, :show).with_params(params)
12
+ end
13
+ end
@@ -0,0 +1,40 @@
1
+ require_relative '../../test_helper'
2
+ require_relative 'capsule_content_helpers'
3
+ require_relative '../../lifecycle_environment/lifecycle_environment_helpers'
4
+ require_relative '../../organization/organization_helpers'
5
+ require 'hammer_cli_katello/capsule'
6
+
7
+ module HammerCLIKatello
8
+ module Capsule
9
+ class Content
10
+ describe Content::AddLifecycleEnvironmentCommand do
11
+ include CapsuleContentHelpers
12
+ include LifecycleEnvironmentHelpers
13
+ include OrganizationHelpers
14
+
15
+ it 'allows minimal options' do
16
+ expect_lifecycle_environment_add('id' => 1, 'environment_id' => 2)
17
+
18
+ run_cmd(%w(capsule content add-lifecycle-environment --id 1 --environment-id 2))
19
+ end
20
+
21
+ it 'resolves environment ID from name' do
22
+ expect_lifecycle_environment_search('3', 'env2', 2)
23
+ expect_lifecycle_environment_add('id' => 1, 'environment_id' => 2)
24
+
25
+ run_cmd(%w(capsule content add-lifecycle-environment --id 1 --environment env2
26
+ --organization-id 3))
27
+ end
28
+
29
+ it 'resolves organization ID from name' do
30
+ expect_organization_search('org3', 3)
31
+ expect_lifecycle_environment_search(3, 'env2', 2)
32
+ expect_lifecycle_environment_add('id' => 1, 'environment_id' => 2)
33
+
34
+ run_cmd(%w(capsule content add-lifecycle-environment --id 1 --environment env2
35
+ --organization org3))
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,42 @@
1
+ require File.join(File.dirname(__FILE__), '../../test_helper')
2
+ require File.join(File.dirname(__FILE__), './capsule_content_helpers')
3
+
4
+ describe 'capsule content cancel-synchronization' do
5
+ include CapsuleContentHelpers
6
+
7
+ before do
8
+ @cmd = ['capsule', 'content', 'cancel-synchronization']
9
+ end
10
+
11
+ MESSAGE = "There's no running synchronization for this capsule.".freeze
12
+
13
+ it "triggers the cancel" do
14
+ expected_result = success_result("#{MESSAGE}\n")
15
+ params = ['--id=3']
16
+
17
+ ex = api_expects(:capsule_content, :cancel_sync, 'Cancel sync') do |par|
18
+ par['id'] == 3
19
+ end
20
+ ex.returns("message" => MESSAGE)
21
+
22
+ result = run_cmd(@cmd + params)
23
+ assert_cmd(expected_result, result)
24
+ end
25
+
26
+ it "resolves id from name" do
27
+ params = ['--name=capsule1']
28
+
29
+ ex = api_expects(:capsule_content, :cancel_sync, 'Cancel sync') do |par|
30
+ par['id'] == 3
31
+ end
32
+ ex.returns("message" => MESSAGE)
33
+ expect_capsule_search('capsule1', 3)
34
+
35
+ run_cmd(@cmd + params)
36
+ end
37
+
38
+ it "is mounted under proxy too" do
39
+ result = run_cmd(['proxy', 'content', 'cancel-synchronization', '-h'])
40
+ assert_exit_code_equal(HammerCLI::EX_OK, result.exit_code)
41
+ end
42
+ end
@@ -0,0 +1,24 @@
1
+ require_relative '../capsule_helpers'
2
+
3
+ module CapsuleContentHelpers
4
+ include CapsuleHelpers
5
+
6
+ def expect_capsule_search(name, id)
7
+ expect_generic_capsule_search(params: {search: "name = \"#{name}\""}, returns: {'id' => id})
8
+ end
9
+
10
+ def expect_lifecycle_environments_list(args = {params: {}, returns: []})
11
+ api_expects(:capsule_content, :lifecycle_environments)
12
+ .with_params(args[:params]).returns(index_response(args[:returns]))
13
+ end
14
+
15
+ def expect_lifecycle_environment_add(params = {})
16
+ api_expects(:capsule_content, :add_lifecycle_environment)
17
+ .with_params(params)
18
+ end
19
+
20
+ def expect_lifecycle_environment_remove(params = {})
21
+ api_expects(:capsule_content, :remove_lifecycle_environment)
22
+ .with_params(params)
23
+ end
24
+ end
@@ -0,0 +1,47 @@
1
+ {
2
+ "library": true,
3
+ "id": 3,
4
+ "name": "Library",
5
+ "label": "Library",
6
+ "description": null,
7
+ "organization": {
8
+ "name": "Default Organization",
9
+ "label": "Default_Organization",
10
+ "id": 1
11
+ },
12
+ "syncable": true,
13
+ "counts": {
14
+ "content_hosts": 0,
15
+ "content_views": 1,
16
+ "products": 3,
17
+ "yum_repositories": 1,
18
+ "packages": 32,
19
+ "package_groups": 2,
20
+ "errata": 4,
21
+ "puppet_repositories": 0,
22
+ "puppet_modules": 0,
23
+ "docker_repositories": 0,
24
+ "docker_images": 0
25
+ },
26
+ "content_views": [
27
+ {
28
+ "id": 3,
29
+ "label": "CV1",
30
+ "name": "CV1",
31
+ "composite": false,
32
+ "last_published": "2016-01-08 15:44:10 +0100",
33
+ "counts": {
34
+ "content_hosts": 0,
35
+ "products": 3,
36
+ "yum_repositories": 1,
37
+ "packages": 32,
38
+ "package_groups": 2,
39
+ "errata": 4,
40
+ "puppet_repositories": 0,
41
+ "puppet_modules": 0,
42
+ "docker_repositories": 0,
43
+ "docker_images": 0
44
+ }
45
+ }
46
+ ]
47
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "last_sync_time": "2016-01-10 00:27:51 +0100",
3
+ "active_sync_tasks": [],
4
+ "last_failed_sync_tasks": [],
5
+ "lifecycle_environments": []
6
+ }
@@ -0,0 +1,62 @@
1
+ {
2
+ "failed1": {
3
+ "id": "ab3e2ae3-fbed-466d-81fc-37130fc9efaa",
4
+ "label": "Actions::Katello::ContentView::CapsuleGenerateAndSync",
5
+ "pending": true,
6
+ "started_at": "2016-01-16 05:13:33 +0100",
7
+ "ended_at": null,
8
+ "state": "paused",
9
+ "result": "error",
10
+ "progress": 0.3,
11
+ "humanized": {
12
+ "action": "Generate Capsule Metadata and Sync",
13
+ "errors": [
14
+ "404 Resource Not Found"
15
+ ]
16
+ }
17
+ },
18
+ "failed2": {
19
+ "id": "ab3e2ae3-fbed-466d-81fc-37130fc9efbb",
20
+ "label": "Actions::Katello::ContentView::CapsuleGenerateAndSync",
21
+ "pending": true,
22
+ "started_at": "2016-01-16 05:13:33 +0100",
23
+ "ended_at": null,
24
+ "state": "paused",
25
+ "result": "error",
26
+ "progress": 0.5,
27
+ "humanized": {
28
+ "action": "Generate Capsule Metadata and Sync",
29
+ "errors": [
30
+ "404 Resource Not Found"
31
+ ]
32
+ }
33
+ },
34
+ "running": {
35
+ "id": "a484eb0d-b40d-4c4c-b187-bb6291d78652",
36
+ "label": "Actions::Katello::CapsuleContent::Sync",
37
+ "pending": true,
38
+ "started_at": "2016-01-16 05:14:16 +0100",
39
+ "ended_at": null,
40
+ "state": "pending",
41
+ "result": "success",
42
+ "progress": 0.6666666666666666,
43
+ "humanized": {
44
+ "action": "Synchronize capsule content",
45
+ "errors": []
46
+ }
47
+ },
48
+ "successful": {
49
+ "id": "a484eb0d-b40d-4c4c-b187-bb6291d78652",
50
+ "label": "Actions::Katello::CapsuleContent::Sync",
51
+ "pending": true,
52
+ "started_at": "2016-01-16 05:14:16 +0100",
53
+ "ended_at": null,
54
+ "state": "paused",
55
+ "result": "error",
56
+ "progress": 0.5,
57
+ "humanized": {
58
+ "action": "Synchronize capsule content",
59
+ "errors": []
60
+ }
61
+ }
62
+ }
@@ -0,0 +1,61 @@
1
+ require File.join(File.dirname(__FILE__), '../../test_helper')
2
+ require File.join(File.dirname(__FILE__), './capsule_content_helpers')
3
+
4
+ describe 'capsule content info' do
5
+ include CapsuleContentHelpers
6
+
7
+ before do
8
+ @cmd = %w(capsule content info)
9
+ end
10
+ let(:params) { ['--id=3'] }
11
+
12
+ it "lists content counts" do
13
+ @sync_status = load_json('./data/sync_status.json', __FILE__)
14
+ @sync_status['lifecycle_environments'] = [
15
+ load_json('./data/library_env.json', __FILE__)
16
+ ]
17
+
18
+ ex = api_expects(:capsule_content, :sync_status, 'Get sync info') do |par|
19
+ par['id'] == 3
20
+ end
21
+ ex.returns(@sync_status)
22
+
23
+ output = OutputMatcher.new([
24
+ "Lifecycle Environments:",
25
+ " 1) Name: Library",
26
+ " Organization: Default Organization",
27
+ " Content Views:",
28
+ " 1) Name: CV1",
29
+ " Composite: no",
30
+ " Last Published: 2016/01/08 15:44:10",
31
+ " Content:",
32
+ " Hosts: 0",
33
+ " Products: 3",
34
+ " Yum repos: 1",
35
+ " Container Image repos: 0",
36
+ " Packages: 32",
37
+ " Package groups: 2",
38
+ " Errata: 4"
39
+ ])
40
+ expected_result = success_result(output)
41
+
42
+ result = run_cmd(@cmd + params)
43
+ assert_cmd(expected_result, result)
44
+ end
45
+
46
+ it "resolves id from name" do
47
+ params = ['--name=capsule1']
48
+
49
+ api_expects(:capsule_content, :sync_status, 'Get sync info') do |par|
50
+ par['id'] == 3
51
+ end
52
+ expect_capsule_search('capsule1', 3)
53
+
54
+ run_cmd(@cmd + params)
55
+ end
56
+
57
+ it "is mounted under proxy too" do
58
+ result = run_cmd(['proxy', 'content', 'info', '-h'])
59
+ assert_exit_code_equal(HammerCLI::EX_OK, result.exit_code)
60
+ end
61
+ end
@@ -0,0 +1,19 @@
1
+ require_relative '../../test_helper'
2
+ require_relative 'capsule_content_helpers'
3
+ require 'hammer_cli_katello/capsule'
4
+
5
+ module HammerCLIKatello
6
+ module Capsule
7
+ class Content
8
+ describe Content::ListLifecycleEnvironmentsCommand do
9
+ include CapsuleContentHelpers
10
+
11
+ it 'allows minimal options' do
12
+ expect_lifecycle_environments_list(params: {'id' => 1}, returns: {})
13
+
14
+ run_cmd(%w(capsule content lifecycle-environments --id 1))
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,40 @@
1
+ require_relative '../../test_helper'
2
+ require_relative 'capsule_content_helpers'
3
+ require_relative '../../lifecycle_environment/lifecycle_environment_helpers'
4
+ require_relative '../../organization/organization_helpers'
5
+ require 'hammer_cli_katello/capsule'
6
+
7
+ module HammerCLIKatello
8
+ module Capsule
9
+ class Content
10
+ describe Content::RemoveLifecycleEnvironmentCommand do
11
+ include CapsuleContentHelpers
12
+ include LifecycleEnvironmentHelpers
13
+ include OrganizationHelpers
14
+
15
+ it 'allows minimal options' do
16
+ expect_lifecycle_environment_remove('id' => 1, 'environment_id' => 2)
17
+
18
+ run_cmd(%w(capsule content remove-lifecycle-environment --id 1 --environment-id 2))
19
+ end
20
+
21
+ it 'resolves environment ID from name' do
22
+ expect_lifecycle_environment_search('3', 'env2', 2)
23
+ expect_lifecycle_environment_remove('id' => 1, 'environment_id' => 2)
24
+
25
+ run_cmd(%w(capsule content remove-lifecycle-environment --id 1 --environment env2
26
+ --organization-id 3))
27
+ end
28
+
29
+ it 'resolves organization ID from name' do
30
+ expect_organization_search('org3', 3)
31
+ expect_lifecycle_environment_search(3, 'env2', 2)
32
+ expect_lifecycle_environment_remove('id' => 1, 'environment_id' => 2)
33
+
34
+ run_cmd(%w(capsule content remove-lifecycle-environment --id 1 --environment env2
35
+ --organization org3))
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,107 @@
1
+ require File.join(File.dirname(__FILE__), '../../test_helper')
2
+ require File.join(File.dirname(__FILE__), './capsule_content_helpers')
3
+
4
+ describe 'capsule content synchronization_status' do
5
+ include CapsuleContentHelpers
6
+
7
+ before do
8
+ @cmd = ['capsule', 'content', 'synchronization-status']
9
+ end
10
+
11
+ describe "output" do
12
+ let(:params) { ['--id=3'] }
13
+
14
+ before do
15
+ @sync_status = load_json('./data/sync_status.json', __FILE__)
16
+ ex = api_expects(:capsule_content, :sync_status, 'Get sync info') do |par|
17
+ par['id'] == 3
18
+ end
19
+ ex.returns(@sync_status)
20
+ end
21
+
22
+ it "shows last sync" do
23
+ expected_result = success_result(FieldMatcher.new("Last sync", "2016/01/10 00:27:51"))
24
+
25
+ result = run_cmd(@cmd + params)
26
+ assert_cmd(expected_result, result)
27
+ end
28
+
29
+ it "shows last sync time" do
30
+ expected_result = success_result(FieldMatcher.new("Last sync", "2016/01/10 00:27:51"))
31
+
32
+ result = run_cmd(@cmd + params)
33
+ assert_cmd(expected_result, result)
34
+ end
35
+
36
+ it "shows the proxy status" do
37
+ expected_result = success_result(FieldMatcher.new("Status", "Capsule is synchronized"))
38
+
39
+ result = run_cmd(@cmd + params)
40
+ assert_cmd(expected_result, result)
41
+ end
42
+
43
+ it "shows environments that can be synchronized" do
44
+ @sync_status['lifecycle_environments'] = [
45
+ load_json('./data/library_env.json', __FILE__)
46
+ ]
47
+
48
+ output = FieldMatcher.new("Status", "1 environment(s) can be synchronized: Library")
49
+ expected_result = success_result(output)
50
+
51
+ result = run_cmd(@cmd + params)
52
+ assert_cmd(expected_result, result)
53
+ end
54
+
55
+ it "shows last sync errors" do
56
+ tasks = load_json('./data/sync_tasks.json', __FILE__)
57
+ @sync_status['last_failed_sync_tasks'] = [
58
+ tasks['failed1'],
59
+ tasks['failed2']
60
+ ]
61
+
62
+ output = OutputMatcher.new([
63
+ "Last failure:",
64
+ " Task id: ab3e2ae3-fbed-466d-81fc-37130fc9efbb",
65
+ " Messages:",
66
+ " 404 Resource Not Found"
67
+ ])
68
+ expected_result = success_result(output)
69
+
70
+ result = run_cmd(@cmd + params)
71
+ assert_cmd(expected_result, result)
72
+ end
73
+
74
+ it "shows currently running tasks" do
75
+ tasks = load_json('./data/sync_tasks.json', __FILE__)
76
+ @sync_status['active_sync_tasks'] = [
77
+ tasks['running']
78
+ ]
79
+
80
+ output = OutputMatcher.new([
81
+ "Currently running sync tasks:",
82
+ " 1) Task id: a484eb0d-b40d-4c4c-b187-bb6291d78652",
83
+ " Progress: 66%"
84
+ ])
85
+ expected_result = success_result(output)
86
+
87
+ result = run_cmd(@cmd + params)
88
+ assert_cmd(expected_result, result)
89
+ end
90
+ end
91
+
92
+ it "resolves id from name" do
93
+ params = ['--name=capsule1']
94
+
95
+ api_expects(:capsule_content, :sync_status, 'Get sync info') do |par|
96
+ par['id'] == 3
97
+ end
98
+ expect_capsule_search('capsule1', 3)
99
+
100
+ run_cmd(@cmd + params)
101
+ end
102
+
103
+ it "is mounted under proxy too" do
104
+ result = run_cmd(['proxy', 'content', 'synchronization-status', '-h'])
105
+ assert_exit_code_equal(HammerCLI::EX_OK, result.exit_code)
106
+ end
107
+ end
@@ -0,0 +1,25 @@
1
+ require_relative '../test_helper'
2
+ require_relative 'capsule_helpers'
3
+ require 'hammer_cli_katello/capsule'
4
+
5
+ module HammerCLIKatello
6
+ describe Capsule do
7
+ describe InfoCommand do
8
+ include CapsuleHelpers
9
+
10
+ it 'allows minimal options' do
11
+ expect_capsule_info('id' => '1')
12
+
13
+ run_cmd(%w(capsule info --id 1))
14
+ end
15
+
16
+ it 'resolves capsule ID from name' do
17
+ expect_generic_capsule_search(
18
+ params: { search: "name = \"capsule1\"" }, returns: {'id' => 1})
19
+ expect_capsule_info('id' => 1)
20
+
21
+ run_cmd(%w(capsule info --name capsule1))
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,24 @@
1
+ require_relative '../test_helper'
2
+ require_relative 'capsule_helpers'
3
+ require 'hammer_cli_katello/capsule'
4
+
5
+ module HammerCLIKatello
6
+ describe Capsule do
7
+ describe ListCommand do
8
+ include CapsuleHelpers
9
+
10
+ it 'allows minimal options' do
11
+ expect_generic_capsule_search
12
+
13
+ run_cmd(%w(capsule list))
14
+ end
15
+
16
+ it 'allows search' do
17
+ expect_generic_capsule_search(
18
+ params: { 'search' => 'search' }, returns: {})
19
+
20
+ run_cmd(%w(capsule list --search search))
21
+ end
22
+ end
23
+ end
24
+ end