Remove authcode fallback for registering anchor tenants

We won't be using this for future launches, so get rid of it now.

Also reorganizes existing anchor tenant test cases and adds a new one for
creation of a TMDBed anchor tenant domain in sunrise.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=239669950
This commit is contained in:
mcilwain 2019-03-21 14:14:21 -07:00 committed by jianglai
parent afdc98835c
commit d7fbd93dca
11 changed files with 137 additions and 147 deletions

View file

@ -89,7 +89,6 @@ import google.registry.model.domain.rgp.GracePeriodStatus;
import google.registry.model.domain.secdns.SecDnsCreateExtension;
import google.registry.model.domain.token.AllocationToken;
import google.registry.model.domain.token.AllocationTokenExtension;
import google.registry.model.eppcommon.AuthInfo;
import google.registry.model.eppcommon.StatusValue;
import google.registry.model.eppinput.EppInput;
import google.registry.model.eppinput.ResourceCommand;
@ -190,7 +189,6 @@ public class DomainCreateFlow implements TransactionalFlow {
@Inject ExtensionManager extensionManager;
@Inject EppInput eppInput;
@Inject AuthInfo authInfo;
@Inject ResourceCommand resourceCommand;
@Inject @ClientId String clientId;
@Inject @TargetId String targetId;
@ -241,15 +239,12 @@ public class DomainCreateFlow implements TransactionalFlow {
verifyNoCodeMarks(launchCreate.get());
validateLaunchCreateNotice(launchCreate.get().getNotice(), domainLabel, isSuperuser, now);
}
boolean isSunriseCreate = hasSignedMarks && tldState == START_DATE_SUNRISE;
boolean isSunriseCreate = hasSignedMarks && (tldState == START_DATE_SUNRISE);
Optional<AllocationToken> allocationToken =
verifyAllocationTokenIfPresent(command, registry, clientId, now);
boolean isAnchorTenant =
isAnchorTenant(
domainName,
allocationToken,
authInfo.getPw().getValue(),
eppInput.getSingleExtension(MetadataExtension.class));
domainName, allocationToken, eppInput.getSingleExtension(MetadataExtension.class));
verifyAnchorTenantValidPeriod(isAnchorTenant, years);
// Superusers can create reserved domains, force creations on domains that require a claims
// notice without specifying a claims key, ignore the registry phase, and override blocks on

View file

@ -254,25 +254,14 @@ public class DomainFlowUtils {
public static boolean isAnchorTenant(
InternetDomainName domainName,
Optional<AllocationToken> token,
String authInfoPw,
Optional<MetadataExtension> metadataExtension) {
// If the domain is reserved for anchor tenants, then check if the allocation token exists and
// is for this domain.
if (getReservationTypes(domainName).contains(RESERVED_FOR_ANCHOR_TENANT)) {
// If there wasn't an allocation token specified, then use the fallback of attempting to load
// the token with the specified EPP authcode.
// TODO(b/111827374): Remove the authInfoPw fallback and only accept an allocation token.
if (!token.isPresent()) {
token =
Optional.ofNullable(
ofy().load().key(Key.create(AllocationToken.class, authInfoPw)).now());
}
// If the token exists, check if it's valid for this domain.
if (token.isPresent()
&& token.get().getDomainName().isPresent()
&& token.get().getDomainName().get().equals(domainName.toString())) {
return true;
}
if (getReservationTypes(domainName).contains(RESERVED_FOR_ANCHOR_TENANT)
&& token.isPresent()
&& token.get().getDomainName().isPresent()
&& token.get().getDomainName().get().equals(domainName.toString())) {
return true;
}
// Otherwise check whether the metadata extension is being used by a superuser to specify that
// it's an anchor tenant creation.