diff --git a/core/src/main/java/google/registry/flows/EppException.java b/core/src/main/java/google/registry/flows/EppException.java index 76c9aea2b..6ef2dd3fe 100644 --- a/core/src/main/java/google/registry/flows/EppException.java +++ b/core/src/main/java/google/registry/flows/EppException.java @@ -209,6 +209,7 @@ public abstract class EppException extends Exception { /** Specified command is not implemented. */ @EppResultCode(Code.UNIMPLEMENTED_COMMAND) public static class UnimplementedCommandException extends EppException { + public UnimplementedCommandException(InnerCommand command) { super(String.format( "No flow found for %s with extension %s", @@ -217,6 +218,10 @@ public abstract class EppException extends Exception { ? ((ResourceCommandWrapper) command).getResourceCommand().getClass().getSimpleName() : null)); } + + public UnimplementedCommandException(String message) { + super(message); + } } /** Abstract exception class. Do not throw this directly or catch in tests. */ diff --git a/core/src/main/java/google/registry/flows/picker/FlowPicker.java b/core/src/main/java/google/registry/flows/picker/FlowPicker.java index 87057a234..34d7fedcf 100644 --- a/core/src/main/java/google/registry/flows/picker/FlowPicker.java +++ b/core/src/main/java/google/registry/flows/picker/FlowPicker.java @@ -82,6 +82,9 @@ public class FlowPicker { /** Marker class for unimplemented flows. */ private abstract static class UnimplementedFlow implements Flow {} + /** Marker class for unimplemented restore flows. */ + private abstract static class UnimplementedRestoreFlow implements Flow {} + /** A function type that takes an {@link EppInput} and returns a {@link Flow} class. */ private abstract static class FlowProvider { /** Get the flow associated with this {@link EppInput} or return null to signal no match. */ @@ -160,7 +163,7 @@ public class FlowPicker { // Restore command with an op of "report" is not currently supported. return (rgpUpdateExtension.get().getRestoreCommand().getRestoreOp() == RestoreOp.REQUEST) ? DomainRestoreRequestFlow.class - : UnimplementedFlow.class; + : UnimplementedRestoreFlow.class; }}; /** @@ -265,8 +268,11 @@ public class FlowPicker { Class flowClass = flowProvider.get(eppInput); if (flowClass == UnimplementedFlow.class) { break; // We found it, but it's marked as not implemented. - } - if (flowClass != null) { + } else if (flowClass == UnimplementedRestoreFlow.class) { + throw new UnimplementedCommandException( + "Domain restores are approved and enacted instantly, " + + "therefore domain restore reports are not supported"); + } else if (flowClass != null) { return flowClass; // We found it! } } diff --git a/core/src/test/java/google/registry/flows/domain/DomainRestoreRequestFlowTest.java b/core/src/test/java/google/registry/flows/domain/DomainRestoreRequestFlowTest.java index 6f25a3c93..5bbd2a741 100644 --- a/core/src/test/java/google/registry/flows/domain/DomainRestoreRequestFlowTest.java +++ b/core/src/test/java/google/registry/flows/domain/DomainRestoreRequestFlowTest.java @@ -632,4 +632,16 @@ public class DomainRestoreRequestFlowTest TransactionReportField.RESTORED_DOMAINS, 1)); } + + @Test + public void testFailure_restoreReportsAreNotSupported() { + setEppInput("domain_update_restore_report.xml"); + // This exception is referred to by its fully qualified path (rather than being imported) so + // that it is not included in the list of exceptions thrown by DomainRestoreRequestFlow, as this + // test EPP won't trigger the request flow at all. + EppException thrown = assertThrows( + google.registry.flows.EppException.UnimplementedCommandException.class, this::runFlow); + assertThat(thrown).hasMessageThat().contains("domain restore reports are not supported"); + assertAboutEppExceptions().that(thrown).marshalsToXml(); + } } diff --git a/core/src/test/java/google/registry/flows/domain/testdata/domain_update_restore_report.xml b/core/src/test/java/google/registry/flows/domain/testdata/domain_update_restore_report.xml new file mode 100644 index 000000000..011f5d3ab --- /dev/null +++ b/core/src/test/java/google/registry/flows/domain/testdata/domain_update_restore_report.xml @@ -0,0 +1,46 @@ + + + + + example.com + + + + + + + + Pre-delete registration data goes here. + Both XML and free text are allowed. + Post-restore registration data goes here. + Both XML and free text are allowed. + 2003-07-10T22:00:00.0Z + 2003-07-20T22:00:00.0Z + Registrant error. + This registrar has not restored the + Registered Name in order to assume the rights to use + or sell the Registered Name for itself or for any + third party. + The information in this report is + true to best of this registrar's knowledge, and this + registrar acknowledges that intentionally supplying + false information in this report shall constitute an + incurable material breach of the + Registry-Registrar Agreement. + Supporting information goes + here. + + + + + ABC-12345 + +