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

@ -25,6 +25,7 @@ import static google.registry.flows.domain.DomainPricingLogic.getMatchingLrpToke
import static google.registry.model.domain.DomainResource.MAX_REGISTRATION_YEARS;
import static google.registry.model.ofy.ObjectifyService.ofy;
import static google.registry.model.registry.Registries.findTldForName;
import static google.registry.model.registry.Registries.getTlds;
import static google.registry.model.registry.label.ReservationType.FULLY_BLOCKED;
import static google.registry.model.registry.label.ReservationType.NAMESERVER_RESTRICTED;
import static google.registry.model.registry.label.ReservationType.RESERVED_FOR_ANCHOR_TENANT;
@ -181,6 +182,9 @@ public class DomainFlowUtils {
}
validateFirstLabel(parts.get(0));
InternetDomainName domainName = InternetDomainName.from(name);
if (getTlds().contains(domainName.toString())) {
throw new DomainNameExistsAsTldException();
}
Optional<InternetDomainName> tldParsed = findTldForName(domainName);
if (!tldParsed.isPresent()) {
throw new TldDoesNotExistException(domainName.parent().toString());
@ -1055,10 +1059,17 @@ public class DomainFlowUtils {
}
}
/** Domain name must have exactly one part above the tld. */
/** Domain name must have exactly one part above the TLD. */
static class BadDomainNamePartsCountException extends ParameterValueSyntaxErrorException {
public BadDomainNamePartsCountException() {
super("Domain name must have exactly one part above the tld");
super("Domain name must have exactly one part above the TLD");
}
}
/** Domain name must not equal an existing multi-part TLD. */
static class DomainNameExistsAsTldException extends ParameterValueSyntaxErrorException {
public DomainNameExistsAsTldException() {
super("Domain name must not equal an existing multi-part TLD");
}
}