|
1 | 1 | import { afterAll, describe, expect, test } from 'vitest'; |
2 | 2 | import { cleanupChildProcesses, createRunner } from '../../../utils/runner'; |
| 3 | +import { assertSentryTransaction } from '../../../utils/assertions'; |
3 | 4 |
|
4 | 5 | describe('express tracing', () => { |
5 | 6 | afterAll(() => { |
@@ -244,6 +245,34 @@ describe('express tracing', () => { |
244 | 245 | }); |
245 | 246 | await runner.completed(); |
246 | 247 | }); |
| 248 | + |
| 249 | + test('correctly ignores request data', async () => { |
| 250 | + const runner = createRunner(__dirname, 'server.js') |
| 251 | + .expect({ |
| 252 | + transaction: e => { |
| 253 | + assertSentryTransaction(e, { |
| 254 | + transaction: 'POST /test-post-ignore-body', |
| 255 | + request: { |
| 256 | + url: expect.stringMatching(/^http:\/\/localhost:(\d+)\/test-post-ignore-body$/), |
| 257 | + method: 'POST', |
| 258 | + headers: { |
| 259 | + 'user-agent': expect.stringContaining(''), |
| 260 | + 'content-type': 'application/octet-stream', |
| 261 | + }, |
| 262 | + }, |
| 263 | + }); |
| 264 | + // Ensure the request body has been ignored |
| 265 | + expect(e).have.property('request').that.does.not.have.property('data'); |
| 266 | + }, |
| 267 | + }) |
| 268 | + .start(); |
| 269 | + |
| 270 | + runner.makeRequest('post', '/test-post-ignore-body', { |
| 271 | + headers: { 'Content-Type': 'application/octet-stream' }, |
| 272 | + data: Buffer.from('some plain text in buffer'), |
| 273 | + }); |
| 274 | + await runner.completed(); |
| 275 | + }); |
247 | 276 | }); |
248 | 277 | }); |
249 | 278 | }); |
0 commit comments