Update create logic to ignore signed marks unless in sunrise

This addresses an issue where the existing logic assumed that the presence of a
signed mark means the current flow is a sunrise/sunrush request, when this isn't
necessarily true. It's safe to ignore signed marks in other circumstances.

This is a combination of work by Justin Graham <justin.af.graham@gmail.com>,
Nick Felt, and me (Ben). It is based on the original PR located at:
https://github.com/google/nomulus/pull/41

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=140784461
This commit is contained in:
mcilwain 2016-12-01 15:14:55 -08:00 committed by Ben McIlwain
parent 59f4984083
commit 3740171bbf
7 changed files with 79 additions and 43 deletions

View file

@ -58,7 +58,6 @@ import google.registry.flows.ExtensionManager.UndeclaredServiceExtensionExceptio
import google.registry.flows.ResourceFlowTestCase;
import google.registry.flows.domain.DomainCreateFlow.DomainHasOpenApplicationsException;
import google.registry.flows.domain.DomainCreateFlow.NoGeneralRegistrationsInCurrentPhaseException;
import google.registry.flows.domain.DomainCreateFlow.SignedMarksNotAcceptedInCurrentPhaseException;
import google.registry.flows.domain.DomainFlowUtils.AcceptedTooLongAgoException;
import google.registry.flows.domain.DomainFlowUtils.BadDomainNameCharacterException;
import google.registry.flows.domain.DomainFlowUtils.BadDomainNamePartsCountException;
@ -123,6 +122,7 @@ import google.registry.model.reporting.HistoryEntry;
import google.registry.testing.DatastoreHelper;
import google.registry.testing.TaskQueueHelper.TaskMatcher;
import java.util.Map;
import javax.annotation.Nullable;
import org.joda.money.CurrencyUnit;
import org.joda.money.Money;
import org.joda.time.DateTime;
@ -252,9 +252,14 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
}
private void assertNoLordn() throws Exception {
assertNoLordn(null, null);
}
private void assertNoLordn(
@Nullable String smdId, @Nullable LaunchNotice launchNotice) throws Exception {
assertAboutDomains().that(reloadResourceByForeignKey())
.hasSmdId(null).and()
.hasLaunchNotice(null);
.hasSmdId(smdId).and()
.hasLaunchNotice(launchNotice);
assertNoTasksEnqueued(QUEUE_CLAIMS, QUEUE_SUNRISE);
}
@ -411,6 +416,18 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
doSuccessfulTest();
}
@Test
public void testSuccess_generalAvailability_ignoresEncodedSignedMark() throws Exception {
createTld("tld", TldState.GENERAL_AVAILABILITY);
clock.setTo(DateTime.parse("2014-09-09T09:09:09Z"));
setEppInput("domain_create_registration_encoded_signed_mark.xml");
eppRequestSource = EppRequestSource.TOOL; // Only tools can pass in metadata.
persistContactsAndHosts();
runFlow();
assertSuccessfulCreate("tld", true);
assertNoLordn("0000001761376042759136-65535", null);
}
@Test
public void testSuccess_fee_v06() throws Exception {
setEppInput("domain_create_fee.xml", ImmutableMap.of("FEE_VERSION", "0.6"));
@ -1210,10 +1227,11 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
}
@Test
public void testFailure_signedMark() throws Exception {
public void testFailure_signedMarkWithoutAnchorTenant() throws Exception {
createTld("tld", TldState.SUNRISE);
setEppInput("domain_create_signed_mark.xml");
persistContactsAndHosts();
thrown.expect(SignedMarksNotAcceptedInCurrentPhaseException.class);
thrown.expect(NoGeneralRegistrationsInCurrentPhaseException.class);
runFlow();
}
@ -1450,7 +1468,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
}
@Test
public void testSuccess_qlpSunriseRegistrationWithEncodedSignedMark() throws Exception {
public void testSuccess_qlpSunriseRegistration_withEncodedSignedMark() throws Exception {
createTld("tld", TldState.SUNRISE);
clock.setTo(DateTime.parse("2014-09-09T09:09:09Z"));
setEppInput("domain_create_registration_qlp_sunrise_encoded_signed_mark.xml");
@ -1462,7 +1480,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
}
@Test
public void testSuccess_qlpSunriseRegistrationWithClaimsNotice() throws Exception {
public void testSuccess_qlpSunriseRegistration_withClaimsNotice() throws Exception {
createTld("tld", TldState.SUNRISE);
clock.setTo(DateTime.parse("2009-08-16T09:00:00.0Z"));
setEppInput("domain_create_registration_qlp_sunrise_claims_notice.xml");
@ -1515,7 +1533,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
}
@Test
public void testSuccess_qlpSunrushRegistrationWithEncodedSignedMark() throws Exception {
public void testSuccess_qlpSunrushRegistration_withEncodedSignedMark() throws Exception {
createTld("tld", TldState.SUNRUSH);
clock.setTo(DateTime.parse("2014-09-09T09:09:09Z"));
setEppInput("domain_create_registration_qlp_sunrush_encoded_signed_mark.xml");
@ -1527,7 +1545,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
}
@Test
public void testSuccess_qlpSunrushRegistrationWithClaimsNotice() throws Exception {
public void testSuccess_qlpSunrushRegistration_withClaimsNotice() throws Exception {
createTld("tld", TldState.SUNRUSH);
clock.setTo(DateTime.parse("2009-08-16T09:00:00.0Z"));
setEppInput("domain_create_registration_qlp_sunrush_claims_notice.xml");
@ -1567,18 +1585,19 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
}
@Test
public void testFailure_qlpLandrushRegistrationWithEncodedSignedMark() throws Exception {
public void testSuccess_qlpLandrushRegistration_ignoresEncodedSignedMark() throws Exception {
createTld("tld", TldState.LANDRUSH);
clock.setTo(DateTime.parse("2014-09-09T09:09:09Z"));
setEppInput("domain_create_registration_qlp_landrush_encoded_signed_mark.xml");
eppRequestSource = EppRequestSource.TOOL; // Only tools can pass in metadata.
persistContactsAndHosts();
thrown.expect(SignedMarksNotAcceptedInCurrentPhaseException.class);
runFlow();
assertSuccessfulCreate("tld", true);
assertNoLordn("0000001761376042759136-65535", null);
}
@Test
public void testSuccess_qlpLandrushRegistrationWithClaimsNotice() throws Exception {
public void testSuccess_qlpLandrushRegistration_withClaimsNotice() throws Exception {
createTld("tld", TldState.LANDRUSH);
clock.setTo(DateTime.parse("2009-08-16T09:00:00.0Z"));
setEppInput("domain_create_registration_qlp_landrush_claims_notice.xml");