mirror of
https://github.com/google/nomulus.git
synced 2025-05-13 07:57:13 +02:00
Add extra flow logic hook for application info
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=138683307
This commit is contained in:
parent
09beacf746
commit
59c213c66f
8 changed files with 206 additions and 10 deletions
|
@ -35,6 +35,7 @@ import google.registry.flows.FlowModule.ClientId;
|
||||||
import google.registry.flows.FlowModule.TargetId;
|
import google.registry.flows.FlowModule.TargetId;
|
||||||
import google.registry.model.domain.DomainApplication;
|
import google.registry.model.domain.DomainApplication;
|
||||||
import google.registry.model.domain.DomainCommand.Info;
|
import google.registry.model.domain.DomainCommand.Info;
|
||||||
|
import google.registry.model.domain.flags.FlagsInfoResponseExtension;
|
||||||
import google.registry.model.domain.launch.LaunchInfoExtension;
|
import google.registry.model.domain.launch.LaunchInfoExtension;
|
||||||
import google.registry.model.domain.launch.LaunchInfoResponseExtension;
|
import google.registry.model.domain.launch.LaunchInfoResponseExtension;
|
||||||
import google.registry.model.eppcommon.AuthInfo;
|
import google.registry.model.eppcommon.AuthInfo;
|
||||||
|
@ -46,7 +47,9 @@ import google.registry.model.mark.Mark;
|
||||||
import google.registry.model.smd.EncodedSignedMark;
|
import google.registry.model.smd.EncodedSignedMark;
|
||||||
import google.registry.model.smd.SignedMark;
|
import google.registry.model.smd.SignedMark;
|
||||||
import google.registry.util.Clock;
|
import google.registry.util.Clock;
|
||||||
|
import java.util.Set;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
import org.joda.time.DateTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An EPP flow that returns information about a domain application.
|
* An EPP flow that returns information about a domain application.
|
||||||
|
@ -78,6 +81,7 @@ public final class DomainApplicationInfoFlow implements Flow {
|
||||||
extensionManager.register(LaunchInfoExtension.class);
|
extensionManager.register(LaunchInfoExtension.class);
|
||||||
extensionManager.validate();
|
extensionManager.validate();
|
||||||
validateClientIsLoggedIn(clientId);
|
validateClientIsLoggedIn(clientId);
|
||||||
|
DateTime now = clock.nowUtc();
|
||||||
if (applicationId.isEmpty()) {
|
if (applicationId.isEmpty()) {
|
||||||
throw new MissingApplicationIdException();
|
throw new MissingApplicationIdException();
|
||||||
}
|
}
|
||||||
|
@ -95,7 +99,7 @@ public final class DomainApplicationInfoFlow implements Flow {
|
||||||
verifyResourceOwnership(clientId, application);
|
verifyResourceOwnership(clientId, application);
|
||||||
return responseBuilder
|
return responseBuilder
|
||||||
.setResData(getResourceInfo(application))
|
.setResData(getResourceInfo(application))
|
||||||
.setExtensions(getDomainResponseExtensions(application, launchInfo))
|
.setExtensions(getDomainResponseExtensions(application, launchInfo, now))
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,8 +115,8 @@ public final class DomainApplicationInfoFlow implements Flow {
|
||||||
return application;
|
return application;
|
||||||
}
|
}
|
||||||
|
|
||||||
ImmutableList<ResponseExtension> getDomainResponseExtensions(
|
ImmutableList<ResponseExtension> getDomainResponseExtensions(DomainApplication application,
|
||||||
DomainApplication application, LaunchInfoExtension launchInfo) {
|
LaunchInfoExtension launchInfo, DateTime now) throws EppException {
|
||||||
ImmutableList.Builder<Mark> marksBuilder = new ImmutableList.Builder<>();
|
ImmutableList.Builder<Mark> marksBuilder = new ImmutableList.Builder<>();
|
||||||
if (Boolean.TRUE.equals(launchInfo.getIncludeMark())) { // Default to false.
|
if (Boolean.TRUE.equals(launchInfo.getIncludeMark())) { // Default to false.
|
||||||
for (EncodedSignedMark encodedMark : application.getEncodedSignedMarks()) {
|
for (EncodedSignedMark encodedMark : application.getEncodedSignedMarks()) {
|
||||||
|
@ -132,6 +136,16 @@ public final class DomainApplicationInfoFlow implements Flow {
|
||||||
.setMarks(marksBuilder.build())
|
.setMarks(marksBuilder.build())
|
||||||
.build());
|
.build());
|
||||||
addSecDnsExtensionIfPresent(extensions, application.getDsData());
|
addSecDnsExtensionIfPresent(extensions, application.getDsData());
|
||||||
|
// If the TLD uses the flags extension, add it to the info response.
|
||||||
|
Optional<RegistryExtraFlowLogic> extraLogicManager =
|
||||||
|
RegistryExtraFlowLogicProxy.newInstanceForDomain(application);
|
||||||
|
if (extraLogicManager.isPresent()) {
|
||||||
|
Set<String> flags = extraLogicManager.get().getApplicationExtensionFlags(
|
||||||
|
application, clientId, now); // As-of date is always now for info commands.
|
||||||
|
if (!flags.isEmpty()) {
|
||||||
|
extensions.add(FlagsInfoResponseExtension.create(ImmutableList.copyOf(flags)));
|
||||||
|
}
|
||||||
|
}
|
||||||
return extensions.build();
|
return extensions.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,11 +29,11 @@ import org.joda.time.DateTime;
|
||||||
*/
|
*/
|
||||||
public interface RegistryExtraFlowLogic {
|
public interface RegistryExtraFlowLogic {
|
||||||
|
|
||||||
/**
|
/** Gets the flags to be returned for application info commands. */
|
||||||
* Gets the flags to be used in the EPP flags extension.
|
public Set<String> getApplicationExtensionFlags(
|
||||||
*
|
DomainApplication application, String clientId, DateTime asOfDate);
|
||||||
* <p>This is used for EPP info commands.
|
|
||||||
*/
|
/** Gets the flags to be returned for domain info commands. */
|
||||||
public Set<String> getExtensionFlags(
|
public Set<String> getExtensionFlags(
|
||||||
DomainResource domainResource, String clientId, DateTime asOfDate);
|
DomainResource domainResource, String clientId, DateTime asOfDate);
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,7 @@ import google.registry.model.domain.DesignatedContact;
|
||||||
import google.registry.model.domain.DesignatedContact.Type;
|
import google.registry.model.domain.DesignatedContact.Type;
|
||||||
import google.registry.model.domain.DomainApplication;
|
import google.registry.model.domain.DomainApplication;
|
||||||
import google.registry.model.domain.DomainAuthInfo;
|
import google.registry.model.domain.DomainAuthInfo;
|
||||||
|
import google.registry.model.domain.TestExtraLogicManager;
|
||||||
import google.registry.model.domain.launch.ApplicationStatus;
|
import google.registry.model.domain.launch.ApplicationStatus;
|
||||||
import google.registry.model.domain.launch.LaunchCreateExtension;
|
import google.registry.model.domain.launch.LaunchCreateExtension;
|
||||||
import google.registry.model.domain.launch.LaunchPhase;
|
import google.registry.model.domain.launch.LaunchPhase;
|
||||||
|
@ -70,6 +71,9 @@ public class DomainApplicationInfoFlowTest
|
||||||
setEppInput("domain_info_sunrise.xml");
|
setEppInput("domain_info_sunrise.xml");
|
||||||
sessionMetadata.setClientId("NewRegistrar");
|
sessionMetadata.setClientId("NewRegistrar");
|
||||||
createTld("tld", TldState.SUNRUSH);
|
createTld("tld", TldState.SUNRUSH);
|
||||||
|
createTld("flags", TldState.SUNRUSH);
|
||||||
|
// For flags extension tests.
|
||||||
|
RegistryExtraFlowLogicProxy.setOverride("flags", TestExtraLogicManager.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void persistTestEntities(HostsState hostsState, MarksState marksState) throws Exception {
|
private void persistTestEntities(HostsState hostsState, MarksState marksState) throws Exception {
|
||||||
|
@ -107,6 +111,34 @@ public class DomainApplicationInfoFlowTest
|
||||||
.build());
|
.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void persistFlagsTestEntities(String domainName, HostsState hostsState) throws Exception {
|
||||||
|
registrant = persistActiveContact("jd1234");
|
||||||
|
contact = persistActiveContact("sh8013");
|
||||||
|
host1 = persistActiveHost("ns1.example.net");
|
||||||
|
host2 = persistActiveHost("ns1.example.tld");
|
||||||
|
application = persistResource(new DomainApplication.Builder()
|
||||||
|
.setRepoId("123-TLD")
|
||||||
|
.setFullyQualifiedDomainName(domainName)
|
||||||
|
.setPhase(LaunchPhase.SUNRUSH)
|
||||||
|
.setCurrentSponsorClientId("NewRegistrar")
|
||||||
|
.setCreationClientId("TheRegistrar")
|
||||||
|
.setLastEppUpdateClientId("NewRegistrar")
|
||||||
|
.setCreationTimeForTest(DateTime.parse("1999-04-03T22:00:00.0Z"))
|
||||||
|
.setLastEppUpdateTime(DateTime.parse("1999-12-03T09:00:00.0Z"))
|
||||||
|
.setLastTransferTime(DateTime.parse("2000-04-08T09:00:00.0Z"))
|
||||||
|
.setRegistrant(Key.create(registrant))
|
||||||
|
.setContacts(ImmutableSet.of(
|
||||||
|
DesignatedContact.create(Type.ADMIN, Key.create(contact)),
|
||||||
|
DesignatedContact.create(Type.TECH, Key.create(contact))))
|
||||||
|
.setNameservers(hostsState.equals(HostsState.HOSTS_EXIST) ? ImmutableSet.of(
|
||||||
|
Key.create(host1), Key.create(host2)) : null)
|
||||||
|
.setAuthInfo(DomainAuthInfo.create(PasswordAuth.create("2fooBAR")))
|
||||||
|
.addStatusValue(StatusValue.PENDING_CREATE)
|
||||||
|
.setApplicationStatus(ApplicationStatus.PENDING_VALIDATION)
|
||||||
|
.setEncodedSignedMarks(null)
|
||||||
|
.build());
|
||||||
|
}
|
||||||
|
|
||||||
private void doSuccessfulTest(String expectedXmlFilename, HostsState hostsState)
|
private void doSuccessfulTest(String expectedXmlFilename, HostsState hostsState)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
assertTransactionalFlow(false);
|
assertTransactionalFlow(false);
|
||||||
|
@ -318,4 +350,21 @@ public class DomainApplicationInfoFlowTest
|
||||||
thrown.expect(ApplicationLaunchPhaseMismatchException.class);
|
thrown.expect(ApplicationLaunchPhaseMismatchException.class);
|
||||||
runFlow();
|
runFlow();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** Test registry extra logic manager with no flags. */
|
||||||
|
@Test
|
||||||
|
public void testExtraLogicManager_noFlags() throws Exception {
|
||||||
|
setEppInput("domain_info_sunrise_flags_none.xml");
|
||||||
|
persistFlagsTestEntities("domain.flags", HostsState.NO_HOSTS_EXIST);
|
||||||
|
doSuccessfulTest("domain_info_response_sunrise_flags_none.xml", HostsState.NO_HOSTS_EXIST);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Test registry extra logic manager with two flags. */
|
||||||
|
@Test
|
||||||
|
public void testExtraLogicManager_twoFlags() throws Exception {
|
||||||
|
setEppInput("domain_info_sunrise_flags_two.xml");
|
||||||
|
persistFlagsTestEntities("domain-flag1-flag2.flags", HostsState.NO_HOSTS_EXIST);
|
||||||
|
doSuccessfulTest("domain_info_response_sunrise_flags_two.xml", HostsState.NO_HOSTS_EXIST);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
37
javatests/google/registry/flows/domain/testdata/domain_info_response_sunrise_flags_none.xml
vendored
Normal file
37
javatests/google/registry/flows/domain/testdata/domain_info_response_sunrise_flags_none.xml
vendored
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
|
||||||
|
<response>
|
||||||
|
<result code="1000">
|
||||||
|
<msg>Command completed successfully</msg>
|
||||||
|
</result>
|
||||||
|
<resData>
|
||||||
|
<domain:infData xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
|
||||||
|
<domain:name>domain.flags</domain:name>
|
||||||
|
<domain:roid>%ROID%</domain:roid>
|
||||||
|
<domain:status s="pendingCreate"/>
|
||||||
|
<domain:registrant>jd1234</domain:registrant>
|
||||||
|
<domain:contact type="admin">sh8013</domain:contact>
|
||||||
|
<domain:contact type="tech">sh8013</domain:contact>
|
||||||
|
<domain:clID>NewRegistrar</domain:clID>
|
||||||
|
<domain:crID>TheRegistrar</domain:crID>
|
||||||
|
<domain:crDate>1999-04-03T22:00:00.0Z</domain:crDate>
|
||||||
|
<domain:upID>NewRegistrar</domain:upID>
|
||||||
|
<domain:upDate>1999-12-03T09:00:00.0Z</domain:upDate>
|
||||||
|
<domain:authInfo>
|
||||||
|
<domain:pw>2fooBAR</domain:pw>
|
||||||
|
</domain:authInfo>
|
||||||
|
</domain:infData>
|
||||||
|
</resData>
|
||||||
|
<extension>
|
||||||
|
<launch:infData xmlns:launch="urn:ietf:params:xml:ns:launch-1.0">
|
||||||
|
<launch:phase name="landrush">sunrise</launch:phase>
|
||||||
|
<launch:applicationID>123-TLD</launch:applicationID>
|
||||||
|
<launch:status s="pendingValidation"/>
|
||||||
|
</launch:infData>
|
||||||
|
</extension>
|
||||||
|
<trID>
|
||||||
|
<clTRID>ABC-12345</clTRID>
|
||||||
|
<svTRID>server-trid</svTRID>
|
||||||
|
</trID>
|
||||||
|
</response>
|
||||||
|
</epp>
|
41
javatests/google/registry/flows/domain/testdata/domain_info_response_sunrise_flags_two.xml
vendored
Normal file
41
javatests/google/registry/flows/domain/testdata/domain_info_response_sunrise_flags_two.xml
vendored
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
|
||||||
|
<response>
|
||||||
|
<result code="1000">
|
||||||
|
<msg>Command completed successfully</msg>
|
||||||
|
</result>
|
||||||
|
<resData>
|
||||||
|
<domain:infData xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
|
||||||
|
<domain:name>domain-flag1-flag2.flags</domain:name>
|
||||||
|
<domain:roid>%ROID%</domain:roid>
|
||||||
|
<domain:status s="pendingCreate"/>
|
||||||
|
<domain:registrant>jd1234</domain:registrant>
|
||||||
|
<domain:contact type="admin">sh8013</domain:contact>
|
||||||
|
<domain:contact type="tech">sh8013</domain:contact>
|
||||||
|
<domain:clID>NewRegistrar</domain:clID>
|
||||||
|
<domain:crID>TheRegistrar</domain:crID>
|
||||||
|
<domain:crDate>1999-04-03T22:00:00.0Z</domain:crDate>
|
||||||
|
<domain:upID>NewRegistrar</domain:upID>
|
||||||
|
<domain:upDate>1999-12-03T09:00:00.0Z</domain:upDate>
|
||||||
|
<domain:authInfo>
|
||||||
|
<domain:pw>2fooBAR</domain:pw>
|
||||||
|
</domain:authInfo>
|
||||||
|
</domain:infData>
|
||||||
|
</resData>
|
||||||
|
<extension>
|
||||||
|
<launch:infData xmlns:launch="urn:ietf:params:xml:ns:launch-1.0">
|
||||||
|
<launch:phase name="landrush">sunrise</launch:phase>
|
||||||
|
<launch:applicationID>123-TLD</launch:applicationID>
|
||||||
|
<launch:status s="pendingValidation"/>
|
||||||
|
</launch:infData>
|
||||||
|
<flags:infData xmlns:flags="urn:google:params:xml:ns:flags-0.1">
|
||||||
|
<flags:flag>flag1</flags:flag>
|
||||||
|
<flags:flag>flag2</flags:flag>
|
||||||
|
</flags:infData>
|
||||||
|
</extension>
|
||||||
|
<trID>
|
||||||
|
<clTRID>ABC-12345</clTRID>
|
||||||
|
<svTRID>server-trid</svTRID>
|
||||||
|
</trID>
|
||||||
|
</response>
|
||||||
|
</epp>
|
19
javatests/google/registry/flows/domain/testdata/domain_info_sunrise_flags_none.xml
vendored
Normal file
19
javatests/google/registry/flows/domain/testdata/domain_info_sunrise_flags_none.xml
vendored
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
|
||||||
|
<command>
|
||||||
|
<info>
|
||||||
|
<domain:info
|
||||||
|
xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
|
||||||
|
<domain:name>domain.flags</domain:name>
|
||||||
|
</domain:info>
|
||||||
|
</info>
|
||||||
|
<extension>
|
||||||
|
<launch:info
|
||||||
|
xmlns:launch="urn:ietf:params:xml:ns:launch-1.0">
|
||||||
|
<launch:phase name="landrush">sunrise</launch:phase>
|
||||||
|
<launch:applicationID>123-TLD</launch:applicationID>
|
||||||
|
</launch:info>
|
||||||
|
</extension>
|
||||||
|
<clTRID>ABC-12345</clTRID>
|
||||||
|
</command>
|
||||||
|
</epp>
|
19
javatests/google/registry/flows/domain/testdata/domain_info_sunrise_flags_two.xml
vendored
Normal file
19
javatests/google/registry/flows/domain/testdata/domain_info_sunrise_flags_two.xml
vendored
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
|
||||||
|
<command>
|
||||||
|
<info>
|
||||||
|
<domain:info
|
||||||
|
xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
|
||||||
|
<domain:name>domain-flag1-flag2.flags</domain:name>
|
||||||
|
</domain:info>
|
||||||
|
</info>
|
||||||
|
<extension>
|
||||||
|
<launch:info
|
||||||
|
xmlns:launch="urn:ietf:params:xml:ns:launch-1.0">
|
||||||
|
<launch:phase name="landrush">sunrise</launch:phase>
|
||||||
|
<launch:applicationID>123-TLD</launch:applicationID>
|
||||||
|
</launch:info>
|
||||||
|
</extension>
|
||||||
|
<clTRID>ABC-12345</clTRID>
|
||||||
|
</command>
|
||||||
|
</epp>
|
|
@ -66,13 +66,30 @@ public class TestExtraLogicManager implements RegistryExtraFlowLogic {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Set<String> getExtensionFlags(
|
public Set<String> getExtensionFlags(
|
||||||
DomainResource domainResource, String clientId, DateTime asOfDate) {
|
DomainResource domain, String clientId, DateTime asOfDate) {
|
||||||
// Take the part before the period, split by dashes, and treat each part after the first as
|
// Take the part before the period, split by dashes, and treat each part after the first as
|
||||||
// a flag.
|
// a flag.
|
||||||
List<String> components =
|
List<String> components =
|
||||||
Splitter.on('-').splitToList(
|
Splitter.on('-').splitToList(
|
||||||
Iterables.getFirst(
|
Iterables.getFirst(
|
||||||
Splitter.on('.').split(domainResource.getFullyQualifiedDomainName()), ""));
|
Splitter.on('.').split(domain.getFullyQualifiedDomainName()), ""));
|
||||||
|
return ImmutableSet.copyOf(components.subList(1, components.size()));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the flags to be used in the EPP flags extension for application info commands.
|
||||||
|
*
|
||||||
|
* <p>This method works the same way as getExtensionFlags().
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Set<String> getApplicationExtensionFlags(
|
||||||
|
DomainApplication application, String clientId, DateTime asOfDate) {
|
||||||
|
// Take the part before the period, split by dashes, and treat each part after the first as
|
||||||
|
// a flag.
|
||||||
|
List<String> components =
|
||||||
|
Splitter.on('-').splitToList(
|
||||||
|
Iterables.getFirst(
|
||||||
|
Splitter.on('.').split(application.getFullyQualifiedDomainName()), ""));
|
||||||
return ImmutableSet.copyOf(components.subList(1, components.size()));
|
return ImmutableSet.copyOf(components.subList(1, components.size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue