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

@ -20,12 +20,14 @@ import static google.registry.model.eppcommon.StatusValue.SERVER_TRANSFER_PROHIB
import static google.registry.model.eppcommon.StatusValue.SERVER_UPDATE_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 com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import google.registry.model.registrar.Registrar.Type;
import java.util.ArrayList;
import java.util.List;
import org.junit.Before;
@ -37,6 +39,8 @@ public class UnlockDomainCommandTest extends EppToolCommandTestCase<UnlockDomain
@Before
public void before() {
eppVerifier.expectSuperuser();
persistNewRegistrar("adminreg", "Admin Registrar", Type.REAL, 693L);
command.registryAdminClientId = "adminreg";
}
private static void persistLockedDomain(String domainName) {
@ -99,6 +103,15 @@ public class UnlockDomainCommandTest extends EppToolCommandTestCase<UnlockDomain
runCommandForced("--client=NewRegistrar", "example.tld");
}
@Test
public void testSuccess_defaultsToAdminRegistrar_ifUnspecified() throws Exception {
persistLockedDomain("example.tld");
runCommandForced("example.tld");
eppVerifier
.expectClientId("adminreg")
.verifySent("domain_unlock.xml", ImmutableMap.of("DOMAIN", "example.tld"));
}
@Test
public void testFailure_duplicateDomainsAreSpecified() throws Exception {
IllegalArgumentException e =