Skip to content

Commit

Permalink
Merge pull request #4650 from thomasmichaelwallace/master
Browse files Browse the repository at this point in the history
allow authorizer.name to override implied authorizer.arn name.
  • Loading branch information
horike37 committed Jan 15, 2018
2 parents cdb1900 + 1ae4764 commit 63f15f6
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
Expand Up @@ -220,7 +220,11 @@ module.exports = {
type = 'AWS_IAM';
} else if (authorizer.arn) {
arn = authorizer.arn;
name = this.provider.naming.extractAuthorizerNameFromArn(arn);
if (_.isString(authorizer.name)) {
name = authorizer.name;
} else {
name = this.provider.naming.extractAuthorizerNameFromArn(arn);
}
} else if (authorizer.name) {
name = authorizer.name;
arn = this.getLambdaArn(name);
Expand Down
Expand Up @@ -934,6 +934,30 @@ describe('#validate()', () => {
expect(validated.events[0].http.authorizer.arn).to.equal('xxx:dev-authorizer');
});

it('should handle an authorizer.arn with an explicit authorizer.name object', () => {
awsCompileApigEvents.serverless.service.functions = {
first: {
events: [
{
http: {
path: 'foo/bar',
method: 'GET',
authorizer: {
arn: 'xxx:dev-authorizer',
name: 'custom-name',
},
},
},
],
},
};

const validated = awsCompileApigEvents.validate();
expect(validated.events).to.be.an('Array').with.length(1);
expect(validated.events[0].http.authorizer.name).to.equal('custom-name');
expect(validated.events[0].http.authorizer.arn).to.equal('xxx:dev-authorizer');
});

it('should throw an error if the provided config is not an object', () => {
awsCompileApigEvents.serverless.service.functions = {
first: {
Expand Down

0 comments on commit 63f15f6

Please sign in to comment.