Default clientId to registry's registrar in domain lock commands

All domain locks we've processed so far are as a result of the URS process, for
which the clientId is always that of the registry's registrar. So it makes sense
to default to that value, while still retaining the option to specify it if
required in case we ever support registrar-requested registry locks in the
future.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=199350120
This commit is contained in:
mcilwain 2018-06-05 13:39:24 -07:00 committed by Ben McIlwain
parent 897690119e
commit 5c7a20797e
4 changed files with 41 additions and 3 deletions

View file

@ -18,12 +18,14 @@ import static com.google.common.truth.Truth.assertThat;
import static google.registry.model.eppcommon.StatusValue.SERVER_TRANSFER_PROHIBITED;
import static google.registry.testing.DatastoreHelper.newDomainResource;
import static google.registry.testing.DatastoreHelper.persistActiveDomain;
import static google.registry.testing.DatastoreHelper.persistNewRegistrar;
import static google.registry.testing.DatastoreHelper.persistResource;
import static google.registry.testing.JUnitBackports.assertThrows;
import static google.registry.tools.LockOrUnlockDomainCommand.REGISTRY_LOCK_STATUSES;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import google.registry.model.registrar.Registrar.Type;
import java.util.ArrayList;
import java.util.List;
import org.junit.Before;
@ -35,6 +37,8 @@ public class LockDomainCommandTest extends EppToolCommandTestCase<LockDomainComm
@Before
public void before() {
eppVerifier.expectSuperuser();
persistNewRegistrar("adminreg", "Admin Registrar", Type.REAL, 693L);
command.registryAdminClientId = "adminreg";
}
@Test
@ -91,6 +95,15 @@ public class LockDomainCommandTest extends EppToolCommandTestCase<LockDomainComm
runCommandForced("--client=NewRegistrar", "example.tld");
}
@Test
public void testSuccess_defaultsToAdminRegistrar_ifUnspecified() throws Exception {
persistActiveDomain("example.tld");
runCommandForced("example.tld");
eppVerifier
.expectClientId("adminreg")
.verifySent("domain_lock.xml", ImmutableMap.of("DOMAIN", "example.tld"));
}
@Test
public void testFailure_duplicateDomainsAreSpecified() throws Exception {
IllegalArgumentException e =