From c252875932c3450aac6fe426cb5733920a965151 Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Fri, 10 Dec 2021 10:01:31 -0800 Subject: [PATCH] Verify case-insensitive TextMapGetters (#4847) * Verify case-insensitive TextMapGetters * Separate test --- .../test/base/HttpServerTest.groovy | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/testing-common/src/main/groovy/io/opentelemetry/instrumentation/test/base/HttpServerTest.groovy b/testing-common/src/main/groovy/io/opentelemetry/instrumentation/test/base/HttpServerTest.groovy index 6aa835b55e2c..67f434205dbf 100644 --- a/testing-common/src/main/groovy/io/opentelemetry/instrumentation/test/base/HttpServerTest.groovy +++ b/testing-common/src/main/groovy/io/opentelemetry/instrumentation/test/base/HttpServerTest.groovy @@ -291,8 +291,31 @@ abstract class HttpServerTest extends InstrumentationSpecification imple def traceId = "00000000000000000000000000000123" def parentId = "0000000000000456" def request = AggregatedHttpRequest.of( + // intentionally sending mixed-case "tracePARENT" to make sure that TextMapGetters are not case-sensitive request(SUCCESS, method).headers().toBuilder() - .set("traceparent", "00-" + traceId.toString() + "-" + parentId.toString() + "-01") + .set("tracePARENT", "00-" + traceId.toString() + "-" + parentId.toString() + "-01") + .build()) + def response = client.execute(request).aggregate().join() + + expect: + response.status().code() == SUCCESS.status + response.contentUtf8() == SUCCESS.body + + and: + assertTheTraces(1, traceId, parentId, "GET", SUCCESS, null, response) + + where: + method = "GET" + } + + // make sure that TextMapGetters are not case-sensitive + def "test success with uppercase TRACEPARENT header"() { + setup: + def traceId = "00000000000000000000000000000123" + def parentId = "0000000000000456" + def request = AggregatedHttpRequest.of( + request(SUCCESS, method).headers().toBuilder() + .set("TRACEPARENT", "00-" + traceId.toString() + "-" + parentId.toString() + "-01") .build()) def response = client.execute(request).aggregate().join()