Add more tests to OpenTelemetryResourceAttributesTests

Add tests for decoding percent-encoded strings with non-ASCII characters
and multi-byte sequences.

See gh-44944

Signed-off-by: Dmytro Nosan <dimanosan@gmail.com>
This commit is contained in:
Dmytro Nosan 2025-03-29 16:49:36 +02:00 committed by Moritz Halbritter
parent db3208460d
commit 094c962bbc
1 changed files with 16 additions and 0 deletions

View File

@ -117,6 +117,22 @@ class OpenTelemetryResourceAttributesTests {
.containsEntry("key", value);
}
@Test
void otelResourceAttributeValuesShouldBePercentDecodedWhenStringContainsNonAscii() {
this.environmentVariables.put("OTEL_RESOURCE_ATTRIBUTES", "key=%20\u015bp\u0159\u00ec\u0144\u0121%20");
assertThat(getAttributes()).hasSize(2)
.containsEntry("service.name", "unknown_service")
.containsEntry("key", " śpřìńġ ");
}
@Test
void otelResourceAttributeValuesShouldBePercentDecodedWhenMultiByteSequences() {
this.environmentVariables.put("OTEL_RESOURCE_ATTRIBUTES", "key=T%C5%8Dky%C5%8D");
assertThat(getAttributes()).hasSize(2)
.containsEntry("service.name", "unknown_service")
.containsEntry("key", "Tōkyō");
}
@Test
void illegalArgumentExceptionShouldBeThrownWhenDecodingIllegalHexCharPercentEncodedValue() {
this.environmentVariables.put("OTEL_RESOURCE_ATTRIBUTES", "key=abc%ß");