mirror of
https://github.com/google/nomulus
synced 2026-02-07 13:31:12 +00:00
Add support for a domain transfer request superuser EPP extension
Allow superusers to change the transfer period to zero years and allow superusers to change the automatic transfer length. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=167598314
This commit is contained in:
@@ -23,10 +23,12 @@ import google.registry.flows.EppException.UnimplementedExtensionException;
|
||||
import google.registry.flows.ExtensionManager.UndeclaredServiceExtensionException;
|
||||
import google.registry.flows.ExtensionManager.UnsupportedRepeatedExtensionException;
|
||||
import google.registry.flows.exceptions.OnlyToolCanPassMetadataException;
|
||||
import google.registry.flows.exceptions.UnauthorizedForSuperuserExtensionException;
|
||||
import google.registry.flows.session.HelloFlow;
|
||||
import google.registry.model.domain.fee06.FeeInfoCommandExtensionV06;
|
||||
import google.registry.model.domain.launch.LaunchCreateExtension;
|
||||
import google.registry.model.domain.metadata.MetadataExtension;
|
||||
import google.registry.model.domain.superuser.DomainTransferRequestSuperuserExtension;
|
||||
import google.registry.model.eppcommon.ProtocolDefinition.ServiceExtension;
|
||||
import google.registry.model.eppinput.EppInput;
|
||||
import google.registry.model.eppinput.EppInput.CommandExtension;
|
||||
@@ -133,6 +135,44 @@ public class ExtensionManagerTest {
|
||||
manager.validate();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuperuserExtension_allowedForToolSource() throws Exception {
|
||||
ExtensionManager manager = new TestInstanceBuilder()
|
||||
.setEppRequestSource(EppRequestSource.TOOL)
|
||||
.setDeclaredUris()
|
||||
.setSuppliedExtensions(DomainTransferRequestSuperuserExtension.class)
|
||||
.setIsSuperuser(true)
|
||||
.build();
|
||||
manager.register(DomainTransferRequestSuperuserExtension.class);
|
||||
manager.validate();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuperuserExtension_forbiddenWhenNotSuperuser() throws Exception {
|
||||
ExtensionManager manager = new TestInstanceBuilder()
|
||||
.setEppRequestSource(EppRequestSource.TOOL)
|
||||
.setDeclaredUris()
|
||||
.setSuppliedExtensions(DomainTransferRequestSuperuserExtension.class)
|
||||
.setIsSuperuser(false)
|
||||
.build();
|
||||
manager.register(DomainTransferRequestSuperuserExtension.class);
|
||||
thrown.expect(UnauthorizedForSuperuserExtensionException.class);
|
||||
manager.validate();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuperuserExtension_forbiddenWhenNotToolSource() throws Exception {
|
||||
ExtensionManager manager = new TestInstanceBuilder()
|
||||
.setEppRequestSource(EppRequestSource.CONSOLE)
|
||||
.setDeclaredUris()
|
||||
.setSuppliedExtensions(DomainTransferRequestSuperuserExtension.class)
|
||||
.setIsSuperuser(true)
|
||||
.build();
|
||||
manager.register(DomainTransferRequestSuperuserExtension.class);
|
||||
thrown.expect(UnauthorizedForSuperuserExtensionException.class);
|
||||
manager.validate();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnimplementedExtensionsForbidden() throws Exception {
|
||||
ExtensionManager manager = new TestInstanceBuilder()
|
||||
@@ -160,6 +200,11 @@ public class ExtensionManagerTest {
|
||||
return this;
|
||||
}
|
||||
|
||||
TestInstanceBuilder setIsSuperuser(boolean isSuperuser) {
|
||||
manager.isSuperuser = isSuperuser;
|
||||
return this;
|
||||
}
|
||||
|
||||
@SafeVarargs
|
||||
final TestInstanceBuilder setSuppliedExtensions(
|
||||
Class<? extends CommandExtension>... suppliedExtensionClasses) {
|
||||
|
||||
Reference in New Issue
Block a user