Show locks in the case where you have an expired unlock request (#507)

* Show locks in the case where you have an expired unlock request
This commit is contained in:
gbrodman 2020-03-06 22:00:42 -05:00 committed by GitHub
parent 28d3af0ee9
commit f83f8f92a3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 33 additions and 3 deletions

View file

@ -159,12 +159,12 @@ public final class RegistryLockGetAction implements JsonGetAction {
() ->
RegistryLockDao.getLocksByRegistrarId(clientId).stream()
.filter(lock -> !lock.isLockRequestExpired(jpaTm().getTransactionTime()))
.filter(lock -> !lock.isUnlockRequestExpired(jpaTm().getTransactionTime()))
.map(lock -> lockToMap(lock, isAdmin))
.collect(toImmutableList()));
}
private ImmutableMap<String, ?> lockToMap(RegistryLock lock, boolean isAdmin) {
DateTime now = jpaTm().getTransactionTime();
return new ImmutableMap.Builder<String, Object>()
.put(FULLY_QUALIFIED_DOMAIN_NAME_PARAM, lock.getDomainName())
.put(
@ -174,7 +174,8 @@ public final class RegistryLockGetAction implements JsonGetAction {
.put(
IS_UNLOCK_PENDING_PARAM,
lock.getUnlockRequestTimestamp().isPresent()
&& !lock.getUnlockCompletionTimestamp().isPresent())
&& !lock.getUnlockCompletionTimestamp().isPresent()
&& !lock.isUnlockRequestExpired(now))
.put(USER_CAN_UNLOCK_PARAM, isAdmin || !lock.isSuperuser())
.build();
}

View file

@ -108,7 +108,21 @@ public final class DomainLockUtilsTest {
public void testSuccess_createLock_previousLockExpired() {
domainLockUtils.saveNewRegistryLockRequest(DOMAIN_NAME, "TheRegistrar", POC_ID, false);
clock.advanceBy(Duration.standardDays(1));
domainLockUtils.saveNewRegistryLockRequest(DOMAIN_NAME, "TheRegistrar", POC_ID, false);
RegistryLock lock =
domainLockUtils.saveNewRegistryLockRequest(DOMAIN_NAME, "TheRegistrar", POC_ID, false);
domainLockUtils.verifyAndApplyLock(lock.getVerificationCode(), false);
verifyProperlyLockedDomain(false);
}
@Test
public void testSuccess_createUnlock_previousUnlockRequestExpired() {
domainLockUtils.administrativelyApplyLock(DOMAIN_NAME, "TheRegistrar", POC_ID, false);
domainLockUtils.saveNewRegistryUnlockRequest(DOMAIN_NAME, "TheRegistrar", false);
clock.advanceBy(Duration.standardDays(1));
RegistryLock unlockRequest =
domainLockUtils.saveNewRegistryUnlockRequest(DOMAIN_NAME, "TheRegistrar", false);
domainLockUtils.verifyAndApplyUnlock(unlockRequest.getVerificationCode(), false);
assertThat(reloadDomain().getStatusValues()).containsNoneIn(REGISTRY_LOCK_STATUSES);
}
@Test

View file

@ -189,6 +189,14 @@ public final class RegistryLockGetActionTest {
"TheRegistrar",
"locks",
ImmutableList.of(
new ImmutableMap.Builder<>()
.put("fullyQualifiedDomainName", "expiredunlock.test")
.put("lockedTime", "2000-06-08T22:00:00.000Z")
.put("lockedBy", "johndoe@theregistrar.com")
.put("userCanUnlock", true)
.put("isLockPending", false)
.put("isUnlockPending", false)
.build(),
new ImmutableMap.Builder<>()
.put("fullyQualifiedDomainName", "example.test")
.put("lockedTime", "2000-06-09T22:00:00.000Z")

View file

@ -450,6 +450,13 @@ public class RegistrarConsoleScreenshotTest extends WebDriverTestCase {
server.runInAppEngineEnvironment(
() -> {
createTld("tld");
// expired unlock request
DomainBase expiredUnlockRequestDomain = persistActiveDomain("expiredunlock.tld");
saveRegistryLock(createRegistryLock(expiredUnlockRequestDomain)
.asBuilder()
.setLockCompletionTimestamp(START_OF_TIME.minusDays(1))
.setUnlockRequestTimestamp(START_OF_TIME.minusDays(1))
.build());
DomainBase domain = persistActiveDomain("example.tld");
saveRegistryLock(createRegistryLock(domain).asBuilder().isSuperuser(true).build());
DomainBase otherDomain = persistActiveDomain("otherexample.tld");

Binary file not shown.

Before

Width:  |  Height:  |  Size: 60 KiB

After

Width:  |  Height:  |  Size: 69 KiB

Before After
Before After