mirror of
https://github.com/serverless/serverless.git
synced 2026-01-18 14:58:43 +00:00
Merge pull request #4775 from serverless/fix-4705
Fixed a bug which you cannot deploy with lambda integration in v1.26.0
This commit is contained in:
commit
eb975ddcba
@ -78,6 +78,11 @@ module.exports = {
|
||||
http.request = this.getRequest(http);
|
||||
http.request.passThrough = this.getRequestPassThrough(http);
|
||||
http.response = this.getResponse(http);
|
||||
if (http.integration === 'AWS' && _.isEmpty(http.response)) {
|
||||
http.response = {
|
||||
statusCodes: DEFAULT_STATUS_CODES,
|
||||
};
|
||||
}
|
||||
} else if (http.integration === 'AWS_PROXY' || http.integration === 'HTTP_PROXY') {
|
||||
// show a warning when request / response config is used with AWS_PROXY (LAMBDA-PROXY)
|
||||
if (http.request) {
|
||||
|
||||
@ -1728,4 +1728,54 @@ describe('#validate()', () => {
|
||||
expect(validated.events).to.be.an('Array').with.length(1);
|
||||
expect(validated.events[0].http.request.passThrough).to.equal(undefined);
|
||||
});
|
||||
|
||||
it('should set default statusCodes to response for lambda by default', () => {
|
||||
awsCompileApigEvents.serverless.service.functions = {
|
||||
first: {
|
||||
events: [
|
||||
{
|
||||
http: {
|
||||
method: 'GET',
|
||||
path: 'users/list',
|
||||
integration: 'lambda',
|
||||
integrationMethod: 'GET',
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
const validated = awsCompileApigEvents.validate();
|
||||
expect(validated.events).to.be.an('Array').with.length(1);
|
||||
expect(validated.events[0].http.response.statusCodes).to.deep.equal({
|
||||
200: {
|
||||
pattern: '',
|
||||
},
|
||||
400: {
|
||||
pattern: '[\\s\\S]*\\[400\\][\\s\\S]*',
|
||||
},
|
||||
401: {
|
||||
pattern: '[\\s\\S]*\\[401\\][\\s\\S]*',
|
||||
},
|
||||
403: {
|
||||
pattern: '[\\s\\S]*\\[403\\][\\s\\S]*',
|
||||
},
|
||||
404: {
|
||||
pattern: '[\\s\\S]*\\[404\\][\\s\\S]*',
|
||||
},
|
||||
422: {
|
||||
pattern: '[\\s\\S]*\\[422\\][\\s\\S]*',
|
||||
},
|
||||
500: {
|
||||
pattern:
|
||||
'[\\s\\S]*(Process\\s?exited\\s?before\\s?completing\\s?request|\\[500\\])[\\s\\S]*',
|
||||
},
|
||||
502: {
|
||||
pattern: '[\\s\\S]*\\[502\\][\\s\\S]*',
|
||||
},
|
||||
504: {
|
||||
pattern: '([\\s\\S]*\\[504\\][\\s\\S]*)|(^[Task timed out].*)',
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user