@@ -424,7 +424,52 @@ describe('AppSec Index', function () {
424424
425425 expect ( waf . run ) . to . have . not . been . called
426426
427- expect ( Reporter . finishRequest ) . to . have . been . calledOnceWithExactly ( req , res )
427+ expect ( Reporter . finishRequest ) . to . have . been . calledOnceWithExactly ( req , res , { } )
428+ } )
429+
430+ it ( 'should pass stored response headers to Reporter.finishRequest' , ( ) => {
431+ const req = {
432+ url : '/path' ,
433+ headers : {
434+ 'user-agent' : 'Arachni' ,
435+ host : 'localhost'
436+ } ,
437+ method : 'POST' ,
438+ socket : {
439+ remoteAddress : '127.0.0.1' ,
440+ remotePort : 8080
441+ }
442+ }
443+ const res = {
444+ getHeaders : ( ) => ( {
445+ 'content-type' : 'application/json' ,
446+ 'content-length' : 42
447+ } ) ,
448+ statusCode : 200
449+ }
450+
451+ const storedHeaders = {
452+ 'content-type' : 'text/plain' ,
453+ 'content-language' : 'en-US' ,
454+ 'content-length' : '15'
455+ }
456+
457+ web . patch ( req )
458+
459+ sinon . stub ( Reporter , 'finishRequest' )
460+ sinon . stub ( waf , 'disposeContext' )
461+
462+ responseWriteHead . publish ( {
463+ req,
464+ res,
465+ abortController : { abort : sinon . stub ( ) } ,
466+ statusCode : 200 ,
467+ responseHeaders : storedHeaders
468+ } )
469+
470+ AppSec . incomingHttpEndTranslator ( { req, res } )
471+
472+ expect ( Reporter . finishRequest ) . to . have . been . calledOnceWithExactly ( req , res , storedHeaders )
428473 } )
429474
430475 it ( 'should not propagate incoming http end data with invalid framework properties' , ( ) => {
@@ -462,7 +507,7 @@ describe('AppSec Index', function () {
462507
463508 expect ( waf . run ) . to . have . not . been . called
464509
465- expect ( Reporter . finishRequest ) . to . have . been . calledOnceWithExactly ( req , res )
510+ expect ( Reporter . finishRequest ) . to . have . been . calledOnceWithExactly ( req , res , { } )
466511 } )
467512
468513 it ( 'should propagate incoming http end data with express' , ( ) => {
@@ -512,7 +557,7 @@ describe('AppSec Index', function () {
512557 'server.request.query' : { b : '2' }
513558 }
514559 } , req )
515- expect ( Reporter . finishRequest ) . to . have . been . calledOnceWithExactly ( req , res )
560+ expect ( Reporter . finishRequest ) . to . have . been . calledOnceWithExactly ( req , res , { } )
516561 } )
517562 } )
518563
0 commit comments