@@ -12,6 +12,7 @@ import io.sentry.IProfileConverter
1212import io.sentry.IScopes
1313import io.sentry.ITransportFactory
1414import io.sentry.Integration
15+ import io.sentry.KeyValueCollectionBehavior
1516import io.sentry.NoOpContinuousProfiler
1617import io.sentry.NoOpProfileConverter
1718import io.sentry.NoOpTransportFactory
@@ -306,6 +307,35 @@ class SentryAutoConfigurationTest {
306307 }
307308 }
308309
310+ @Test
311+ fun `data collection key value properties are applied to SentryOptions` () {
312+ contextRunner
313+ .withPropertyValues(
314+ " sentry.dsn=http://key@localhost/proj" ,
315+ " sentry.data-collection.cookies.mode=off" ,
316+ " sentry.data-collection.url-query-params.mode=allow-list" ,
317+ " sentry.data-collection.url-query-params.terms=page,sort" ,
318+ " sentry.data-collection.http-headers.request.mode=deny-list" ,
319+ " sentry.data-collection.http-headers.request.terms=forwarded,-ip" ,
320+ " sentry.data-collection.http-headers.response.mode=allow-list" ,
321+ " sentry.data-collection.http-headers.response.terms=content-type,x-request-id" ,
322+ )
323+ .run {
324+ val dataCollection = it.getBean(SentryProperties ::class .java).dataCollection
325+ assertThat(dataCollection.cookies!! .mode).isEqualTo(KeyValueCollectionBehavior .Mode .OFF )
326+ assertThat(dataCollection.urlQueryParams!! .mode)
327+ .isEqualTo(KeyValueCollectionBehavior .Mode .ALLOW_LIST )
328+ assertThat(dataCollection.urlQueryParams!! .terms).containsExactly(" page" , " sort" )
329+ assertThat(dataCollection.httpHeaders.request!! .mode)
330+ .isEqualTo(KeyValueCollectionBehavior .Mode .DENY_LIST )
331+ assertThat(dataCollection.httpHeaders.request!! .terms).containsExactly(" forwarded" , " -ip" )
332+ assertThat(dataCollection.httpHeaders.response!! .mode)
333+ .isEqualTo(KeyValueCollectionBehavior .Mode .ALLOW_LIST )
334+ assertThat(dataCollection.httpHeaders.response!! .terms)
335+ .containsExactly(" content-type" , " x-request-id" )
336+ }
337+ }
338+
309339 @Test
310340 fun `when tracePropagationTargets are not set, default is returned` () {
311341 contextRunner.withPropertyValues(" sentry.dsn=http://key@localhost/proj" ).run {
0 commit comments