Skip to content

Commit e321134

Browse files
committed
Add more tests to OpenTelemetryResourceAttributesTests
Add tests for decoding percent-encoded strings with non-ASCII characters and multi-byte sequences. Signed-off-by: Dmytro Nosan <[email protected]>
1 parent faef7d5 commit e321134

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/opentelemetry/OpenTelemetryResourceAttributesTests.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,22 @@ void otelResourceAttributeValuesShouldBePercentDecoded() {
117117
.containsEntry("key", value);
118118
}
119119

120+
@Test
121+
void otelResourceAttributeValuesShouldBePercentDecodedWhenStringContainsNonAscii() {
122+
this.environmentVariables.put("OTEL_RESOURCE_ATTRIBUTES", "key=%20\u015bp\u0159\u00ec\u0144\u0121%20");
123+
assertThat(getAttributes()).hasSize(2)
124+
.containsEntry("service.name", "unknown_service")
125+
.containsEntry("key", " śpřìńġ ");
126+
}
127+
128+
@Test
129+
void otelResourceAttributeValuesShouldBePercentDecodedWhenMultiByteSequences() {
130+
this.environmentVariables.put("OTEL_RESOURCE_ATTRIBUTES", "key=T%C5%8Dky%C5%8D");
131+
assertThat(getAttributes()).hasSize(2)
132+
.containsEntry("service.name", "unknown_service")
133+
.containsEntry("key", "Tōkyō");
134+
}
135+
120136
@Test
121137
void illegalArgumentExceptionShouldBeThrownWhenDecodingIllegalHexCharPercentEncodedValue() {
122138
this.environmentVariables.put("OTEL_RESOURCE_ATTRIBUTES", "key=abc%ß");

0 commit comments

Comments
 (0)