mirror of
https://github.com/serverless/serverless.git
synced 2026-01-25 15:07:39 +00:00
update test coverage, fixed typo
update test coverage update test coverage add api gateway authorizer with authorizeId
This commit is contained in:
parent
c90486d50f
commit
eac5ab5f04
@ -13,6 +13,15 @@ module.exports = {
|
||||
}
|
||||
|
||||
if (http.authorizer) {
|
||||
if (http.authorizer.type && http.authorizer.authorizerId) {
|
||||
return {
|
||||
Properties: {
|
||||
AuthorizationType: http.authorizer.type,
|
||||
AuthorizerId: http.authorizer.authorizerId,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
const authorizerLogicalId = this.provider.naming
|
||||
.getAuthorizerLogicalId(http.authorizer.name);
|
||||
|
||||
|
||||
@ -314,6 +314,32 @@ describe('#compileMethods()', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('should set custom authorizer config with authorizeId', () => {
|
||||
awsCompileApigEvents.validated.events = [
|
||||
{
|
||||
functionName: 'First',
|
||||
http: {
|
||||
path: 'users/create',
|
||||
method: 'post',
|
||||
authorizer: {
|
||||
type: 'COGNITO_USER_POOLS',
|
||||
authorizerId: 'gy7lyj',
|
||||
},
|
||||
},
|
||||
},
|
||||
];
|
||||
return awsCompileApigEvents.compileMethods().then(() => {
|
||||
expect(
|
||||
awsCompileApigEvents.serverless.service.provider.compiledCloudFormationTemplate
|
||||
.Resources.ApiGatewayMethodUsersCreatePost.Properties.AuthorizationType
|
||||
).to.equal('COGNITO_USER_POOLS');
|
||||
expect(
|
||||
awsCompileApigEvents.serverless.service.provider.compiledCloudFormationTemplate
|
||||
.Resources.ApiGatewayMethodUsersCreatePost.Properties.AuthorizerId
|
||||
).to.equal('gy7lyj');
|
||||
});
|
||||
});
|
||||
|
||||
it('should set authorizer config if given as ARN string', () => {
|
||||
awsCompileApigEvents.validated.events = [
|
||||
{
|
||||
@ -322,6 +348,7 @@ describe('#compileMethods()', () => {
|
||||
authorizer: {
|
||||
name: 'Authorizer',
|
||||
},
|
||||
integration: 'AWS',
|
||||
path: 'users/create',
|
||||
method: 'post',
|
||||
},
|
||||
|
||||
@ -227,6 +227,7 @@ module.exports = {
|
||||
let resultTtlInSeconds;
|
||||
let identityValidationExpression;
|
||||
let claims;
|
||||
let authorizerId;
|
||||
|
||||
if (typeof authorizer === 'string') {
|
||||
if (authorizer.toUpperCase() === 'AWS_IAM') {
|
||||
@ -239,7 +240,10 @@ module.exports = {
|
||||
name = this.provider.naming.extractAuthorizerNameFromArn(arn);
|
||||
}
|
||||
} else if (typeof authorizer === 'object') {
|
||||
if (authorizer.type && authorizer.type.toUpperCase() === 'AWS_IAM') {
|
||||
if (authorizer.type && authorizer.authorizerId) {
|
||||
type = authorizer.type;
|
||||
authorizerId = authorizer.authorizerId;
|
||||
} else if (authorizer.type && authorizer.type.toUpperCase() === 'AWS_IAM') {
|
||||
type = 'AWS_IAM';
|
||||
} else if (authorizer.arn) {
|
||||
arn = authorizer.arn;
|
||||
@ -284,6 +288,7 @@ module.exports = {
|
||||
type,
|
||||
name,
|
||||
arn,
|
||||
authorizerId,
|
||||
resultTtlInSeconds,
|
||||
identitySource,
|
||||
identityValidationExpression,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user