Skip to content

Commit

Permalink
fix tests recursive call
Browse files Browse the repository at this point in the history
  • Loading branch information
iunanua committed Sep 23, 2024
1 parent 39bc608 commit 1c3677d
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions packages/dd-trace/test/appsec/rasp/lfi.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const { fsOperationStart, incomingHttpRequestStart } = require('../../../src/app
const { FS_OPERATION_PATH } = require('../../../src/appsec/addresses')

describe('RASP - lfi.js', () => {
let waf, datadogCore, lfi, web, blocking, appsecFsPlugin
let waf, datadogCore, lfi, web, blocking, appsecFsPlugin, config

beforeEach(() => {
datadogCore = {
Expand Down Expand Up @@ -39,7 +39,7 @@ describe('RASP - lfi.js', () => {
'./fs-plugin': appsecFsPlugin
})

const config = {
config = {
appsec: {
stackTrace: {
enabled: true,
Expand All @@ -51,8 +51,6 @@ describe('RASP - lfi.js', () => {

sinon.spy(incomingHttpRequestStart, 'subscribe')
sinon.spy(incomingHttpRequestStart, 'unsubscribe')

lfi.enable(config)
})

afterEach(() => {
Expand All @@ -62,18 +60,25 @@ describe('RASP - lfi.js', () => {

describe('enable', () => {
it('should subscribe to first http req', () => {
lfi.enable(config)

sinon.assert.calledOnce(incomingHttpRequestStart.subscribe)
})

it('should enable AppsecFsPlugin after the first request', () => {
lfi.enable(config)

incomingHttpRequestStart.publish({})

sinon.assert.calledOnceWithExactly(appsecFsPlugin.enable, 'rasp')
sinon.assert.calledOnce(incomingHttpRequestStart.unsubscribe)
})
})

describe('disable', () => {
it('should disable AppsecFsPlugin', () => {
lfi.enable(config)

lfi.disable()
sinon.assert.calledOnceWithExactly(appsecFsPlugin.disable, 'rasp')
})
Expand All @@ -85,6 +90,8 @@ describe('RASP - lfi.js', () => {
const req = {}

beforeEach(() => {
lfi.enable(config)

incomingHttpRequestStart.publish({})
})

Expand Down

0 comments on commit 1c3677d

Please sign in to comment.