Allow the same LaunchPhase to be used for both start-date and end-date sunrise

Also changed the name of "verifyRegistryStateAllowsLaunchFlows" to "verifyRegistryStateAllowsApplicationFlows", because there are now launch flows that don't use applications (start-date sunrise).

Finally, added a test to showcase the "super-user" power that EPPs with Anchor Tenants have. There's no change in behavior in that regard in this CL - we just add a test to make it explicit.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=187517199
This commit is contained in:
guyben 2018-03-01 12:34:50 -08:00 committed by jianglai
parent ef26dabf32
commit 24799b394d
11 changed files with 36 additions and 26 deletions

View file

@ -37,7 +37,7 @@ import static google.registry.flows.domain.DomainFlowUtils.verifyNoCodeMarks;
import static google.registry.flows.domain.DomainFlowUtils.verifyNotReserved;
import static google.registry.flows.domain.DomainFlowUtils.verifyPremiumNameIsNotBlocked;
import static google.registry.flows.domain.DomainFlowUtils.verifyRegistrarIsActive;
import static google.registry.flows.domain.DomainFlowUtils.verifyRegistryStateAllowsLaunchFlows;
import static google.registry.flows.domain.DomainFlowUtils.verifyRegistryStateAllowsApplicationFlows;
import static google.registry.flows.domain.DomainFlowUtils.verifyUnitIsYears;
import static google.registry.model.EppResourceUtils.createDomainRepoId;
import static google.registry.model.index.DomainApplicationIndex.loadActiveApplicationsByDomainName;
@ -320,7 +320,7 @@ public final class DomainApplicationCreateFlow implements TransactionalFlow {
}
boolean isSunriseApplication = !launchCreate.getSignedMarks().isEmpty();
if (!isSuperuser) { // Superusers can ignore the phase.
verifyRegistryStateAllowsLaunchFlows(registry, now);
verifyRegistryStateAllowsApplicationFlows(registry, now);
verifyLaunchPhaseMatchesRegistryPhase(registry, launchCreate, now);
}
if (now.isBefore(registry.getClaimsPeriodEnd())) {

View file

@ -22,7 +22,7 @@ import static google.registry.flows.ResourceFlowUtils.verifyResourceOwnership;
import static google.registry.flows.domain.DomainFlowUtils.checkAllowedAccessToTld;
import static google.registry.flows.domain.DomainFlowUtils.verifyApplicationDomainMatchesTargetId;
import static google.registry.flows.domain.DomainFlowUtils.verifyLaunchPhaseMatchesRegistryPhase;
import static google.registry.flows.domain.DomainFlowUtils.verifyRegistryStateAllowsLaunchFlows;
import static google.registry.flows.domain.DomainFlowUtils.verifyRegistryStateAllowsApplicationFlows;
import static google.registry.model.EppResourceUtils.loadDomainApplication;
import static google.registry.model.ofy.ObjectifyService.ofy;
@ -91,7 +91,7 @@ public final class DomainApplicationDeleteFlow implements TransactionalFlow {
if (!isSuperuser) {
checkAllowedAccessToTld(clientId, tld);
Registry registry = Registry.get(tld);
verifyRegistryStateAllowsLaunchFlows(registry, now);
verifyRegistryStateAllowsApplicationFlows(registry, now);
verifyLaunchPhaseMatchesRegistryPhase(
registry, eppInput.getSingleExtension(LaunchDeleteExtension.class).get(), now);
verifyResourceOwnership(clientId, existingApplication);

View file

@ -118,7 +118,6 @@ import java.util.Comparator;
import java.util.HashSet;
import java.util.List;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import javax.annotation.Nullable;
@ -130,14 +129,14 @@ import org.joda.time.Duration;
/** Static utility functions for domain flows. */
public class DomainFlowUtils {
/** Map from launch phases to the equivalent tld states. */
private static final ImmutableMap<LaunchPhase, TldState> LAUNCH_PHASE_TO_TLD_STATE =
new ImmutableMap.Builder<LaunchPhase, TldState>()
/** Map from launch phases to the allowed tld states. */
private static final ImmutableMultimap<LaunchPhase, TldState> LAUNCH_PHASE_TO_TLD_STATES =
new ImmutableMultimap.Builder<LaunchPhase, TldState>()
.put(LaunchPhase.SUNRISE, TldState.SUNRISE)
.put(LaunchPhase.SUNRUSH, TldState.SUNRUSH)
.put(LaunchPhase.LANDRUSH, TldState.LANDRUSH)
.put(LaunchPhase.CLAIMS, TldState.GENERAL_AVAILABILITY)
.put(LaunchPhase.START_DATE_SUNRISE, TldState.START_DATE_SUNRISE)
.put(LaunchPhase.SUNRISE, TldState.START_DATE_SUNRISE)
.put(LaunchPhase.OPEN, TldState.GENERAL_AVAILABILITY)
.build();
@ -149,7 +148,7 @@ public class DomainFlowUtils {
ReservationType.MISTAKEN_PREMIUM);
/** Non-sunrise tld states. */
private static final ImmutableSet<TldState> DISALLOWED_TLD_STATES_FOR_LAUNCH_FLOWS =
private static final ImmutableSet<TldState> DISALLOWED_TLD_STATES_FOR_APPLICATION_FLOWS =
Sets.immutableEnumSet(
TldState.PREDELEGATION,
TldState.QUIET_PERIOD,
@ -421,8 +420,8 @@ public class DomainFlowUtils {
/** Verifies that a launch extension's specified phase matches the specified registry's phase. */
static void verifyLaunchPhaseMatchesRegistryPhase(
Registry registry, LaunchExtension launchExtension, DateTime now) throws EppException {
if (!Objects.equals(
registry.getTldState(now), LAUNCH_PHASE_TO_TLD_STATE.get(launchExtension.getPhase()))) {
if (!LAUNCH_PHASE_TO_TLD_STATES.containsEntry(
launchExtension.getPhase(), registry.getTldState(now))) {
// No launch operations are allowed during the quiet period or predelegation.
throw new LaunchPhaseMismatchException();
}
@ -843,9 +842,9 @@ public class DomainFlowUtils {
}
/** Check that the registry phase is not incompatible with launch extension flows. */
static void verifyRegistryStateAllowsLaunchFlows(Registry registry, DateTime now)
static void verifyRegistryStateAllowsApplicationFlows(Registry registry, DateTime now)
throws BadCommandForRegistryPhaseException {
if (DISALLOWED_TLD_STATES_FOR_LAUNCH_FLOWS.contains(registry.getTldState(now))) {
if (DISALLOWED_TLD_STATES_FOR_APPLICATION_FLOWS.contains(registry.getTldState(now))) {
throw new BadCommandForRegistryPhaseException();
}
}

View file

@ -58,6 +58,10 @@ public class LaunchPhase extends ImmutableObject {
/**
* The phase during which trademark holders can submit registrations or applications with
* trademark information that can be validated by the server.
*
* This phase works for both start-date and end-data sunrise.
*
* TODO(b/74006379): maybe make this work for sunrush phase?
*/
public static final LaunchPhase SUNRISE = create("sunrise", null);
@ -76,12 +80,6 @@ public class LaunchPhase extends ImmutableObject {
*/
public static final LaunchPhase CLAIMS = create("claims", null);
/**
* An alternative launch phase which allows only trademark owners to create domains. It is used
* instead of the previous phases.
*/
public static final LaunchPhase START_DATE_SUNRISE = create("sunrise", "start-date");
/** A post-launch phase that is also referred to as "steady state". */
public static final LaunchPhase OPEN = create("open", null);

View file

@ -1778,6 +1778,19 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
assertNoLordn("0000001761376042759136-65535", null);
}
/** Tests possible confusion caused by the common start-date and end-date sunrise LaunchPhase. */
@Test
public void testFail_sunriseRegistration_withEncodedSignedMark() throws Exception {
createTld("tld", TldState.SUNRISE);
clock.setTo(DateTime.parse("2014-09-09T09:09:09Z"));
setEppInput("domain_create_registration_start_date_sunrise_encoded_signed_mark.xml");
persistContactsAndHosts();
EppException thrown =
assertThrows(NoGeneralRegistrationsInCurrentPhaseException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml();
}
@Test
public void testFail_startDateSunriseRegistration_wrongEncodedSignedMark() throws Exception {
createTld("tld", TldState.START_DATE_SUNRISE);

View file

@ -20,7 +20,7 @@
</create>
<extension>
<launch:create xmlns:launch="urn:ietf:params:xml:ns:launch-1.0" type="registration">
<launch:phase name="start-date">sunrise</launch:phase>
<launch:phase>sunrise</launch:phase>
</launch:create>
<metadata:metadata xmlns:metadata="urn:google:params:xml:ns:metadata-1.0">
<metadata:requestedByRegistrar>true</metadata:requestedByRegistrar>

View file

@ -22,7 +22,7 @@
<launch:create
xmlns:launch="urn:ietf:params:xml:ns:launch-1.0"
type="registration">
<launch:phase name="start-date">sunrise</launch:phase>
<launch:phase>sunrise</launch:phase>
</launch:create>
</extension>
<clTRID>ABC-12345</clTRID>

View file

@ -20,7 +20,7 @@
</create>
<extension>
<launch:create xmlns:launch="urn:ietf:params:xml:ns:launch-1.0" type="registration">
<launch:phase name="start-date">sunrise</launch:phase>
<launch:phase>sunrise</launch:phase>
<launch:notice>
<launch:noticeID>370d0b7c9223372036854775807</launch:noticeID>
<launch:notAfter>2010-08-16T09:00:00.0Z</launch:notAfter>

File diff suppressed because one or more lines are too long