@@ -146,7 +146,7 @@ function checkNoVulnerabilityInRequest (vulnerability, config, done) {
146146 . catch ( done )
147147 axios . get ( `http://localhost:${ config . port } /` ) . catch ( done )
148148}
149- function checkVulnerabilityInRequest ( vulnerability , occurrencesAndLocation , cb , config , done ) {
149+ function checkVulnerabilityInRequest ( vulnerability , occurrencesAndLocation , cb , makeRequest , config , done ) {
150150 let location
151151 let occurrences = occurrencesAndLocation
152152 if ( typeof occurrencesAndLocation === 'object' ) {
@@ -195,7 +195,11 @@ function checkVulnerabilityInRequest (vulnerability, occurrencesAndLocation, cb,
195195 } )
196196 . then ( done )
197197 . catch ( done )
198- axios . get ( `http://localhost:${ config . port } /` ) . catch ( done )
198+ if ( makeRequest ) {
199+ makeRequest ( done )
200+ } else {
201+ axios . get ( `http://localhost:${ config . port } /` ) . catch ( done )
202+ }
199203}
200204
201205function prepareTestServerForIast ( description , tests , iastConfig ) {
@@ -247,7 +251,7 @@ function prepareTestServerForIast (description, tests, iastConfig) {
247251 it ( `should have ${ vulnerability } vulnerability` , function ( done ) {
248252 this . timeout ( 5000 )
249253 app = fn
250- checkVulnerabilityInRequest ( vulnerability , occurrences , cb , config , done )
254+ checkVulnerabilityInRequest ( vulnerability , occurrences , cb , undefined , config , done )
251255 } )
252256 }
253257
@@ -278,7 +282,10 @@ function prepareTestServerForIastInExpress (description, expressVersion, tests)
278282
279283 before ( ( done ) => {
280284 const express = require ( `../../../../../versions/express@${ expressVersion } ` ) . get ( )
285+ const bodyParser = require ( `../../../../../versions/body-parser` ) . get ( )
281286 const expressApp = express ( )
287+ expressApp . use ( bodyParser . json ( ) )
288+
282289 expressApp . all ( '/' , listener )
283290 getPort ( ) . then ( newPort => {
284291 config . port = newPort
@@ -300,11 +307,11 @@ function prepareTestServerForIastInExpress (description, expressVersion, tests)
300307 return agent . close ( { ritmReset : false } )
301308 } )
302309
303- function testThatRequestHasVulnerability ( fn , vulnerability , occurrences , cb ) {
310+ function testThatRequestHasVulnerability ( fn , vulnerability , occurrences , cb , makeRequest ) {
304311 it ( `should have ${ vulnerability } vulnerability` , function ( done ) {
305312 this . timeout ( 5000 )
306313 app = fn
307- checkVulnerabilityInRequest ( vulnerability , occurrences , cb , config , done )
314+ checkVulnerabilityInRequest ( vulnerability , occurrences , cb , makeRequest , config , done )
308315 } )
309316 }
310317
0 commit comments