@@ -148,10 +148,8 @@ def generate_signed_message_for(map)
148
148
File . stubs ( :open ) . with ( @last_successful_install_file_location )
149
149
150
150
@app_spec = mock ( "parsed application specification" )
151
- File .
152
- stubs ( :read ) .
153
- with ( "#@archive_root_dir /appspec.yml" ) .
154
- returns ( "APP SPEC" )
151
+ File . stubs ( :exist? ) . with ( "#@archive_root_dir /appspec.yml" ) . returns ( true )
152
+ File . stubs ( :read ) . with ( "#@archive_root_dir /appspec.yml" ) . returns ( "APP SPEC" )
155
153
ApplicationSpecification ::ApplicationSpecification . stubs ( :parse ) . with ( "APP SPEC" ) . returns ( @app_spec )
156
154
end
157
155
@@ -234,6 +232,91 @@ def generate_signed_message_for(map)
234
232
@command_executor . execute_command ( @command , deployment_spec )
235
233
end
236
234
end
235
+
236
+ should 'honor the AppSpecPath command variable' do
237
+ deployment_spec = generate_signed_message_for ( {
238
+ "DeploymentId" => @deployment_id . to_s ,
239
+ "DeploymentGroupId" => @deployment_group_id ,
240
+ "ApplicationName" => @application_name ,
241
+ "DeploymentGroupName" => @deployment_group_name ,
242
+ "DeploymentCreator" => @deployment_creator ,
243
+ "DeploymentType" => @deployment_type ,
244
+ "AgentActionOverrides" => @agent_actions_overrides ,
245
+ "AppSpecPath" => "appspec-override.yaml" ,
246
+ "Revision" => {
247
+ "RevisionType" => "S3" ,
248
+ "S3Revision" => @s3Revision
249
+ }
250
+ } )
251
+
252
+ File . expects ( :exist? ) . with ( "#@archive_root_dir /appspec-override.yaml" ) . returns ( true )
253
+ File . expects ( :read ) . with ( "#@archive_root_dir /appspec-override.yaml" ) . returns ( "APP SPEC" )
254
+ @command_executor . execute_command ( @command , deployment_spec )
255
+ end
256
+
257
+ should 'fallback to appspec.yaml if provided AppSpecPath variable points to a file which does\'t exist' do
258
+ deployment_spec = generate_signed_message_for ( {
259
+ "DeploymentId" => @deployment_id . to_s ,
260
+ "DeploymentGroupId" => @deployment_group_id ,
261
+ "ApplicationName" => @application_name ,
262
+ "DeploymentGroupName" => @deployment_group_name ,
263
+ "DeploymentCreator" => @deployment_creator ,
264
+ "DeploymentType" => @deployment_type ,
265
+ "AgentActionOverrides" => @agent_actions_overrides ,
266
+ "AppSpecPath" => "appspec-override.yaml" ,
267
+ "Revision" => {
268
+ "RevisionType" => "S3" ,
269
+ "S3Revision" => @s3Revision
270
+ }
271
+ } )
272
+
273
+ File . expects ( :exist? ) . with ( "#@archive_root_dir /appspec-override.yaml" ) . returns ( false )
274
+ File . expects ( :exist? ) . with ( "#@archive_root_dir /appspec.yaml" ) . returns ( true )
275
+ File . expects ( :read ) . with ( "#@archive_root_dir /appspec.yaml" ) . returns ( "APP SPEC" )
276
+ @command_executor . execute_command ( @command , deployment_spec )
277
+ end
278
+ should 'fallback to appspec.yaml if both AppSpecPath variable and appspec.yaml don\'t exist' do
279
+ deployment_spec = generate_signed_message_for ( {
280
+ "DeploymentId" => @deployment_id . to_s ,
281
+ "DeploymentGroupId" => @deployment_group_id ,
282
+ "ApplicationName" => @application_name ,
283
+ "DeploymentGroupName" => @deployment_group_name ,
284
+ "DeploymentCreator" => @deployment_creator ,
285
+ "DeploymentType" => @deployment_type ,
286
+ "AgentActionOverrides" => @agent_actions_overrides ,
287
+ "AppSpecPath" => "appspec-override.yaml" ,
288
+ "Revision" => {
289
+ "RevisionType" => "S3" ,
290
+ "S3Revision" => @s3Revision
291
+ }
292
+ } )
293
+
294
+ File . expects ( :exist? ) . with ( "#@archive_root_dir /appspec-override.yaml" ) . returns ( false )
295
+ File . expects ( :exist? ) . with ( "#@archive_root_dir /appspec.yaml" ) . returns ( false )
296
+ File . expects ( :read ) . with ( "#@archive_root_dir /appspec.yml" ) . returns ( "APP SPEC" )
297
+ @command_executor . execute_command ( @command , deployment_spec )
298
+ end
299
+
300
+ should 'fallback to appspec.yaml if appspec.yml is not there and no AppSpecPath arg is specified' do
301
+ deployment_spec = generate_signed_message_for ( {
302
+ "DeploymentId" => @deployment_id . to_s ,
303
+ "DeploymentGroupId" => @deployment_group_id ,
304
+ "ApplicationName" => @application_name ,
305
+ "DeploymentGroupName" => @deployment_group_name ,
306
+ "DeploymentCreator" => @deployment_creator ,
307
+ "DeploymentType" => @deployment_type ,
308
+ "AgentActionOverrides" => @agent_actions_overrides ,
309
+ "Revision" => {
310
+ "RevisionType" => "S3" ,
311
+ "S3Revision" => @s3Revision
312
+ }
313
+ } )
314
+
315
+ File . expects ( :exist? ) . with ( "#@archive_root_dir /appspec.yml" ) . returns ( false )
316
+ File . expects ( :exist? ) . with ( "#@archive_root_dir /appspec.yaml" ) . returns ( true )
317
+ File . expects ( :read ) . with ( "#@archive_root_dir /appspec.yaml" ) . returns ( "APP SPEC" )
318
+ @command_executor . execute_command ( @command , deployment_spec )
319
+ end
237
320
end
238
321
239
322
context "when executing the DownloadBundle command" do
@@ -317,36 +400,36 @@ def generate_signed_message_for(map)
317
400
end
318
401
319
402
context "when creating S3 options" do
320
-
403
+
321
404
should "use right region" do
322
405
assert_equal 'us-east-1' , @command_executor . s3_options [ :region ]
323
406
end
324
-
325
- should "use right signature version" do
407
+
408
+ should "use right signature version" do
326
409
assert_equal 'v4' , @command_executor . s3_options [ :signature_version ]
327
410
end
328
-
411
+
329
412
should "use right endpoint when using Fips" do
330
413
InstanceAgent ::Config . config [ :use_fips_mode ] = true
331
414
assert_equal 'https://s3-fips.us-east-1.amazonaws.com' , @command_executor . s3_options [ :endpoint ]
332
415
InstanceAgent ::Config . config [ :use_fips_mode ] = false
333
416
end
334
-
417
+
335
418
should "use right endpoint when using endpoint override" do
336
419
s3_endpoint_override_url = 'htpp://testendpointoverride'
337
420
InstanceAgent ::Config . config [ :s3_endpoint_override ] = s3_endpoint_override_url
338
421
assert_equal s3_endpoint_override_url , @command_executor . s3_options [ :endpoint ] . to_s
339
422
InstanceAgent ::Config . config [ :s3_endpoint_override ] = nil
340
423
end
341
-
424
+
342
425
should "use no endpoint when neither using Fips nor Endpoint override" do
343
426
InstanceAgent ::Config . config [ :s3_endpoint_override ] = nil
344
427
InstanceAgent ::Config . config [ :use_fips_mode ] = false
345
428
assert_false @command_executor . s3_options . include? :endpoint
346
429
end
347
-
430
+
348
431
end
349
-
432
+
350
433
context "downloading bundle from S3" do
351
434
setup do
352
435
File . expects ( :open ) . with ( File . join ( @deployment_root_dir , 'bundle.tar' ) , 'wb' ) . yields ( @mock_file )
@@ -598,7 +681,7 @@ def generate_signed_message_for(map)
598
681
:deployment_group_id => @deployment_group_id ,
599
682
:deployment_creator => @deployment_creator ,
600
683
:deployment_type => @deployment_type ,
601
- :deployment_root_dir => @deployment_root_dir ,
684
+ :deployment_root_dir => @deployment_root_dir ,
602
685
:last_successful_deployment_dir => nil ,
603
686
:most_recent_deployment_dir => nil ,
604
687
:app_spec_path => 'appspec.yml' }
0 commit comments