mirror of
https://github.com/google/nomulus.git
synced 2025-05-13 07:57:13 +02:00
Decentralize how registry phase checks are done in flows
Very few flows actually check the phase. Push the checks down to the leaf flows so that we can remove the inherited code from ResourceFlow and replace it with utility methods. In the process, document and test two places that throw the exception but did not previously test it. This introduces a temporary hack in BaseDomainCreateFlow that does something specific for DomainApplicationCreateFlow. It will go away literally tomorrow when I flatten that flow. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=135480538
This commit is contained in:
parent
aaa84d6ec6
commit
a09d48a4a5
18 changed files with 166 additions and 129 deletions
|
@ -44,6 +44,7 @@ import com.google.common.net.InternetDomainName;
|
|||
import com.googlecode.objectify.Key;
|
||||
import google.registry.flows.EppException;
|
||||
import google.registry.flows.EppException.AuthorizationErrorException;
|
||||
import google.registry.flows.EppException.CommandUseErrorException;
|
||||
import google.registry.flows.EppException.ObjectDoesNotExistException;
|
||||
import google.registry.flows.EppException.ParameterValuePolicyErrorException;
|
||||
import google.registry.flows.EppException.ParameterValueRangeErrorException;
|
||||
|
@ -134,13 +135,6 @@ public class DomainFlowUtils {
|
|||
LaunchPhase.CLAIMS, TldState.GENERAL_AVAILABILITY,
|
||||
LaunchPhase.OPEN, TldState.GENERAL_AVAILABILITY);
|
||||
|
||||
/** Non-sunrise tld states. */
|
||||
public static final ImmutableSet<TldState> DISALLOWED_TLD_STATES_FOR_LAUNCH_FLOWS =
|
||||
Sets.immutableEnumSet(
|
||||
TldState.PREDELEGATION,
|
||||
TldState.QUIET_PERIOD,
|
||||
TldState.GENERAL_AVAILABILITY);
|
||||
|
||||
/** Reservation types that are allowed in sunrise by policy. */
|
||||
public static final ImmutableSet<ReservationType> TYPES_ALLOWED_FOR_CREATE_ONLY_IN_SUNRISE =
|
||||
Sets.immutableEnumSet(
|
||||
|
@ -148,6 +142,13 @@ public class DomainFlowUtils {
|
|||
ReservationType.NAME_COLLISION,
|
||||
ReservationType.MISTAKEN_PREMIUM);
|
||||
|
||||
/** Non-sunrise tld states. */
|
||||
private static final ImmutableSet<TldState> DISALLOWED_TLD_STATES_FOR_LAUNCH_FLOWS =
|
||||
Sets.immutableEnumSet(
|
||||
TldState.PREDELEGATION,
|
||||
TldState.QUIET_PERIOD,
|
||||
TldState.GENERAL_AVAILABILITY);
|
||||
|
||||
/** Strict validator for ascii lowercase letters, digits, and "-", allowing "." as a separator */
|
||||
private static final CharMatcher ALLOWED_CHARS =
|
||||
CharMatcher.inRange('a', 'z').or(CharMatcher.inRange('0', '9').or(CharMatcher.anyOf("-.")));
|
||||
|
@ -377,7 +378,6 @@ public class DomainFlowUtils {
|
|||
if (!Objects.equals(
|
||||
Registry.get(tld).getTldState(now),
|
||||
LAUNCH_PHASE_TO_TLD_STATE.get(launchExtension.getPhase()))) {
|
||||
// No launch operations are allowed during the quiet period or predelegation.
|
||||
throw new LaunchPhaseMismatchException();
|
||||
}
|
||||
}
|
||||
|
@ -826,7 +826,7 @@ public class DomainFlowUtils {
|
|||
}
|
||||
|
||||
/** If a domain or application has "clientUpdateProhibited" set, updates must clear it or fail. */
|
||||
public static void verifyClientUpdateNotProhibited(Update command, DomainBase existingResource)
|
||||
static void verifyClientUpdateNotProhibited(Update command, DomainBase existingResource)
|
||||
throws ResourceHasClientUpdateProhibitedException {
|
||||
if (existingResource.getStatusValues().contains(StatusValue.CLIENT_UPDATE_PROHIBITED)
|
||||
&& !command.getInnerRemove().getStatusValues()
|
||||
|
@ -835,6 +835,20 @@ public class DomainFlowUtils {
|
|||
}
|
||||
}
|
||||
|
||||
static void verifyRegistryStateAllowsLaunchFlows(Registry registry, DateTime now)
|
||||
throws BadCommandForRegistryPhaseException {
|
||||
if (DISALLOWED_TLD_STATES_FOR_LAUNCH_FLOWS.contains(registry.getTldState(now))) {
|
||||
throw new BadCommandForRegistryPhaseException();
|
||||
}
|
||||
}
|
||||
|
||||
static void verifyNotInPredelegation(Registry registry, DateTime now)
|
||||
throws BadCommandForRegistryPhaseException {
|
||||
if (registry.getTldState(now) == TldState.PREDELEGATION) {
|
||||
throw new BadCommandForRegistryPhaseException();
|
||||
}
|
||||
}
|
||||
|
||||
/** Encoded signed marks must use base64 encoding. */
|
||||
static class Base64RequiredForEncodedSignedMarksException
|
||||
extends ParameterValuePolicyErrorException {
|
||||
|
@ -1204,6 +1218,13 @@ public class DomainFlowUtils {
|
|||
}
|
||||
}
|
||||
|
||||
/** Command is not allowed in the current registry phase. */
|
||||
public static class BadCommandForRegistryPhaseException extends CommandUseErrorException {
|
||||
public BadCommandForRegistryPhaseException() {
|
||||
super("Command is not allowed in the current registry phase");
|
||||
}
|
||||
}
|
||||
|
||||
/** The secDNS:all element must have value 'true' if present. */
|
||||
static class SecDnsAllUsageException extends ParameterValuePolicyErrorException {
|
||||
public SecDnsAllUsageException() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue