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,17 +0,0 @@
1
- module SearchHelpers
2
- def expect_generic_search(resource, args)
3
- ex = api_expects(resource, :index, "Find the #{resource}").with_params(args[:params])
4
- ex.returns(index_response([args[:returns]]))
5
- end
6
-
7
- def expect_lenient_search(resource, params:, returns:)
8
- ex = api_expects(resource, :index, "Find the #{resource}") do |p|
9
- params.each do |key, expected|
10
- actual = p[key] || p[key.to_sym] || p[key.to_s]
11
- assert_equal expected.to_s, actual.to_s, "key: '#{key}', resource: #{resource}"
12
- end
13
- end
14
- returns = [returns] unless returns.is_a? Array
15
- ex.returns(index_response(returns))
16
- end
17
- end
@@ -1,48 +0,0 @@
1
- require File.join(File.dirname(__FILE__), '../../test_helper')
2
-
3
- describe 'simple-content-access disable' do
4
- before do
5
- @cmd = %w(simple-content-access disable)
6
- end
7
-
8
- let(:organization_id) { 3 }
9
-
10
- it "disables with required options" do
11
- params = ["--organization-id=#{organization_id}"]
12
-
13
- api_expects(:simple_content_access, :eligible).
14
- with_params('organization_id' => organization_id).
15
- returns("simple_content_access_eligible" => true)
16
-
17
- api_expects(:simple_content_access, :disable)
18
- .with_params('organization_id' => organization_id)
19
- run_cmd(@cmd + params)
20
- end
21
-
22
- it 'fails on missing required params' do
23
- params = []
24
-
25
- result = run_cmd(@cmd + params)
26
- expected_error = "Could not disable Simple Content Access for this organization"
27
-
28
- assert_equal(result.exit_code, HammerCLI::EX_SOFTWARE)
29
- assert_equal(result.err[/#{expected_error}/], expected_error)
30
- end
31
-
32
- it 'fails on non eligible org' do
33
- params = ["--organization-id=#{organization_id}"]
34
-
35
- api_expects(:simple_content_access, :eligible).
36
- with_params('organization_id' => organization_id).
37
- returns("simple_content_access_eligible" => false)
38
-
39
- api_expects(:simple_content_access, :disable)
40
- .with_params('organization_id' => organization_id).never
41
- result = run_cmd(@cmd + params)
42
-
43
- expected_error = "Could not disable Simple Content Access for this organization"
44
-
45
- assert_equal(result.exit_code, HammerCLI::EX_SOFTWARE)
46
- assert_equal(result.err[/#{expected_error}/], expected_error)
47
- end
48
- end
@@ -1,46 +0,0 @@
1
- require File.join(File.dirname(__FILE__), '../../test_helper')
2
-
3
- describe 'simple-content-access enable' do
4
- before do
5
- @cmd = %w(simple-content-access enable)
6
- end
7
-
8
- let(:organization_id) { 3 }
9
-
10
- it "enables with required options" do
11
- params = ["--organization-id=#{organization_id}"]
12
- api_expects(:simple_content_access, :eligible).
13
- with_params('organization_id' => organization_id).
14
- returns("simple_content_access_eligible" => true)
15
-
16
- api_expects(:simple_content_access, :enable)
17
- .with_params('organization_id' => organization_id)
18
- run_cmd(@cmd + params)
19
- end
20
-
21
- it 'fails on missing required params' do
22
- params = []
23
- result = run_cmd(@cmd + params)
24
- expected_error = "Could not enable Simple Content Access for this organization"
25
-
26
- assert_equal(result.exit_code, HammerCLI::EX_SOFTWARE)
27
- assert_equal(result.err[/#{expected_error}/], expected_error)
28
- end
29
-
30
- it 'fails on non eligible org' do
31
- params = ["--organization-id=#{organization_id}"]
32
-
33
- api_expects(:simple_content_access, :eligible).
34
- with_params('organization_id' => organization_id).
35
- returns("simple_content_access_eligible" => false)
36
-
37
- api_expects(:simple_content_access, :enable)
38
- .with_params('organization_id' => organization_id).never
39
- result = run_cmd(@cmd + params)
40
-
41
- expected_error = "Could not enable Simple Content Access for this organization"
42
-
43
- assert_equal(result.exit_code, HammerCLI::EX_SOFTWARE)
44
- assert_equal(result.err[/#{expected_error}/], expected_error)
45
- end
46
- end
@@ -1,92 +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 'hammer_cli_katello/package'
6
- require 'hammer_cli_katello/srpm'
7
-
8
- module HammerCLIKatello
9
- describe SrpmCommand::ListCommand do
10
- include OrganizationHelpers
11
- include RepositoryHelpers
12
- include ProductHelpers
13
-
14
- it 'allows minimal options' do
15
- api_expects(:srpms, :index)
16
-
17
- run_cmd(%w(srpm list))
18
- end
19
-
20
- describe 'repository options' do
21
- it 'may be specified by ID' do
22
- api_expects(:srpms, :index).with_params('repository_id' => 1)
23
-
24
- run_cmd(%w(srpm list --repository-id 1))
25
- end
26
-
27
- it 'require product ID when given repository name' do
28
- api_expects_no_call
29
-
30
- r = run_cmd(%w(srpm list --repository repo1))
31
- assert(r.err.include?("--product-id, --product is required"), "Invalid error message")
32
- end
33
-
34
- it 'may be specified by name and product ID' do
35
- expect_repository_search(2, 'repo1', 1)
36
-
37
- api_expects(:srpms, :index).with_params('repository_id' => 1)
38
-
39
- run_cmd(%w(srpm list --repository repo1 --product-id 2))
40
- end
41
- end
42
-
43
- describe 'organization options' do
44
- it 'may be specified by ID' do
45
- api_expects(:srpms, :index).with_params('organization_id' => 1)
46
-
47
- run_cmd(%w(srpm list --organization-id 1))
48
- end
49
-
50
- it 'may be specified by name' do
51
- expect_organization_search('org3', 1)
52
- api_expects(:srpms, :index).with_params('organization_id' => 1)
53
-
54
- run_cmd(%w(srpm list --organization org3))
55
- end
56
-
57
- it 'may be specified by label' do
58
- expect_organization_search('org3', 1, field: 'label')
59
- api_expects(:srpms, :index).with_params('organization_id' => 1)
60
-
61
- run_cmd(%w(srpm list --organization-label org3))
62
- end
63
- end
64
-
65
- describe 'content-view options' do
66
- it 'may be specified by ID' do
67
- api_expects(:content_view_versions, :index)
68
- .with_params('content_view_id' => 1, 'version' => '2.1')
69
- .returns(index_response([{'id' => 5}]))
70
- api_expects(:srpms, :index).with_params('content_view_version_id' => 5)
71
-
72
- run_cmd(%w(srpm list --content-view-id 1 --content-view-version 2.1))
73
- end
74
-
75
- it 'requires organization ID when given content view name' do
76
- api_expects_no_call
77
-
78
- r = run_cmd(%w(srpm list --content-view cv1 --content-view-version 2.1))
79
- expected_error = "--organization-id, --organization, --organization-label is required"
80
- assert(r.err.include?(expected_error), "Invalid error message")
81
- end
82
-
83
- it 'requires content view ID when given content view version number' do
84
- api_expects_no_call
85
-
86
- r = run_cmd(%w(srpm list --content-view-version cvv1))
87
- assert(r.err.include?("--content-view-id, --content-view is required"),
88
- "Invalid error message")
89
- end
90
- end
91
- end
92
- end
@@ -1,86 +0,0 @@
1
- require_relative '../test_helper'
2
- require 'hammer_cli_katello/subscription'
3
-
4
- module HammerCLIKatello
5
- describe SubscriptionCommand::ListCommand do
6
- before do
7
- @cmd = %w(subscription list)
8
- end
9
-
10
- let(:org_id) { 1 }
11
-
12
- it "returns the correct subscription type" do
13
- cmd = SubscriptionCommand::ListCommand.new({})
14
- assert_equal("Physical", cmd.get_subscription_type("virt_only" => false))
15
-
16
- hostname = "boo.com"
17
- with_hostname = cmd.get_subscription_type("virt_only" => true, "host" => {"name" => hostname})
18
- assert(with_hostname.include?(hostname))
19
-
20
- assert_equal("Temporary",
21
- cmd.get_subscription_type("virt_only" => true, "unmapper_guest" => true))
22
-
23
- assert_equal("Virtual",
24
- cmd.get_subscription_type("virt_only" => true))
25
- end
26
-
27
- it "lists an organizations subscriptions" do
28
- params = ["--organization-id=#{org_id}"]
29
-
30
- ex = api_expects(:subscriptions, :index, 'Subscription list') do |par|
31
- par['organization_id'] == org_id
32
- end
33
-
34
- ex.returns(index_response([]))
35
-
36
- result = run_cmd(@cmd + params)
37
-
38
- fields = ['ID', 'UUID', 'NAME', 'TYPE', 'CONTRACT', 'ACCOUNT', 'SUPPORT',
39
- 'START DATE', 'END DATE', 'QUANTITY', 'CONSUMED']
40
- expected_result = success_result(IndexMatcher.new([fields, []]))
41
- assert_cmd(expected_result, result)
42
- end
43
-
44
- it 'allows organization name' do
45
- api_expects(:organizations, :index) { |par| par[:search] == "name = \"org1\"" }
46
- .returns(index_response([{'id' => 1}]))
47
-
48
- api_expects(:subscriptions, :index) { |par| par['organization_id'].to_i == 1 }
49
-
50
- run_cmd(%w(subscription list --organization org1))
51
- end
52
-
53
- it 'allows organization label' do
54
- api_expects(:organizations, :index) { |par| par[:search] == "label = \"org1\"" }
55
- .returns(index_response([{'id' => 1}]))
56
-
57
- api_expects(:subscriptions, :index) { |par| par['organization_id'].to_i == 1 }
58
-
59
- run_cmd(%w(subscription list --organization-label org1))
60
- end
61
-
62
- it 'allows host id' do
63
- api_expects(:subscriptions, :index) { |par| par['host_id'] == '1' }
64
- run_cmd(%w(subscription list --organization-id 1 --host-id 1))
65
- end
66
-
67
- it 'allows host name' do
68
- api_expects(:hosts, :index) { |par| par[:search] == "name = \"host1\"" }
69
- .returns(index_response([{'id' => 1}]))
70
- api_expects(:subscriptions, :index) { |par| par['host_id'] == 1 }
71
- run_cmd(%w(subscription list --organization-id 1 --host host1))
72
- end
73
-
74
- it 'allows activation key id' do
75
- api_expects(:subscriptions, :index) { |par| par['activation_key_id'] == '1' }
76
- run_cmd(%w(subscription list --organization-id 1 --activation-key-id 1))
77
- end
78
-
79
- it 'allows activation key name' do
80
- api_expects(:activation_keys, :index) { |par| par['name'] == "ak1" }
81
- .returns(index_response([{'id' => 1}]))
82
- api_expects(:subscriptions, :index) { |par| par['activation_key_id'] == 1 }
83
- run_cmd(%w(subscription list --organization-id 1 --activation-key ak1))
84
- end
85
- end
86
- end
@@ -1,60 +0,0 @@
1
- require_relative '../test_helper'
2
-
3
- describe "create sync plan" do
4
- let(:org_id) { 1 }
5
- let(:name) { "sync_plan1" }
6
- let(:hourly) { "hourly" }
7
- let(:custom) { "custom cron" }
8
- let(:cron) { "10 * * * *" }
9
- let(:date) { "2018-09-08T00:00:00+00:00" }
10
-
11
- it 'with organization ID,name,interval,date and enabled' do
12
- api_expects(:sync_plans, :create, 'create a sync plan').
13
- with_params('organization_id' => org_id,
14
- 'name' => name,
15
- 'interval' => hourly,
16
- 'sync_date' => date,
17
- 'enabled' => true)
18
- command = %W(sync-plan create --organization-id #{org_id} --name #{name}
19
- --interval #{hourly} --enabled 1 --sync-date #{date})
20
- assert_equal(0, run_cmd(command).exit_code)
21
- end
22
-
23
- it 'with custom cron' do
24
- api_expects(:sync_plans, :create, 'create a sync plan').
25
- with_params('organization_id' => org_id,
26
- 'name' => name,
27
- 'interval' => custom,
28
- 'cron_expression' => cron,
29
- 'sync_date' => date,
30
- 'enabled' => true)
31
- # end
32
- command = %W(sync-plan create --organization-id #{org_id} --name #{name} --interval #{custom}
33
- --cron-expression #{cron} --enabled 1 --sync-date #{date})
34
- assert_equal(0, run_cmd(command).exit_code)
35
- end
36
-
37
- it 'fails without organization-id' do
38
- command = %w(sync-plan create --name #{name}
39
- --interval #{hourly} --enabled 1 --sync-date #{date})
40
- refute_equal(0, run_cmd(command).exit_code)
41
- end
42
-
43
- it 'fails without name' do
44
- command = %w(sync-plan create --organization-id #{org_id}
45
- --interval #{hourly} --enabled 1 --sync-date #{date})
46
- refute_equal(0, run_cmd(command).err)
47
- end
48
-
49
- it 'fails without interval' do
50
- command = %w(sync-plan create --organization-id #{org_id} --name #{name}
51
- --enabled 1 --sync-date #{date})
52
- refute_equal(0, run_cmd(command).exit_code)
53
- end
54
-
55
- it 'fails without enabled' do
56
- command = %w(sync-plan create --organization-id #{org_id} --name #{name}
57
- --interval #{hourly} --sync-date #{date})
58
- refute_equal(0, run_cmd(command).exit_code)
59
- end
60
- end
@@ -1,46 +0,0 @@
1
- require_relative '../test_helper'
2
- require_relative 'sync_plan_helpers'
3
- require_relative '../organization/organization_helpers'
4
-
5
- describe 'delete a sync plan' do
6
- include OrganizationHelpers
7
- include SyncPlanHelpers
8
-
9
- let(:org_id) { 1 }
10
- let(:id) { 1 }
11
- let(:name) { "sync_plan1" }
12
- let(:org_name) { "org1" }
13
-
14
- it 'by organization ID and sync plan id' do
15
- api_expects(:sync_plans, :destroy, 'delete a sync plan').
16
- with_params('organization_id' => org_id,
17
- 'id' => id)
18
- command = %W(sync-plan delete --organization-id #{org_id} --id #{id})
19
- assert_equal(0, run_cmd(command).exit_code)
20
- end
21
-
22
- it 'by organization ID and sync plan name' do
23
- expect_sync_plan_search(1, 'sync_plan1', 1)
24
- api_expects(:sync_plans, :destroy, 'delete a sync plan').
25
- with_params('id' => id)
26
- command = %W(sync-plan delete --organization-id #{org_id} --name #{name})
27
- assert_equal(0, run_cmd(command).exit_code)
28
- end
29
-
30
- it 'by organization name and sync plan name' do
31
- expect_organization_search('org1', 1)
32
- expect_sync_plan_search(1, 'sync_plan1', 1)
33
- api_expects(:sync_plans, :destroy, 'delete a sync plan').
34
- with_params('id' => id)
35
- command = %W(sync-plan delete --organization #{org_name} --name #{name})
36
- assert_equal(0, run_cmd(command).exit_code)
37
- end
38
-
39
- it 'by organization name and sync plan id' do
40
- expect_organization_search(org_name, org_id)
41
- api_expects(:sync_plans, :destroy, 'delete a sync plan').
42
- with_params('id' => id)
43
- command = %W(sync-plan delete --organization #{org_name} --id #{id})
44
- assert_equal(0, run_cmd(command).exit_code)
45
- end
46
- end
@@ -1,37 +0,0 @@
1
- require_relative '../test_helper'
2
- require 'hammer_cli_katello/sync_plan'
3
- require_relative 'sync_plan_helpers'
4
- require_relative '../organization/organization_helpers'
5
- module HammerCLIKatello
6
- describe SyncPlan::InfoCommand do
7
- include OrganizationHelpers
8
- include SyncPlanHelpers
9
-
10
- it 'allows ID' do
11
- api_expects(:sync_plans, :show).with_params('id' => 1)
12
-
13
- run_cmd(%w(sync-plan info --id 1))
14
- end
15
-
16
- it 'allows organization id and sync plan name' do
17
- org_id = 1
18
- name = "SyncPlan1"
19
- id = 100
20
- expect_sync_plan_search(org_id, name, id)
21
- api_expects(:sync_plans, :show).with_params('id' => id)
22
- run_cmd("sync-plan info --organization-id #{org_id} --name #{name}".split)
23
- end
24
-
25
- it 'allows organization name and sync plan name' do
26
- org_id = 1
27
- org_label = "org"
28
- name = "SyncPlan1"
29
- id = 100
30
-
31
- expect_organization_search(org_label, org_id, field: 'label')
32
- expect_sync_plan_search(org_id, name, id)
33
- api_expects(:sync_plans, :show).with_params('id' => id)
34
- run_cmd("sync-plan info --organization-label #{org_label} --name #{name}".split)
35
- end
36
- end
37
- end
@@ -1,31 +0,0 @@
1
- require_relative '../test_helper'
2
- require 'hammer_cli_katello/sync_plan'
3
- require_relative 'sync_plan_helpers'
4
- require_relative '../organization/organization_helpers'
5
-
6
- module HammerCLIKatello
7
- describe SyncPlan::ListCommand do
8
- include SyncPlanHelpers
9
- include OrganizationHelpers
10
-
11
- it 'allows minimal options' do
12
- expect_sync_plan_search(1, nil, nil)
13
-
14
- run_cmd(%w(sync-plan list --organization-id 1))
15
- end
16
-
17
- it 'allows org name' do
18
- expect_organization_search('org1', 1)
19
- expect_sync_plan_search(1, nil, nil)
20
-
21
- run_cmd(%w(sync-plan list --organization org1))
22
- end
23
-
24
- it 'allows org label' do
25
- expect_organization_search('org1', 1, field: 'label')
26
- expect_sync_plan_search(1, nil, nil)
27
-
28
- run_cmd(%w(sync-plan list --organization-label org1))
29
- end
30
- end
31
- end
@@ -1,8 +0,0 @@
1
- module SyncPlanHelpers
2
- def expect_sync_plan_search(org_id, name, id)
3
- ex = api_expects(:sync_plans, :index, 'find sync plan') do |par|
4
- par['name'] == name && par['organization_id'] == org_id
5
- end
6
- ex.returns(index_response([{'id' => id}]))
7
- end
8
- end
@@ -1,44 +0,0 @@
1
- require_relative '../test_helper'
2
- require_relative 'sync_plan_helpers'
3
- require_relative '../organization/organization_helpers'
4
-
5
- describe 'update a sync plan' do
6
- include OrganizationHelpers
7
- include SyncPlanHelpers
8
-
9
- let(:org_id) { 1 }
10
- let(:id) { 1 }
11
- let(:name) { "sync_plan1" }
12
- let(:org_name) { "org1" }
13
- let(:desc) { "New Description" }
14
-
15
- it 'with organization id and sync plan ID' do
16
- api_expects(:sync_plans, :update, 'update a sync plan').
17
- with_params('description' => desc,
18
- 'id' => id)
19
- command = %W(sync-plan update --organization-id #{org_id} --id #{id}
20
- --description #{desc})
21
- assert_equal(0, run_cmd(command).exit_code)
22
- end
23
-
24
- it 'with organization ID and sync plan name' do
25
- expect_sync_plan_search(org_id, name, id)
26
- api_expects(:sync_plans, :update, 'update a sync plan').
27
- with_params('description' => desc,
28
- 'id' => id)
29
- command = %W(sync-plan update --organization-id #{org_id} --name #{name}
30
- --description #{desc})
31
- assert_equal(0, run_cmd(command).exit_code)
32
- end
33
-
34
- it 'with organization name and sync plan name' do
35
- expect_organization_search(org_name, org_id)
36
- expect_sync_plan_search(org_id, name, id)
37
- api_expects(:sync_plans, :update, 'update a sync plan').
38
- with_params('description' => desc,
39
- 'id' => id)
40
- command = %W(sync-plan update --organization #{org_name} --name #{name}
41
- --description #{desc})
42
- assert_equal(0, run_cmd(command).exit_code)
43
- end
44
- end
@@ -1,24 +0,0 @@
1
- require File.join(File.dirname(__FILE__), '../test_helper')
2
-
3
- require 'hammer_cli/testing/output_matchers'
4
- require 'hammer_cli/testing/command_assertions'
5
- require 'hammer_cli/testing/data_helpers'
6
- require 'hammer_cli_foreman/testing/api_expectations'
7
-
8
- include HammerCLI::Testing::OutputMatchers
9
- include HammerCLI::Testing::CommandAssertions
10
- include HammerCLI::Testing::DataHelpers
11
- include HammerCLIForeman::Testing::APIExpectations
12
-
13
- def assert_success(command_run_result)
14
- assert command_run_result.exit_code.zero?,
15
- "Nonzero exit code (#{command_run_result.exit_code}): #{command_run_result.err}"
16
- end
17
-
18
- def assert_failure(command_run_result, msg = nil)
19
- assert !command_run_result.exit_code.zero?, "Success exit code (0) when expecting failure"
20
- if msg
21
- assert command_run_result.err[msg],
22
- "Actual:\n#{command_run_result.err}\nExpected:\n#{msg.inspect}"
23
- end
24
- end
data/test/task_helper.rb DELETED
@@ -1,7 +0,0 @@
1
- module ForemanTaskHelpers
2
- def expect_foreman_task(task_id)
3
- ex = api_expects(:foreman_tasks, :show, 'Show task')
4
- ex.returns('id' => task_id, 'state' => 'stopped', 'progress' => 1,
5
- 'humanized' => {'output' => '', 'errors' => ''})
6
- end
7
- end
data/test/test_helper.rb DELETED
@@ -1,38 +0,0 @@
1
- if RUBY_VERSION > "2.2"
2
- # Coverage - Keep these two lines at the top of this file
3
- require 'simplecov'
4
- require 'coveralls'
5
- SimpleCov.formatters = [SimpleCov::Formatter::HTMLFormatter, Coveralls::SimpleCov::Formatter]
6
- SimpleCov.start do
7
- minimum_coverage 70
8
- maximum_coverage_drop 0.1
9
- track_files "lib/**/*.rb"
10
- add_filter '/test/'
11
- end
12
- end
13
-
14
- require File.join(File.dirname(__FILE__), './task_helper.rb')
15
- require 'minitest/autorun'
16
- require 'minitest/spec'
17
- require 'mocha/minitest'
18
- require 'hammer_cli'
19
-
20
- KATELLO_VERSION = Gem::Version.new(ENV['TEST_API_VERSION'] || '4.4')
21
-
22
- if HammerCLI.context[:api_connection]
23
- HammerCLI.context[:api_connection].create('foreman') do
24
- HammerCLI::Apipie::ApiConnection.new(
25
- :apidoc_cache_dir => 'test/data/' + KATELLO_VERSION.to_s,
26
- :apidoc_cache_name => 'foreman_api',
27
- :dry_run => true
28
- )
29
- end
30
- else
31
- HammerCLIForeman.stubs(:resource_config).returns(
32
- :apidoc_cache_dir => 'test/data/' + KATELLO_VERSION.to_s,
33
- :apidoc_cache_name => 'foreman_api',
34
- :dry_run => true
35
- )
36
- end
37
-
38
- require 'hammer_cli_katello'