File tree Expand file tree Collapse file tree 2 files changed +17
-2
lines changed
lambdas/api-handler/src/handlers Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -123,6 +123,21 @@ describe('API Lambda handler', () => {
123123 } ) ;
124124 } ) ;
125125
126+ it ( "returns 400 if the limit parameter is zero" , async ( ) => {
127+ const event = makeApiGwEvent ( {
128+ path : "/letters" ,
129+ queryStringParameters : { limit : "0" } ,
130+ } ) ;
131+ const context = mockDeep < Context > ( ) ;
132+ const callback = jest . fn ( ) ;
133+ const result = await getLetters ( event , context , callback ) ;
134+
135+ expect ( result ) . toEqual ( {
136+ statusCode : 400 ,
137+ body : "Invalid Request: limit parameter must be a positive number not greater than 2500" ,
138+ } ) ;
139+ } ) ;
140+
126141 it ( "returns 400 if the limit parameter is out of range" , async ( ) => {
127142 const event = makeApiGwEvent ( {
128143 path : "/letters" ,
Original file line number Diff line number Diff line change @@ -67,14 +67,14 @@ export const getLetters: APIGatewayProxyHandler = async (event) => {
6767 limitNumber = maxLimit ;
6868 }
6969
70- if ( limitNumber < 0 || limitNumber > maxLimit ) {
70+ if ( limitNumber <= 0 || limitNumber > maxLimit ) {
7171 log . info ( {
7272 description : "Limit value is invalid" ,
7373 limitNumber,
7474 } ) ;
7575 return {
7676 statusCode : 400 ,
77- body : " Invalid Request: limit parameter must be a positive number not greater than 2500" ,
77+ body : ` Invalid Request: limit parameter must be a positive number not greater than ${ maxLimit } ` ,
7878 } ;
7979 }
8080
You can’t perform that action at this time.
0 commit comments