hammer_cli_foreman 2.5.1 → 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 -1
  3. data/lib/hammer_cli_foreman.rb +0 -21
  4. data/lib/hammer_cli_foreman/architecture.rb +5 -5
  5. data/lib/hammer_cli_foreman/associating_commands.rb +0 -24
  6. data/lib/hammer_cli_foreman/bookmark.rb +5 -5
  7. data/lib/hammer_cli_foreman/combination.rb +3 -13
  8. data/lib/hammer_cli_foreman/command_extensions.rb +0 -2
  9. data/lib/hammer_cli_foreman/commands.rb +2 -9
  10. data/lib/hammer_cli_foreman/compute_profile.rb +5 -5
  11. data/lib/hammer_cli_foreman/host.rb +0 -35
  12. data/lib/hammer_cli_foreman/hostgroup.rb +2 -53
  13. data/lib/hammer_cli_foreman/hosts/common_update_options.rb +1 -23
  14. data/lib/hammer_cli_foreman/id_resolver.rb +0 -61
  15. data/lib/hammer_cli_foreman/location.rb +0 -6
  16. data/lib/hammer_cli_foreman/mail_notification.rb +2 -2
  17. data/lib/hammer_cli_foreman/model.rb +5 -5
  18. data/lib/hammer_cli_foreman/operating_system.rb +10 -10
  19. data/lib/hammer_cli_foreman/option_sources.rb +0 -1
  20. data/lib/hammer_cli_foreman/option_sources/id_params.rb +27 -10
  21. data/lib/hammer_cli_foreman/option_sources/ids_params.rb +25 -6
  22. data/lib/hammer_cli_foreman/organization.rb +0 -6
  23. data/lib/hammer_cli_foreman/references.rb +0 -16
  24. data/lib/hammer_cli_foreman/settings.rb +3 -3
  25. data/lib/hammer_cli_foreman/smart_proxy.rb +0 -52
  26. data/lib/hammer_cli_foreman/usergroup.rb +5 -5
  27. data/lib/hammer_cli_foreman/version.rb +1 -1
  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 +64 -85
  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
@@ -112,14 +112,6 @@ module HammerCLIForeman
112
112
  end
113
113
  end
114
114
 
115
- def self.environments(dsl)
116
- dsl.build do
117
- collection :environments, _("Environments"), :numbered => false do
118
- custom_field Fields::Reference
119
- end
120
- end
121
- end
122
-
123
115
  def self.hostgroups(dsl)
124
116
  dsl.build do
125
117
  collection :hostgroups, _("Hostgroups"), :numbered => false do
@@ -153,14 +145,6 @@ module HammerCLIForeman
153
145
  end
154
146
  end
155
147
 
156
- def self.puppetclasses(dsl)
157
- dsl.build do
158
- collection :puppetclasses, _("Puppetclasses"), :numbered => false do
159
- custom_field Fields::Reference
160
- end
161
- end
162
- end
163
-
164
148
  def self.operating_systems(dsl)
165
149
  dsl.build do
166
150
  collection :operatingsystems, _("Operating systems"), :numbered => false do
@@ -20,7 +20,7 @@ module HammerCLIForeman
20
20
  data
21
21
  end
22
22
 
23
- build_options expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
23
+ build_options
24
24
  end
25
25
 
26
26
  class UpdateCommand < HammerCLIForeman::UpdateCommand
@@ -29,7 +29,7 @@ module HammerCLIForeman
29
29
  success_message _("Setting [%{name}] updated to [%{value}].")
30
30
  failure_message _("Could not update the setting")
31
31
 
32
- build_options expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
32
+ build_options
33
33
  end
34
34
 
35
35
  class InfoCommand < HammerCLIForeman::InfoCommand
@@ -42,7 +42,7 @@ module HammerCLIForeman
42
42
  field :value, _("Value")
43
43
  end
44
44
 
45
- build_options expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
45
+ build_options
46
46
  end
47
47
 
48
48
 
@@ -60,58 +60,6 @@ module HammerCLIForeman
60
60
  build_options
61
61
  end
62
62
 
63
-
64
- class ImportPuppetClassesCommand < HammerCLIForeman::Command
65
- action :import_puppetclasses
66
-
67
- command_name "import-classes"
68
-
69
- option "--dryrun", :flag, _("Do not run the import")
70
-
71
- output do
72
- field :message, _("Result"), Fields::LongText
73
- collection :results, _("Changed environments"), :hide_blank => true do
74
- field :name, nil
75
- collection :new_puppetclasses, _("New classes"), :hide_blank => true, :numbered => false do
76
- field nil, nil
77
- end
78
- collection :updated_puppetclasses, _("Updated classes"), :hide_blank => true, :numbered => false do
79
- field nil, nil
80
- end
81
- collection :obsolete_puppetclasses, _("Removed classes"), :hide_blank => true, :numbered => false do
82
- field nil, nil
83
- end
84
- collection :ignored_puppetclasses, _("Ignored classes"), :hide_blank => true, :numbered => false do
85
- field nil, nil
86
- end
87
- end
88
- end
89
-
90
- build_options do |o|
91
- o.without(:smart_proxy_id, :dryrun)
92
- o.expand.except(:smart_proxies)
93
- end
94
-
95
- def request_params
96
- opts = super
97
- opts['dryrun'] = option_dryrun? || false
98
- opts
99
- end
100
-
101
- def transform_format(data)
102
- # Overriding the default behavior that tries to remove nesting
103
- # when there's only {"message": "..."}
104
- data
105
- end
106
-
107
- def print_data(record)
108
- print_record(output_definition, record)
109
- end
110
-
111
- extend_with(HammerCLIForeman::CommandExtensions::PuppetEnvironment.new)
112
- end
113
-
114
-
115
63
  class RefreshFeaturesCommand < HammerCLIForeman::Command
116
64
 
117
65
  action :refresh
@@ -13,7 +13,7 @@ module HammerCLIForeman
13
13
  field :admin, _("Admin"), Fields::Boolean
14
14
  end
15
15
 
16
- build_options expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
16
+ build_options
17
17
  end
18
18
 
19
19
  class InfoCommand < HammerCLIForeman::InfoCommand
@@ -25,28 +25,28 @@ module HammerCLIForeman
25
25
  HammerCLIForeman::References.timestamps(self)
26
26
  end
27
27
 
28
- build_options expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
28
+ build_options
29
29
  end
30
30
 
31
31
  class CreateCommand < HammerCLIForeman::CreateCommand
32
32
  success_message _("User group [%<name>s] created.")
33
33
  failure_message _("Could not create the user group")
34
34
 
35
- build_options expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
35
+ build_options
36
36
  end
37
37
 
38
38
  class UpdateCommand < HammerCLIForeman::UpdateCommand
39
39
  success_message _("User group [%<name>s] updated.")
40
40
  failure_message _("Could not update the user group")
41
41
 
42
- build_options expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
42
+ build_options
43
43
  end
44
44
 
45
45
  class DeleteCommand < HammerCLIForeman::DeleteCommand
46
46
  success_message _("User group [%<name>s] deleted.")
47
47
  failure_message _("Could not delete the user group")
48
48
 
49
- build_options expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
49
+ build_options
50
50
  end
51
51
 
52
52
  HammerCLIForeman::AssociatingCommands::Role.extend_command(self)
@@ -1,5 +1,5 @@
1
1
  module HammerCLIForeman
2
2
  def self.version
3
- @version ||= Gem::Version.new "2.5.1"
3
+ @version ||= Gem::Version.new "3.0.0"
4
4
  end
5
5
  end
@@ -3,7 +3,7 @@ require "json"
3
3
  module Minitest
4
4
  class CoverageRunner
5
5
 
6
- RESOURCE_BLACK_LIST = ['tasks','home','config_groups','statistics','table_preferences','autosign','puppet_hosts']
6
+ RESOURCE_BLACK_LIST = ['tasks','home','statistics','table_preferences','autosign']
7
7
  attr_reader :raw_data, :api_endpoints, :covered_resources, :uncovered_resources, :partially_covered_resources
8
8
  def initialize(file_path)
9
9
  @raw_data = JSON.load(File.open(file_path))
@@ -7,9 +7,9 @@ describe 'architecture' do
7
7
  before do
8
8
  @cmd = %w[architecture list]
9
9
  @architectures = [{
10
- id: 1,
11
- name: 'i386',
12
- }]
10
+ id: 1,
11
+ name: 'i386'
12
+ }]
13
13
  end
14
14
 
15
15
  it 'should return a list of architectures' do
@@ -26,7 +26,7 @@ describe 'architecture' 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.1')) }
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 'architecture' 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(:architectures, :index, 'List architectures').returns(@architectures)
43
45
 
44
46
  result = run_cmd(@cmd, { use_defaults: true, defaults: defaults })
@@ -29,7 +29,7 @@ describe 'bookmark' do
29
29
  end
30
30
 
31
31
  it 'should run list command with defaults' do
32
- providers = { 'foreman' => HammerCLIForeman::Defaults.new(api_connection({}, '2.1')) }
32
+ providers = { 'foreman' => HammerCLIForeman::Defaults.new(api_connection({}, '2.5')) }
33
33
  defaults = HammerCLI::Defaults.new(
34
34
  {
35
35
  organization_id: {
@@ -42,6 +42,8 @@ describe 'bookmark' do
42
42
  )
43
43
  defaults.stubs(:write_to_file).returns(true)
44
44
  defaults.stubs(:providers).returns(providers)
45
+ api_expects(:users, :index, 'Find user').with_params(search: 'login=admin').returns(index_response([{ 'default_organization' => { 'id' => 2 } }]))
46
+ api_expects(:users, :index, 'Find user').with_params(search: 'login=admin').returns(index_response([{ 'default_location' => { 'id' => 1 } }]))
45
47
  api_expects(:bookmarks, :index, 'List bookmarks').returns(@bookmarks)
46
48
 
47
49
  result = run_cmd(@cmd, { use_defaults: true, defaults: defaults })
@@ -132,7 +132,7 @@ describe "parameters" do
132
132
  end
133
133
 
134
134
  it 'should run list command with defaults' do
135
- providers = { 'foreman' => HammerCLIForeman::Defaults.new(api_connection({}, '2.1')) }
135
+ providers = { 'foreman' => HammerCLIForeman::Defaults.new(api_connection({}, '2.5')) }
136
136
  defaults = HammerCLI::Defaults.new(
137
137
  {
138
138
  organization_id: {
@@ -145,6 +145,8 @@ describe "parameters" do
145
145
  )
146
146
  defaults.stubs(:write_to_file).returns(true)
147
147
  defaults.stubs(:providers).returns(providers)
148
+ api_expects(:users, :index, 'Find user').with_params(search: 'login=admin').returns(index_response([{ 'default_organization' => { 'id' => 2 } }]))
149
+ api_expects(:users, :index, 'Find user').with_params(search: 'login=admin').returns(index_response([{ 'default_location' => { 'id' => 1 } }]))
148
150
  api_expects(:compute_profiles, :index, 'List compute profiles').returns(@compute_profiles)
149
151
 
150
152
  result = run_cmd(@cmd, { use_defaults: true, defaults: defaults })
@@ -356,7 +356,6 @@ describe 'host update' do
356
356
  'organization_id' => '5',
357
357
  'location_id' => '5',
358
358
  'compute_attributes' => {},
359
- 'puppetclass_ids' => [],
360
359
  'owner_id' => '1',
361
360
  'owner_name' => 'adminGroup',
362
361
  'owner_type' => 'Usergroup'
@@ -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 &&