mirror of
https://github.com/google/nomulus.git
synced 2025-05-19 18:59:35 +02:00
Add support for dsdata to the URS tool
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=122631925
This commit is contained in:
parent
d2a66e9d1f
commit
24c11dfdca
7 changed files with 179 additions and 46 deletions
|
@ -15,12 +15,14 @@
|
||||||
package google.registry.tools;
|
package google.registry.tools;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkArgument;
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
|
import static com.google.common.base.Strings.nullToEmpty;
|
||||||
import static com.google.common.collect.Sets.difference;
|
import static com.google.common.collect.Sets.difference;
|
||||||
import static google.registry.model.EppResourceUtils.checkResourcesExist;
|
import static google.registry.model.EppResourceUtils.checkResourcesExist;
|
||||||
import static google.registry.model.EppResourceUtils.loadByUniqueId;
|
import static google.registry.model.EppResourceUtils.loadByUniqueId;
|
||||||
import static org.joda.time.DateTimeZone.UTC;
|
import static org.joda.time.DateTimeZone.UTC;
|
||||||
|
|
||||||
import com.google.common.base.Joiner;
|
import com.google.common.base.Joiner;
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.ImmutableSortedSet;
|
import com.google.common.collect.ImmutableSortedSet;
|
||||||
import com.google.template.soy.data.SoyMapData;
|
import com.google.template.soy.data.SoyMapData;
|
||||||
|
@ -30,17 +32,24 @@ import com.beust.jcommander.Parameters;
|
||||||
import com.googlecode.objectify.Ref;
|
import com.googlecode.objectify.Ref;
|
||||||
|
|
||||||
import google.registry.model.domain.DomainResource;
|
import google.registry.model.domain.DomainResource;
|
||||||
|
import google.registry.model.domain.secdns.DelegationSignerData;
|
||||||
import google.registry.model.eppcommon.StatusValue;
|
import google.registry.model.eppcommon.StatusValue;
|
||||||
import google.registry.model.host.HostResource;
|
import google.registry.model.host.HostResource;
|
||||||
import google.registry.tools.Command.GtechCommand;
|
import google.registry.tools.Command.GtechCommand;
|
||||||
import google.registry.tools.soy.UniformRapidSuspensionSoyInfo;
|
import google.registry.tools.soy.UniformRapidSuspensionSoyInfo;
|
||||||
|
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
|
import org.json.simple.JSONArray;
|
||||||
|
import org.json.simple.JSONValue;
|
||||||
|
import org.json.simple.parser.ParseException;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import javax.xml.bind.annotation.adapters.HexBinaryAdapter;
|
||||||
|
|
||||||
/** A command to suspend a domain for the Uniform Rapid Suspension process. */
|
/** A command to suspend a domain for the Uniform Rapid Suspension process. */
|
||||||
@Parameters(separators = " =",
|
@Parameters(separators = " =",
|
||||||
commandDescription = "Suspend a domain for Uniform Rapid Suspension.")
|
commandDescription = "Suspend a domain for Uniform Rapid Suspension.")
|
||||||
|
@ -54,6 +63,9 @@ final class UniformRapidSuspensionCommand extends MutatingEppToolCommand impleme
|
||||||
/** Client id that made this change. Only recorded in the history entry. **/
|
/** Client id that made this change. Only recorded in the history entry. **/
|
||||||
private static final String CLIENT_ID = "CharlestonRoad";
|
private static final String CLIENT_ID = "CharlestonRoad";
|
||||||
|
|
||||||
|
private static final ImmutableSet<String> DSDATA_FIELDS =
|
||||||
|
ImmutableSet.of("keyTag", "alg", "digestType", "digest");
|
||||||
|
|
||||||
@Parameter(
|
@Parameter(
|
||||||
names = {"-n", "--domain_name"},
|
names = {"-n", "--domain_name"},
|
||||||
description = "Domain to suspend.",
|
description = "Domain to suspend.",
|
||||||
|
@ -67,7 +79,14 @@ final class UniformRapidSuspensionCommand extends MutatingEppToolCommand impleme
|
||||||
private List<String> newHosts = new ArrayList<>();
|
private List<String> newHosts = new ArrayList<>();
|
||||||
|
|
||||||
@Parameter(
|
@Parameter(
|
||||||
names = {"-p", "--preserve"},
|
names = {"-s", "--dsdata"},
|
||||||
|
description = "Comma-delimited set of dsdata to replace the current dsdata on the domain, "
|
||||||
|
+ "where each dsdata is represented as a JSON object with fields 'keyTag', 'alg', "
|
||||||
|
+ "'digestType' and 'digest'.")
|
||||||
|
private String newDsData;
|
||||||
|
|
||||||
|
@Parameter(
|
||||||
|
names = {"-p", "--locks_to_preserve"},
|
||||||
description = "Comma-delimited set of locks to preserve (only valid with --undo). "
|
description = "Comma-delimited set of locks to preserve (only valid with --undo). "
|
||||||
+ "Valid locks: serverDeleteProhibited, serverTransferProhibited, serverUpdateProhibited")
|
+ "Valid locks: serverDeleteProhibited, serverTransferProhibited, serverUpdateProhibited")
|
||||||
private List<String> locksToPreserve = new ArrayList<>();
|
private List<String> locksToPreserve = new ArrayList<>();
|
||||||
|
@ -83,11 +102,29 @@ final class UniformRapidSuspensionCommand extends MutatingEppToolCommand impleme
|
||||||
/** Set of existing nameservers that need to be restored during undo, sorted for nicer output. */
|
/** Set of existing nameservers that need to be restored during undo, sorted for nicer output. */
|
||||||
ImmutableSortedSet<String> existingNameservers;
|
ImmutableSortedSet<String> existingNameservers;
|
||||||
|
|
||||||
|
/** Set of existing dsdata jsons that need to be restored during undo, sorted for nicer output. */
|
||||||
|
ImmutableSortedSet<String> existingDsData;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void initMutatingEppToolCommand() {
|
protected void initMutatingEppToolCommand() throws ParseException {
|
||||||
superuser = true;
|
superuser = true;
|
||||||
DateTime now = DateTime.now(UTC);
|
DateTime now = DateTime.now(UTC);
|
||||||
ImmutableSet<String> newHostsSet = ImmutableSet.copyOf(newHosts);
|
ImmutableSet<String> newHostsSet = ImmutableSet.copyOf(newHosts);
|
||||||
|
ImmutableSet.Builder<Map<String, Object>> newDsDataBuilder = new ImmutableSet.Builder<>();
|
||||||
|
try {
|
||||||
|
// Add brackets around newDsData to convert it to a parsable JSON array.
|
||||||
|
String jsonArrayString = String.format("[%s]", nullToEmpty(newDsData));
|
||||||
|
for (Object dsData : (JSONArray) JSONValue.parseWithException(jsonArrayString)) {
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
Map<String, Object> dsDataJson = (Map<String, Object>) dsData;
|
||||||
|
checkArgument(
|
||||||
|
dsDataJson.keySet().equals(DSDATA_FIELDS),
|
||||||
|
"Incorrect fields on --dsdata JSON: " + JSONValue.toJSONString(dsDataJson));
|
||||||
|
newDsDataBuilder.add(dsDataJson);
|
||||||
|
}
|
||||||
|
} catch (ClassCastException | ParseException e) {
|
||||||
|
throw new IllegalArgumentException("Invalid --dsdata JSON", e);
|
||||||
|
}
|
||||||
DomainResource domain = loadByUniqueId(DomainResource.class, domainName, now);
|
DomainResource domain = loadByUniqueId(DomainResource.class, domainName, now);
|
||||||
checkArgument(domain != null, "Domain '%s' does not exist", domainName);
|
checkArgument(domain != null, "Domain '%s' does not exist", domainName);
|
||||||
Set<String> missingHosts =
|
Set<String> missingHosts =
|
||||||
|
@ -98,6 +135,7 @@ final class UniformRapidSuspensionCommand extends MutatingEppToolCommand impleme
|
||||||
"Locks can only be preserved when running with --undo");
|
"Locks can only be preserved when running with --undo");
|
||||||
existingNameservers = getExistingNameservers(domain);
|
existingNameservers = getExistingNameservers(domain);
|
||||||
existingLocks = getExistingLocks(domain);
|
existingLocks = getExistingLocks(domain);
|
||||||
|
existingDsData = getExistingDsData(domain);
|
||||||
setSoyTemplate(
|
setSoyTemplate(
|
||||||
UniformRapidSuspensionSoyInfo.getInstance(),
|
UniformRapidSuspensionSoyInfo.getInstance(),
|
||||||
UniformRapidSuspensionSoyInfo.UNIFORMRAPIDSUSPENSION);
|
UniformRapidSuspensionSoyInfo.UNIFORMRAPIDSUSPENSION);
|
||||||
|
@ -108,6 +146,7 @@ final class UniformRapidSuspensionCommand extends MutatingEppToolCommand impleme
|
||||||
"locksToApply", undo ? ImmutableSet.of() : URS_LOCKS,
|
"locksToApply", undo ? ImmutableSet.of() : URS_LOCKS,
|
||||||
"locksToRemove",
|
"locksToRemove",
|
||||||
undo ? difference(URS_LOCKS, ImmutableSet.copyOf(locksToPreserve)) : ImmutableSet.of(),
|
undo ? difference(URS_LOCKS, ImmutableSet.copyOf(locksToPreserve)) : ImmutableSet.of(),
|
||||||
|
"newDsData", newDsDataBuilder.build(),
|
||||||
"reason", (undo ? "Undo " : "") + "Uniform Rapid Suspension"));
|
"reason", (undo ? "Undo " : "") + "Uniform Rapid Suspension"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,6 +168,19 @@ final class UniformRapidSuspensionCommand extends MutatingEppToolCommand impleme
|
||||||
return locks.build();
|
return locks.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ImmutableSortedSet<String> getExistingDsData(DomainResource domain) {
|
||||||
|
ImmutableSortedSet.Builder<String> dsDataJsons = ImmutableSortedSet.naturalOrder();
|
||||||
|
HexBinaryAdapter hexBinaryAdapter = new HexBinaryAdapter();
|
||||||
|
for (DelegationSignerData dsData : domain.getDsData()) {
|
||||||
|
dsDataJsons.add(JSONValue.toJSONString(ImmutableMap.of(
|
||||||
|
"keyTag", dsData.getKeyTag(),
|
||||||
|
"algorithm", dsData.getAlgorithm(),
|
||||||
|
"digestType", dsData.getDigestType(),
|
||||||
|
"digest", hexBinaryAdapter.marshal(dsData.getDigest()))));
|
||||||
|
}
|
||||||
|
return dsDataJsons.build();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String postExecute() throws Exception {
|
protected String postExecute() throws Exception {
|
||||||
if (undo) {
|
if (undo) {
|
||||||
|
@ -142,7 +194,10 @@ final class UniformRapidSuspensionCommand extends MutatingEppToolCommand impleme
|
||||||
undoBuilder.append(" --hosts ").append(Joiner.on(',').join(existingNameservers));
|
undoBuilder.append(" --hosts ").append(Joiner.on(',').join(existingNameservers));
|
||||||
}
|
}
|
||||||
if (!existingLocks.isEmpty()) {
|
if (!existingLocks.isEmpty()) {
|
||||||
undoBuilder.append(" --preserve ").append(Joiner.on(',').join(existingLocks));
|
undoBuilder.append(" --locks_to_preserve ").append(Joiner.on(',').join(existingLocks));
|
||||||
|
}
|
||||||
|
if (!existingDsData.isEmpty()) {
|
||||||
|
undoBuilder.append(" --dsdata ").append(Joiner.on(',').join(existingDsData));
|
||||||
}
|
}
|
||||||
return undoBuilder.toString();
|
return undoBuilder.toString();
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
{@param hostsToRemove: list<string>}
|
{@param hostsToRemove: list<string>}
|
||||||
{@param locksToApply: list<string>}
|
{@param locksToApply: list<string>}
|
||||||
{@param locksToRemove: list<string>}
|
{@param locksToRemove: list<string>}
|
||||||
|
{@param newDsData: list<[keyTag:int, alg:int, digestType:int, digest:string]>}
|
||||||
{@param reason: string}
|
{@param reason: string}
|
||||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||||
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
|
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
|
||||||
|
@ -43,6 +44,23 @@
|
||||||
</domain:update>
|
</domain:update>
|
||||||
</update>
|
</update>
|
||||||
<extension>
|
<extension>
|
||||||
|
<secDNS:update xmlns:secDNS="urn:ietf:params:xml:ns:secDNS-1.1">
|
||||||
|
<secDNS:rem>
|
||||||
|
<secDNS:all>true</secDNS:all>
|
||||||
|
</secDNS:rem>
|
||||||
|
{if length($newDsData) > 0}
|
||||||
|
<secDNS:add>
|
||||||
|
{foreach $ds in $newDsData}
|
||||||
|
<secDNS:dsData>
|
||||||
|
<secDNS:keyTag>{$ds.keyTag}</secDNS:keyTag>
|
||||||
|
<secDNS:alg>{$ds.alg}</secDNS:alg>
|
||||||
|
<secDNS:digestType>{$ds.digestType}</secDNS:digestType>
|
||||||
|
<secDNS:digest>{$ds.digest}</secDNS:digest>
|
||||||
|
</secDNS:dsData>
|
||||||
|
{/foreach}
|
||||||
|
</secDNS:add>
|
||||||
|
{/if}
|
||||||
|
</secDNS:update>
|
||||||
<metadata:metadata xmlns:metadata="urn:google:params:xml:ns:metadata-1.0">
|
<metadata:metadata xmlns:metadata="urn:google:params:xml:ns:metadata-1.0">
|
||||||
<metadata:reason>{$reason}</metadata:reason>
|
<metadata:reason>{$reason}</metadata:reason>
|
||||||
<metadata:requestedByRegistrar>false</metadata:requestedByRegistrar>
|
<metadata:requestedByRegistrar>false</metadata:requestedByRegistrar>
|
||||||
|
|
|
@ -24,6 +24,7 @@ import com.google.common.collect.ImmutableSet;
|
||||||
import com.beust.jcommander.ParameterException;
|
import com.beust.jcommander.ParameterException;
|
||||||
import com.googlecode.objectify.Ref;
|
import com.googlecode.objectify.Ref;
|
||||||
|
|
||||||
|
import google.registry.model.domain.secdns.DelegationSignerData;
|
||||||
import google.registry.model.eppcommon.StatusValue;
|
import google.registry.model.eppcommon.StatusValue;
|
||||||
import google.registry.model.host.HostResource;
|
import google.registry.model.host.HostResource;
|
||||||
import google.registry.model.registrar.Registrar;
|
import google.registry.model.registrar.Registrar;
|
||||||
|
@ -31,16 +32,27 @@ import google.registry.model.registrar.Registrar;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import javax.xml.bind.annotation.adapters.HexBinaryAdapter;
|
||||||
|
|
||||||
/** Unit tests for {@link UniformRapidSuspensionCommand}. */
|
/** Unit tests for {@link UniformRapidSuspensionCommand}. */
|
||||||
public class UniformRapidSuspensionCommandTest
|
public class UniformRapidSuspensionCommandTest
|
||||||
extends EppToolCommandTestCase<UniformRapidSuspensionCommand> {
|
extends EppToolCommandTestCase<UniformRapidSuspensionCommand> {
|
||||||
|
|
||||||
|
HostResource ns1;
|
||||||
|
HostResource ns2;
|
||||||
|
HostResource urs1;
|
||||||
|
HostResource urs2;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void initRegistrar() {
|
public void initResources() {
|
||||||
// Since the command's history client ID must be CharlestonRoad, resave TheRegistrar that way.
|
// Since the command's history client ID must be CharlestonRoad, resave TheRegistrar that way.
|
||||||
persistResource(Registrar.loadByClientId("TheRegistrar").asBuilder()
|
persistResource(Registrar.loadByClientId("TheRegistrar").asBuilder()
|
||||||
.setClientIdentifier("CharlestonRoad")
|
.setClientIdentifier("CharlestonRoad")
|
||||||
.build());
|
.build());
|
||||||
|
ns1 = persistActiveHost("ns1.example.com");
|
||||||
|
ns2 = persistActiveHost("ns2.example.com");
|
||||||
|
urs1 = persistActiveHost("urs1.example.com");
|
||||||
|
urs2 = persistActiveHost("urs2.example.com");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void persistDomainWithHosts(HostResource... hosts) {
|
private void persistDomainWithHosts(HostResource... hosts) {
|
||||||
|
@ -50,71 +62,70 @@ public class UniformRapidSuspensionCommandTest
|
||||||
}
|
}
|
||||||
persistResource(newDomainResource("evil.tld").asBuilder()
|
persistResource(newDomainResource("evil.tld").asBuilder()
|
||||||
.setNameservers(hostRefs.build())
|
.setNameservers(hostRefs.build())
|
||||||
|
.setDsData(ImmutableSet.of(
|
||||||
|
DelegationSignerData.create(1, 2, 3, new HexBinaryAdapter().unmarshal("dead")),
|
||||||
|
DelegationSignerData.create(4, 5, 6, new HexBinaryAdapter().unmarshal("beef"))))
|
||||||
.build());
|
.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCommand_addsLocksReplacesHostsPrintsUndo() throws Exception {
|
public void testCommand_addsLocksReplacesHostsAndDsDataPrintsUndo() throws Exception {
|
||||||
persistActiveHost("urs1.example.com");
|
persistDomainWithHosts(ns1, ns2);
|
||||||
persistActiveHost("urs2.example.com");
|
runCommandForced(
|
||||||
persistDomainWithHosts(
|
"--domain_name=evil.tld",
|
||||||
persistActiveHost("ns1.example.com"),
|
"--hosts=urs1.example.com,urs2.example.com",
|
||||||
persistActiveHost("ns2.example.com"));
|
"--dsdata={\"keyTag\":1,\"alg\":1,\"digestType\":1,\"digest\":\"abc\"}");
|
||||||
runCommandForced("--domain_name=evil.tld", "--hosts=urs1.example.com,urs2.example.com");
|
|
||||||
eppVerifier()
|
eppVerifier()
|
||||||
.setClientIdentifier("CharlestonRoad")
|
.setClientIdentifier("CharlestonRoad")
|
||||||
.asSuperuser()
|
.asSuperuser()
|
||||||
.verifySent("testdata/uniform_rapid_suspension.xml");
|
.verifySent("testdata/uniform_rapid_suspension.xml");
|
||||||
assertInStdout("uniform_rapid_suspension "
|
assertInStdout("uniform_rapid_suspension --undo");
|
||||||
+ "--undo "
|
assertInStdout("--domain_name evil.tld");
|
||||||
+ "--domain_name evil.tld "
|
assertInStdout("--hosts ns1.example.com,ns2.example.com");
|
||||||
+ "--hosts ns1.example.com,ns2.example.com");
|
assertInStdout("--dsdata "
|
||||||
|
+ "{\"keyTag\":1,\"algorithm\":2,\"digestType\":3,\"digest\":\"DEAD\"},"
|
||||||
|
+ "{\"keyTag\":4,\"algorithm\":5,\"digestType\":6,\"digest\":\"BEEF\"}");
|
||||||
|
assertNotInStdout("--locks_to_preserve");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCommand_respectsExistingHost() throws Exception {
|
public void testCommand_respectsExistingHost() throws Exception {
|
||||||
persistActiveHost("urs1.example.com");
|
persistDomainWithHosts(urs2, ns1);
|
||||||
persistDomainWithHosts(
|
|
||||||
persistActiveHost("urs2.example.com"),
|
|
||||||
persistActiveHost("ns1.example.com"));
|
|
||||||
runCommandForced("--domain_name=evil.tld", "--hosts=urs1.example.com,urs2.example.com");
|
runCommandForced("--domain_name=evil.tld", "--hosts=urs1.example.com,urs2.example.com");
|
||||||
eppVerifier()
|
eppVerifier()
|
||||||
.setClientIdentifier("CharlestonRoad")
|
.setClientIdentifier("CharlestonRoad")
|
||||||
.asSuperuser()
|
.asSuperuser()
|
||||||
.verifySent("testdata/uniform_rapid_suspension_existing_host.xml");
|
.verifySent("testdata/uniform_rapid_suspension_existing_host.xml");
|
||||||
assertInStdout("uniform_rapid_suspension "
|
assertInStdout("uniform_rapid_suspension --undo ");
|
||||||
+ "--undo "
|
assertInStdout("--domain_name evil.tld");
|
||||||
+ "--domain_name evil.tld "
|
assertInStdout("--hosts ns1.example.com,urs2.example.com");
|
||||||
+ "--hosts ns1.example.com,urs2.example.com");
|
assertNotInStdout("--locks_to_preserve");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCommand_generatesUndoForUndelegatedDomain() throws Exception {
|
public void testCommand_generatesUndoForUndelegatedDomain() throws Exception {
|
||||||
persistActiveHost("urs1.example.com");
|
|
||||||
persistActiveHost("urs2.example.com");
|
|
||||||
persistActiveDomain("evil.tld");
|
persistActiveDomain("evil.tld");
|
||||||
runCommandForced("--domain_name=evil.tld", "--hosts=urs1.example.com,urs2.example.com");
|
runCommandForced("--domain_name=evil.tld", "--hosts=urs1.example.com,urs2.example.com");
|
||||||
assertInStdout("uniform_rapid_suspension --undo --domain_name evil.tld");
|
assertInStdout("uniform_rapid_suspension --undo");
|
||||||
|
assertInStdout("--domain_name evil.tld");
|
||||||
|
assertNotInStdout("--locks_to_preserve");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCommand_generatesUndoWithPreserve() throws Exception {
|
public void testCommand_generatesUndoWithLocksToPreserve() throws Exception {
|
||||||
persistResource(
|
persistResource(
|
||||||
newDomainResource("evil.tld").asBuilder()
|
newDomainResource("evil.tld").asBuilder()
|
||||||
.addStatusValue(StatusValue.SERVER_DELETE_PROHIBITED)
|
.addStatusValue(StatusValue.SERVER_DELETE_PROHIBITED)
|
||||||
.build());
|
.build());
|
||||||
runCommandForced("--domain_name=evil.tld");
|
runCommandForced("--domain_name=evil.tld");
|
||||||
assertInStdout(
|
assertInStdout("uniform_rapid_suspension --undo");
|
||||||
"uniform_rapid_suspension --undo --domain_name evil.tld --preserve serverDeleteProhibited");
|
assertInStdout("--domain_name evil.tld");
|
||||||
|
assertInStdout("--locks_to_preserve serverDeleteProhibited");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUndo_removesLocksReplacesHosts() throws Exception {
|
public void testUndo_removesLocksReplacesHostsAndDsData() throws Exception {
|
||||||
persistActiveHost("ns1.example.com");
|
persistDomainWithHosts(urs1, urs2);
|
||||||
persistActiveHost("ns2.example.com");
|
|
||||||
persistDomainWithHosts(
|
|
||||||
persistActiveHost("urs1.example.com"),
|
|
||||||
persistActiveHost("urs2.example.com"));
|
|
||||||
runCommandForced(
|
runCommandForced(
|
||||||
"--domain_name=evil.tld", "--undo", "--hosts=ns1.example.com,ns2.example.com");
|
"--domain_name=evil.tld", "--undo", "--hosts=ns1.example.com,ns2.example.com");
|
||||||
eppVerifier()
|
eppVerifier()
|
||||||
|
@ -125,16 +136,12 @@ public class UniformRapidSuspensionCommandTest
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUndo_respectsPreserveFlag() throws Exception {
|
public void testUndo_respectsLocksToPreserveFlag() throws Exception {
|
||||||
persistActiveHost("ns1.example.com");
|
persistDomainWithHosts(urs1, urs2);
|
||||||
persistActiveHost("ns2.example.com");
|
|
||||||
persistDomainWithHosts(
|
|
||||||
persistActiveHost("urs1.example.com"),
|
|
||||||
persistActiveHost("urs2.example.com"));
|
|
||||||
runCommandForced(
|
runCommandForced(
|
||||||
"--domain_name=evil.tld",
|
"--domain_name=evil.tld",
|
||||||
"--undo",
|
"--undo",
|
||||||
"--preserve=serverDeleteProhibited",
|
"--locks_to_preserve=serverDeleteProhibited",
|
||||||
"--hosts=ns1.example.com,ns2.example.com");
|
"--hosts=ns1.example.com,ns2.example.com");
|
||||||
eppVerifier()
|
eppVerifier()
|
||||||
.setClientIdentifier("CharlestonRoad")
|
.setClientIdentifier("CharlestonRoad")
|
||||||
|
@ -144,18 +151,43 @@ public class UniformRapidSuspensionCommandTest
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_preserveWithoutUndo() throws Exception {
|
public void testFailure_locksToPreserveWithoutUndo() throws Exception {
|
||||||
persistActiveDomain("evil.tld");
|
persistActiveDomain("evil.tld");
|
||||||
thrown.expect(IllegalArgumentException.class, "--undo");
|
thrown.expect(IllegalArgumentException.class, "--undo");
|
||||||
runCommandForced("--domain_name=evil.tld", "--preserve=serverDeleteProhibited");
|
runCommandForced("--domain_name=evil.tld", "--locks_to_preserve=serverDeleteProhibited");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_domainNameRequired() throws Exception {
|
public void testFailure_domainNameRequired() throws Exception {
|
||||||
persistActiveHost("urs1.example.com");
|
|
||||||
persistActiveHost("urs2.example.com");
|
|
||||||
persistActiveDomain("evil.tld");
|
persistActiveDomain("evil.tld");
|
||||||
thrown.expect(ParameterException.class, "--domain_name");
|
thrown.expect(ParameterException.class, "--domain_name");
|
||||||
runCommandForced("--hosts=urs1.example.com,urs2.example.com");
|
runCommandForced("--hosts=urs1.example.com,urs2.example.com");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testFailure_extraFieldInDsData() throws Exception {
|
||||||
|
persistActiveDomain("evil.tld");
|
||||||
|
thrown.expect(IllegalArgumentException.class, "Incorrect fields on --dsdata JSON");
|
||||||
|
runCommandForced(
|
||||||
|
"--domain_name=evil.tld",
|
||||||
|
"--dsdata={\"keyTag\":1,\"alg\":1,\"digestType\":1,\"digest\":\"abc\",\"foo\":1}");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testFailure_missingFieldInDsData() throws Exception {
|
||||||
|
persistActiveDomain("evil.tld");
|
||||||
|
thrown.expect(IllegalArgumentException.class, "Incorrect fields on --dsdata JSON");
|
||||||
|
runCommandForced(
|
||||||
|
"--domain_name=evil.tld",
|
||||||
|
"--dsdata={\"keyTag\":1,\"alg\":1,\"digestType\":1}");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testFailure_malformedDsData() throws Exception {
|
||||||
|
persistActiveDomain("evil.tld");
|
||||||
|
thrown.expect(IllegalArgumentException.class, "Invalid --dsdata JSON");
|
||||||
|
runCommandForced(
|
||||||
|
"--domain_name=evil.tld",
|
||||||
|
"--dsdata=[1,2,3]");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,19 @@
|
||||||
</domain:update>
|
</domain:update>
|
||||||
</update>
|
</update>
|
||||||
<extension>
|
<extension>
|
||||||
|
<secDNS:update xmlns:secDNS="urn:ietf:params:xml:ns:secDNS-1.1">
|
||||||
|
<secDNS:rem>
|
||||||
|
<secDNS:all>true</secDNS:all>
|
||||||
|
</secDNS:rem>
|
||||||
|
<secDNS:add>
|
||||||
|
<secDNS:dsData>
|
||||||
|
<secDNS:keyTag>1</secDNS:keyTag>
|
||||||
|
<secDNS:alg>1</secDNS:alg>
|
||||||
|
<secDNS:digestType>1</secDNS:digestType>
|
||||||
|
<secDNS:digest>abc</secDNS:digest>
|
||||||
|
</secDNS:dsData>
|
||||||
|
</secDNS:add>
|
||||||
|
</secDNS:update>
|
||||||
<metadata:metadata xmlns:metadata="urn:google:params:xml:ns:metadata-1.0">
|
<metadata:metadata xmlns:metadata="urn:google:params:xml:ns:metadata-1.0">
|
||||||
<metadata:reason>Uniform Rapid Suspension</metadata:reason>
|
<metadata:reason>Uniform Rapid Suspension</metadata:reason>
|
||||||
<metadata:requestedByRegistrar>false</metadata:requestedByRegistrar>
|
<metadata:requestedByRegistrar>false</metadata:requestedByRegistrar>
|
||||||
|
|
|
@ -20,6 +20,11 @@
|
||||||
</domain:update>
|
</domain:update>
|
||||||
</update>
|
</update>
|
||||||
<extension>
|
<extension>
|
||||||
|
<secDNS:update xmlns:secDNS="urn:ietf:params:xml:ns:secDNS-1.1">
|
||||||
|
<secDNS:rem>
|
||||||
|
<secDNS:all>true</secDNS:all>
|
||||||
|
</secDNS:rem>
|
||||||
|
</secDNS:update>
|
||||||
<metadata:metadata xmlns:metadata="urn:google:params:xml:ns:metadata-1.0">
|
<metadata:metadata xmlns:metadata="urn:google:params:xml:ns:metadata-1.0">
|
||||||
<metadata:reason>Uniform Rapid Suspension</metadata:reason>
|
<metadata:reason>Uniform Rapid Suspension</metadata:reason>
|
||||||
<metadata:requestedByRegistrar>false</metadata:requestedByRegistrar>
|
<metadata:requestedByRegistrar>false</metadata:requestedByRegistrar>
|
||||||
|
|
|
@ -22,6 +22,11 @@
|
||||||
</domain:update>
|
</domain:update>
|
||||||
</update>
|
</update>
|
||||||
<extension>
|
<extension>
|
||||||
|
<secDNS:update xmlns:secDNS="urn:ietf:params:xml:ns:secDNS-1.1">
|
||||||
|
<secDNS:rem>
|
||||||
|
<secDNS:all>true</secDNS:all>
|
||||||
|
</secDNS:rem>
|
||||||
|
</secDNS:update>
|
||||||
<metadata:metadata xmlns:metadata="urn:google:params:xml:ns:metadata-1.0">
|
<metadata:metadata xmlns:metadata="urn:google:params:xml:ns:metadata-1.0">
|
||||||
<metadata:reason>Undo Uniform Rapid Suspension</metadata:reason>
|
<metadata:reason>Undo Uniform Rapid Suspension</metadata:reason>
|
||||||
<metadata:requestedByRegistrar>false</metadata:requestedByRegistrar>
|
<metadata:requestedByRegistrar>false</metadata:requestedByRegistrar>
|
||||||
|
|
|
@ -21,6 +21,11 @@
|
||||||
</domain:update>
|
</domain:update>
|
||||||
</update>
|
</update>
|
||||||
<extension>
|
<extension>
|
||||||
|
<secDNS:update xmlns:secDNS="urn:ietf:params:xml:ns:secDNS-1.1">
|
||||||
|
<secDNS:rem>
|
||||||
|
<secDNS:all>true</secDNS:all>
|
||||||
|
</secDNS:rem>
|
||||||
|
</secDNS:update>
|
||||||
<metadata:metadata xmlns:metadata="urn:google:params:xml:ns:metadata-1.0">
|
<metadata:metadata xmlns:metadata="urn:google:params:xml:ns:metadata-1.0">
|
||||||
<metadata:reason>Undo Uniform Rapid Suspension</metadata:reason>
|
<metadata:reason>Undo Uniform Rapid Suspension</metadata:reason>
|
||||||
<metadata:requestedByRegistrar>false</metadata:requestedByRegistrar>
|
<metadata:requestedByRegistrar>false</metadata:requestedByRegistrar>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue