@@ -368,6 +368,17 @@ def __init__(
368368 self .expected_source = expected_source
369369
370370
371+ @pytest .mark .parametrize (
372+ "data_collection, expect_query" ,
373+ [
374+ pytest .param ({}, True , id = "data_collection_default" ),
375+ pytest .param (
376+ {"url_query_params" : {"mode" : "off" }},
377+ False ,
378+ id = "data_collection_url_query_params_off" ,
379+ ),
380+ ],
381+ )
371382@pytest .mark .parametrize (
372383 "test_config" ,
373384 [
@@ -406,12 +417,14 @@ def test_transactions(
406417 sentry_init : "Any" ,
407418 app : "Any" ,
408419 capture_items : "Any" ,
420+ data_collection : "Any" ,
421+ expect_query : bool ,
409422) -> None :
410423 # Init the SanicIntegration with the desired arguments
411424 sentry_init (
412425 integrations = [SanicIntegration ()],
413426 traces_sample_rate = 1.0 ,
414- data_collection = {} ,
427+ data_collection = data_collection ,
415428 )
416429
417430 items = capture_items ("span" )
@@ -456,10 +469,16 @@ def test_transactions(
456469 "error" if test_config .expected_status >= 400 else "ok"
457470 )
458471
459- assert attrs ["url.full" ].endswith (test_config .url )
472+ expected_url = (
473+ test_config .url if expect_query else test_config .url .split ("?" , 1 )[0 ]
474+ )
475+ assert attrs ["url.full" ].endswith (expected_url )
460476 assert attrs ["url.path" ] == test_config .url .split ("?" )[0 ]
461477 if "?" in test_config .url :
462- assert attrs ["http.query" ] == test_config .url .split ("?" , 1 )[1 ]
478+ if expect_query :
479+ assert attrs ["http.query" ] == test_config .url .split ("?" , 1 )[1 ]
480+ else :
481+ assert "http.query" not in attrs
463482
464483
465484def test_span_origin (sentry_init , app , capture_items ):
@@ -561,6 +580,16 @@ def test_client_address_span_attribute_data_collection(
561580
562581
563582_QUERY_PARAM_DATA_COLLECTION_CASES = [
583+ pytest .param (
584+ {"data_collection" : {"url_query_params" : {"mode" : "denylist" , "terms" : []}}},
585+ "toy=tennisball&color=red&auth=%5BFiltered%5D" ,
586+ id = "data_collection_denylist_empty_terms" ,
587+ ),
588+ pytest .param (
589+ {"data_collection" : {"url_query_params" : {"mode" : "off" }}},
590+ None ,
591+ id = "data_collection_off" ,
592+ ),
564593 pytest .param (
565594 {"data_collection" : {}},
566595 "toy=tennisball&color=red&auth=%5BFiltered%5D" ,
@@ -593,11 +622,6 @@ def test_client_address_span_attribute_data_collection(
593622 "toy=%5BFiltered%5D&color=%5BFiltered%5D&auth=%5BFiltered%5D" ,
594623 id = "data_collection_allowlist_sensitive_term" ,
595624 ),
596- pytest .param (
597- {"data_collection" : {"url_query_params" : {"mode" : "off" }}},
598- None ,
599- id = "data_collection_off" ,
600- ),
601625]
602626
603627
0 commit comments