@@ -302,5 +302,51 @@ export = {
302
302
// THEN
303
303
test . throws ( ( ) => api . root . addMethod ( 'GET' , integration ) , / c a n n o t s e t ' v p c L i n k ' w h e r e ' c o n n e c t i o n T y p e ' i s I N T E R N E T / ) ;
304
304
test . done ( ) ;
305
+ } ,
306
+
307
+ 'multiple integration responses can be used' ( test : Test ) { // @see https://github.com/awslabs/aws-cdk/issues/1608
308
+ // GIVEN
309
+ const stack = new cdk . Stack ( ) ;
310
+ const api = new apigateway . RestApi ( stack , 'test-api' , { deploy : false } ) ;
311
+
312
+ // WHEN
313
+ api . root . addMethod ( 'GET' , new apigateway . AwsIntegration ( {
314
+ service : 'foo-service' ,
315
+ action : 'BarAction' ,
316
+ options : {
317
+ integrationResponses : [
318
+ {
319
+ statusCode : '200' ,
320
+ responseTemplates : { 'application/json' : JSON . stringify ( { success : true } ) } ,
321
+ } ,
322
+ {
323
+ selectionPattern : 'Invalid' ,
324
+ statusCode : '503' ,
325
+ responseTemplates : { 'application/json' : JSON . stringify ( { success : false , message : 'Invalid Request' } ) } ,
326
+ }
327
+ ] ,
328
+ }
329
+ } ) ) ;
330
+
331
+ // THEN
332
+ expect ( stack ) . to ( haveResource ( 'AWS::ApiGateway::Method' , {
333
+ Integration : {
334
+ IntegrationHttpMethod : 'POST' ,
335
+ IntegrationResponses : [
336
+ {
337
+ ResponseTemplates : { 'application/json' : '{"success":true}' } ,
338
+ StatusCode : '200' ,
339
+ } ,
340
+ {
341
+ ResponseTemplates : { 'application/json' : '{"success":false,"message":"Invalid Request"}' } ,
342
+ SelectionPattern : 'Invalid' ,
343
+ StatusCode : '503' ,
344
+ }
345
+ ] ,
346
+ Type : 'AWS' ,
347
+ Uri : { 'Fn::Join' : [ '' , [ 'arn:' , { Ref : 'AWS::Partition' } , ':apigateway:' , { Ref : 'AWS::Region' } , ':foo-service:action/BarAction' ] ] }
348
+ }
349
+ } ) ) ;
350
+ test . done ( ) ;
305
351
}
306
352
} ;
0 commit comments