chef-dk 0.4.0 → 0.5.0.rc.1
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/CONTRIBUTING.md +1 -3
- data/README.md +20 -15
- data/lib/chef-dk/cli.rb +18 -1
- data/lib/chef-dk/command/verify.rb +1 -1
- data/lib/chef-dk/policyfile/cookbook_location_specification.rb +5 -1
- data/lib/chef-dk/policyfile/read_cookbook_for_compat_mode_upload.rb +44 -0
- data/lib/chef-dk/policyfile/uploader.rb +58 -6
- data/lib/chef-dk/policyfile_lock.rb +42 -0
- data/lib/chef-dk/skeletons/code_generator/files/default/{repo/cookbooks → cookbook_readmes}/README-policy.md +0 -0
- data/lib/chef-dk/skeletons/code_generator/files/default/{repo/cookbooks → cookbook_readmes}/README.md +1 -1
- data/lib/chef-dk/skeletons/code_generator/files/default/repo/cookbooks/example/attributes/default.rb +7 -0
- data/lib/chef-dk/skeletons/code_generator/files/default/repo/cookbooks/example/metadata.rb +3 -0
- data/lib/chef-dk/skeletons/code_generator/files/default/repo/cookbooks/example/recipes/default.rb +8 -0
- data/lib/chef-dk/skeletons/code_generator/files/default/repo/data_bags/README.md +13 -18
- data/lib/chef-dk/skeletons/code_generator/files/default/repo/data_bags/example/example_item.json +4 -0
- data/lib/chef-dk/skeletons/code_generator/files/default/repo/environments/README.md +7 -3
- data/lib/chef-dk/skeletons/code_generator/files/default/repo/environments/example.json +13 -0
- data/lib/chef-dk/skeletons/code_generator/files/default/repo/roles/README.md +6 -13
- data/lib/chef-dk/skeletons/code_generator/files/default/repo/roles/example.json +13 -0
- data/lib/chef-dk/skeletons/code_generator/recipes/app.rb +5 -1
- data/lib/chef-dk/skeletons/code_generator/recipes/cookbook.rb +5 -1
- data/lib/chef-dk/skeletons/code_generator/recipes/repo.rb +5 -20
- data/lib/chef-dk/version.rb +1 -1
- data/lib/kitchen/provisioner/policyfile_zero.rb +21 -9
- data/spec/spec_helper.rb +8 -0
- data/spec/unit/cli_spec.rb +49 -3
- data/spec/unit/command/generator_commands/app_spec.rb +1 -1
- data/spec/unit/command/generator_commands/cookbook_spec.rb +1 -1
- data/spec/unit/command/generator_commands/repo_spec.rb +46 -50
- data/spec/unit/policyfile/uploader_spec.rb +225 -171
- data/spec/unit/policyfile_evaluation_spec.rb +16 -0
- data/spec/unit/policyfile_lock_build_spec.rb +156 -0
- metadata +18 -9
- data/lib/chef-dk/skeletons/code_generator/files/default/repo/Rakefile +0 -65
- data/lib/chef-dk/skeletons/code_generator/files/default/repo/certificates/README.md +0 -19
- data/lib/chef-dk/skeletons/code_generator/templates/default/repo/config/rake.rb.erb +0 -38
@@ -86,270 +86,324 @@ describe ChefDK::Policyfile::Uploader do
|
|
86
86
|
expect(uploader.http_client).to eq(http_client)
|
87
87
|
end
|
88
88
|
|
89
|
-
describe "uploading
|
89
|
+
describe "uploading policies and cookbooks" do
|
90
90
|
|
91
91
|
let(:cookbook_locks) { {} }
|
92
92
|
let(:cookbook_versions) { {} }
|
93
93
|
|
94
|
-
let(:existing_cookbook_on_remote) do
|
95
|
-
{"apt"=>
|
96
|
-
{"url"=>"http://localhost:8889/cookbooks/apt",
|
97
|
-
"versions"=>
|
98
|
-
[{"url"=>
|
99
|
-
"http://localhost:8889/cookbooks/apt/46097674477573307.43471642740453733.243606720748315",
|
100
|
-
"version"=>"46097674477573307.43471642740453733.243606720748315"}]},
|
101
|
-
"build-essential"=>
|
102
|
-
{"url"=>"http://localhost:8889/cookbooks/build-essential",
|
103
|
-
"versions"=>
|
104
|
-
[{"url"=>
|
105
|
-
"http://localhost:8889/cookbooks/build-essential/67369247788170534.26353953100055918.55660493423796",
|
106
|
-
"version"=>"67369247788170534.26353953100055918.55660493423796"}]},
|
107
|
-
"java"=>
|
108
|
-
{"url"=>"http://localhost:8889/cookbooks/java",
|
109
|
-
"versions"=>
|
110
|
-
[{"url"=>
|
111
|
-
"http://localhost:8889/cookbooks/java/5664982062912610.52588194571203830.6215746262253",
|
112
|
-
"version"=>"5664982062912610.52588194571203830.6215746262253"}]},
|
113
|
-
"jenkins"=>
|
114
|
-
{"url"=>"http://localhost:8889/cookbooks/jenkins",
|
115
|
-
"versions"=>
|
116
|
-
[{"url"=>
|
117
|
-
"http://localhost:8889/cookbooks/jenkins/69194928762630300.30177357398946006.269829039948647",
|
118
|
-
"version"=>"69194928762630300.30177357398946006.269829039948647"}]}
|
119
|
-
}
|
120
|
-
end
|
121
|
-
|
122
94
|
before do
|
123
95
|
allow(policyfile_lock).to receive(:cookbook_locks).and_return(cookbook_locks)
|
124
96
|
end
|
125
97
|
|
126
|
-
def lock_double(name, dotted_decimal_id)
|
98
|
+
def lock_double(name, identifier, dotted_decimal_id)
|
127
99
|
cache_path = "/home/user/cache_path/#{name}"
|
128
100
|
|
129
101
|
lock = instance_double("ChefDK::Policyfile::CookbookLock",
|
130
102
|
name: name,
|
131
103
|
version: "1.0.0",
|
132
|
-
identifier:
|
104
|
+
identifier: identifier,
|
133
105
|
dotted_decimal_identifier: dotted_decimal_id,
|
134
106
|
cookbook_path: cache_path)
|
135
107
|
|
136
108
|
cookbook_version = instance_double("Chef::CookbookVersion",
|
137
109
|
name: name,
|
110
|
+
identifier: lock.identifier,
|
138
111
|
version: dotted_decimal_id)
|
139
112
|
|
113
|
+
allow(cookbook_version).to receive(:identifier=).with(lock.identifier)
|
114
|
+
|
140
115
|
allow(ChefDK::Policyfile::ReadCookbookForCompatModeUpload).
|
141
116
|
to receive(:load).
|
142
117
|
with(name, dotted_decimal_id, cache_path).
|
143
118
|
and_return(cookbook_version)
|
144
119
|
|
120
|
+
allow(ChefDK::Policyfile::CookbookLoaderWithChefignore).
|
121
|
+
to receive(:load).
|
122
|
+
with(name, cache_path).
|
123
|
+
and_return(cookbook_version)
|
124
|
+
|
145
125
|
cookbook_versions[name] = cookbook_version
|
146
126
|
cookbook_locks[name] = lock
|
147
127
|
|
148
128
|
lock
|
149
129
|
end
|
150
130
|
|
151
|
-
|
131
|
+
shared_examples_for "uploading cookbooks" do
|
152
132
|
|
153
|
-
|
133
|
+
describe "uploading cookbooks" do
|
154
134
|
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
135
|
+
it "enumerates the cookbooks already on the server" do
|
136
|
+
expect(http_client).to receive(:get).with(list_cookbooks_url).and_return(existing_cookbook_on_remote)
|
137
|
+
expect(uploader.existing_cookbook_on_remote).to eq(existing_cookbook_on_remote)
|
138
|
+
end
|
159
139
|
|
160
|
-
|
161
|
-
response = double("Net::HTTP response", code: "409")
|
162
|
-
error = Net::HTTPServerException.new("conflict", response)
|
163
|
-
expect(http_client).to receive(:post).with('data', {"name" => "policyfiles"}).and_raise(error)
|
164
|
-
expect { uploader.data_bag_create }.to_not raise_error
|
165
|
-
end
|
140
|
+
context "with an empty policyfile lock" do
|
166
141
|
|
167
|
-
|
168
|
-
|
169
|
-
error = Net::HTTPServerException.new("Not Found", response)
|
170
|
-
expect(http_client).to receive(:put).
|
171
|
-
with('data/policyfiles/example-unit-test', policyfile_as_data_bag_item).
|
172
|
-
and_raise(error)
|
173
|
-
expect(http_client).to receive(:post).
|
174
|
-
with('data/policyfiles', policyfile_as_data_bag_item)
|
142
|
+
it "has an empty list of cookbooks for possible upload" do
|
143
|
+
expect(policyfile_lock).to receive(:validate_cookbooks!)
|
175
144
|
|
176
|
-
|
177
|
-
|
145
|
+
expect(uploader.cookbook_versions_for_policy).to eq([])
|
146
|
+
end
|
178
147
|
|
179
|
-
|
180
|
-
|
181
|
-
with('data/policyfiles/example-unit-test', policyfile_as_data_bag_item)
|
182
|
-
uploader.data_bag_item_create
|
183
|
-
end
|
148
|
+
it "has an empty list of cookbooks that need to be uploaded" do
|
149
|
+
expect(policyfile_lock).to receive(:validate_cookbooks!)
|
184
150
|
|
185
|
-
|
186
|
-
|
187
|
-
expect(http_client).to receive(:put).
|
188
|
-
with('data/policyfiles/example-unit-test', policyfile_as_data_bag_item)
|
189
|
-
uploader.upload_policy
|
190
|
-
end
|
151
|
+
expect(uploader.cookbook_versions_to_upload).to eq([])
|
152
|
+
end
|
191
153
|
|
192
|
-
|
154
|
+
end
|
193
155
|
|
194
|
-
|
156
|
+
context "with a set of cookbooks that don't exist on the server" do
|
195
157
|
|
196
|
-
|
158
|
+
before do
|
159
|
+
lock_double("my_apache2", "1111111111111111111111111111111111111111", "123.456.789")
|
160
|
+
lock_double("my_jenkins", "2222222222222222222222222222222222222222", "321.654.987")
|
161
|
+
end
|
197
162
|
|
198
|
-
|
199
|
-
|
200
|
-
end
|
163
|
+
it "lists the cookbooks in the lock as possibly needing to be uploaded" do
|
164
|
+
expect(policyfile_lock).to receive(:validate_cookbooks!)
|
201
165
|
|
202
|
-
|
203
|
-
|
204
|
-
|
166
|
+
expected_versions_for_policy = cookbook_versions.keys.map do |cb_name|
|
167
|
+
cb = cookbook_versions[cb_name]
|
168
|
+
lock = cookbook_locks[cb_name]
|
169
|
+
ChefDK::Policyfile::Uploader::LockedCookbookForUpload.new(cb, lock)
|
170
|
+
end
|
205
171
|
|
206
|
-
|
207
|
-
|
172
|
+
expect(uploader.cookbook_versions_for_policy).to eq(expected_versions_for_policy)
|
173
|
+
end
|
208
174
|
|
209
|
-
|
175
|
+
it "lists all cookbooks in the lock as needing to be uploaded" do
|
176
|
+
expect(policyfile_lock).to receive(:validate_cookbooks!)
|
177
|
+
expect(http_client).to receive(:get).with(list_cookbooks_url).and_return(existing_cookbook_on_remote)
|
210
178
|
|
211
|
-
|
212
|
-
|
213
|
-
expect(uploader.existing_cookbook_on_remote).to eq(existing_cookbook_on_remote)
|
214
|
-
end
|
179
|
+
expect(uploader.cookbook_versions_to_upload).to eq(cookbook_versions.values)
|
180
|
+
end
|
215
181
|
|
216
|
-
|
182
|
+
it "uploads the cookbooks and then the policy" do
|
183
|
+
expect(policyfile_lock).to receive(:validate_cookbooks!)
|
184
|
+
expect(http_client).to receive(:get).with(list_cookbooks_url).and_return(existing_cookbook_on_remote)
|
217
185
|
|
218
|
-
|
219
|
-
|
186
|
+
cookbook_uploader = instance_double("Chef::CookbookUploader")
|
187
|
+
expect(Chef::CookbookUploader).to receive(:new).
|
188
|
+
with(cookbook_versions.values, rest: http_client, policy_mode: policy_document_native_api).
|
189
|
+
and_return(cookbook_uploader)
|
190
|
+
expect(cookbook_uploader).to receive(:upload_cookbooks)
|
220
191
|
|
221
|
-
|
222
|
-
end
|
192
|
+
expect_policyfile_upload
|
223
193
|
|
224
|
-
|
225
|
-
|
194
|
+
uploader.upload
|
195
|
+
end
|
226
196
|
|
227
|
-
|
228
|
-
end
|
197
|
+
end
|
229
198
|
|
230
|
-
|
199
|
+
context "with a set of cookbooks where some already exist on the server" do
|
231
200
|
|
232
|
-
|
201
|
+
before do
|
202
|
+
# These are new:
|
203
|
+
lock_double("my_apache2", "1111111111111111111111111111111111111111", "123.456.789")
|
204
|
+
lock_double("my_jenkins", "2222222222222222222222222222222222222222", "321.654.987")
|
233
205
|
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
end
|
206
|
+
# Have this one:
|
207
|
+
lock_double("build-essential", "571d8ebd02b296fe90b2e4d68754af7e8e185f28", "67369247788170534.26353953100055918.55660493423796")
|
208
|
+
end
|
238
209
|
|
239
|
-
|
240
|
-
|
210
|
+
let(:expected_cookbooks_for_upload) do
|
211
|
+
[
|
212
|
+
cookbook_versions["my_apache2"],
|
213
|
+
cookbook_versions["my_jenkins"]
|
214
|
+
]
|
215
|
+
end
|
241
216
|
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
ChefDK::Policyfile::Uploader::LockedCookbookForUpload.new(cb, lock)
|
246
|
-
end
|
217
|
+
it "lists only cookbooks not on the server as needing to be uploaded" do
|
218
|
+
expect(policyfile_lock).to receive(:validate_cookbooks!)
|
219
|
+
expect(http_client).to receive(:get).with(list_cookbooks_url).and_return(existing_cookbook_on_remote)
|
247
220
|
|
248
|
-
expect(uploader.cookbook_versions_for_policy).to eq(expected_versions_for_policy)
|
249
|
-
end
|
250
221
|
|
251
|
-
|
252
|
-
|
253
|
-
expect(http_client).to receive(:get).with('cookbooks?num_versions=all').and_return(existing_cookbook_on_remote)
|
222
|
+
expect(uploader.cookbook_versions_to_upload).to eq(expected_cookbooks_for_upload)
|
223
|
+
end
|
254
224
|
|
255
|
-
|
256
|
-
|
225
|
+
it "uploads the cookbooks and then the policy" do
|
226
|
+
expect(policyfile_lock).to receive(:validate_cookbooks!)
|
227
|
+
expect(http_client).to receive(:get).with(list_cookbooks_url).and_return(existing_cookbook_on_remote)
|
257
228
|
|
258
|
-
|
259
|
-
|
260
|
-
|
229
|
+
cookbook_uploader = instance_double("Chef::CookbookUploader")
|
230
|
+
expect(Chef::CookbookUploader).to receive(:new).
|
231
|
+
with(expected_cookbooks_for_upload, rest: http_client, policy_mode: policy_document_native_api).
|
232
|
+
and_return(cookbook_uploader)
|
233
|
+
expect(cookbook_uploader).to receive(:upload_cookbooks)
|
261
234
|
|
262
|
-
|
263
|
-
expect(Chef::CookbookUploader).to receive(:new).
|
264
|
-
with(cookbook_versions.values, :rest => http_client).
|
265
|
-
and_return(cookbook_uploader)
|
266
|
-
expect(cookbook_uploader).to receive(:upload_cookbooks)
|
235
|
+
expect_policyfile_upload
|
267
236
|
|
268
|
-
|
269
|
-
|
270
|
-
expect(uploader).to receive(:data_bag_item_create)
|
237
|
+
uploader.upload
|
238
|
+
end
|
271
239
|
|
272
|
-
|
273
|
-
end
|
240
|
+
end
|
274
241
|
|
275
|
-
|
242
|
+
context "with a set of cookbooks that all exist on the server" do
|
276
243
|
|
277
|
-
|
244
|
+
before do
|
245
|
+
# Have this one:
|
246
|
+
lock_double("build-essential", "571d8ebd02b296fe90b2e4d68754af7e8e185f28", "67369247788170534.26353953100055918.55660493423796")
|
247
|
+
end
|
278
248
|
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
lock_double("my_jenkins", "321.654.987")
|
249
|
+
let(:expected_cookbooks_for_upload) do
|
250
|
+
[]
|
251
|
+
end
|
283
252
|
|
284
|
-
|
285
|
-
|
286
|
-
|
253
|
+
it "lists no cookbooks as needing to be uploaded" do
|
254
|
+
expect(policyfile_lock).to receive(:validate_cookbooks!)
|
255
|
+
expect(http_client).to receive(:get).with(list_cookbooks_url).and_return(existing_cookbook_on_remote)
|
287
256
|
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
257
|
+
expect(uploader.cookbook_versions_to_upload).to eq(expected_cookbooks_for_upload)
|
258
|
+
end
|
259
|
+
|
260
|
+
it "skips cookbooks uploads, then uploads the policy" do
|
261
|
+
expect(policyfile_lock).to receive(:validate_cookbooks!)
|
262
|
+
expect(http_client).to receive(:get).with(list_cookbooks_url).and_return(existing_cookbook_on_remote)
|
294
263
|
|
295
|
-
|
296
|
-
expect(policyfile_lock).to receive(:validate_cookbooks!)
|
297
|
-
expect(http_client).to receive(:get).with('cookbooks?num_versions=all').and_return(existing_cookbook_on_remote)
|
264
|
+
expect(uploader.uploader).to_not receive(:upload_cookbooks)
|
298
265
|
|
266
|
+
expect_policyfile_upload
|
299
267
|
|
300
|
-
|
268
|
+
uploader.upload
|
269
|
+
end
|
270
|
+
end
|
301
271
|
end
|
272
|
+
end # uploading cookbooks shared examples
|
273
|
+
|
274
|
+
context "when configured for policy document compat mode" do
|
302
275
|
|
303
|
-
|
304
|
-
expect(policyfile_lock).to receive(:validate_cookbooks!)
|
305
|
-
expect(http_client).to receive(:get).with('cookbooks?num_versions=all').and_return(existing_cookbook_on_remote)
|
276
|
+
let(:policyfiles_data_bag) { {"name" => "policyfiles" } }
|
306
277
|
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
278
|
+
let(:list_cookbooks_url) { 'cookbooks?num_versions=all' }
|
279
|
+
|
280
|
+
let(:existing_cookbook_on_remote) do
|
281
|
+
{"apt"=>
|
282
|
+
{"url"=>"http://localhost:8889/cookbooks/apt",
|
283
|
+
"versions"=>
|
284
|
+
[{"url"=>
|
285
|
+
"http://localhost:8889/cookbooks/apt/46097674477573307.43471642740453733.243606720748315",
|
286
|
+
"version"=>"46097674477573307.43471642740453733.243606720748315"}]},
|
287
|
+
"build-essential"=>
|
288
|
+
{"url"=>"http://localhost:8889/cookbooks/build-essential",
|
289
|
+
"versions"=>
|
290
|
+
[{"url"=>
|
291
|
+
"http://localhost:8889/cookbooks/build-essential/67369247788170534.26353953100055918.55660493423796",
|
292
|
+
"version"=>"67369247788170534.26353953100055918.55660493423796"}]},
|
293
|
+
"java"=>
|
294
|
+
{"url"=>"http://localhost:8889/cookbooks/java",
|
295
|
+
"versions"=>
|
296
|
+
[{"url"=>
|
297
|
+
"http://localhost:8889/cookbooks/java/5664982062912610.52588194571203830.6215746262253",
|
298
|
+
"version"=>"5664982062912610.52588194571203830.6215746262253"}]},
|
299
|
+
"jenkins"=>
|
300
|
+
{"url"=>"http://localhost:8889/cookbooks/jenkins",
|
301
|
+
"versions"=>
|
302
|
+
[{"url"=>
|
303
|
+
"http://localhost:8889/cookbooks/jenkins/69194928762630300.30177357398946006.269829039948647",
|
304
|
+
"version"=>"69194928762630300.30177357398946006.269829039948647"}]}
|
305
|
+
}
|
306
|
+
end
|
312
307
|
|
313
|
-
|
308
|
+
def expect_policyfile_upload
|
314
309
|
expect(uploader).to receive(:data_bag_create)
|
315
310
|
expect(uploader).to receive(:data_bag_item_create)
|
311
|
+
end
|
312
|
+
|
313
|
+
it "ensures a data bag named 'policyfiles' exists" do
|
314
|
+
expect(http_client).to receive(:post).with('data', policyfiles_data_bag)
|
315
|
+
uploader.data_bag_create
|
316
|
+
end
|
316
317
|
|
317
|
-
|
318
|
+
it "does not error when the 'policyfiles' data bag exists" do
|
319
|
+
response = double("Net::HTTP response", code: "409")
|
320
|
+
error = Net::HTTPServerException.new("conflict", response)
|
321
|
+
expect(http_client).to receive(:post).with('data', {"name" => "policyfiles"}).and_raise(error)
|
322
|
+
expect { uploader.data_bag_create }.to_not raise_error
|
318
323
|
end
|
319
324
|
|
320
|
-
|
325
|
+
it "uploads the policyfile as a data bag item" do
|
326
|
+
response = double("Net::HTTP response", code: "404")
|
327
|
+
error = Net::HTTPServerException.new("Not Found", response)
|
328
|
+
expect(http_client).to receive(:put).
|
329
|
+
with('data/policyfiles/example-unit-test', policyfile_as_data_bag_item).
|
330
|
+
and_raise(error)
|
331
|
+
expect(http_client).to receive(:post).
|
332
|
+
with('data/policyfiles', policyfile_as_data_bag_item)
|
321
333
|
|
322
|
-
|
334
|
+
uploader.data_bag_item_create
|
335
|
+
end
|
323
336
|
|
324
|
-
|
325
|
-
|
326
|
-
|
337
|
+
it "replaces an existing policyfile on the server if it exists" do
|
338
|
+
expect(http_client).to receive(:put).
|
339
|
+
with('data/policyfiles/example-unit-test', policyfile_as_data_bag_item)
|
340
|
+
uploader.data_bag_item_create
|
327
341
|
end
|
328
342
|
|
329
|
-
|
330
|
-
|
343
|
+
it "creates the data bag and item to upload the policy" do
|
344
|
+
expect(http_client).to receive(:post).with('data', policyfiles_data_bag)
|
345
|
+
expect(http_client).to receive(:put).
|
346
|
+
with('data/policyfiles/example-unit-test', policyfile_as_data_bag_item)
|
347
|
+
uploader.upload_policy
|
331
348
|
end
|
332
349
|
|
333
|
-
|
334
|
-
expect(policyfile_lock).to receive(:validate_cookbooks!)
|
335
|
-
expect(http_client).to receive(:get).with('cookbooks?num_versions=all').and_return(existing_cookbook_on_remote)
|
350
|
+
include_examples "uploading cookbooks"
|
336
351
|
|
337
|
-
|
338
|
-
end
|
352
|
+
end
|
339
353
|
|
340
|
-
|
341
|
-
expect(policyfile_lock).to receive(:validate_cookbooks!)
|
342
|
-
expect(http_client).to receive(:get).with('cookbooks?num_versions=all').and_return(existing_cookbook_on_remote)
|
354
|
+
context "when configured for policy document native mode" do
|
343
355
|
|
344
|
-
|
356
|
+
let(:policy_document_native_api) { true }
|
345
357
|
|
346
|
-
|
347
|
-
|
348
|
-
|
358
|
+
let(:list_cookbooks_url) { 'cookbook_artifacts?num_versions=all' }
|
359
|
+
|
360
|
+
let(:existing_cookbook_on_remote) do
|
361
|
+
{"apt"=>
|
362
|
+
{"url"=>"http://localhost:8889/cookbook_artifacts/apt",
|
363
|
+
"versions"=>
|
364
|
+
[{"url"=>
|
365
|
+
"http://localhost:8889/cookbook_artifacts/apt/5f7045a8aeaf6ccda3b3594258df9ee982b3a023",
|
366
|
+
"identifier"=>"5f7045a8aeaf6ccda3b3594258df9ee982b3a023"}]},
|
367
|
+
"build-essential"=>
|
368
|
+
{"url"=>"http://localhost:8889/cookbook_artifacts/build-essential",
|
369
|
+
"versions"=>
|
370
|
+
[{"url"=>
|
371
|
+
"http://localhost:8889/cookbook_artifacts/build-essential/571d8ebd02b296fe90b2e4d68754af7e8e185f28",
|
372
|
+
"identifier"=>"571d8ebd02b296fe90b2e4d68754af7e8e185f28"}]},
|
373
|
+
"java"=>
|
374
|
+
{"url"=>"http://localhost:8889/cookbook_artifacts/java",
|
375
|
+
"versions"=>
|
376
|
+
[{"url"=>
|
377
|
+
"http://localhost:8889/cookbook_artifacts/java/9178a38ad3e3baa55b49c1b8d9f4bf6a43dbc358",
|
378
|
+
"identifier"=>"9178a38ad3e3baa55b49c1b8d9f4bf6a43dbc358"}]},
|
379
|
+
"jenkins"=>
|
380
|
+
{"url"=>"http://localhost:8889/cookbook_artifacts/jenkins",
|
381
|
+
"versions"=>
|
382
|
+
[{"url"=>
|
383
|
+
"http://localhost:8889/cookbook_artifacts/jenkins/0be380429add00d189b4431059ac967a60052323",
|
384
|
+
"identifier"=>"0be380429add00d189b4431059ac967a60052323"}]}
|
385
|
+
}
|
386
|
+
end
|
387
|
+
def expect_policyfile_upload
|
388
|
+
expect(http_client).to receive(:put).
|
389
|
+
with('/policy_groups/unit-test/policies/example', policyfile_lock_data)
|
390
|
+
end
|
391
|
+
|
392
|
+
it "enables native document mode for policyfiles" do
|
393
|
+
expect(uploader.using_policy_document_native_api?).to be(true)
|
394
|
+
end
|
395
|
+
|
396
|
+
it "uploads the policyfile to the native API" do
|
397
|
+
expect(http_client).to receive(:put).
|
398
|
+
with('/policy_groups/unit-test/policies/example', policyfile_lock_data)
|
349
399
|
|
350
|
-
uploader.
|
400
|
+
uploader.upload_policy
|
351
401
|
end
|
402
|
+
|
403
|
+
include_examples "uploading cookbooks"
|
404
|
+
|
352
405
|
end
|
406
|
+
|
353
407
|
end
|
354
408
|
|
355
409
|
end
|