hammer_cli_foreman 2.5.2 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. checksums.yaml +4 -4
  2. data/doc/release_notes.md +10 -4
  3. data/lib/hammer_cli_foreman/architecture.rb +5 -5
  4. data/lib/hammer_cli_foreman/associating_commands.rb +0 -24
  5. data/lib/hammer_cli_foreman/bookmark.rb +5 -5
  6. data/lib/hammer_cli_foreman/combination.rb +3 -13
  7. data/lib/hammer_cli_foreman/command_extensions.rb +0 -2
  8. data/lib/hammer_cli_foreman/commands.rb +2 -9
  9. data/lib/hammer_cli_foreman/compute_profile.rb +5 -5
  10. data/lib/hammer_cli_foreman/host.rb +0 -35
  11. data/lib/hammer_cli_foreman/hostgroup.rb +2 -53
  12. data/lib/hammer_cli_foreman/hosts/common_update_options.rb +1 -23
  13. data/lib/hammer_cli_foreman/id_resolver.rb +0 -61
  14. data/lib/hammer_cli_foreman/location.rb +0 -6
  15. data/lib/hammer_cli_foreman/mail_notification.rb +2 -2
  16. data/lib/hammer_cli_foreman/model.rb +5 -5
  17. data/lib/hammer_cli_foreman/operating_system.rb +10 -10
  18. data/lib/hammer_cli_foreman/option_sources/id_params.rb +27 -10
  19. data/lib/hammer_cli_foreman/option_sources/ids_params.rb +25 -6
  20. data/lib/hammer_cli_foreman/option_sources.rb +0 -1
  21. data/lib/hammer_cli_foreman/organization.rb +0 -6
  22. data/lib/hammer_cli_foreman/references.rb +0 -16
  23. data/lib/hammer_cli_foreman/settings.rb +3 -3
  24. data/lib/hammer_cli_foreman/smart_proxy.rb +0 -52
  25. data/lib/hammer_cli_foreman/usergroup.rb +5 -5
  26. data/lib/hammer_cli_foreman/version.rb +1 -1
  27. data/lib/hammer_cli_foreman.rb +0 -21
  28. data/lib/minitest/coverage_reporter.rb +1 -1
  29. data/locale/ca/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  30. data/locale/de/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  31. data/locale/en/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  32. data/locale/en_GB/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  33. data/locale/es/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  34. data/locale/fr/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  35. data/locale/it/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  36. data/locale/ja/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  37. data/locale/ko/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  38. data/locale/pt_BR/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  39. data/locale/ru/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  40. data/locale/zh_CN/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  41. data/locale/zh_TW/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  42. data/test/functional/architecture_test.rb +6 -4
  43. data/test/functional/bookmark_test.rb +3 -1
  44. data/test/functional/compute_profile_test.rb +3 -1
  45. data/test/functional/host_test.rb +0 -1
  46. data/test/functional/hostgroup/create_test.rb +0 -117
  47. data/test/functional/hostgroup/update_test.rb +0 -79
  48. data/test/functional/location_test.rb +0 -3
  49. data/test/functional/mail_notification_test.rb +3 -1
  50. data/test/functional/model_test.rb +3 -1
  51. data/test/functional/operating_system_test.rb +3 -1
  52. data/test/functional/settings_test.rb +4 -4
  53. data/test/functional/template_test.rb +4 -37
  54. data/test/functional/usergroup_test.rb +3 -1
  55. data/test/unit/apipie_resource_mock.rb +1 -39
  56. data/test/unit/architecture_test.rb +10 -10
  57. data/test/unit/bookmark_test.rb +10 -14
  58. data/test/unit/compute_profile_test.rb +10 -10
  59. data/test/unit/helpers/command.rb +0 -8
  60. data/test/unit/host_test.rb +14 -61
  61. data/test/unit/hostgroup_test.rb +7 -26
  62. data/test/unit/id_resolver_test.rb +0 -28
  63. data/test/unit/mail_notification_test.rb +4 -4
  64. data/test/unit/model_test.rb +47 -47
  65. data/test/unit/operating_system_test.rb +10 -16
  66. data/test/unit/option_sources/id_params_test.rb +9 -0
  67. data/test/unit/option_sources/ids_params_test.rb +9 -0
  68. data/test/unit/settings_test.rb +4 -4
  69. data/test/unit/smart_proxy_test.rb +0 -12
  70. data/test/unit/usergroup_test.rb +10 -10
  71. metadata +27 -48
  72. data/lib/hammer_cli_foreman/command_extensions/puppet_environment.rb +0 -29
  73. data/lib/hammer_cli_foreman/command_extensions/puppet_environments.rb +0 -29
  74. data/lib/hammer_cli_foreman/config_group.rb +0 -45
  75. data/lib/hammer_cli_foreman/option_sources/puppet_environment_params.rb +0 -59
  76. data/lib/hammer_cli_foreman/puppet_class.rb +0 -61
  77. data/lib/hammer_cli_foreman/puppet_environment.rb +0 -65
  78. data/lib/hammer_cli_foreman/smart_class_parameter.rb +0 -189
  79. data/test/functional/config_group_test.rb +0 -50
  80. data/test/functional/proxy_test.rb +0 -86
  81. data/test/functional/smart_class_parameter_test.rb +0 -97
  82. data/test/unit/config_group_test.rb +0 -82
  83. data/test/unit/puppet_class_test.rb +0 -72
  84. data/test/unit/puppet_environment_test.rb +0 -114
  85. data/test/unit/smart_class_parameter_test.rb +0 -113
@@ -17,14 +17,6 @@ class IdResolverTestProxy
17
17
  @original_resolver.searchables(resource)
18
18
  end
19
19
 
20
- def puppet_environment_id(options)
21
- environment_id(options)
22
- end
23
-
24
- def puppet_environment_ids(options)
25
- environment_ids(options)
26
- end
27
-
28
20
  protected
29
21
 
30
22
  def define_id_finders
@@ -45,8 +45,7 @@ describe HammerCLIForeman::Host do
45
45
  with_params ["--id=1"] do
46
46
  it_should_print_n_records 1
47
47
  it_should_print_columns ["Id", "Name", "Organization", "Location"]
48
- it_should_print_columns ["Host Group", "Compute Resource", "Compute Profile", "Puppet Environment"]
49
- it_should_print_columns ["Puppet CA Proxy", "Puppet Master Proxy", "Cert name"]
48
+ it_should_print_columns ["Host Group", "Compute Resource", "Compute Profile"]
50
49
  it_should_print_columns ["Managed", "Status", "Installed at", "Last report"]
51
50
  it_should_print_columns ["Network", "Network interfaces", "Operating system", "Parameters", "All parameters", "Additional info"]
52
51
  end
@@ -106,32 +105,6 @@ describe HammerCLIForeman::Host do
106
105
  end
107
106
  end
108
107
 
109
-
110
- context "PuppetClassesCommand" do
111
- before do
112
- ResourceMocks.mock_action_call(:puppetclasses, :index, {})
113
- end
114
-
115
- let(:cmd) { HammerCLIForeman::Host::PuppetClassesCommand.new("", ctx) }
116
-
117
- context "parameters" do
118
- it_should_accept "host", ["--host=name=my5name.mydomain.net"]
119
- it_should_accept "host-id", ["--host-id=1"]
120
- # it_should_fail_with "host or host-id missing", []
121
- # TODO: temporarily disabled, parameters are checked in the id resolver
122
- end
123
-
124
- context "output" do
125
-
126
- with_params ["--host=my5name.mydomain.net"] do
127
- it_should_print_column "Id"
128
- it_should_print_column "Name"
129
- end
130
- end
131
-
132
- end
133
-
134
-
135
108
  context "ConfigReportsCommand" do
136
109
  before do
137
110
  ResourceMocks.mock_action_call(:config_reports, :index, [])
@@ -186,29 +159,25 @@ describe HammerCLIForeman::Host do
186
159
 
187
160
  context "parameters" do
188
161
  taxonomies = ["--organization-id=1", "--location-id=1"]
189
- it_should_accept "name, environment_id, architecture_id, domain_id, puppet_proxy_id, operatingsystem_id and more",
190
- ["--name=host", "--environment-id=1", "--architecture-id=1", "--domain-id=1", "--puppet-proxy-id=1", "--operatingsystem-id=1",
162
+ it_should_accept "name, architecture_id, domain_id, operatingsystem_id and more",
163
+ ["--name=host", "--architecture-id=1", "--domain-id=1", "--operatingsystem-id=1",
191
164
  "--ip=1.2.3.4", "--mac=11:22:33:44:55:66", "--medium-id=1", "--partition-table-id=1", "--subnet-id=1",
192
- "--model-id=1", "--hostgroup-id=1", "--owner-id=1", '--puppet-ca-proxy-id=1', '--puppet-class-ids',
165
+ "--model-id=1", "--hostgroup-id=1", "--owner-id=1",
193
166
  "--root-password=pwd", "--ask-root-password=true", "--provision-method=build", "--interface=primary=true,provision=true"] + taxonomies
194
167
  it_should_fail_with "name or id missing",
195
- ["--environment-id=1", "--architecture-id=1", "--domain-id=1", "--puppet-proxy-id=1", "--operatingsystem-id=1", "--interface=primary=true,provision=true"]
196
- it_should_fail_with "environment_id missing",
197
- ["--name=host", "--architecture-id=1", "--domain-id=1", "--puppet-proxy-id=1", "--operatingsystem-id=1", "--interface=primary=true,provision=true"]
168
+ ["--architecture-id=1", "--domain-id=1", "--operatingsystem-id=1", "--interface=primary=true,provision=true"]
198
169
  it_should_fail_with "architecture_id missing",
199
- ["--name=host", "--environment-id=1", "--domain-id=1", "--puppet-proxy-id=1", "--operatingsystem-id=1", "--interface=primary=true,provision=true"]
170
+ ["--name=host", "--domain-id=1", "--operatingsystem-id=1", "--interface=primary=true,provision=true"]
200
171
  it_should_fail_with "domain_id missing",
201
- ["--name=host", "--environment-id=1", "--architecture-id=1", "--puppet-proxy-id=1", "--operatingsystem-id=1", "--interface=primary=true,provision=true"]
202
- it_should_fail_with "puppet_proxy_id missing",
203
- ["--name=host", "--environment-id=1", "--architecture-id=1", "--domain-id=1", "--operatingsystem-id=1", "--interface=primary=true,provision=true"]
172
+ ["--name=host", "--architecture-id=1", "--operatingsystem-id=1", "--interface=primary=true,provision=true"]
204
173
  it_should_fail_with "operatingsystem_id missing",
205
- ["--name=host", "--environment-id=1", "--architecture-id=1", "--domain-id=1", "--puppet-proxy-id=1", "--interface=primary=true,provision=true"]
174
+ ["--name=host", "--architecture-id=1", "--domain-id=1", "--interface=primary=true,provision=true"]
206
175
  it_should_accept "only hostgroup name", ["--hostgroup=example", "--name=host", "--interface=primary=true,provision=true"] + taxonomies
207
176
  it_should_accept "only hostgroup ID", ["--hostgroup-id=1", "--name=host", "--interface=primary=true,provision=true"] + taxonomies
208
177
 
209
- with_params ["--name=host", "--environment-id=1", "--architecture-id=1", "--domain-id=1", "--puppet-proxy-id=1", "--operatingsystem-id=1",
178
+ with_params ["--name=host", "--architecture-id=1", "--domain-id=1", "--operatingsystem-id=1",
210
179
  "--ip=1.2.3.4", "--mac=11:22:33:44:55:66", "--medium-id=1", "--partition-table-id=1", "--subnet-id=1",
211
- "--model-id=1", "--hostgroup-id=1", "--owner-id=1", '--puppet-ca-proxy-id=1', '--puppet-class-ids',
180
+ "--model-id=1", "--hostgroup-id=1", "--owner-id=1",
212
181
  "--root-password=pwd", "--ask-root-password=true", "--provision-method=build", "--interface=primary=true,provision=true"] do
213
182
  it_should_call_action_and_test_params(:create) { |par| par["host"]["managed"] == true }
214
183
  it_should_call_action_and_test_params(:create) { |par| par["host"]["build"] == true }
@@ -240,16 +209,16 @@ describe HammerCLIForeman::Host do
240
209
 
241
210
  context "parameters" do
242
211
  it_should_accept "name", ["--name=host", "--new-name=host2"]
243
- it_should_accept "id and more", ["--id=1", "--new-name=host2", "--environment-id=1", "--architecture-id=1",
244
- "--domain-id=1", "--puppet-proxy-id=1", "--operatingsystem-id=1",
212
+ it_should_accept "id and more", ["--id=1", "--new-name=host2", "--architecture-id=1",
213
+ "--domain-id=1", "--operatingsystem-id=1",
245
214
  "--ip=1.2.3.4", "--mac=11:22:33:44:55:66", "--medium-id=1", "--partition-table-id=1", "--subnet-id=1",
246
- "--model-id=1", "--hostgroup-id=1", "--owner-id=1", '--puppet-ca-proxy-id=1',
215
+ "--model-id=1", "--hostgroup-id=1", "--owner-id=1",
247
216
  "--root-password=pwd", "--ask-root-password=true", "--provision-method=build"]
248
217
  # it_should_fail_with "no params", []
249
218
  # it_should_fail_with "name or id missing", ["--new-name=host2"]
250
219
  # TODO: temporarily disabled, parameters are checked in the id resolver
251
220
 
252
- with_params ["--id=1", "--puppet-proxy-id=1"] do
221
+ with_params ["--id=1"] do
253
222
  it_should_call_action_and_test_params(:update) { |par| par["host"].key?("managed") != true }
254
223
  it_should_call_action_and_test_params(:update) { |par| par["host"].key?("build") != true }
255
224
  it_should_call_action_and_test_params(:update) { |par| par["host"].key?("enabled") != true }
@@ -350,22 +319,6 @@ describe HammerCLIForeman::Host do
350
319
  end
351
320
  end
352
321
 
353
- context "SCParamsCommand" do
354
-
355
- before :each do
356
- ResourceMocks.smart_class_parameters_index
357
- end
358
-
359
- let(:cmd) { HammerCLIForeman::Host::SCParamsCommand.new("", ctx) }
360
-
361
- context "parameters" do
362
- it_should_accept "host", ["--host=host"]
363
- it_should_accept "host-id", ["--host-id=1"]
364
- # it_should_fail_with "name or id missing", [] # TODO: temporarily disabled, parameters are checked in the id resolver
365
- end
366
-
367
- end
368
-
369
322
  context "RebuildConfigCommand" do
370
323
 
371
324
  let(:cmd) { HammerCLIForeman::Host::RebuildConfigCommand.new("", ctx) }
@@ -24,7 +24,7 @@ describe HammerCLIForeman::Hostgroup do
24
24
 
25
25
  it_should_print_n_records
26
26
  it_should_print_columns ["Id", "Name", "Title", "Operating System"]
27
- it_should_print_columns ["Puppet Environment", "Model"]
27
+ it_should_print_columns ["Model"]
28
28
  end
29
29
 
30
30
  end
@@ -42,8 +42,6 @@ describe HammerCLIForeman::Hostgroup do
42
42
  with_params ["--id=1"] do
43
43
  it_should_print_n_records 1
44
44
  it_should_print_columns ["Id", "Name", "Title"]
45
- it_should_print_columns ["Puppet Environment", "Puppetclasses", "Parent"]
46
- it_should_print_columns ["Puppet CA Proxy", "Puppet Master Proxy"]
47
45
  it_should_print_columns ["Parameters", "Description"]
48
46
  it_should_print_columns ["Network", "Operating system"]
49
47
  end
@@ -67,9 +65,9 @@ describe HammerCLIForeman::Hostgroup do
67
65
  let(:cmd) { HammerCLIForeman::Hostgroup::CreateCommand.new("", ctx) }
68
66
 
69
67
  context "parameters" do
70
- it_should_accept "name, parent_id, environment_id, architecture_id, domain_id, puppet_proxy_id, operatingsystem_id and more",
71
- ["--name=hostgroup", "--parent-id=1", "--environment-id=1", "--architecture-id=1", "--domain-id=1", "--puppet-proxy-id=1",
72
- "--operatingsystem-id=1", "--medium-id=1", "--partition-table-id=1", "--subnet-id=1", '--puppet-ca-proxy-id=1', '--puppet-class-ids=1,2', '--root-pass=foreman']
68
+ it_should_accept "name, parent_id, architecture_id, domain_id, operatingsystem_id and more",
69
+ ["--name=hostgroup", "--parent-id=1", "--architecture-id=1", "--domain-id=1",
70
+ "--operatingsystem-id=1", "--medium-id=1", "--partition-table-id=1", "--subnet-id=1", '--root-password=foreman']
73
71
  # it_should_fail_with "name or id missing",
74
72
  # ["--environment-id=1", "--architecture-id=1", "--domain-id=1", "--puppet-proxy-id=1", "--operatingsystem-id=1"]
75
73
  # TODO: temporarily disabled, parameters are checked in the api
@@ -81,9 +79,9 @@ describe HammerCLIForeman::Hostgroup do
81
79
  let(:cmd) { HammerCLIForeman::Hostgroup::UpdateCommand.new("", ctx) }
82
80
 
83
81
  context "parameters" do
84
- it_should_accept "name, parent_id, environment_id, architecture_id, domain_id, puppet_proxy_id, operatingsystem_id and more",
85
- ["--id=1 --name=hostgroup2 --title=default/hostgroup2", "--parent-id=1", "--environment-id=1", "--architecture-id=1", "--domain-id=1", "--puppet-proxy-id=1",
86
- "--operatingsystem-id=1", "--medium-id=1", "--partition-table-id=1", "--subnet-id=1", '--puppet-ca-proxy-id=1', '--puppet-class-ids=1,2', '--root-pass=foreman']
82
+ it_should_accept "name, parent_id, architecture_id, domain_id, operatingsystem_id and more",
83
+ ["--id=1 --name=hostgroup2 --title=default/hostgroup2", "--parent-id=1", "--architecture-id=1", "--domain-id=1",
84
+ "--operatingsystem-id=1", "--medium-id=1", "--partition-table-id=1", "--subnet-id=1", '--root-password=foreman']
87
85
  # it_should_fail_with "no params", []
88
86
  # it_should_fail_with "id missing", ["--name=host2"]
89
87
  # TODO: temporarily disabled, parameters are checked in the id resolver
@@ -123,23 +121,6 @@ describe HammerCLIForeman::Hostgroup do
123
121
 
124
122
  end
125
123
 
126
-
127
- context "SCParamsCommand" do
128
-
129
- before :each do
130
- ResourceMocks.smart_class_parameters_index
131
- end
132
-
133
- let(:cmd) { HammerCLIForeman::Hostgroup::SCParamsCommand.new("", ctx) }
134
-
135
- context "parameters" do
136
- it_should_accept "hostgroup", ["--hostgroup=hostgroup"]
137
- it_should_accept "hostgroup-id", ["--hostgroup-id=1"]
138
- # it_should_fail_with "name or id missing", [] # TODO: temporarily disabled, parameters are checked in the id resolver
139
- end
140
-
141
- end
142
-
143
124
  context "RebuildConfigCommand" do
144
125
 
145
126
  let(:cmd) { HammerCLIForeman::Hostgroup::RebuildConfigCommand.new("", ctx) }
@@ -213,34 +213,6 @@ describe HammerCLIForeman::IdResolver do
213
213
  end
214
214
  end
215
215
 
216
- describe 'searching for puppetclasses' do
217
- before do
218
- ResourceMocks.mock_action_call(:puppetclasses, :index, {
219
- 'apache' => [
220
- { 'id' => 70, 'name' => 'apache::dev', 'created_at' => '2015-01-27T07:24:57.134Z', 'updated_at' => '2015-03-05T17:27:54.282Z' },
221
- { 'id' => 27, 'name' => 'apache::mod::authnz_ldap', 'created_at' => '2015-01-27T07:24:56.378Z','updated_at' => '2015-01-27T07:24:56.378Z' }
222
- ],
223
- 'git' => [
224
- { 'id' => 85, 'name' => 'git::params', 'created_at' => '2015-01-27T07:24:57.306Z', 'updated_at' => '2015-01-27T07:24:57.306Z' }
225
- ]
226
- })
227
- end
228
-
229
- it "returns ids from options" do
230
- result = resolver.user_ids({"option_ids" => [4, 5], "option_names" => ['apache::dev']})
231
- assert_equal [4, 5], result
232
- end
233
-
234
- it "returns ids of the classes" do
235
- class_names = ['apache::mod::authnz_ldap', 'git::params', 'apache::dev']
236
- assert_equal [70, 27, 85], resolver.puppetclass_ids('option_names' => class_names)
237
- end
238
-
239
- it 'returns empty array for empty class array' do
240
- assert_equal [], resolver.puppetclass_ids('option_names' => [])
241
- end
242
- end
243
-
244
216
  describe "searching for multiple resources" do
245
217
  it "returns ids from options" do
246
218
  result = resolver.user_ids({"option_ids" => [4, 5], "option_names" => ["some", "names"]})
@@ -17,8 +17,8 @@ describe HammerCLIForeman::MailNotification do
17
17
 
18
18
  context 'parameters' do
19
19
  it_should_accept 'no arguments'
20
- it_should_fail_with 'organization param', ['--organization-id=1']
21
- it_should_fail_with 'location param', ['--location-id=1']
20
+ it_should_accept 'organization', ['--organization-id=1']
21
+ it_should_accept 'location', ['--location-id=1']
22
22
  end
23
23
 
24
24
  context 'output' do
@@ -36,8 +36,8 @@ describe HammerCLIForeman::MailNotification do
36
36
  context 'parameters' do
37
37
  it_should_accept 'id', ['--id=1']
38
38
  it_should_accept 'name', ['--name=test']
39
- it_should_fail_with 'organization param', ['--organization-id=1']
40
- it_should_fail_with 'location param', ['--location-id=1']
39
+ it_should_accept 'organization', %w[--id=1 --organization-id=1]
40
+ it_should_accept 'location', %w[--id=1 --location-id=1]
41
41
  end
42
42
 
43
43
  context 'output' do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require File.join(File.dirname(__FILE__), 'test_helper')
2
3
  require File.join(File.dirname(__FILE__), 'apipie_resource_mock')
3
4
 
@@ -7,68 +8,67 @@ describe HammerCLIForeman::Model do
7
8
 
8
9
  include CommandTestHelper
9
10
 
10
- context "ListCommand" do
11
+ context 'ListCommand' do
11
12
  before do
12
13
  ResourceMocks.mock_action_call(:models, :index, [])
13
14
  end
14
15
 
15
- let(:cmd) { HammerCLIForeman::Model::ListCommand.new("", ctx) }
16
+ let(:cmd) { HammerCLIForeman::Model::ListCommand.new('', ctx) }
16
17
 
17
- context "parameters" do
18
- it_should_accept "no arguments"
18
+ context 'parameters' do
19
+ it_should_accept 'no arguments'
19
20
  it_should_accept_search_params
20
- it_should_fail_with 'organization param', ['--organization-id=1']
21
- it_should_fail_with 'location param', ['--location-id=1']
21
+ it_should_accept 'organization', ['--organization-id=1']
22
+ it_should_accept 'location', ['--location-id=1']
22
23
  end
23
24
 
24
- context "output" do
25
+ context 'output' do
25
26
  let(:expected_record_count) { count_records(cmd.resource.call(:index)) }
26
27
 
27
28
  it_should_print_n_records
28
- it_should_print_column "Name"
29
- it_should_print_column "Id"
30
- it_should_print_column "Vendor class"
31
- it_should_print_column "HW model"
29
+ it_should_print_column 'Name'
30
+ it_should_print_column 'Id'
31
+ it_should_print_column 'Vendor class'
32
+ it_should_print_column 'HW model'
32
33
  end
33
34
  end
34
35
 
35
36
 
36
- context "InfoCommand" do
37
+ context 'InfoCommand' do
37
38
 
38
- let(:cmd) { HammerCLIForeman::Model::InfoCommand.new("", ctx) }
39
+ let(:cmd) { HammerCLIForeman::Model::InfoCommand.new('', ctx) }
39
40
 
40
- context "parameters" do
41
- it_should_accept "id", ["--id=1"]
42
- it_should_accept "name", ["--name=model"]
43
- it_should_fail_with 'organization param', ['--organization-id=1']
44
- it_should_fail_with 'location param', ['--location-id=1']
41
+ context 'parameters' do
42
+ it_should_accept 'id', ['--id=1']
43
+ it_should_accept 'name', ['--name=model']
44
+ it_should_accept 'organization', %w[--id=1 --organization-id=1]
45
+ it_should_accept 'location', %w[--id=1 --location-id=1]
45
46
  # it_should_fail_with "no arguments" # TODO: temporarily disabled, parameters are checked in the id resolver
46
47
  end
47
48
 
48
- context "output" do
49
- with_params ["--id=1"] do
49
+ context 'output' do
50
+ with_params ['--id=1'] do
50
51
  it_should_print_n_records 1
51
- it_should_print_column "Name"
52
- it_should_print_column "Id"
53
- it_should_print_column "Vendor class"
54
- it_should_print_column "HW model"
55
- it_should_print_column "Info"
56
- it_should_print_column "Created at"
57
- it_should_print_column "Updated at"
52
+ it_should_print_column 'Name'
53
+ it_should_print_column 'Id'
54
+ it_should_print_column 'Vendor class'
55
+ it_should_print_column 'HW model'
56
+ it_should_print_column 'Info'
57
+ it_should_print_column 'Created at'
58
+ it_should_print_column 'Updated at'
58
59
  end
59
60
  end
60
61
 
61
62
  end
62
63
 
63
64
 
64
- context "CreateCommand" do
65
+ context 'CreateCommand' do
65
66
 
66
- let(:cmd) { HammerCLIForeman::Model::CreateCommand.new("", ctx) }
67
+ let(:cmd) { HammerCLIForeman::Model::CreateCommand.new('', ctx) }
67
68
 
68
- context "parameters" do
69
- it_should_accept "name", ["--name=model", "--info=description", "--vendor-class=class", "--hardware-model=model"]
70
- it_should_fail_with 'organization param', ['--organization-id=1']
71
- it_should_fail_with 'location param', ['--location-id=1']
69
+ context 'parameters' do
70
+ it_should_accept 'name, info, vendor-class, hardware-model, organization, location',
71
+ %w[--name=model --info=description --vendor-class=class --hardware-model=model --organization-id=1 --location-id=1]
72
72
  # it_should_fail_with "name missing", ["--info=description", "--vendor-class=class", "--hardware-model=model"]
73
73
  # TODO: temporarily disabled, parameters are checked in the api
74
74
  end
@@ -76,30 +76,30 @@ describe HammerCLIForeman::Model do
76
76
  end
77
77
 
78
78
 
79
- context "DeleteCommand" do
79
+ context 'DeleteCommand' do
80
80
 
81
- let(:cmd) { HammerCLIForeman::Model::DeleteCommand.new("", ctx) }
81
+ let(:cmd) { HammerCLIForeman::Model::DeleteCommand.new('', ctx) }
82
82
 
83
- context "parameters" do
84
- it_should_accept "name", ["--name=model"]
85
- it_should_accept "id", ["--id=1"]
86
- it_should_fail_with 'organization param', ['--organization-id=1']
87
- it_should_fail_with 'location param', ['--location-id=1']
83
+ context 'parameters' do
84
+ it_should_accept 'name', ['--name=model']
85
+ it_should_accept 'id', ['--id=1']
86
+ it_should_accept 'organization', %w[--id=1 --organization-id=1]
87
+ it_should_accept 'location', %w[--id=1 --location-id=1]
88
88
  # it_should_fail_with "name or id missing", [] # TODO: temporarily disabled, parameters are checked in the id resolver
89
89
  end
90
90
 
91
91
  end
92
92
 
93
93
 
94
- context "UpdateCommand" do
94
+ context 'UpdateCommand' do
95
95
 
96
- let(:cmd) { HammerCLIForeman::Model::UpdateCommand.new("", ctx) }
96
+ let(:cmd) { HammerCLIForeman::Model::UpdateCommand.new('', ctx) }
97
97
 
98
- context "parameters" do
99
- it_should_accept "name", ["--name=model", "--new-name=model2", "--info=description", "--vendor-class=class", "--hardware-model=model"]
100
- it_should_accept "id", ["--id=1", "--new-name=model2", "--info=description", "--vendor-class=class", "--hardware-model=model"]
101
- it_should_fail_with 'organization param', ['--organization-id=1']
102
- it_should_fail_with 'location param', ['--location-id=1']
98
+ context 'parameters' do
99
+ it_should_accept 'name', ['--name=model', '--new-name=model2', '--info=description', '--vendor-class=class', '--hardware-model=model']
100
+ it_should_accept 'id', ['--id=1', '--new-name=model2', '--info=description', '--vendor-class=class', '--hardware-model=model']
101
+ it_should_accept 'organization', %w[--id=1 --organization-id=1]
102
+ it_should_accept 'location', %w[--id=1 --location-id=1]
103
103
  # it_should_fail_with "no params", []
104
104
  # it_should_fail_with "name or id missing", ["--new-name=model2", "--info=description", "--vendor-class=class", "--hardware-model=model"]
105
105
  # TODO: temporarily disabled, parameters are checked in the id resolver
@@ -18,8 +18,8 @@ describe HammerCLIForeman::OperatingSystem do
18
18
  context "parameters" do
19
19
  it_should_accept "no arguments"
20
20
  it_should_accept_search_params
21
- it_should_fail_with 'organization param', ['--organization-id=1']
22
- it_should_fail_with 'location param', ['--location-id=1']
21
+ it_should_accept 'organization', ['--organization-id=1']
22
+ it_should_accept 'location', ['--location-id=1']
23
23
  end
24
24
 
25
25
  context "output" do
@@ -42,8 +42,8 @@ describe HammerCLIForeman::OperatingSystem do
42
42
  context "parameters" do
43
43
  it_should_accept "id", ["--id=1"]
44
44
  it_should_accept "title", ["--title=Rhel 6.5"]
45
- it_should_fail_with 'organization param', ['--organization-id=1']
46
- it_should_fail_with 'location param', ['--location-id=1']
45
+ it_should_accept 'organization', %w[--id=1 --organization-id=1]
46
+ it_should_accept 'location', %w[--id=1 --location-id=1]
47
47
  # it_should_fail_with "no arguments" # TODO: temporarily disabled, parameters are checked in the id resolver
48
48
  end
49
49
 
@@ -73,9 +73,8 @@ describe HammerCLIForeman::OperatingSystem do
73
73
  let(:cmd) { HammerCLIForeman::OperatingSystem::CreateCommand.new("", ctx) }
74
74
 
75
75
  context "parameters" do
76
- it_should_accept "name, major, minor, family, release name", ["--name=media", "--major=1", "--minor=2", "--family=Red Hat", "--release-name=awesome"]
77
- it_should_fail_with 'organization param', ['--organization-id=1']
78
- it_should_fail_with 'location param', ['--location-id=1']
76
+ it_should_accept "name, major, minor, family, release name, organization, location",
77
+ ["--name=media", "--major=1", "--minor=2", "--family=Red Hat", "--release-name=awesome", "--organization-id=1", "--location-id=1"]
79
78
  # it_should_fail_with "name missing", ["--major=1", "--minor=2", "--family=Red Hat", "--release-name=awesome"]
80
79
  # TODO: temporarily disabled, parameters are checked in the api
81
80
  end
@@ -93,8 +92,8 @@ describe HammerCLIForeman::OperatingSystem do
93
92
  context "parameters" do
94
93
  it_should_accept "id", ["--id=1"]
95
94
  it_should_accept "title", ["--title=Rhel 6.5"]
96
- it_should_fail_with 'organization param', ['--organization-id=1']
97
- it_should_fail_with 'location param', ['--location-id=1']
95
+ it_should_accept 'organization', %w[--id=1 --organization-id=1]
96
+ it_should_accept 'location', %w[--id=1 --location-id=1]
98
97
  # it_should_fail_with "name or id missing", [] # TODO: temporarily disabled, parameters are checked in the id resolver
99
98
  # TODO: temporarily disabled, parameters are checked in the id resolver
100
99
  end
@@ -109,9 +108,8 @@ describe HammerCLIForeman::OperatingSystem do
109
108
  context "parameters" do
110
109
  it_should_accept "id", ["--id=1"]
111
110
  it_should_accept "title", ["--title=Rhel 6.5"]
112
- it_should_accept "name, major, minor, family, release name", ["--id=83", "--name=os", "--major=1", "--minor=2", "--family=Red Hat", "--release-name=awesome"]
113
- it_should_fail_with 'organization param', ['--organization-id=1']
114
- it_should_fail_with 'location param', ['--location-id=1']
111
+ it_should_accept "name, major, minor, family, release name, organization, location",
112
+ ["--id=83", "--name=os", "--major=1", "--minor=2", "--family=Red Hat", "--release-name=awesome", "--organization-id=1", "--location-id=1"]
115
113
  # it_should_fail_with "no params", []
116
114
  # it_should_fail_with "label or id missing", ["--name=os", "--major=1", "--minor=2", "--family=Red Hat", "--release-name=awesome"]
117
115
  # TODO: temporarily disabled, parameters are checked in the id resolver
@@ -136,8 +134,6 @@ describe HammerCLIForeman::OperatingSystem do
136
134
  it_should_accept "name, value and os id", ["--name=domain", "--value=val", "--operatingsystem-id=1"]
137
135
  it_should_accept "name, value and os title", ["--name=domain", "--value=val", "--operatingsystem=Rhel 6.5"]
138
136
  it_should_accept "name, value, type and os id", ["--name=domain", "--value=val", "--parameter-type=string", "--operatingsystem-id=1"]
139
- it_should_fail_with 'organization param', ['--organization-id=1']
140
- it_should_fail_with 'location param', ['--location-id=1']
141
137
  # it_should_fail_with "name missing", ["--value=val", "--operatingsystem-id=id"]
142
138
  # it_should_fail_with "value missing", ["--name=name", "--operatingsystem-id=id"]
143
139
  # it_should_fail_with "os id missing", ["--name=name", "--value=val"]
@@ -154,8 +150,6 @@ describe HammerCLIForeman::OperatingSystem do
154
150
  context "parameters" do
155
151
  it_should_accept "name and os id", ["--name=domain", "--operatingsystem-id=1"]
156
152
  it_should_accept "name and os title", ["--name=domain", "--operatingsystem=Rhel 6.5"]
157
- it_should_fail_with 'organization param', ['--organization-id=1']
158
- it_should_fail_with 'location param', ['--location-id=1']
159
153
  # it_should_fail_with "name missing", ["--operatingsystem-id=id"]
160
154
  # it_should_fail_with "os id missing", ["--name=name"]
161
155
  # TODO: temporarily disabled, parameters are checked in the id resolver
@@ -26,5 +26,14 @@ describe HammerCLIForeman::OptionSources::IdParams do
26
26
  params = id_params_source.get_options([], option_data)
27
27
  _(params).must_equal expected_data
28
28
  end
29
+
30
+ it 'resolves param when set but different name' do
31
+ hg_cmd.stubs(:get_resource_id).returns(nil)
32
+ hg_cmd.expects(:get_resource_id).with { |res| res.name == :domains }.returns(3)
33
+ option_data = { 'option_domain_id' => 1, 'option_domain_name' => 'test3' }
34
+ expected_data = { 'option_domain_id' => 3, 'option_domain_name' => 'test3' }
35
+ params = id_params_source.get_options([], option_data)
36
+ _(params).must_equal expected_data
37
+ end
29
38
  end
30
39
  end
@@ -26,5 +26,14 @@ describe HammerCLIForeman::OptionSources::IdsParams do
26
26
  params = ids_params_source.get_options([], option_data)
27
27
  _(params).must_equal expected_data
28
28
  end
29
+
30
+ it "resolves param when set but different name" do
31
+ cmd.stubs(:get_resource_ids).returns(nil)
32
+ cmd.expects(:get_resource_ids).with { |res| res.name == :locations }.returns([3])
33
+ option_data = { 'option_location_ids' => [1], 'option_location_names' => 'test3' }
34
+ expected_data = { 'option_location_ids' => [3], 'option_location_names' => 'test3' }
35
+ params = ids_params_source.get_options([], option_data)
36
+ _(params).must_equal expected_data
37
+ end
29
38
  end
30
39
  end
@@ -18,8 +18,8 @@ describe HammerCLIForeman::Settings do
18
18
  context "parameters" do
19
19
  it_should_accept "no arguments"
20
20
  it_should_accept_search_params
21
- it_should_fail_with 'organization param', ['--organization-id=1']
22
- it_should_fail_with 'location param', ['--location-id=1']
21
+ it_should_accept 'organization', ['--organization-id=1']
22
+ it_should_accept 'location', ['--location-id=1']
23
23
  end
24
24
 
25
25
  context "output" do
@@ -40,8 +40,8 @@ describe HammerCLIForeman::Settings do
40
40
  context "parameters" do
41
41
  it_should_accept "name", ["--name=setting1", "--value=setting2"]
42
42
  it_should_accept "id", ["--id=1", "--value=setting2"]
43
- it_should_fail_with 'organization param', ['--organization-id=1']
44
- it_should_fail_with 'location param', ['--location-id=1']
43
+ it_should_accept 'organization', %w[--id=1 --organization-id=1]
44
+ it_should_accept 'location', %w[--id=1 --location-id=1]
45
45
  end
46
46
 
47
47
  end
@@ -90,18 +90,6 @@ describe HammerCLIForeman::SmartProxy do
90
90
 
91
91
  end
92
92
 
93
- context "ImportPuppetClassesCommand" do
94
-
95
- let(:cmd) { HammerCLIForeman::SmartProxy::ImportPuppetClassesCommand.new("", ctx) }
96
-
97
- context "parameters" do
98
- it_should_accept "id, environment-id and dryrun", ["--id=1", "--environment-id=1", "--dryrun"]
99
- # it_should_fail_with "id missing", []
100
- # TODO: temporarily disabled, parameters are checked in the id resolver
101
- end
102
-
103
- end
104
-
105
93
  context "RefreshFeaturesCommand" do
106
94
 
107
95
  let(:cmd) { HammerCLIForeman::SmartProxy::RefreshFeaturesCommand.new("", ctx) }
@@ -18,8 +18,8 @@ describe HammerCLIForeman::Usergroup do
18
18
  context "parameters" do
19
19
  it_should_accept "no arguments"
20
20
  it_should_accept_search_params
21
- it_should_fail_with 'organization param', ['--organization-id=1']
22
- it_should_fail_with 'location param', ['--location-id=1']
21
+ it_should_accept 'organization', ['--organization-id=1']
22
+ it_should_accept 'location', ['--location-id=1']
23
23
  end
24
24
 
25
25
  context "output" do
@@ -37,8 +37,8 @@ describe HammerCLIForeman::Usergroup do
37
37
  context "parameters" do
38
38
  it_should_accept "id", ["--id=1"]
39
39
  it_should_accept "name", ["--name=ug"]
40
- it_should_fail_with 'organization param', ['--organization-id=1']
41
- it_should_fail_with 'location param', ['--location-id=1']
40
+ it_should_accept 'organization', %w[--id=1 --organization-id=1]
41
+ it_should_accept 'location', %w[--id=1 --location-id=1]
42
42
  end
43
43
 
44
44
  context "output" do
@@ -62,8 +62,8 @@ describe HammerCLIForeman::Usergroup do
62
62
  context "parameters" do
63
63
  it_should_accept "name", ["--name=ug"]
64
64
  it_should_accept "name, role ids, user group ids and user ids", ["--name=ug", "--role-ids=1,2,3", "--user-group-ids=1,2,3", "--user-ids=1,2,3"]
65
- it_should_fail_with 'organization param', ['--organization-id=1']
66
- it_should_fail_with 'location param', ['--location-id=1']
65
+ it_should_accept 'organization', %w[--name=ug --organization-id=1]
66
+ it_should_accept 'location', %w[--name=ug --location-id=1]
67
67
  end
68
68
  end
69
69
 
@@ -74,8 +74,8 @@ describe HammerCLIForeman::Usergroup do
74
74
  context "parameters" do
75
75
  it_should_accept "name", ["--name=ug"]
76
76
  it_should_accept "id", ["--id=1"]
77
- it_should_fail_with 'organization param', ['--organization-id=1']
78
- it_should_fail_with 'location param', ['--location-id=1']
77
+ it_should_accept 'organization', %w[--id=1 --organization-id=1]
78
+ it_should_accept 'location', %w[--id=1 --location-id=1]
79
79
  end
80
80
  end
81
81
 
@@ -88,8 +88,8 @@ describe HammerCLIForeman::Usergroup do
88
88
  it_should_accept "id", ["--id=1"]
89
89
  it_should_accept "name and new name", ["--name=ug", "--new-name=ug2"]
90
90
  it_should_accept "id, new name, role ids, user group ids and user ids", ["--id=1", "--new-name=ug", "--role-ids=1,2,3", "--user-group-ids=1,2,3", "--user-ids=1,2,3"]
91
- it_should_fail_with 'organization param', ['--organization-id=1']
92
- it_should_fail_with 'location param', ['--location-id=1']
91
+ it_should_accept 'organization', %w[--id=1 --organization-id=1]
92
+ it_should_accept 'location', %w[--id=1 --location-id=1]
93
93
  end
94
94
  end
95
95
  end