1
0
mirror of https://github.com/google/nomulus synced 2026-01-10 16:00:52 +00:00

Add two tests of hostname validation

(One of which doesn't pass yet.)

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=164036917
This commit is contained in:
mcilwain
2017-08-02 14:18:33 -07:00
committed by Ben McIlwain
parent f623d53e73
commit 2707208100

View File

@@ -14,6 +14,7 @@
package google.registry.flows.host;
import static com.google.common.truth.Truth.assertThat;
import static google.registry.flows.host.HostFlowUtils.validateHostName;
import com.google.common.base.Strings;
@@ -25,6 +26,7 @@ import google.registry.flows.host.HostFlowUtils.HostNameTooShallowException;
import google.registry.flows.host.HostFlowUtils.InvalidHostNameException;
import google.registry.testing.AppEngineRule;
import google.registry.testing.ExceptionRule;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -38,6 +40,20 @@ public class HostFlowUtilsTest {
@Rule public final AppEngineRule appEngine = AppEngineRule.builder().withDatastore().build();
@Test
public void test_validExternalHostName_validates() throws Exception {
assertThat(validateHostName("host.example.com").toString()).isEqualTo("host.example.com");
}
@Test
@Ignore
// TODO(b/63128999): Fix handling of public suffix lists so that hostnames that aren't on
// effective TLDs validate.
public void test_validExternalHostNameOnPublicSuffixList_validates() throws Exception {
assertThat(validateHostName("host.blogspot.com").toString()).isEqualTo("host.blogspot.com");
}
@Test
public void test_validateHostName_hostNameTooLong() throws Exception {
thrown.expect(HostNameTooLongException.class);