Skip to content

Commit 0777be3

Browse files
authored
Allow superuser ext to override client/server transfer prohibited (#2890)
The superuser can remove/add those statuses anyway, so there's not really any point. This also saves us trouble if we need to do a BTAPPA transfer.
1 parent f9cd167 commit 0777be3

File tree

2 files changed

+55
-5
lines changed

2 files changed

+55
-5
lines changed

core/src/main/java/google/registry/flows/domain/DomainTransferRequestFlow.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,9 @@
133133
@ReportingSpec(ActivityReportField.DOMAIN_TRANSFER_REQUEST)
134134
public final class DomainTransferRequestFlow implements MutatingFlow {
135135

136-
private static final ImmutableSet<StatusValue> DISALLOWED_STATUSES = ImmutableSet.of(
137-
StatusValue.CLIENT_TRANSFER_PROHIBITED,
138-
StatusValue.PENDING_DELETE,
139-
StatusValue.SERVER_TRANSFER_PROHIBITED);
136+
private static final ImmutableSet<StatusValue> NON_SUPERUSER_DISALLOWED_STATUSES =
137+
ImmutableSet.of(
138+
StatusValue.CLIENT_TRANSFER_PROHIBITED, StatusValue.SERVER_TRANSFER_PROHIBITED);
140139

141140
@Inject ResourceCommand resourceCommand;
142141
@Inject ExtensionManager extensionManager;
@@ -299,8 +298,9 @@ private void verifyTransferAllowed(
299298
DateTime now,
300299
Optional<DomainTransferRequestSuperuserExtension> superuserExtension)
301300
throws EppException {
302-
verifyNoDisallowedStatuses(existingDomain, DISALLOWED_STATUSES);
301+
verifyNoDisallowedStatuses(existingDomain, ImmutableSet.of(StatusValue.PENDING_DELETE));
303302
if (!isSuperuser) {
303+
verifyNoDisallowedStatuses(existingDomain, NON_SUPERUSER_DISALLOWED_STATUSES);
304304
verifyAuthInfoPresentForResourceTransfer(authInfo);
305305
verifyAuthInfo(authInfo.get(), existingDomain);
306306
}

core/src/test/java/google/registry/flows/domain/DomainTransferRequestFlowTest.java

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1004,6 +1004,40 @@ void testFailure_superuserExtension_zeroPeriod_feeTransferExtension() {
10041004
ImmutableMap.of("PERIOD", "0", "AUTOMATIC_TRANSFER_LENGTH", "5")));
10051005
}
10061006

1007+
@Test
1008+
void testSuccess_superuserExtension_clientTransferProhibited() throws Exception {
1009+
setupDomain("example", "tld");
1010+
eppRequestSource = EppRequestSource.TOOL;
1011+
domain =
1012+
persistResource(
1013+
domain.asBuilder().addStatusValue(StatusValue.CLIENT_TRANSFER_PROHIBITED).build());
1014+
doSuccessfulSuperuserExtensionTest(
1015+
"domain_transfer_request_superuser_extension.xml",
1016+
"domain_transfer_request_response_su_ext_zero_period_zero_transfer_length.xml",
1017+
domain.getRegistrationExpirationTime().plusYears(0),
1018+
ImmutableMap.of("PERIOD", "0", "AUTOMATIC_TRANSFER_LENGTH", "0"),
1019+
Optional.empty(),
1020+
Period.create(0, Unit.YEARS),
1021+
Duration.ZERO);
1022+
}
1023+
1024+
@Test
1025+
void testSuccess_superuserExtension_serverTransferProhibited() throws Exception {
1026+
setupDomain("example", "tld");
1027+
eppRequestSource = EppRequestSource.TOOL;
1028+
domain =
1029+
persistResource(
1030+
domain.asBuilder().addStatusValue(StatusValue.SERVER_TRANSFER_PROHIBITED).build());
1031+
doSuccessfulSuperuserExtensionTest(
1032+
"domain_transfer_request_superuser_extension.xml",
1033+
"domain_transfer_request_response_su_ext_zero_period_zero_transfer_length.xml",
1034+
domain.getRegistrationExpirationTime().plusYears(0),
1035+
ImmutableMap.of("PERIOD", "0", "AUTOMATIC_TRANSFER_LENGTH", "0"),
1036+
Optional.empty(),
1037+
Period.create(0, Unit.YEARS),
1038+
Duration.ZERO);
1039+
}
1040+
10071041
@Test
10081042
void testSuccess_cappedExpiration() throws Exception {
10091043
setupDomain("example", "tld");
@@ -1809,6 +1843,22 @@ void testFailure_pendingDelete() {
18091843
assertThat(thrown).hasMessageThat().contains("pendingDelete");
18101844
}
18111845

1846+
@Test
1847+
void testFailure_pendingDelete_evenWhenSuperuser() {
1848+
setupDomain("example", "tld");
1849+
eppRequestSource = EppRequestSource.TOOL;
1850+
domain = persistResource(domain.asBuilder().addStatusValue(StatusValue.PENDING_DELETE).build());
1851+
ResourceStatusProhibitsOperationException thrown =
1852+
assertThrows(
1853+
ResourceStatusProhibitsOperationException.class,
1854+
() ->
1855+
runTest(
1856+
"domain_transfer_request_superuser_extension.xml",
1857+
UserPrivileges.SUPERUSER,
1858+
ImmutableMap.of("PERIOD", "0", "AUTOMATIC_TRANSFER_LENGTH", "0")));
1859+
assertThat(thrown).hasMessageThat().contains("pendingDelete");
1860+
}
1861+
18121862
@Test
18131863
void testIcannActivityReportField_getsLogged() throws Exception {
18141864
setupDomain("example", "tld");

0 commit comments

Comments
 (0)