hammer_cli_katello 1.4.1 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (208) hide show
  1. checksums.yaml +4 -4
  2. data/lib/hammer_cli_katello/content_export_complete.rb +8 -0
  3. data/lib/hammer_cli_katello/content_export_helper.rb +55 -3
  4. data/lib/hammer_cli_katello/content_export_incremental.rb +8 -0
  5. data/lib/hammer_cli_katello/content_import.rb +9 -0
  6. data/lib/hammer_cli_katello/host_collection.rb +2 -0
  7. data/lib/hammer_cli_katello/id_resolver.rb +3 -2
  8. data/lib/hammer_cli_katello/organization.rb +11 -0
  9. data/lib/hammer_cli_katello/repository.rb +39 -2
  10. data/lib/hammer_cli_katello/version.rb +1 -1
  11. metadata +4 -398
  12. data/test/data/2.5/foreman_api.json +0 -1
  13. data/test/data/3.0/foreman_api.json +0 -1
  14. data/test/data/3.10/foreman_api.json +0 -1
  15. data/test/data/3.11/foreman_api.json +0 -1
  16. data/test/data/3.12/foreman_api.json +0 -1
  17. data/test/data/3.13/foreman_api.json +0 -1
  18. data/test/data/3.14/foreman_api.json +0 -1
  19. data/test/data/3.15/foreman_api.json +0 -1
  20. data/test/data/3.16/foreman_api.json +0 -1
  21. data/test/data/3.17/foreman_api.json +0 -1
  22. data/test/data/3.18/foreman_api.json +0 -1
  23. data/test/data/3.19/foreman_api.json +0 -1
  24. data/test/data/3.2/foreman_api.json +0 -1
  25. data/test/data/3.4/foreman_api.json +0 -1
  26. data/test/data/3.5/foreman_api.json +0 -1
  27. data/test/data/3.6/foreman_api.json +0 -1
  28. data/test/data/3.7/foreman_api.json +0 -1
  29. data/test/data/3.8/foreman_api.json +0 -1
  30. data/test/data/3.9/foreman_api.json +0 -1
  31. data/test/data/4.0/foreman_api.json +0 -1
  32. data/test/data/4.1/foreman_api.json +0 -1
  33. data/test/data/4.3/foreman_api.json +0 -1
  34. data/test/data/4.4/foreman_api.json +0 -1
  35. data/test/data/Readme.md +0 -5
  36. data/test/functional/activation_key/add_host_collection_test.rb +0 -62
  37. data/test/functional/activation_key/content_override_test.rb +0 -92
  38. data/test/functional/activation_key/create_test.rb +0 -33
  39. data/test/functional/activation_key/data/activation_key.json +0 -17
  40. data/test/functional/activation_key/info_test.rb +0 -29
  41. data/test/functional/activation_key/list_test.rb +0 -68
  42. data/test/functional/activation_key/product_content_test.rb +0 -23
  43. data/test/functional/activation_key/remove_host_collection_test.rb +0 -62
  44. data/test/functional/activation_key/subscriptions_test.rb +0 -74
  45. data/test/functional/activation_key/update_test.rb +0 -26
  46. data/test/functional/apipie_helper_test.rb +0 -31
  47. data/test/functional/capsule/capsule_helpers.rb +0 -13
  48. data/test/functional/capsule/content/add_lifecycle_environment_test.rb +0 -40
  49. data/test/functional/capsule/content/cancel_synchronization_test.rb +0 -42
  50. data/test/functional/capsule/content/capsule_content_helpers.rb +0 -24
  51. data/test/functional/capsule/content/data/library_env.json +0 -47
  52. data/test/functional/capsule/content/data/sync_status.json +0 -6
  53. data/test/functional/capsule/content/data/sync_tasks.json +0 -62
  54. data/test/functional/capsule/content/info_test.rb +0 -61
  55. data/test/functional/capsule/content/lifecycle_environments_test.rb +0 -19
  56. data/test/functional/capsule/content/remove_lifecycle_environment_test.rb +0 -40
  57. data/test/functional/capsule/content/synchronization_status_test.rb +0 -107
  58. data/test/functional/capsule/info_test.rb +0 -25
  59. data/test/functional/capsule/list_test.rb +0 -24
  60. data/test/functional/content_credentials/create_test.rb +0 -32
  61. data/test/functional/content_credentials/data/test_cert.json +0 -43
  62. data/test/functional/content_credentials/info_test.rb +0 -50
  63. data/test/functional/content_credentials/list_test.rb +0 -66
  64. data/test/functional/content_export/complete/library_test.rb +0 -155
  65. data/test/functional/content_export/complete/version_test.rb +0 -252
  66. data/test/functional/content_export/content_export_helpers.rb +0 -26
  67. data/test/functional/content_export/generate_metadata_test.rb +0 -64
  68. data/test/functional/content_export/incremental/library_test.rb +0 -172
  69. data/test/functional/content_export/incremental/version_test.rb +0 -268
  70. data/test/functional/content_export/list_test.rb +0 -64
  71. data/test/functional/content_import/library_test.rb +0 -85
  72. data/test/functional/content_import/list_test.rb +0 -65
  73. data/test/functional/content_import/metadata.json +0 -1
  74. data/test/functional/content_import/version_test.rb +0 -85
  75. data/test/functional/content_units/info_test.rb +0 -29
  76. data/test/functional/content_units/list_test.rb +0 -106
  77. data/test/functional/content_view/add_content_view_version_test.rb +0 -88
  78. data/test/functional/content_view/add_repository_test.rb +0 -21
  79. data/test/functional/content_view/component/add_test.rb +0 -177
  80. data/test/functional/content_view/component/list_test.rb +0 -55
  81. data/test/functional/content_view/component/remove_test.rb +0 -107
  82. data/test/functional/content_view/component/update_test.rb +0 -134
  83. data/test/functional/content_view/content_view_helpers.rb +0 -20
  84. data/test/functional/content_view/copy_test.rb +0 -53
  85. data/test/functional/content_view/create_test.rb +0 -34
  86. data/test/functional/content_view/delete_test.rb +0 -62
  87. data/test/functional/content_view/filter/create_test.rb +0 -57
  88. data/test/functional/content_view/filter/delete_test.rb +0 -90
  89. data/test/functional/content_view/filter/info_test.rb +0 -89
  90. data/test/functional/content_view/filter/list_test.rb +0 -98
  91. data/test/functional/content_view/filter/update_test.rb +0 -91
  92. data/test/functional/content_view/list_test.rb +0 -68
  93. data/test/functional/content_view/publish_test.rb +0 -24
  94. data/test/functional/content_view/purge_test.rb +0 -97
  95. data/test/functional/content_view/remove_content_view_version_test.rb +0 -88
  96. data/test/functional/content_view/remove_test.rb +0 -79
  97. data/test/functional/content_view/update_test.rb +0 -53
  98. data/test/functional/content_view/version/incremental_update_test.rb +0 -108
  99. data/test/functional/content_view/version/list_test.rb +0 -44
  100. data/test/functional/content_view/version/promote_test.rb +0 -75
  101. data/test/functional/content_view/version/republish_repositories_test.rb +0 -34
  102. data/test/functional/content_view/version/update_test.rb +0 -48
  103. data/test/functional/erratum/erratum_helpers.rb +0 -91
  104. data/test/functional/erratum/info_test.rb +0 -29
  105. data/test/functional/erratum/list_test.rb +0 -108
  106. data/test/functional/file/file_helpers.rb +0 -13
  107. data/test/functional/file/info_test.rb +0 -162
  108. data/test/functional/file/list_test.rb +0 -112
  109. data/test/functional/filter_rule/create_test.rb +0 -99
  110. data/test/functional/filter_rule/delete_test.rb +0 -104
  111. data/test/functional/filter_rule/filter_rule_helpers.rb +0 -12
  112. data/test/functional/filter_rule/info_test.rb +0 -104
  113. data/test/functional/filter_rule/list_test.rb +0 -91
  114. data/test/functional/filter_rule/update_test.rb +0 -104
  115. data/test/functional/host/errata/apply_test.rb +0 -45
  116. data/test/functional/host/errata/info_test.rb +0 -27
  117. data/test/functional/host/errata/list_test.rb +0 -49
  118. data/test/functional/host/errata/recalculate_test.rb +0 -26
  119. data/test/functional/host/extensions/create_test.rb +0 -95
  120. data/test/functional/host/extensions/data/host.json +0 -320
  121. data/test/functional/host/extensions/data/host_list.json +0 -117
  122. data/test/functional/host/extensions/info_test.rb +0 -35
  123. data/test/functional/host/extensions/list_test.rb +0 -21
  124. data/test/functional/host/extensions/update_test.rb +0 -70
  125. data/test/functional/host/host_helpers.rb +0 -8
  126. data/test/functional/host/subscription/attach_test.rb +0 -54
  127. data/test/functional/host/subscription/auto_attach_test.rb +0 -35
  128. data/test/functional/host/subscription/content_override_test.rb +0 -96
  129. data/test/functional/host/subscription/product_content_test.rb +0 -27
  130. data/test/functional/host/subscription/register_test.rb +0 -53
  131. data/test/functional/host/subscription/remove_test.rb +0 -52
  132. data/test/functional/host/subscription/unregister_test.rb +0 -37
  133. data/test/functional/host/traces/list_test.rb +0 -37
  134. data/test/functional/host/traces/resolve_test.rb +0 -31
  135. data/test/functional/host_collection/add_host_test.rb +0 -90
  136. data/test/functional/host_collection/content_api_expectations.rb +0 -35
  137. data/test/functional/host_collection/content_install_test.rb +0 -62
  138. data/test/functional/host_collection/content_remove_test.rb +0 -37
  139. data/test/functional/host_collection/content_update_test.rb +0 -37
  140. data/test/functional/host_collection/copy_test.rb +0 -64
  141. data/test/functional/host_collection/create_test.rb +0 -54
  142. data/test/functional/host_collection/delete_test.rb +0 -57
  143. data/test/functional/host_collection/hosts_test.rb +0 -39
  144. data/test/functional/host_collection/info_test.rb +0 -57
  145. data/test/functional/host_collection/list_test.rb +0 -63
  146. data/test/functional/host_collection/remove_host_test.rb +0 -90
  147. data/test/functional/host_collection/update_test.rb +0 -57
  148. data/test/functional/hostgroup/create_test.rb +0 -112
  149. data/test/functional/hostgroup/data/hostgroup.json +0 -50
  150. data/test/functional/hostgroup/info_test.rb +0 -33
  151. data/test/functional/hostgroup/update_test.rb +0 -120
  152. data/test/functional/lifecycle_environment/create_test.rb +0 -14
  153. data/test/functional/lifecycle_environment/lifecycle_environment_helpers.rb +0 -18
  154. data/test/functional/lifecycle_environment/list_test.rb +0 -38
  155. data/test/functional/lifecycle_environment/update_test.rb +0 -14
  156. data/test/functional/local_helper_test.rb +0 -30
  157. data/test/functional/module_stream/info_test.rb +0 -58
  158. data/test/functional/module_stream/list_test.rb +0 -53
  159. data/test/functional/organization/cdn_configuration_test.rb +0 -45
  160. data/test/functional/organization/delete_test.rb +0 -26
  161. data/test/functional/organization/info_test.rb +0 -39
  162. data/test/functional/organization/organization_helpers.rb +0 -10
  163. data/test/functional/package/list_test.rb +0 -160
  164. data/test/functional/package_group/list_test.rb +0 -38
  165. data/test/functional/ping_test.rb +0 -61
  166. data/test/functional/product/create_test.rb +0 -54
  167. data/test/functional/product/delete_test.rb +0 -41
  168. data/test/functional/product/info_test.rb +0 -33
  169. data/test/functional/product/list_test.rb +0 -58
  170. data/test/functional/product/product_helpers.rb +0 -24
  171. data/test/functional/product/remove_sync_plan_test.rb +0 -35
  172. data/test/functional/product/set_sync_plan_test.rb +0 -49
  173. data/test/functional/product/update_proxy.rb +0 -48
  174. data/test/functional/product/update_test.rb +0 -46
  175. data/test/functional/repository/create_test.rb +0 -21
  176. data/test/functional/repository/delete_test.rb +0 -95
  177. data/test/functional/repository/info_test.rb +0 -162
  178. data/test/functional/repository/list_test.rb +0 -68
  179. data/test/functional/repository/reclaim_space_test.rb +0 -105
  180. data/test/functional/repository/remove_content_test.rb +0 -108
  181. data/test/functional/repository/repository_helpers.rb +0 -18
  182. data/test/functional/repository/synchronize_test.rb +0 -57
  183. data/test/functional/repository/update_test.rb +0 -149
  184. data/test/functional/repository/upload_test.rb +0 -368
  185. data/test/functional/repository_set/available_repositories_test.rb +0 -18
  186. data/test/functional/repository_set/disable_test.rb +0 -42
  187. data/test/functional/repository_set/enable_test.rb +0 -42
  188. data/test/functional/repository_set/info_test.rb +0 -17
  189. data/test/functional/repository_set/list_test.rb +0 -18
  190. data/test/functional/repository_set/repository_set_helpers.rb +0 -20
  191. data/test/functional/search_helpers.rb +0 -17
  192. data/test/functional/simple_content_access/disable_test.rb +0 -48
  193. data/test/functional/simple_content_access/enable_test.rb +0 -46
  194. data/test/functional/srpm/list_test.rb +0 -92
  195. data/test/functional/subscription/list_test.rb +0 -86
  196. data/test/functional/sync_plan/create_test.rb +0 -60
  197. data/test/functional/sync_plan/delete_test.rb +0 -46
  198. data/test/functional/sync_plan/info_test.rb +0 -37
  199. data/test/functional/sync_plan/list_test.rb +0 -31
  200. data/test/functional/sync_plan/sync_plan_helpers.rb +0 -8
  201. data/test/functional/sync_plan/update_test.rb +0 -44
  202. data/test/functional/test_helper.rb +0 -24
  203. data/test/task_helper.rb +0 -7
  204. data/test/test_helper.rb +0 -38
  205. data/test/unit/id_name_options_validator_test.rb +0 -96
  206. data/test/unit/id_resolver_test.rb +0 -58
  207. data/test/unit/messages_test.rb +0 -7
  208. data/test/unit/search_options_creators_test.rb +0 -145
@@ -1,160 +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)
28
- .with_params('content_view_version_id' => 5)
29
- .returns(index_response([{'id' => 1}, {'id' => 2}]))
30
-
31
- run_cmd(%w(package list --content-view-id 1 --content-view-version 2.1))
32
- end
33
-
34
- it 'requires organization ID when given content view name' do
35
- api_expects_no_call
36
-
37
- r = run_cmd(%w(package list --content-view cv1 --content-view-version 2.1))
38
- expected_error = "--organization-id, --organization, --organization-label is required"
39
- assert(r.err.include?(expected_error), "Invalid error message")
40
- end
41
-
42
- it 'requires content view ID when given content view version name' do
43
- api_expects_no_call
44
-
45
- r = run_cmd(%w(package list --content-view-version cvv1))
46
- assert(r.err.include?("--content-view-id, --content-view is required"),
47
- "Invalid error message")
48
- end
49
- end
50
-
51
- describe 'repository options' do
52
- it 'may be specified by ID' do
53
- api_expects(:packages, :index).with_params('repository_id' => 1)
54
-
55
- run_cmd(%w(package list --repository-id 1))
56
- end
57
-
58
- it 'require product ID when given repository name' do
59
- api_expects_no_call
60
-
61
- r = run_cmd(%w(package list --repository repo1))
62
- assert(r.err.include?("--product-id, --product is required"), "Invalid error message")
63
- end
64
-
65
- it 'may be specified by name and product ID' do
66
- expect_repository_search(2, 'repo1', 1)
67
-
68
- api_expects(:packages, :index).with_params('repository_id' => 1)
69
-
70
- run_cmd(%w(package list --repository repo1 --product-id 2))
71
- end
72
- end
73
-
74
- describe 'environment options' do
75
- it 'may be specified environment name' do
76
- org_id = 2
77
- env_name = "dev"
78
- expected_id = 6
79
- expect_lifecycle_environment_search(org_id, env_name, expected_id)
80
-
81
- api_expects(:packages, :index).with_params("organization_id" => org_id,
82
- "environment_id" => expected_id,
83
- "page" => 1, "per_page" => 1000)
84
-
85
- run_cmd(%W(package list --environment=#{env_name} --organization-id=#{org_id}))
86
- end
87
-
88
- it 'may be specified environment name no org fails' do
89
- api_expects_no_call
90
- r = run_cmd(%w(package list --environment Library))
91
- expec_err = "Missing options to search organization"
92
- puts r.err
93
- assert(r.err.include?(expec_err), "Invalid error message")
94
- end
95
- end
96
-
97
- describe 'product options' do
98
- it 'may be specified by ID' do
99
- api_expects(:repositories, :index)
100
- .with_params('product_id' => 1)
101
- .returns(index_response([{'id' => 2}]))
102
-
103
- api_expects(:packages, :index).with_params('repository_id' => 2)
104
-
105
- run_cmd(%w(package list --product-id 1))
106
- end
107
-
108
- it 'fail if more than one repository is found' do
109
- api_expects(:repositories, :index)
110
- .with_params('product_id' => 1)
111
- .returns(index_response([{'id' => 2}, {'id' => 3}]))
112
-
113
- r = run_cmd(%w(package list --product-id 1))
114
- assert(r.err.include?("Found more than one repository"), "Invalid error message: #{r.err}")
115
- end
116
-
117
- it 'requires organization options to resolve ID by name' do
118
- api_expects_no_call
119
-
120
- r = run_cmd(%w(package list --product product1))
121
- expected_error = "--organization-id, --organization, --organization-label is required"
122
- assert(r.err.include?(expected_error), "Invalid error message")
123
- end
124
-
125
- it 'allows organization ID when resolving ID by name' do
126
- expect_product_search(3, 'product1', 1)
127
-
128
- expect_generic_repositories_search({'product_id' => 1}, [{'id' => 2}])
129
-
130
- api_expects(:packages, :index).with_params('repository_id' => 2)
131
-
132
- run_cmd(%w(package list --product product1 --organization-id 3))
133
- end
134
-
135
- it 'allows organization name when resolving ID by name' do
136
- expect_organization_search('org3', 3)
137
-
138
- expect_product_search(3, 'product1', 1)
139
-
140
- expect_generic_repositories_search({'product_id' => 1}, [{'id' => 2}])
141
-
142
- api_expects(:packages, :index).with_params('repository_id' => 2)
143
-
144
- run_cmd(%w(package list --product product1 --organization org3))
145
- end
146
-
147
- it 'allows organization label when resolving ID by name' do
148
- expect_organization_search('org3', 3, field: 'label')
149
-
150
- expect_product_search(3, 'product1', 1)
151
-
152
- expect_generic_repositories_search({'product_id' => 1}, [{'id' => 2}])
153
-
154
- api_expects(:packages, :index).with_params('repository_id' => 2)
155
-
156
- run_cmd(%w(package list --product product1 --organization-label org3))
157
- end
158
- end
159
- end
160
- 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,61 +0,0 @@
1
- require_relative 'test_helper'
2
-
3
- describe 'ping' do
4
- let(:standard_response_services) do
5
- {
6
- 'katello_agent' =>
7
- {'status' => 'ok', 'message' => '0 Processed, 0 Failed', 'duration_ms' => '34'},
8
- 'foreman_tasks' =>
9
- {'status' => 'ok', 'duration_ms' => '34'},
10
- 'candlepin' => {'status' => 'ok', 'duration_ms' => '34'},
11
- 'candlepin_events' =>
12
- {'status' => 'ok', 'message' => '0 Processed, 0 Failed', 'duration_ms' => '34'},
13
- 'candlepin_auth' =>
14
- {'status' => 'ok', 'duration_ms' => '34'},
15
- 'katello_events' =>
16
- {'status' => 'ok', 'message' => '0 Processed, 0 Failed', 'duration_ms' => '34'},
17
- 'pulp3' =>
18
- {'status' => 'ok', 'duration_ms' => '34'},
19
- 'pulp3_content' =>
20
- {'status' => 'ok', 'duration_ms' => '34'}
21
- }
22
- end
23
- let(:standard_response) do
24
- {
25
- 'status' => 'ok',
26
- 'services' => standard_response_services
27
- }
28
- end
29
- let(:standard_response_keys) do
30
- %w(katello_agent foreman_tasks candlepin candlepin_events
31
- candlepin_auth katello_events pulp3 pulp3_content).sort
32
- end
33
- let(:hammer_ping) { %w(ping katello) }
34
-
35
- it 'does not require authentication' do
36
- api_expects(:ping, :index).returns(standard_response)
37
-
38
- run_cmd(hammer_ping)
39
- end
40
-
41
- it "includes all keys" do
42
- api_expects(:ping, :index).returns(standard_response)
43
-
44
- result = JSON.parse(run_cmd(%w(--output=json ping katello))&.out)&.first&.keys&.sort
45
- expected = standard_response_keys
46
-
47
- assert_equal result, expected
48
- end
49
-
50
- it "skips katello_agent if not included in API response" do
51
- response_without_katello_agent = {
52
- 'status' => 'ok',
53
- 'services' => standard_response_services.select { |k, _v| k != 'katello_agent' }
54
- }
55
- api_expects(:ping, :index).returns(response_without_katello_agent)
56
- result = JSON.parse(run_cmd(%w(--output=json ping katello))&.out)&.first&.keys&.sort
57
- expected = standard_response_keys.select { |k| k != 'katello_agent' }
58
-
59
- assert_equal result, expected
60
- end
61
- 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
@@ -1,41 +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__), '../product/product_helpers')
4
-
5
- describe 'delete a product' do
6
- include OrganizationHelpers
7
- include ProductHelpers
8
-
9
- it 'by ID' do
10
- api_expects(:products, :destroy, 'delete a product') do |par|
11
- par['id'] == 1
12
- end
13
- assert_equal(
14
- 0,
15
- run_cmd(%w(product delete --id 1)).exit_code
16
- )
17
- end
18
-
19
- it 'by organization ID and product name' do
20
- expect_product_search(1, 'product1', 1)
21
- api_expects(:products, :destroy, 'delete a product') do |par|
22
- par['id'] == 1
23
- end
24
- assert_equal(
25
- 0,
26
- run_cmd(%w(product delete --organization-id 1 --name product1)).exit_code
27
- )
28
- end
29
-
30
- it 'by organization name and product name' do
31
- expect_organization_search('org1', 1)
32
- expect_product_search(1, 'product1', 1)
33
- api_expects(:products, :destroy, 'delete a product') do |par|
34
- par['id'] == 1
35
- end
36
- assert_equal(
37
- 0,
38
- run_cmd(%w(product delete --organization org1 --name product1)).exit_code
39
- )
40
- end
41
- end
@@ -1,33 +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__), '../product/product_helpers')
4
-
5
- describe "get product info" do
6
- include OrganizationHelpers
7
- include ProductHelpers
8
-
9
- it 'by ID' do
10
- expect_product_show(:id => 1)
11
- assert_equal(
12
- 0,
13
- run_cmd(%w(product info --id 1)).exit_code
14
- )
15
- end
16
-
17
- it 'by organization id and product name' do
18
- expect_product_show(:name => 'product1', :org_id => 1, :id => 1)
19
- assert_equal(
20
- 0,
21
- run_cmd(%w(product info --organization-id 1 --name product1)).exit_code
22
- )
23
- end
24
-
25
- it 'by organization name and product name' do
26
- expect_organization_search('org1', 1)
27
- expect_product_show(:name => 'product1', :org_id => 1, :id => 1)
28
- assert_equal(
29
- 0,
30
- run_cmd(%w(product info --organization org1 --name product1)).exit_code
31
- )
32
- end
33
- end
@@ -1,58 +0,0 @@
1
- require File.join(File.dirname(__FILE__), '../test_helper')
2
- require File.join(File.dirname(__FILE__), 'product_helpers')
3
-
4
- describe "listing products" do
5
- include ProductHelpers
6
-
7
- let(:empty_response_table) do
8
- <<eostring
9
- ---|------|-------------|--------------|--------------|-----------
10
- ID | NAME | DESCRIPTION | ORGANIZATION | REPOSITORIES | SYNC STATE
11
- ---|------|-------------|--------------|--------------|-----------
12
- eostring
13
- end
14
-
15
- it 'displays the table properly' do
16
- api_expects(:products, :index, 'index products').returns(index_response([]))
17
- assert_cmd(
18
- success_result(empty_response_table),
19
- run_cmd(%w(product list --organization-id 1))
20
- )
21
- end
22
-
23
- it 'by organization ID' do
24
- ex = api_expects(:products, :index, 'index products') do |par|
25
- par['organization_id'] == 1
26
- end
27
- ex.returns(index_response([]))
28
-
29
- assert_equal(
30
- 0,
31
- run_cmd(%w(product list --organization-id 1)).exit_code
32
- )
33
- end
34
-
35
- it 'by organization ID and subscription ID' do
36
- ex = api_expects(:products, :index, 'organization product list') do |par|
37
- par['organization_id'] == 1 && par['subscription_id'] == 1
38
- end
39
- ex.returns(index_response([]))
40
-
41
- assert_equal(
42
- 0,
43
- run_cmd(%w(product list --organization-id 1 --subscription-id 1)).exit_code
44
- )
45
- end
46
-
47
- it 'by organization ID and sync plan ID' do
48
- ex = api_expects(:products, :index, 'organization product list') do |par|
49
- par['organization_id'] == 1 && par['sync_plan_id'] == 1
50
- end
51
- ex.returns(index_response([]))
52
-
53
- assert_equal(
54
- 0,
55
- run_cmd(%w(product list --organization-id 1 --sync-plan-id 1)).exit_code
56
- )
57
- end
58
- end
@@ -1,24 +0,0 @@
1
- module ProductHelpers
2
- def expect_generic_product_search(params = {}, returns = {})
3
- api_expects(:products, :index, 'Find the Product')
4
- .with_params(params).returns(index_response([returns]))
5
- end
6
-
7
- def expect_product_search(org_id, name, id)
8
- expect_generic_product_search({'name' => name, 'organization_id' => org_id}, 'id' => id)
9
- end
10
-
11
- def expect_product_show(options = {})
12
- raise "#{__method__} must be called with :id" unless (options.keys & [:id]).size == 1
13
-
14
- if options[:name]
15
- raise "#{__method__} used with :name also requires :org_id" unless options[:org_id]
16
- expect_product_search(options[:org_id], options[:name], options[:id])
17
- end
18
-
19
- ex = api_expects(:products, :show, 'Show a Product') do |par|
20
- par['id'] == options[:id]
21
- end
22
- ex.returns(index_response([{'id' => options[:id]}]))
23
- end
24
- end
@@ -1,35 +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 "remove a product's sync plan" do
7
- include OrganizationHelpers
8
- include SyncPlanHelpers
9
- include ProductHelpers
10
-
11
- it "by product ID" do
12
- api_expects(:products, :update, "set sync plan") do |params|
13
- params['id'] == 1 && params['sync_plan_id'].nil?
14
- end
15
-
16
- assert_equal(
17
- 0,
18
- run_cmd(%w(product remove-sync-plan --id 1)).exit_code
19
- )
20
- end
21
-
22
- it "by product name" do
23
- expect_product_search(1, 'product1', 1)
24
- api_expects(:products, :update, "set sync plan") do |params|
25
- params['id'] == 1 && params['sync_plan_id'].nil?
26
- end
27
-
28
- assert_equal(
29
- 0,
30
- run_cmd(%w(product remove-sync-plan
31
- --organization-id 1
32
- --name product1)).exit_code
33
- )
34
- end
35
- end
@@ -1,49 +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 "set a product's sync plan" do
7
- include OrganizationHelpers
8
- include SyncPlanHelpers
9
- include ProductHelpers
10
-
11
- it "by product ID and sync-plan ID" do
12
- api_expects(:products, :update, "set sync plan") do |params|
13
- params['id'] == 1 && params['sync_plan_id'] == 1
14
- end
15
-
16
- assert_equal(
17
- 0,
18
- run_cmd(%w(product set-sync-plan --id 1 --sync-plan-id 1)).exit_code
19
- )
20
- end
21
-
22
- it "by product ID and sync-plan name (requires org ID)" do
23
- expect_sync_plan_search(1, 'syncplan1', 1)
24
- api_expects(:products, :update, "set sync plan") do |params|
25
- params['id'] == 1 && params['sync_plan_id'] == 1
26
- end
27
-
28
- assert_equal(
29
- 0,
30
- run_cmd(%w(product set-sync-plan --organization-id 1 --id 1 --sync-plan syncplan1)).exit_code
31
- )
32
- end
33
-
34
- it "by product name and sync-plan name (both requiring org ID)" do
35
- expect_product_search(1, 'product1', 1)
36
- expect_sync_plan_search(1, 'syncplan1', 1)
37
- api_expects(:products, :update, "set sync plan") do |params|
38
- params['id'] == 1 && params['sync_plan_id'] == 1
39
- end
40
-
41
- assert_equal(
42
- 0,
43
- run_cmd(%w(product set-sync-plan
44
- --organization-id 1
45
- --name product1
46
- --sync-plan syncplan1)).exit_code
47
- )
48
- end
49
- end
@@ -1,48 +0,0 @@
1
- require File.join(File.dirname(__FILE__), '../test_helper')
2
-
3
- describe 'update an http proxy on a product' do
4
- include ForemanTaskHelpers
5
-
6
- before do
7
- @cmd = %w(product update-proxy)
8
- end
9
-
10
- let(:sync_response) do
11
- {
12
- 'id' => 1,
13
- 'state' => 'planned',
14
- 'action' => 'Update http proxy'
15
- }
16
- end
17
-
18
- it 'updates product proxy policy' do
19
- params = [
20
- '--ids=1',
21
- '--http-proxy-policy=use_selected_http_proxy',
22
- '--http-proxy-id=1'
23
- ]
24
-
25
- ex = api_expects(:products_bulk_actions, :update_http_proxy, 'update an http-proxy')
26
- .with_params('ids' => '1', 'http_proxy_policy' => 'use_selected_http_proxy',
27
- 'http_proxy_id' => '1')
28
- ex.returns(sync_response)
29
-
30
- expect_foreman_task('3')
31
-
32
- result = run_cmd(@cmd + params)
33
- assert_equal(HammerCLI::EX_OK, result.exit_code)
34
- end
35
-
36
- it 'fails with missing required params' do
37
- params = ['--proxy-id=1']
38
-
39
- ex = api_expects(:products_bulk_actions, :update_http_proxy, 'update an http-proxy')
40
- .with_params('proxy_id' => '1')
41
- ex.returns(
42
- 'proxy_id' => '1'
43
- )
44
-
45
- result = run_cmd(@cmd + params)
46
- assert_equal(result.exit_code, 70)
47
- end
48
- end
@@ -1,46 +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__), '../product/product_helpers')
4
-
5
- describe 'update a product' do
6
- include OrganizationHelpers
7
- include ProductHelpers
8
-
9
- it 'by product ID' do
10
- api_expects(:products, :update, 'update a product') do |par|
11
- par['id'] == 1 &&
12
- par['description'] == 'new_description'
13
- end
14
- assert_equal(
15
- 0,
16
- run_cmd(%w(product update --organization-id 1 --id 1 --description new_description)).exit_code
17
- )
18
- end
19
-
20
- it 'by organization ID and product name' do
21
- expect_product_search(1, 'product1', 1)
22
- api_expects(:products, :update, 'update a product') do |par|
23
- par['id'] == 1 &&
24
- par['description'] == 'new_description'
25
- end
26
- command = %w(product update --organization-id 1 --name product1 --description new_description)
27
- assert_equal(
28
- 0,
29
- run_cmd(command).exit_code
30
- )
31
- end
32
-
33
- it 'by organization name and product name' do
34
- expect_organization_search('org1', 1)
35
- expect_product_search(1, 'product1', 1)
36
- api_expects(:products, :update, 'update a product') do |par|
37
- par['id'] == 1 &&
38
- par['description'] == 'new_description'
39
- end
40
- command = %w(product update --organization org1 --name product1 --description new_description)
41
- assert_equal(
42
- 0,
43
- run_cmd(command).exit_code
44
- )
45
- end
46
- end
@@ -1,21 +0,0 @@
1
- require_relative '../test_helper'
2
-
3
- describe "create repository" do
4
- let(:org_id) { 1 }
5
- let(:product_id) { 2 }
6
- let(:name) { "repo1" }
7
- let(:content_type) { "yum" }
8
-
9
- it 'with basic options' do
10
- api_expects(:repositories, :create)
11
- .with_params(
12
- name: name,
13
- product_id: product_id,
14
- content_type: content_type)
15
-
16
- command = %W(repository create --organization-id #{org_id} --product-id #{product_id}
17
- --content-type #{content_type} --name #{name})
18
-
19
- assert_equal(0, run_cmd(command).exit_code)
20
- end
21
- end