@@ -12,6 +12,7 @@ import graphql.schema.GraphQLObjectType
1212import graphql.schema.GraphQLScalarType
1313import graphql.schema.GraphQLSchema
1414import io.sentry.Hint
15+ import io.sentry.HttpBodyType
1516import io.sentry.IScope
1617import io.sentry.IScopes
1718import io.sentry.KeyValueCollectionBehavior
@@ -253,6 +254,124 @@ class ExceptionReporterTest {
253254 )
254255 }
255256
257+ @Test
258+ fun `legacy options can disable outgoing response data` () {
259+ val options = SentryOptions ().also { it.maxRequestBodySize = SentryOptions .RequestSize .ALWAYS }
260+ val exceptionReporter = fixture.getSut(options)
261+
262+ exceptionReporter.captureThrowable(
263+ fixture.exception,
264+ ExceptionReporter .ExceptionDetails (
265+ fixture.scopes,
266+ fixture.instrumentationExecutionParameters,
267+ false ,
268+ ),
269+ fixture.executionResult,
270+ )
271+
272+ verify(fixture.scopes)
273+ .captureEvent(
274+ org.mockito.kotlin.check { assertNull(it.contexts.response) },
275+ any<Hint >(),
276+ )
277+ }
278+
279+ @Test
280+ fun `legacy request body size can disable outgoing response data` () {
281+ val options = SentryOptions ().also { it.isSendDefaultPii = true }
282+ val exceptionReporter = fixture.getSut(options)
283+
284+ exceptionReporter.captureThrowable(
285+ fixture.exception,
286+ ExceptionReporter .ExceptionDetails (
287+ fixture.scopes,
288+ fixture.instrumentationExecutionParameters,
289+ false ,
290+ ),
291+ fixture.executionResult,
292+ )
293+
294+ verify(fixture.scopes)
295+ .captureEvent(
296+ org.mockito.kotlin.check { assertNull(it.contexts.response) },
297+ any<Hint >(),
298+ )
299+ }
300+
301+ @Test
302+ fun `data collection response ignores legacy request body options` () {
303+ val options =
304+ SentryOptions ().also {
305+ it.maxRequestBodySize = SentryOptions .RequestSize .NONE
306+ it.dataCollection.httpBodies = setOf (HttpBodyType .OUTGOING_RESPONSE )
307+ }
308+ val exceptionReporter = fixture.getSut(options)
309+
310+ exceptionReporter.captureThrowable(
311+ fixture.exception,
312+ ExceptionReporter .ExceptionDetails (
313+ fixture.scopes,
314+ fixture.instrumentationExecutionParameters,
315+ false ,
316+ ),
317+ fixture.executionResult,
318+ )
319+
320+ verify(fixture.scopes)
321+ .captureEvent(
322+ org.mockito.kotlin.check { assertNotNull(it.contexts.response?.data) },
323+ any<Hint >(),
324+ )
325+ }
326+
327+ @Test
328+ fun `data collection can disable outgoing response data` () {
329+ val options = fixture.defaultOptions.also { it.dataCollection.httpBodies = emptySet() }
330+ val exceptionReporter = fixture.getSut(options)
331+
332+ exceptionReporter.captureThrowable(
333+ fixture.exception,
334+ ExceptionReporter .ExceptionDetails (
335+ fixture.scopes,
336+ fixture.instrumentationExecutionParameters,
337+ false ,
338+ ),
339+ fixture.executionResult,
340+ )
341+
342+ verify(fixture.scopes)
343+ .captureEvent(
344+ org.mockito.kotlin.check { assertNull(it.contexts.response) },
345+ any<Hint >(),
346+ )
347+ }
348+
349+ @Test
350+ fun `data collection namespace default enables outgoing response data` () {
351+ val options =
352+ SentryOptions ().also {
353+ it.maxRequestBodySize = SentryOptions .RequestSize .NONE
354+ it.dataCollection.cookies = KeyValueCollectionBehavior .off()
355+ }
356+ val exceptionReporter = fixture.getSut(options)
357+
358+ exceptionReporter.captureThrowable(
359+ fixture.exception,
360+ ExceptionReporter .ExceptionDetails (
361+ fixture.scopes,
362+ fixture.instrumentationExecutionParameters,
363+ false ,
364+ ),
365+ fixture.executionResult,
366+ )
367+
368+ verify(fixture.scopes)
369+ .captureEvent(
370+ org.mockito.kotlin.check { assertNotNull(it.contexts.response?.data) },
371+ any<Hint >(),
372+ )
373+ }
374+
256375 @Test
257376 fun `does not attach query or variables if sendDefaultPii is false` () {
258377 val exceptionReporter =
0 commit comments