mirror of
https://github.com/google/nomulus.git
synced 2025-05-10 16:58:21 +02:00
Use the relock duration if provided in RLPA (#519)
* Use the relock duration if provided in RLPA
This commit is contained in:
parent
3b5d7b01ca
commit
3bee6b4f42
6 changed files with 73 additions and 23 deletions
|
@ -37,6 +37,7 @@ import javax.annotation.Nullable;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Named;
|
import javax.inject.Named;
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
|
import org.joda.time.Duration;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utility functions for validating and applying {@link RegistryLock}s.
|
* Utility functions for validating and applying {@link RegistryLock}s.
|
||||||
|
@ -76,12 +77,12 @@ public final class DomainLockUtils {
|
||||||
* <p>The unlock will not be applied until {@link #verifyAndApplyUnlock} is called.
|
* <p>The unlock will not be applied until {@link #verifyAndApplyUnlock} is called.
|
||||||
*/
|
*/
|
||||||
public RegistryLock saveNewRegistryUnlockRequest(
|
public RegistryLock saveNewRegistryUnlockRequest(
|
||||||
String domainName, String registrarId, boolean isAdmin) {
|
String domainName, String registrarId, boolean isAdmin, Optional<Duration> relockDuration) {
|
||||||
return jpaTm()
|
return jpaTm()
|
||||||
.transact(
|
.transact(
|
||||||
() ->
|
() ->
|
||||||
RegistryLockDao.save(
|
RegistryLockDao.save(
|
||||||
createUnlockBuilder(domainName, registrarId, isAdmin).build()));
|
createUnlockBuilder(domainName, registrarId, isAdmin, relockDuration).build()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Verifies and applies the lock request previously requested by a user. */
|
/** Verifies and applies the lock request previously requested by a user. */
|
||||||
|
@ -166,14 +167,14 @@ public final class DomainLockUtils {
|
||||||
* Nomulus tool commands.
|
* Nomulus tool commands.
|
||||||
*/
|
*/
|
||||||
public RegistryLock administrativelyApplyUnlock(
|
public RegistryLock administrativelyApplyUnlock(
|
||||||
String domainName, String registrarId, boolean isAdmin) {
|
String domainName, String registrarId, boolean isAdmin, Optional<Duration> relockDuration) {
|
||||||
return jpaTm()
|
return jpaTm()
|
||||||
.transact(
|
.transact(
|
||||||
() -> {
|
() -> {
|
||||||
DateTime now = jpaTm().getTransactionTime();
|
DateTime now = jpaTm().getTransactionTime();
|
||||||
RegistryLock result =
|
RegistryLock result =
|
||||||
RegistryLockDao.save(
|
RegistryLockDao.save(
|
||||||
createUnlockBuilder(domainName, registrarId, isAdmin)
|
createUnlockBuilder(domainName, registrarId, isAdmin, relockDuration)
|
||||||
.setUnlockCompletionTimestamp(now)
|
.setUnlockCompletionTimestamp(now)
|
||||||
.build());
|
.build());
|
||||||
tm().transact(() -> removeLockStatuses(result, isAdmin, now));
|
tm().transact(() -> removeLockStatuses(result, isAdmin, now));
|
||||||
|
@ -217,7 +218,7 @@ public final class DomainLockUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
private RegistryLock.Builder createUnlockBuilder(
|
private RegistryLock.Builder createUnlockBuilder(
|
||||||
String domainName, String registrarId, boolean isAdmin) {
|
String domainName, String registrarId, boolean isAdmin, Optional<Duration> relockDuration) {
|
||||||
DateTime now = jpaTm().getTransactionTime();
|
DateTime now = jpaTm().getTransactionTime();
|
||||||
DomainBase domainBase = getDomain(domainName, now);
|
DomainBase domainBase = getDomain(domainName, now);
|
||||||
Optional<RegistryLock> lockOptional =
|
Optional<RegistryLock> lockOptional =
|
||||||
|
@ -258,6 +259,7 @@ public final class DomainLockUtils {
|
||||||
!lock.isSuperuser(), "Non-admin user cannot unlock admin-locked domain %s", domainName);
|
!lock.isSuperuser(), "Non-admin user cannot unlock admin-locked domain %s", domainName);
|
||||||
newLockBuilder = lock.asBuilder();
|
newLockBuilder = lock.asBuilder();
|
||||||
}
|
}
|
||||||
|
relockDuration.ifPresent(newLockBuilder::setRelockDuration);
|
||||||
return newLockBuilder
|
return newLockBuilder
|
||||||
.setVerificationCode(stringGenerator.createString(VERIFICATION_CODE_LENGTH))
|
.setVerificationCode(stringGenerator.createString(VERIFICATION_CODE_LENGTH))
|
||||||
.isSuperuser(isAdmin)
|
.isSuperuser(isAdmin)
|
||||||
|
|
|
@ -22,6 +22,7 @@ import com.google.common.collect.Sets;
|
||||||
import com.google.common.flogger.FluentLogger;
|
import com.google.common.flogger.FluentLogger;
|
||||||
import google.registry.model.domain.DomainBase;
|
import google.registry.model.domain.DomainBase;
|
||||||
import google.registry.model.eppcommon.StatusValue;
|
import google.registry.model.eppcommon.StatusValue;
|
||||||
|
import java.util.Optional;
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -53,6 +54,6 @@ public class UnlockDomainCommand extends LockOrUnlockDomainCommand {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void createAndApplyRequest(String domain) {
|
protected void createAndApplyRequest(String domain) {
|
||||||
domainLockUtils.administrativelyApplyUnlock(domain, clientId, true);
|
domainLockUtils.administrativelyApplyUnlock(domain, clientId, true, Optional.empty());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,6 +56,7 @@ import javax.inject.Inject;
|
||||||
import javax.mail.internet.AddressException;
|
import javax.mail.internet.AddressException;
|
||||||
import javax.mail.internet.InternetAddress;
|
import javax.mail.internet.InternetAddress;
|
||||||
import org.apache.http.client.utils.URIBuilder;
|
import org.apache.http.client.utils.URIBuilder;
|
||||||
|
import org.joda.time.Duration;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* UI action that allows for creating registry locks. Locks / unlocks must be verified separately
|
* UI action that allows for creating registry locks. Locks / unlocks must be verified separately
|
||||||
|
@ -141,7 +142,8 @@ public class RegistryLockPostAction implements Runnable, JsonActionRunner.JsonAc
|
||||||
: domainLockUtils.saveNewRegistryUnlockRequest(
|
: domainLockUtils.saveNewRegistryUnlockRequest(
|
||||||
postInput.fullyQualifiedDomainName,
|
postInput.fullyQualifiedDomainName,
|
||||||
postInput.clientId,
|
postInput.clientId,
|
||||||
registrarAccessor.isAdmin());
|
registrarAccessor.isAdmin(),
|
||||||
|
Optional.ofNullable(postInput.relockDurationMillis).map(Duration::new));
|
||||||
sendVerificationEmail(registryLock, userEmail, postInput.isLock);
|
sendVerificationEmail(registryLock, userEmail, postInput.isLock);
|
||||||
});
|
});
|
||||||
String action = postInput.isLock ? "lock" : "unlock";
|
String action = postInput.isLock ? "lock" : "unlock";
|
||||||
|
@ -218,5 +220,6 @@ public class RegistryLockPostAction implements Runnable, JsonActionRunner.JsonAc
|
||||||
private String fullyQualifiedDomainName;
|
private String fullyQualifiedDomainName;
|
||||||
private Boolean isLock;
|
private Boolean isLock;
|
||||||
private String password;
|
private String password;
|
||||||
|
private Long relockDurationMillis;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,6 +40,7 @@ import google.registry.testing.FakeResponse;
|
||||||
import google.registry.testing.UserInfo;
|
import google.registry.testing.UserInfo;
|
||||||
import google.registry.tools.DomainLockUtils;
|
import google.registry.tools.DomainLockUtils;
|
||||||
import google.registry.util.StringGenerator.Alphabets;
|
import google.registry.util.StringGenerator.Alphabets;
|
||||||
|
import java.util.Optional;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -79,7 +80,9 @@ public class RelockDomainActionTest {
|
||||||
oldLock = domainLockUtils.administrativelyApplyLock(DOMAIN_NAME, CLIENT_ID, POC_ID, false);
|
oldLock = domainLockUtils.administrativelyApplyLock(DOMAIN_NAME, CLIENT_ID, POC_ID, false);
|
||||||
assertThat(reloadDomain(domain).getStatusValues())
|
assertThat(reloadDomain(domain).getStatusValues())
|
||||||
.containsAtLeastElementsIn(REGISTRY_LOCK_STATUSES);
|
.containsAtLeastElementsIn(REGISTRY_LOCK_STATUSES);
|
||||||
oldLock = domainLockUtils.administrativelyApplyUnlock(DOMAIN_NAME, CLIENT_ID, false);
|
oldLock =
|
||||||
|
domainLockUtils.administrativelyApplyUnlock(
|
||||||
|
DOMAIN_NAME, CLIENT_ID, false, Optional.empty());
|
||||||
assertThat(reloadDomain(domain).getStatusValues()).containsNoneIn(REGISTRY_LOCK_STATUSES);
|
assertThat(reloadDomain(domain).getStatusValues()).containsNoneIn(REGISTRY_LOCK_STATUSES);
|
||||||
action = createAction(oldLock.getRevisionId());
|
action = createAction(oldLock.getRevisionId());
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,6 +42,7 @@ import google.registry.testing.DeterministicStringGenerator;
|
||||||
import google.registry.testing.FakeClock;
|
import google.registry.testing.FakeClock;
|
||||||
import google.registry.testing.UserInfo;
|
import google.registry.testing.UserInfo;
|
||||||
import google.registry.util.StringGenerator.Alphabets;
|
import google.registry.util.StringGenerator.Alphabets;
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import org.joda.time.Duration;
|
import org.joda.time.Duration;
|
||||||
|
@ -91,7 +92,8 @@ public final class DomainLockUtilsTest {
|
||||||
public void testSuccess_createUnlock() {
|
public void testSuccess_createUnlock() {
|
||||||
domainLockUtils.administrativelyApplyLock(DOMAIN_NAME, "TheRegistrar", POC_ID, false);
|
domainLockUtils.administrativelyApplyLock(DOMAIN_NAME, "TheRegistrar", POC_ID, false);
|
||||||
RegistryLock lock =
|
RegistryLock lock =
|
||||||
domainLockUtils.saveNewRegistryUnlockRequest(DOMAIN_NAME, "TheRegistrar", false);
|
domainLockUtils.saveNewRegistryUnlockRequest(
|
||||||
|
DOMAIN_NAME, "TheRegistrar", false, Optional.empty());
|
||||||
assertThat(lock.getUnlockCompletionTimestamp().isPresent()).isFalse();
|
assertThat(lock.getUnlockCompletionTimestamp().isPresent()).isFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,7 +101,8 @@ public final class DomainLockUtilsTest {
|
||||||
public void testSuccess_createUnlock_adminUnlockingAdmin() {
|
public void testSuccess_createUnlock_adminUnlockingAdmin() {
|
||||||
domainLockUtils.administrativelyApplyLock(DOMAIN_NAME, "TheRegistrar", null, true);
|
domainLockUtils.administrativelyApplyLock(DOMAIN_NAME, "TheRegistrar", null, true);
|
||||||
RegistryLock lock =
|
RegistryLock lock =
|
||||||
domainLockUtils.saveNewRegistryUnlockRequest(DOMAIN_NAME, "TheRegistrar", true);
|
domainLockUtils.saveNewRegistryUnlockRequest(
|
||||||
|
DOMAIN_NAME, "TheRegistrar", true, Optional.empty());
|
||||||
assertThat(lock.getUnlockCompletionTimestamp().isPresent()).isFalse();
|
assertThat(lock.getUnlockCompletionTimestamp().isPresent()).isFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,10 +119,12 @@ public final class DomainLockUtilsTest {
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_createUnlock_previousUnlockRequestExpired() {
|
public void testSuccess_createUnlock_previousUnlockRequestExpired() {
|
||||||
domainLockUtils.administrativelyApplyLock(DOMAIN_NAME, "TheRegistrar", POC_ID, false);
|
domainLockUtils.administrativelyApplyLock(DOMAIN_NAME, "TheRegistrar", POC_ID, false);
|
||||||
domainLockUtils.saveNewRegistryUnlockRequest(DOMAIN_NAME, "TheRegistrar", false);
|
domainLockUtils.saveNewRegistryUnlockRequest(
|
||||||
|
DOMAIN_NAME, "TheRegistrar", false, Optional.empty());
|
||||||
clock.advanceBy(Duration.standardDays(1));
|
clock.advanceBy(Duration.standardDays(1));
|
||||||
RegistryLock unlockRequest =
|
RegistryLock unlockRequest =
|
||||||
domainLockUtils.saveNewRegistryUnlockRequest(DOMAIN_NAME, "TheRegistrar", false);
|
domainLockUtils.saveNewRegistryUnlockRequest(
|
||||||
|
DOMAIN_NAME, "TheRegistrar", false, Optional.empty());
|
||||||
domainLockUtils.verifyAndApplyUnlock(unlockRequest.getVerificationCode(), false);
|
domainLockUtils.verifyAndApplyUnlock(unlockRequest.getVerificationCode(), false);
|
||||||
assertThat(reloadDomain().getStatusValues()).containsNoneIn(REGISTRY_LOCK_STATUSES);
|
assertThat(reloadDomain().getStatusValues()).containsNoneIn(REGISTRY_LOCK_STATUSES);
|
||||||
}
|
}
|
||||||
|
@ -136,7 +141,8 @@ public final class DomainLockUtilsTest {
|
||||||
public void testSuccess_applyUnlockDomain() {
|
public void testSuccess_applyUnlockDomain() {
|
||||||
domainLockUtils.administrativelyApplyLock(DOMAIN_NAME, "TheRegistrar", POC_ID, false);
|
domainLockUtils.administrativelyApplyLock(DOMAIN_NAME, "TheRegistrar", POC_ID, false);
|
||||||
RegistryLock unlock =
|
RegistryLock unlock =
|
||||||
domainLockUtils.saveNewRegistryUnlockRequest(DOMAIN_NAME, "TheRegistrar", false);
|
domainLockUtils.saveNewRegistryUnlockRequest(
|
||||||
|
DOMAIN_NAME, "TheRegistrar", false, Optional.empty());
|
||||||
domainLockUtils.verifyAndApplyUnlock(unlock.getVerificationCode(), false);
|
domainLockUtils.verifyAndApplyUnlock(unlock.getVerificationCode(), false);
|
||||||
verifyProperlyUnlockedDomain(false);
|
verifyProperlyUnlockedDomain(false);
|
||||||
}
|
}
|
||||||
|
@ -155,7 +161,8 @@ public final class DomainLockUtilsTest {
|
||||||
domainLockUtils.saveNewRegistryLockRequest(DOMAIN_NAME, "TheRegistrar", null, true);
|
domainLockUtils.saveNewRegistryLockRequest(DOMAIN_NAME, "TheRegistrar", null, true);
|
||||||
domainLockUtils.verifyAndApplyLock(lock.getVerificationCode(), true);
|
domainLockUtils.verifyAndApplyLock(lock.getVerificationCode(), true);
|
||||||
RegistryLock unlock =
|
RegistryLock unlock =
|
||||||
domainLockUtils.saveNewRegistryUnlockRequest(DOMAIN_NAME, "TheRegistrar", true);
|
domainLockUtils.saveNewRegistryUnlockRequest(
|
||||||
|
DOMAIN_NAME, "TheRegistrar", true, Optional.empty());
|
||||||
domainLockUtils.verifyAndApplyUnlock(unlock.getVerificationCode(), true);
|
domainLockUtils.verifyAndApplyUnlock(unlock.getVerificationCode(), true);
|
||||||
verifyProperlyUnlockedDomain(true);
|
verifyProperlyUnlockedDomain(true);
|
||||||
}
|
}
|
||||||
|
@ -178,7 +185,8 @@ public final class DomainLockUtilsTest {
|
||||||
RegistryLock lock =
|
RegistryLock lock =
|
||||||
domainLockUtils.saveNewRegistryLockRequest(DOMAIN_NAME, "TheRegistrar", POC_ID, false);
|
domainLockUtils.saveNewRegistryLockRequest(DOMAIN_NAME, "TheRegistrar", POC_ID, false);
|
||||||
domainLockUtils.verifyAndApplyLock(lock.getVerificationCode(), false);
|
domainLockUtils.verifyAndApplyLock(lock.getVerificationCode(), false);
|
||||||
domainLockUtils.administrativelyApplyUnlock(DOMAIN_NAME, "TheRegistrar", false);
|
domainLockUtils.administrativelyApplyUnlock(
|
||||||
|
DOMAIN_NAME, "TheRegistrar", false, Optional.empty());
|
||||||
verifyProperlyUnlockedDomain(false);
|
verifyProperlyUnlockedDomain(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -187,7 +195,8 @@ public final class DomainLockUtilsTest {
|
||||||
RegistryLock lock =
|
RegistryLock lock =
|
||||||
domainLockUtils.saveNewRegistryLockRequest(DOMAIN_NAME, "TheRegistrar", null, true);
|
domainLockUtils.saveNewRegistryLockRequest(DOMAIN_NAME, "TheRegistrar", null, true);
|
||||||
domainLockUtils.verifyAndApplyLock(lock.getVerificationCode(), true);
|
domainLockUtils.verifyAndApplyLock(lock.getVerificationCode(), true);
|
||||||
domainLockUtils.administrativelyApplyUnlock(DOMAIN_NAME, "TheRegistrar", true);
|
domainLockUtils.administrativelyApplyUnlock(
|
||||||
|
DOMAIN_NAME, "TheRegistrar", true, Optional.empty());
|
||||||
verifyProperlyUnlockedDomain(true);
|
verifyProperlyUnlockedDomain(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -195,7 +204,8 @@ public final class DomainLockUtilsTest {
|
||||||
public void testSuccess_regularLock_relockSet() {
|
public void testSuccess_regularLock_relockSet() {
|
||||||
domainLockUtils.administrativelyApplyLock(DOMAIN_NAME, "TheRegistrar", POC_ID, false);
|
domainLockUtils.administrativelyApplyLock(DOMAIN_NAME, "TheRegistrar", POC_ID, false);
|
||||||
RegistryLock oldLock =
|
RegistryLock oldLock =
|
||||||
domainLockUtils.administrativelyApplyUnlock(DOMAIN_NAME, "TheRegistrar", false);
|
domainLockUtils.administrativelyApplyUnlock(
|
||||||
|
DOMAIN_NAME, "TheRegistrar", false, Optional.empty());
|
||||||
RegistryLock newLock =
|
RegistryLock newLock =
|
||||||
domainLockUtils.saveNewRegistryLockRequest(DOMAIN_NAME, "TheRegistrar", POC_ID, false);
|
domainLockUtils.saveNewRegistryLockRequest(DOMAIN_NAME, "TheRegistrar", POC_ID, false);
|
||||||
newLock = domainLockUtils.verifyAndApplyLock(newLock.getVerificationCode(), false);
|
newLock = domainLockUtils.verifyAndApplyLock(newLock.getVerificationCode(), false);
|
||||||
|
@ -208,7 +218,8 @@ public final class DomainLockUtilsTest {
|
||||||
public void testSuccess_administrativelyLock_relockSet() {
|
public void testSuccess_administrativelyLock_relockSet() {
|
||||||
domainLockUtils.administrativelyApplyLock(DOMAIN_NAME, "TheRegistrar", POC_ID, false);
|
domainLockUtils.administrativelyApplyLock(DOMAIN_NAME, "TheRegistrar", POC_ID, false);
|
||||||
RegistryLock oldLock =
|
RegistryLock oldLock =
|
||||||
domainLockUtils.administrativelyApplyUnlock(DOMAIN_NAME, "TheRegistrar", false);
|
domainLockUtils.administrativelyApplyUnlock(
|
||||||
|
DOMAIN_NAME, "TheRegistrar", false, Optional.empty());
|
||||||
RegistryLock newLock =
|
RegistryLock newLock =
|
||||||
domainLockUtils.administrativelyApplyLock(DOMAIN_NAME, "TheRegistrar", POC_ID, false);
|
domainLockUtils.administrativelyApplyLock(DOMAIN_NAME, "TheRegistrar", POC_ID, false);
|
||||||
assertThat(
|
assertThat(
|
||||||
|
@ -216,19 +227,29 @@ public final class DomainLockUtilsTest {
|
||||||
.isEqualTo(newLock.getRevisionId());
|
.isEqualTo(newLock.getRevisionId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSuccess_createUnlock_relockDuration() {
|
||||||
|
domainLockUtils.administrativelyApplyLock(DOMAIN_NAME, "TheRegistrar", POC_ID, false);
|
||||||
|
RegistryLock lock =
|
||||||
|
domainLockUtils.saveNewRegistryUnlockRequest(
|
||||||
|
DOMAIN_NAME, "TheRegistrar", false, Optional.of(Duration.standardDays(1)));
|
||||||
|
assertThat(lock.getRelockDuration()).isEqualTo(Optional.of(Duration.standardDays(1)));
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_createUnlock_alreadyPendingUnlock() {
|
public void testFailure_createUnlock_alreadyPendingUnlock() {
|
||||||
RegistryLock lock =
|
RegistryLock lock =
|
||||||
domainLockUtils.saveNewRegistryLockRequest(DOMAIN_NAME, "TheRegistrar", POC_ID, false);
|
domainLockUtils.saveNewRegistryLockRequest(DOMAIN_NAME, "TheRegistrar", POC_ID, false);
|
||||||
domainLockUtils.verifyAndApplyLock(lock.getVerificationCode(), false);
|
domainLockUtils.verifyAndApplyLock(lock.getVerificationCode(), false);
|
||||||
domainLockUtils.saveNewRegistryUnlockRequest(DOMAIN_NAME, "TheRegistrar", false);
|
domainLockUtils.saveNewRegistryUnlockRequest(
|
||||||
|
DOMAIN_NAME, "TheRegistrar", false, Optional.empty());
|
||||||
|
|
||||||
assertThat(
|
assertThat(
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
() ->
|
() ->
|
||||||
domainLockUtils.saveNewRegistryUnlockRequest(
|
domainLockUtils.saveNewRegistryUnlockRequest(
|
||||||
DOMAIN_NAME, "TheRegistrar", false)))
|
DOMAIN_NAME, "TheRegistrar", false, Optional.empty())))
|
||||||
.hasMessageThat()
|
.hasMessageThat()
|
||||||
.isEqualTo("A pending unlock action already exists for example.tld");
|
.isEqualTo("A pending unlock action already exists for example.tld");
|
||||||
}
|
}
|
||||||
|
@ -243,7 +264,7 @@ public final class DomainLockUtilsTest {
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
() ->
|
() ->
|
||||||
domainLockUtils.saveNewRegistryUnlockRequest(
|
domainLockUtils.saveNewRegistryUnlockRequest(
|
||||||
DOMAIN_NAME, "TheRegistrar", false)))
|
DOMAIN_NAME, "TheRegistrar", false, Optional.empty())))
|
||||||
.hasMessageThat()
|
.hasMessageThat()
|
||||||
.isEqualTo("Non-admin user cannot unlock admin-locked domain example.tld");
|
.isEqualTo("Non-admin user cannot unlock admin-locked domain example.tld");
|
||||||
}
|
}
|
||||||
|
@ -293,7 +314,7 @@ public final class DomainLockUtilsTest {
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
() ->
|
() ->
|
||||||
domainLockUtils.saveNewRegistryUnlockRequest(
|
domainLockUtils.saveNewRegistryUnlockRequest(
|
||||||
DOMAIN_NAME, "TheRegistrar", false)))
|
DOMAIN_NAME, "TheRegistrar", false, Optional.empty())))
|
||||||
.hasMessageThat()
|
.hasMessageThat()
|
||||||
.isEqualTo("Domain example.tld is already unlocked");
|
.isEqualTo("Domain example.tld is already unlocked");
|
||||||
}
|
}
|
||||||
|
@ -346,7 +367,8 @@ public final class DomainLockUtilsTest {
|
||||||
domainLockUtils.saveNewRegistryLockRequest(DOMAIN_NAME, "TheRegistrar", POC_ID, false);
|
domainLockUtils.saveNewRegistryLockRequest(DOMAIN_NAME, "TheRegistrar", POC_ID, false);
|
||||||
domainLockUtils.verifyAndApplyLock(lock.getVerificationCode(), false);
|
domainLockUtils.verifyAndApplyLock(lock.getVerificationCode(), false);
|
||||||
RegistryLock unlock =
|
RegistryLock unlock =
|
||||||
domainLockUtils.saveNewRegistryUnlockRequest(DOMAIN_NAME, "TheRegistrar", false);
|
domainLockUtils.saveNewRegistryUnlockRequest(
|
||||||
|
DOMAIN_NAME, "TheRegistrar", false, Optional.empty());
|
||||||
domainLockUtils.verifyAndApplyUnlock(unlock.getVerificationCode(), false);
|
domainLockUtils.verifyAndApplyUnlock(unlock.getVerificationCode(), false);
|
||||||
|
|
||||||
assertThat(
|
assertThat(
|
||||||
|
|
|
@ -20,6 +20,7 @@ import static google.registry.testing.DatastoreHelper.createTld;
|
||||||
import static google.registry.testing.DatastoreHelper.loadRegistrar;
|
import static google.registry.testing.DatastoreHelper.loadRegistrar;
|
||||||
import static google.registry.testing.DatastoreHelper.newDomainBase;
|
import static google.registry.testing.DatastoreHelper.newDomainBase;
|
||||||
import static google.registry.testing.DatastoreHelper.persistResource;
|
import static google.registry.testing.DatastoreHelper.persistResource;
|
||||||
|
import static google.registry.testing.SqlHelper.getMostRecentRegistryLockByRepoId;
|
||||||
import static google.registry.testing.SqlHelper.getRegistryLockByVerificationCode;
|
import static google.registry.testing.SqlHelper.getRegistryLockByVerificationCode;
|
||||||
import static google.registry.testing.SqlHelper.saveRegistryLock;
|
import static google.registry.testing.SqlHelper.saveRegistryLock;
|
||||||
import static google.registry.tools.LockOrUnlockDomainCommand.REGISTRY_LOCK_STATUSES;
|
import static google.registry.tools.LockOrUnlockDomainCommand.REGISTRY_LOCK_STATUSES;
|
||||||
|
@ -49,9 +50,11 @@ import google.registry.util.EmailMessage;
|
||||||
import google.registry.util.SendEmailService;
|
import google.registry.util.SendEmailService;
|
||||||
import google.registry.util.StringGenerator.Alphabets;
|
import google.registry.util.StringGenerator.Alphabets;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import javax.mail.internet.InternetAddress;
|
import javax.mail.internet.InternetAddress;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import org.joda.time.Duration;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -116,6 +119,22 @@ public final class RegistryLockPostActionTest {
|
||||||
assertSuccess(response, "unlock", "Marla.Singer.RegistryLock@crr.com");
|
assertSuccess(response, "unlock", "Marla.Singer.RegistryLock@crr.com");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSuccess_unlock_relockDurationSet() throws Exception {
|
||||||
|
saveRegistryLock(createLock().asBuilder().setLockCompletionTimestamp(clock.nowUtc()).build());
|
||||||
|
persistResource(domain.asBuilder().setStatusValues(REGISTRY_LOCK_STATUSES).build());
|
||||||
|
ImmutableMap<String, Object> request =
|
||||||
|
new ImmutableMap.Builder<String, Object>()
|
||||||
|
.putAll(unlockRequest())
|
||||||
|
.put("relockDurationMillis", Duration.standardDays(1).getMillis())
|
||||||
|
.build();
|
||||||
|
Map<String, ?> response = action.handleJsonRequest(request);
|
||||||
|
assertSuccess(response, "unlock", "Marla.Singer@crr.com");
|
||||||
|
RegistryLock savedUnlockRequest = getMostRecentRegistryLockByRepoId(domain.getRepoId()).get();
|
||||||
|
assertThat(savedUnlockRequest.getRelockDuration())
|
||||||
|
.isEqualTo(Optional.of(Duration.standardDays(1)));
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_unlock_adminUnlockingAdmin() throws Exception {
|
public void testSuccess_unlock_adminUnlockingAdmin() throws Exception {
|
||||||
saveRegistryLock(
|
saveRegistryLock(
|
||||||
|
|
Loading…
Add table
Reference in a new issue