Skip to content

Commit 07c6d02

Browse files
authored
chore(test): Fixing iast overhead controller flaky tests (#7607)
1 parent c69f877 commit 07c6d02

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

packages/dd-trace/test/appsec/iast/overhead-controller.integration.spec.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,7 @@ describe('IAST - overhead-controller - integration', () => {
4646
})
4747

4848
async function checkVulnerabilitiesInEndpoint (path, vulnerabilitiesAndCount, method = 'GET') {
49-
await axios.request(path, { method })
50-
51-
await agent.assertMessageReceived(({ payload }) => {
49+
const assertPromise = agent.assertMessageReceived(({ payload }) => {
5250
assert.strictEqual(payload[0][0].type, 'web')
5351
assert.strictEqual(payload[0][0].metrics['_dd.iast.enabled'], 1)
5452
assert.ok(Object.hasOwn(payload[0][0].meta, '_dd.iast.json'))
@@ -67,16 +65,24 @@ describe('IAST - overhead-controller - integration', () => {
6765
assert.strictEqual(vulnerabilities[vType], vulnerabilitiesAndCount[vType], `route: ${path} - type: ${vType}`)
6866
})
6967
}, 1000, 1, true)
68+
69+
await Promise.all([
70+
axios.request(path, { method }),
71+
assertPromise,
72+
])
7073
}
7174

7275
async function checkNoVulnerabilitiesInEndpoint (path, method = 'GET') {
73-
await axios.request(path, { method })
74-
75-
await agent.assertMessageReceived(({ payload }) => {
76+
const assertPromise = agent.assertMessageReceived(({ payload }) => {
7677
assert.strictEqual(payload[0][0].type, 'web')
7778
assert.strictEqual(payload[0][0].metrics['_dd.iast.enabled'], 1)
7879
assert.ok(!('_dd.iast.json' in payload[0][0].meta))
7980
}, 1000, 1, true)
81+
82+
await Promise.all([
83+
axios.request(path, { method }),
84+
assertPromise,
85+
])
8086
}
8187

8288
it('should report vulnerability only in the first request', async () => {

0 commit comments

Comments
 (0)