Skip to content

Commit 3f8cef5

Browse files
committed
coverage
1 parent 5d7b940 commit 3f8cef5

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

sdk/src/main/java/io/opentdf/platform/sdk/AddressNormalizer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ private AddressNormalizer(){
1515
}
1616

1717
static String normalizeAddress(String urlString, boolean usePlaintext) {
18-
final String scheme = usePlaintext ? "http" : "https";
1918
URI uri = getInitialUri(urlString);
2019

20+
final String scheme = usePlaintext ? "http" : "https";
2121
if (uri.getHost() == null) {
2222
// if there is no host and no scheme, then we assume the input is a hostname with no port or scheme
2323
if (uri.getScheme() == null) {

sdk/src/test/java/io/opentdf/platform/sdk/AddressNormalizerTest.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
import org.junit.jupiter.api.Test;
55

6+
import java.net.URISyntaxException;
7+
68
import static io.opentdf.platform.sdk.AddressNormalizer.normalizeAddress;
79
import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
810
import static org.junit.jupiter.api.Assertions.assertThrows;
@@ -40,4 +42,10 @@ void testAddressNormalizationWithInvalidPort() {
4042
thrown = assertThrows(SDKException.class, () -> normalizeAddress("http://example.org:notaport", true));
4143
assertThat(thrown.getMessage()).contains("http://example.org:notaport");
4244
}
45+
46+
@Test
47+
void testInsaneAddressThrowsException() {
48+
var thrown = assertThrows(SDKException.class, () -> normalizeAddress("1://&()&{$!//1//1", true));
49+
assertThat(thrown.getCause()).isInstanceOf(URISyntaxException.class);
50+
}
4351
}

0 commit comments

Comments
 (0)