diff --git a/sentry_sdk/integrations/aiohttp.py b/sentry_sdk/integrations/aiohttp.py index 50eaaed816..5c05a5b08b 100644 --- a/sentry_sdk/integrations/aiohttp.py +++ b/sentry_sdk/integrations/aiohttp.py @@ -18,7 +18,7 @@ request_body_within_bounds, ) from sentry_sdk.integrations.logging import ignore_logger_for_events -from sentry_sdk.scope import Scope, should_send_default_pii +from sentry_sdk.scope import Scope from sentry_sdk.sessions import track_session from sentry_sdk.traces import ( BAGGAGE_HEADER_NAME, @@ -42,7 +42,6 @@ capture_internal_exceptions, ensure_integration_enabled, event_from_exception, - has_data_collection_enabled, logger, parse_url, parse_version, @@ -146,52 +145,28 @@ async def sentry_app_handle( url_attributes = {} client_address_attributes = {} - if has_data_collection_enabled(client.options): - url_attributes["url.full"] = "%s://%s%s" % ( - request.scheme, - request.host, - request.path, - ) - url_attributes["url.path"] = request.path - - if request.query_string: - filtered_query_string = ( - _apply_data_collection_filtering_to_query_string( - query_string=request.query_string, - behaviour=client.options["data_collection"][ - "url_query_params" - ], - ) + url_attributes["url.full"] = "%s://%s%s" % ( + request.scheme, + request.host, + request.path, + ) + url_attributes["url.path"] = request.path + + if request.query_string: + filtered_query_string = ( + _apply_data_collection_filtering_to_query_string( + query_string=request.query_string, + behaviour=client.options["data_collection"][ + "url_query_params" + ], ) - if filtered_query_string: - url_attributes["url.query"] = filtered_query_string - url_attributes["url.full"] += ( - "?" + filtered_query_string - ) - - if request.remote: - if client.options["data_collection"]["user_info"]: - client_address_attributes["client.address"] = ( - request.remote - ) - scope.set_attribute( - SPANDATA.USER_IP_ADDRESS, request.remote - ) - - elif should_send_default_pii(): - url_full = "%s://%s%s" % ( - request.scheme, - request.host, - request.path, ) - if request.query_string: - url_full += "?" + request.query_string - url_attributes["url.query"] = request.query_string + if filtered_query_string: + url_attributes["url.query"] = filtered_query_string + url_attributes["url.full"] += "?" + filtered_query_string - url_attributes["url.full"] = url_full - url_attributes["url.path"] = request.path - - if request.remote: + if request.remote: + if client.options["data_collection"]["user_info"]: client_address_attributes["client.address"] = request.remote scope.set_attribute( SPANDATA.USER_IP_ADDRESS, request.remote @@ -347,43 +322,26 @@ async def on_request_start( "http.request.method": method, } if parsed_url is not None: - if has_data_collection_enabled(client.options): - url_full = parsed_url.url - attributes["url.path"] = params.url.path - - if parsed_url.query: - filtered_query = _apply_data_collection_filtering_to_query_string( - query_string=parsed_url.query, - behaviour=client.options["data_collection"]["url_query_params"], - ) - if filtered_query: - attributes["url.query"] = filtered_query - url_full += "?" + filtered_query - breadcrumb[SPANDATA.HTTP_QUERY] = filtered_query - - if parsed_url.fragment: - attributes["url.fragment"] = parsed_url.fragment - url_full += "#" + parsed_url.fragment - breadcrumb[SPANDATA.HTTP_FRAGMENT] = parsed_url.fragment - - attributes["url.full"] = url_full - breadcrumb["url"] = url_full - - elif should_send_default_pii(): - url_full = parsed_url.url - attributes["url.path"] = params.url.path - - if parsed_url.query: - url_full += "?" + parsed_url.query - attributes["url.query"] = parsed_url.query - breadcrumb[SPANDATA.HTTP_QUERY] = parsed_url.query - if parsed_url.fragment: - url_full += "#" + parsed_url.fragment - attributes["url.fragment"] = parsed_url.fragment - breadcrumb[SPANDATA.HTTP_FRAGMENT] = parsed_url.fragment - - attributes["url.full"] = url_full - breadcrumb["url"] = url_full + url_full = parsed_url.url + attributes["url.path"] = params.url.path + + if parsed_url.query: + filtered_query = _apply_data_collection_filtering_to_query_string( + query_string=parsed_url.query, + behaviour=client.options["data_collection"]["url_query_params"], + ) + if filtered_query: + attributes["url.query"] = filtered_query + url_full += "?" + filtered_query + breadcrumb[SPANDATA.HTTP_QUERY] = filtered_query + + if parsed_url.fragment: + attributes["url.fragment"] = parsed_url.fragment + url_full += "#" + parsed_url.fragment + breadcrumb[SPANDATA.HTTP_FRAGMENT] = parsed_url.fragment + + attributes["url.full"] = url_full + breadcrumb["url"] = url_full if sentry_sdk.get_current_span() is not None: span = sentry_sdk.start_span(name=span_name, attributes=attributes) @@ -480,6 +438,7 @@ async def on_request_end( with capture_internal_exceptions(): add_http_request_source(span) + span.end() trace_config = TraceConfig() @@ -511,44 +470,26 @@ def aiohttp_processor( request.path, ) - if has_data_collection_enabled(client_options): - if request.query_string: - filtered_query_string = ( - _apply_data_collection_filtering_to_query_string( - query_string=request.query_string, - behaviour=client_options["data_collection"][ - "url_query_params" - ], - ) + if request.query_string: + filtered_query_string = ( + _apply_data_collection_filtering_to_query_string( + query_string=request.query_string, + behaviour=client_options["data_collection"]["url_query_params"], ) - if filtered_query_string: - request_info["query_string"] = filtered_query_string - else: - request_info["query_string"] = request.query_string + ) + if filtered_query_string: + request_info["query_string"] = filtered_query_string request_info["method"] = request.method + request_info["headers"] = _filter_headers(dict(request.headers)) - # REMOTE_ADDR was unconditionally set pre-data collection, so it - # continues to be set when data collection is not enabled. - if ( - not has_data_collection_enabled(client_options) - or client_options["data_collection"]["user_info"] - ): + if client_options["data_collection"]["user_info"]: request_info["env"] = {"REMOTE_ADDR": request.remote} - request_info["headers"] = _filter_headers(dict(request.headers)) # Just attach raw data here if it is within bounds, if available. # Unfortunately there's no way to get structured data from aiohttp # without awaiting on some coroutine. - if has_data_collection_enabled(client_options): - if ( - "incoming_request" - in client_options["data_collection"]["http_bodies"] - ): - request_info["data"] = get_aiohttp_request_data(request) - else: - # We never gated this prior to data collection, so it should be attached - # when data collection is not enabled. + if "incoming_request" in client_options["data_collection"]["http_bodies"]: request_info["data"] = get_aiohttp_request_data(request) return event diff --git a/tests/integrations/aiohttp/test_aiohttp.py b/tests/integrations/aiohttp/test_aiohttp.py index 39be86896f..e92992cb86 100644 --- a/tests/integrations/aiohttp/test_aiohttp.py +++ b/tests/integrations/aiohttp/test_aiohttp.py @@ -33,7 +33,7 @@ @pytest.mark.asyncio async def test_basic(sentry_init, aiohttp_client, capture_events): - sentry_init(integrations=[AioHttpIntegration()]) + sentry_init(integrations=[AioHttpIntegration()], data_collection={}) async def hello(request): 1 / 0 @@ -61,7 +61,6 @@ async def hello(request): assert request["env"] == {"REMOTE_ADDR": "127.0.0.1"} assert request["method"] == "GET" - assert request["query_string"] == "" assert request.get("data") is None assert request["url"] == "http://{host}/".format(host=host) assert request["headers"] == { @@ -78,7 +77,7 @@ async def hello(request): async def test_post_body_not_read(sentry_init, aiohttp_client, capture_events): from sentry_sdk.integrations.aiohttp import BODY_NOT_READ_MESSAGE - sentry_init(integrations=[AioHttpIntegration()]) + sentry_init(integrations=[AioHttpIntegration()], data_collection={}) body = {"some": "value"} @@ -106,7 +105,7 @@ async def hello(request): @pytest.mark.asyncio async def test_post_body_read(sentry_init, aiohttp_client, capture_events): - sentry_init(integrations=[AioHttpIntegration()]) + sentry_init(integrations=[AioHttpIntegration()], data_collection={}) body = {"some": "value"} @@ -236,7 +235,7 @@ async def hello(request): @pytest.mark.asyncio async def test_403_not_captured(sentry_init, aiohttp_client, capture_events): - sentry_init(integrations=[AioHttpIntegration()]) + sentry_init(integrations=[AioHttpIntegration()], data_collection={}) async def hello(request): raise web.HTTPForbidden() @@ -257,7 +256,7 @@ async def hello(request): async def test_cancelled_error_not_captured( sentry_init, aiohttp_client, capture_events ): - sentry_init(integrations=[AioHttpIntegration()]) + sentry_init(integrations=[AioHttpIntegration()], data_collection={}) async def hello(request): raise asyncio.CancelledError() @@ -278,8 +277,9 @@ async def hello(request): @pytest.mark.asyncio async def test_half_initialized(sentry_init, aiohttp_client, capture_events): - sentry_init(integrations=[AioHttpIntegration()]) + # Note: the first sentry_init is intentional sentry_init() + sentry_init(integrations=[AioHttpIntegration()], data_collection={}) async def hello(request): return web.Response(text="hello") @@ -302,6 +302,7 @@ async def test_tracing_unparseable_url(sentry_init, aiohttp_client, capture_item sentry_init( integrations=[AioHttpIntegration()], traces_sample_rate=1.0, + data_collection={}, ) async def hello(request): @@ -341,6 +342,7 @@ async def test_traces_sampler_gets_request_object_in_sampling_context( sentry_init( integrations=[AioHttpIntegration()], traces_sampler=traces_sampler, + data_collection={}, ) async def kangaroo_handler(request): @@ -370,6 +372,7 @@ async def test_has_trace_if_performance_enabled( sentry_init( integrations=[AioHttpIntegration()], traces_sample_rate=1.0, + data_collection={}, ) async def hello(request): @@ -420,7 +423,7 @@ async def hello(request): async def test_has_trace_if_performance_disabled( sentry_init, aiohttp_client, capture_events ): - sentry_init(integrations=[AioHttpIntegration()]) + sentry_init(integrations=[AioHttpIntegration()], data_collection={}) async def hello(request): capture_message("It's a good day to try dividing by 0") @@ -456,6 +459,7 @@ async def test_trace_from_headers_if_performance_enabled( sentry_init( integrations=[AioHttpIntegration()], traces_sample_rate=1.0, + data_collection={}, ) async def hello(request): @@ -509,7 +513,7 @@ async def hello(request): async def test_trace_from_headers_if_performance_disabled( sentry_init, aiohttp_client, capture_events ): - sentry_init(integrations=[AioHttpIntegration()]) + sentry_init(integrations=[AioHttpIntegration()], data_collection={}) async def hello(request): capture_message("It's a good day to try dividing by 0") @@ -546,8 +550,6 @@ async def hello(request): "pii_options,url_expected,query_expected", [ ({}, False, False), - ({"send_default_pii": True}, True, True), - ({"send_default_pii": False}, False, False), ( { "data_collection": { @@ -638,8 +640,6 @@ async def handler(request): "pii_options,url_expected,query_expected", [ ({}, False, False), - ({"send_default_pii": True}, True, True), - ({"send_default_pii": False}, False, False), ( { "data_collection": { @@ -723,6 +723,7 @@ async def test_outgoing_trace_headers_adds_missing_unsigned_propagation_headers( sentry_init( integrations=[AioHttpIntegration()], traces_sample_rate=1.0, + data_collection={}, ) async def handler(request): @@ -765,6 +766,7 @@ async def test_outgoing_trace_headers_appends_baggage_but_preserves_sentry_trace integrations=[AioHttpIntegration()], traces_sample_rate=1.0, release="d08ebdb9309e1b004c6f52202de58a09c2268e42", + data_collection={}, ) async def handler(request): @@ -798,6 +800,7 @@ async def test_outgoing_trace_headers_preserves_signed_propagation_headers( sentry_init( integrations=[AioHttpIntegration()], traces_sample_rate=1.0, + data_collection={}, ) async def handler(request): @@ -837,6 +840,7 @@ async def test_outgoing_trace_headers_preserves_query_signed_baggage( sentry_init( integrations=[AioHttpIntegration()], traces_sample_rate=1.0, + data_collection={}, ) async def handler(request): @@ -877,6 +881,7 @@ async def test_request_source_disabled( traces_sample_rate=1.0, enable_http_request_source=False, http_request_source_threshold_ms=0, + data_collection={}, ) # server for making span request @@ -927,6 +932,7 @@ async def test_request_source_enabled( integrations=[AioHttpIntegration()], traces_sample_rate=1.0, http_request_source_threshold_ms=0, + data_collection={}, **extra_options, ) @@ -970,6 +976,7 @@ async def test_request_source( traces_sample_rate=1.0, enable_http_request_source=True, http_request_source_threshold_ms=0, + data_collection={}, ) # server for making span request @@ -1030,6 +1037,7 @@ async def test_request_source_with_module_in_search_path( traces_sample_rate=1.0, enable_http_request_source=True, http_request_source_threshold_ms=0, + data_collection={}, ) # server for making span request @@ -1084,6 +1092,7 @@ async def test_no_request_source_if_duration_too_short( traces_sample_rate=1.0, enable_http_request_source=True, http_request_source_threshold_ms=10**10, + data_collection={}, ) # server for making span request @@ -1129,6 +1138,7 @@ async def test_request_source_if_duration_over_threshold( traces_sample_rate=1.0, enable_http_request_source=True, http_request_source_threshold_ms=0, + data_collection={}, ) # server for making span request @@ -1187,6 +1197,7 @@ async def test_span_origin( sentry_init( integrations=[AioHttpIntegration()], traces_sample_rate=1.0, + data_collection={}, ) # server for making span request @@ -1255,7 +1266,9 @@ async def test_failed_request_status_codes( exception_to_raise, should_capture, ): - sentry_init(integrations=[AioHttpIntegration(**integration_kwargs)]) + sentry_init( + integrations=[AioHttpIntegration(**integration_kwargs)], data_collection={} + ) events = capture_events() async def handle(_): @@ -1289,7 +1302,10 @@ async def test_failed_request_status_codes_with_returned_status( """ Returning a web.Response with a failed_request_status_code should not be reported to Sentry. """ - sentry_init(integrations=[AioHttpIntegration(failed_request_status_codes={500})]) + sentry_init( + integrations=[AioHttpIntegration(failed_request_status_codes={500})], + data_collection={}, + ) events = capture_events() async def handle(_): @@ -1313,7 +1329,10 @@ async def test_failed_request_status_codes_non_http_exception( If an exception, which is not an instance of HTTPException, is raised, it should be captured, even if failed_request_status_codes is empty. """ - sentry_init(integrations=[AioHttpIntegration(failed_request_status_codes=set())]) + sentry_init( + integrations=[AioHttpIntegration(failed_request_status_codes=set())], + data_collection={}, + ) events = capture_events() async def handle(_): @@ -1331,12 +1350,11 @@ async def handle(_): @pytest.mark.asyncio -@pytest.mark.parametrize("send_pii", [True, False]) -async def test_tracing(sentry_init, aiohttp_client, capture_items, send_pii): +async def test_tracing(sentry_init, aiohttp_client, capture_items): sentry_init( integrations=[AioHttpIntegration()], traces_sample_rate=1.0, - send_default_pii=send_pii, + data_collection={}, ) async def hello(request): @@ -1376,23 +1394,15 @@ async def hello(request): # Request attributes derived directly from the aiohttp request. assert server_span["attributes"]["http.request.method"] == "GET" - if send_pii: - assert "client.address" in server_span["attributes"] - assert "user.ip_address" in server_span["attributes"] + assert "client.address" in server_span["attributes"] + assert "user.ip_address" in server_span["attributes"] - url_full = server_span["attributes"]["url.full"] - assert url_full.startswith("http://127.0.0.1:") - assert url_full.endswith("/") + url_full = server_span["attributes"]["url.full"] + assert url_full.startswith("http://127.0.0.1:") + assert url_full.endswith("/") - url_path = server_span["attributes"]["url.path"] - assert url_path == "/" - else: - assert "url.full" not in server_span["attributes"] - assert "url.path" not in server_span["attributes"] - assert "url.query" not in server_span["attributes"] - - assert "client.address" not in server_span["attributes"] - assert "user.ip_address" not in server_span["attributes"] + url_path = server_span["attributes"]["url.path"] + assert url_path == "/" # aiohttp's test client always sends a Host header; we assert it propagates # into the span attributes via _filter_headers. @@ -1440,6 +1450,7 @@ async def test_sensitive_header_scrubbing(sentry_init, aiohttp_client, capture_i sentry_init( integrations=[AioHttpIntegration()], traces_sample_rate=1.0, + data_collection={}, ) async def hello(request): @@ -1479,44 +1490,18 @@ async def hello(request): @pytest.mark.parametrize( - "options,expected", + "data_collection,expected", [ pytest.param( { - "send_default_pii": True, - "data_collection": {}, - }, - { - "authorization": "[Filtered]", - "custom": "foobar", - "cookie": "[Filtered]", - }, - id="enabled_send_default_pii_redacts_auth_header_due_to_data_collection_default_settings", - ), - pytest.param( - { - "send_default_pii": False, - "data_collection": {}, - }, - { - "authorization": "[Filtered]", - "custom": "foobar", - "cookie": "[Filtered]", - }, - id="disabled_send_default_pii_redacts_auth_header_due_to_data_collection_default_settings", - ), - pytest.param( - { - "send_default_pii": False, - "data_collection": {"http_headers": {"request": {"mode": "off"}}}, + "http_headers": {"request": {"mode": "off"}}, }, None, id="data_collection_off_does_not_add_headers", ), pytest.param( { - "send_default_pii": False, - "data_collection": {"http_headers": {"request": {"mode": "allowlist"}}}, + "http_headers": {"request": {"mode": "allowlist"}}, }, { "authorization": "[Filtered]", @@ -1527,12 +1512,9 @@ async def hello(request): ), pytest.param( { - "send_default_pii": False, - "data_collection": { - "http_headers": { - "request": {"mode": "allowlist", "terms": ["Authorization"]} - } - }, + "http_headers": { + "request": {"mode": "allowlist", "terms": ["Authorization"]} + } }, { "authorization": "[Filtered]", @@ -1542,14 +1524,7 @@ async def hello(request): id="data_collection_allow_list_redacts_sensitive_terms_even_when_provided_by_user", ), pytest.param( - { - "send_default_pii": False, - "data_collection": { - "http_headers": { - "request": {"mode": "allowlist", "terms": ["custom"]} - } - }, - }, + {"http_headers": {"request": {"mode": "allowlist", "terms": ["custom"]}}}, { "authorization": "[Filtered]", "custom": "foobar", @@ -1558,14 +1533,7 @@ async def hello(request): id="data_collection_allow_list_does_not_redact_provided_term", ), pytest.param( - { - "send_default_pii": False, - "data_collection": { - "http_headers": { - "request": {"mode": "denylist", "terms": ["custom"]} - } - }, - }, + {"http_headers": {"request": {"mode": "denylist", "terms": ["custom"]}}}, { "authorization": "[Filtered]", "custom": "[Filtered]", @@ -1574,14 +1542,7 @@ async def hello(request): id="data_collection_deny_list_redacts_sensitive_terms_when_provided_by_user", ), pytest.param( - { - "send_default_pii": False, - "data_collection": { - "http_headers": { - "request": {"mode": "allowlist", "terms": ["cookie"]} - } - }, - }, + {"http_headers": {"request": {"mode": "allowlist", "terms": ["cookie"]}}}, { "authorization": "[Filtered]", "custom": "[Filtered]", @@ -1593,13 +1554,12 @@ async def hello(request): ) @pytest.mark.asyncio async def test_sensitive_header_passthrough_with_pii( - sentry_init, aiohttp_client, capture_items, options, expected, request + sentry_init, aiohttp_client, capture_items, data_collection, expected, request ): sentry_init( integrations=[AioHttpIntegration()], traces_sample_rate=1.0, - send_default_pii=options["send_default_pii"], - data_collection=options["data_collection"], + data_collection=data_collection, ) async def hello(request): @@ -1642,76 +1602,6 @@ async def hello(request): ) -@pytest.mark.asyncio -async def test_sensitive_header_passthrough_with_pii_without_data_collection( - sentry_init, aiohttp_client, capture_items -): - sentry_init( - integrations=[AioHttpIntegration()], - traces_sample_rate=1.0, - send_default_pii=True, - ) - - async def hello(request): - return web.Response(text="hello") - - app = web.Application() - app.router.add_get("/", hello) - - items = capture_items("span") - - client = await aiohttp_client(app) - await client.get("/", headers={"Authorization": "Bearer secret-token"}) - - sentry_sdk.flush() - - (server_span,) = [item.payload for item in items] - - # With send_default_pii=True, _filter_headers is a no-op and the original - # value reaches the span attribute. - assert ( - server_span["attributes"]["http.request.header.authorization"] - == "Bearer secret-token" - ) - # client.address and user.ip_address is captured under send_default_pii=True. - assert server_span["attributes"]["client.address"] == "127.0.0.1" - assert server_span["attributes"]["user.ip_address"] == "127.0.0.1" - - -@pytest.mark.asyncio -@pytest.mark.parametrize("send_pii", [True, False]) -async def test_url_query_attribute( - sentry_init, aiohttp_client, capture_items, send_pii -): - sentry_init( - integrations=[AioHttpIntegration()], - traces_sample_rate=1.0, - send_default_pii=send_pii, - ) - - async def hello(request): - return web.Response(text="hello") - - app = web.Application() - app.router.add_get("/", hello) - - items = capture_items("span") - - client = await aiohttp_client(app) - resp = await client.get("/?foo=bar&baz=qux") - assert resp.status == 200 - - sentry_sdk.flush() - - assert len(items) == 1 - (server_segment,) = [item.payload for item in items] - - if send_pii: - assert server_segment["attributes"]["url.query"] == "foo=bar&baz=qux" - else: - assert "url.query" not in server_segment["attributes"] - - @pytest.mark.asyncio @pytest.mark.parametrize( "url,transaction_style,expected_name,expected_source", @@ -1743,6 +1633,7 @@ async def test_transaction_style( sentry_init( integrations=[AioHttpIntegration(transaction_style=transaction_style)], traces_sample_rate=1.0, + data_collection={}, ) async def hello(request): @@ -1784,6 +1675,7 @@ async def test_http_route( sentry_init( integrations=[AioHttpIntegration()], traces_sample_rate=1.0, + data_collection={}, ) async def hello(request): @@ -1807,6 +1699,7 @@ async def test_server_error(sentry_init, aiohttp_client, capture_items): sentry_init( integrations=[AioHttpIntegration()], traces_sample_rate=1.0, + data_collection={}, ) async def hello(request): @@ -1845,6 +1738,7 @@ async def test_http_exception(sentry_init, aiohttp_client, capture_items): sentry_init( integrations=[AioHttpIntegration()], traces_sample_rate=1.0, + data_collection={}, ) async def hello(request): @@ -1876,6 +1770,7 @@ async def test_http_exception_ok_status_not_overridden( sentry_init( integrations=[AioHttpIntegration()], traces_sample_rate=1.0, + data_collection={}, ) async def hello(request): @@ -1967,6 +1862,7 @@ async def test_outgoing_trace_headers( sentry_init( integrations=[AioHttpIntegration()], traces_sample_rate=1.0, + data_collection={}, ) async def handler(request): @@ -2031,21 +1927,6 @@ async def hello(request): _QUERY_PARAM_DATA_COLLECTION_CASES = [ - pytest.param( - {"send_default_pii": True}, - "toy=tennisball&color=red&auth=secret", - id="send_default_pii_true", - ), - pytest.param( - {"send_default_pii": False}, - None, - id="send_default_pii_false", - ), - pytest.param( - {}, - None, - id="defaults", - ), pytest.param( {"data_collection": {}}, "toy=tennisball&color=red&auth=%5BFiltered%5D", @@ -2083,14 +1964,6 @@ async def hello(request): None, id="data_collection_off", ), - pytest.param( - { - "send_default_pii": True, - "data_collection": {"url_query_params": {"mode": "off"}}, - }, - None, - id="data_collection_wins_over_send_default_pii", - ), ] diff --git a/tests/integrations/utils.py b/tests/integrations/utils.py index 2f0cbbaff7..ab61d4955f 100644 --- a/tests/integrations/utils.py +++ b/tests/integrations/utils.py @@ -39,15 +39,9 @@ ), ] -# Shared parametrization test matrix for ``REMOTE_ADDR`` on events in -# integrations that set it unconditionally pre-data collection (tornado, sanic, -# aiohttp). Each case is ``(init_kwargs, expect_remote_addr)``: the address is -# only gated once ``data_collection`` is enabled, so the legacy -# ``send_default_pii`` cases still expect it to be collected. +# Shared parametrization test matrix for ``REMOTE_ADDR`` on events. +# Each case is ``(init_kwargs, expect_remote_addr)``. DATA_COLLECTION_REMOTE_ADDR_CASES = [ - pytest.param({}, True, id="defaults"), - pytest.param({"send_default_pii": True}, True, id="send_default_pii_true"), - pytest.param({"send_default_pii": False}, True, id="send_default_pii_false"), pytest.param({"data_collection": {}}, True, id="data_collection_default"), pytest.param( {"data_collection": {"user_info": True}}, @@ -59,14 +53,6 @@ False, id="data_collection_user_info_false", ), - pytest.param( - { - "send_default_pii": True, - "data_collection": {"user_info": False}, - }, - False, - id="data_collection_wins_over_send_default_pii", - ), ] # Shared parametrization test matrix exercising the interaction between the