Show pending locks in the locked-domains table (#495)

* Show pending locks in the locked-domains table

* asdf

* fix the tests

* including pending unlocks in the table

* fix the screenshot test
This commit is contained in:
gbrodman 2020-02-28 13:57:33 -05:00 committed by GitHub
parent 9283cd263f
commit e8ff4081a9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 152 additions and 54 deletions

View file

@ -127,8 +127,7 @@ public final class RegistryLockDaoTest {
@Test
public void testLoad_lockedDomains_byRegistrarId() {
RegistryLock lock =
createLock().asBuilder().setLockCompletionTimestamp(fakeClock.nowUtc()).build();
RegistryLock lock = createLock();
RegistryLock secondLock =
createLock()
.asBuilder()

View file

@ -41,7 +41,7 @@ public class SqlHelper {
}
public static ImmutableList<RegistryLock> getRegistryLocksByRegistrarId(String registrarId) {
return jpaTm().transact(() -> RegistryLockDao.getLockedDomainsByRegistrarId(registrarId));
return jpaTm().transact(() -> RegistryLockDao.getLocksByRegistrarId(registrarId));
}
private SqlHelper() {}

View file

@ -45,6 +45,7 @@ import google.registry.testing.FakeResponse;
import java.util.Map;
import java.util.Optional;
import org.joda.time.DateTime;
import org.joda.time.Duration;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
@ -92,6 +93,28 @@ public final class RegistryLockGetActionTest {
@Test
public void testSuccess_retrievesLocks() {
RegistryLock expiredLock =
new RegistryLock.Builder()
.setRepoId("repoId")
.setDomainName("expired.test")
.setRegistrarId("TheRegistrar")
.setVerificationCode("123456789ABCDEFGHJKLMNPQRSTUVWXY")
.setRegistrarPocId("johndoe@theregistrar.com")
.build();
saveRegistryLock(expiredLock);
RegistryLock expiredUnlock =
new RegistryLock.Builder()
.setRepoId("repoId")
.setDomainName("expiredunlock.test")
.setRegistrarId("TheRegistrar")
.setVerificationCode("123456789ABCDEFGHJKLMNPQRSTUVWXY")
.setRegistrarPocId("johndoe@theregistrar.com")
.setLockCompletionTimestamp(fakeClock.nowUtc())
.setUnlockRequestTimestamp(fakeClock.nowUtc())
.build();
saveRegistryLock(expiredUnlock);
fakeClock.advanceBy(Duration.standardDays(1));
RegistryLock regularLock =
new RegistryLock.Builder()
.setRepoId("repoId")
@ -114,12 +137,23 @@ public final class RegistryLockGetActionTest {
RegistryLock incompleteLock =
new RegistryLock.Builder()
.setRepoId("repoId")
.setDomainName("incomplete.test")
.setDomainName("pending.test")
.setRegistrarId("TheRegistrar")
.setVerificationCode("111111111ABCDEFGHJKLMNPQRSTUVWXY")
.setRegistrarPocId("johndoe@theregistrar.com")
.build();
RegistryLock incompleteUnlock =
new RegistryLock.Builder()
.setRepoId("repoId")
.setDomainName("incompleteunlock.test")
.setRegistrarId("TheRegistrar")
.setVerificationCode("123456789ABCDEFGHJKLMNPQRSTUVWXY")
.setRegistrarPocId("johndoe@theregistrar.com")
.setLockCompletionTimestamp(fakeClock.nowUtc())
.setUnlockRequestTimestamp(fakeClock.nowUtc())
.build();
RegistryLock unlockedLock =
new RegistryLock.Builder()
.setRepoId("repoId")
@ -135,6 +169,7 @@ public final class RegistryLockGetActionTest {
saveRegistryLock(regularLock);
saveRegistryLock(adminLock);
saveRegistryLock(incompleteLock);
saveRegistryLock(incompleteUnlock);
saveRegistryLock(unlockedLock);
action.run();
@ -154,16 +189,38 @@ public final class RegistryLockGetActionTest {
"TheRegistrar",
"locks",
ImmutableList.of(
ImmutableMap.of(
"fullyQualifiedDomainName", "example.test",
"lockedTime", "2000-06-08T22:00:00.000Z",
"lockedBy", "johndoe@theregistrar.com",
"userCanUnlock", true),
ImmutableMap.of(
"fullyQualifiedDomainName", "adminexample.test",
"lockedTime", "2000-06-08T22:00:00.001Z",
"lockedBy", "admin",
"userCanUnlock", false)))));
new ImmutableMap.Builder<>()
.put("fullyQualifiedDomainName", "example.test")
.put("lockedTime", "2000-06-09T22:00:00.000Z")
.put("lockedBy", "johndoe@theregistrar.com")
.put("userCanUnlock", true)
.put("isLockPending", false)
.put("isUnlockPending", false)
.build(),
new ImmutableMap.Builder<>()
.put("fullyQualifiedDomainName", "adminexample.test")
.put("lockedTime", "2000-06-09T22:00:00.001Z")
.put("lockedBy", "admin")
.put("userCanUnlock", false)
.put("isLockPending", false)
.put("isUnlockPending", false)
.build(),
new ImmutableMap.Builder<>()
.put("fullyQualifiedDomainName", "pending.test")
.put("lockedTime", "")
.put("lockedBy", "johndoe@theregistrar.com")
.put("userCanUnlock", true)
.put("isLockPending", true)
.put("isUnlockPending", false)
.build(),
new ImmutableMap.Builder<>()
.put("fullyQualifiedDomainName", "incompleteunlock.test")
.put("lockedTime", "2000-06-09T22:00:00.001Z")
.put("lockedBy", "johndoe@theregistrar.com")
.put("userCanUnlock", true)
.put("isLockPending", false)
.put("isUnlockPending", true)
.build()))));
}
@Test

View file

@ -24,6 +24,7 @@ import static google.registry.testing.DatastoreHelper.newDomainBase;
import static google.registry.testing.DatastoreHelper.persistActiveDomain;
import static google.registry.testing.DatastoreHelper.persistResource;
import static google.registry.testing.SqlHelper.saveRegistryLock;
import static google.registry.tools.LockOrUnlockDomainCommand.REGISTRY_LOCK_STATUSES;
import static google.registry.util.DateTimeUtils.START_OF_TIME;
import com.google.common.collect.ImmutableMap;
@ -453,6 +454,35 @@ public class RegistrarConsoleScreenshotTest extends WebDriverTestCase {
saveRegistryLock(createRegistryLock(domain).asBuilder().isSuperuser(true).build());
DomainBase otherDomain = persistActiveDomain("otherexample.tld");
saveRegistryLock(createRegistryLock(otherDomain));
// include one pending-lock domain
DomainBase pendingDomain = persistActiveDomain("pending.tld");
saveRegistryLock(
new RegistryLock.Builder()
.setVerificationCode(UUID.randomUUID().toString())
.isSuperuser(false)
.setRegistrarId("TheRegistrar")
.setRegistrarPocId("Marla.Singer@crr.com")
.setDomainName("pending.tld")
.setRepoId(pendingDomain.getRepoId())
.build());
// and one pending-unlock domain
DomainBase pendingUnlockDomain =
persistResource(
newDomainBase("pendingunlock.tld")
.asBuilder()
.setStatusValues(REGISTRY_LOCK_STATUSES)
.build());
saveRegistryLock(
new RegistryLock.Builder()
.setVerificationCode(UUID.randomUUID().toString())
.isSuperuser(false)
.setRegistrarId("TheRegistrar")
.setRegistrarPocId("Marla.Singer@crr.com")
.setDomainName(pendingUnlockDomain.getFullyQualifiedDomainName())
.setRepoId(pendingUnlockDomain.getRepoId())
.setLockCompletionTimestamp(START_OF_TIME)
.setUnlockRequestTimestamp(START_OF_TIME)
.build());
return null;
});
driver.get(server.getUrl("/registrar#registry-lock"));
@ -523,7 +553,7 @@ public class RegistrarConsoleScreenshotTest extends WebDriverTestCase {
.setRegistrarId("TheRegistrar")
.setRegistrarPocId("Marla.Singer@crr.com")
.setLockCompletionTimestamp(START_OF_TIME)
.setDomainName("example.tld")
.setDomainName(domainBase.getFullyQualifiedDomainName())
.setRepoId(domainBase.getRepoId())
.build();
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 56 KiB

After

Width:  |  Height:  |  Size: 60 KiB

Before After
Before After