hammer_cli_foreman 2.5.2 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/doc/release_notes.md +10 -4
- data/lib/hammer_cli_foreman/architecture.rb +5 -5
- data/lib/hammer_cli_foreman/associating_commands.rb +0 -24
- data/lib/hammer_cli_foreman/bookmark.rb +5 -5
- data/lib/hammer_cli_foreman/combination.rb +3 -13
- data/lib/hammer_cli_foreman/command_extensions.rb +0 -2
- data/lib/hammer_cli_foreman/commands.rb +2 -9
- data/lib/hammer_cli_foreman/compute_profile.rb +5 -5
- data/lib/hammer_cli_foreman/host.rb +0 -35
- data/lib/hammer_cli_foreman/hostgroup.rb +2 -53
- data/lib/hammer_cli_foreman/hosts/common_update_options.rb +1 -23
- data/lib/hammer_cli_foreman/id_resolver.rb +0 -61
- data/lib/hammer_cli_foreman/location.rb +0 -6
- data/lib/hammer_cli_foreman/mail_notification.rb +2 -2
- data/lib/hammer_cli_foreman/model.rb +5 -5
- data/lib/hammer_cli_foreman/operating_system.rb +10 -10
- data/lib/hammer_cli_foreman/option_sources/id_params.rb +27 -10
- data/lib/hammer_cli_foreman/option_sources/ids_params.rb +25 -6
- data/lib/hammer_cli_foreman/option_sources.rb +0 -1
- data/lib/hammer_cli_foreman/organization.rb +0 -6
- data/lib/hammer_cli_foreman/references.rb +0 -16
- data/lib/hammer_cli_foreman/settings.rb +3 -3
- data/lib/hammer_cli_foreman/smart_proxy.rb +0 -52
- data/lib/hammer_cli_foreman/usergroup.rb +5 -5
- data/lib/hammer_cli_foreman/version.rb +1 -1
- data/lib/hammer_cli_foreman.rb +0 -21
- data/lib/minitest/coverage_reporter.rb +1 -1
- data/locale/ca/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/de/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/en/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/en_GB/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/es/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/fr/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/it/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/ja/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/ko/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/pt_BR/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/ru/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/zh_CN/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/zh_TW/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/test/functional/architecture_test.rb +6 -4
- data/test/functional/bookmark_test.rb +3 -1
- data/test/functional/compute_profile_test.rb +3 -1
- data/test/functional/host_test.rb +0 -1
- data/test/functional/hostgroup/create_test.rb +0 -117
- data/test/functional/hostgroup/update_test.rb +0 -79
- data/test/functional/location_test.rb +0 -3
- data/test/functional/mail_notification_test.rb +3 -1
- data/test/functional/model_test.rb +3 -1
- data/test/functional/operating_system_test.rb +3 -1
- data/test/functional/settings_test.rb +4 -4
- data/test/functional/template_test.rb +4 -37
- data/test/functional/usergroup_test.rb +3 -1
- data/test/unit/apipie_resource_mock.rb +1 -39
- data/test/unit/architecture_test.rb +10 -10
- data/test/unit/bookmark_test.rb +10 -14
- data/test/unit/compute_profile_test.rb +10 -10
- data/test/unit/helpers/command.rb +0 -8
- data/test/unit/host_test.rb +14 -61
- data/test/unit/hostgroup_test.rb +7 -26
- data/test/unit/id_resolver_test.rb +0 -28
- data/test/unit/mail_notification_test.rb +4 -4
- data/test/unit/model_test.rb +47 -47
- data/test/unit/operating_system_test.rb +10 -16
- data/test/unit/option_sources/id_params_test.rb +9 -0
- data/test/unit/option_sources/ids_params_test.rb +9 -0
- data/test/unit/settings_test.rb +4 -4
- data/test/unit/smart_proxy_test.rb +0 -12
- data/test/unit/usergroup_test.rb +10 -10
- metadata +27 -48
- data/lib/hammer_cli_foreman/command_extensions/puppet_environment.rb +0 -29
- data/lib/hammer_cli_foreman/command_extensions/puppet_environments.rb +0 -29
- data/lib/hammer_cli_foreman/config_group.rb +0 -45
- data/lib/hammer_cli_foreman/option_sources/puppet_environment_params.rb +0 -59
- data/lib/hammer_cli_foreman/puppet_class.rb +0 -61
- data/lib/hammer_cli_foreman/puppet_environment.rb +0 -65
- data/lib/hammer_cli_foreman/smart_class_parameter.rb +0 -189
- data/test/functional/config_group_test.rb +0 -50
- data/test/functional/proxy_test.rb +0 -86
- data/test/functional/smart_class_parameter_test.rb +0 -97
- data/test/unit/config_group_test.rb +0 -82
- data/test/unit/puppet_class_test.rb +0 -72
- data/test/unit/puppet_environment_test.rb +0 -114
- data/test/unit/smart_class_parameter_test.rb +0 -113
@@ -68,25 +68,6 @@ module HammerCLIForeman
|
|
68
68
|
run_cmd(%w(hostgroup create --name hg1 --domain d1))
|
69
69
|
end
|
70
70
|
|
71
|
-
it 'allows environment id' do
|
72
|
-
api_expects(:hostgroups, :create) do |p|
|
73
|
-
p['hostgroup']['environment_id'] == 1 &&
|
74
|
-
p['hostgroup']['name'] == 'hg1'
|
75
|
-
end
|
76
|
-
run_cmd(%w(hostgroup create --name hg1 --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, :create) do |p|
|
84
|
-
p['hostgroup']['environment_id'] == 1 &&
|
85
|
-
p['hostgroup']['name'] == 'hg1'
|
86
|
-
end
|
87
|
-
run_cmd(%w(hostgroup create --name hg1 --environment env1))
|
88
|
-
end
|
89
|
-
|
90
71
|
it 'allows location ids' do
|
91
72
|
api_expects(:hostgroups, :create) do |p|
|
92
73
|
p['hostgroup']['location_ids'] == ['1','4'] &&
|
@@ -203,104 +184,6 @@ module HammerCLIForeman
|
|
203
184
|
run_cmd(%w(hostgroup create --name hg1 --partition-table pt1))
|
204
185
|
end
|
205
186
|
|
206
|
-
it 'allows puppet ca proxy id' do
|
207
|
-
api_expects(:hostgroups, :create).with_params({
|
208
|
-
:hostgroup => {
|
209
|
-
:name => 'hg1',
|
210
|
-
:puppet_ca_proxy_id => 1
|
211
|
-
}
|
212
|
-
})
|
213
|
-
run_cmd(%w(hostgroup create --name hg1 --puppet-ca-proxy-id 1))
|
214
|
-
end
|
215
|
-
|
216
|
-
it 'allows puppet ca proxy name' do
|
217
|
-
api_expects(:smart_proxies, :index) do |p|
|
218
|
-
p[:search] = "name = \"sp1\""
|
219
|
-
end.returns(index_response([{'id' => 1}]))
|
220
|
-
api_expects(:hostgroups, :create) do |p|
|
221
|
-
p['hostgroup']['puppet_ca_proxy_id'] == 1 &&
|
222
|
-
p['hostgroup']['name'] == 'hg1'
|
223
|
-
end
|
224
|
-
run_cmd(%w(hostgroup create --name hg1 --puppet-ca-proxy sp1))
|
225
|
-
end
|
226
|
-
|
227
|
-
it 'allows puppet class ids' do
|
228
|
-
api_expects(:hostgroups, :create) do |p|
|
229
|
-
p['hostgroup']['puppetclass_ids'] == ['1','2'] &&
|
230
|
-
p['hostgroup']['name'] == 'hg1'
|
231
|
-
end
|
232
|
-
run_cmd(%w(hostgroup create --name hg1 --puppet-class-ids 1,2))
|
233
|
-
end
|
234
|
-
|
235
|
-
it 'allows puppet class names' do
|
236
|
-
api_expects(:puppetclasses, :index) do |p|
|
237
|
-
p[:search] = "name = \"pc1\" or name = \"pc2\""
|
238
|
-
end.returns(index_response('puppetclasses' => [
|
239
|
-
{'id' => 1, 'name' => 'pc1'},
|
240
|
-
{'id' => 2, 'name' => 'pc2'}
|
241
|
-
]))
|
242
|
-
api_expects(:hostgroups, :create) do |p|
|
243
|
-
p['hostgroup']['puppetclass_ids'] == [1,2] &&
|
244
|
-
p['hostgroup']['name'] == 'hg1'
|
245
|
-
end
|
246
|
-
run_cmd(%w(hostgroup create --name hg1 --puppet-classes pc1,pc2))
|
247
|
-
end
|
248
|
-
|
249
|
-
it 'allows puppet class names that exceeds entries_per_page' do
|
250
|
-
search_objects = []
|
251
|
-
response_objects = []
|
252
|
-
ids = []
|
253
|
-
names = []
|
254
|
-
1100.times.with_object('pc').each do |id, name|
|
255
|
-
next_name = "\"#{name}#{id}\""
|
256
|
-
search_objects << "name = #{next_name}"
|
257
|
-
response_objects << { 'id' => id, 'name' => next_name }
|
258
|
-
ids << id
|
259
|
-
names << next_name
|
260
|
-
end
|
261
|
-
|
262
|
-
api_expects(:puppetclasses, :index) do |p|
|
263
|
-
p[:search] == search_objects.join(' or ') &&
|
264
|
-
p[:page].to_i == 1 &&
|
265
|
-
p[:per_page].to_i == HammerCLIForeman::IdResolver::ALL_PER_PAGE
|
266
|
-
end.returns(
|
267
|
-
index_response('puppetclasses' => response_objects[0...1000]))
|
268
|
-
|
269
|
-
api_expects(:puppetclasses, :index) do |p|
|
270
|
-
p[:search] == search_objects.join(' or ') &&
|
271
|
-
p[:page].to_i == 2 &&
|
272
|
-
p[:per_page].to_i == HammerCLIForeman::IdResolver::ALL_PER_PAGE
|
273
|
-
end.returns(index_response('puppetclasses' => response_objects[1000...1100]))
|
274
|
-
|
275
|
-
api_expects(:hostgroups, :create) do |p|
|
276
|
-
p['hostgroup']['name'] == 'hg1' &&
|
277
|
-
p['hostgroup']['puppetclass_ids'] == ids
|
278
|
-
end
|
279
|
-
|
280
|
-
run_cmd(%w[hostgroup create --name hg1 --puppet-classes] << names.join(',').tr('"', ''))
|
281
|
-
end
|
282
|
-
|
283
|
-
it 'allows puppet proxy id' do
|
284
|
-
api_expects(:hostgroups, :create).with_params({
|
285
|
-
:hostgroup => {
|
286
|
-
:name => 'hg1',
|
287
|
-
:puppet_proxy_id => 1
|
288
|
-
}
|
289
|
-
})
|
290
|
-
run_cmd(%w(hostgroup create --name hg1 --puppet-proxy-id 1))
|
291
|
-
end
|
292
|
-
|
293
|
-
it 'allows puppet proxy name' do
|
294
|
-
api_expects(:smart_proxies, :index) do |p|
|
295
|
-
p[:search] = "name = \"sp1\""
|
296
|
-
end.returns(index_response([{'id' => 1}]))
|
297
|
-
api_expects(:hostgroups, :create) do |p|
|
298
|
-
p['hostgroup']['puppet_proxy_id'] == 1 &&
|
299
|
-
p['hostgroup']['name'] == 'hg1'
|
300
|
-
end
|
301
|
-
run_cmd(%w(hostgroup create --name hg1 --puppet-proxy sp1))
|
302
|
-
end
|
303
|
-
|
304
187
|
it 'allows realm id' do
|
305
188
|
api_expects(:hostgroups, :create) do |p|
|
306
189
|
p['hostgroup']['realm_id'] == 1 &&
|
@@ -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 &&
|
@@ -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:',
|
@@ -26,7 +26,7 @@ describe 'mail_notification' do
|
|
26
26
|
end
|
27
27
|
|
28
28
|
it 'should run list command with defaults' do
|
29
|
-
providers = { 'foreman' => HammerCLIForeman::Defaults.new(api_connection({}, '2.
|
29
|
+
providers = { 'foreman' => HammerCLIForeman::Defaults.new(api_connection({}, '2.5')) }
|
30
30
|
defaults = HammerCLI::Defaults.new(
|
31
31
|
{
|
32
32
|
organization_id: {
|
@@ -39,6 +39,8 @@ describe 'mail_notification' do
|
|
39
39
|
)
|
40
40
|
defaults.stubs(:write_to_file).returns(true)
|
41
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 } }]))
|
42
44
|
api_expects(:mail_notifications, :index, 'List mail notifications').returns(@mail_notifications)
|
43
45
|
|
44
46
|
result = run_cmd(@cmd, { use_defaults: true, defaults: defaults })
|
@@ -26,7 +26,7 @@ describe 'model' do
|
|
26
26
|
end
|
27
27
|
|
28
28
|
it 'should run list command with defaults' do
|
29
|
-
providers = { 'foreman' => HammerCLIForeman::Defaults.new(api_connection({}, '2.
|
29
|
+
providers = { 'foreman' => HammerCLIForeman::Defaults.new(api_connection({}, '2.5')) }
|
30
30
|
defaults = HammerCLI::Defaults.new(
|
31
31
|
{
|
32
32
|
organization_id: {
|
@@ -39,6 +39,8 @@ describe 'model' do
|
|
39
39
|
)
|
40
40
|
defaults.stubs(:write_to_file).returns(true)
|
41
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 } }]))
|
42
44
|
api_expects(:models, :index, 'List models').returns(@models)
|
43
45
|
|
44
46
|
result = run_cmd(@cmd, { use_defaults: true, defaults: defaults })
|
@@ -27,7 +27,7 @@ describe 'operating_system' do
|
|
27
27
|
end
|
28
28
|
|
29
29
|
it 'should run list command with defaults' do
|
30
|
-
providers = { 'foreman' => HammerCLIForeman::Defaults.new(api_connection({}, '2.
|
30
|
+
providers = { 'foreman' => HammerCLIForeman::Defaults.new(api_connection({}, '2.5')) }
|
31
31
|
defaults = HammerCLI::Defaults.new(
|
32
32
|
{
|
33
33
|
organization_id: {
|
@@ -40,6 +40,8 @@ describe 'operating_system' do
|
|
40
40
|
)
|
41
41
|
defaults.stubs(:write_to_file).returns(true)
|
42
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 } }]))
|
43
45
|
api_expects(:operatingsystems, :index, 'List operating systems').returns(@operating_system)
|
44
46
|
|
45
47
|
result = run_cmd(@cmd, { use_defaults: true, defaults: defaults })
|
@@ -32,7 +32,7 @@ describe 'Settings' do
|
|
32
32
|
end
|
33
33
|
|
34
34
|
it 'should run list command with defaults' do
|
35
|
-
providers = { 'foreman' => HammerCLIForeman::Defaults.new(api_connection({}, '2.
|
35
|
+
providers = { 'foreman' => HammerCLIForeman::Defaults.new(api_connection({}, '2.5')) }
|
36
36
|
defaults = HammerCLI::Defaults.new(
|
37
37
|
{
|
38
38
|
organization_id: {
|
@@ -45,9 +45,9 @@ describe 'Settings' do
|
|
45
45
|
)
|
46
46
|
defaults.stubs(:write_to_file).returns(true)
|
47
47
|
defaults.stubs(:providers).returns(providers)
|
48
|
-
api_expects(:
|
49
|
-
|
50
|
-
).returns(
|
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
51
|
|
52
52
|
result = run_cmd(@cmd, { use_defaults: true, defaults: defaults })
|
53
53
|
_(result.exit_code).must_equal HammerCLI::EX_OK
|
@@ -140,45 +140,13 @@ describe 'template' do
|
|
140
140
|
@cmd = %w(template combination)
|
141
141
|
end
|
142
142
|
|
143
|
-
it 'should create new combination with warning' do
|
144
|
-
params = ['create','--provisioning-template-id=10', '--hostgroup-id=1', '--environment-id=1']
|
145
|
-
expected_result = success_result("Template combination created.\n")
|
146
|
-
expected_result.expected_err = "Warning: Option --environment-id is deprecated. Use --puppet-environment[-id] instead\n"
|
147
|
-
api_expects(:template_combinations, :create, 'Create template combination') do |params|
|
148
|
-
params['provisioning_template_id'] == 10 &&
|
149
|
-
params['hostgroup_id'] == 1 &&
|
150
|
-
params['environment_id'] == 1 &&
|
151
|
-
params['template_combination'] == {'environment_id' => 1, 'hostgroup_id' => 1}
|
152
|
-
end
|
153
|
-
|
154
|
-
result = run_cmd(@cmd + params)
|
155
|
-
assert_cmd(expected_result, result)
|
156
|
-
end
|
157
|
-
|
158
143
|
it 'should create new combination' do
|
159
|
-
params = ['create','--provisioning-template-id=10', '--hostgroup-id=1'
|
144
|
+
params = ['create','--provisioning-template-id=10', '--hostgroup-id=1']
|
160
145
|
expected_result = success_result("Template combination created.\n")
|
161
146
|
api_expects(:template_combinations, :create, 'Create template combination') do |params|
|
162
147
|
params['provisioning_template_id'] == 10 &&
|
163
148
|
params['hostgroup_id'] == 1 &&
|
164
|
-
params['
|
165
|
-
params['template_combination'] == {'environment_id' => 1, 'hostgroup_id' => 1}
|
166
|
-
end
|
167
|
-
|
168
|
-
result = run_cmd(@cmd + params)
|
169
|
-
assert_cmd(expected_result, result)
|
170
|
-
end
|
171
|
-
|
172
|
-
it 'should update combination with warning' do
|
173
|
-
params = ['update', '--id=3', '--provisioning-template-id=10', '--hostgroup-id=1', '--environment-id=1']
|
174
|
-
expected_result = success_result("Template combination updated.\n")
|
175
|
-
expected_result.expected_err = "Warning: Option --environment-id is deprecated. Use --puppet-environment[-id] instead\n"
|
176
|
-
api_expects(:template_combinations, :update, 'Update template combination') do |params|
|
177
|
-
params['id'] == '3' &&
|
178
|
-
params['provisioning_template_id'] == 10 &&
|
179
|
-
params['hostgroup_id'] == 1 &&
|
180
|
-
params['environment_id'] == 1 &&
|
181
|
-
params['template_combination'] == { 'environment_id' => 1, 'hostgroup_id' => 1 }
|
149
|
+
params['template_combination'] == {'hostgroup_id' => 1}
|
182
150
|
end
|
183
151
|
|
184
152
|
result = run_cmd(@cmd + params)
|
@@ -186,14 +154,13 @@ describe 'template' do
|
|
186
154
|
end
|
187
155
|
|
188
156
|
it 'should update combination' do
|
189
|
-
params = ['update', '--id=3', '--provisioning-template-id=10', '--hostgroup-id=1'
|
157
|
+
params = ['update', '--id=3', '--provisioning-template-id=10', '--hostgroup-id=1']
|
190
158
|
expected_result = success_result("Template combination updated.\n")
|
191
159
|
api_expects(:template_combinations, :update, 'Update template combination') do |params|
|
192
160
|
params['id'] == '3' &&
|
193
161
|
params['provisioning_template_id'] == 10 &&
|
194
162
|
params['hostgroup_id'] == 1 &&
|
195
|
-
params['
|
196
|
-
params['template_combination'] == { 'environment_id' => 1, 'hostgroup_id' => 1 }
|
163
|
+
params['template_combination'] == { 'hostgroup_id' => 1 }
|
197
164
|
end
|
198
165
|
|
199
166
|
result = run_cmd(@cmd + params)
|
@@ -27,7 +27,7 @@ describe 'user-group' do
|
|
27
27
|
end
|
28
28
|
|
29
29
|
it 'should run list command with defaults' do
|
30
|
-
providers = { 'foreman' => HammerCLIForeman::Defaults.new(api_connection({}, '2.
|
30
|
+
providers = { 'foreman' => HammerCLIForeman::Defaults.new(api_connection({}, '2.5')) }
|
31
31
|
defaults = HammerCLI::Defaults.new(
|
32
32
|
{
|
33
33
|
organization_id: {
|
@@ -40,6 +40,8 @@ describe 'user-group' do
|
|
40
40
|
)
|
41
41
|
defaults.stubs(:write_to_file).returns(true)
|
42
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 } }]))
|
43
45
|
api_expects(:usergroups, :index, 'List user groups').returns(@user_groups)
|
44
46
|
|
45
47
|
result = run_cmd(@cmd, { use_defaults: true, defaults: defaults })
|
@@ -19,15 +19,6 @@ module ResourceMocks
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
-
def self.smart_class_parameters_index
|
23
|
-
ResourceMocks.mock_action_call(:smart_class_parameters, :index,
|
24
|
-
{ "results" => [ { 'parameter' => 'config', 'id' => '1'} ] })
|
25
|
-
end
|
26
|
-
|
27
|
-
def self.smart_class_parameters_show
|
28
|
-
ResourceMocks.mock_action_call(:smart_class_parameters, :show, { 'smart_class_parameter' => { 'override_value_order' => '', 'environments' => [] }})
|
29
|
-
end
|
30
|
-
|
31
22
|
def self.smart_variables_index
|
32
23
|
ResourceMocks.mock_action_call(:smart_variables, :index,
|
33
24
|
{ "results" => [ { 'variable' => 'var', 'id' => '1'} ] })
|
@@ -107,8 +98,6 @@ module ResourceMocks
|
|
107
98
|
ResourceMocks.mock_action_call(:hosts, :show, {
|
108
99
|
"ip" => "192.168.122.51",
|
109
100
|
"ip6" => nil,
|
110
|
-
"environment_id" => 1,
|
111
|
-
"environment_name" => "production",
|
112
101
|
"last_report" => "2016-10-24 12:06:31 UTC",
|
113
102
|
"mac" => "52:54:00:ce:b2:b9",
|
114
103
|
"realm_id" => nil,
|
@@ -150,26 +139,11 @@ module ResourceMocks
|
|
150
139
|
"organization_name" => nil,
|
151
140
|
"location_id" => nil,
|
152
141
|
"location_name" => nil,
|
153
|
-
"puppet_status" => 0,
|
154
142
|
"model_name" => "KVM",
|
155
143
|
"configuration_status" => 0,
|
156
144
|
"configuration_status_label" => "No reports",
|
157
145
|
"name" => "foreman.example.com",
|
158
146
|
"id" => 1,
|
159
|
-
"puppet_proxy_id" => 1,
|
160
|
-
"puppet_proxy_name" => "foreman.example.com",
|
161
|
-
"puppet_ca_proxy_id" => 1,
|
162
|
-
"puppet_ca_proxy_name" => "foreman.example.com",
|
163
|
-
"puppet_proxy" => {
|
164
|
-
"name" => "foreman.example.com",
|
165
|
-
"id" => 1,
|
166
|
-
"url" => "https://foreman.example.com:9090"
|
167
|
-
},
|
168
|
-
"puppet_ca_proxy" => {
|
169
|
-
"name" => "foreman.example.com",
|
170
|
-
"id" => 1,
|
171
|
-
"url" => "https://foreman.example.com:9090"
|
172
|
-
},
|
173
147
|
"hostgroup_name" => nil,
|
174
148
|
"hostgroup_title" => nil,
|
175
149
|
"parameters" => [],
|
@@ -193,10 +167,7 @@ module ResourceMocks
|
|
193
167
|
"primary" => false,
|
194
168
|
"provision" => false,
|
195
169
|
"type" => "interface"
|
196
|
-
}]
|
197
|
-
"puppetclasses" => [],
|
198
|
-
"config_groups" => [],
|
199
|
-
"all_puppetclasses" => []
|
170
|
+
}]
|
200
171
|
})
|
201
172
|
end
|
202
173
|
|
@@ -335,13 +306,4 @@ module ResourceMocks
|
|
335
306
|
"value" => "random value",
|
336
307
|
}])
|
337
308
|
end
|
338
|
-
|
339
|
-
def self.config_groups_index
|
340
|
-
ResourceMocks.mock_action_call(:config_groups, :index, [{
|
341
|
-
id: 15,
|
342
|
-
name: "test config group",
|
343
|
-
puppetclasses: [ { name: "My puppetclass" } ]
|
344
|
-
}])
|
345
|
-
end
|
346
|
-
|
347
309
|
end
|
@@ -17,8 +17,8 @@ describe HammerCLIForeman::Architecture do
|
|
17
17
|
context "parameters" do
|
18
18
|
it_should_accept "no arguments"
|
19
19
|
it_should_accept_search_params
|
20
|
-
|
21
|
-
|
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
|
@@ -39,8 +39,8 @@ describe HammerCLIForeman::Architecture do
|
|
39
39
|
context "parameters" do
|
40
40
|
it_should_accept "id", ["--id=1"]
|
41
41
|
it_should_accept "name", ["--name=arch"]
|
42
|
-
|
43
|
-
|
42
|
+
it_should_accept 'organization', %w[--id=1 --organization-id=1]
|
43
|
+
it_should_accept 'location', %w[--id=1 --location-id=1]
|
44
44
|
# it_should_fail_with "no arguments" # TODO: temporarily disabled, parameters are checked in the id resolver
|
45
45
|
end
|
46
46
|
|
@@ -61,8 +61,8 @@ describe HammerCLIForeman::Architecture do
|
|
61
61
|
|
62
62
|
context "parameters" do
|
63
63
|
it_should_accept "name", ["--name=arch"]
|
64
|
-
|
65
|
-
|
64
|
+
it_should_accept 'organization', %w[--name=arch --organization-id=1]
|
65
|
+
it_should_accept 'location', %w[--name=arch --location-id=1]
|
66
66
|
# it_should_fail_with "name missing", []
|
67
67
|
# TODO: temporarily disabled, parameters are checked in the api
|
68
68
|
end
|
@@ -77,8 +77,8 @@ describe HammerCLIForeman::Architecture do
|
|
77
77
|
context "parameters" do
|
78
78
|
it_should_accept "name", ["--name=arch"]
|
79
79
|
it_should_accept "id", ["--id=1"]
|
80
|
-
|
81
|
-
|
80
|
+
it_should_accept 'organization', %w[--id=1 --organization-id=1]
|
81
|
+
it_should_accept 'location', %w[--id=1 --location-id=1]
|
82
82
|
# it_should_fail_with "name or id missing", [] # TODO: temporarily disabled, parameters are checked in the id resolver
|
83
83
|
end
|
84
84
|
|
@@ -92,8 +92,8 @@ describe HammerCLIForeman::Architecture do
|
|
92
92
|
context "parameters" do
|
93
93
|
it_should_accept "name", ["--name=arch", "--new-name=arch2"]
|
94
94
|
it_should_accept "id", ["--id=1", "--new-name=arch2"]
|
95
|
-
|
96
|
-
|
95
|
+
it_should_accept 'organization', %w[--id=1 --new-name=arch2 --organization-id=1]
|
96
|
+
it_should_accept 'location', %w[--id=1 --new-name=arch2 --location-id=1]
|
97
97
|
# it_should_fail_with "no params", [] # TODO: temporarily disabled, parameters are checked in the id resolver
|
98
98
|
# it_should_fail_with "name or id missing", ["--new-name=arch2"] # TODO: temporarily disabled, parameters are checked in the id resolver
|
99
99
|
end
|
data/test/unit/bookmark_test.rb
CHANGED
@@ -17,8 +17,8 @@ describe HammerCLIForeman::Bookmark do
|
|
17
17
|
|
18
18
|
context 'parameters' do
|
19
19
|
it_should_accept 'no arguments'
|
20
|
-
|
21
|
-
|
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
|
@@ -41,8 +41,8 @@ describe HammerCLIForeman::Bookmark do
|
|
41
41
|
context 'parameters' do
|
42
42
|
it_should_accept 'id', ['--id=1']
|
43
43
|
it_should_accept 'name', ['--name=active']
|
44
|
-
|
45
|
-
|
44
|
+
it_should_accept 'organization', %w[--id=1 --organization-id=1]
|
45
|
+
it_should_accept 'location', %w[--id=1 --location-id=1]
|
46
46
|
end
|
47
47
|
|
48
48
|
context 'output' do
|
@@ -63,11 +63,9 @@ describe HammerCLIForeman::Bookmark do
|
|
63
63
|
let(:cmd) { HammerCLIForeman::Bookmark::CreateCommand.new('', ctx) }
|
64
64
|
|
65
65
|
context 'parameters' do
|
66
|
-
it_should_accept 'name, public, controller, query',
|
67
|
-
['--name=active', '--public=1', '--controller=hosts',
|
66
|
+
it_should_accept 'name, public, controller, query, organization, location',
|
67
|
+
['--name=active', '--public=1', '--controller=hosts', '--organization-id=1', '--location-id=1',
|
68
68
|
'--query=last_report > "35 minutes ago" and (status.applied > 0 or status.restarted > 0)']
|
69
|
-
it_should_fail_with 'organization param', ['--organization-id=1']
|
70
|
-
it_should_fail_with 'location param', ['--location-id=1']
|
71
69
|
end
|
72
70
|
|
73
71
|
end
|
@@ -78,8 +76,8 @@ describe HammerCLIForeman::Bookmark do
|
|
78
76
|
context 'parameters' do
|
79
77
|
it_should_accept 'id', ['--id=1']
|
80
78
|
it_should_accept 'name', ['--name=active']
|
81
|
-
|
82
|
-
|
79
|
+
it_should_accept 'organization', %w[--id=1 --organization-id=1]
|
80
|
+
it_should_accept 'location', %w[--id=1 --location-id=1]
|
83
81
|
end
|
84
82
|
end
|
85
83
|
|
@@ -89,11 +87,9 @@ describe HammerCLIForeman::Bookmark do
|
|
89
87
|
context 'parameters' do
|
90
88
|
it_should_accept 'id', ['--id=1']
|
91
89
|
it_should_accept 'name', ['--name=active']
|
92
|
-
it_should_accept 'name, public, controller, query',
|
93
|
-
['--name=active', '--public=1', '--controller=hosts',
|
90
|
+
it_should_accept 'name, public, controller, query, organization, location',
|
91
|
+
['--name=active', '--public=1', '--controller=hosts', '--organization-id=1', '--location-id=1',
|
94
92
|
'--query=last_report > "35 minutes ago" and (status.applied > 0 or status.restarted > 0)']
|
95
|
-
it_should_fail_with 'organization param', ['--organization-id=1']
|
96
|
-
it_should_fail_with 'location param', ['--location-id=1']
|
97
93
|
end
|
98
94
|
end
|
99
95
|
end
|
@@ -17,8 +17,8 @@ describe HammerCLIForeman::ComputeProfile do
|
|
17
17
|
|
18
18
|
context 'parameters' do
|
19
19
|
it_should_accept 'no arguments'
|
20
|
-
|
21
|
-
|
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::ComputeProfile do
|
|
36
36
|
context 'parameters' do
|
37
37
|
it_should_accept 'id', ['--id=1']
|
38
38
|
it_should_accept 'name', ['--name=test']
|
39
|
-
|
40
|
-
|
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
|
@@ -57,8 +57,8 @@ describe HammerCLIForeman::ComputeProfile do
|
|
57
57
|
|
58
58
|
context 'parameters' do
|
59
59
|
it_should_accept 'name', ['--name=test']
|
60
|
-
|
61
|
-
|
60
|
+
it_should_accept 'organization', %w[--name=test --organization-id=1]
|
61
|
+
it_should_accept 'location', %w[--name=test --location-id=1]
|
62
62
|
end
|
63
63
|
|
64
64
|
end
|
@@ -69,8 +69,8 @@ describe HammerCLIForeman::ComputeProfile do
|
|
69
69
|
context 'parameters' do
|
70
70
|
it_should_accept 'id', ['--id=1']
|
71
71
|
it_should_accept 'name', ['--name=test']
|
72
|
-
|
73
|
-
|
72
|
+
it_should_accept 'organization', %w[--id=1 --organization-id=1]
|
73
|
+
it_should_accept 'location', %w[--id=1 --location-id=1]
|
74
74
|
end
|
75
75
|
end
|
76
76
|
|
@@ -80,8 +80,8 @@ describe HammerCLIForeman::ComputeProfile do
|
|
80
80
|
context 'parameters' do
|
81
81
|
it_should_accept 'id', ['--id=1']
|
82
82
|
it_should_accept 'name', ['--name=test']
|
83
|
-
|
84
|
-
|
83
|
+
it_should_accept 'organization', %w[--id=1 --organization-id=1]
|
84
|
+
it_should_accept 'location', %w[--id=1 --location-id=1]
|
85
85
|
end
|
86
86
|
end
|
87
87
|
end
|