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,120 +0,0 @@
1
- require_relative '../test_helper'
2
- require 'hammer_cli_foreman/hostgroup'
3
- module HammerCLIForeman
4
- describe Hostgroup do
5
- # These tests are only for the extensions Katello adds to the hostgroup command
6
- # See hammer-cli-foreman for the core hostgroup tests
7
- describe UpdateCommand do
8
- it 'allows content source id' do
9
- api_expects(:hostgroups, :update) do |p|
10
- p['id'] == '1' && p['hostgroup']['content_source_id'] == 1
11
- end
12
- run_cmd(%w(hostgroup update --id 1 --content-source-id 1))
13
- end
14
-
15
- it 'allows content source name' do
16
- content_source_name = "life_of_cs"
17
- content_source_id = 111
18
- hg_id = 441
19
-
20
- api_expects(:smart_proxies, :index).
21
- with_params(:search => "name = \"#{content_source_name}\"").
22
- returns(index_response([{'id' => content_source_id}]))
23
-
24
- api_expects(:hostgroups, :update).
25
- with_params('id' => hg_id.to_s,
26
- 'hostgroup' => {'content_source_id' => content_source_id
27
- })
28
-
29
- cmd = "hostgroup update --id #{hg_id} --content-source #{content_source_name}"
30
- run_cmd(cmd.split)
31
- end
32
-
33
- it 'allows content view id' do
34
- api_expects(:hostgroups, :update) do |p|
35
- p['id'] == '1' && p['hostgroup']['content_view_id'] == 1
36
- end
37
- run_cmd(%w(hostgroup update --id 1 --content-view-id 1))
38
- end
39
-
40
- it 'allows content view name' do
41
- ex = api_expects(:content_views, :index) do |p|
42
- p[:search] = "name = \"cv1\"" && p['organization_id'] == '1'
43
- end
44
- ex.returns(index_response([{'id' => 1}]))
45
- api_expects(:hostgroups, :update) do |p|
46
- p['id'] == '1' && p['hostgroup']['content_view_id'] == 1
47
- end
48
- run_cmd(%w(hostgroup update --id 1 --content-view cv1 --query-organization-id 1))
49
- end
50
-
51
- it 'requires organization options to resolve content view name' do
52
- api_expects_no_call
53
- result = run_cmd(%w(hostgroup update --id 1 --content-view cv1))
54
- assert_match(/--query-organization/, result.err)
55
- end
56
-
57
- it 'allows lifecycle environment id' do
58
- api_expects(:hostgroups, :update) do |p|
59
- p['id'] == '1' && p['hostgroup']['lifecycle_environment_id'] == 1 &&
60
- p['hostgroup']['organization_ids'] == %w(1 2)
61
- end
62
- run_cmd(%w(hostgroup update --id 1 --lifecycle-environment-id 1 --organization-ids 1,2))
63
- end
64
-
65
- it 'allows lifecycle environment name' do
66
- ex = api_expects(:lifecycle_environments, :index) do |p|
67
- p[:name] = 'le1' && p['organization_id'] == '1'
68
- end
69
- ex.returns(index_response([{'id' => 1}]))
70
- api_expects(:hostgroups, :update) do |p|
71
- p['id'] == '1' && p['hostgroup']['lifecycle_environment_id'] == 1
72
- end
73
- run_cmd(%w(hostgroup update --id 1 --lifecycle-environment le1
74
- --query-organization-id 1 --organization-ids 1,2))
75
- end
76
-
77
- it 'requires organization options to resolve lifecycle environment name' do
78
- api_expects_no_call
79
- result = run_cmd(%w(hostgroup update --name hg1 --lifecycle-environment le1))
80
- assert_match(/--query-organization/, result.err)
81
- end
82
-
83
- it 'requires organization options to resolve lifecycle environment name' do
84
- api_expects_no_call
85
- result = run_cmd(%w(hostgroup update --id 1 --lifecycle-environment le1))
86
- assert_match(/--query-organization/, result.err)
87
- end
88
-
89
- it 'allows kickstart repository name' do
90
- env_id = 100
91
- cv_id = 200
92
- repo_name = "life_of_kickstart"
93
- repo_id = 111
94
- hg_name = "mercury"
95
- hg_id = 108
96
-
97
- api_expects(:hostgroups, :index).
98
- with_params(:search => "name = \"#{hg_name}\"").
99
- returns(index_response([{'id' => hg_id}]))
100
-
101
- api_expects(:repositories, :index).
102
- with_params('name' => repo_name,
103
- 'environment_id' => env_id,
104
- 'content_view_id' => cv_id).
105
- returns(index_response([{'id' => repo_id}]))
106
-
107
- api_expects(:hostgroups, :update).
108
- with_params('id' => hg_id,
109
- 'hostgroup' => {'lifecycle_environment_id' => env_id,
110
- 'content_view_id' => cv_id,
111
- 'kickstart_repository_id' => repo_id
112
- })
113
-
114
- cmd = "hostgroup update --name #{hg_name} --lifecycle-environment-id #{env_id}"\
115
- " --content-view-id #{cv_id} --kickstart-repository #{repo_name}"
116
- run_cmd(cmd.split)
117
- end
118
- end
119
- end
120
- end
@@ -1,14 +0,0 @@
1
- require_relative '../test_helper'
2
- require 'hammer_cli_katello/lifecycle_environment'
3
-
4
- module HammerCLIKatello
5
- describe LifecycleEnvironmentCommand::CreateCommand do
6
- it 'allows minimal options' do
7
- api_expects(:lifecycle_environments, :create) do |p|
8
- p['name'] == 'le1' && p['prior_id'] == 3 && p['organization_id'] == 1
9
- end
10
-
11
- run_cmd(%w(lifecycle-environment create --name le1 --prior-id 3 --organization-id 1))
12
- end
13
- end
14
- end
@@ -1,18 +0,0 @@
1
- require_relative '../search_helpers'
2
-
3
- module LifecycleEnvironmentHelpers
4
- include SearchHelpers
5
-
6
- def expect_lifecycle_environment_search(org_id, name, id)
7
- expect_lenient_search(:lifecycle_environments,
8
- params: {'name' => name, 'organization_id' => org_id},
9
- returns: {'id' => id})
10
- end
11
-
12
- def expect_lifecycle_environments_request(org_id, results)
13
- ex = api_expects(:lifecycle_environments, :index, 'List the lifecycle environments') do |par|
14
- par['organization_id'] == org_id
15
- end
16
- ex.returns(index_response(results))
17
- end
18
- end
@@ -1,38 +0,0 @@
1
- require_relative '../test_helper'
2
- require 'hammer_cli_katello/lifecycle_environment'
3
-
4
- module HammerCLIKatello
5
- describe LifecycleEnvironmentCommand::ListCommand do
6
- it 'allows minimal options' do
7
- api_expects(:lifecycle_environments, :index)
8
-
9
- run_cmd(%w(lifecycle-environment list))
10
- end
11
-
12
- describe 'allows organization' do
13
- it 'id' do
14
- api_expects(:lifecycle_environments, :index) { |p| p['organization_id'] == 1 }
15
-
16
- run_cmd(%w(lifecycle-environment list --organization-id 1))
17
- end
18
-
19
- it 'name' do
20
- api_expects(:organizations, :index) { |par| par[:search] == "name = \"org1\"" }
21
- .at_least_once.returns(index_response([{'id' => 1}]))
22
-
23
- api_expects(:lifecycle_environments, :index) { |p| p['organization_id'] == 1 }
24
-
25
- run_cmd(%w(lifecycle-environment list --organization org1))
26
- end
27
-
28
- it 'label' do
29
- api_expects(:organizations, :index) { |par| par[:search] == "label = \"org1\"" }
30
- .at_least_once.returns(index_response([{'id' => 1}]))
31
-
32
- api_expects(:lifecycle_environments, :index) { |p| p['organization_id'] == 1 }
33
-
34
- run_cmd(%w(lifecycle-environment list --organization-label org1))
35
- end
36
- end
37
- end
38
- end
@@ -1,14 +0,0 @@
1
- require_relative '../test_helper'
2
- require 'hammer_cli_katello/lifecycle_environment'
3
-
4
- module HammerCLIKatello
5
- describe LifecycleEnvironmentCommand::UpdateCommand do
6
- it 'allows minimal options' do
7
- api_expects(:lifecycle_environments, :update) do |p|
8
- p['new_name'] == 'le3' && p['id'] == 3
9
- end
10
-
11
- run_cmd(%w(lifecycle-environment update --id 3 --new-name le3))
12
- end
13
- end
14
- end
@@ -1,30 +0,0 @@
1
- require File.join(File.dirname(__FILE__), '../test_helper')
2
-
3
- describe 'local helper' do
4
- before do
5
- class SuperLocalTestHelper
6
- def parse_subcommand
7
- true
8
- end
9
- end
10
-
11
- class LocalTestHelper < SuperLocalTestHelper
12
- include HammerCLIKatello::LocalHelper
13
- end
14
-
15
- @local_helper = LocalTestHelper.new
16
- end
17
-
18
- it "does not fail if /usr/share/foreman exists" do
19
- File.expects(:exist?).with('/usr/share/foreman').returns(true)
20
- assert @local_helper.parse_subcommand
21
- end
22
-
23
- it "fails if /usr/share/foreman does not exist" do
24
- File.expects(:exist?).with('/usr/share/foreman').returns(false)
25
-
26
- assert_raises RuntimeError do
27
- @local_helper.parse_subcommand
28
- end
29
- end
30
- end
@@ -1,58 +0,0 @@
1
- require_relative '../test_helper'
2
- require 'hammer_cli_katello/module_stream'
3
-
4
- module HammerCLIKatello
5
- describe ModuleStreamCommand::InfoCommand do
6
- it 'allows ID' do
7
- api_expects(:module_streams, :show).with_params('id' => '1')
8
-
9
- run_cmd(%w(module-stream info --id 1))
10
- end
11
-
12
- it 'resolves ID from name and repo id' do
13
- api_expects(:module_streams, :index)
14
- .with_params(search: "name = \"duck\"", name: "duck", repository_id: "1")
15
- .returns(index_response([{'id' => 1}]))
16
-
17
- api_expects(:module_streams, :show)
18
- .with_params(repository_id: "1", id: 1)
19
-
20
- run_cmd(%w(module-stream info --name duck --repository-id 1))
21
- end
22
-
23
- it 'resolves ID from name, repo name, and product id' do
24
- api_expects(:module_streams, :index)
25
- .with_params(search: "name = \"walrus\"")
26
- .returns(index_response([{'id' => 1}]))
27
-
28
- api_expects(:repositories, :index)
29
- .with_params(name: 'zoo', product_id: 1)
30
- .returns(index_response([{'id' => 1}]))
31
-
32
- api_expects(:module_streams, :show)
33
- .with_params(repository_id: 1, id: 1)
34
-
35
- run_cmd(%w(module-stream info --name walrus --repository zoo --product-id 1))
36
- end
37
-
38
- it 'resolves ID from name, repo name, product name, and org id' do
39
- api_expects(:products, :index)
40
- .with_params(name: "habitat", organization_id: 1)
41
- .returns(index_response([{'id' => 1}]))
42
-
43
- api_expects(:module_streams, :index)
44
- .with_params(search: "name = \"walrus\"")
45
- .returns(index_response([{'id' => 1}]))
46
-
47
- api_expects(:repositories, :index)
48
- .with_params(name: 'zoo', product_id: 1)
49
- .returns(index_response([{'id' => 1}]))
50
-
51
- api_expects(:module_streams, :show)
52
- .with_params(repository_id: 1, id: 1)
53
-
54
- run_cmd(%w(module-stream info --name walrus --repository zoo
55
- --product habitat --organization-id 1))
56
- end
57
- end
58
- end
@@ -1,53 +0,0 @@
1
- require_relative '../test_helper'
2
- require 'hammer_cli_katello/module_stream'
3
-
4
- module HammerCLIKatello
5
- describe ModuleStreamCommand::ListCommand do
6
- it 'allows minimal options' do
7
- api_expects(:module_streams, :index)
8
-
9
- run_cmd(%w(module-stream list))
10
- end
11
-
12
- it 'can be provided by repository ID' do
13
- api_expects(:module_streams, :index).with_params(repository_id: 1)
14
-
15
- run_cmd(%w(module-stream list --repository-id 1))
16
- end
17
-
18
- it 'product params needed with repository name' do
19
- cmd = run_cmd(%w(module-stream list --repository Repo))
20
- error_msg = "At least one of options --product, --product-id is required."
21
- api_expects_no_call
22
- assert_match error_msg, cmd.err
23
- end
24
-
25
- it 'can be provided by repository name and product id' do
26
- api_expects(:repositories, :index)
27
- .with_params(name: "Repo", product_id: 1)
28
- .returns(index_response([{'id' => 1}]))
29
-
30
- api_expects(:module_streams, :index).with_params(repository_id: 1)
31
-
32
- run_cmd(%w(module-stream list --repository Repo --product-id 1))
33
- end
34
-
35
- it 'can be provided by repository id and organization id' do
36
- api_expects(:module_streams, :index)
37
- .with_params(repository_id: 1, organization_id: 1)
38
-
39
- run_cmd(%w(module-stream list --repository-id 1 --organization-id 1))
40
- end
41
-
42
- it 'can be provided by repository name, product id, and organization id' do
43
- api_expects(:repositories, :index)
44
- .with_params(name: "Repo", product_id: 1)
45
- .returns(index_response([{'id' => 1}]))
46
-
47
- api_expects(:module_streams, :index)
48
- .with_params(repository_id: 1, organization_id: 1)
49
-
50
- run_cmd(%w(module-stream list --repository Repo --product-id 1 --organization-id 1))
51
- end
52
- end
53
- end
@@ -1,26 +0,0 @@
1
- require_relative '../test_helper'
2
-
3
- module HammerCLIKatello
4
- describe 'Organization::DeleteCommand' do
5
- it 'it requires the organization ID and must be resolved from name' do
6
- api_expects(:organizations, :index).with_params(
7
- :search => "name = \"my_org\"", :per_page => 1000, :page => 1
8
- )
9
- run_cmd(%w(organization delete --name my_org))
10
- end
11
-
12
- it 'it requires the organization ID and must be resolved from name' do
13
- api_expects(:organizations, :index).with_params(
14
- :search => "label = \"my_org\"", :per_page => 1000, :page => 1
15
- )
16
- run_cmd(%w(organization delete --label my_org))
17
- end
18
-
19
- it 'it requires the organization ID and must be resolved from name' do
20
- api_expects(:organizations, :index).with_params(
21
- :search => "title = \"my_org\"", :per_page => 1000, :page => 1
22
- )
23
- run_cmd(%w(organization delete --title my_org))
24
- end
25
- end
26
- end
@@ -1,10 +0,0 @@
1
- require_relative '../search_helpers'
2
-
3
- module OrganizationHelpers
4
- include SearchHelpers
5
-
6
- def expect_organization_search(name_or_label, id, field: 'name')
7
- expect_generic_search(:organizations, params: {search: "#{field} = \"#{name_or_label}\""},
8
- returns: {'id' => id}).at_least_once
9
- end
10
- end
@@ -1,158 +0,0 @@
1
- require_relative '../test_helper'
2
- require_relative '../repository/repository_helpers'
3
- require_relative '../product/product_helpers'
4
- require_relative '../organization/organization_helpers'
5
- require_relative '../lifecycle_environment/lifecycle_environment_helpers'
6
- require 'hammer_cli_katello/package'
7
-
8
- # rubocop:disable ModuleLength
9
- module HammerCLIKatello
10
- describe PackageCommand::ListCommand do
11
- include OrganizationHelpers
12
- include LifecycleEnvironmentHelpers
13
- include RepositoryHelpers
14
- include ProductHelpers
15
-
16
- it 'allows minimal options' do
17
- api_expects(:packages, :index)
18
-
19
- run_cmd(%w(package list))
20
- end
21
-
22
- describe 'content view options' do
23
- it 'may be specified by ID' do
24
- api_expects(:content_view_versions, :index)
25
- .with_params('content_view_id' => 1, 'version' => '2.1')
26
- .returns(index_response([{'id' => 5}]))
27
- api_expects(:packages, :index).with_params('content_view_version_id' => 5)
28
-
29
- run_cmd(%w(package list --content-view-id 1 --content-view-version 2.1))
30
- end
31
-
32
- it 'requires organization ID when given content view name' do
33
- api_expects_no_call
34
-
35
- r = run_cmd(%w(package list --content-view cv1 --content-view-version 2.1))
36
- expected_error = "--organization-id, --organization, --organization-label is required"
37
- assert(r.err.include?(expected_error), "Invalid error message")
38
- end
39
-
40
- it 'requires content view ID when given content view version name' do
41
- api_expects_no_call
42
-
43
- r = run_cmd(%w(package list --content-view-version cvv1))
44
- assert(r.err.include?("--content-view-id, --content-view is required"),
45
- "Invalid error message")
46
- end
47
- end
48
-
49
- describe 'repository options' do
50
- it 'may be specified by ID' do
51
- api_expects(:packages, :index).with_params('repository_id' => 1)
52
-
53
- run_cmd(%w(package list --repository-id 1))
54
- end
55
-
56
- it 'require product ID when given repository name' do
57
- api_expects_no_call
58
-
59
- r = run_cmd(%w(package list --repository repo1))
60
- assert(r.err.include?("--product-id, --product is required"), "Invalid error message")
61
- end
62
-
63
- it 'may be specified by name and product ID' do
64
- expect_repository_search(2, 'repo1', 1)
65
-
66
- api_expects(:packages, :index).with_params('repository_id' => 1)
67
-
68
- run_cmd(%w(package list --repository repo1 --product-id 2))
69
- end
70
- end
71
-
72
- describe 'environment options' do
73
- it 'may be specified environment name' do
74
- org_id = 2
75
- env_name = "dev"
76
- expected_id = 6
77
- expect_lifecycle_environment_search(org_id, env_name, expected_id)
78
-
79
- api_expects(:packages, :index).with_params("organization_id" => org_id,
80
- "environment_id" => expected_id,
81
- "page" => 1, "per_page" => 1000)
82
-
83
- run_cmd(%W(package list --environment=#{env_name} --organization-id=#{org_id}))
84
- end
85
-
86
- it 'may be specified environment name no org fails' do
87
- api_expects_no_call
88
- r = run_cmd(%w(package list --environment Library))
89
- expec_err = "--organization, --organization-title, --organization-label, --organization-id"
90
- puts r.err
91
- assert(r.err.include?(expec_err), "Invalid error message")
92
- end
93
- end
94
-
95
- describe 'product options' do
96
- it 'may be specified by ID' do
97
- api_expects(:repositories, :index)
98
- .with_params('product_id' => 1)
99
- .returns(index_response([{'id' => 2}]))
100
-
101
- api_expects(:packages, :index).with_params('repository_id' => 2)
102
-
103
- run_cmd(%w(package list --product-id 1))
104
- end
105
-
106
- it 'fail if more than one repository is found' do
107
- api_expects(:repositories, :index)
108
- .with_params('product_id' => 1)
109
- .returns(index_response([{'id' => 2}, {'id' => 3}]))
110
-
111
- r = run_cmd(%w(package list --product-id 1))
112
- assert(r.err.include?("Found more than one repository"), "Invalid error message: #{r.err}")
113
- end
114
-
115
- it 'requires organization options to resolve ID by name' do
116
- api_expects_no_call
117
-
118
- r = run_cmd(%w(package list --product product1))
119
- expected_error = "--organization-id, --organization, --organization-label is required"
120
- assert(r.err.include?(expected_error), "Invalid error message")
121
- end
122
-
123
- it 'allows organization ID when resolving ID by name' do
124
- expect_product_search(3, 'product1', 1)
125
-
126
- expect_generic_repositories_search({'product_id' => 1}, [{'id' => 2}])
127
-
128
- api_expects(:packages, :index).with_params('repository_id' => 2)
129
-
130
- run_cmd(%w(package list --product product1 --organization-id 3))
131
- end
132
-
133
- it 'allows organization name when resolving ID by name' do
134
- expect_organization_search('org3', 3)
135
-
136
- expect_product_search(3, 'product1', 1)
137
-
138
- expect_generic_repositories_search({'product_id' => 1}, [{'id' => 2}])
139
-
140
- api_expects(:packages, :index).with_params('repository_id' => 2)
141
-
142
- run_cmd(%w(package list --product product1 --organization org3))
143
- end
144
-
145
- it 'allows organization label when resolving ID by name' do
146
- expect_organization_search('org3', 3, field: 'label')
147
-
148
- expect_product_search(3, 'product1', 1)
149
-
150
- expect_generic_repositories_search({'product_id' => 1}, [{'id' => 2}])
151
-
152
- api_expects(:packages, :index).with_params('repository_id' => 2)
153
-
154
- run_cmd(%w(package list --product product1 --organization-label org3))
155
- end
156
- end
157
- end
158
- end
@@ -1,38 +0,0 @@
1
- require_relative '../test_helper'
2
- require 'hammer_cli_katello/package_group'
3
-
4
- module HammerCLIKatello
5
- describe PackageGroupCommand::ListCommand do
6
- it 'allows minimal options' do
7
- api_expects(:package_groups, :index)
8
-
9
- run_cmd(%w(package-group list))
10
- end
11
-
12
- it 'can be provided by repository ID' do
13
- api_expects(:package_groups, :index) do |params|
14
- params['repository_id'] == 1
15
- end
16
-
17
- run_cmd(%w(package-group list --repository-id 1))
18
- end
19
-
20
- it 'needs product options with repository name' do
21
- cmd = run_cmd(%w(package-group list --repository Repo))
22
- api_expects_no_call
23
- error_msg = "At least one of options --product, --product-id is required."
24
- assert_match error_msg, cmd.err
25
- end
26
-
27
- it 'can be provided product id and repository name' do
28
- api_expects(:repositories, :index)
29
- .with_params(name: "Repo", product_id: 1)
30
- .returns(index_response([{'id' => 1}]))
31
-
32
- api_expects(:package_groups, :index)
33
- .with_params(repository_id: 1)
34
-
35
- run_cmd(%w(package-group list --repository Repo --product-id 1))
36
- end
37
- end
38
- end
@@ -1,20 +0,0 @@
1
- require_relative 'test_helper'
2
-
3
- describe 'ping' do
4
- it 'does not require authentication' do
5
- api_expects(:ping, :index).returns(
6
- 'status' => 'ok',
7
- 'services' => {
8
- 'foreman_tasks' => {'status' => 'ok', 'duration_ms' => '34'},
9
- 'foreman_auth' => {'status' => 'ok', 'duration_ms' => '34'},
10
- 'candlepin' => {'status' => 'ok', 'duration_ms' => '34'},
11
- 'candlepin_events' => {'status' => 'ok', 'message' => '0 messages', 'duration_ms' => '34'},
12
- 'candlepin_auth' => {'status' => 'ok', 'duration_ms' => '34'},
13
- 'katello_events' => {'status' => 'ok', 'message' => '0 messages', 'duration_ms' => '34'},
14
- 'pulp3' => {'status' => 'ok', 'duration_ms' => '34'}
15
- }
16
- )
17
-
18
- run_cmd(%w(ping katello))
19
- end
20
- end
@@ -1,54 +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__), '../sync_plan/sync_plan_helpers')
4
- require File.join(File.dirname(__FILE__), '../product/product_helpers')
5
-
6
- describe "create a product" do
7
- include OrganizationHelpers
8
- include SyncPlanHelpers
9
- include ProductHelpers
10
-
11
- it 'by organization ID and product name' do
12
- api_expects(:products, :create, 'create a product') do |par|
13
- par['organization_id'] == 1 && par['name'] = 'product1'
14
- end
15
-
16
- assert_equal(
17
- 0,
18
- run_cmd(%w(product create --organization-id 1 --name product1)).exit_code
19
- )
20
- end
21
-
22
- it 'by organization name and product name' do
23
- expect_organization_search('org1', 1)
24
- api_expects(:products, :create, 'create a product') do |par|
25
- par['organization_id'] == 1 && par['name'] = 'product1'
26
- end
27
- assert_equal(
28
- 0,
29
- run_cmd(%w(product create --organization org1 --name product1)).exit_code
30
- )
31
- end
32
-
33
- it 'by organization name, product name, and sync plan' do
34
- expect_organization_search('org1', 1)
35
- expect_sync_plan_search(1, 'sync_plan1', 1)
36
- api_expects(:products, :create, 'create a product with a sync plan') do |par|
37
- par['organization_id'] == 1 &&
38
- par['name'] == 'product1' &&
39
- par['sync_plan_id'] == 1
40
- end
41
- command = %w(product create --organization org1 --name product1 --sync-plan sync_plan1)
42
- assert_equal(
43
- 0,
44
- run_cmd(command).exit_code
45
- )
46
- end
47
-
48
- it 'fails if no organization is given' do
49
- refute_equal(
50
- 0,
51
- run_cmd(%w(product create --name product1)).exit_code
52
- )
53
- end
54
- end