Add tests for obscure hostname canonicalization rule (#1388)

Also correctly configures Gradle for the util subproject (it wasn't possible to
run tests in IntelliJ without these changes).
This commit is contained in:
Ben McIlwain 2021-10-14 14:53:28 -04:00 committed by GitHub
parent 5803215755
commit b96de0e32f
6 changed files with 85 additions and 6 deletions

View file

@ -43,12 +43,16 @@ dependencies {
testCompile deps['com.google.appengine:appengine-api-stubs']
testCompile deps['com.google.guava:guava-testlib']
testCompile deps['com.google.truth:truth']
testCompile deps['junit:junit']
testCompile deps['org.junit.jupiter:junit-jupiter-api']
testCompile deps['org.junit.jupiter:junit-jupiter-engine']
testCompile deps['org.junit.platform:junit-platform-runner']
testCompile deps['org.junit.platform:junit-platform-suite-api']
testCompile deps['org.hamcrest:hamcrest']
testCompile deps['org.hamcrest:hamcrest-core']
testCompile deps['org.mockito:mockito-core']
testCompile deps['org.mockito:mockito-junit-jupiter']
testCompile deps['org.testcontainers:junit-jupiter']
testCompile files("${rootDir}/third_party/objectify/v4_1/objectify-4.1.3.jar")
testCompile project(path: ':common', configuration: 'testing')
testRuntime deps['com.google.flogger:flogger-system-backend']
@ -57,3 +61,7 @@ dependencies {
testAnnotationProcessor deps['com.google.auto.value:auto-value']
testAnnotationProcessor deps['com.google.dagger:dagger-compiler']
}
test {
useJUnitPlatform()
}

View file

@ -1,6 +1,10 @@
# This is a Gradle generated file for dependency locking.
# Manual edits can break the build and are not advised.
# This file is expected to be part of source control.
com.fasterxml.jackson.core:jackson-annotations:2.10.3
com.github.docker-java:docker-java-api:3.2.7
com.github.docker-java:docker-java-transport-zerodep:3.2.7
com.github.docker-java:docker-java-transport:3.2.7
com.google.android:annotations:4.1.1.4
com.google.api-client:google-api-client:1.31.3
com.google.api.grpc:proto-google-cloud-tasks-v2:1.33.2
@ -61,6 +65,8 @@ joda-time:joda-time:2.9.2
junit:junit:4.13.2
net.bytebuddy:byte-buddy-agent:1.10.19
net.bytebuddy:byte-buddy:1.10.19
net.java.dev.jna:jna:5.5.0
org.apache.commons:commons-compress:1.20
org.apache.httpcomponents:httpclient:4.5.13
org.apache.httpcomponents:httpcore:4.4.14
org.apiguardian:apiguardian-api:1.1.0
@ -76,11 +82,19 @@ org.junit.jupiter:junit-jupiter-api:5.7.0
org.junit.jupiter:junit-jupiter-engine:5.7.0
org.junit.platform:junit-platform-commons:1.7.0
org.junit.platform:junit-platform-engine:1.7.0
org.junit.platform:junit-platform-launcher:1.7.0
org.junit.platform:junit-platform-runner:1.7.0
org.junit.platform:junit-platform-suite-api:1.7.0
org.junit:junit-bom:5.7.0
org.mockito:mockito-core:3.7.7
org.mockito:mockito-junit-jupiter:3.7.7
org.objenesis:objenesis:3.1
org.opentest4j:opentest4j:1.2.0
org.ow2.asm:asm:9.0
org.rnorth.duct-tape:duct-tape:1.0.8
org.rnorth.visible-assertions:visible-assertions:2.1.2
org.slf4j:slf4j-api:1.7.30
org.testcontainers:junit-jupiter:1.15.2
org.testcontainers:testcontainers:1.15.2
org.threeten:threetenbp:1.5.1
org.yaml:snakeyaml:1.17

View file

@ -1,6 +1,10 @@
# This is a Gradle generated file for dependency locking.
# Manual edits can break the build and are not advised.
# This file is expected to be part of source control.
com.fasterxml.jackson.core:jackson-annotations:2.10.3
com.github.docker-java:docker-java-api:3.2.7
com.github.docker-java:docker-java-transport-zerodep:3.2.7
com.github.docker-java:docker-java-transport:3.2.7
com.google.api-client:google-api-client:1.31.3
com.google.api.grpc:proto-google-cloud-tasks-v2:1.33.2
com.google.api.grpc:proto-google-cloud-tasks-v2beta2:0.89.2
@ -58,6 +62,8 @@ joda-time:joda-time:2.9.2
junit:junit:4.13.2
net.bytebuddy:byte-buddy-agent:1.10.19
net.bytebuddy:byte-buddy:1.10.19
net.java.dev.jna:jna:5.5.0
org.apache.commons:commons-compress:1.20
org.apache.httpcomponents:httpclient:4.5.13
org.apache.httpcomponents:httpcore:4.4.14
org.apiguardian:apiguardian-api:1.1.0
@ -68,15 +74,23 @@ org.checkerframework:checker-qual:3.9.1
org.conscrypt:conscrypt-openjdk-uber:2.5.1
org.hamcrest:hamcrest-core:2.2
org.hamcrest:hamcrest:2.2
org.junit.jupiter:junit-jupiter-api:5.6.2
org.junit.jupiter:junit-jupiter-engine:5.6.2
org.junit.platform:junit-platform-commons:1.6.2
org.junit.platform:junit-platform-engine:1.6.2
org.junit:junit-bom:5.6.2
org.junit.jupiter:junit-jupiter-api:5.7.0
org.junit.jupiter:junit-jupiter-engine:5.7.0
org.junit.platform:junit-platform-commons:1.7.0
org.junit.platform:junit-platform-engine:1.7.0
org.junit.platform:junit-platform-launcher:1.7.0
org.junit.platform:junit-platform-runner:1.7.0
org.junit.platform:junit-platform-suite-api:1.7.0
org.junit:junit-bom:5.7.0
org.mockito:mockito-core:3.7.7
org.mockito:mockito-junit-jupiter:3.7.7
org.objenesis:objenesis:3.1
org.opentest4j:opentest4j:1.2.0
org.ow2.asm:asm:9.0
org.rnorth.duct-tape:duct-tape:1.0.8
org.rnorth.visible-assertions:visible-assertions:2.1.2
org.slf4j:slf4j-api:1.7.30
org.testcontainers:junit-jupiter:1.15.2
org.testcontainers:testcontainers:1.15.2
org.threeten:threetenbp:1.5.1
org.yaml:snakeyaml:1.17

View file

@ -1,6 +1,10 @@
# This is a Gradle generated file for dependency locking.
# Manual edits can break the build and are not advised.
# This file is expected to be part of source control.
com.fasterxml.jackson.core:jackson-annotations:2.10.3
com.github.docker-java:docker-java-api:3.2.7
com.github.docker-java:docker-java-transport-zerodep:3.2.7
com.github.docker-java:docker-java-transport:3.2.7
com.google.android:annotations:4.1.1.4
com.google.api-client:google-api-client:1.31.3
com.google.api.grpc:proto-google-cloud-tasks-v2:1.33.2
@ -63,6 +67,8 @@ joda-time:joda-time:2.9.2
junit:junit:4.13.2
net.bytebuddy:byte-buddy-agent:1.10.19
net.bytebuddy:byte-buddy:1.10.19
net.java.dev.jna:jna:5.5.0
org.apache.commons:commons-compress:1.20
org.apache.httpcomponents:httpclient:4.5.13
org.apache.httpcomponents:httpcore:4.4.14
org.apiguardian:apiguardian-api:1.1.0
@ -78,11 +84,19 @@ org.junit.jupiter:junit-jupiter-api:5.7.0
org.junit.jupiter:junit-jupiter-engine:5.7.0
org.junit.platform:junit-platform-commons:1.7.0
org.junit.platform:junit-platform-engine:1.7.0
org.junit.platform:junit-platform-launcher:1.7.0
org.junit.platform:junit-platform-runner:1.7.0
org.junit.platform:junit-platform-suite-api:1.7.0
org.junit:junit-bom:5.7.0
org.mockito:mockito-core:3.7.7
org.mockito:mockito-junit-jupiter:3.7.7
org.objenesis:objenesis:3.1
org.opentest4j:opentest4j:1.2.0
org.ow2.asm:asm:9.0
org.rnorth.duct-tape:duct-tape:1.0.8
org.rnorth.visible-assertions:visible-assertions:2.1.2
org.slf4j:slf4j-api:1.7.30
org.testcontainers:junit-jupiter:1.15.2
org.testcontainers:testcontainers:1.15.2
org.threeten:threetenbp:1.5.1
org.yaml:snakeyaml:1.17

View file

@ -1,6 +1,10 @@
# This is a Gradle generated file for dependency locking.
# Manual edits can break the build and are not advised.
# This file is expected to be part of source control.
com.fasterxml.jackson.core:jackson-annotations:2.10.3
com.github.docker-java:docker-java-api:3.2.7
com.github.docker-java:docker-java-transport-zerodep:3.2.7
com.github.docker-java:docker-java-transport:3.2.7
com.google.android:annotations:4.1.1.4
com.google.api-client:google-api-client:1.31.3
com.google.api.grpc:proto-google-cloud-tasks-v2:1.33.2
@ -63,6 +67,8 @@ joda-time:joda-time:2.9.2
junit:junit:4.13.2
net.bytebuddy:byte-buddy-agent:1.10.19
net.bytebuddy:byte-buddy:1.10.19
net.java.dev.jna:jna:5.5.0
org.apache.commons:commons-compress:1.20
org.apache.httpcomponents:httpclient:4.5.13
org.apache.httpcomponents:httpcore:4.4.14
org.apiguardian:apiguardian-api:1.1.0
@ -78,11 +84,19 @@ org.junit.jupiter:junit-jupiter-api:5.7.0
org.junit.jupiter:junit-jupiter-engine:5.7.0
org.junit.platform:junit-platform-commons:1.7.0
org.junit.platform:junit-platform-engine:1.7.0
org.junit.platform:junit-platform-launcher:1.7.0
org.junit.platform:junit-platform-runner:1.7.0
org.junit.platform:junit-platform-suite-api:1.7.0
org.junit:junit-bom:5.7.0
org.mockito:mockito-core:3.7.7
org.mockito:mockito-junit-jupiter:3.7.7
org.objenesis:objenesis:3.1
org.opentest4j:opentest4j:1.2.0
org.ow2.asm:asm:9.0
org.rnorth.duct-tape:duct-tape:1.0.8
org.rnorth.visible-assertions:visible-assertions:2.1.2
org.slf4j:slf4j-api:1.7.30
org.testcontainers:junit-jupiter:1.15.2
org.testcontainers:testcontainers:1.15.2
org.threeten:threetenbp:1.5.1
org.yaml:snakeyaml:1.17

View file

@ -25,7 +25,7 @@ import org.junit.jupiter.api.Test;
class DomainNameUtilsTest {
@Test
void testCanonicalizeDomainName() {
void testCanonicalizeDomainName_succeeds() {
assertThat(canonicalizeDomainName("foo")).isEqualTo("foo");
assertThat(canonicalizeDomainName("FOO")).isEqualTo("foo");
assertThat(canonicalizeDomainName("foo.tld")).isEqualTo("foo.tld");
@ -38,6 +38,21 @@ class DomainNameUtilsTest {
assertThat(canonicalizeDomainName("ħ")).isEqualTo("xn--1ea");
}
@Test
void testCanonicalizeDomainName_allowsRdnsNames() {
assertThat(canonicalizeDomainName("119.63.227.45-ns1.jhz-tt.uk"))
.isEqualTo("119.63.227.45-ns1.jhz-tt.uk");
}
@Test
void testCanonicalizeDomainName_throwsOn34HyphenRule() {
IllegalArgumentException thrown =
assertThrows(
IllegalArgumentException.class,
() -> canonicalizeDomainName("119.63.227.45--ns1.jhz-tt.uk"));
assertThat(thrown).hasCauseThat().hasMessageThat().contains("HYPHEN_3_4");
}
@Test
void testCanonicalizeDomainName_acePrefixUnicodeChars() {
assertThrows(IllegalArgumentException.class, () -> canonicalizeDomainName("xn--みんな"));