Add a boolean for when a registrar has enabled registry lock (#228)

* Add a boolean for when a registrar has enabled registry lock

* enabled -> allowed

* get -> is
This commit is contained in:
gbrodman 2019-08-16 10:46:07 -04:00 committed by GitHub
parent 57975898d5
commit 92f2f3274e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 80 additions and 0 deletions

View file

@ -409,6 +409,9 @@ public class Registrar extends ImmutableObject implements Buildable, Jsonifiable
*/ */
boolean contactsRequireSyncing = true; boolean contactsRequireSyncing = true;
/** Whether or not registry lock is allowed for this registrar. */
boolean registryLockAllowed = false;
@NonFinalForTesting @NonFinalForTesting
private static Supplier<byte[]> saltSupplier = private static Supplier<byte[]> saltSupplier =
() -> { () -> {
@ -545,6 +548,10 @@ public class Registrar extends ImmutableObject implements Buildable, Jsonifiable
return contactsRequireSyncing; return contactsRequireSyncing;
} }
public boolean isRegistryLockAllowed() {
return registryLockAllowed;
}
public String getUrl() { public String getUrl() {
return url; return url;
} }
@ -895,6 +902,11 @@ public class Registrar extends ImmutableObject implements Buildable, Jsonifiable
return this; return this;
} }
public Builder setRegistryLockAllowed(boolean registryLockAllowed) {
getInstance().registryLockAllowed = registryLockAllowed;
return this;
}
/** Build the registrar, nullifying empty fields. */ /** Build the registrar, nullifying empty fields. */
@Override @Override
public Registrar build() { public Registrar build() {

View file

@ -234,6 +234,13 @@ abstract class CreateOrUpdateRegistrarCommand extends MutatingCommand {
arity = 1) arity = 1)
private Boolean contactsRequireSyncing; private Boolean contactsRequireSyncing;
@Nullable
@Parameter(
names = "--registry_lock_allowed",
description = "Whether this registrar is allowed to use registry lock",
arity = 1)
private Boolean registryLockAllowed;
@Nullable @Nullable
@Parameter( @Parameter(
names = "--drive_folder_id", names = "--drive_folder_id",
@ -393,6 +400,7 @@ abstract class CreateOrUpdateRegistrarCommand extends MutatingCommand {
} }
Optional.ofNullable(blockPremiumNames).ifPresent(builder::setBlockPremiumNames); Optional.ofNullable(blockPremiumNames).ifPresent(builder::setBlockPremiumNames);
Optional.ofNullable(contactsRequireSyncing).ifPresent(builder::setContactsRequireSyncing); Optional.ofNullable(contactsRequireSyncing).ifPresent(builder::setContactsRequireSyncing);
Optional.ofNullable(registryLockAllowed).ifPresent(builder::setRegistryLockAllowed);
Optional.ofNullable(phonePasscode).ifPresent(builder::setPhonePasscode); Optional.ofNullable(phonePasscode).ifPresent(builder::setPhonePasscode);
Optional.ofNullable(icannReferralEmail).ifPresent(builder::setIcannReferralEmail); Optional.ofNullable(icannReferralEmail).ifPresent(builder::setIcannReferralEmail);
Optional.ofNullable(whoisServer).ifPresent(builder::setWhoisServer); Optional.ofNullable(whoisServer).ifPresent(builder::setWhoisServer);

View file

@ -88,6 +88,7 @@ public class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarC
assertThat(registrar.getCreationTime()).isIn(Range.closed(before, after)); assertThat(registrar.getCreationTime()).isIn(Range.closed(before, after));
assertThat(registrar.getLastUpdateTime()).isEqualTo(registrar.getCreationTime()); assertThat(registrar.getLastUpdateTime()).isEqualTo(registrar.getCreationTime());
assertThat(registrar.getBlockPremiumNames()).isFalse(); assertThat(registrar.getBlockPremiumNames()).isFalse();
assertThat(registrar.isRegistryLockAllowed()).isFalse();
assertThat(registrar.getPoNumber()).isEmpty(); assertThat(registrar.getPoNumber()).isEmpty();
assertThat(registrar.getIcannReferralEmail()).isEqualTo("foo@bar.test"); assertThat(registrar.getIcannReferralEmail()).isEqualTo("foo@bar.test");
@ -766,6 +767,50 @@ public class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarC
assertThat(registrar.get().getBlockPremiumNames()).isFalse(); assertThat(registrar.get().getBlockPremiumNames()).isFalse();
} }
@Test
public void testSuccess_registryLockAllowed() throws Exception {
runCommandForced(
"--name=blobio",
"--password=some_password",
"--registrar_type=REAL",
"--iana_id=8",
"--registry_lock_allowed=true",
"--passcode=01234",
"--icann_referral_email=foo@bar.test",
"--street=\"123 Fake St\"",
"--city Fakington",
"--state MA",
"--zip 00351",
"--cc US",
"clientz");
Optional<Registrar> registrar = Registrar.loadByClientId("clientz");
assertThat(registrar).isPresent();
assertThat(registrar.get().isRegistryLockAllowed()).isTrue();
}
@Test
public void testSuccess_registryLockDisallowed() throws Exception {
runCommandForced(
"--name=blobio",
"--password=some_password",
"--registrar_type=REAL",
"--iana_id=8",
"--registry_lock_allowed=false",
"--passcode=01234",
"--icann_referral_email=foo@bar.test",
"--street=\"123 Fake St\"",
"--city Fakington",
"--state MA",
"--zip 00351",
"--cc US",
"clientz");
Optional<Registrar> registrar = Registrar.loadByClientId("clientz");
assertThat(registrar).isPresent();
assertThat(registrar.get().isRegistryLockAllowed()).isFalse();
}
@Test @Test
public void testFailure_badPhoneNumber() { public void testFailure_badPhoneNumber() {
ParameterException thrown = ParameterException thrown =

View file

@ -364,6 +364,20 @@ public class UpdateRegistrarCommandTest extends CommandTestCase<UpdateRegistrarC
assertThat(loadRegistrar("NewRegistrar").getBlockPremiumNames()).isFalse(); assertThat(loadRegistrar("NewRegistrar").getBlockPremiumNames()).isFalse();
} }
@Test
public void testSuccess_allowRegistryLock() throws Exception {
assertThat(loadRegistrar("NewRegistrar").isRegistryLockAllowed()).isFalse();
runCommandForced("--registry_lock_allowed=true", "NewRegistrar");
assertThat(loadRegistrar("NewRegistrar").isRegistryLockAllowed()).isTrue();
}
@Test
public void testSuccess_disallowRegistryLock() throws Exception {
persistResource(loadRegistrar("NewRegistrar").asBuilder().setRegistryLockAllowed(true).build());
runCommandForced("--registry_lock_allowed=false", "NewRegistrar");
assertThat(loadRegistrar("NewRegistrar").isRegistryLockAllowed()).isFalse();
}
@Test @Test
public void testSuccess_unspecifiedBooleansArentChanged() throws Exception { public void testSuccess_unspecifiedBooleansArentChanged() throws Exception {
persistResource( persistResource(

View file

@ -409,6 +409,7 @@ class google.registry.model.registrar.Registrar {
@Parent com.googlecode.objectify.Key<google.registry.model.common.EntityGroupRoot> parent; @Parent com.googlecode.objectify.Key<google.registry.model.common.EntityGroupRoot> parent;
boolean blockPremiumNames; boolean blockPremiumNames;
boolean contactsRequireSyncing; boolean contactsRequireSyncing;
boolean registryLockAllowed;
google.registry.model.CreateAutoTimestamp creationTime; google.registry.model.CreateAutoTimestamp creationTime;
google.registry.model.UpdateAutoTimestamp lastUpdateTime; google.registry.model.UpdateAutoTimestamp lastUpdateTime;
google.registry.model.registrar.Registrar$State state; google.registry.model.registrar.Registrar$State state;