hammer_cli_foreman 2.3.2 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (102) hide show
  1. checksums.yaml +4 -4
  2. data/doc/release_notes.md +33 -3
  3. data/lib/hammer_cli_foreman.rb +3 -21
  4. data/lib/hammer_cli_foreman/associating_commands.rb +0 -24
  5. data/lib/hammer_cli_foreman/bookmark.rb +1 -1
  6. data/lib/hammer_cli_foreman/combination.rb +3 -13
  7. data/lib/hammer_cli_foreman/command_extensions.rb +1 -2
  8. data/lib/hammer_cli_foreman/command_extensions/ping.rb +21 -2
  9. data/lib/hammer_cli_foreman/command_extensions/status.rb +1 -1
  10. data/lib/hammer_cli_foreman/command_extensions/update_common.rb +14 -0
  11. data/lib/hammer_cli_foreman/commands.rb +16 -9
  12. data/lib/hammer_cli_foreman/compute_resource.rb +22 -0
  13. data/lib/hammer_cli_foreman/compute_resource/ovirt.rb +2 -1
  14. data/lib/hammer_cli_foreman/config_report.rb +2 -0
  15. data/lib/hammer_cli_foreman/filter.rb +2 -2
  16. data/lib/hammer_cli_foreman/host.rb +1 -47
  17. data/lib/hammer_cli_foreman/hostgroup.rb +2 -53
  18. data/lib/hammer_cli_foreman/hosts/common_update_options.rb +7 -28
  19. data/lib/hammer_cli_foreman/id_resolver.rb +0 -61
  20. data/lib/hammer_cli_foreman/location.rb +0 -6
  21. data/lib/hammer_cli_foreman/operating_system.rb +2 -1
  22. data/lib/hammer_cli_foreman/option_builders.rb +6 -5
  23. data/lib/hammer_cli_foreman/option_sources.rb +0 -1
  24. data/lib/hammer_cli_foreman/option_sources/id_params.rb +27 -10
  25. data/lib/hammer_cli_foreman/option_sources/ids_params.rb +25 -6
  26. data/lib/hammer_cli_foreman/organization.rb +0 -6
  27. data/lib/hammer_cli_foreman/ping.rb +6 -1
  28. data/lib/hammer_cli_foreman/references.rb +0 -16
  29. data/lib/hammer_cli_foreman/registration.rb +18 -0
  30. data/lib/hammer_cli_foreman/smart_proxy.rb +0 -52
  31. data/lib/hammer_cli_foreman/version.rb +1 -1
  32. data/lib/minitest/coverage_reporter.rb +1 -1
  33. data/locale/ca/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  34. data/locale/de/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  35. data/locale/en/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  36. data/locale/en_GB/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  37. data/locale/es/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  38. data/locale/fr/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  39. data/locale/it/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  40. data/locale/ja/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  41. data/locale/ko/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  42. data/locale/pt_BR/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  43. data/locale/ru/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  44. data/locale/zh_CN/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  45. data/locale/zh_TW/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  46. data/test/data/2.4/foreman_api.json +1 -0
  47. data/test/data/2.5/foreman_api.json +1 -0
  48. data/test/functional/architecture_test.rb +81 -0
  49. data/test/functional/bookmark_test.rb +24 -1
  50. data/test/functional/compute_profile_test.rb +56 -0
  51. data/test/functional/compute_resource_test.rb +37 -0
  52. data/test/functional/filter_test.rb +115 -47
  53. data/test/functional/host_test.rb +94 -13
  54. data/test/functional/hostgroup/create_test.rb +0 -117
  55. data/test/functional/hostgroup/update_test.rb +0 -79
  56. data/test/functional/http_proxy_test.rb +12 -0
  57. data/test/functional/location_test.rb +13 -3
  58. data/test/functional/mail_notification_test.rb +22 -0
  59. data/test/functional/media_test.rb +11 -0
  60. data/test/functional/model_test.rb +52 -0
  61. data/test/functional/operating_system_test.rb +53 -0
  62. data/test/functional/ping_test.rb +33 -0
  63. data/test/functional/realm_test.rb +11 -0
  64. data/test/functional/registration_test.rb +8 -0
  65. data/test/functional/report_template_test.rb +11 -0
  66. data/test/functional/settings_test.rb +21 -0
  67. data/test/functional/status_test.rb +79 -13
  68. data/test/functional/template_test.rb +16 -37
  69. data/test/functional/user_test.rb +11 -0
  70. data/test/functional/usergroup_test.rb +53 -0
  71. data/test/test_helper.rb +1 -1
  72. data/test/unit/apipie_resource_mock.rb +22 -39
  73. data/test/unit/architecture_test.rb +10 -1
  74. data/test/unit/bookmark_test.rb +95 -0
  75. data/test/unit/compute_profile_test.rb +87 -0
  76. data/test/unit/config_report_test.rb +1 -0
  77. data/test/unit/helpers/command.rb +0 -8
  78. data/test/unit/host_test.rb +14 -61
  79. data/test/unit/hostgroup_test.rb +7 -26
  80. data/test/unit/id_resolver_test.rb +0 -28
  81. data/test/unit/mail_notification_test.rb +53 -0
  82. data/test/unit/model_test.rb +47 -37
  83. data/test/unit/operating_system_test.rb +10 -3
  84. data/test/unit/option_sources/id_params_test.rb +9 -0
  85. data/test/unit/option_sources/ids_params_test.rb +9 -0
  86. data/test/unit/settings_test.rb +4 -0
  87. data/test/unit/smart_proxy_test.rb +0 -12
  88. data/test/unit/usergroup_test.rb +10 -0
  89. metadata +76 -73
  90. data/lib/hammer_cli_foreman/command_extensions/puppet_environment.rb +0 -29
  91. data/lib/hammer_cli_foreman/command_extensions/puppet_environments.rb +0 -29
  92. data/lib/hammer_cli_foreman/config_group.rb +0 -45
  93. data/lib/hammer_cli_foreman/option_sources/puppet_environment_params.rb +0 -59
  94. data/lib/hammer_cli_foreman/puppet_class.rb +0 -61
  95. data/lib/hammer_cli_foreman/puppet_environment.rb +0 -65
  96. data/lib/hammer_cli_foreman/smart_class_parameter.rb +0 -189
  97. data/test/functional/proxy_test.rb +0 -86
  98. data/test/functional/smart_class_parameter_test.rb +0 -97
  99. data/test/unit/config_group_test.rb +0 -72
  100. data/test/unit/puppet_class_test.rb +0 -72
  101. data/test/unit/puppet_environment_test.rb +0 -114
  102. data/test/unit/smart_class_parameter_test.rb +0 -113
@@ -68,25 +68,6 @@ module HammerCLIForeman
68
68
  run_cmd(%w(hostgroup update --id 1 --domain d1))
69
69
  end
70
70
 
71
- it 'allows environment id' do
72
- api_expects(:hostgroups, :update) do |p|
73
- p['hostgroup']['environment_id'] == 1 &&
74
- p['id'] == '1'
75
- end
76
- run_cmd(%w(hostgroup update --id 1 --environment-id 1))
77
- end
78
-
79
- it 'allows environment name' do
80
- api_expects(:environments, :index) do |p|
81
- p[:search] = "name = \"env1\""
82
- end.returns(index_response([{'id' => 1}]))
83
- api_expects(:hostgroups, :update) do |p|
84
- p['hostgroup']['environment_id'] == 1 &&
85
- p['id'] == '1'
86
- end
87
- run_cmd(%w(hostgroup update --id 1 --environment env1))
88
- end
89
-
90
71
  it 'allows location ids' do
91
72
  api_expects(:hostgroups, :update) do |p|
92
73
  p['hostgroup']['location_ids'] == ['1','4'] &&
@@ -201,66 +182,6 @@ module HammerCLIForeman
201
182
  run_cmd(%w(hostgroup update --id 1 --partition-table pt1))
202
183
  end
203
184
 
204
- it 'allows puppet ca proxy id' do
205
- api_expects(:hostgroups, :update).with_params({
206
- :id => '1',
207
- :hostgroup => { :puppet_ca_proxy_id => 1 }
208
- })
209
- run_cmd(%w(hostgroup update --id 1 --puppet-ca-proxy-id 1))
210
- end
211
-
212
- it 'allows puppet ca proxy name' do
213
- api_expects(:smart_proxies, :index) do |p|
214
- p[:search] = "name = \"sp1\""
215
- end.returns(index_response([{'id' => 1}]))
216
- api_expects(:hostgroups, :update) do |p|
217
- p['hostgroup']['puppet_ca_proxy_id'] == 1 &&
218
- p['id'] == '1'
219
- end
220
- run_cmd(%w(hostgroup update --id 1 --puppet-ca-proxy sp1))
221
- end
222
-
223
- it 'allows puppet class ids' do
224
- api_expects(:hostgroups, :update) do |p|
225
- p['hostgroup']['puppetclass_ids'] == ['1','2'] &&
226
- p['id'] == '1'
227
- end
228
- run_cmd(%w(hostgroup update --id 1 --puppet-class-ids 1,2))
229
- end
230
-
231
- it 'allows puppet class names' do
232
- api_expects(:puppetclasses, :index) do |p|
233
- p[:search] = "name = \"pc1\" or name = \"pc2\""
234
- end.returns(index_response('puppetclasses' => [
235
- {'id' => 1, 'name' => 'pc1'},
236
- {'id' => 2, 'name' => 'pc2'}
237
- ]))
238
- api_expects(:hostgroups, :update) do |p|
239
- p['hostgroup']['puppetclass_ids'] == [1,2] &&
240
- p['id'] == '1'
241
- end
242
- run_cmd(%w(hostgroup update --id 1 --puppet-classes pc1,pc2))
243
- end
244
-
245
- it 'allows puppet proxy id' do
246
- api_expects(:hostgroups, :update).with_params({
247
- :id => '1',
248
- :hostgroup => { :puppet_proxy_id => 1 }
249
- })
250
- run_cmd(%w(hostgroup update --id 1 --puppet-proxy-id 1))
251
- end
252
-
253
- it 'allows puppet proxy name' do
254
- api_expects(:smart_proxies, :index) do |p|
255
- p[:search] = "name = \"sp1\""
256
- end.returns(index_response([{'id' => 1}]))
257
- api_expects(:hostgroups, :update) do |p|
258
- p['hostgroup']['puppet_proxy_id'] == 1 &&
259
- p['id'] == '1'
260
- end
261
- run_cmd(%w(hostgroup update --id 1 --puppet-proxy sp1))
262
- end
263
-
264
185
  it 'allows realm id' do
265
186
  api_expects(:hostgroups, :update) do |p|
266
187
  p['hostgroup']['realm_id'] == 1 &&
@@ -61,9 +61,21 @@ describe 'httpproxy' do
61
61
  end
62
62
 
63
63
  it 'deletes an http proxy' do
64
+ api_expects(:http_proxies, :destroy, 'Delete proxy').returns(http_proxy)
65
+
64
66
  expected_result = success_result("Http proxy deleted.\n")
65
67
 
66
68
  result = run_cmd(%w(http-proxy delete --id 1))
67
69
  assert_cmd(expected_result, result)
68
70
  end
71
+
72
+ it 'updates nothing without related parameters' do
73
+ api_expects(:http_proxies, :update, 'Update proxy with no params').returns({})
74
+
75
+ expected_result = success_result("Nothing to update.\n")
76
+
77
+ result = run_cmd(%w(http-proxy update --id 1))
78
+ assert_cmd(expected_result, result)
79
+ end
80
+
69
81
  end
@@ -208,7 +208,6 @@ describe 'info' do
208
208
  provisioning_templates: [],
209
209
  domains: [],
210
210
  realms: [],
211
- environments: [],
212
211
  hostgroups: [],
213
212
  organizations: [],
214
213
  parameters: []
@@ -242,8 +241,6 @@ describe 'info' do
242
241
  '',
243
242
  'Realms:',
244
243
  '',
245
- 'Environments:',
246
- '',
247
244
  'Hostgroups:',
248
245
  '',
249
246
  'Parameters:',
@@ -272,4 +269,17 @@ describe 'update' do
272
269
  result = run_cmd(@cmd + params)
273
270
  assert_cmd(success_result("Location updated.\n"), result)
274
271
  end
272
+
273
+ it 'updates nothing without related parameters' do
274
+ params = %w[--id=1]
275
+
276
+ api_expects(:locations, :index)
277
+ api_expects(:locations, :update, 'Update location with no params').returns({})
278
+
279
+ expected_result = success_result("Nothing to update.\n")
280
+
281
+ result = run_cmd(@cmd + params)
282
+ assert_cmd(expected_result, result)
283
+ end
284
+
275
285
  end
@@ -24,6 +24,28 @@ describe 'mail_notification' do
24
24
  result = run_cmd(@cmd)
25
25
  assert_cmd(expected_result, result)
26
26
  end
27
+
28
+ it 'should run list command with defaults' do
29
+ providers = { 'foreman' => HammerCLIForeman::Defaults.new(api_connection({}, '2.5')) }
30
+ defaults = HammerCLI::Defaults.new(
31
+ {
32
+ organization_id: {
33
+ provider: 'foreman'
34
+ },
35
+ location_id: {
36
+ provider: 'foreman'
37
+ }
38
+ }
39
+ )
40
+ defaults.stubs(:write_to_file).returns(true)
41
+ defaults.stubs(:providers).returns(providers)
42
+ api_expects(:users, :index, 'Find user').with_params(search: 'login=admin').returns(index_response([{ 'default_organization' => { 'id' => 2 } }]))
43
+ api_expects(:users, :index, 'Find user').with_params(search: 'login=admin').returns(index_response([{ 'default_location' => { 'id' => 1 } }]))
44
+ api_expects(:mail_notifications, :index, 'List mail notifications').returns(@mail_notifications)
45
+
46
+ result = run_cmd(@cmd, { use_defaults: true, defaults: defaults })
47
+ _(result.exit_code).must_equal HammerCLI::EX_OK
48
+ end
27
49
  end
28
50
 
29
51
  describe 'info' do
@@ -126,5 +126,16 @@ describe 'medium' do
126
126
  result = run_cmd(@cmd + params)
127
127
  assert_cmd(success_result("Installation medium updated.\n"), result)
128
128
  end
129
+
130
+ it 'updates nothing without medium related parameters' do
131
+ params = %w[--id=1]
132
+
133
+ api_expects(:media, :update, 'Update medium with no params').returns({})
134
+
135
+ expected_result = success_result("Nothing to update.\n")
136
+
137
+ result = run_cmd(@cmd + params)
138
+ assert_cmd(expected_result, result)
139
+ end
129
140
  end
130
141
  end
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ require File.join(File.dirname(__FILE__), 'test_helper')
4
+
5
+ describe 'model' do
6
+ describe 'list' do
7
+ before do
8
+ @cmd = %w[model list]
9
+ @models = [{
10
+ id: 1,
11
+ name: 'model',
12
+ }]
13
+ end
14
+
15
+ it 'should return a list of models' do
16
+ api_expects(:models, :index, 'List models').returns(@models)
17
+
18
+ output = IndexMatcher.new([
19
+ %w[ID NAME],
20
+ %w[1 model]
21
+ ])
22
+ expected_result = success_result(output)
23
+
24
+ result = run_cmd(@cmd)
25
+ assert_cmd(expected_result, result)
26
+ end
27
+
28
+ it 'should run list command with defaults' do
29
+ providers = { 'foreman' => HammerCLIForeman::Defaults.new(api_connection({}, '2.5')) }
30
+ defaults = HammerCLI::Defaults.new(
31
+ {
32
+ organization_id: {
33
+ provider: 'foreman'
34
+ },
35
+ location_id: {
36
+ provider: 'foreman'
37
+ }
38
+ }
39
+ )
40
+ defaults.stubs(:write_to_file).returns(true)
41
+ defaults.stubs(:providers).returns(providers)
42
+ api_expects(:users, :index, 'Find user').with_params(search: 'login=admin').returns(index_response([{ 'default_organization' => { 'id' => 2 } }]))
43
+ api_expects(:users, :index, 'Find user').with_params(search: 'login=admin').returns(index_response([{ 'default_location' => { 'id' => 1 } }]))
44
+ api_expects(:models, :index, 'List models').returns(@models)
45
+
46
+ result = run_cmd(@cmd, { use_defaults: true, defaults: defaults })
47
+ _(result.exit_code).must_equal HammerCLI::EX_OK
48
+ end
49
+ end
50
+ end
51
+
52
+
@@ -0,0 +1,53 @@
1
+ # frozen_string_literal: true
2
+
3
+ require File.join(File.dirname(__FILE__), 'test_helper')
4
+
5
+ describe 'operating_system' do
6
+ describe 'list' do
7
+ before do
8
+ @cmd = %w[os list]
9
+ @operating_system = [{
10
+ id: 1,
11
+ release_name: 'Redhat 7',
12
+ family: 'Redhat',
13
+ }]
14
+ end
15
+
16
+ it 'should return a list of operating system' do
17
+ api_expects(:operatingsystems, :index, 'List operating systems').returns(@operating_system)
18
+
19
+ output = IndexMatcher.new([
20
+ ['ID', 'RELEASE NAME', 'FAMILY'],
21
+ ['1', 'Redhat 7', 'Redhat']
22
+ ])
23
+ expected_result = success_result(output)
24
+
25
+ result = run_cmd(@cmd)
26
+ assert_cmd(expected_result, result)
27
+ end
28
+
29
+ it 'should run list command with defaults' do
30
+ providers = { 'foreman' => HammerCLIForeman::Defaults.new(api_connection({}, '2.5')) }
31
+ defaults = HammerCLI::Defaults.new(
32
+ {
33
+ organization_id: {
34
+ provider: 'foreman'
35
+ },
36
+ location_id: {
37
+ provider: 'foreman'
38
+ }
39
+ }
40
+ )
41
+ defaults.stubs(:write_to_file).returns(true)
42
+ defaults.stubs(:providers).returns(providers)
43
+ api_expects(:users, :index, 'Find user').with_params(search: 'login=admin').returns(index_response([{ 'default_organization' => { 'id' => 2 } }]))
44
+ api_expects(:users, :index, 'Find user').with_params(search: 'login=admin').returns(index_response([{ 'default_location' => { 'id' => 1 } }]))
45
+ api_expects(:operatingsystems, :index, 'List operating systems').returns(@operating_system)
46
+
47
+ result = run_cmd(@cmd, { use_defaults: true, defaults: defaults })
48
+ _(result.exit_code).must_equal HammerCLI::EX_OK
49
+ end
50
+ end
51
+ end
52
+
53
+
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require File.join(File.dirname(__FILE__), 'test_helper')
2
4
 
3
5
  describe 'ping' do
@@ -30,5 +32,36 @@ describe 'ping' do
30
32
  result = run_cmd(cmd)
31
33
  assert_cmd(expected_result, result)
32
34
  end
35
+
36
+ it 'returns 1 if one of the services failed and shows unrecognized services' do
37
+ ping_results['results']['new_plugin'] = {
38
+ 'services' => {
39
+ 'first' => {
40
+ 'status' => 'FAIL'
41
+ },
42
+ 'second' => {
43
+ 'status' => 'ok'
44
+ }
45
+ },
46
+ 'status' => 'FAIL'
47
+ }
48
+ api_expects(:ping, :ping, 'Ping').returns(ping_results)
49
+
50
+ expected_result = CommandExpectation.new
51
+ expected_result.expected_out = OutputMatcher.new(
52
+ [
53
+ 'database:',
54
+ ' Status: ok',
55
+ ' Server Response: Duration: 0ms'
56
+ ]
57
+ )
58
+ expected_result.expected_err =
59
+ ['1 more service(s) failed, but not shown:',
60
+ 'first',
61
+ ''].join("\n")
62
+ expected_result.expected_exit_code = 1
63
+ result = run_cmd(cmd)
64
+ assert_cmd(expected_result, result)
65
+ end
33
66
  end
34
67
  end
@@ -99,5 +99,16 @@ describe 'realm' do
99
99
  result = run_cmd(@cmd + params)
100
100
  assert_cmd(success_result("Realm [%{name}] updated.\n"), result)
101
101
  end
102
+
103
+ it 'updates nothing without realm related parameters' do
104
+ params = %w[--id=1]
105
+
106
+ api_expects(:realms, :update, 'Update realm with no params').returns({})
107
+
108
+ expected_result = success_result("Nothing to update.\n")
109
+
110
+ result = run_cmd(@cmd + params)
111
+ assert_cmd(expected_result, result)
112
+ end
102
113
  end
103
114
  end
@@ -0,0 +1,8 @@
1
+ require File.join(File.dirname(__FILE__), 'test_helper')
2
+
3
+ describe 'registration_commands' do
4
+ it 'create' do
5
+ api_expects(:registration_commands, :create)
6
+ run_cmd(%w(host-registration generate-command))
7
+ end
8
+ end
@@ -195,6 +195,17 @@ describe 'report-template' do
195
195
  result = run_cmd(cmd + params)
196
196
  assert_cmd(success_result("Report template updated.\n"), result)
197
197
  end
198
+
199
+ it 'updates nothing without template related parameters' do
200
+ params = %w[--id=1]
201
+
202
+ api_expects(:report_templates, :update, 'Update template with no params').returns({})
203
+
204
+ expected_result = success_result("Nothing to update.\n")
205
+
206
+ result = run_cmd(cmd + params)
207
+ assert_cmd(expected_result, result)
208
+ end
198
209
  end
199
210
 
200
211
  describe 'dump' do
@@ -31,6 +31,27 @@ describe 'Settings' do
31
31
  assert_cmd(expected_result, result)
32
32
  end
33
33
 
34
+ it 'should run list command with defaults' do
35
+ providers = { 'foreman' => HammerCLIForeman::Defaults.new(api_connection({}, '2.5')) }
36
+ defaults = HammerCLI::Defaults.new(
37
+ {
38
+ organization_id: {
39
+ provider: 'foreman'
40
+ },
41
+ location_id: {
42
+ provider: 'foreman'
43
+ }
44
+ }
45
+ )
46
+ defaults.stubs(:write_to_file).returns(true)
47
+ defaults.stubs(:providers).returns(providers)
48
+ api_expects(:users, :index, 'Find user').with_params(search: 'login=admin').returns(index_response([{ 'default_organization' => { 'id' => 2 } }]))
49
+ api_expects(:users, :index, 'Find user').with_params(search: 'login=admin').returns(index_response([{ 'default_location' => { 'id' => 1 } }]))
50
+ api_expects(:settings, :index, 'List settings').returns(setting)
51
+
52
+ result = run_cmd(@cmd, { use_defaults: true, defaults: defaults })
53
+ _(result.exit_code).must_equal HammerCLI::EX_OK
54
+ end
34
55
  end
35
56
 
36
57
  describe 'info' do
@@ -1,24 +1,60 @@
1
1
  require File.join(File.dirname(__FILE__), 'test_helper')
2
2
 
3
+ BASIC_STATUS = {
4
+ 'database' => { 'active' => true, 'duration_ms' => 0 },
5
+ 'version' => '1.24.0-develop',
6
+ 'api' => { 'version' => 'v2' },
7
+ 'plugins' => [],
8
+ 'smart_proxies' => [],
9
+ 'compute_resources' => []
10
+ }
11
+
12
+ STRING_STATUS = Marshal.load(Marshal.dump(BASIC_STATUS)).merge({
13
+ 'plugins' => [
14
+ 'Foreman plugin: foreman_ansible, 6.0.1, Daniel Lobato Garcia, Ansible integration with Foreman'
15
+ ]
16
+ })
17
+
18
+ STRUCTURED_STATUS = Marshal.load(Marshal.dump(BASIC_STATUS)).merge({
19
+ 'plugins' => [
20
+ {'name': 'foreman_ansible', 'version': '6.0.1'}
21
+ ]
22
+ })
23
+
3
24
  describe 'status' do
4
25
  let(:base_cmd) { %w[status] }
5
26
 
6
27
  describe 'foreman' do
7
28
  let(:cmd) { base_cmd << 'foreman' }
8
- let(:status_results) do
9
- {
10
- 'results' => {
11
- 'foreman' => {
12
- 'database' => { 'active' => true, 'duration_ms' => 0 },
13
- 'version' => '1.24.0-develop',
14
- 'api' => { 'version' => 'v2' },
15
- 'plugins' => [],
16
- 'smart_proxies' => [],
17
- 'compute_resources' => []
18
- }
19
- }
20
- }
29
+ let(:status_results) { {'results' => {'foreman' => BASIC_STATUS }} }
30
+
31
+ it 'checks status of the foreman system' do
32
+ api_expects(:ping, :statuses, 'Status').returns(status_results)
33
+
34
+ output = OutputMatcher.new(
35
+ [
36
+ 'Version: 1.24.0-develop',
37
+ 'API Version: v2',
38
+ 'Database:',
39
+ ' Status: ok',
40
+ ' Server Response: Duration: 0ms',
41
+ 'Plugins:',
42
+ '',
43
+ 'Smart Proxies:',
44
+ '',
45
+ 'Compute Resources:'
46
+ ]
47
+ )
48
+
49
+ expected_result = success_result(output)
50
+ result = run_cmd(cmd)
51
+ assert_cmd(expected_result, result)
21
52
  end
53
+ end
54
+
55
+ describe 'foreman with string plugins' do
56
+ let(:cmd) { base_cmd << 'foreman' }
57
+ let(:status_results) { {'results' => {'foreman' => STRING_STATUS }} }
22
58
 
23
59
  it 'checks status of the foreman system' do
24
60
  api_expects(:ping, :statuses, 'Status').returns(status_results)
@@ -31,7 +67,37 @@ describe 'status' do
31
67
  ' Status: ok',
32
68
  ' Server Response: Duration: 0ms',
33
69
  'Plugins:',
70
+ ' 1) Name: foreman_ansible',
71
+ ' Version: 6.0.1',
72
+ 'Smart Proxies:',
34
73
  '',
74
+ 'Compute Resources:'
75
+ ]
76
+ )
77
+
78
+ expected_result = success_result(output)
79
+ result = run_cmd(cmd)
80
+ assert_cmd(expected_result, result)
81
+ end
82
+ end
83
+
84
+ describe 'foreman with structured plugins' do
85
+ let(:cmd) { base_cmd << 'foreman' }
86
+ let(:status_results) { {'results' => {'foreman' => STRUCTURED_STATUS }} }
87
+
88
+ it 'checks status of the foreman system' do
89
+ api_expects(:ping, :statuses, 'Status').returns(status_results)
90
+
91
+ output = OutputMatcher.new(
92
+ [
93
+ 'Version: 1.24.0-develop',
94
+ 'API Version: v2',
95
+ 'Database:',
96
+ ' Status: ok',
97
+ ' Server Response: Duration: 0ms',
98
+ 'Plugins:',
99
+ ' 1) Name: foreman_ansible',
100
+ ' Version: 6.0.1',
35
101
  'Smart Proxies:',
36
102
  '',
37
103
  'Compute Resources:'