From 61dd28c0480a05289fea1826ea11806f4738100b Mon Sep 17 00:00:00 2001 From: Rocky Ken Date: Wed, 11 Sep 2024 11:34:48 -0700 Subject: [PATCH] add unit test for non-utf8 header decoding --- .../tests/test_asgi_custom_headers.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/instrumentation/opentelemetry-instrumentation-asgi/tests/test_asgi_custom_headers.py b/instrumentation/opentelemetry-instrumentation-asgi/tests/test_asgi_custom_headers.py index f6cb05fbda..66ceb23f0b 100644 --- a/instrumentation/opentelemetry-instrumentation-asgi/tests/test_asgi_custom_headers.py +++ b/instrumentation/opentelemetry-instrumentation-asgi/tests/test_asgi_custom_headers.py @@ -130,6 +130,10 @@ async def test_http_custom_request_headers_in_span_attributes(self): (b"Regex-Test-Header-1", b"Regex Test Value 1"), (b"regex-test-header-2", b"RegexTestValue2,RegexTestValue3"), (b"My-Secret-Header", b"My Secret Value"), + ( + b"non-utf8-header", + b"Moto Z\xb2", + ), ] ) self.seed_app(self.app) @@ -147,6 +151,7 @@ async def test_http_custom_request_headers_in_span_attributes(self): "http.request.header.regex_test_header_2": ( "RegexTestValue2,RegexTestValue3", ), + "http.request.header.non_utf8_header": ("Moto Z²",), "http.request.header.my_secret_header": ("[REDACTED]",), } for span in span_list: @@ -418,7 +423,7 @@ async def test_websocket_custom_response_headers_not_in_span_attributes( SANITIZE_FIELDS_TEST_VALUE = ".*my-secret.*" -SERVER_REQUEST_TEST_VALUE = "Custom-Test-Header-1,Custom-Test-Header-2,Custom-Test-Header-3,Regex-Test-Header-.*,Regex-Invalid-Test-Header-.*,.*my-secret.*" +SERVER_REQUEST_TEST_VALUE = "Custom-Test-Header-1,Custom-Test-Header-2,Custom-Test-Header-3,Regex-Test-Header-.*,Regex-Invalid-Test-Header-.*,.*my-secret.*,non-utf8-header" SERVER_RESPONSE_TEST_VALUE = "Custom-Test-Header-1,Custom-Test-Header-2,Custom-Test-Header-3,my-custom-regex-header-.*,invalid-regex-header-.*,.*my-secret.*"