mirror of
https://github.com/google/nomulus.git
synced 2025-05-31 09:44:03 +02:00
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:
parent
28d3af0ee9
commit
f83f8f92a3
5 changed files with 33 additions and 3 deletions
|
@ -159,12 +159,12 @@ public final class RegistryLockGetAction implements JsonGetAction {
|
||||||
() ->
|
() ->
|
||||||
RegistryLockDao.getLocksByRegistrarId(clientId).stream()
|
RegistryLockDao.getLocksByRegistrarId(clientId).stream()
|
||||||
.filter(lock -> !lock.isLockRequestExpired(jpaTm().getTransactionTime()))
|
.filter(lock -> !lock.isLockRequestExpired(jpaTm().getTransactionTime()))
|
||||||
.filter(lock -> !lock.isUnlockRequestExpired(jpaTm().getTransactionTime()))
|
|
||||||
.map(lock -> lockToMap(lock, isAdmin))
|
.map(lock -> lockToMap(lock, isAdmin))
|
||||||
.collect(toImmutableList()));
|
.collect(toImmutableList()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private ImmutableMap<String, ?> lockToMap(RegistryLock lock, boolean isAdmin) {
|
private ImmutableMap<String, ?> lockToMap(RegistryLock lock, boolean isAdmin) {
|
||||||
|
DateTime now = jpaTm().getTransactionTime();
|
||||||
return new ImmutableMap.Builder<String, Object>()
|
return new ImmutableMap.Builder<String, Object>()
|
||||||
.put(FULLY_QUALIFIED_DOMAIN_NAME_PARAM, lock.getDomainName())
|
.put(FULLY_QUALIFIED_DOMAIN_NAME_PARAM, lock.getDomainName())
|
||||||
.put(
|
.put(
|
||||||
|
@ -174,7 +174,8 @@ public final class RegistryLockGetAction implements JsonGetAction {
|
||||||
.put(
|
.put(
|
||||||
IS_UNLOCK_PENDING_PARAM,
|
IS_UNLOCK_PENDING_PARAM,
|
||||||
lock.getUnlockRequestTimestamp().isPresent()
|
lock.getUnlockRequestTimestamp().isPresent()
|
||||||
&& !lock.getUnlockCompletionTimestamp().isPresent())
|
&& !lock.getUnlockCompletionTimestamp().isPresent()
|
||||||
|
&& !lock.isUnlockRequestExpired(now))
|
||||||
.put(USER_CAN_UNLOCK_PARAM, isAdmin || !lock.isSuperuser())
|
.put(USER_CAN_UNLOCK_PARAM, isAdmin || !lock.isSuperuser())
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
|
@ -108,7 +108,21 @@ public final class DomainLockUtilsTest {
|
||||||
public void testSuccess_createLock_previousLockExpired() {
|
public void testSuccess_createLock_previousLockExpired() {
|
||||||
domainLockUtils.saveNewRegistryLockRequest(DOMAIN_NAME, "TheRegistrar", POC_ID, false);
|
domainLockUtils.saveNewRegistryLockRequest(DOMAIN_NAME, "TheRegistrar", POC_ID, false);
|
||||||
clock.advanceBy(Duration.standardDays(1));
|
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
|
@Test
|
||||||
|
|
|
@ -189,6 +189,14 @@ public final class RegistryLockGetActionTest {
|
||||||
"TheRegistrar",
|
"TheRegistrar",
|
||||||
"locks",
|
"locks",
|
||||||
ImmutableList.of(
|
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<>()
|
new ImmutableMap.Builder<>()
|
||||||
.put("fullyQualifiedDomainName", "example.test")
|
.put("fullyQualifiedDomainName", "example.test")
|
||||||
.put("lockedTime", "2000-06-09T22:00:00.000Z")
|
.put("lockedTime", "2000-06-09T22:00:00.000Z")
|
||||||
|
|
|
@ -450,6 +450,13 @@ public class RegistrarConsoleScreenshotTest extends WebDriverTestCase {
|
||||||
server.runInAppEngineEnvironment(
|
server.runInAppEngineEnvironment(
|
||||||
() -> {
|
() -> {
|
||||||
createTld("tld");
|
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");
|
DomainBase domain = persistActiveDomain("example.tld");
|
||||||
saveRegistryLock(createRegistryLock(domain).asBuilder().isSuperuser(true).build());
|
saveRegistryLock(createRegistryLock(domain).asBuilder().isSuperuser(true).build());
|
||||||
DomainBase otherDomain = persistActiveDomain("otherexample.tld");
|
DomainBase otherDomain = persistActiveDomain("otherexample.tld");
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 60 KiB After Width: | Height: | Size: 69 KiB |
Loading…
Add table
Add a link
Reference in a new issue