@@ -306,6 +306,31 @@ describe('input-validation middleware tests', function () {
306306 } ) ;
307307 } ) ;
308308 } ) ;
309+ describe ( 'additionalProperties flag false' , function ( ) {
310+ it ( 'invalid update when body contains properties which are not in schema' , function ( done ) {
311+ request ( app )
312+ . put ( '/dog/1' )
313+ . set ( 'public-key' , '1.0' )
314+ . send ( {
315+ max_length : '10' ,
316+ min_length : '5' ,
317+ additional1 : '1' ,
318+ additional2 : '2'
319+ } )
320+ . expect ( 400 , function ( err , res ) {
321+ if ( err ) {
322+ throw err ;
323+ }
324+ expect ( res . body ) . to . eql ( {
325+ 'more_info' : JSON . stringify (
326+ [
327+ "body should NOT have additional properties 'additional1'" ,
328+ "body should NOT have additional properties 'additional2'" ] )
329+ } ) ;
330+ done ( ) ;
331+ } ) ;
332+ } ) ;
333+ } ) ;
309334 describe . skip ( 'discriminator pet type is not on the root, only on child' , function ( ) {
310335 // does not support wright now.
311336 } ) ;
@@ -334,5 +359,28 @@ describe('input-validation middleware tests', function () {
334359 done ( ) ;
335360 } ) ;
336361 } ) ;
362+ describe ( 'additionalProperties flag false' , function ( ) {
363+ it ( 'invalid update when body contains properties which are not in schema' , function ( done ) {
364+ request ( app )
365+ . put ( '/dog/1' )
366+ . set ( 'public-key' , '1.0' )
367+ . send ( {
368+ max_length : '10' ,
369+ min_length : '5' ,
370+ additional1 : '1' ,
371+ additional2 : '2'
372+ } )
373+ . expect ( 400 , function ( err , res ) {
374+ if ( err ) {
375+ throw err ;
376+ }
377+ expect ( res . body ) . to . eql ( {
378+ 'more_info' : JSON . stringify (
379+ "body should NOT have additional properties 'additional1'" )
380+ } ) ;
381+ done ( ) ;
382+ } ) ;
383+ } ) ;
384+ } ) ;
337385 } ) ;
338386} ) ;
0 commit comments