-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathtest.ts
More file actions
55 lines (48 loc) · 2.02 KB
/
test.ts
File metadata and controls
55 lines (48 loc) · 2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import { afterAll, expect, test } from 'vitest';
import { conditionalTest } from '../../../utils';
import { cleanupChildProcesses, createRunner } from '../../../utils/runner';
afterAll(() => {
cleanupChildProcesses();
});
conditionalTest({ min: 22 })('light mode ipAddress handling', () => {
test('does not include ip_address on events when sendDefaultPii is not set', async () => {
const runner = createRunner(__dirname, 'without-sendDefaultPii/server.js')
.expect({
event: event => {
expect(event.exception?.values?.[0]?.value).toBe('test error');
expect(event.user?.ip_address).toBeUndefined();
},
})
.start();
runner.makeRequest('get', '/test-error');
await runner.completed();
});
test('includes ip_address on events when sendDefaultPii is true', async () => {
const runner = createRunner(__dirname, 'with-sendDefaultPii/server.js')
.expect({
event: event => {
expect(event.exception?.values?.[0]?.value).toBe('test error');
expect(event.user?.ip_address).toBeDefined();
},
})
.start();
runner.makeRequest('get', '/test-error');
await runner.completed();
});
// Even with sendDefaultPii: true, if requestDataIntegration is removed, ipAddress should not
// leak onto the event. The ipAddress is stored in sdkProcessingMetadata on the isolation scope,
// and only requestDataIntegration promotes it to event.user.ip_address. Without it,
// sdkProcessingMetadata is stripped before envelope serialization (in envelope.ts).
test('does not include ip_address on events when requestDataIntegration is removed', async () => {
const runner = createRunner(__dirname, 'without-requestDataIntegration/server.js')
.expect({
event: event => {
expect(event.exception?.values?.[0]?.value).toBe('test error');
expect(event.user?.ip_address).toBeUndefined();
},
})
.start();
runner.makeRequest('get', '/test-error');
await runner.completed();
});
});