@@ -38,6 +38,7 @@ describe('reporter', () => {
3838 updateRaspRequestsMetricTags : sinon . stub ( ) ,
3939 incrementWafUpdatesMetric : sinon . stub ( ) ,
4040 incrementWafRequestsMetric : sinon . stub ( ) ,
41+ updateRateLimitedMetric : sinon . stub ( ) ,
4142 getRequestMetrics : sinon . stub ( )
4243 }
4344
@@ -296,6 +297,7 @@ describe('reporter', () => {
296297 '_dd.appsec.json' : '{"triggers":[{"rule":{},"rule_matches":[{}]}]}'
297298 } )
298299 expect ( prioritySampler . setPriority ) . to . have . been . calledOnceWithExactly ( span , USER_KEEP , ASM )
300+ expect ( telemetry . updateRateLimitedMetric ) . to . not . have . been . called
299301 } )
300302
301303 it ( 'should add tags to request span' , ( ) => {
@@ -310,38 +312,43 @@ describe('reporter', () => {
310312 'network.client.ip' : '8.8.8.8'
311313 } )
312314 expect ( prioritySampler . setPriority ) . to . have . been . calledOnceWithExactly ( span , USER_KEEP , ASM )
315+ expect ( telemetry . updateRateLimitedMetric ) . to . not . have . been . called
313316 } )
314317
315318 it ( 'should not add manual.keep when rate limit is reached' , ( done ) => {
316319 const addTags = span . addTags
317- const params = { }
318320
319- expect ( Reporter . reportAttack ( '' , params ) ) . to . not . be . false
320- expect ( Reporter . reportAttack ( '' , params ) ) . to . not . be . false
321- expect ( Reporter . reportAttack ( '' , params ) ) . to . not . be . false
321+ expect ( Reporter . reportAttack ( '' ) ) . to . not . be . false
322+ expect ( Reporter . reportAttack ( '' ) ) . to . not . be . false
323+ expect ( Reporter . reportAttack ( '' ) ) . to . not . be . false
322324
323325 expect ( prioritySampler . setPriority ) . to . have . callCount ( 3 )
326+ expect ( telemetry . updateRateLimitedMetric ) . to . not . have . been . called
324327
325328 Reporter . setRateLimit ( 1 )
326329
327- expect ( Reporter . reportAttack ( '' , params ) ) . to . not . be . false
330+ expect ( Reporter . reportAttack ( '' ) ) . to . not . be . false
328331 expect ( addTags . getCall ( 3 ) . firstArg ) . to . have . property ( 'appsec.event' ) . that . equals ( 'true' )
329332 expect ( prioritySampler . setPriority ) . to . have . callCount ( 4 )
330- expect ( Reporter . reportAttack ( '' , params ) ) . to . not . be . false
333+ expect ( telemetry . updateRateLimitedMetric ) . to . not . have . been . called
334+
335+ expect ( Reporter . reportAttack ( '' ) ) . to . not . be . false
331336 expect ( addTags . getCall ( 4 ) . firstArg ) . to . have . property ( 'appsec.event' ) . that . equals ( 'true' )
332337 expect ( prioritySampler . setPriority ) . to . have . callCount ( 4 )
338+ expect ( telemetry . updateRateLimitedMetric ) . to . be . calledOnceWithExactly ( req )
333339
334340 setTimeout ( ( ) => {
335- expect ( Reporter . reportAttack ( '' , params ) ) . to . not . be . false
341+ expect ( Reporter . reportAttack ( '' ) ) . to . not . be . false
336342 expect ( prioritySampler . setPriority ) . to . have . callCount ( 5 )
343+ expect ( telemetry . updateRateLimitedMetric ) . to . be . calledOnceWithExactly ( req )
337344 done ( )
338345 } , 1020 )
339346 } )
340347
341348 it ( 'should not overwrite origin tag' , ( ) => {
342349 span . context ( ) . _tags = { '_dd.origin' : 'tracer' }
343350
344- const result = Reporter . reportAttack ( '[]' , { } )
351+ const result = Reporter . reportAttack ( '[]' )
345352 expect ( result ) . to . not . be . false
346353 expect ( web . root ) . to . have . been . calledOnceWith ( req )
347354
@@ -351,6 +358,7 @@ describe('reporter', () => {
351358 'network.client.ip' : '8.8.8.8'
352359 } )
353360 expect ( prioritySampler . setPriority ) . to . have . been . calledOnceWithExactly ( span , USER_KEEP , ASM )
361+ expect ( telemetry . updateRateLimitedMetric ) . to . not . have . been . called
354362 } )
355363
356364 it ( 'should merge attacks json' , ( ) => {
@@ -367,6 +375,7 @@ describe('reporter', () => {
367375 'network.client.ip' : '8.8.8.8'
368376 } )
369377 expect ( prioritySampler . setPriority ) . to . have . been . calledOnceWithExactly ( span , USER_KEEP , ASM )
378+ expect ( telemetry . updateRateLimitedMetric ) . to . not . have . been . called
370379 } )
371380
372381 it ( 'should call standalone sample' , ( ) => {
@@ -384,6 +393,7 @@ describe('reporter', () => {
384393 } )
385394
386395 expect ( prioritySampler . setPriority ) . to . have . been . calledOnceWithExactly ( span , USER_KEEP , ASM )
396+ expect ( telemetry . updateRateLimitedMetric ) . to . not . have . been . called
387397 } )
388398 } )
389399
0 commit comments