mirror of
https://github.com/google/nomulus.git
synced 2025-05-14 16:37:13 +02:00
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:
parent
ef26dabf32
commit
24799b394d
11 changed files with 36 additions and 26 deletions
|
@ -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.verifyNotReserved;
|
||||||
import static google.registry.flows.domain.DomainFlowUtils.verifyPremiumNameIsNotBlocked;
|
import static google.registry.flows.domain.DomainFlowUtils.verifyPremiumNameIsNotBlocked;
|
||||||
import static google.registry.flows.domain.DomainFlowUtils.verifyRegistrarIsActive;
|
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.flows.domain.DomainFlowUtils.verifyUnitIsYears;
|
||||||
import static google.registry.model.EppResourceUtils.createDomainRepoId;
|
import static google.registry.model.EppResourceUtils.createDomainRepoId;
|
||||||
import static google.registry.model.index.DomainApplicationIndex.loadActiveApplicationsByDomainName;
|
import static google.registry.model.index.DomainApplicationIndex.loadActiveApplicationsByDomainName;
|
||||||
|
@ -320,7 +320,7 @@ public final class DomainApplicationCreateFlow implements TransactionalFlow {
|
||||||
}
|
}
|
||||||
boolean isSunriseApplication = !launchCreate.getSignedMarks().isEmpty();
|
boolean isSunriseApplication = !launchCreate.getSignedMarks().isEmpty();
|
||||||
if (!isSuperuser) { // Superusers can ignore the phase.
|
if (!isSuperuser) { // Superusers can ignore the phase.
|
||||||
verifyRegistryStateAllowsLaunchFlows(registry, now);
|
verifyRegistryStateAllowsApplicationFlows(registry, now);
|
||||||
verifyLaunchPhaseMatchesRegistryPhase(registry, launchCreate, now);
|
verifyLaunchPhaseMatchesRegistryPhase(registry, launchCreate, now);
|
||||||
}
|
}
|
||||||
if (now.isBefore(registry.getClaimsPeriodEnd())) {
|
if (now.isBefore(registry.getClaimsPeriodEnd())) {
|
||||||
|
|
|
@ -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.checkAllowedAccessToTld;
|
||||||
import static google.registry.flows.domain.DomainFlowUtils.verifyApplicationDomainMatchesTargetId;
|
import static google.registry.flows.domain.DomainFlowUtils.verifyApplicationDomainMatchesTargetId;
|
||||||
import static google.registry.flows.domain.DomainFlowUtils.verifyLaunchPhaseMatchesRegistryPhase;
|
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.EppResourceUtils.loadDomainApplication;
|
||||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ public final class DomainApplicationDeleteFlow implements TransactionalFlow {
|
||||||
if (!isSuperuser) {
|
if (!isSuperuser) {
|
||||||
checkAllowedAccessToTld(clientId, tld);
|
checkAllowedAccessToTld(clientId, tld);
|
||||||
Registry registry = Registry.get(tld);
|
Registry registry = Registry.get(tld);
|
||||||
verifyRegistryStateAllowsLaunchFlows(registry, now);
|
verifyRegistryStateAllowsApplicationFlows(registry, now);
|
||||||
verifyLaunchPhaseMatchesRegistryPhase(
|
verifyLaunchPhaseMatchesRegistryPhase(
|
||||||
registry, eppInput.getSingleExtension(LaunchDeleteExtension.class).get(), now);
|
registry, eppInput.getSingleExtension(LaunchDeleteExtension.class).get(), now);
|
||||||
verifyResourceOwnership(clientId, existingApplication);
|
verifyResourceOwnership(clientId, existingApplication);
|
||||||
|
|
|
@ -118,7 +118,6 @@ import java.util.Comparator;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
@ -130,14 +129,14 @@ import org.joda.time.Duration;
|
||||||
/** Static utility functions for domain flows. */
|
/** Static utility functions for domain flows. */
|
||||||
public class DomainFlowUtils {
|
public class DomainFlowUtils {
|
||||||
|
|
||||||
/** Map from launch phases to the equivalent tld states. */
|
/** Map from launch phases to the allowed tld states. */
|
||||||
private static final ImmutableMap<LaunchPhase, TldState> LAUNCH_PHASE_TO_TLD_STATE =
|
private static final ImmutableMultimap<LaunchPhase, TldState> LAUNCH_PHASE_TO_TLD_STATES =
|
||||||
new ImmutableMap.Builder<LaunchPhase, TldState>()
|
new ImmutableMultimap.Builder<LaunchPhase, TldState>()
|
||||||
.put(LaunchPhase.SUNRISE, TldState.SUNRISE)
|
.put(LaunchPhase.SUNRISE, TldState.SUNRISE)
|
||||||
.put(LaunchPhase.SUNRUSH, TldState.SUNRUSH)
|
.put(LaunchPhase.SUNRUSH, TldState.SUNRUSH)
|
||||||
.put(LaunchPhase.LANDRUSH, TldState.LANDRUSH)
|
.put(LaunchPhase.LANDRUSH, TldState.LANDRUSH)
|
||||||
.put(LaunchPhase.CLAIMS, TldState.GENERAL_AVAILABILITY)
|
.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)
|
.put(LaunchPhase.OPEN, TldState.GENERAL_AVAILABILITY)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
@ -149,7 +148,7 @@ public class DomainFlowUtils {
|
||||||
ReservationType.MISTAKEN_PREMIUM);
|
ReservationType.MISTAKEN_PREMIUM);
|
||||||
|
|
||||||
/** Non-sunrise tld states. */
|
/** 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(
|
Sets.immutableEnumSet(
|
||||||
TldState.PREDELEGATION,
|
TldState.PREDELEGATION,
|
||||||
TldState.QUIET_PERIOD,
|
TldState.QUIET_PERIOD,
|
||||||
|
@ -421,8 +420,8 @@ public class DomainFlowUtils {
|
||||||
/** Verifies that a launch extension's specified phase matches the specified registry's phase. */
|
/** Verifies that a launch extension's specified phase matches the specified registry's phase. */
|
||||||
static void verifyLaunchPhaseMatchesRegistryPhase(
|
static void verifyLaunchPhaseMatchesRegistryPhase(
|
||||||
Registry registry, LaunchExtension launchExtension, DateTime now) throws EppException {
|
Registry registry, LaunchExtension launchExtension, DateTime now) throws EppException {
|
||||||
if (!Objects.equals(
|
if (!LAUNCH_PHASE_TO_TLD_STATES.containsEntry(
|
||||||
registry.getTldState(now), LAUNCH_PHASE_TO_TLD_STATE.get(launchExtension.getPhase()))) {
|
launchExtension.getPhase(), registry.getTldState(now))) {
|
||||||
// No launch operations are allowed during the quiet period or predelegation.
|
// No launch operations are allowed during the quiet period or predelegation.
|
||||||
throw new LaunchPhaseMismatchException();
|
throw new LaunchPhaseMismatchException();
|
||||||
}
|
}
|
||||||
|
@ -843,9 +842,9 @@ public class DomainFlowUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Check that the registry phase is not incompatible with launch extension flows. */
|
/** 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 {
|
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();
|
throw new BadCommandForRegistryPhaseException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,6 +58,10 @@ public class LaunchPhase extends ImmutableObject {
|
||||||
/**
|
/**
|
||||||
* The phase during which trademark holders can submit registrations or applications with
|
* The phase during which trademark holders can submit registrations or applications with
|
||||||
* trademark information that can be validated by the server.
|
* 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);
|
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);
|
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". */
|
/** A post-launch phase that is also referred to as "steady state". */
|
||||||
public static final LaunchPhase OPEN = create("open", null);
|
public static final LaunchPhase OPEN = create("open", null);
|
||||||
|
|
||||||
|
|
|
@ -1778,6 +1778,19 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
|
||||||
assertNoLordn("0000001761376042759136-65535", null);
|
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
|
@Test
|
||||||
public void testFail_startDateSunriseRegistration_wrongEncodedSignedMark() throws Exception {
|
public void testFail_startDateSunriseRegistration_wrongEncodedSignedMark() throws Exception {
|
||||||
createTld("tld", TldState.START_DATE_SUNRISE);
|
createTld("tld", TldState.START_DATE_SUNRISE);
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
</create>
|
</create>
|
||||||
<extension>
|
<extension>
|
||||||
<launch:create xmlns:launch="urn:ietf:params:xml:ns:launch-1.0" type="registration">
|
<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>
|
</launch:create>
|
||||||
<metadata:metadata xmlns:metadata="urn:google:params:xml:ns:metadata-1.0">
|
<metadata:metadata xmlns:metadata="urn:google:params:xml:ns:metadata-1.0">
|
||||||
<metadata:requestedByRegistrar>true</metadata:requestedByRegistrar>
|
<metadata:requestedByRegistrar>true</metadata:requestedByRegistrar>
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
<launch:create
|
<launch:create
|
||||||
xmlns:launch="urn:ietf:params:xml:ns:launch-1.0"
|
xmlns:launch="urn:ietf:params:xml:ns:launch-1.0"
|
||||||
type="registration">
|
type="registration">
|
||||||
<launch:phase name="start-date">sunrise</launch:phase>
|
<launch:phase>sunrise</launch:phase>
|
||||||
</launch:create>
|
</launch:create>
|
||||||
</extension>
|
</extension>
|
||||||
<clTRID>ABC-12345</clTRID>
|
<clTRID>ABC-12345</clTRID>
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
</create>
|
</create>
|
||||||
<extension>
|
<extension>
|
||||||
<launch:create xmlns:launch="urn:ietf:params:xml:ns:launch-1.0" type="registration">
|
<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:notice>
|
||||||
<launch:noticeID>370d0b7c9223372036854775807</launch:noticeID>
|
<launch:noticeID>370d0b7c9223372036854775807</launch:noticeID>
|
||||||
<launch:notAfter>2010-08-16T09:00:00.0Z</launch:notAfter>
|
<launch:notAfter>2010-08-16T09:00:00.0Z</launch:notAfter>
|
||||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue