@@ -152,4 +152,55 @@ describe('#compileHttpLambdaPermissions()', () => {
152152 } ) ;
153153 } ) ;
154154 } ) ;
155+
156+ it ( 'should create a Lambda Permission resource when there is an ARN authorizer' , ( ) => {
157+ serverlessStepFunctions . serverless . service . provider
158+ . compiledCloudFormationTemplate . Resources . HelloApiGatewayAuthorizer = {
159+ Type : 'AWS::ApiGateway::Authorizer' ,
160+ Properties : {
161+ AuthorizerResultTtlInSeconds : 300 ,
162+ IdentitySource : 'method.request.header.Authorization' ,
163+ Name : 'hello' ,
164+ RestApiId : {
165+ Ref : 'ApiGatewayRestApi' ,
166+ } ,
167+ AuthorizerUri : {
168+ 'Fn::Join' : [
169+ '' ,
170+ [
171+ 'arn:' ,
172+ {
173+ Ref : 'AWS::Partition' ,
174+ } ,
175+ ':apigateway:' ,
176+ {
177+ Ref : 'AWS::Region' ,
178+ } ,
179+ ':lambda:path/2015-03-31/functions/' ,
180+ 'arn:aws:lambda:us-east-1:000000000000:function:remote-authorizer' ,
181+ '/invocations' ,
182+ ] ,
183+ ] ,
184+ } ,
185+ Type : 'TOKEN' ,
186+ } ,
187+ } ;
188+
189+ serverlessStepFunctions . compileHttpLambdaPermissions ( ) . then ( ( ) => {
190+ const resources = serverlessStepFunctions . serverless . service . provider
191+ . compiledCloudFormationTemplate . Resources ;
192+ const lambdaPermissions = _ . values ( resources ) . filter ( x => x . Type === 'AWS::Lambda::Permission' ) ;
193+ expect ( lambdaPermissions ) . to . have . lengthOf ( 1 ) ;
194+ expect ( lambdaPermissions [ 0 ] ) . to . deep . eq ( {
195+ Type : 'AWS::Lambda::Permission' ,
196+ Properties : {
197+ FunctionName : 'arn:aws:lambda:us-east-1:000000000000:function:remote-authorizer' ,
198+ Action : 'lambda:InvokeFunction' ,
199+ Principal : {
200+ 'Fn::Sub' : 'apigateway.${AWS::URLSuffix}' ,
201+ } ,
202+ } ,
203+ } ) ;
204+ } ) ;
205+ } ) ;
155206} ) ;
0 commit comments