@@ -579,6 +579,100 @@ describe('#validateServiceProxies()', () => {
579
579
} )
580
580
} )
581
581
582
+ it ( 'should throw if "roleArn" is not a string or an AWS intrinsic "Fn::GetAtt" function' , ( ) => {
583
+ serverlessApigatewayServiceProxy . serverless . service . custom = {
584
+ apiGatewayServiceProxies : [
585
+ {
586
+ kinesis : {
587
+ path : '/kinesis' ,
588
+ streamName : 'streamName' ,
589
+ method : 'post' ,
590
+ roleArn : [ ]
591
+ }
592
+ }
593
+ ]
594
+ }
595
+
596
+ expect ( ( ) => serverlessApigatewayServiceProxy . validateServiceProxies ( ) ) . to . throw (
597
+ serverless . classes . Error ,
598
+ 'child "kinesis" fails because [child "roleArn" fails because ["roleArn" must be a string, "roleArn" must be an object]]'
599
+ )
600
+ } )
601
+
602
+ it ( 'should throw if "roleArn" is an AWS intrinsic function other than "Fn::GetAtt"' , ( ) => {
603
+ serverlessApigatewayServiceProxy . serverless . service . custom = {
604
+ apiGatewayServiceProxies : [
605
+ {
606
+ kinesis : {
607
+ path : '/kinesis' ,
608
+ streamName : 'streamName' ,
609
+ method : 'post' ,
610
+ roleArn : { Ref : 'KinesisCustomRoleId' }
611
+ }
612
+ }
613
+ ]
614
+ }
615
+
616
+ expect ( ( ) => serverlessApigatewayServiceProxy . validateServiceProxies ( ) ) . to . throw (
617
+ serverless . classes . Error ,
618
+ `child "kinesis" fails because [child "roleArn" fails because ["roleArn" must be a string, "roleArn" must be in the format "{ 'Fn::GetAtt': ['<ResourceId>', 'Arn'] }"]]`
619
+ )
620
+ } )
621
+
622
+ it ( 'should throw if "roleArn" is an AWS intrinsic "Fn::GetAtt" function for an attribute other than Arn' , ( ) => {
623
+ serverlessApigatewayServiceProxy . serverless . service . custom = {
624
+ apiGatewayServiceProxies : [
625
+ {
626
+ kinesis : {
627
+ path : '/kinesis' ,
628
+ streamName : 'streamName' ,
629
+ method : 'post' ,
630
+ roleArn : { 'Fn::GetAtt' : [ 'KinesisCustomRoleId' , 'RoleId' ] }
631
+ }
632
+ }
633
+ ]
634
+ }
635
+
636
+ expect ( ( ) => serverlessApigatewayServiceProxy . validateServiceProxies ( ) ) . to . throw (
637
+ serverless . classes . Error ,
638
+ `child "kinesis" fails because [child "roleArn" fails because ["roleArn" must be a string, "roleArn" must be in the format "{ 'Fn::GetAtt': ['<ResourceId>', 'Arn'] }"]]`
639
+ )
640
+ } )
641
+
642
+ it ( 'should not throw error if "roleArn" is a string' , ( ) => {
643
+ serverlessApigatewayServiceProxy . serverless . service . custom = {
644
+ apiGatewayServiceProxies : [
645
+ {
646
+ kinesis : {
647
+ path : '/kinesis' ,
648
+ streamName : 'streamName' ,
649
+ method : 'post' ,
650
+ roleArn : 'roleArn'
651
+ }
652
+ }
653
+ ]
654
+ }
655
+
656
+ expect ( ( ) => serverlessApigatewayServiceProxy . validateServiceProxies ( ) ) . to . not . throw ( )
657
+ } )
658
+
659
+ it ( 'should not throw error if "roleArn" is valid intrinsic function' , ( ) => {
660
+ serverlessApigatewayServiceProxy . serverless . service . custom = {
661
+ apiGatewayServiceProxies : [
662
+ {
663
+ kinesis : {
664
+ path : '/kinesis' ,
665
+ streamName : 'streamName' ,
666
+ method : 'post' ,
667
+ roleArn : { 'Fn::GetAtt' : [ 'KinesisCustomRoleId' , 'Arn' ] }
668
+ }
669
+ }
670
+ ]
671
+ }
672
+
673
+ expect ( ( ) => serverlessApigatewayServiceProxy . validateServiceProxies ( ) ) . to . not . throw ( )
674
+ } )
675
+
582
676
const proxiesToTest = [
583
677
{ proxy : 'kinesis' , props : { streamName : 'streamName' } } ,
584
678
{ proxy : 'sns' , props : { topicName : 'topicName' } }
@@ -1280,11 +1374,10 @@ describe('#validateServiceProxies()', () => {
1280
1374
} )
1281
1375
1282
1376
it ( 'should not show error if queueName is a string' , ( ) => {
1283
- serverlessApigatewayServiceProxy . validated = {
1284
- events : [
1377
+ serverlessApigatewayServiceProxy . serverless . service . custom = {
1378
+ apiGatewayServiceProxies : [
1285
1379
{
1286
- serviceName : 'sqs' ,
1287
- http : {
1380
+ sqs : {
1288
1381
queueName : 'yourQueue' ,
1289
1382
path : 'sqs' ,
1290
1383
method : 'post'
0 commit comments