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,91 +0,0 @@
1
- module ErratumHelpers
2
- # rubocop:disable MethodLength
3
- def make_erratum_response(with_packages = true, with_module_streams = true)
4
- packs = with_packages ? packages : []
5
- if with_module_streams
6
- module_streams = [
7
- {
8
- "name" => module_stream[:name],
9
- "stream" => module_stream[:stream],
10
- "version" => "20180730223407",
11
- "context" => "deadbeef",
12
- "arch" => "noarch",
13
- "id" => 4,
14
- "packages" => packs
15
- }
16
- ]
17
- else
18
- module_streams = []
19
- end
20
- {
21
- "id" => 6,
22
- "pulp_id" => "a4999071-2e2a-4293-9a72-219924032633",
23
- "title" => "Duck_Kangaroo_Erratum",
24
- "errata_id" => "RHEA-2012:0059",
25
- "issued" => "2018-01-27",
26
- "updated" => "2018-07-20",
27
- "severity" => "",
28
- "description" => "Duck_Kangaro_Erratum description",
29
- "solution" => "",
30
- "summary" => "",
31
- "reboot_suggested" => false,
32
- "uuid" => "a4999071-2e2a-4293-9a72-219924032633",
33
- "name" => "Duck_Kangaroo_Erratum",
34
- "type" => "enhancement",
35
- "cves" => [],
36
- "bugs" => [],
37
- "hosts_available_count" => 0,
38
- "hosts_applicable_count" => 0,
39
- "packages" => packages,
40
- "module_streams" => module_streams
41
- }
42
- end
43
-
44
- def packages
45
- ["kangaroo-0.3-1.noarch", "bar"]
46
- end
47
-
48
- def module_stream
49
- {name: "MyMOdule", stream: "cool-100"}
50
- end
51
-
52
- def erratum_id
53
- "1"
54
- end
55
-
56
- def host_id
57
- 1
58
- end
59
-
60
- def verify_module_packages_and_orphan_packages(result)
61
- result_out = result.out
62
- # output looks like
63
- # => "Title: Duck_Kangaroo_Erratum\n
64
- # Description: Duck_Kangaro_Erratum description\n
65
- # ID: 6
66
- # \nErrata ID: RHEA-2012:0059\nReboot Suggested: false\n
67
- # Updated: 2018-07-20\nIssued: 2018-01-27\nSolution:
68
- # \nPackages: kangaroo-0.3-1.noarch
69
- #\nModule Streams: \n 1) Name: kangaroo\n Stream: 0
70
- # \n Packages: kangaroo-0.3-1.noarch\n\n
71
- module_streams_out = result_out.slice(result_out.index("Module Streams")..-1)
72
- package_out = result_out.slice(0..result_out.index("Module Streams"))
73
-
74
- assert_includes(module_streams_out, "Name")
75
- assert_includes(module_streams_out, module_stream[:name])
76
- assert_includes(module_streams_out, "Stream")
77
- assert_includes(module_streams_out, module_stream[:stream])
78
- assert_includes(module_streams_out, packages.first)
79
- assert_includes(module_streams_out, packages.last)
80
-
81
- assert_includes(package_out, packages.first)
82
- assert_includes(package_out, packages.last)
83
- end
84
-
85
- def verify_no_modules_packages_with_orphan_packages(result)
86
- result_out = result.out
87
- refute_includes(result_out, "Module Streams")
88
- assert_includes(result_out, packages.first)
89
- assert_includes(result_out, packages.last)
90
- end
91
- end
@@ -1,29 +0,0 @@
1
- require_relative '../test_helper'
2
- require_relative 'erratum_helpers'
3
-
4
- describe 'Erratum Info' do
5
- include ErratumHelpers
6
-
7
- before do
8
- @cmd = %w(erratum info)
9
- end
10
-
11
- it "prints module package info on run" do
12
- api_expects(:errata, :show)
13
- .with_params('id' => erratum_id)
14
- .returns(make_erratum_response)
15
- params = ["--id=#{erratum_id}"]
16
- result = run_cmd(@cmd + params)
17
- verify_module_packages_and_orphan_packages(result)
18
- end
19
-
20
- it "prints package info on run" do
21
- api_expects(:errata, :show)
22
- .with_params('id' => erratum_id)
23
- .returns(make_erratum_response(true, false))
24
-
25
- params = ["--id=#{erratum_id}"]
26
- result = run_cmd(@cmd + params)
27
- verify_no_modules_packages_with_orphan_packages(result)
28
- end
29
- end
@@ -1,108 +0,0 @@
1
- require_relative '../test_helper'
2
- require 'hammer_cli_katello/erratum'
3
-
4
- module HammerCLIKatello
5
- describe ErratumCommand::ListCommand do
6
- it 'allows minimal options' do
7
- api_expects(:errata, :index)
8
-
9
- run_cmd(%w(erratum list))
10
- end
11
-
12
- describe 'product options' do
13
- it 'may be specified by ID' do
14
- ex = api_expects(:repositories, :index) do |p|
15
- p['product_id'] == 1
16
- end
17
- ex.returns(index_response([{'id' => 2}]))
18
-
19
- api_expects(:errata, :index) do |p|
20
- p['repository_id'] = 2
21
- end
22
-
23
- run_cmd(%w(erratum list --product-id 1))
24
- end
25
-
26
- it 'fail if more than one repository is found' do
27
- ex = api_expects(:repositories, :index) do |p|
28
- p['product_id'] == 1
29
- end
30
- ex.returns(index_response([{'id' => 2}, {'id' => 3}]))
31
-
32
- r = run_cmd(%w(erratum list --product-id 1))
33
- assert r.err.include?("Found more than one repository."), r.err
34
- end
35
-
36
- it 'requires organization options to resolve ID by name' do
37
- api_expects_no_call
38
-
39
- r = run_cmd(%w(erratum list --product product1))
40
- assert r.err.include? "--organization-id, --organization, --organization-label is required"
41
- end
42
-
43
- it 'allows organization ID when resolving ID by name' do
44
- ex = api_expects(:products, :index) do |p|
45
- p['name'] == 'product1' && p['organization_id'] == 3
46
- end
47
- ex.returns(index_response([{'id' => 1}]))
48
-
49
- ex = api_expects(:repositories, :index) do |p|
50
- p['product_id'] == 1
51
- end
52
- ex.returns(index_response([{'id' => 2}]))
53
-
54
- api_expects(:errata, :index) do |p|
55
- p['repository_id'] = 2
56
- end
57
-
58
- run_cmd(%w(erratum list --product product1 --organization-id 3))
59
- end
60
-
61
- it 'allows organization name when resolving ID by name' do
62
- ex = api_expects(:organizations, :index) do |p|
63
- p[:search] == "name = \"org3\""
64
- end
65
- ex.at_least_once.returns(index_response([{'id' => 3}]))
66
-
67
- ex = api_expects(:products, :index) do |p|
68
- p['name'] == 'product1' && p['organization_id'] == 3
69
- end
70
- ex.returns(index_response([{'id' => 1}]))
71
-
72
- ex = api_expects(:repositories, :index) do |p|
73
- p['product_id'] == 1
74
- end
75
- ex.returns(index_response([{'id' => 2}]))
76
-
77
- api_expects(:errata, :index) do |p|
78
- p['repository_id'] = 2
79
- end
80
-
81
- run_cmd(%w(erratum list --product product1 --organization org3))
82
- end
83
-
84
- it 'allows organization label when resolving ID by name' do
85
- ex = api_expects(:organizations, :index) do |p|
86
- p[:search] == "label = \"org3\""
87
- end
88
- ex.at_least_once.returns(index_response([{'id' => 3}]))
89
-
90
- ex = api_expects(:products, :index) do |p|
91
- p['name'] == 'product1' && p['organization_id'] == 3
92
- end
93
- ex.returns(index_response([{'id' => 1}]))
94
-
95
- ex = api_expects(:repositories, :index) do |p|
96
- p['product_id'] == 1
97
- end
98
- ex.returns(index_response([{'id' => 2}]))
99
-
100
- api_expects(:errata, :index) do |p|
101
- p['repository_id'] = 2
102
- end
103
-
104
- run_cmd(%w(erratum list --product product1 --organization-label org3))
105
- end
106
- end
107
- end
108
- end
@@ -1,13 +0,0 @@
1
- require_relative '../search_helpers'
2
-
3
- module FileHelpers
4
- include SearchHelpers
5
-
6
- def expect_file_search(params, returns)
7
- expect_generic_search(:file_units, params: params, returns: returns)
8
- end
9
-
10
- def expect_file_show(params)
11
- api_expects(:file_units, :show).with_params(params)
12
- end
13
- end
@@ -1,162 +0,0 @@
1
- require_relative '../test_helper.rb'
2
- require_relative '../organization/organization_helpers'
3
- require_relative '../content_view/content_view_helpers'
4
- require_relative '../repository/repository_helpers'
5
- require_relative '../product/product_helpers'
6
- require_relative 'file_helpers'
7
- require 'hammer_cli_katello/file'
8
-
9
- # rubocop:disable ModuleLength
10
- module HammerCLIKatello
11
- describe FileCommand::InfoCommand do
12
- include FileHelpers
13
- include ContentViewHelpers
14
- include RepositoryHelpers
15
- include ProductHelpers
16
- include OrganizationHelpers
17
-
18
- it 'allows minimal options' do
19
- expect_file_show('id' => '1')
20
- run_cmd(%w(file info --id 1))
21
- end
22
-
23
- describe 'requires' do
24
- describe 'organization options' do
25
- it 'to resolve product ID' do
26
- api_expects_no_call
27
- result = run_cmd(%w(file list --product product1))
28
- assert_match(/--organization-id/, result.err)
29
- end
30
-
31
- it 'to resolve content view ID' do
32
- api_expects_no_call
33
- result = run_cmd(%w(file list --content-view cv1))
34
- assert_match(/--organization-id/, result.err)
35
- end
36
- end
37
-
38
- describe 'product options' do
39
- it 'to resolve repository ID' do
40
- api_expects_no_call
41
- result = run_cmd(%w(file list --repository repo1))
42
- assert_match(/--product-id/, result.err)
43
- end
44
- end
45
- end
46
-
47
- describe 'allows filtering by' do
48
- it 'repository ID' do
49
- expect_file_search({'repository_id' => 2}, {})
50
- run_cmd(%w(file list --repository-id 2))
51
- end
52
-
53
- it 'content view version ID' do
54
- expect_file_search({'content_view_version_id' => 2}, {})
55
- run_cmd(%w(file list --content-view-version-id 2))
56
- end
57
- end
58
-
59
- describe 'resolves ID from file name' do
60
- it 'and repository ID' do
61
- expect_file_search({'repository_id' => '2', search: "name = \"foo\""}, 'id' => 1)
62
- expect_file_show('id' => 1)
63
- run_cmd(%w(file info --name foo --repository-id 2))
64
- end
65
-
66
- describe 'repository name' do
67
- it 'and product ID' do
68
- expect_generic_repositories_search({'name' => 'repo2', 'product_id' => 1}, 'id' => 2)
69
- expect_file_search({'repository_id' => '2', search: "name = \"foo\""}, 'id' => 1)
70
- expect_file_show('id' => 1)
71
- run_cmd(%w(file info --name foo --repository repo2 --product-id 1))
72
- end
73
-
74
- describe 'product name, and organization' do
75
- it 'ID' do
76
- expect_generic_product_search({'name' => 'product1', 'organization_id' => 3}, 'id' => 1)
77
- expect_generic_repositories_search({'name' => 'repo2', 'product_id' => 1}, 'id' => 2)
78
- expect_file_search({'repository_id' => '2', search: "name = \"foo\""}, 'id' => 1)
79
- expect_file_show('id' => 1)
80
- run_cmd(%w(file info --name foo --repository repo2 --product product1
81
- --organization-id 3))
82
- end
83
-
84
- it 'name' do
85
- expect_organization_search('org3', 3)
86
- expect_generic_product_search({'name' => 'product1', 'organization_id' => 3}, 'id' => 1)
87
- expect_generic_repositories_search({'name' => 'repo2', 'product_id' => 1}, 'id' => 2)
88
- expect_file_search({'repository_id' => '2', search: "name = \"foo\""}, 'id' => 1)
89
- expect_file_show('id' => 1)
90
- run_cmd(%w(file info --name foo --repository repo2 --product product1
91
- --organization org3))
92
- end
93
-
94
- it 'label' do
95
- expect_organization_search('org3', 3, field: 'label')
96
- expect_generic_product_search({'name' => 'product1', 'organization_id' => 3}, 'id' => 1)
97
- expect_generic_repositories_search({'name' => 'repo2', 'product_id' => 1}, 'id' => 2)
98
- expect_file_search({'repository_id' => '2', search: "name = \"foo\""}, 'id' => 1)
99
- expect_file_show('id' => 1)
100
- run_cmd(%w(file info --name foo --repository repo2 --product product1
101
- --organization-label org3))
102
- end
103
- end
104
- end
105
-
106
- it 'and content view version ID' do
107
- expect_file_search({'content_view_version_id' => '2', 'name' => 'foo'}, 'id' => 1)
108
- expect_file_show('id' => 1)
109
- run_cmd(%w(file info --name foo --content-view-version-id 2))
110
- end
111
-
112
- describe 'content view version' do
113
- it 'and content view ID' do
114
- expect_content_view_version_search({'version' => '2.0',
115
- 'content_view_id' => 3}, 'id' => 2)
116
- expect_file_search({'content_view_version_id' => '2',
117
- search: "name = \"foo\""}, 'id' => 1)
118
- expect_file_show('id' => 1)
119
- run_cmd(%w(file info --name foo --content-view-version 2.0 --content-view-id 3))
120
- end
121
-
122
- describe 'content view name, and organization' do
123
- it 'ID' do
124
- expect_content_view_search(4, 'cv3', 3)
125
- expect_content_view_version_search({'version' => '2.0',
126
- 'content_view_id' => 3}, 'id' => 2)
127
- expect_file_search({'content_view_version_id' => '2',
128
- search: "name = \"foo\""}, 'id' => 1)
129
- expect_file_show('id' => 1)
130
- run_cmd(%w(file info --name foo --content-view-version 2.0 --content-view cv3
131
- --organization-id 4))
132
- end
133
-
134
- it 'name' do
135
- expect_organization_search('org4', 4)
136
- expect_content_view_search(4, 'cv3', 3)
137
- expect_content_view_version_search({'version' => '2.0',
138
- 'content_view_id' => 3}, 'id' => 2)
139
- expect_file_search({'content_view_version_id' => '2',
140
- search: "name = \"foo\""}, 'id' => 1)
141
- expect_file_show('id' => 1)
142
- run_cmd(%w(file info --name foo --content-view-version 2.0 --content-view cv3
143
- --organization org4))
144
- end
145
-
146
- it 'label' do
147
- expect_organization_search('org4', 4, field: 'label')
148
- expect_content_view_search(4, 'cv3', 3)
149
- expect_content_view_version_search({'version' => '2.0',
150
- 'content_view_id' => 3}, 'id' => 2)
151
- expect_file_search({'content_view_version_id' => '2',
152
- search: "name = \"foo\""}, 'id' => 1)
153
- expect_file_show('id' => 1)
154
- run_cmd(%w(file info --name foo --content-view-version 2.0 --content-view cv3
155
- --organization-label org4))
156
- end
157
- end
158
- end
159
- end
160
- end
161
- end
162
- # rubocop:enable ModuleLength
@@ -1,112 +0,0 @@
1
- require_relative '../test_helper.rb'
2
- require_relative '../organization/organization_helpers'
3
- require_relative '../content_view/content_view_helpers'
4
- require_relative '../repository/repository_helpers'
5
- require_relative '../product/product_helpers'
6
- require_relative 'file_helpers'
7
- require 'hammer_cli_katello/file'
8
-
9
- module HammerCLIKatello
10
- describe FileCommand::ListCommand do
11
- include FileHelpers
12
- include ContentViewHelpers
13
- include RepositoryHelpers
14
- include ProductHelpers
15
- include OrganizationHelpers
16
-
17
- it 'allows minimal options' do
18
- expect_file_search({}, {})
19
- run_cmd(%w(file list))
20
- end
21
-
22
- describe 'requires' do
23
- describe 'organization options' do
24
- it 'to resolve product ID' do
25
- api_expects_no_call
26
- result = run_cmd(%w(file list --product product1))
27
- assert_match(/--organization-id/, result.err)
28
- end
29
-
30
- it 'to resolve content view ID' do
31
- api_expects_no_call
32
- result = run_cmd(%w(file list --content-view cv1))
33
- assert_match(/--organization-id/, result.err)
34
- end
35
- end
36
-
37
- describe 'product options' do
38
- it 'to resolve repository ID' do
39
- api_expects_no_call
40
- result = run_cmd(%w(file list --repository repo1))
41
- assert_match(/--product-id/, result.err)
42
- end
43
- end
44
- end
45
-
46
- describe 'allows filtering by' do
47
- it 'repository ID' do
48
- expect_file_search({'repository_id' => 2}, {})
49
- run_cmd(%w(file list --repository-id 2))
50
- end
51
-
52
- it 'content view version ID' do
53
- expect_file_search({'content_view_version_id' => 2}, {})
54
- run_cmd(%w(file list --content-view-version-id 2))
55
- end
56
- end
57
-
58
- describe 'resolves' do
59
- describe 'repository ID' do
60
- it 'from name and product ID' do
61
- expect_generic_repositories_search(
62
- {'name' => 'repo2', 'product_id' => 1}, 'id' => 2)
63
- expect_file_search({'repository_id' => 2}, {})
64
- run_cmd(%w(file list --repository repo2 --product-id 1))
65
- end
66
-
67
- it 'from name, product, and organization ID' do
68
- expect_generic_product_search({'name' => 'product1', 'organization_id' => 3}, 'id' => 1)
69
- expect_generic_repositories_search({'name' => 'repo2', 'product_id' => 1}, 'id' => 2)
70
- expect_file_search({'repository_id' => 2}, {})
71
- run_cmd(%w(file list --repository repo2 --product product1 --organization-id 3))
72
- end
73
-
74
- it 'from name, product, and organization name' do
75
- expect_organization_search('org3', 3)
76
- expect_generic_product_search({'name' => 'product1', 'organization_id' => 3}, 'id' => 1)
77
- expect_generic_repositories_search({'name' => 'repo2', 'product_id' => 1}, 'id' => 2)
78
- expect_file_search({'repository_id' => 2}, {})
79
- run_cmd(%w(file list --repository repo2 --product product1 --organization org3))
80
- end
81
- end
82
-
83
- describe 'content view version ID' do
84
- it 'from version and content view ID' do
85
- expect_content_view_version_search(
86
- {'version' => '1.0', 'content_view_id' => 1}, 'id' => 2)
87
- expect_file_search({'content_view_version_id' => 2}, {})
88
- run_cmd(%w(file list --content-view-version 1.0 --content-view-id 1))
89
- end
90
-
91
- it 'from version, content view name, and organization ID' do
92
- expect_generic_content_view_search(params: {'name' => 'cv1', 'organization_id' => 3},
93
- returns: {'id' => 1})
94
- expect_content_view_version_search(
95
- {'version' => '1.0', 'content_view_id' => 1}, 'id' => 2)
96
- expect_file_search({'content_view_version_id' => 2}, {})
97
- run_cmd(%w(file list --content-view-version 1.0 --content-view cv1 --organization-id 3))
98
- end
99
-
100
- it 'from version, content view name, and organization name' do
101
- expect_organization_search('org3', 3)
102
- expect_generic_content_view_search(params: {'name' => 'cv1', 'organization_id' => 3},
103
- returns: {'id' => 1})
104
- expect_content_view_version_search(
105
- {'version' => '1.0', 'content_view_id' => 1}, 'id' => 2)
106
- expect_file_search({'content_view_version_id' => 2}, {})
107
- run_cmd(%w(file list --content-view-version 1.0 --content-view cv1 --organization org3))
108
- end
109
- end
110
- end
111
- end
112
- end
@@ -1,99 +0,0 @@
1
- require_relative '../test_helper'
2
- require 'hammer_cli_katello/filter_rule'
3
-
4
- module HammerCLIKatello
5
- describe FilterRule::CreateCommand do
6
- it 'allows minimal options' do
7
- api_expects(:content_view_filter_rules, :create) do |p|
8
- p['content_view_filter_id'] == 1 && p['name'] == %w(rpm1)
9
- end
10
- run_cmd(%w(content-view filter rule create --content-view-filter-id 1 --name rpm1))
11
- end
12
-
13
- it 'allows multiple package names' do
14
- api_expects(:content_view_filter_rules, :create) do |p|
15
- p['content_view_filter_id'] == 1 && p['name'] == %w(rpm1 rpm2)
16
- end
17
- run_cmd(%w(content-view filter rule create --content-view-filter-id 1 --names rpm1,rpm2))
18
- end
19
-
20
- it 'allows name resolution of filter with content-view-id' do
21
- ex = api_expects(:content_view_filters, :index) do |p|
22
- p['name'] == 'cvf1' && p['content_view_id'] == 3
23
- end
24
- ex.returns(index_response([{'id' => 1}]))
25
-
26
- api_expects(:content_view_filter_rules, :create) do |p|
27
- p['content_view_filter_id'] == 1 && p['name'] == %w(rule9)
28
- end
29
- run_cmd(%w(content-view filter rule create --content-view-filter cvf1 --content-view-id 3
30
- --name rule9))
31
- end
32
-
33
- describe 'organization' do
34
- it 'ID can be specified to resolve content view name' do
35
- ex = api_expects(:content_views, :index) do |p|
36
- p['name'] == 'cv3' && p['organization_id'] == '6'
37
- end
38
- ex.returns(index_response([{'id' => 3}]))
39
-
40
- ex = api_expects(:content_view_filters, :index) do |p|
41
- p['name'] == 'cvf1' && p['content_view_id'] == 3
42
- end
43
- ex.returns(index_response([{'id' => 1}]))
44
-
45
- api_expects(:content_view_filter_rules, :create) do |p|
46
- p['content_view_filter_id'] == 1 && p['name'] == %w(rule9)
47
- end
48
- run_cmd(%w(content-view filter rule create --content-view-filter cvf1 --organization-id 6
49
- --content-view cv3 --name rule9))
50
- end
51
-
52
- it 'name can be specified to resolve content view name' do
53
- ex = api_expects(:organizations, :index) do |p|
54
- p[:search] == "name = \"org6\""
55
- end
56
- ex.returns(index_response([{'id' => 6}]))
57
-
58
- ex = api_expects(:content_views, :index) do |p|
59
- p['name'] == 'cv3' && p['organization_id'] == 6
60
- end
61
- ex.returns(index_response([{'id' => 3}]))
62
-
63
- ex = api_expects(:content_view_filters, :index) do |p|
64
- p['name'] == 'cvf1' && p['content_view_id'] == 3
65
- end
66
- ex.returns(index_response([{'id' => 1}]))
67
-
68
- api_expects(:content_view_filter_rules, :create) do |p|
69
- p['content_view_filter_id'] == 1 && p['name'] == %w(rule9)
70
- end
71
- run_cmd(%w(content-view filter rule create --content-view-filter cvf1 --organization org6
72
- --content-view cv3 --name rule9))
73
- end
74
-
75
- it 'label can be specified to resolve content view name' do
76
- ex = api_expects(:organizations, :index) do |p|
77
- p[:search] == "label = \"org6\""
78
- end
79
- ex.returns(index_response([{'id' => 6}]))
80
-
81
- ex = api_expects(:content_views, :index) do |p|
82
- p['name'] == 'cv3' && p['organization_id'] == 6
83
- end
84
- ex.returns(index_response([{'id' => 3}]))
85
-
86
- ex = api_expects(:content_view_filters, :index) do |p|
87
- p['name'] == 'cvf1' && p['content_view_id'] == 3
88
- end
89
- ex.returns(index_response([{'id' => 1}]))
90
-
91
- api_expects(:content_view_filter_rules, :create) do |p|
92
- p['content_view_filter_id'] == 1 && p['name'] == %w(rule9)
93
- end
94
- run_cmd(%w(content-view filter rule create --content-view-filter cvf1 --organization-label
95
- org6 --content-view cv3 --name rule9))
96
- end
97
- end
98
- end
99
- end