fixed the bug resultTtlInSeconds defaults to 300 when set to 0

This commit is contained in:
horike37 2016-11-02 08:47:56 +09:00
parent b3a49d580c
commit cf441a4dbc
2 changed files with 4 additions and 3 deletions

View File

@ -51,7 +51,8 @@ module.exports = {
throw new this.serverless.classes
.Error('Please provide either an authorizer name or ARN');
}
resultTtlInSeconds = Number.parseInt(authorizer.resultTtlInSeconds, 10) || 300;
resultTtlInSeconds = Number.parseInt(authorizer.resultTtlInSeconds, 10);
resultTtlInSeconds = Number.isNaN(resultTtlInSeconds) ? 300 : resultTtlInSeconds;
identitySource = authorizer.identitySource || 'method.request.header.Authorization';
} else {
const errorMessage = [

View File

@ -108,7 +108,7 @@ describe('#compileAuthorizers()', () => {
it('should create authorizer with the given config object', () => {
awsCompileApigEvents.serverless.service.functions.first.events[0].http.authorizer = {
name: 'authorizer',
resultTtlInSeconds: 400,
resultTtlInSeconds: 0,
identitySource: 'method.request.header.Custom',
identityValidationExpression: 'regex',
};
@ -117,7 +117,7 @@ describe('#compileAuthorizers()', () => {
expect(
awsCompileApigEvents.serverless.service.provider.compiledCloudFormationTemplate
.Resources.AuthorizerApiGatewayAuthorizer.Properties.AuthorizerResultTtlInSeconds
).to.equal(400);
).to.equal(0);
expect(
awsCompileApigEvents.serverless.service.provider.compiledCloudFormationTemplate