mirror of
https://github.com/serverless/serverless.git
synced 2026-01-25 15:07:39 +00:00
Merge pull request #4650 from thomasmichaelwallace/master
allow authorizer.name to override implied authorizer.arn name.
This commit is contained in:
commit
63f15f6741
@ -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);
|
||||
|
||||
@ -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: {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user