cheffish 1.1.2 → 1.2
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.
- checksums.yaml +4 -4
- data/lib/cheffish/chef_run.rb +13 -0
- data/lib/cheffish/rspec.rb +8 -0
- data/lib/cheffish/rspec/chef_run_support.rb +19 -52
- data/lib/cheffish/rspec/matchers.rb +4 -81
- data/lib/cheffish/rspec/matchers/be_idempotent.rb +16 -0
- data/lib/cheffish/rspec/matchers/emit_no_warnings_or_errors.rb +15 -0
- data/lib/cheffish/rspec/matchers/have_updated.rb +37 -0
- data/lib/cheffish/rspec/matchers/partially_match.rb +63 -0
- data/lib/cheffish/rspec/recipe_run_wrapper.rb +2 -2
- data/lib/cheffish/rspec/repository_support.rb +1 -1
- data/lib/cheffish/version.rb +1 -1
- data/spec/integration/chef_acl_spec.rb +384 -420
- data/spec/integration/chef_client_spec.rb +18 -24
- data/spec/integration/chef_container_spec.rb +4 -6
- data/spec/integration/chef_group_spec.rb +30 -46
- data/spec/integration/chef_mirror_spec.rb +60 -89
- data/spec/integration/chef_node_spec.rb +96 -124
- data/spec/integration/chef_organization_spec.rb +38 -57
- data/spec/integration/chef_user_spec.rb +16 -22
- data/spec/integration/private_key_spec.rb +120 -168
- data/spec/integration/recipe_dsl_spec.rb +4 -6
- data/spec/support/spec_support.rb +1 -2
- metadata +13 -8
- data/lib/cheffish/rspec/chef_run_wrapper.rb +0 -5
@@ -18,19 +18,17 @@ describe Chef::Resource::ChefClient do
|
|
18
18
|
|
19
19
|
context 'and is empty' do
|
20
20
|
context 'and we have a private key with a path' do
|
21
|
-
|
21
|
+
with_converge do
|
22
22
|
private_key "#{repo_path}/blah.pem"
|
23
23
|
end
|
24
24
|
|
25
25
|
context 'and we run a recipe that creates client "blah"' do
|
26
|
-
with_converge do
|
27
|
-
chef_client 'blah' do
|
28
|
-
source_key_path "#{repo_path}/blah.pem"
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
26
|
it 'the client gets created' do
|
33
|
-
|
27
|
+
expect_recipe {
|
28
|
+
chef_client 'blah' do
|
29
|
+
source_key_path "#{repo_path}/blah.pem"
|
30
|
+
end
|
31
|
+
}.to have_updated 'chef_client[blah]', :create
|
34
32
|
client = get('clients/blah')
|
35
33
|
expect(client['name']).to eq('blah')
|
36
34
|
key, format = Cheffish::KeyFormatter.decode(client['public_key'])
|
@@ -58,19 +56,17 @@ describe Chef::Resource::ChefClient do
|
|
58
56
|
Chef::Config.private_key_paths = [ repo_path ]
|
59
57
|
end
|
60
58
|
|
61
|
-
|
59
|
+
with_converge do
|
62
60
|
private_key 'blah'
|
63
61
|
end
|
64
62
|
|
65
63
|
context "and a chef_client 'foobar' resource with source_key_path 'blah'" do
|
66
|
-
with_converge do
|
67
|
-
chef_client 'foobar' do
|
68
|
-
source_key_path 'blah'
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
64
|
it 'the client is accessible via the given private key' do
|
73
|
-
|
65
|
+
expect_recipe {
|
66
|
+
chef_client 'foobar' do
|
67
|
+
source_key_path 'blah'
|
68
|
+
end
|
69
|
+
}.to have_updated 'chef_client[foobar]', :create
|
74
70
|
client = get('clients/foobar')
|
75
71
|
key, format = Cheffish::KeyFormatter.decode(client['public_key'])
|
76
72
|
expect(key).to be_public_key_for("#{repo_path}/blah.pem")
|
@@ -86,19 +82,17 @@ describe Chef::Resource::ChefClient do
|
|
86
82
|
when_the_chef_server 'is in OSC mode' do
|
87
83
|
context 'and is empty' do
|
88
84
|
context 'and we have a private key with a path' do
|
89
|
-
|
85
|
+
with_converge do
|
90
86
|
private_key "#{repo_path}/blah.pem"
|
91
87
|
end
|
92
88
|
|
93
89
|
context 'and we run a recipe that creates client "blah"' do
|
94
|
-
with_converge do
|
95
|
-
chef_client 'blah' do
|
96
|
-
source_key_path "#{repo_path}/blah.pem"
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
90
|
it 'the client gets created' do
|
101
|
-
|
91
|
+
expect_recipe {
|
92
|
+
chef_client 'blah' do
|
93
|
+
source_key_path "#{repo_path}/blah.pem"
|
94
|
+
end
|
95
|
+
}.to have_updated 'chef_client[blah]', :create
|
102
96
|
client = get('clients/blah')
|
103
97
|
expect(client['name']).to eq('blah')
|
104
98
|
key, format = Cheffish::KeyFormatter.decode(client['public_key'])
|
@@ -14,10 +14,9 @@ describe Chef::Resource::ChefContainer do
|
|
14
14
|
end
|
15
15
|
|
16
16
|
it 'Converging chef_container "x" creates the container' do
|
17
|
-
|
17
|
+
expect_recipe {
|
18
18
|
chef_container 'x'
|
19
|
-
|
20
|
-
expect(chef_run).to have_updated('chef_container[x]', :create)
|
19
|
+
}.to have_updated('chef_container[x]', :create)
|
21
20
|
expect { get('containers/x') }.not_to raise_error
|
22
21
|
end
|
23
22
|
|
@@ -25,10 +24,9 @@ describe Chef::Resource::ChefContainer do
|
|
25
24
|
container 'x', {}
|
26
25
|
|
27
26
|
it 'Converging chef_container "x" changes nothing' do
|
28
|
-
|
27
|
+
expect_recipe {
|
29
28
|
chef_container 'x'
|
30
|
-
|
31
|
-
expect(chef_run).not_to have_updated('chef_container[x]', :create)
|
29
|
+
}.not_to have_updated('chef_container[x]', :create)
|
32
30
|
end
|
33
31
|
end
|
34
32
|
end
|
@@ -19,10 +19,9 @@ describe Chef::Resource::ChefGroup do
|
|
19
19
|
client 'c', {}
|
20
20
|
|
21
21
|
it 'Converging chef_group "x" creates the group with no members' do
|
22
|
-
|
22
|
+
expect_recipe {
|
23
23
|
chef_group 'x'
|
24
|
-
|
25
|
-
expect(chef_run).to have_updated('chef_group[x]', :create)
|
24
|
+
}.to have_updated('chef_group[x]', :create)
|
26
25
|
expect(get('groups/x')).to eq({
|
27
26
|
'name' => 'x',
|
28
27
|
'groupname' => 'x',
|
@@ -35,25 +34,22 @@ describe Chef::Resource::ChefGroup do
|
|
35
34
|
end
|
36
35
|
|
37
36
|
it 'chef_group "x" action :delete does nothing' do
|
38
|
-
|
37
|
+
expect_recipe {
|
39
38
|
chef_group 'x' do
|
40
39
|
action :delete
|
41
40
|
end
|
42
|
-
|
43
|
-
expect(chef_run).not_to have_updated('chef_group[x]', :delete)
|
44
|
-
expect(chef_run).not_to have_updated('chef_group[x]', :create)
|
41
|
+
}.to not_have_updated('chef_group[x]', :delete).and not_have_updated('chef_group[x]', :create)
|
45
42
|
expect { get('groups/x') }.to raise_error(Net::HTTPServerException)
|
46
43
|
end
|
47
44
|
|
48
45
|
it 'Converging chef_group "x" creates the group with the given members' do
|
49
|
-
|
46
|
+
expect_recipe {
|
50
47
|
chef_group 'x' do
|
51
48
|
groups 'g'
|
52
49
|
users 'u'
|
53
50
|
clients 'c'
|
54
51
|
end
|
55
|
-
|
56
|
-
expect(chef_run).to have_updated('chef_group[x]', :create)
|
52
|
+
}.to have_updated('chef_group[x]', :create)
|
57
53
|
expect(get('groups/x')).to eq({
|
58
54
|
'name' => 'x',
|
59
55
|
'groupname' => 'x',
|
@@ -87,10 +83,9 @@ describe Chef::Resource::ChefGroup do
|
|
87
83
|
}
|
88
84
|
|
89
85
|
it 'Converging chef_group "x" changes nothing' do
|
90
|
-
|
86
|
+
expect_recipe {
|
91
87
|
chef_group 'x'
|
92
|
-
|
93
|
-
expect(chef_run).not_to have_updated('chef_group[x]', :create)
|
88
|
+
}.not_to have_updated('chef_group[x]', :create)
|
94
89
|
expect(get('groups/x')).to eq({
|
95
90
|
'name' => 'x',
|
96
91
|
'groupname' => 'x',
|
@@ -103,24 +98,22 @@ describe Chef::Resource::ChefGroup do
|
|
103
98
|
end
|
104
99
|
|
105
100
|
it 'chef_group "x" action :delete deletes the group' do
|
106
|
-
|
101
|
+
expect_recipe {
|
107
102
|
chef_group 'x' do
|
108
103
|
action :delete
|
109
104
|
end
|
110
|
-
|
111
|
-
expect(chef_run).to have_updated('chef_group[x]', :delete)
|
105
|
+
}.to have_updated('chef_group[x]', :delete)
|
112
106
|
expect { get('groups/x') }.to raise_error(Net::HTTPServerException)
|
113
107
|
end
|
114
108
|
|
115
109
|
it 'Converging chef_group "x" with existing users changes nothing' do
|
116
|
-
|
110
|
+
expect_recipe {
|
117
111
|
chef_group 'x' do
|
118
112
|
users 'u'
|
119
113
|
clients 'c'
|
120
114
|
groups 'g'
|
121
115
|
end
|
122
|
-
|
123
|
-
expect(chef_run).not_to have_updated('chef_group[x]', :create)
|
116
|
+
}.not_to have_updated('chef_group[x]', :create)
|
124
117
|
expect(get('groups/x')).to eq({
|
125
118
|
'name' => 'x',
|
126
119
|
'groupname' => 'x',
|
@@ -133,14 +126,13 @@ describe Chef::Resource::ChefGroup do
|
|
133
126
|
end
|
134
127
|
|
135
128
|
it 'Converging chef_group "x" adds new users' do
|
136
|
-
|
129
|
+
expect_recipe {
|
137
130
|
chef_group 'x' do
|
138
131
|
users 'u3'
|
139
132
|
clients 'c3'
|
140
133
|
groups 'g3'
|
141
134
|
end
|
142
|
-
|
143
|
-
expect(chef_run).to have_updated('chef_group[x]', :create)
|
135
|
+
}.to have_updated('chef_group[x]', :create)
|
144
136
|
expect(get('groups/x')).to eq({
|
145
137
|
'name' => 'x',
|
146
138
|
'groupname' => 'x',
|
@@ -153,14 +145,13 @@ describe Chef::Resource::ChefGroup do
|
|
153
145
|
end
|
154
146
|
|
155
147
|
it 'Converging chef_group "x" with multiple users adds new users' do
|
156
|
-
|
148
|
+
expect_recipe {
|
157
149
|
chef_group 'x' do
|
158
150
|
users 'u3', 'u4'
|
159
151
|
clients 'c3', 'c4'
|
160
152
|
groups 'g3', 'g4'
|
161
153
|
end
|
162
|
-
|
163
|
-
expect(chef_run).to have_updated('chef_group[x]', :create)
|
154
|
+
}.to have_updated('chef_group[x]', :create)
|
164
155
|
expect(get('groups/x')).to eq({
|
165
156
|
'name' => 'x',
|
166
157
|
'groupname' => 'x',
|
@@ -173,14 +164,13 @@ describe Chef::Resource::ChefGroup do
|
|
173
164
|
end
|
174
165
|
|
175
166
|
it 'Converging chef_group "x" with multiple users in an array adds new users' do
|
176
|
-
|
167
|
+
expect_recipe {
|
177
168
|
chef_group 'x' do
|
178
169
|
users [ 'u3', 'u4' ]
|
179
170
|
clients [ 'c3', 'c4' ]
|
180
171
|
groups [ 'g3', 'g4' ]
|
181
172
|
end
|
182
|
-
|
183
|
-
expect(chef_run).to have_updated('chef_group[x]', :create)
|
173
|
+
}.to have_updated('chef_group[x]', :create)
|
184
174
|
expect(get('groups/x')).to eq({
|
185
175
|
'name' => 'x',
|
186
176
|
'groupname' => 'x',
|
@@ -193,7 +183,7 @@ describe Chef::Resource::ChefGroup do
|
|
193
183
|
end
|
194
184
|
|
195
185
|
it 'Converging chef_group "x" with multiple users declarations adds new users' do
|
196
|
-
|
186
|
+
expect_recipe {
|
197
187
|
chef_group 'x' do
|
198
188
|
users 'u3'
|
199
189
|
users 'u4'
|
@@ -202,8 +192,7 @@ describe Chef::Resource::ChefGroup do
|
|
202
192
|
groups 'g3'
|
203
193
|
groups 'g4'
|
204
194
|
end
|
205
|
-
|
206
|
-
expect(chef_run).to have_updated('chef_group[x]', :create)
|
195
|
+
}.to have_updated('chef_group[x]', :create)
|
207
196
|
expect(get('groups/x')).to eq({
|
208
197
|
'name' => 'x',
|
209
198
|
'groupname' => 'x',
|
@@ -216,14 +205,13 @@ describe Chef::Resource::ChefGroup do
|
|
216
205
|
end
|
217
206
|
|
218
207
|
it 'Converging chef_group "x" removes desired users' do
|
219
|
-
|
208
|
+
expect_recipe {
|
220
209
|
chef_group 'x' do
|
221
210
|
remove_users 'u2'
|
222
211
|
remove_clients 'c2'
|
223
212
|
remove_groups 'g2'
|
224
213
|
end
|
225
|
-
|
226
|
-
expect(chef_run).to have_updated('chef_group[x]', :create)
|
214
|
+
}.to have_updated('chef_group[x]', :create)
|
227
215
|
expect(get('groups/x')).to eq({
|
228
216
|
'name' => 'x',
|
229
217
|
'groupname' => 'x',
|
@@ -236,14 +224,13 @@ describe Chef::Resource::ChefGroup do
|
|
236
224
|
end
|
237
225
|
|
238
226
|
it 'Converging chef_group "x" with multiple users removes desired users' do
|
239
|
-
|
227
|
+
expect_recipe {
|
240
228
|
chef_group 'x' do
|
241
229
|
remove_users 'u', 'u2'
|
242
230
|
remove_clients 'c', 'c2'
|
243
231
|
remove_groups 'g', 'g2'
|
244
232
|
end
|
245
|
-
|
246
|
-
expect(chef_run).to have_updated('chef_group[x]', :create)
|
233
|
+
}.to have_updated('chef_group[x]', :create)
|
247
234
|
expect(get('groups/x')).to eq({
|
248
235
|
'name' => 'x',
|
249
236
|
'groupname' => 'x',
|
@@ -256,14 +243,13 @@ describe Chef::Resource::ChefGroup do
|
|
256
243
|
end
|
257
244
|
|
258
245
|
it 'Converging chef_group "x" with multiple users in an array removes desired users' do
|
259
|
-
|
246
|
+
expect_recipe {
|
260
247
|
chef_group 'x' do
|
261
248
|
remove_users [ 'u', 'u2' ]
|
262
249
|
remove_clients [ 'c', 'c2' ]
|
263
250
|
remove_groups [ 'g', 'g2' ]
|
264
251
|
end
|
265
|
-
|
266
|
-
expect(chef_run).to have_updated('chef_group[x]', :create)
|
252
|
+
}.to have_updated('chef_group[x]', :create)
|
267
253
|
expect(get('groups/x')).to eq({
|
268
254
|
'name' => 'x',
|
269
255
|
'groupname' => 'x',
|
@@ -276,7 +262,7 @@ describe Chef::Resource::ChefGroup do
|
|
276
262
|
end
|
277
263
|
|
278
264
|
it 'Converging chef_group "x" with multiple remove_ declarations removes desired users' do
|
279
|
-
|
265
|
+
expect_recipe {
|
280
266
|
chef_group 'x' do
|
281
267
|
remove_users 'u'
|
282
268
|
remove_users 'u2'
|
@@ -285,8 +271,7 @@ describe Chef::Resource::ChefGroup do
|
|
285
271
|
remove_groups 'g'
|
286
272
|
remove_groups 'g2'
|
287
273
|
end
|
288
|
-
|
289
|
-
expect(chef_run).to have_updated('chef_group[x]', :create)
|
274
|
+
}.to have_updated('chef_group[x]', :create)
|
290
275
|
expect(get('groups/x')).to eq({
|
291
276
|
'name' => 'x',
|
292
277
|
'groupname' => 'x',
|
@@ -299,7 +284,7 @@ describe Chef::Resource::ChefGroup do
|
|
299
284
|
end
|
300
285
|
|
301
286
|
it 'Converging chef_group "x" adds and removes desired users' do
|
302
|
-
|
287
|
+
expect_recipe {
|
303
288
|
chef_group 'x' do
|
304
289
|
users 'u3'
|
305
290
|
clients 'c3'
|
@@ -308,8 +293,7 @@ describe Chef::Resource::ChefGroup do
|
|
308
293
|
remove_clients 'c'
|
309
294
|
remove_groups 'g'
|
310
295
|
end
|
311
|
-
|
312
|
-
expect(chef_run).to have_updated('chef_group[x]', :create)
|
296
|
+
}.to have_updated('chef_group[x]', :create)
|
313
297
|
expect(get('groups/x')).to eq({
|
314
298
|
'name' => 'x',
|
315
299
|
'groupname' => 'x',
|
@@ -22,23 +22,21 @@ describe Chef::Resource::ChefMirror do
|
|
22
22
|
end
|
23
23
|
|
24
24
|
it "Download grabs defaults" do
|
25
|
-
|
25
|
+
expect_recipe {
|
26
26
|
chef_mirror '' do
|
27
27
|
action :download
|
28
28
|
end
|
29
|
-
|
30
|
-
expect(chef_run).to have_updated('chef_mirror[]', :download)
|
29
|
+
}.to have_updated('chef_mirror[]', :download)
|
31
30
|
expect(File.exist?(path_to('groups/admins.json'))).to be true
|
32
31
|
expect(File.exist?(path_to('environments/_default.json'))).to be true
|
33
32
|
end
|
34
33
|
|
35
34
|
it "Upload uploads everything" do
|
36
|
-
|
35
|
+
expect_recipe {
|
37
36
|
chef_mirror '' do
|
38
37
|
action :upload
|
39
38
|
end
|
40
|
-
|
41
|
-
expect(chef_run).to have_updated('chef_mirror[]', :upload)
|
39
|
+
}.to have_updated('chef_mirror[]', :upload)
|
42
40
|
expect { get('nodes/x') }.not_to raise_error
|
43
41
|
expect { get('roles/x') }.not_to raise_error
|
44
42
|
expect { get('cookbooks/x/2.0.0') }.not_to raise_error
|
@@ -46,12 +44,12 @@ describe Chef::Resource::ChefMirror do
|
|
46
44
|
|
47
45
|
it 'chef_mirror with concurrency 0 fails with a reasonable message' do
|
48
46
|
expect {
|
49
|
-
|
47
|
+
converge {
|
50
48
|
chef_mirror '' do
|
51
49
|
concurrency 0
|
52
50
|
action :download
|
53
51
|
end
|
54
|
-
|
52
|
+
}
|
55
53
|
}.to raise_error /chef_mirror.concurrency must be above 0/
|
56
54
|
end
|
57
55
|
end
|
@@ -63,23 +61,21 @@ describe Chef::Resource::ChefMirror do
|
|
63
61
|
|
64
62
|
when_the_repository 'is empty' do
|
65
63
|
it "Download grabs the node and role" do
|
66
|
-
|
64
|
+
expect_recipe {
|
67
65
|
chef_mirror '' do
|
68
66
|
action :download
|
69
67
|
end
|
70
|
-
|
71
|
-
expect(chef_run).to have_updated('chef_mirror[]', :download)
|
68
|
+
}.to have_updated('chef_mirror[]', :download)
|
72
69
|
expect(File.exist?(path_to('nodes/x.json'))).to be true
|
73
70
|
expect(File.exist?(path_to('roles/x.json'))).to be true
|
74
71
|
end
|
75
72
|
|
76
73
|
it "Upload uploads nothing" do
|
77
|
-
|
74
|
+
expect_recipe {
|
78
75
|
chef_mirror '' do
|
79
76
|
action :upload
|
80
77
|
end
|
81
|
-
|
82
|
-
expect(chef_run).not_to have_updated('chef_mirror[]', :upload)
|
78
|
+
}.not_to have_updated('chef_mirror[]', :upload)
|
83
79
|
end
|
84
80
|
end
|
85
81
|
end
|
@@ -93,12 +89,11 @@ describe Chef::Resource::ChefMirror do
|
|
93
89
|
file 'roles/y.json', {}
|
94
90
|
|
95
91
|
it "Download grabs the x's" do
|
96
|
-
|
92
|
+
expect_recipe {
|
97
93
|
chef_mirror '' do
|
98
94
|
action :download
|
99
95
|
end
|
100
|
-
|
101
|
-
expect(chef_run).to have_updated('chef_mirror[]', :download)
|
96
|
+
}.to have_updated('chef_mirror[]', :download)
|
102
97
|
expect(File.exist?(path_to('nodes/x.json'))).to be true
|
103
98
|
expect(File.exist?(path_to('roles/x.json'))).to be true
|
104
99
|
expect(File.exist?(path_to('nodes/y.json'))).to be true
|
@@ -106,12 +101,11 @@ describe Chef::Resource::ChefMirror do
|
|
106
101
|
end
|
107
102
|
|
108
103
|
it "Upload uploads the y's" do
|
109
|
-
|
104
|
+
expect_recipe {
|
110
105
|
chef_mirror '' do
|
111
106
|
action :upload
|
112
107
|
end
|
113
|
-
|
114
|
-
expect(chef_run).to have_updated('chef_mirror[]', :upload)
|
108
|
+
}.to have_updated('chef_mirror[]', :upload)
|
115
109
|
expect { get('nodes/x') }.not_to raise_error
|
116
110
|
expect { get('roles/x') }.not_to raise_error
|
117
111
|
expect { get('nodes/y') }.not_to raise_error
|
@@ -119,25 +113,23 @@ describe Chef::Resource::ChefMirror do
|
|
119
113
|
end
|
120
114
|
|
121
115
|
it "Download with purge grabs the x's and deletes the y's" do
|
122
|
-
|
116
|
+
expect_recipe {
|
123
117
|
chef_mirror '' do
|
124
118
|
purge true
|
125
119
|
action :download
|
126
120
|
end
|
127
|
-
|
128
|
-
expect(chef_run).to have_updated('chef_mirror[]', :download)
|
121
|
+
}.to have_updated('chef_mirror[]', :download)
|
129
122
|
expect(File.exist?(path_to('nodes/x.json'))).to be true
|
130
123
|
expect(File.exist?(path_to('roles/x.json'))).to be true
|
131
124
|
end
|
132
125
|
|
133
126
|
it "Upload with :purge uploads the y's and deletes the x's" do
|
134
|
-
|
127
|
+
expect_recipe {
|
135
128
|
chef_mirror '*/*.json' do
|
136
129
|
purge true
|
137
130
|
action :upload
|
138
131
|
end
|
139
|
-
|
140
|
-
expect(chef_run).to have_updated('chef_mirror[*/*.json]', :upload)
|
132
|
+
}.to have_updated('chef_mirror[*/*.json]', :upload)
|
141
133
|
expect { get('nodes/y') }.not_to raise_error
|
142
134
|
expect { get('roles/y') }.not_to raise_error
|
143
135
|
end
|
@@ -160,13 +152,12 @@ describe Chef::Resource::ChefMirror do
|
|
160
152
|
|
161
153
|
it "Upload with chef_repo_path('repo') uploads everything" do
|
162
154
|
repo_path = path_to('repo')
|
163
|
-
|
155
|
+
expect_recipe {
|
164
156
|
chef_mirror '' do
|
165
157
|
chef_repo_path repo_path
|
166
158
|
action :upload
|
167
159
|
end
|
168
|
-
|
169
|
-
expect(chef_run).to have_updated('chef_mirror[]', :upload)
|
160
|
+
}.to have_updated('chef_mirror[]', :upload)
|
170
161
|
expect { get('nodes/x') }.not_to raise_error
|
171
162
|
expect { get('roles/x') }.not_to raise_error
|
172
163
|
expect { get('nodes/y') }.to raise_error
|
@@ -176,13 +167,12 @@ describe Chef::Resource::ChefMirror do
|
|
176
167
|
it "Upload with chef_repo_path(:chef_repo_path) with multiple paths uploads everything" do
|
177
168
|
repo_path = path_to('repo')
|
178
169
|
repo2_path = path_to('repo2')
|
179
|
-
|
170
|
+
expect_recipe {
|
180
171
|
chef_mirror '' do
|
181
172
|
chef_repo_path :chef_repo_path => [ repo_path, repo2_path ]
|
182
173
|
action :upload
|
183
174
|
end
|
184
|
-
|
185
|
-
expect(chef_run).to have_updated('chef_mirror[]', :upload)
|
175
|
+
}.to have_updated('chef_mirror[]', :upload)
|
186
176
|
expect { get('nodes/x') }.not_to raise_error
|
187
177
|
expect { get('roles/x') }.not_to raise_error
|
188
178
|
expect { get('nodes/y') }.not_to raise_error
|
@@ -193,15 +183,14 @@ describe Chef::Resource::ChefMirror do
|
|
193
183
|
repo_path = path_to('repo')
|
194
184
|
repo2_path = path_to('repo2')
|
195
185
|
|
196
|
-
|
186
|
+
expect_recipe {
|
197
187
|
chef_mirror '' do
|
198
188
|
chef_repo_path :chef_repo_path => '/blahblah',
|
199
189
|
:node_path => "#{repo_path}/nodes",
|
200
190
|
:role_path => "#{repo2_path}/roles"
|
201
191
|
action :upload
|
202
192
|
end
|
203
|
-
|
204
|
-
expect(chef_run).to have_updated('chef_mirror[]', :upload)
|
193
|
+
}.to have_updated('chef_mirror[]', :upload)
|
205
194
|
expect { get('nodes/x') }.not_to raise_error
|
206
195
|
expect { get('roles/x') }.to raise_error
|
207
196
|
expect { get('nodes/y') }.to raise_error
|
@@ -212,14 +201,13 @@ describe Chef::Resource::ChefMirror do
|
|
212
201
|
repo_path = path_to('repo')
|
213
202
|
repo2_path = path_to('repo2')
|
214
203
|
|
215
|
-
|
204
|
+
expect_recipe {
|
216
205
|
chef_mirror '' do
|
217
206
|
chef_repo_path :chef_repo_path => repo_path,
|
218
207
|
:role_path => "#{repo2_path}/roles"
|
219
208
|
action :upload
|
220
209
|
end
|
221
|
-
|
222
|
-
expect(chef_run).to have_updated('chef_mirror[]', :upload)
|
210
|
+
}.to have_updated('chef_mirror[]', :upload)
|
223
211
|
expect { get('nodes/x') }.not_to raise_error
|
224
212
|
expect { get('roles/x') }.to raise_error
|
225
213
|
expect { get('nodes/y') }.to raise_error
|
@@ -230,15 +218,14 @@ describe Chef::Resource::ChefMirror do
|
|
230
218
|
repo_path = path_to('repo')
|
231
219
|
repo2_path = path_to('repo2')
|
232
220
|
|
233
|
-
|
221
|
+
expect_recipe {
|
234
222
|
chef_mirror '' do
|
235
223
|
chef_repo_path :chef_repo_path => [ 'foo', 'bar' ],
|
236
224
|
:node_path => [ "#{repo_path}/nodes", "#{repo2_path}/nodes" ],
|
237
225
|
:role_path => [ "#{repo_path}/roles", "#{repo2_path}/roles" ]
|
238
226
|
action :upload
|
239
227
|
end
|
240
|
-
|
241
|
-
expect(chef_run).to have_updated('chef_mirror[]', :upload)
|
228
|
+
}.to have_updated('chef_mirror[]', :upload)
|
242
229
|
expect { get('nodes/x') }.not_to raise_error
|
243
230
|
expect { get('roles/x') }.not_to raise_error
|
244
231
|
expect { get('nodes/y') }.not_to raise_error
|
@@ -253,12 +240,11 @@ describe Chef::Resource::ChefMirror do
|
|
253
240
|
file 'cookbooks/y-1.0.0/metadata.rb', 'name "y-3.0.0"; version "4.0.0"'
|
254
241
|
|
255
242
|
it "chef_mirror :upload uploads everything" do
|
256
|
-
|
243
|
+
expect_recipe {
|
257
244
|
chef_mirror '' do
|
258
245
|
action :upload
|
259
246
|
end
|
260
|
-
|
261
|
-
expect(chef_run).to have_updated('chef_mirror[]', :upload)
|
247
|
+
}.to have_updated('chef_mirror[]', :upload)
|
262
248
|
expect { get('cookbooks/x-1.0.0/2.0.0') }.not_to raise_error
|
263
249
|
expect { get('cookbooks/y-3.0.0/4.0.0') }.not_to raise_error
|
264
250
|
end
|
@@ -268,12 +254,11 @@ describe Chef::Resource::ChefMirror do
|
|
268
254
|
Chef::Config.versioned_cookbooks false
|
269
255
|
end
|
270
256
|
it "chef_mirror :upload uploads everything" do
|
271
|
-
|
257
|
+
expect_recipe {
|
272
258
|
chef_mirror '' do
|
273
259
|
action :upload
|
274
260
|
end
|
275
|
-
|
276
|
-
expect(chef_run).to have_updated('chef_mirror[]', :upload)
|
261
|
+
}.to have_updated('chef_mirror[]', :upload)
|
277
262
|
expect { get('cookbooks/x-1.0.0/2.0.0') }.not_to raise_error
|
278
263
|
expect { get('cookbooks/y-3.0.0/4.0.0') }.not_to raise_error
|
279
264
|
end
|
@@ -287,14 +272,13 @@ describe Chef::Resource::ChefMirror do
|
|
287
272
|
|
288
273
|
it "chef_mirror :upload with chef_repo_path and versioned_cookbooks false uploads cookbooks with name including version" do
|
289
274
|
repository_dir = @repository_dir
|
290
|
-
|
275
|
+
expect_recipe {
|
291
276
|
chef_mirror '' do
|
292
277
|
chef_repo_path repository_dir
|
293
278
|
versioned_cookbooks false
|
294
279
|
action :upload
|
295
280
|
end
|
296
|
-
|
297
|
-
expect(chef_run).to have_updated('chef_mirror[]', :upload)
|
281
|
+
}.to have_updated('chef_mirror[]', :upload)
|
298
282
|
expect { get('cookbooks/x-1.0.0/2.0.0') }.not_to raise_error
|
299
283
|
expect { get('cookbooks/y-3.0.0/4.0.0') }.not_to raise_error
|
300
284
|
end
|
@@ -310,12 +294,11 @@ describe Chef::Resource::ChefMirror do
|
|
310
294
|
Chef::Config.versioned_cookbooks true
|
311
295
|
end
|
312
296
|
it "chef_mirror :upload uploads everything" do
|
313
|
-
|
297
|
+
expect_recipe {
|
314
298
|
chef_mirror '' do
|
315
299
|
action :upload
|
316
300
|
end
|
317
|
-
|
318
|
-
expect(chef_run).to have_updated('chef_mirror[]', :upload)
|
301
|
+
}.to have_updated('chef_mirror[]', :upload)
|
319
302
|
expect { get('cookbooks/x/1.0.0') }.not_to raise_error
|
320
303
|
expect { get('cookbooks/x/2.0.0') }.not_to raise_error
|
321
304
|
end
|
@@ -327,13 +310,12 @@ describe Chef::Resource::ChefMirror do
|
|
327
310
|
end
|
328
311
|
it "chef_mirror :upload with chef_repo_path uploads cookbooks" do
|
329
312
|
repository_dir = @repository_dir
|
330
|
-
|
313
|
+
expect_recipe {
|
331
314
|
chef_mirror '' do
|
332
315
|
chef_repo_path repository_dir
|
333
316
|
action :upload
|
334
317
|
end
|
335
|
-
|
336
|
-
expect(chef_run).to have_updated('chef_mirror[]', :upload)
|
318
|
+
}.to have_updated('chef_mirror[]', :upload)
|
337
319
|
expect { get('cookbooks/x/1.0.0') }.not_to raise_error
|
338
320
|
expect { get('cookbooks/x/2.0.0') }.not_to raise_error
|
339
321
|
end
|
@@ -347,27 +329,25 @@ describe Chef::Resource::ChefMirror do
|
|
347
329
|
|
348
330
|
it "chef_mirror :upload with chef_repo_path uploads cookbooks with name split from version" do
|
349
331
|
repository_dir = @repository_dir
|
350
|
-
|
332
|
+
expect_recipe {
|
351
333
|
chef_mirror '' do
|
352
334
|
chef_repo_path repository_dir
|
353
335
|
action :upload
|
354
336
|
end
|
355
|
-
|
356
|
-
expect(chef_run).to have_updated('chef_mirror[]', :upload)
|
337
|
+
}.to have_updated('chef_mirror[]', :upload)
|
357
338
|
expect { get('cookbooks/x/1.0.0') }.not_to raise_error
|
358
339
|
expect { get('cookbooks/x/2.0.0') }.not_to raise_error
|
359
340
|
end
|
360
341
|
|
361
342
|
it "chef_mirror :upload with chef_repo_path and versioned_cookbooks uploads cookbooks with name split from version" do
|
362
343
|
repository_dir = @repository_dir
|
363
|
-
|
344
|
+
expect_recipe {
|
364
345
|
chef_mirror '' do
|
365
346
|
chef_repo_path repository_dir
|
366
347
|
versioned_cookbooks true
|
367
348
|
action :upload
|
368
349
|
end
|
369
|
-
|
370
|
-
expect(chef_run).to have_updated('chef_mirror[]', :upload)
|
350
|
+
}.to have_updated('chef_mirror[]', :upload)
|
371
351
|
expect { get('cookbooks/x/1.0.0') }.not_to raise_error
|
372
352
|
expect { get('cookbooks/x/2.0.0') }.not_to raise_error
|
373
353
|
end
|
@@ -380,13 +360,12 @@ describe Chef::Resource::ChefMirror do
|
|
380
360
|
end
|
381
361
|
it "chef_mirror :upload with chef_repo_path uploads cookbooks with name split from version" do
|
382
362
|
repository_dir = @repository_dir
|
383
|
-
|
363
|
+
expect_recipe {
|
384
364
|
chef_mirror '' do
|
385
365
|
chef_repo_path repository_dir
|
386
366
|
action :upload
|
387
367
|
end
|
388
|
-
|
389
|
-
expect(chef_run).to have_updated('chef_mirror[]', :upload)
|
368
|
+
}.to have_updated('chef_mirror[]', :upload)
|
390
369
|
expect { get('cookbooks/x/1.0.0') }.not_to raise_error
|
391
370
|
expect { get('cookbooks/x/2.0.0') }.not_to raise_error
|
392
371
|
end
|
@@ -401,23 +380,21 @@ describe Chef::Resource::ChefMirror do
|
|
401
380
|
|
402
381
|
when_the_repository 'is empty' do
|
403
382
|
it 'chef_mirror :download downloads the latest version of the cookbook' do
|
404
|
-
|
383
|
+
expect_recipe {
|
405
384
|
chef_mirror '' do
|
406
385
|
action :download
|
407
386
|
end
|
408
|
-
|
409
|
-
expect(chef_run).to have_updated('chef_mirror[]', :download)
|
387
|
+
}.to have_updated('chef_mirror[]', :download)
|
410
388
|
expect(File.read(path_to('cookbooks/x/metadata.rb'))).to eq('name "x"; version "2.0.0"')
|
411
389
|
end
|
412
390
|
|
413
391
|
it 'chef_mirror :download with versioned_cookbooks = true downloads all versions of the cookbook' do
|
414
|
-
|
392
|
+
expect_recipe {
|
415
393
|
chef_mirror '' do
|
416
394
|
versioned_cookbooks true
|
417
395
|
action :download
|
418
396
|
end
|
419
|
-
|
420
|
-
expect(chef_run).to have_updated('chef_mirror[]', :download)
|
397
|
+
}.to have_updated('chef_mirror[]', :download)
|
421
398
|
expect(File.read(path_to('cookbooks/x-1.0.0/metadata.rb'))).to eq('name "x"; version "1.0.0"')
|
422
399
|
expect(File.read(path_to('cookbooks/x-2.0.0/metadata.rb'))).to eq('name "x"; version "2.0.0"')
|
423
400
|
end
|
@@ -429,27 +406,25 @@ describe Chef::Resource::ChefMirror do
|
|
429
406
|
|
430
407
|
it 'chef_mirror :download with chef_repo_path downloads all versions of the cookbook' do
|
431
408
|
repository_dir = @repository_dir
|
432
|
-
|
409
|
+
expect_recipe {
|
433
410
|
chef_mirror '' do
|
434
411
|
chef_repo_path repository_dir
|
435
412
|
action :download
|
436
413
|
end
|
437
|
-
|
438
|
-
expect(chef_run).to have_updated('chef_mirror[]', :download)
|
414
|
+
}.to have_updated('chef_mirror[]', :download)
|
439
415
|
expect(File.read(path_to('cookbooks/x-1.0.0/metadata.rb'))).to eq('name "x"; version "1.0.0"')
|
440
416
|
expect(File.read(path_to('cookbooks/x-2.0.0/metadata.rb'))).to eq('name "x"; version "2.0.0"')
|
441
417
|
end
|
442
418
|
|
443
419
|
it 'chef_mirror :download with chef_repo_path and versioned_cookbooks = false downloads the latest version of the cookbook' do
|
444
420
|
repository_dir = @repository_dir
|
445
|
-
|
421
|
+
expect_recipe {
|
446
422
|
chef_mirror '' do
|
447
423
|
chef_repo_path repository_dir
|
448
424
|
versioned_cookbooks false
|
449
425
|
action :download
|
450
426
|
end
|
451
|
-
|
452
|
-
expect(chef_run).to have_updated('chef_mirror[]', :download)
|
427
|
+
}.to have_updated('chef_mirror[]', :download)
|
453
428
|
expect(File.read(path_to('cookbooks/x/metadata.rb'))).to eq('name "x"; version "2.0.0"')
|
454
429
|
end
|
455
430
|
end
|
@@ -460,24 +435,22 @@ describe Chef::Resource::ChefMirror do
|
|
460
435
|
end
|
461
436
|
|
462
437
|
it 'chef_mirror :download downloads all versions of the cookbook' do
|
463
|
-
|
438
|
+
expect_recipe {
|
464
439
|
chef_mirror '' do
|
465
440
|
action :download
|
466
441
|
end
|
467
|
-
|
468
|
-
expect(chef_run).to have_updated('chef_mirror[]', :download)
|
442
|
+
}.to have_updated('chef_mirror[]', :download)
|
469
443
|
expect(File.read(path_to('cookbooks/x-1.0.0/metadata.rb'))).to eq('name "x"; version "1.0.0"')
|
470
444
|
expect(File.read(path_to('cookbooks/x-2.0.0/metadata.rb'))).to eq('name "x"; version "2.0.0"')
|
471
445
|
end
|
472
446
|
|
473
447
|
it 'chef_mirror :download with versioned_cookbooks = false downloads the latest version of the cookbook' do
|
474
|
-
|
448
|
+
expect_recipe {
|
475
449
|
chef_mirror '' do
|
476
450
|
versioned_cookbooks false
|
477
451
|
action :download
|
478
452
|
end
|
479
|
-
|
480
|
-
expect(chef_run).to have_updated('chef_mirror[]', :download)
|
453
|
+
}.to have_updated('chef_mirror[]', :download)
|
481
454
|
expect(File.read(path_to('cookbooks/x/metadata.rb'))).to eq('name "x"; version "2.0.0"')
|
482
455
|
end
|
483
456
|
|
@@ -488,27 +461,25 @@ describe Chef::Resource::ChefMirror do
|
|
488
461
|
|
489
462
|
it 'chef_mirror :download with chef_repo_path downloads all versions of the cookbook' do
|
490
463
|
repository_dir = @repository_dir
|
491
|
-
|
464
|
+
expect_recipe {
|
492
465
|
chef_mirror '' do
|
493
466
|
chef_repo_path repository_dir
|
494
467
|
action :download
|
495
468
|
end
|
496
|
-
|
497
|
-
expect(chef_run).to have_updated('chef_mirror[]', :download)
|
469
|
+
}.to have_updated('chef_mirror[]', :download)
|
498
470
|
expect(File.read(path_to('cookbooks/x-1.0.0/metadata.rb'))).to eq('name "x"; version "1.0.0"')
|
499
471
|
expect(File.read(path_to('cookbooks/x-2.0.0/metadata.rb'))).to eq('name "x"; version "2.0.0"')
|
500
472
|
end
|
501
473
|
|
502
474
|
it 'chef_mirror :download with chef_repo_path and versioned_cookbooks = false downloads the latest version of the cookbook' do
|
503
475
|
repository_dir = @repository_dir
|
504
|
-
|
476
|
+
expect_recipe {
|
505
477
|
chef_mirror '' do
|
506
478
|
chef_repo_path repository_dir
|
507
479
|
versioned_cookbooks false
|
508
480
|
action :download
|
509
481
|
end
|
510
|
-
|
511
|
-
expect(chef_run).to have_updated('chef_mirror[]', :download)
|
482
|
+
}.to have_updated('chef_mirror[]', :download)
|
512
483
|
expect(File.read(path_to('cookbooks/x/metadata.rb'))).to eq('name "x"; version "2.0.0"')
|
513
484
|
end
|
514
485
|
end
|