Add ability to manually trigger contact group syncs

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=117549773
This commit is contained in:
mcilwain 2016-03-18 08:33:55 -07:00 committed by Justine Tunney
parent 9f548674b7
commit c8d655e416
2 changed files with 20 additions and 0 deletions

View file

@ -217,6 +217,13 @@ abstract class CreateOrUpdateRegistrarCommand extends MutatingCommand {
arity = 1) arity = 1)
private Boolean blockPremiumNames; private Boolean blockPremiumNames;
@Nullable
@Parameter(
names = "--sync_groups",
description = "Whether this registrar's groups should be updated at the next scheduled sync",
arity = 1)
private Boolean contactsRequireSyncing;
@Nullable @Nullable
@Parameter( @Parameter(
names = "--drive_id", names = "--drive_id",
@ -361,6 +368,9 @@ abstract class CreateOrUpdateRegistrarCommand extends MutatingCommand {
if (blockPremiumNames != null) { if (blockPremiumNames != null) {
builder.setBlockPremiumNames(blockPremiumNames); builder.setBlockPremiumNames(blockPremiumNames);
} }
if (contactsRequireSyncing != null) {
builder.setContactsRequireSyncing(contactsRequireSyncing);
}
// When creating a new REAL registrar or changing the type to REAL, a passcode is required. // When creating a new REAL registrar or changing the type to REAL, a passcode is required.
// Leave existing REAL registrars alone. // Leave existing REAL registrars alone.
if (Registrar.Type.REAL.equals(registrarType) if (Registrar.Type.REAL.equals(registrarType)

View file

@ -17,6 +17,7 @@ package com.google.domain.registry.tools;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Strings.isNullOrEmpty; import static com.google.common.base.Strings.isNullOrEmpty;
import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertThat;
import static com.google.domain.registry.model.registrar.Registrar.loadByClientId;
import static com.google.domain.registry.testing.CertificateSamples.SAMPLE_CERT; import static com.google.domain.registry.testing.CertificateSamples.SAMPLE_CERT;
import static com.google.domain.registry.testing.CertificateSamples.SAMPLE_CERT_HASH; import static com.google.domain.registry.testing.CertificateSamples.SAMPLE_CERT_HASH;
import static com.google.domain.registry.testing.DatastoreHelper.createTlds; import static com.google.domain.registry.testing.DatastoreHelper.createTlds;
@ -416,6 +417,15 @@ public class UpdateRegistrarCommandTest extends CommandTestCase<UpdateRegistrarC
.isEqualTo("whois.goth.black"); .isEqualTo("whois.goth.black");
} }
@Test
public void testSuccess_triggerGroupSyncing_works() throws Exception {
persistResource(
loadByClientId("NewRegistrar").asBuilder().setContactsRequireSyncing(false).build());
assertThat(loadByClientId("NewRegistrar").getContactsRequireSyncing()).isFalse();
runCommand("--sync_groups=true", "--force", "NewRegistrar");
assertThat(loadByClientId("NewRegistrar").getContactsRequireSyncing()).isTrue();
}
@Test @Test
public void testFailure_invalidRegistrarType() throws Exception { public void testFailure_invalidRegistrarType() throws Exception {
thrown.expect(ParameterException.class); thrown.expect(ParameterException.class);