HistoryEntry for extra logic; update fee check

While working on an implementation of TLD-specific logic, it was realized that the extra logic methods would need access to the flow's HistoryEntry, so that things like poll messages could be parented properly.

Also, the update flow had not been fixed to perform the fee check.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=132561527
This commit is contained in:
mountford 2016-09-08 09:04:07 -07:00 committed by Ben McIlwain
parent 95cc7ab3d8
commit a63921350b
13 changed files with 129 additions and 21 deletions

View file

@ -55,6 +55,8 @@ import google.registry.flows.domain.BaseDomainUpdateFlow.MaxSigLifeChangeNotSupp
import google.registry.flows.domain.BaseDomainUpdateFlow.SecDnsAllUsageException;
import google.registry.flows.domain.BaseDomainUpdateFlow.UrgentAttributeNotSupportedException;
import google.registry.flows.domain.DomainFlowUtils.DuplicateContactForRoleException;
import google.registry.flows.domain.DomainFlowUtils.FeesMismatchException;
import google.registry.flows.domain.DomainFlowUtils.FeesRequiredForNonFreeUpdateException;
import google.registry.flows.domain.DomainFlowUtils.LinkedResourceInPendingDeleteProhibitsOperationException;
import google.registry.flows.domain.DomainFlowUtils.LinkedResourcesDoNotExistException;
import google.registry.flows.domain.DomainFlowUtils.MissingAdminContactException;
@ -1181,10 +1183,28 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
}
@Test
public void testAddAndRemoveFlags() throws Exception {
public void testAddAndRemoveFlags_noFee() throws Exception {
setEppInput("domain_update_addremove_flags.xml");
persistReferencedEntities();
persistDomain();
thrown.expect(FeesRequiredForNonFreeUpdateException.class);
runFlow();
}
@Test
public void testAddAndRemoveFlags_wrongFee() throws Exception {
setEppInput("domain_update_addremove_flags_fee.xml", ImmutableMap.of("FEE", "11.00"));
persistReferencedEntities();
persistDomain();
thrown.expect(FeesMismatchException.class);
runFlow();
}
@Test
public void testAddAndRemoveFlags_correctFee() throws Exception {
setEppInput("domain_update_addremove_flags_fee.xml", ImmutableMap.of("FEE", "13.00"));
persistReferencedEntities();
persistDomain();
thrown.expect(IllegalArgumentException.class, "add:flag1,flag2;remove:flag3,flag4");
runFlow();
}

View file

@ -3,7 +3,7 @@
<update>
<domain:update
xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
<domain:name>example.flags</domain:name>
<domain:name>update-13.flags</domain:name>
</domain:update>
</update>
<extension>

View file

@ -0,0 +1,27 @@
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
<command>
<update>
<domain:update
xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
<domain:name>update-13.flags</domain:name>
</domain:update>
</update>
<extension>
<flags:update xmlns:flags="urn:google:params:xml:ns:flags-0.1">
<flags:add>
<flags:flag>flag1</flags:flag>
<flags:flag>flag2</flags:flag>
</flags:add>
<flags:rem>
<flags:flag>flag3</flags:flag>
<flags:flag>flag4</flags:flag>
</flags:rem>
</flags:update>
<fee:update xmlns:fee="urn:ietf:params:xml:ns:fee-0.6">
<fee:currency>USD</fee:currency>
<fee:fee>%FEE%</fee:fee>
</fee:update>
</extension>
<clTRID>ABC-12345</clTRID>
</command>
</epp>

View file

@ -31,6 +31,7 @@ import google.registry.model.domain.flags.FlagsCreateCommandExtension;
import google.registry.model.domain.flags.FlagsTransferCommandExtension;
import google.registry.model.domain.flags.FlagsUpdateCommandExtension;
import google.registry.model.eppinput.EppInput;
import google.registry.model.reporting.HistoryEntry;
import java.math.BigDecimal;
import java.util.List;
import org.joda.time.DateTime;
@ -95,7 +96,8 @@ public class TestExtraLogicManager implements RegistryExtraFlowLogic {
String clientIdentifier,
DateTime asOfDate,
int years,
EppInput eppInput) throws EppException {
EppInput eppInput,
HistoryEntry historyEntry) throws EppException {
FlagsCreateCommandExtension flags =
eppInput.getSingleExtension(FlagsCreateCommandExtension.class);
if (flags == null) {
@ -113,7 +115,8 @@ public class TestExtraLogicManager implements RegistryExtraFlowLogic {
DomainResource domainResource,
String clientIdentifier,
DateTime asOfDate,
EppInput eppInput) throws EppException {
EppInput eppInput,
HistoryEntry historyEntry) throws EppException {
messageToThrow = "deleted";
}
@ -138,7 +141,8 @@ public class TestExtraLogicManager implements RegistryExtraFlowLogic {
String clientIdentifier,
DateTime asOfDate,
int years,
EppInput eppInput) throws EppException {
EppInput eppInput,
HistoryEntry historyEntry) throws EppException {
messageToThrow = "renewed";
}
@ -151,7 +155,8 @@ public class TestExtraLogicManager implements RegistryExtraFlowLogic {
DomainResource domainResource,
String clientIdentifier,
DateTime asOfDate,
EppInput eppInput) throws EppException {
EppInput eppInput,
HistoryEntry historyEntry) throws EppException {
messageToThrow = "restored";
}
@ -165,7 +170,8 @@ public class TestExtraLogicManager implements RegistryExtraFlowLogic {
String clientIdentifier,
DateTime asOfDate,
int years,
EppInput eppInput) throws EppException {
EppInput eppInput,
HistoryEntry historyEntry) throws EppException {
FlagsTransferCommandExtension flags =
eppInput.getSingleExtension(FlagsTransferCommandExtension.class);
if (flags == null) {
@ -197,7 +203,8 @@ public class TestExtraLogicManager implements RegistryExtraFlowLogic {
DomainResource domainResource,
String clientIdentifier,
DateTime asOfDate,
EppInput eppInput) throws EppException {
EppInput eppInput,
HistoryEntry historyEntry) throws EppException {
FlagsUpdateCommandExtension flags =
eppInput.getSingleExtension(FlagsUpdateCommandExtension.class);
if (flags == null) {