mirror of
https://github.com/google/nomulus.git
synced 2025-05-15 17:07:15 +02:00
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:
parent
897690119e
commit
5c7a20797e
4 changed files with 41 additions and 3 deletions
|
@ -23,8 +23,10 @@ import static google.registry.util.CollectionUtils.findDuplicates;
|
||||||
import com.beust.jcommander.Parameter;
|
import com.beust.jcommander.Parameter;
|
||||||
import com.google.common.base.Joiner;
|
import com.google.common.base.Joiner;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
import google.registry.config.RegistryConfig.Config;
|
||||||
import google.registry.model.eppcommon.StatusValue;
|
import google.registry.model.eppcommon.StatusValue;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import javax.inject.Inject;
|
||||||
|
|
||||||
/** Shared base class for commands to registry lock or unlock a domain via EPP. */
|
/** Shared base class for commands to registry lock or unlock a domain via EPP. */
|
||||||
public abstract class LockOrUnlockDomainCommand extends MutatingEppToolCommand {
|
public abstract class LockOrUnlockDomainCommand extends MutatingEppToolCommand {
|
||||||
|
@ -35,14 +37,17 @@ public abstract class LockOrUnlockDomainCommand extends MutatingEppToolCommand {
|
||||||
|
|
||||||
@Parameter(
|
@Parameter(
|
||||||
names = {"-c", "--client"},
|
names = {"-c", "--client"},
|
||||||
description = "Client identifier of the registrar to execute the command as",
|
description =
|
||||||
required = true
|
"Client ID of the requesting registrar if applicable, otherwise the registry registrar")
|
||||||
)
|
|
||||||
String clientId;
|
String clientId;
|
||||||
|
|
||||||
@Parameter(description = "Names of the domains", required = true)
|
@Parameter(description = "Names of the domains", required = true)
|
||||||
private List<String> mainParameters;
|
private List<String> mainParameters;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
@Config("registryAdminClientId")
|
||||||
|
String registryAdminClientId;
|
||||||
|
|
||||||
protected ImmutableSet<String> getDomains() {
|
protected ImmutableSet<String> getDomains() {
|
||||||
return ImmutableSet.copyOf(mainParameters);
|
return ImmutableSet.copyOf(mainParameters);
|
||||||
}
|
}
|
||||||
|
@ -51,6 +56,11 @@ public abstract class LockOrUnlockDomainCommand extends MutatingEppToolCommand {
|
||||||
protected void initEppToolCommand() throws Exception {
|
protected void initEppToolCommand() throws Exception {
|
||||||
// Superuser status is required to update registry lock statuses.
|
// Superuser status is required to update registry lock statuses.
|
||||||
superuser = true;
|
superuser = true;
|
||||||
|
|
||||||
|
// Default clientId to the registry registrar account if otherwise unspecified.
|
||||||
|
if (clientId == null) {
|
||||||
|
clientId = registryAdminClientId;
|
||||||
|
}
|
||||||
String duplicates = Joiner.on(", ").join(findDuplicates(mainParameters));
|
String duplicates = Joiner.on(", ").join(findDuplicates(mainParameters));
|
||||||
checkArgument(duplicates.isEmpty(), "Duplicate domain arguments found: '%s'", duplicates);
|
checkArgument(duplicates.isEmpty(), "Duplicate domain arguments found: '%s'", duplicates);
|
||||||
initMutatingEppToolCommand();
|
initMutatingEppToolCommand();
|
||||||
|
|
|
@ -91,12 +91,14 @@ interface RegistryToolComponent {
|
||||||
void inject(GetKeyringSecretCommand command);
|
void inject(GetKeyringSecretCommand command);
|
||||||
void inject(GhostrydeCommand command);
|
void inject(GhostrydeCommand command);
|
||||||
void inject(ListCursorsCommand command);
|
void inject(ListCursorsCommand command);
|
||||||
|
void inject(LockDomainCommand command);
|
||||||
void inject(LoginCommand command);
|
void inject(LoginCommand command);
|
||||||
void inject(LogoutCommand command);
|
void inject(LogoutCommand command);
|
||||||
void inject(PendingEscrowCommand command);
|
void inject(PendingEscrowCommand command);
|
||||||
void inject(RenewDomainCommand command);
|
void inject(RenewDomainCommand command);
|
||||||
void inject(SendEscrowReportToIcannCommand command);
|
void inject(SendEscrowReportToIcannCommand command);
|
||||||
void inject(SetupOteCommand command);
|
void inject(SetupOteCommand command);
|
||||||
|
void inject(UnlockDomainCommand command);
|
||||||
void inject(UpdateCursorsCommand command);
|
void inject(UpdateCursorsCommand command);
|
||||||
void inject(UpdateDomainCommand command);
|
void inject(UpdateDomainCommand command);
|
||||||
void inject(UpdateKmsKeyringCommand command);
|
void inject(UpdateKmsKeyringCommand command);
|
||||||
|
|
|
@ -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.model.eppcommon.StatusValue.SERVER_TRANSFER_PROHIBITED;
|
||||||
import static google.registry.testing.DatastoreHelper.newDomainResource;
|
import static google.registry.testing.DatastoreHelper.newDomainResource;
|
||||||
import static google.registry.testing.DatastoreHelper.persistActiveDomain;
|
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.DatastoreHelper.persistResource;
|
||||||
import static google.registry.testing.JUnitBackports.assertThrows;
|
import static google.registry.testing.JUnitBackports.assertThrows;
|
||||||
import static google.registry.tools.LockOrUnlockDomainCommand.REGISTRY_LOCK_STATUSES;
|
import static google.registry.tools.LockOrUnlockDomainCommand.REGISTRY_LOCK_STATUSES;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
import google.registry.model.registrar.Registrar.Type;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
@ -35,6 +37,8 @@ public class LockDomainCommandTest extends EppToolCommandTestCase<LockDomainComm
|
||||||
@Before
|
@Before
|
||||||
public void before() {
|
public void before() {
|
||||||
eppVerifier.expectSuperuser();
|
eppVerifier.expectSuperuser();
|
||||||
|
persistNewRegistrar("adminreg", "Admin Registrar", Type.REAL, 693L);
|
||||||
|
command.registryAdminClientId = "adminreg";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -91,6 +95,15 @@ public class LockDomainCommandTest extends EppToolCommandTestCase<LockDomainComm
|
||||||
runCommandForced("--client=NewRegistrar", "example.tld");
|
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
|
@Test
|
||||||
public void testFailure_duplicateDomainsAreSpecified() throws Exception {
|
public void testFailure_duplicateDomainsAreSpecified() throws Exception {
|
||||||
IllegalArgumentException e =
|
IllegalArgumentException e =
|
||||||
|
|
|
@ -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.model.eppcommon.StatusValue.SERVER_UPDATE_PROHIBITED;
|
||||||
import static google.registry.testing.DatastoreHelper.newDomainResource;
|
import static google.registry.testing.DatastoreHelper.newDomainResource;
|
||||||
import static google.registry.testing.DatastoreHelper.persistActiveDomain;
|
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.DatastoreHelper.persistResource;
|
||||||
import static google.registry.testing.JUnitBackports.assertThrows;
|
import static google.registry.testing.JUnitBackports.assertThrows;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
import google.registry.model.registrar.Registrar.Type;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
@ -37,6 +39,8 @@ public class UnlockDomainCommandTest extends EppToolCommandTestCase<UnlockDomain
|
||||||
@Before
|
@Before
|
||||||
public void before() {
|
public void before() {
|
||||||
eppVerifier.expectSuperuser();
|
eppVerifier.expectSuperuser();
|
||||||
|
persistNewRegistrar("adminreg", "Admin Registrar", Type.REAL, 693L);
|
||||||
|
command.registryAdminClientId = "adminreg";
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void persistLockedDomain(String domainName) {
|
private static void persistLockedDomain(String domainName) {
|
||||||
|
@ -99,6 +103,15 @@ public class UnlockDomainCommandTest extends EppToolCommandTestCase<UnlockDomain
|
||||||
runCommandForced("--client=NewRegistrar", "example.tld");
|
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
|
@Test
|
||||||
public void testFailure_duplicateDomainsAreSpecified() throws Exception {
|
public void testFailure_duplicateDomainsAreSpecified() throws Exception {
|
||||||
IllegalArgumentException e =
|
IllegalArgumentException e =
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue