cheffish 1.4.1 → 1.4.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +201 -201
  3. data/README.md +120 -120
  4. data/Rakefile +23 -23
  5. data/lib/chef/provider/chef_acl.rb +439 -439
  6. data/lib/chef/provider/chef_client.rb +53 -53
  7. data/lib/chef/provider/chef_container.rb +55 -55
  8. data/lib/chef/provider/chef_data_bag.rb +55 -55
  9. data/lib/chef/provider/chef_data_bag_item.rb +278 -278
  10. data/lib/chef/provider/chef_environment.rb +83 -83
  11. data/lib/chef/provider/chef_group.rb +83 -83
  12. data/lib/chef/provider/chef_mirror.rb +169 -169
  13. data/lib/chef/provider/chef_node.rb +87 -87
  14. data/lib/chef/provider/chef_organization.rb +155 -155
  15. data/lib/chef/provider/chef_resolved_cookbooks.rb +46 -46
  16. data/lib/chef/provider/chef_role.rb +84 -84
  17. data/lib/chef/provider/chef_user.rb +59 -59
  18. data/lib/chef/provider/private_key.rb +225 -225
  19. data/lib/chef/provider/public_key.rb +88 -88
  20. data/lib/chef/resource/chef_acl.rb +69 -69
  21. data/lib/chef/resource/chef_client.rb +48 -48
  22. data/lib/chef/resource/chef_container.rb +22 -22
  23. data/lib/chef/resource/chef_data_bag.rb +22 -22
  24. data/lib/chef/resource/chef_data_bag_item.rb +121 -121
  25. data/lib/chef/resource/chef_environment.rb +77 -77
  26. data/lib/chef/resource/chef_group.rb +53 -53
  27. data/lib/chef/resource/chef_mirror.rb +52 -52
  28. data/lib/chef/resource/chef_node.rb +22 -22
  29. data/lib/chef/resource/chef_organization.rb +69 -69
  30. data/lib/chef/resource/chef_resolved_cookbooks.rb +35 -35
  31. data/lib/chef/resource/chef_role.rb +110 -110
  32. data/lib/chef/resource/chef_user.rb +56 -56
  33. data/lib/chef/resource/private_key.rb +48 -48
  34. data/lib/chef/resource/public_key.rb +25 -25
  35. data/lib/cheffish/actor_provider_base.rb +131 -131
  36. data/lib/cheffish/basic_chef_client.rb +184 -184
  37. data/lib/cheffish/chef_provider_base.rb +246 -246
  38. data/lib/cheffish/chef_run.rb +162 -162
  39. data/lib/cheffish/chef_run_data.rb +19 -19
  40. data/lib/cheffish/chef_run_listener.rb +30 -30
  41. data/lib/cheffish/key_formatter.rb +113 -113
  42. data/lib/cheffish/merged_config.rb +94 -94
  43. data/lib/cheffish/recipe_dsl.rb +157 -157
  44. data/lib/cheffish/rspec/chef_run_support.rb +83 -83
  45. data/lib/cheffish/rspec/matchers/be_idempotent.rb +16 -16
  46. data/lib/cheffish/rspec/matchers/emit_no_warnings_or_errors.rb +15 -15
  47. data/lib/cheffish/rspec/matchers/have_updated.rb +37 -37
  48. data/lib/cheffish/rspec/matchers/partially_match.rb +63 -63
  49. data/lib/cheffish/rspec/matchers.rb +4 -4
  50. data/lib/cheffish/rspec/recipe_run_wrapper.rb +78 -59
  51. data/lib/cheffish/rspec/repository_support.rb +108 -108
  52. data/lib/cheffish/rspec.rb +8 -8
  53. data/lib/cheffish/server_api.rb +52 -52
  54. data/lib/cheffish/version.rb +3 -3
  55. data/lib/cheffish/with_pattern.rb +21 -21
  56. data/lib/cheffish.rb +235 -235
  57. data/spec/functional/fingerprint_spec.rb +64 -64
  58. data/spec/functional/merged_config_spec.rb +19 -19
  59. data/spec/functional/server_api_spec.rb +13 -13
  60. data/spec/integration/chef_acl_spec.rb +879 -879
  61. data/spec/integration/chef_client_spec.rb +105 -105
  62. data/spec/integration/chef_container_spec.rb +33 -33
  63. data/spec/integration/chef_group_spec.rb +309 -309
  64. data/spec/integration/chef_mirror_spec.rb +491 -491
  65. data/spec/integration/chef_node_spec.rb +786 -786
  66. data/spec/integration/chef_organization_spec.rb +226 -226
  67. data/spec/integration/chef_role_spec.rb +78 -78
  68. data/spec/integration/chef_user_spec.rb +85 -85
  69. data/spec/integration/private_key_spec.rb +399 -399
  70. data/spec/integration/recipe_dsl_spec.rb +28 -28
  71. data/spec/integration/rspec/converge_spec.rb +183 -183
  72. data/spec/support/key_support.rb +29 -29
  73. data/spec/support/spec_support.rb +15 -15
  74. data/spec/unit/get_private_key_spec.rb +131 -131
  75. data/spec/unit/recipe_run_wrapper_spec.rb +37 -37
  76. metadata +3 -2
@@ -1,309 +1,309 @@
1
- require 'support/spec_support'
2
- require 'cheffish/rspec/chef_run_support'
3
- require 'chef/resource/chef_group'
4
- require 'chef/provider/chef_group'
5
-
6
- describe Chef::Resource::ChefGroup do
7
- extend Cheffish::RSpec::ChefRunSupport
8
-
9
- when_the_chef_12_server 'is in multi-org mode' do
10
- organization 'foo'
11
-
12
- before :each do
13
- Chef::Config.chef_server_url = URI.join(Chef::Config.chef_server_url, '/organizations/foo').to_s
14
- end
15
-
16
- context 'and is empty' do
17
- group 'g', {}
18
- user 'u', {}
19
- client 'c', {}
20
-
21
- it 'Converging chef_group "x" creates the group with no members' do
22
- expect_recipe {
23
- chef_group 'x'
24
- }.to have_updated('chef_group[x]', :create)
25
- expect(get('groups/x')).to eq({
26
- 'name' => 'x',
27
- 'groupname' => 'x',
28
- 'orgname' => 'foo',
29
- 'actors' => [],
30
- 'groups' => [],
31
- 'users' => [],
32
- 'clients' => []
33
- })
34
- end
35
-
36
- it 'chef_group "x" action :delete does nothing' do
37
- expect_recipe {
38
- chef_group 'x' do
39
- action :delete
40
- end
41
- }.to not_have_updated('chef_group[x]', :delete).and not_have_updated('chef_group[x]', :create)
42
- expect { get('groups/x') }.to raise_error(Net::HTTPServerException)
43
- end
44
-
45
- it 'Converging chef_group "x" creates the group with the given members' do
46
- expect_recipe {
47
- chef_group 'x' do
48
- groups 'g'
49
- users 'u'
50
- clients 'c'
51
- end
52
- }.to have_updated('chef_group[x]', :create)
53
- expect(get('groups/x')).to eq({
54
- 'name' => 'x',
55
- 'groupname' => 'x',
56
- 'orgname' => 'foo',
57
- 'actors' => %w(c u),
58
- 'groups' => %w(g),
59
- 'users' => %w(u),
60
- 'clients' => %w(c)
61
- })
62
- end
63
- end
64
-
65
- context 'and has a group named x' do
66
- group 'g', {}
67
- group 'g2', {}
68
- group 'g3', {}
69
- group 'g4', {}
70
- user 'u', {}
71
- user 'u2', {}
72
- user 'u3', {}
73
- user 'u4', {}
74
- client 'c', {}
75
- client 'c2', {}
76
- client 'c3', {}
77
- client 'c4', {}
78
-
79
- group 'x', {
80
- 'users' => %w(u u2),
81
- 'clients' => %w(c c2),
82
- 'groups' => %w(g g2)
83
- }
84
-
85
- it 'Converging chef_group "x" changes nothing' do
86
- expect_recipe {
87
- chef_group 'x'
88
- }.not_to have_updated('chef_group[x]', :create)
89
- expect(get('groups/x')).to eq({
90
- 'name' => 'x',
91
- 'groupname' => 'x',
92
- 'orgname' => 'foo',
93
- 'actors' => %w(c c2 u u2),
94
- 'groups' => %w(g g2),
95
- 'users' => %w(u u2),
96
- 'clients' => %w(c c2)
97
- })
98
- end
99
-
100
- it 'chef_group "x" action :delete deletes the group' do
101
- expect_recipe {
102
- chef_group 'x' do
103
- action :delete
104
- end
105
- }.to have_updated('chef_group[x]', :delete)
106
- expect { get('groups/x') }.to raise_error(Net::HTTPServerException)
107
- end
108
-
109
- it 'Converging chef_group "x" with existing users changes nothing' do
110
- expect_recipe {
111
- chef_group 'x' do
112
- users 'u'
113
- clients 'c'
114
- groups 'g'
115
- end
116
- }.not_to have_updated('chef_group[x]', :create)
117
- expect(get('groups/x')).to eq({
118
- 'name' => 'x',
119
- 'groupname' => 'x',
120
- 'orgname' => 'foo',
121
- 'actors' => %w(c c2 u u2),
122
- 'groups' => %w(g g2),
123
- 'users' => %w(u u2),
124
- 'clients' => %w(c c2)
125
- })
126
- end
127
-
128
- it 'Converging chef_group "x" adds new users' do
129
- expect_recipe {
130
- chef_group 'x' do
131
- users 'u3'
132
- clients 'c3'
133
- groups 'g3'
134
- end
135
- }.to have_updated('chef_group[x]', :create)
136
- expect(get('groups/x')).to eq({
137
- 'name' => 'x',
138
- 'groupname' => 'x',
139
- 'orgname' => 'foo',
140
- 'actors' => %w(c c2 c3 u u2 u3),
141
- 'groups' => %w(g g2 g3),
142
- 'users' => %w(u u2 u3),
143
- 'clients' => %w(c c2 c3)
144
- })
145
- end
146
-
147
- it 'Converging chef_group "x" with multiple users adds new users' do
148
- expect_recipe {
149
- chef_group 'x' do
150
- users 'u3', 'u4'
151
- clients 'c3', 'c4'
152
- groups 'g3', 'g4'
153
- end
154
- }.to have_updated('chef_group[x]', :create)
155
- expect(get('groups/x')).to eq({
156
- 'name' => 'x',
157
- 'groupname' => 'x',
158
- 'orgname' => 'foo',
159
- 'actors' => %w(c c2 c3 c4 u u2 u3 u4),
160
- 'groups' => %w(g g2 g3 g4),
161
- 'users' => %w(u u2 u3 u4),
162
- 'clients' => %w(c c2 c3 c4)
163
- })
164
- end
165
-
166
- it 'Converging chef_group "x" with multiple users in an array adds new users' do
167
- expect_recipe {
168
- chef_group 'x' do
169
- users [ 'u3', 'u4' ]
170
- clients [ 'c3', 'c4' ]
171
- groups [ 'g3', 'g4' ]
172
- end
173
- }.to have_updated('chef_group[x]', :create)
174
- expect(get('groups/x')).to eq({
175
- 'name' => 'x',
176
- 'groupname' => 'x',
177
- 'orgname' => 'foo',
178
- 'actors' => %w(c c2 c3 c4 u u2 u3 u4),
179
- 'groups' => %w(g g2 g3 g4),
180
- 'users' => %w(u u2 u3 u4),
181
- 'clients' => %w(c c2 c3 c4)
182
- })
183
- end
184
-
185
- it 'Converging chef_group "x" with multiple users declarations adds new users' do
186
- expect_recipe {
187
- chef_group 'x' do
188
- users 'u3'
189
- users 'u4'
190
- clients 'c3'
191
- clients 'c4'
192
- groups 'g3'
193
- groups 'g4'
194
- end
195
- }.to have_updated('chef_group[x]', :create)
196
- expect(get('groups/x')).to eq({
197
- 'name' => 'x',
198
- 'groupname' => 'x',
199
- 'orgname' => 'foo',
200
- 'actors' => %w(c c2 c3 c4 u u2 u3 u4),
201
- 'groups' => %w(g g2 g3 g4),
202
- 'users' => %w(u u2 u3 u4),
203
- 'clients' => %w(c c2 c3 c4)
204
- })
205
- end
206
-
207
- it 'Converging chef_group "x" removes desired users' do
208
- expect_recipe {
209
- chef_group 'x' do
210
- remove_users 'u2'
211
- remove_clients 'c2'
212
- remove_groups 'g2'
213
- end
214
- }.to have_updated('chef_group[x]', :create)
215
- expect(get('groups/x')).to eq({
216
- 'name' => 'x',
217
- 'groupname' => 'x',
218
- 'orgname' => 'foo',
219
- 'actors' => %w(c u),
220
- 'groups' => %w(g),
221
- 'users' => %w(u),
222
- 'clients' => %w(c)
223
- })
224
- end
225
-
226
- it 'Converging chef_group "x" with multiple users removes desired users' do
227
- expect_recipe {
228
- chef_group 'x' do
229
- remove_users 'u', 'u2'
230
- remove_clients 'c', 'c2'
231
- remove_groups 'g', 'g2'
232
- end
233
- }.to have_updated('chef_group[x]', :create)
234
- expect(get('groups/x')).to eq({
235
- 'name' => 'x',
236
- 'groupname' => 'x',
237
- 'orgname' => 'foo',
238
- 'actors' => [],
239
- 'groups' => [],
240
- 'users' => [],
241
- 'clients' => []
242
- })
243
- end
244
-
245
- it 'Converging chef_group "x" with multiple users in an array removes desired users' do
246
- expect_recipe {
247
- chef_group 'x' do
248
- remove_users [ 'u', 'u2' ]
249
- remove_clients [ 'c', 'c2' ]
250
- remove_groups [ 'g', 'g2' ]
251
- end
252
- }.to have_updated('chef_group[x]', :create)
253
- expect(get('groups/x')).to eq({
254
- 'name' => 'x',
255
- 'groupname' => 'x',
256
- 'orgname' => 'foo',
257
- 'actors' => [],
258
- 'groups' => [],
259
- 'users' => [],
260
- 'clients' => []
261
- })
262
- end
263
-
264
- it 'Converging chef_group "x" with multiple remove_ declarations removes desired users' do
265
- expect_recipe {
266
- chef_group 'x' do
267
- remove_users 'u'
268
- remove_users 'u2'
269
- remove_clients 'c'
270
- remove_clients 'c2'
271
- remove_groups 'g'
272
- remove_groups 'g2'
273
- end
274
- }.to have_updated('chef_group[x]', :create)
275
- expect(get('groups/x')).to eq({
276
- 'name' => 'x',
277
- 'groupname' => 'x',
278
- 'orgname' => 'foo',
279
- 'actors' => [],
280
- 'groups' => [],
281
- 'users' => [],
282
- 'clients' => []
283
- })
284
- end
285
-
286
- it 'Converging chef_group "x" adds and removes desired users' do
287
- expect_recipe {
288
- chef_group 'x' do
289
- users 'u3'
290
- clients 'c3'
291
- groups 'g3'
292
- remove_users 'u'
293
- remove_clients 'c'
294
- remove_groups 'g'
295
- end
296
- }.to have_updated('chef_group[x]', :create)
297
- expect(get('groups/x')).to eq({
298
- 'name' => 'x',
299
- 'groupname' => 'x',
300
- 'orgname' => 'foo',
301
- 'actors' => %w(c2 c3 u2 u3),
302
- 'groups' => %w(g2 g3),
303
- 'users' => %w(u2 u3),
304
- 'clients' => %w(c2 c3)
305
- })
306
- end
307
- end
308
- end
309
- end
1
+ require 'support/spec_support'
2
+ require 'cheffish/rspec/chef_run_support'
3
+ require 'chef/resource/chef_group'
4
+ require 'chef/provider/chef_group'
5
+
6
+ describe Chef::Resource::ChefGroup do
7
+ extend Cheffish::RSpec::ChefRunSupport
8
+
9
+ when_the_chef_12_server 'is in multi-org mode' do
10
+ organization 'foo'
11
+
12
+ before :each do
13
+ Chef::Config.chef_server_url = URI.join(Chef::Config.chef_server_url, '/organizations/foo').to_s
14
+ end
15
+
16
+ context 'and is empty' do
17
+ group 'g', {}
18
+ user 'u', {}
19
+ client 'c', {}
20
+
21
+ it 'Converging chef_group "x" creates the group with no members' do
22
+ expect_recipe {
23
+ chef_group 'x'
24
+ }.to have_updated('chef_group[x]', :create)
25
+ expect(get('groups/x')).to eq({
26
+ 'name' => 'x',
27
+ 'groupname' => 'x',
28
+ 'orgname' => 'foo',
29
+ 'actors' => [],
30
+ 'groups' => [],
31
+ 'users' => [],
32
+ 'clients' => []
33
+ })
34
+ end
35
+
36
+ it 'chef_group "x" action :delete does nothing' do
37
+ expect_recipe {
38
+ chef_group 'x' do
39
+ action :delete
40
+ end
41
+ }.to not_have_updated('chef_group[x]', :delete).and not_have_updated('chef_group[x]', :create)
42
+ expect { get('groups/x') }.to raise_error(Net::HTTPServerException)
43
+ end
44
+
45
+ it 'Converging chef_group "x" creates the group with the given members' do
46
+ expect_recipe {
47
+ chef_group 'x' do
48
+ groups 'g'
49
+ users 'u'
50
+ clients 'c'
51
+ end
52
+ }.to have_updated('chef_group[x]', :create)
53
+ expect(get('groups/x')).to eq({
54
+ 'name' => 'x',
55
+ 'groupname' => 'x',
56
+ 'orgname' => 'foo',
57
+ 'actors' => %w(c u),
58
+ 'groups' => %w(g),
59
+ 'users' => %w(u),
60
+ 'clients' => %w(c)
61
+ })
62
+ end
63
+ end
64
+
65
+ context 'and has a group named x' do
66
+ group 'g', {}
67
+ group 'g2', {}
68
+ group 'g3', {}
69
+ group 'g4', {}
70
+ user 'u', {}
71
+ user 'u2', {}
72
+ user 'u3', {}
73
+ user 'u4', {}
74
+ client 'c', {}
75
+ client 'c2', {}
76
+ client 'c3', {}
77
+ client 'c4', {}
78
+
79
+ group 'x', {
80
+ 'users' => %w(u u2),
81
+ 'clients' => %w(c c2),
82
+ 'groups' => %w(g g2)
83
+ }
84
+
85
+ it 'Converging chef_group "x" changes nothing' do
86
+ expect_recipe {
87
+ chef_group 'x'
88
+ }.not_to have_updated('chef_group[x]', :create)
89
+ expect(get('groups/x')).to eq({
90
+ 'name' => 'x',
91
+ 'groupname' => 'x',
92
+ 'orgname' => 'foo',
93
+ 'actors' => %w(c c2 u u2),
94
+ 'groups' => %w(g g2),
95
+ 'users' => %w(u u2),
96
+ 'clients' => %w(c c2)
97
+ })
98
+ end
99
+
100
+ it 'chef_group "x" action :delete deletes the group' do
101
+ expect_recipe {
102
+ chef_group 'x' do
103
+ action :delete
104
+ end
105
+ }.to have_updated('chef_group[x]', :delete)
106
+ expect { get('groups/x') }.to raise_error(Net::HTTPServerException)
107
+ end
108
+
109
+ it 'Converging chef_group "x" with existing users changes nothing' do
110
+ expect_recipe {
111
+ chef_group 'x' do
112
+ users 'u'
113
+ clients 'c'
114
+ groups 'g'
115
+ end
116
+ }.not_to have_updated('chef_group[x]', :create)
117
+ expect(get('groups/x')).to eq({
118
+ 'name' => 'x',
119
+ 'groupname' => 'x',
120
+ 'orgname' => 'foo',
121
+ 'actors' => %w(c c2 u u2),
122
+ 'groups' => %w(g g2),
123
+ 'users' => %w(u u2),
124
+ 'clients' => %w(c c2)
125
+ })
126
+ end
127
+
128
+ it 'Converging chef_group "x" adds new users' do
129
+ expect_recipe {
130
+ chef_group 'x' do
131
+ users 'u3'
132
+ clients 'c3'
133
+ groups 'g3'
134
+ end
135
+ }.to have_updated('chef_group[x]', :create)
136
+ expect(get('groups/x')).to eq({
137
+ 'name' => 'x',
138
+ 'groupname' => 'x',
139
+ 'orgname' => 'foo',
140
+ 'actors' => %w(c c2 c3 u u2 u3),
141
+ 'groups' => %w(g g2 g3),
142
+ 'users' => %w(u u2 u3),
143
+ 'clients' => %w(c c2 c3)
144
+ })
145
+ end
146
+
147
+ it 'Converging chef_group "x" with multiple users adds new users' do
148
+ expect_recipe {
149
+ chef_group 'x' do
150
+ users 'u3', 'u4'
151
+ clients 'c3', 'c4'
152
+ groups 'g3', 'g4'
153
+ end
154
+ }.to have_updated('chef_group[x]', :create)
155
+ expect(get('groups/x')).to eq({
156
+ 'name' => 'x',
157
+ 'groupname' => 'x',
158
+ 'orgname' => 'foo',
159
+ 'actors' => %w(c c2 c3 c4 u u2 u3 u4),
160
+ 'groups' => %w(g g2 g3 g4),
161
+ 'users' => %w(u u2 u3 u4),
162
+ 'clients' => %w(c c2 c3 c4)
163
+ })
164
+ end
165
+
166
+ it 'Converging chef_group "x" with multiple users in an array adds new users' do
167
+ expect_recipe {
168
+ chef_group 'x' do
169
+ users [ 'u3', 'u4' ]
170
+ clients [ 'c3', 'c4' ]
171
+ groups [ 'g3', 'g4' ]
172
+ end
173
+ }.to have_updated('chef_group[x]', :create)
174
+ expect(get('groups/x')).to eq({
175
+ 'name' => 'x',
176
+ 'groupname' => 'x',
177
+ 'orgname' => 'foo',
178
+ 'actors' => %w(c c2 c3 c4 u u2 u3 u4),
179
+ 'groups' => %w(g g2 g3 g4),
180
+ 'users' => %w(u u2 u3 u4),
181
+ 'clients' => %w(c c2 c3 c4)
182
+ })
183
+ end
184
+
185
+ it 'Converging chef_group "x" with multiple users declarations adds new users' do
186
+ expect_recipe {
187
+ chef_group 'x' do
188
+ users 'u3'
189
+ users 'u4'
190
+ clients 'c3'
191
+ clients 'c4'
192
+ groups 'g3'
193
+ groups 'g4'
194
+ end
195
+ }.to have_updated('chef_group[x]', :create)
196
+ expect(get('groups/x')).to eq({
197
+ 'name' => 'x',
198
+ 'groupname' => 'x',
199
+ 'orgname' => 'foo',
200
+ 'actors' => %w(c c2 c3 c4 u u2 u3 u4),
201
+ 'groups' => %w(g g2 g3 g4),
202
+ 'users' => %w(u u2 u3 u4),
203
+ 'clients' => %w(c c2 c3 c4)
204
+ })
205
+ end
206
+
207
+ it 'Converging chef_group "x" removes desired users' do
208
+ expect_recipe {
209
+ chef_group 'x' do
210
+ remove_users 'u2'
211
+ remove_clients 'c2'
212
+ remove_groups 'g2'
213
+ end
214
+ }.to have_updated('chef_group[x]', :create)
215
+ expect(get('groups/x')).to eq({
216
+ 'name' => 'x',
217
+ 'groupname' => 'x',
218
+ 'orgname' => 'foo',
219
+ 'actors' => %w(c u),
220
+ 'groups' => %w(g),
221
+ 'users' => %w(u),
222
+ 'clients' => %w(c)
223
+ })
224
+ end
225
+
226
+ it 'Converging chef_group "x" with multiple users removes desired users' do
227
+ expect_recipe {
228
+ chef_group 'x' do
229
+ remove_users 'u', 'u2'
230
+ remove_clients 'c', 'c2'
231
+ remove_groups 'g', 'g2'
232
+ end
233
+ }.to have_updated('chef_group[x]', :create)
234
+ expect(get('groups/x')).to eq({
235
+ 'name' => 'x',
236
+ 'groupname' => 'x',
237
+ 'orgname' => 'foo',
238
+ 'actors' => [],
239
+ 'groups' => [],
240
+ 'users' => [],
241
+ 'clients' => []
242
+ })
243
+ end
244
+
245
+ it 'Converging chef_group "x" with multiple users in an array removes desired users' do
246
+ expect_recipe {
247
+ chef_group 'x' do
248
+ remove_users [ 'u', 'u2' ]
249
+ remove_clients [ 'c', 'c2' ]
250
+ remove_groups [ 'g', 'g2' ]
251
+ end
252
+ }.to have_updated('chef_group[x]', :create)
253
+ expect(get('groups/x')).to eq({
254
+ 'name' => 'x',
255
+ 'groupname' => 'x',
256
+ 'orgname' => 'foo',
257
+ 'actors' => [],
258
+ 'groups' => [],
259
+ 'users' => [],
260
+ 'clients' => []
261
+ })
262
+ end
263
+
264
+ it 'Converging chef_group "x" with multiple remove_ declarations removes desired users' do
265
+ expect_recipe {
266
+ chef_group 'x' do
267
+ remove_users 'u'
268
+ remove_users 'u2'
269
+ remove_clients 'c'
270
+ remove_clients 'c2'
271
+ remove_groups 'g'
272
+ remove_groups 'g2'
273
+ end
274
+ }.to have_updated('chef_group[x]', :create)
275
+ expect(get('groups/x')).to eq({
276
+ 'name' => 'x',
277
+ 'groupname' => 'x',
278
+ 'orgname' => 'foo',
279
+ 'actors' => [],
280
+ 'groups' => [],
281
+ 'users' => [],
282
+ 'clients' => []
283
+ })
284
+ end
285
+
286
+ it 'Converging chef_group "x" adds and removes desired users' do
287
+ expect_recipe {
288
+ chef_group 'x' do
289
+ users 'u3'
290
+ clients 'c3'
291
+ groups 'g3'
292
+ remove_users 'u'
293
+ remove_clients 'c'
294
+ remove_groups 'g'
295
+ end
296
+ }.to have_updated('chef_group[x]', :create)
297
+ expect(get('groups/x')).to eq({
298
+ 'name' => 'x',
299
+ 'groupname' => 'x',
300
+ 'orgname' => 'foo',
301
+ 'actors' => %w(c2 c3 u2 u3),
302
+ 'groups' => %w(g2 g3),
303
+ 'users' => %w(u2 u3),
304
+ 'clients' => %w(c2 c3)
305
+ })
306
+ end
307
+ end
308
+ end
309
+ end