Add better testing of domain and host creation using multi-part TLDs

Added validation on domain creation, preventing a domain from being created if
it equals an existing TLD. Added domain create tests for domains using
multi-part TLDs that shared suffixes and prefixes. Added host create tests for
hosts using multi-part TLDs that shared suffixes.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=164297749
This commit is contained in:
bbilbo 2017-08-04 12:53:33 -07:00 committed by Ben McIlwain
parent b9a8853f4b
commit e786c8d6ff
14 changed files with 322 additions and 14 deletions

View file

@ -18,6 +18,7 @@ import static com.google.common.truth.Truth.assertThat;
import static google.registry.model.EppResourceUtils.loadByForeignKey;
import static google.registry.testing.DatastoreHelper.assertNoBillingEvents;
import static google.registry.testing.DatastoreHelper.createTld;
import static google.registry.testing.DatastoreHelper.createTlds;
import static google.registry.testing.DatastoreHelper.newDomainResource;
import static google.registry.testing.DatastoreHelper.persistActiveDomain;
import static google.registry.testing.DatastoreHelper.persistActiveHost;
@ -49,7 +50,6 @@ import google.registry.model.eppcommon.StatusValue;
import google.registry.model.host.HostResource;
import google.registry.model.reporting.HistoryEntry;
import org.joda.time.DateTime;
import org.junit.Before;
import org.junit.Test;
/** Unit tests for {@link HostCreateFlow}. */
@ -76,11 +76,6 @@ public class HostCreateFlowTest extends ResourceFlowTestCase<HostCreateFlow, Hos
clock.setTo(DateTime.parse("1999-04-03T22:00:00.0Z"));
}
@Before
public void initHostTest() {
createTld("foobar");
}
private void doSuccessfulTest() throws Exception {
clock.advanceOneMilli();
assertTransactionalFlow(true);
@ -124,6 +119,15 @@ public class HostCreateFlowTest extends ResourceFlowTestCase<HostCreateFlow, Hos
assertDnsTasksEnqueued("ns1.example.tld");
}
@Test
public void testFailure_multipartTLDsAndInvalidHost() throws Exception {
createTlds("bar.tld", "tld");
setEppHostCreateInputWithIps("ns1.bar.tld");
thrown.expect(HostNameTooShallowException.class);
runFlow();
}
@Test
public void testSuccess_externalExistedButWasDeleted() throws Exception {
persistDeletedHost(getUniqueIdFromCommand(), clock.nowUtc().minusDays(1));