@@ -412,7 +412,7 @@ describe('#validateServiceProxies()', () => {
412412 expect ( json . events [ 0 ] . http . cors . methods ) . to . deep . equal ( [ 'POST' , 'OPTIONS' ] )
413413 } )
414414
415- it ( 'should throw if "authorizationType" is not a string' , async ( ) => {
415+ it ( 'should throw if "authorizationType" is not a string' , ( ) => {
416416 serverlessApigatewayServiceProxy . serverless . service . custom = {
417417 apiGatewayServiceProxies : [
418418 {
@@ -581,7 +581,7 @@ describe('#validateServiceProxies()', () => {
581581 const proxiesToTest = [
582582 { proxy : 'kinesis' , props : { streamName : 'streamName' } } ,
583583 { proxy : 's3' , props : { bucket : 'bucket' , action : 'PutObject' , key : 'myKey' } } ,
584- { proxy : 'sns' , props : { } }
584+ { proxy : 'sns' , props : { topicName : 'topicName' } }
585585 ]
586586 proxiesToTest . forEach ( ( { proxy, props } ) => {
587587 it ( `should throw if requestParameters is set for ${ proxy } ` , ( ) => {
@@ -851,6 +851,115 @@ describe('#validateServiceProxies()', () => {
851851 } )
852852 } )
853853
854+ describe ( 'sns' , ( ) => {
855+ it ( 'should throw error if the "topicName" property doesn\'t exist' , ( ) => {
856+ serverlessApigatewayServiceProxy . serverless . service . custom = {
857+ apiGatewayServiceProxies : [
858+ {
859+ sns : {
860+ path : 'sns' ,
861+ method : 'post'
862+ }
863+ }
864+ ]
865+ }
866+
867+ expect ( ( ) => serverlessApigatewayServiceProxy . validateServiceProxies ( ) ) . to . throw (
868+ serverless . classes . Error ,
869+ 'child "sns" fails because [child "topicName" fails because ["topicName" is required]]'
870+ )
871+ } )
872+
873+ it ( 'should throw error if the "topicName" property is not a string or an AWS intrinsic function' , ( ) => {
874+ serverlessApigatewayServiceProxy . serverless . service . custom = {
875+ apiGatewayServiceProxies : [
876+ {
877+ sns : {
878+ path : 'sns' ,
879+ method : 'post' ,
880+ topicName : [ 'xx' , 'yy' ]
881+ }
882+ }
883+ ]
884+ }
885+
886+ expect ( ( ) => serverlessApigatewayServiceProxy . validateServiceProxies ( ) ) . to . throw (
887+ serverless . classes . Error ,
888+ 'child "sns" fails because [child "topicName" fails because ["topicName" must be a string, "topicName" must be an object]]'
889+ )
890+ } )
891+
892+ it ( 'should throw error if the "topicName" property is missing the AWS intrinsic function "Fn::GetAtt"' , ( ) => {
893+ serverlessApigatewayServiceProxy . serverless . service . custom = {
894+ apiGatewayServiceProxies : [
895+ {
896+ sns : {
897+ path : 'sns' ,
898+ method : 'post' ,
899+ topicName : { xxx : 'SNSResourceId' }
900+ }
901+ }
902+ ]
903+ }
904+
905+ expect ( ( ) => serverlessApigatewayServiceProxy . validateServiceProxies ( ) ) . to . throw (
906+ serverless . classes . Error ,
907+ `child "sns" fails because [child "topicName" fails because ["topicName" must be a string, "topicName" must be in the format "{ 'Fn::GetAtt': ['<ResourceId>', 'TopicName'] }"]]`
908+ )
909+ } )
910+
911+ it ( 'should throw error if the "topicName" property is an intrinsic function "Fn::GetAtt" but specifies a property other than TopicName' , ( ) => {
912+ serverlessApigatewayServiceProxy . serverless . service . custom = {
913+ apiGatewayServiceProxies : [
914+ {
915+ sns : {
916+ path : 'sns' ,
917+ method : 'post' ,
918+ topicName : { 'Fn::GetAtt' : [ 'SNSResourceId' , 'Arn' ] }
919+ }
920+ }
921+ ]
922+ }
923+
924+ expect ( ( ) => serverlessApigatewayServiceProxy . validateServiceProxies ( ) ) . to . throw (
925+ serverless . classes . Error ,
926+ `child "sns" fails because [child "topicName" fails because ["topicName" must be a string, "topicName" must be in the format "{ 'Fn::GetAtt': ['<ResourceId>', 'TopicName'] }"]]`
927+ )
928+ } )
929+
930+ it ( 'should not show error if topicName is valid string' , ( ) => {
931+ serverlessApigatewayServiceProxy . serverless . service . custom = {
932+ apiGatewayServiceProxies : [
933+ {
934+ sns : {
935+ path : 'sns' ,
936+ method : 'post' ,
937+ topicName : 'someTopicName'
938+ }
939+ }
940+ ]
941+ }
942+
943+ expect ( ( ) => serverlessApigatewayServiceProxy . validateServiceProxies ( ) ) . to . not . throw ( )
944+ } )
945+
946+ it ( 'should not show error if topicName is valid intrinsic function' , ( ) => {
947+ serverlessApigatewayServiceProxy . serverless . service . custom = {
948+ apiGatewayServiceProxies : [
949+ {
950+ sns : {
951+ path : 'sns' ,
952+ method : 'post' ,
953+ topicName : { 'Fn::GetAtt' : [ 'SNSResourceId' , 'TopicName' ] }
954+ }
955+ }
956+ ]
957+ }
958+
959+ expect ( ( ) => serverlessApigatewayServiceProxy . validateServiceProxies ( ) ) . to . not . throw ( )
960+ } )
961+ } )
962+
854963 describe ( 'sqs' , ( ) => {
855964 it ( 'should throw if requestParameters is not a string to string' , ( ) => {
856965 serverlessApigatewayServiceProxy . serverless . service . custom = {
0 commit comments