|
2 | 2 |
|
3 | 3 | const { assert } = require('chai') |
4 | 4 | const { setup } = require('./utils') |
| 5 | +const { once } = require('node:events') |
5 | 6 |
|
6 | 7 | // Default settings is tested in unit tests, so we only need to test the env vars here |
7 | 8 | describe('Dynamic Instrumentation snapshot PII redaction', function () { |
8 | 9 | describe('DD_DYNAMIC_INSTRUMENTATION_REDACTED_IDENTIFIERS=foo,bar', function () { |
9 | 10 | const t = setup({ env: { DD_DYNAMIC_INSTRUMENTATION_REDACTED_IDENTIFIERS: 'foo,bar' } }) |
10 | 11 |
|
11 | | - it('should respect DD_DYNAMIC_INSTRUMENTATION_REDACTED_IDENTIFIERS', function (done) { |
| 12 | + it('should respect DD_DYNAMIC_INSTRUMENTATION_REDACTED_IDENTIFIERS', async function () { |
12 | 13 | t.triggerBreakpoint() |
13 | 14 |
|
14 | | - t.agent.on('debugger-input', ({ payload: [{ 'debugger.snapshot': { captures } }] }) => { |
15 | | - const { locals } = captures.lines[t.breakpoint.line] |
| 15 | + const promise = once(t.agent, 'debugger-input') |
16 | 16 |
|
17 | | - assert.deepPropertyVal(locals, 'foo', { type: 'string', notCapturedReason: 'redactedIdent' }) |
18 | | - assert.deepPropertyVal(locals, 'bar', { type: 'string', notCapturedReason: 'redactedIdent' }) |
19 | | - assert.deepPropertyVal(locals, 'baz', { type: 'string', value: 'c' }) |
| 17 | + t.agent.addRemoteConfig(t.generateRemoteConfig({ captureSnapshot: true })) |
20 | 18 |
|
21 | | - // existing redaction should not be impacted |
22 | | - assert.deepPropertyVal(locals, 'secret', { type: 'string', notCapturedReason: 'redactedIdent' }) |
| 19 | + const [{ payload: [{ 'debugger.snapshot': { captures } }] }] = await promise |
| 20 | + const { locals } = captures.lines[t.breakpoint.line] |
23 | 21 |
|
24 | | - done() |
25 | | - }) |
| 22 | + assert.deepPropertyVal(locals, 'foo', { type: 'string', notCapturedReason: 'redactedIdent' }) |
| 23 | + assert.deepPropertyVal(locals, 'bar', { type: 'string', notCapturedReason: 'redactedIdent' }) |
| 24 | + assert.deepPropertyVal(locals, 'baz', { type: 'string', value: 'c' }) |
26 | 25 |
|
27 | | - t.agent.addRemoteConfig(t.generateRemoteConfig({ captureSnapshot: true })) |
| 26 | + // existing redaction should not be impacted |
| 27 | + assert.deepPropertyVal(locals, 'secret', { type: 'string', notCapturedReason: 'redactedIdent' }) |
28 | 28 | }) |
29 | 29 | }) |
30 | 30 |
|
31 | 31 | describe('DD_DYNAMIC_INSTRUMENTATION_REDACTION_EXCLUDED_IDENTIFIERS=secret', function () { |
32 | 32 | const t = setup({ env: { DD_DYNAMIC_INSTRUMENTATION_REDACTION_EXCLUDED_IDENTIFIERS: 'secret' } }) |
33 | 33 |
|
34 | | - it('should respect DD_DYNAMIC_INSTRUMENTATION_REDACTED_IDENTIFIERS', function (done) { |
| 34 | + it('should respect DD_DYNAMIC_INSTRUMENTATION_REDACTED_IDENTIFIERS', async function () { |
35 | 35 | t.triggerBreakpoint() |
36 | 36 |
|
37 | | - t.agent.on('debugger-input', ({ payload: [{ 'debugger.snapshot': { captures } }] }) => { |
38 | | - const { locals } = captures.lines[t.breakpoint.line] |
| 37 | + const promise = once(t.agent, 'debugger-input') |
39 | 38 |
|
40 | | - assert.deepPropertyVal(locals, 'secret', { type: 'string', value: 'shh!' }) |
41 | | - assert.deepPropertyVal(locals, 'password', { type: 'string', notCapturedReason: 'redactedIdent' }) |
| 39 | + t.agent.addRemoteConfig(t.generateRemoteConfig({ captureSnapshot: true })) |
42 | 40 |
|
43 | | - done() |
44 | | - }) |
| 41 | + const [{ payload: [{ 'debugger.snapshot': { captures } }] }] = await promise |
| 42 | + const { locals } = captures.lines[t.breakpoint.line] |
45 | 43 |
|
46 | | - t.agent.addRemoteConfig(t.generateRemoteConfig({ captureSnapshot: true })) |
| 44 | + assert.deepPropertyVal(locals, 'secret', { type: 'string', value: 'shh!' }) |
| 45 | + assert.deepPropertyVal(locals, 'password', { type: 'string', notCapturedReason: 'redactedIdent' }) |
47 | 46 | }) |
48 | 47 | }) |
49 | 48 | }) |
0 commit comments