mv com/google/domain/registry google/registry

This change renames directories in preparation for the great package
rename. The repository is now in a broken state because the code
itself hasn't been updated. However this should ensure that git
correctly preserves history for each file.
This commit is contained in:
Justine Tunney 2016-05-13 18:55:08 -04:00
parent a41677aea1
commit 5012893c1d
2396 changed files with 0 additions and 0 deletions

View file

@ -0,0 +1,192 @@
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.domain.registry.tools;
import static com.google.common.io.BaseEncoding.base16;
import static com.google.common.io.Resources.getResource;
import static com.google.common.io.Resources.toByteArray;
import static com.google.common.truth.Truth.assertThat;
import static com.google.domain.registry.flows.EppServletUtils.APPLICATION_EPP_XML_UTF8;
import static com.google.domain.registry.flows.FlowRegistry.getFlowClass;
import static com.google.domain.registry.model.domain.DesignatedContact.Type.ADMIN;
import static com.google.domain.registry.model.domain.DesignatedContact.Type.BILLING;
import static com.google.domain.registry.model.domain.DesignatedContact.Type.TECH;
import static com.google.domain.registry.model.domain.launch.ApplicationStatus.VALIDATED;
import static com.google.domain.registry.model.registry.Registry.TldState.QUIET_PERIOD;
import static com.google.domain.registry.testing.DatastoreHelper.createTld;
import static com.google.domain.registry.testing.DatastoreHelper.newDomainApplication;
import static com.google.domain.registry.testing.DatastoreHelper.persistActiveContact;
import static com.google.domain.registry.testing.DatastoreHelper.persistActiveHost;
import static com.google.domain.registry.testing.DatastoreHelper.persistResource;
import static com.google.domain.registry.util.DateTimeUtils.START_OF_TIME;
import static com.google.domain.registry.util.ResourceUtils.readResourceUtf8;
import static com.google.domain.registry.xml.XmlTestUtils.assertXmlEquals;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.domain.registry.flows.EppXmlTransformer;
import com.google.domain.registry.flows.domain.DomainAllocateFlow;
import com.google.domain.registry.model.domain.DesignatedContact;
import com.google.domain.registry.model.domain.DomainApplication;
import com.google.domain.registry.model.domain.ReferenceUnion;
import com.google.domain.registry.model.domain.launch.LaunchNotice;
import com.google.domain.registry.model.domain.secdns.DelegationSignerData;
import com.google.domain.registry.model.eppcommon.Trid;
import com.google.domain.registry.model.eppinput.EppInput;
import com.google.domain.registry.model.reporting.HistoryEntry;
import com.google.domain.registry.tools.ServerSideCommand.Connection;
import com.beust.jcommander.ParameterException;
import org.joda.time.DateTime;
import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
import org.mockito.Mock;
import java.io.IOException;
import java.util.List;
/** Unit tests for {@link AllocateDomainCommand}. */
public class AllocateDomainCommandTest extends CommandTestCase<AllocateDomainCommand> {
private static final String EXPECTED_XML_ONE =
readResourceUtf8(AllocateDomainCommandTest.class, "testdata/allocate_domain.xml");
private static final String EXPECTED_XML_TWO =
readResourceUtf8(AllocateDomainCommandTest.class, "testdata/allocate_domain2.xml");
@Mock
Connection connection;
@Captor
ArgumentCaptor<byte[]> xml;
@Before
public void init() throws IOException {
command.setConnection(connection);
createTld("tld", QUIET_PERIOD);
createApplication("example-one.tld", "testdata/domain_create_sunrush.xml", "1-TLD");
createApplication("example-two.tld", "testdata/domain_create_sunrush2.xml", "2-TLD");
}
private void createApplication(String name, String xmlFile, String repoId) throws IOException {
DomainApplication application =
persistResource(newDomainApplication(name)
.asBuilder()
.setRepoId(repoId)
.setCreationTimeForTest(START_OF_TIME)
.setRegistrant(ReferenceUnion.create(persistActiveContact("registrant")))
.setContacts(ImmutableSet.of(
DesignatedContact.create(
ADMIN,
ReferenceUnion.create(persistActiveContact("adminContact"))),
DesignatedContact.create(
BILLING,
ReferenceUnion.create(persistActiveContact("billingContact"))),
DesignatedContact.create(
TECH,
ReferenceUnion.create(persistActiveContact("techContact")))))
.setNameservers(ImmutableSet.of(
ReferenceUnion.create(persistActiveHost("ns1.example.com")),
ReferenceUnion.create(persistActiveHost("ns2.example.com"))))
.setApplicationStatus(VALIDATED)
.setDsData(ImmutableSet.of(
DelegationSignerData.create(
12345, 3, 1, base16().decode("49FD46E6C4B45C55D4AC")),
DelegationSignerData.create(
56789, 2, 4, base16().decode("69FD46E6C4A45C55D4AC"))))
.setLaunchNotice(LaunchNotice.create(
"370d0b7c9223372036854775807",
"tmch",
DateTime.parse("2010-08-16T09:00:00.0Z"),
DateTime.parse("2009-08-16T09:00:00.0Z")))
.build());
persistResource(
new HistoryEntry.Builder()
.setParent(application)
.setClientId("NewRegistrar")
.setModificationTime(application.getCreationTime())
.setTrid(Trid.create("ABC-123"))
.setXmlBytes(toByteArray(getResource(AllocateDomainCommandTest.class, xmlFile)))
.build());
}
private void verifySent(boolean dryRun, String clientId, String... expectedXml) throws Exception {
ImmutableMap<String, ?> params = ImmutableMap.of(
"dryRun", dryRun,
"clientIdentifier", clientId,
"superuser", true);
verify(connection, times(expectedXml.length))
.send(eq("/_dr/epptool"), eq(params), eq(APPLICATION_EPP_XML_UTF8), xml.capture());
List<byte[]> allCapturedXml = xml.getAllValues();
assertThat(allCapturedXml).hasSize(expectedXml.length);
int capturedXmlIndex = 0;
for (String expected : expectedXml) {
assertXmlEquals(expected, new String(allCapturedXml.get(capturedXmlIndex++), UTF_8));
}
}
@Test
public void testSuccess() throws Exception {
runCommand("--ids=1-TLD", "--force", "--superuser");
// NB: These commands are all sent on behalf of the sponsoring registrar, in this case
// "TheRegistrar".
verifySent(false, "TheRegistrar", EXPECTED_XML_ONE);
}
@Test
public void testSuccess_multiple() throws Exception {
runCommand("--ids=1-TLD,2-TLD", "--force", "--superuser");
verifySent(false, "TheRegistrar", EXPECTED_XML_ONE, EXPECTED_XML_TWO);
}
@Test
public void testSuccess_dryRun() throws Exception {
runCommand("--ids=1-TLD", "--dry_run", "--superuser");
verifySent(true, "TheRegistrar", EXPECTED_XML_ONE);
}
@Test
public void testFailure_notAsSuperuser() throws Exception {
thrown.expect(IllegalArgumentException.class);
runCommand("--ids=1-TLD", "--force");
}
@Test
public void testFailure_forceAndDryRunIncompatible() throws Exception {
thrown.expect(IllegalArgumentException.class);
runCommand("--ids=1-TLD", "--force", "--dry_run", "--superuser");
}
@Test
public void testFailure_unknownFlag() throws Exception {
thrown.expect(ParameterException.class);
runCommand("--ids=1-TLD", "--force", "--unrecognized=foo", "--superuser");
}
@Test
public void testXmlInstantiatesFlow() throws Exception {
assertThat(
getFlowClass(EppXmlTransformer.<EppInput>unmarshal(EXPECTED_XML_ONE.getBytes(UTF_8))))
.isEqualTo(DomainAllocateFlow.class);
}
}

View file

@ -0,0 +1,58 @@
package(
default_visibility = ["//java/com/google/domain/registry:registry_project"],
)
load("//java/com/google/testing/builddefs:GenTestRules.bzl", "GenTestRules")
internal_files = [
"brda_copy_files_test.py",
"tld_watcher_test.py",
]
java_library(
name = "tools",
srcs = glob(["*.java"]),
resources = glob(["testdata/*.*"]),
deps = [
"//java/com/google/common/annotations",
"//java/com/google/common/base",
"//java/com/google/common/collect",
"//java/com/google/common/io",
"//java/com/google/common/net",
"//java/com/google/common/reflect",
"//java/com/google/domain/registry/config",
"//java/com/google/domain/registry/flows",
"//java/com/google/domain/registry/keyring/api",
"//java/com/google/domain/registry/model",
"//java/com/google/domain/registry/rde",
"//java/com/google/domain/registry/request",
"//java/com/google/domain/registry/tmch",
"//java/com/google/domain/registry/tools",
"//java/com/google/domain/registry/tools/params",
"//java/com/google/domain/registry/tools/server",
"//java/com/google/domain/registry/util",
"//java/com/google/domain/registry/xjc",
"//java/com/google/domain/registry/xml",
"//javatests/com/google/domain/registry/model",
"//javatests/com/google/domain/registry/rde",
"//javatests/com/google/domain/registry/testing",
"//javatests/com/google/domain/registry/xml",
"//third_party/java/appengine:appengine-api-testonly",
"//third_party/java/jcommander",
"//third_party/java/joda_money",
"//third_party/java/joda_time",
"//third_party/java/json_simple",
"//third_party/java/junit",
"//third_party/java/mockito",
"//third_party/java/objectify:objectify-v4_1",
"//third_party/java/truth",
],
)
GenTestRules(
name = "GeneratedTestRules",
test_files = glob(["**/*Test.java"]),
deps = [":tools"],
)

View file

@ -0,0 +1,180 @@
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.domain.registry.tools;
import static com.google.common.truth.Truth.assertThat;
import static com.google.domain.registry.model.ofy.ObjectifyService.ofy;
import static java.nio.charset.StandardCharsets.UTF_8;
import com.google.common.base.Joiner;
import com.google.common.base.Splitter;
import com.google.common.collect.FluentIterable;
import com.google.common.collect.ObjectArrays;
import com.google.common.io.Files;
import com.google.common.reflect.TypeToken;
import com.google.domain.registry.model.poll.PollMessage;
import com.google.domain.registry.testing.AppEngineRule;
import com.google.domain.registry.testing.CertificateSamples;
import com.google.domain.registry.testing.ExceptionRule;
import com.google.domain.registry.tools.params.ParameterFactory;
import com.beust.jcommander.JCommander;
import org.junit.Before;
import org.junit.Rule;
import org.junit.rules.TemporaryFolder;
import org.junit.runner.RunWith;
import org.mockito.runners.MockitoJUnitRunner;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.PrintStream;
import java.util.List;
import java.util.regex.Pattern;
/**
* Base class for all command tests.
*
* @param <C> the command type
*/
@RunWith(MockitoJUnitRunner.class)
public abstract class CommandTestCase<C extends Command> {
private ByteArrayOutputStream stdout = new ByteArrayOutputStream();
protected C command;
@Rule
public final AppEngineRule appEngine = AppEngineRule.builder()
.withDatastore()
.withTaskQueue()
.build();
@Rule
public final ExceptionRule thrown = new ExceptionRule();
@Rule
public TemporaryFolder tmpDir = new TemporaryFolder();
@Before
public final void beforeCommandTestCase() {
// Ensure the UNITTEST environment has been set before constructing a new command instance.
RegistryToolEnvironment.UNITTEST.setup();
command = newCommandInstance();
System.setOut(new PrintStream(stdout));
}
void runCommandInEnvironment(RegistryToolEnvironment env, String... args) throws Exception {
env.setup();
try {
JCommander jcommander = new JCommander(command);
jcommander.addConverterFactory(new ParameterFactory());
jcommander.parse(args);
command.run();
} finally {
// Clear the session cache so that subsequent reads for verification purposes hit datastore.
// This primarily matters for AutoTimestamp fields, which otherwise won't have updated values.
ofy().clearSessionCache();
// Reset back to UNITTEST environment.
RegistryToolEnvironment.UNITTEST.setup();
}
}
void runCommand(String... args) throws Exception {
runCommandInEnvironment(RegistryToolEnvironment.UNITTEST, args);
}
/** Adds "--force" as the first parameter, then runs the command. */
void runCommandForced(String... args) throws Exception {
runCommand(ObjectArrays.concat("--force", args));
}
/** Writes the data to a named temporary file and then returns a path to the file. */
String writeToNamedTmpFile(String filename, byte[] data) throws IOException {
File tmpFile = tmpDir.newFile(filename);
Files.write(data, tmpFile);
return tmpFile.getPath();
}
/** Writes the data to a named temporary file and then returns a path to the file. */
String writeToNamedTmpFile(String filename, String...data) throws IOException {
return writeToNamedTmpFile(filename, Joiner.on('\n').join(data).getBytes(UTF_8));
}
/** Writes the data to a temporary file and then returns a path to the file. */
String writeToNamedTmpFile(String filename, Iterable<String> data) throws IOException {
return writeToNamedTmpFile(filename, FluentIterable.from(data).toArray(String.class));
}
/** Writes the data to a temporary file and then returns a path to the file. */
String writeToTmpFile(byte[] data) throws IOException {
return writeToNamedTmpFile("tmp_file", data);
}
/** Writes the data to a temporary file and then returns a path to the file. */
String writeToTmpFile(String...data) throws IOException {
return writeToNamedTmpFile("tmp_file", data);
}
/** Writes the data to a temporary file and then returns a path to the file. */
String writeToTmpFile(Iterable<String> data) throws IOException {
return writeToNamedTmpFile("tmp_file", FluentIterable.from(data).toArray(String.class));
}
/** Returns a path to a known good certificate file. */
String getCertFilename() throws IOException {
return writeToNamedTmpFile("cert.pem", CertificateSamples.SAMPLE_CERT);
}
/** Reloads the given resource from Datastore. */
<T> T reloadResource(T resource) {
return ofy().load().entity(resource).now();
}
/** Returns count of all poll messages in Datastore. */
int getPollMessageCount() {
return ofy().load().type(PollMessage.class).count();
}
void assertInStdout(String expected) throws Exception {
assertThat(stdout.toString(UTF_8.toString())).contains(expected);
}
void assertInStdout(Pattern expected) throws Exception {
assertThat(stdout.toString(UTF_8.toString())).containsMatch(expected);
}
void assertNotInStdout(String expected) throws Exception {
assertThat(stdout.toString(UTF_8.toString())).doesNotContain(expected);
}
String getStdoutAsString() {
return new String(stdout.toByteArray(), UTF_8);
}
List<String> getStdoutAsLines() {
return Splitter.on('\n').omitEmptyStrings().trimResults().splitToList(getStdoutAsString());
}
@SuppressWarnings("unchecked")
protected C newCommandInstance() {
try {
return (C) new TypeToken<C>(getClass()){}.getRawType().newInstance();
} catch (InstantiationException | IllegalAccessException e) {
throw new RuntimeException(e);
}
}
}

View file

@ -0,0 +1,125 @@
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.domain.registry.tools;
import static com.google.domain.registry.testing.DatastoreHelper.createTld;
import static com.google.domain.registry.testing.DatastoreHelper.persistPremiumList;
import static com.google.domain.registry.testing.DatastoreHelper.persistResource;
import com.google.domain.registry.model.registry.Registry;
import com.beust.jcommander.ParameterException;
import org.junit.Test;
/** Unit tests for {@link CreateAnchorTenantCommand}. */
public class CreateAnchorTenantCommandTest
extends EppToolCommandTestCase<CreateAnchorTenantCommand> {
@Override
void initEppToolCommandTestCase() {
command.passwordGenerator = new FakePasswordGenerator("abcdefghijklmnopqrstuvwxyz");
}
@Test
public void testSuccess() throws Exception {
runCommandForced("--client=NewRegistrar", "--superuser",
"--reason=anchor-tenant-test", "--contact=jd1234", "--domain_name=example.tld");
verifySent("testdata/domain_create_anchor_tenant.xml", false, true);
}
@Test
public void testSuccess_suppliedPassword() throws Exception {
runCommandForced("--client=NewRegistrar", "--superuser", "--password=foo",
"--reason=anchor-tenant-test", "--contact=jd1234", "--domain_name=example.tld");
verifySent("testdata/domain_create_anchor_tenant_password.xml", false, true);
}
@Test
public void testSuccess_multipleWordReason() throws Exception {
runCommandForced("--client=NewRegistrar", "--superuser",
"--reason=\"anchor tenant test\"", "--contact=jd1234", "--domain_name=example.tld");
verifySent("testdata/domain_create_anchor_tenant_multiple_word_reason.xml", false, true);
}
@Test
public void testSuccess_noReason() throws Exception {
runCommandForced("--client=NewRegistrar", "--superuser",
"--contact=jd1234", "--domain_name=example.tld");
verifySent("testdata/domain_create_anchor_tenant_no_reason.xml", false, true);
}
@Test
public void testSuccess_feeStandard() throws Exception {
runCommandForced("--client=NewRegistrar", "--superuser", "--fee",
"--reason=anchor-tenant-test", "--contact=jd1234", "--domain_name=example.tld");
verifySent("testdata/domain_create_anchor_tenant_fee_standard.xml", false, true);
}
@Test
public void testSuccess_feePremium() throws Exception {
createTld("tld");
persistResource(
Registry.get("tld")
.asBuilder()
.setPremiumList(persistPremiumList("tld", "premium,JPY 20000"))
.build());
runCommandForced("--client=NewRegistrar", "--superuser", "--fee",
"--reason=anchor-tenant-test", "--contact=jd1234", "--domain_name=premium.tld");
verifySent("testdata/domain_create_anchor_tenant_fee_premium.xml", false, true);
}
@Test
public void testFailure_mainParameter() throws Exception {
thrown.expect(ParameterException.class);
runCommandForced("--tld=tld", "--client=NewRegistrar", "--superuser",
"--reason=anchor-tenant-test", "--contact=jd1234", "--domain_name=example.tld", "foo");
}
@Test
public void testFailure_missingClientId() throws Exception {
thrown.expect(ParameterException.class);
runCommandForced("--superuser",
"--reason=anchor-tenant-test", "--contact=jd1234", "--domain_name=example.tld");
}
@Test
public void testFailure_unknownFlag() throws Exception {
thrown.expect(ParameterException.class);
runCommandForced("--foo=bar", "--client=NewRegistrar", "--superuser",
"--reason=anchor-tenant-test", "--contact=jd1234", "--domain_name=example.tld");
}
@Test
public void testFailure_missingDomainName() throws Exception {
thrown.expect(ParameterException.class);
runCommandForced("--client=NewRegistrar", "--superuser",
"--reason=anchor-tenant-test", "--contact=jd1234", "foo");
}
@Test
public void testFailure_missingContact() throws Exception {
thrown.expect(ParameterException.class);
runCommandForced("--client=NewRegistrar", "--superuser",
"--reason=anchor-tenant-test", "--domain_name=example.tld", "foo");
}
@Test
public void testFailure_notAsSuperuser() throws Exception {
thrown.expect(IllegalArgumentException.class);
runCommandForced("--client=NewRegistrar",
"--reason=anchor-tenant-test", "--contact=jd1234", "--domain_name=example.tld");
}
}

View file

@ -0,0 +1,87 @@
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.domain.registry.tools;
import com.beust.jcommander.ParameterException;
import org.junit.Test;
/** Unit tests for {@link CreateContactCommand}. */
public class CreateContactCommandTest
extends EppToolCommandTestCase<CreateContactCommand> {
@Override
void initEppToolCommandTestCase() {
command.passwordGenerator = new FakePasswordGenerator("abcdefghijklmnopqrstuvwxyz");
}
@Test
public void testSuccess_complete() throws Exception {
runCommandForced(
"--client=NewRegistrar",
"--id=sh8013",
"--name=\"John Doe\"",
"--org=\"Example Inc.\"",
"--street=\"123 Example Dr.\"",
"--street=\"Floor 3\"",
"--street=\"Suite 100\"",
"--city=Dulles",
"--state=VA",
"--zip=20166-6503",
"--cc=US",
"--phone=+1.7035555555",
"--fax=+1.7035555556",
"--email=jdoe@example.com",
"--password=2fooBAR");
verifySent("testdata/contact_create_complete.xml", false, false);
}
@Test
public void testSuccess_minimal() throws Exception {
// Will never be the case, but tests that each field can be omitted.
// Also tests the auto-gen password.
runCommandForced("--client=NewRegistrar");
verifySent("testdata/contact_create_minimal.xml", false, false);
}
@Test
public void testFailure_missingClientId() throws Exception {
thrown.expect(ParameterException.class);
runCommandForced();
}
@Test
public void testFailure_tooManyStreetLines() throws Exception {
thrown.expect(IllegalArgumentException.class);
runCommandForced(
"--client=NewRegistrar",
"--street=\"123 Example Dr.\"",
"--street=\"Floor 3\"",
"--street=\"Suite 100\"",
"--street=\"Office 1\"");
}
@Test
public void testFailure_badPhone() throws Exception {
thrown.expect(ParameterException.class);
runCommandForced("--client=NewRegistrar", "--phone=3");
}
@Test
public void testFailure_badFax() throws Exception {
thrown.expect(ParameterException.class);
runCommandForced("--client=NewRegistrar", "--fax=3");
}
}

View file

@ -0,0 +1,148 @@
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.domain.registry.tools;
import static com.google.common.collect.Iterables.getOnlyElement;
import static com.google.common.truth.Truth.assertThat;
import static com.google.domain.registry.model.ofy.ObjectifyService.ofy;
import static com.google.domain.registry.testing.DatastoreHelper.createTld;
import static com.google.domain.registry.testing.DatastoreHelper.persistResource;
import static org.joda.money.CurrencyUnit.USD;
import static org.joda.time.DateTimeZone.UTC;
import com.google.common.collect.Range;
import com.google.domain.registry.model.billing.RegistrarCredit;
import com.google.domain.registry.model.billing.RegistrarCredit.CreditType;
import com.google.domain.registry.model.billing.RegistrarCreditBalance;
import com.google.domain.registry.model.registrar.Registrar;
import com.google.domain.registry.model.registry.Registry;
import com.beust.jcommander.ParameterException;
import com.googlecode.objectify.Key;
import org.joda.money.Money;
import org.joda.time.DateTime;
import org.junit.Before;
import org.junit.Test;
/** Unit tests for {@link CreateCreditBalanceCommand}. */
public class CreateCreditBalanceCommandTest extends CommandTestCase<CreateCreditBalanceCommand> {
private Registrar registrar;
private RegistrarCredit credit;
private long creditId;
@Before
public void setUp() {
registrar = Registrar.loadByClientId("TheRegistrar");
createTld("tld");
assertThat(Registry.get("tld").getCurrency()).isEqualTo(USD);
credit = persistResource(
new RegistrarCredit.Builder()
.setParent(registrar)
.setType(CreditType.PROMOTION)
.setTld("tld")
.setCurrency(USD)
.setCreationTime(Registry.get("tld").getCreationTime().plusMillis(1))
.build());
creditId = Key.create(credit).getId();
}
@Test
public void testSuccess() throws Exception {
DateTime before = DateTime.now(UTC);
runCommandForced(
"--registrar=TheRegistrar",
"--credit_id=" + creditId,
"--balance=\"USD 100\"",
"--effective_time=2014-11-01T01:02:03Z");
RegistrarCreditBalance creditBalance =
getOnlyElement(ofy().load().type(RegistrarCreditBalance.class).ancestor(credit));
assertThat(creditBalance).isNotNull();
assertThat(creditBalance.getParent().get()).isEqualTo(credit);
assertThat(creditBalance.getEffectiveTime()).isEqualTo(DateTime.parse("2014-11-01T01:02:03Z"));
assertThat(creditBalance.getWrittenTime()).isIn(Range.closed(before, DateTime.now(UTC)));
assertThat(creditBalance.getAmount()).isEqualTo(Money.of(USD, 100));
}
@Test
public void testFailure_nonexistentParentRegistrar() throws Exception {
thrown.expect(NullPointerException.class, "FakeRegistrar");
runCommandForced(
"--registrar=FakeRegistrar",
"--credit_id=" + creditId,
"--balance=\"USD 100\"",
"--effective_time=2014-11-01T01:02:03Z");
}
@Test
public void testFailure_nonexistentCreditId() throws Exception {
long badId = creditId + 1;
thrown.expect(NullPointerException.class, "ID " + badId);
runCommandForced(
"--registrar=TheRegistrar",
"--credit_id=" + badId,
"--balance=\"USD 100\"",
"--effective_time=2014-11-01T01:02:03Z");
}
@Test
public void testFailure_negativeBalance() throws Exception {
thrown.expect(IllegalArgumentException.class, "negative");
runCommandForced(
"--registrar=TheRegistrar",
"--credit_id=" + creditId,
"--balance=\"USD -1\"",
"--effective_time=2014-11-01T01:02:03Z");
}
@Test
public void testFailure_noRegistrar() throws Exception {
thrown.expect(ParameterException.class, "--registrar");
runCommandForced(
"--credit_id=" + creditId,
"--balance=\"USD 100\"",
"--effective_time=2014-11-01T01:02:03Z");
}
@Test
public void testFailure_noCreditId() throws Exception {
thrown.expect(ParameterException.class, "--credit_id");
runCommandForced(
"--registrar=TheRegistrar",
"--balance=\"USD 100\"",
"--effective_time=2014-11-01T01:02:03Z");
}
@Test
public void testFailure_noBalance() throws Exception {
thrown.expect(ParameterException.class, "--balance");
runCommandForced(
"--registrar=TheRegistrar",
"--credit_id=" + creditId,
"--effective_time=2014-11-01T01:02:03Z");
}
@Test
public void testFailure_noEffectiveTime() throws Exception {
thrown.expect(ParameterException.class, "--effective_time");
runCommandForced(
"--registrar=TheRegistrar",
"--credit_id=" + creditId,
"--balance=\"USD 100\"");
}
}

View file

@ -0,0 +1,188 @@
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.domain.registry.tools;
import static com.google.common.collect.Iterables.getOnlyElement;
import static com.google.common.truth.Truth.assertThat;
import static com.google.domain.registry.model.ofy.ObjectifyService.ofy;
import static com.google.domain.registry.testing.DatastoreHelper.createTld;
import static org.joda.money.CurrencyUnit.USD;
import static org.joda.time.DateTimeZone.UTC;
import com.google.common.collect.Range;
import com.google.domain.registry.model.billing.RegistrarCredit;
import com.google.domain.registry.model.billing.RegistrarCredit.CreditType;
import com.google.domain.registry.model.billing.RegistrarCreditBalance;
import com.google.domain.registry.model.registrar.Registrar;
import com.google.domain.registry.model.registry.Registry;
import com.beust.jcommander.ParameterException;
import org.joda.money.Money;
import org.joda.time.DateTime;
import org.junit.Before;
import org.junit.Test;
/** Unit tests for {@link CreateCreditCommand}. */
public class CreateCreditCommandTest extends CommandTestCase<CreateCreditCommand> {
private Registrar registrar;
@Before
public void setUp() {
createTld("tld");
registrar = Registrar.loadByClientId("TheRegistrar");
assertThat(Registry.get("tld").getCurrency()).isEqualTo(USD);
}
@Test
public void testSuccess() throws Exception {
DateTime before = DateTime.now(UTC);
runCommandForced(
"--registrar=TheRegistrar",
"--type=PROMOTION",
"--tld=tld",
"--description=\"Some kind of credit\"",
"--balance=\"USD 100\"",
"--effective_time=2014-11-01T01:02:03Z");
RegistrarCredit credit =
getOnlyElement(ofy().load().type(RegistrarCredit.class).ancestor(registrar));
assertThat(credit).isNotNull();
assertThat(credit.getParent().get()).isEqualTo(registrar);
assertThat(credit.getType()).isEqualTo(CreditType.PROMOTION);
assertThat(credit.getTld()).isEqualTo("tld");
assertThat(credit.getDescription()).isEqualTo("Some kind of credit");
assertThat(credit.getCurrency()).isEqualTo(USD);
assertThat(credit.getCreationTime()).isIn(Range.closed(before, DateTime.now(UTC)));
RegistrarCreditBalance creditBalance =
getOnlyElement(ofy().load().type(RegistrarCreditBalance.class).ancestor(credit));
assertThat(creditBalance).isNotNull();
assertThat(creditBalance.getParent().get()).isEqualTo(credit);
assertThat(creditBalance.getEffectiveTime()).isEqualTo(DateTime.parse("2014-11-01T01:02:03Z"));
assertThat(creditBalance.getWrittenTime()).isEqualTo(credit.getCreationTime());
assertThat(creditBalance.getAmount()).isEqualTo(Money.of(USD, 100));
}
@Test
public void testSuccess_defaultDescription() throws Exception {
runCommandForced(
"--registrar=TheRegistrar",
"--type=PROMOTION",
"--tld=tld",
"--balance=\"USD 100\"",
"--effective_time=2014-11-01T01:02:03Z");
RegistrarCredit credit =
getOnlyElement(ofy().load().type(RegistrarCredit.class).ancestor(registrar));
assertThat(credit).isNotNull();
assertThat(credit.getDescription()).isEqualTo("Promotional Credit for .tld");
}
@Test
public void testFailure_nonexistentParentRegistrar() throws Exception {
thrown.expect(NullPointerException.class, "FakeRegistrar");
runCommandForced(
"--registrar=FakeRegistrar",
"--type=PROMOTION",
"--tld=tld",
"--balance=\"USD 100\"",
"--effective_time=2014-11-01T01:02:03Z");
}
@Test
public void testFailure_nonexistentTld() throws Exception {
thrown.expect(IllegalArgumentException.class, "faketld");
runCommandForced(
"--registrar=TheRegistrar",
"--type=PROMOTION",
"--tld=faketld",
"--balance=\"USD 100\"",
"--effective_time=2014-11-01T01:02:03Z");
}
@Test
public void testFailure_nonexistentType() throws Exception {
thrown.expect(ParameterException.class, "Invalid value for --type");
runCommandForced(
"--registrar=TheRegistrar",
"--type=BADTYPE",
"--tld=tld",
"--balance=\"USD 100\"",
"--effective_time=2014-11-01T01:02:03Z");
}
@Test
public void testFailure_negativeBalance() throws Exception {
thrown.expect(IllegalArgumentException.class, "negative");
runCommandForced(
"--registrar=TheRegistrar",
"--type=PROMOTION",
"--tld=tld",
"--balance=\"USD -1\"",
"--effective_time=2014-11-01T01:02:03Z");
}
@Test
public void testFailure_noRegistrar() throws Exception {
thrown.expect(ParameterException.class, "--registrar");
runCommandForced(
"--type=PROMOTION",
"--tld=tld",
"--balance=\"USD 100\"",
"--effective_time=2014-11-01T01:02:03Z");
}
@Test
public void testFailure_noType() throws Exception {
thrown.expect(ParameterException.class, "--type");
runCommandForced(
"--registrar=TheRegistrar",
"--tld=tld",
"--balance=\"USD 100\"",
"--effective_time=2014-11-01T01:02:03Z");
}
@Test
public void testFailure_noTld() throws Exception {
thrown.expect(ParameterException.class, "--tld");
runCommandForced(
"--registrar=TheRegistrar",
"--type=PROMOTION",
"--balance=\"USD 100\"",
"--effective_time=2014-11-01T01:02:03Z");
}
@Test
public void testFailure_noBalance() throws Exception {
thrown.expect(ParameterException.class, "--balance");
runCommandForced(
"--registrar=TheRegistrar",
"--type=PROMOTION",
"--tld=tld",
"--effective_time=2014-11-01T01:02:03Z");
}
@Test
public void testFailure_noEffectiveTime() throws Exception {
thrown.expect(ParameterException.class, "--effective_time");
runCommandForced(
"--registrar=TheRegistrar",
"--type=PROMOTION",
"--tld=tld",
"--balance=\"USD 100\"");
}
}

View file

@ -0,0 +1,64 @@
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.domain.registry.tools;
import static com.google.common.truth.Truth.assertThat;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.verify;
import com.google.common.collect.ImmutableMap;
import com.google.common.io.Files;
import com.google.common.net.MediaType;
import com.google.domain.registry.testing.UriParameters;
import com.google.domain.registry.tools.ServerSideCommand.Connection;
import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
import java.io.File;
import java.nio.charset.StandardCharsets;
/**
* Base class for common testing setup for create and update commands for Premium Lists.
*/
public abstract class CreateOrUpdatePremiumListCommandTestCase<
T extends CreateOrUpdatePremiumListCommand> extends CommandTestCase<T> {
@Captor
ArgumentCaptor<ImmutableMap<String, String>> urlParamCaptor;
@Captor
ArgumentCaptor<byte[]> requestBodyCaptor;
static String generateInputData(String premiumTermsPath) throws Exception {
return Files.toString(new File(premiumTermsPath), StandardCharsets.UTF_8);
}
void verifySentParams(
Connection connection, String path, ImmutableMap<String, String> parameterMap)
throws Exception {
verify(connection).send(
eq(path),
urlParamCaptor.capture(),
eq(MediaType.FORM_DATA),
requestBodyCaptor.capture());
assertThat(new ImmutableMap.Builder<String, String>()
.putAll(urlParamCaptor.getValue())
.putAll(UriParameters.parse(new String(requestBodyCaptor.getValue(), UTF_8)).entries())
.build())
.containsExactlyEntriesIn(parameterMap);
}
}

View file

@ -0,0 +1,68 @@
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.domain.registry.tools;
import static com.google.domain.registry.util.ResourceUtils.readResourceUtf8;
import static java.nio.charset.StandardCharsets.UTF_8;
import com.google.common.io.Files;
import com.beust.jcommander.ParameterException;
import org.junit.Before;
import org.junit.Test;
import java.io.File;
import java.io.IOException;
/**
* Base class for common testing setup for create and update commands for Reserved Lists.
*
* @param <T> command type
*/
public abstract class CreateOrUpdateReservedListCommandTestCase
<T extends CreateOrUpdateReservedListCommand> extends CommandTestCase<T> {
String reservedTermsPath;
String invalidReservedTermsPath;
@Before
public void init() throws IOException {
File reservedTermsFile = tmpDir.newFile("xn--q9jyb4c_common-reserved.txt");
File invalidReservedTermsFile = tmpDir.newFile("reserved-terms-wontparse.csv");
String reservedTermsCsv = readResourceUtf8(
CreateOrUpdateReservedListCommandTestCase.class, "testdata/example_reserved_terms.csv");
Files.write(reservedTermsCsv, reservedTermsFile, UTF_8);
Files.write("sdfgagmsdgs,sdfgsd\nasdf234tafgs,asdfaw\n\n", invalidReservedTermsFile, UTF_8);
reservedTermsPath = reservedTermsFile.getPath();
invalidReservedTermsPath = invalidReservedTermsFile.getPath();
}
@Test
public void testFailure_fileDoesntExist() throws Exception {
thrown.expect(ParameterException.class);
runCommandForced(
"--name=xn--q9jyb4c-blah",
"--input=" + reservedTermsPath + "-nonexistent");
}
@Test
public void testFailure_fileDoesntParse() throws Exception {
thrown.expect(IllegalArgumentException.class);
runCommandForced(
"--name=xn--q9jyb4c-blork",
"--input=" + invalidReservedTermsPath);
}
}

View file

@ -0,0 +1,116 @@
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.domain.registry.tools;
import static com.google.domain.registry.request.JsonResponse.JSON_SAFETY_PREFIX;
import static com.google.domain.registry.util.ResourceUtils.readResourceUtf8;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyMapOf;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.reset;
import static org.mockito.Mockito.when;
import com.google.common.base.VerifyException;
import com.google.common.collect.ImmutableMap;
import com.google.common.net.MediaType;
import com.google.domain.registry.tools.ServerSideCommand.Connection;
import com.google.domain.registry.tools.server.CreatePremiumListAction;
import com.beust.jcommander.ParameterException;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
/** Unit tests for {@link CreatePremiumListCommand}. */
public class CreatePremiumListCommandTest<C extends CreatePremiumListCommand>
extends CreateOrUpdatePremiumListCommandTestCase<C> {
@Mock
Connection connection;
String premiumTermsPath;
String premiumTermsCsv;
String servletPath;
@Before
public void init() throws Exception {
command.setConnection(connection);
premiumTermsPath = writeToNamedTmpFile(
"example_premium_terms.csv",
readResourceUtf8(
CreatePremiumListCommandTest.class,
"testdata/example_premium_terms.csv"));
servletPath = "/_dr/admin/createPremiumList";
when(connection.send(
eq(CreatePremiumListAction.PATH),
anyMapOf(String.class, String.class),
any(MediaType.class),
any(byte[].class)))
.thenReturn(JSON_SAFETY_PREFIX + "{\"status\":\"success\",\"lines\":[]}");
}
@Test
public void testRun() throws Exception {
runCommandForced("-i=" + premiumTermsPath, "-n=foo");
assertInStdout("Successfully");
verifySentParams(
connection,
servletPath,
ImmutableMap.of("name", "foo", "inputData", generateInputData(premiumTermsPath)));
}
@Test
public void testRun_noProvidedName_usesBasenameOfInputFile() throws Exception {
runCommandForced("-i=" + premiumTermsPath);
assertInStdout("Successfully");
verifySentParams(
connection,
servletPath,
ImmutableMap.of(
"name", "example_premium_terms", "inputData", generateInputData(premiumTermsPath)));
}
@Test
public void testRun_errorResponse() throws Exception {
reset(connection);
command.setConnection(connection);
when(connection.send(
eq(CreatePremiumListAction.PATH),
anyMapOf(String.class, String.class),
any(MediaType.class),
any(byte[].class)))
.thenReturn(
JSON_SAFETY_PREFIX + "{\"status\":\"error\",\"error\":\"foo already exists\"}");
thrown.expect(VerifyException.class, "Server error:");
runCommandForced("-i=" + premiumTermsPath, "-n=foo");
}
@Test
public void testRun_noInputFileSpecified_throwsException() throws Exception {
thrown.expect(ParameterException.class, "The following option is required");
runCommand();
}
@Test
public void testRun_invalidInputData() throws Exception {
premiumTermsPath = writeToNamedTmpFile(
"tmp_file2",
readResourceUtf8(
CreatePremiumListCommandTest.class, "testdata/example_invalid_premium_terms.csv"));
thrown.expect(IllegalArgumentException.class, "Could not parse line in premium list");
runCommandForced("-i=" + premiumTermsPath, "-n=foo");
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,63 @@
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.domain.registry.tools;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.verify;
import com.google.common.collect.ImmutableMap;
import com.google.common.net.MediaType;
import com.google.domain.registry.tools.ServerSideCommand.Connection;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
/** Unit tests for {@link CreateRegistrarGroupsCommand}. */
public class CreateRegistrarGroupsCommandTest extends
CommandTestCase<CreateRegistrarGroupsCommand> {
@Mock
private Connection connection;
@Before
public void init() {
command.setConnection(connection);
}
@Test
public void test_createGroupsForTwoRegistrars() throws Exception {
runCommandForced("NewRegistrar", "TheRegistrar");
verify(connection).send(
eq("/_dr/admin/createGroups"),
eq(ImmutableMap.of("clientId", "NewRegistrar")),
eq(MediaType.PLAIN_TEXT_UTF_8),
eq(new byte[0]));
verify(connection).send(
eq("/_dr/admin/createGroups"),
eq(ImmutableMap.of("clientId", "TheRegistrar")),
eq(MediaType.PLAIN_TEXT_UTF_8),
eq(new byte[0]));
assertInStdout("Success!");
}
@Test
public void test_throwsExceptionForNonExistentRegistrar() throws Exception {
thrown.expect(IllegalArgumentException.class,
"Could not load registrar with id FakeRegistrarThatDefinitelyDoesNotExist");
runCommandForced("FakeRegistrarThatDefinitelyDoesNotExist");
}
}

View file

@ -0,0 +1,182 @@
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.domain.registry.tools;
import static com.google.common.truth.Truth.assertThat;
import static com.google.domain.registry.model.registry.label.ReservationType.FULLY_BLOCKED;
import static com.google.domain.registry.testing.DatastoreHelper.createTlds;
import static com.google.domain.registry.testing.DatastoreHelper.persistReservedList;
import static com.google.domain.registry.testing.DatastoreHelper.persistResource;
import static com.google.domain.registry.tools.CreateReservedListCommand.INVALID_FORMAT_ERROR_MESSAGE;
import static org.joda.time.DateTimeZone.UTC;
import com.google.domain.registry.model.registry.Registry;
import com.google.domain.registry.model.registry.label.ReservedList;
import org.joda.time.DateTime;
import org.junit.Before;
import org.junit.Test;
/** Unit tests for {@link CreateReservedListCommand}. */
public class CreateReservedListCommandTest extends
CreateOrUpdateReservedListCommandTestCase<CreateReservedListCommand> {
@Before
public void initTest() throws Exception {
createTlds("xn--q9jyb4c", "soy");
}
@Test
public void testSuccess() throws Exception {
runCommandForced("--name=xn--q9jyb4c_common-reserved", "--input=" + reservedTermsPath);
assertThat(ReservedList.get("xn--q9jyb4c_common-reserved")).isPresent();
ReservedList reservedList = ReservedList.get("xn--q9jyb4c_common-reserved").get();
assertThat(reservedList.getReservedListEntries()).hasSize(2);
assertThat(reservedList.getReservationInList("baddies")).hasValue(FULLY_BLOCKED);
assertThat(reservedList.getReservationInList("ford")).hasValue(FULLY_BLOCKED);
}
@Test
public void testSuccess_unspecifiedNameDefaultsToFileName() throws Exception {
runCommandForced("--input=" + reservedTermsPath);
assertThat(ReservedList.get("xn--q9jyb4c_common-reserved")).isPresent();
}
@Test
public void testSuccess_timestampsSetCorrectly() throws Exception {
DateTime before = DateTime.now(UTC);
runCommandForced("--input=" + reservedTermsPath);
assertThat(ReservedList.get("xn--q9jyb4c_common-reserved")).isPresent();
ReservedList rl = ReservedList.get("xn--q9jyb4c_common-reserved").get();
assertThat(rl.getCreationTime()).isAtLeast(before);
assertThat(rl.getLastUpdateTime()).isEqualTo(rl.getCreationTime());
}
@Test
public void testSuccess_shouldPublishDefaultsToTrue() throws Exception {
runCommandForced("--input=" + reservedTermsPath);
assertThat(ReservedList.get("xn--q9jyb4c_common-reserved")).isPresent();
assertThat(ReservedList.get("xn--q9jyb4c_common-reserved").get().getShouldPublish()).isTrue();
}
@Test
public void testSuccess_shouldPublishSetToTrue_works() throws Exception {
runCommandForced("--input=" + reservedTermsPath, "--should_publish=true");
assertThat(ReservedList.get("xn--q9jyb4c_common-reserved")).isPresent();
assertThat(ReservedList.get("xn--q9jyb4c_common-reserved").get().getShouldPublish()).isTrue();
}
@Test
public void testSuccess_shouldPublishSetToFalse_works() throws Exception {
runCommandForced("--input=" + reservedTermsPath, "--should_publish=false");
assertThat(ReservedList.get("xn--q9jyb4c_common-reserved")).isPresent();
assertThat(ReservedList.get("xn--q9jyb4c_common-reserved").get().getShouldPublish()).isFalse();
}
@Test
public void testFailure_reservedListWithThatNameAlreadyExists() throws Exception {
thrown.expect(IllegalArgumentException.class, "A reserved list already exists by this name");
ReservedList rl = persistReservedList("xn--q9jyb4c_foo", "jones,FULLY_BLOCKED");
persistResource(Registry.get("xn--q9jyb4c").asBuilder().setReservedLists(rl).build());
runCommandForced("--name=xn--q9jyb4c_foo", "--input=" + reservedTermsPath);
}
@Test
public void testNamingRules_commonReservedList() throws Exception {
runCommandForced("--name=common_abuse-list", "--input=" + reservedTermsPath);
assertThat(ReservedList.get("common_abuse-list")).isPresent();
}
@Test
public void testNamingRules_tldThatDoesNotExist_succeedsWithOverride() throws Exception {
runNameTestWithOverride("footld_reserved-list");
}
@Test
public void testNamingRules_tldThatDoesNotExist_failsWithoutOverride() throws Exception {
runNameTestExpectedFailure("footld_reserved-list", "TLD footld does not exist");
}
@Test
public void testNamingRules_underscoreIsMissing_succeedsWithOverride() throws Exception {
runNameTestWithOverride("random-reserved-list");
}
@Test
public void testNamingRules_underscoreIsMissing_failsWithoutOverride() throws Exception {
runNameTestExpectedFailure("random-reserved-list", INVALID_FORMAT_ERROR_MESSAGE);
}
@Test
public void testNamingRules_secondHalfOfNameIsMissing_succeedsWithOverride() throws Exception {
runNameTestWithOverride("soy_");
}
@Test
public void testNamingRules_secondHalfOfNameIsMissing_failsWithoutOverride() throws Exception {
runNameTestExpectedFailure("soy_", INVALID_FORMAT_ERROR_MESSAGE);
}
@Test
public void testNamingRules_onlyTldIsSpecifiedAsName_succeedsWithOverride() throws Exception {
runNameTestWithOverride("soy");
}
@Test
public void testNamingRules_onlyTldIsSpecifiedAsName_failsWithoutOverride() throws Exception {
runNameTestExpectedFailure("soy", INVALID_FORMAT_ERROR_MESSAGE);
}
@Test
public void testNamingRules_commonAsListName_succeedsWithOverride() throws Exception {
runNameTestWithOverride("invalidtld_common");
}
@Test
public void testNamingRules_commonAsListName_failsWithoutOverride() throws Exception {
runNameTestExpectedFailure("invalidtld_common", "TLD invalidtld does not exist");
}
@Test
public void testNamingRules_too_many_underscores_succeedsWithOverride() throws Exception {
runNameTestWithOverride("soy_buffalo_buffalo_buffalo");
}
@Test
public void testNamingRules_too_many_underscores_failsWithoutOverride() throws Exception {
runNameTestExpectedFailure("soy_buffalo_buffalo_buffalo", INVALID_FORMAT_ERROR_MESSAGE);
}
@Test
public void testNamingRules_withWeirdCharacters_succeedsWithOverride() throws Exception {
runNameTestWithOverride("soy_$oy");
}
@Test
public void testNamingRules_withWeirdCharacters_failsWithoutOverride() throws Exception {
runNameTestExpectedFailure("soy_$oy", INVALID_FORMAT_ERROR_MESSAGE);
}
private void runNameTestExpectedFailure(String name, String expectedErrorMsg) throws Exception {
thrown.expect(IllegalArgumentException.class, expectedErrorMsg);
runCommandForced("--name=" + name, "--input=" + reservedTermsPath);
assertThat(ReservedList.get(name)).isAbsent();
}
private void runNameTestWithOverride(String name) throws Exception {
runCommandForced("--name=" + name, "--override", "--input=" + reservedTermsPath);
assertThat(ReservedList.get(name)).isPresent();
}
}

View file

@ -0,0 +1,388 @@
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.domain.registry.tools;
import static com.google.common.collect.Iterables.transform;
import static com.google.common.truth.Truth.assertThat;
import static com.google.domain.registry.model.registry.label.ReservedListTest.GET_NAME_FUNCTION;
import static com.google.domain.registry.testing.DatastoreHelper.createTld;
import static com.google.domain.registry.testing.DatastoreHelper.persistPremiumList;
import static com.google.domain.registry.testing.DatastoreHelper.persistReservedList;
import static com.google.domain.registry.util.DateTimeUtils.START_OF_TIME;
import static org.joda.money.CurrencyUnit.JPY;
import static org.joda.money.CurrencyUnit.USD;
import static org.joda.time.DateTimeZone.UTC;
import static org.joda.time.Duration.standardMinutes;
import com.google.common.collect.Range;
import com.google.domain.registry.model.registry.Registry;
import com.google.domain.registry.model.registry.Registry.TldState;
import com.beust.jcommander.ParameterException;
import org.joda.money.Money;
import org.joda.time.DateTime;
import org.junit.Before;
import org.junit.Test;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
/** Unit tests for {@link CreateTldCommand}. */
public class CreateTldCommandTest extends CommandTestCase<CreateTldCommand> {
@Before
public void init() {
persistReservedList("common_abuse", "baa,FULLY_BLOCKED");
persistReservedList("xn--q9jyb4c_abuse", "lamb,FULLY_BLOCKED");
persistReservedList("tld_banned", "kilo,FULLY_BLOCKED", "lima,MISTAKEN_PREMIUM");
persistReservedList("soy_expurgated", "fireflies,FULLY_BLOCKED");
persistPremiumList("xn--q9jyb4c", "minecraft,USD 1000");
}
@Test
public void testSuccess() throws Exception {
DateTime before = DateTime.now(UTC);
runCommandForced("xn--q9jyb4c", "--roid_suffix=Q9JYB4C");
DateTime after = DateTime.now(UTC);
Registry registry = Registry.get("xn--q9jyb4c");
assertThat(registry).isNotNull();
assertThat(registry.getTldState(registry.getCreationTime())).isEqualTo(TldState.PREDELEGATION);
assertThat(registry.getAddGracePeriodLength()).isEqualTo(Registry.DEFAULT_ADD_GRACE_PERIOD);
assertThat(registry.getRedemptionGracePeriodLength())
.isEqualTo(Registry.DEFAULT_REDEMPTION_GRACE_PERIOD);
assertThat(registry.getPendingDeleteLength()).isEqualTo(Registry.DEFAULT_PENDING_DELETE_LENGTH);
assertThat(registry.getCreationTime()).isIn(Range.closed(before, after));
}
@Test
public void testFailure_multipleArguments() throws Exception {
thrown.expect(IllegalArgumentException.class, "Can't create more than one TLD at a time");
runCommandForced("--roid_suffix=blah", "xn--q9jyb4c", "test");
}
@Test
public void testSuccess_initialTldStateFlag() throws Exception {
runCommandForced(
"--initial_tld_state=GENERAL_AVAILABILITY", "--roid_suffix=Q9JYB4C", "xn--q9jyb4c");
assertThat(Registry.get("xn--q9jyb4c").getTldState(DateTime.now(UTC)))
.isEqualTo(TldState.GENERAL_AVAILABILITY);
}
@Test
public void testSuccess_initialRenewBillingCostFlag() throws Exception {
runCommandForced(
"--initial_renew_billing_cost=\"USD 42.42\"", "--roid_suffix=Q9JYB4C", "xn--q9jyb4c");
assertThat(Registry.get("xn--q9jyb4c").getStandardRenewCost(DateTime.now(UTC)))
.isEqualTo(Money.of(USD, 42.42));
}
@Test
public void testSuccess_addGracePeriodFlag() throws Exception {
runCommandForced("--add_grace_period=PT300S", "--roid_suffix=Q9JYB4C", "xn--q9jyb4c");
assertThat(Registry.get("xn--q9jyb4c").getAddGracePeriodLength()).isEqualTo(standardMinutes(5));
}
@Test
public void testSuccess_roidSuffixWorks() throws Exception {
runCommandForced("--roid_suffix=RSUFFIX", "tld");
assertThat(Registry.get("tld").getRoidSuffix()).isEqualTo("RSUFFIX");
}
@Test
public void testSuccess_escrow() throws Exception {
runCommandForced("--escrow=true", "--roid_suffix=Q9JYB4C", "xn--q9jyb4c");
assertThat(Registry.get("xn--q9jyb4c").getEscrowEnabled()).isTrue();
}
@Test
public void testSuccess_noEscrow() throws Exception {
runCommandForced("--escrow=false", "--roid_suffix=Q9JYB4C", "xn--q9jyb4c");
assertThat(Registry.get("xn--q9jyb4c").getEscrowEnabled()).isFalse();
}
@Test
public void testSuccess_redemptionGracePeriodFlag() throws Exception {
runCommandForced("--redemption_grace_period=PT300S", "--roid_suffix=Q9JYB4C", "xn--q9jyb4c");
assertThat(Registry.get("xn--q9jyb4c").getRedemptionGracePeriodLength())
.isEqualTo(standardMinutes(5));
}
@Test
public void testSuccess_pendingDeleteLengthFlag() throws Exception {
runCommandForced("--pending_delete_length=PT300S", "--roid_suffix=Q9JYB4C", "xn--q9jyb4c");
assertThat(Registry.get("xn--q9jyb4c").getPendingDeleteLength()).isEqualTo(standardMinutes(5));
}
@Test
public void testSuccess_automaticTransferLengthFlag() throws Exception {
runCommandForced("--automatic_transfer_length=PT300S", "--roid_suffix=Q9JYB4C", "xn--q9jyb4c");
assertThat(Registry.get("xn--q9jyb4c").getAutomaticTransferLength())
.isEqualTo(standardMinutes(5));
}
@Test
public void testSuccess_createBillingCostFlag() throws Exception {
runCommandForced(
"--create_billing_cost=\"USD 42.42\"", "--roid_suffix=Q9JYB4C", "xn--q9jyb4c");
assertThat(Registry.get("xn--q9jyb4c").getStandardCreateCost()).isEqualTo(Money.of(USD, 42.42));
}
@Test
public void testSuccess_restoreBillingCostFlag() throws Exception {
runCommandForced(
"--restore_billing_cost=\"USD 42.42\"", "--roid_suffix=Q9JYB4C", "xn--q9jyb4c");
assertThat(Registry.get("xn--q9jyb4c").getStandardRestoreCost())
.isEqualTo(Money.of(USD, 42.42));
}
@Test
public void testSuccess_serverStatusChangeCostFlag() throws Exception {
runCommandForced(
"--server_status_change_cost=\"USD 42.42\"", "--roid_suffix=Q9JYB4C", "xn--q9jyb4c");
assertThat(Registry.get("xn--q9jyb4c").getServerStatusChangeCost())
.isEqualTo(Money.of(USD, 42.42));
}
@Test
public void testSuccess_nonUsdBillingCostFlag() throws Exception {
runCommandForced(
"--create_billing_cost=\"JPY 12345\"",
"--restore_billing_cost=\"JPY 67890\"",
"--initial_renew_billing_cost=\"JPY 101112\"",
"--server_status_change_cost=\"JPY 97865\"",
"--roid_suffix=Q9JYB4C",
"xn--q9jyb4c");
Registry registry = Registry.get("xn--q9jyb4c");
assertThat(registry.getStandardCreateCost()).isEqualTo(Money.ofMajor(JPY, 12345));
assertThat(registry.getStandardRestoreCost()).isEqualTo(Money.ofMajor(JPY, 67890));
assertThat(registry.getStandardRenewCost(START_OF_TIME)).isEqualTo(Money.ofMajor(JPY, 101112));
}
@Test
public void testSuccess_multipartTld() throws Exception {
runCommandForced("co.uk", "--roid_suffix=COUK");
Registry registry = Registry.get("co.uk");
assertThat(registry.getTldState(new DateTime())).isEqualTo(TldState.PREDELEGATION);
assertThat(registry.getAddGracePeriodLength()).isEqualTo(Registry.DEFAULT_ADD_GRACE_PERIOD);
assertThat(registry.getRedemptionGracePeriodLength())
.isEqualTo(Registry.DEFAULT_REDEMPTION_GRACE_PERIOD);
assertThat(registry.getPendingDeleteLength()).isEqualTo(Registry.DEFAULT_PENDING_DELETE_LENGTH);
}
@Test
public void testSuccess_setReservedLists() throws Exception {
runCommandForced(
"--reserved_lists=xn--q9jyb4c_abuse,common_abuse", "--roid_suffix=Q9JYB4C", "xn--q9jyb4c");
assertThat(transform(Registry.get("xn--q9jyb4c").getReservedLists(), GET_NAME_FUNCTION))
.containsExactly("xn--q9jyb4c_abuse", "common_abuse");
}
@Test
public void testSuccess_setPremiumPriceAckRequired() throws Exception {
runCommandForced("--premium_price_ack_required=true", "--roid_suffix=Q9JYB4C", "xn--q9jyb4c");
assertThat(Registry.get("xn--q9jyb4c").getPremiumPriceAckRequired()).isTrue();
}
@Test
public void testFailure_invalidAddGracePeriod() throws Exception {
thrown.expect(IllegalArgumentException.class);
runCommandForced("--add_grace_period=5m", "--roid_suffix=Q9JYB4C", "xn--q9jyb4c");
}
@Test
public void testFailure_invalidRedemptionGracePeriod() throws Exception {
thrown.expect(IllegalArgumentException.class);
runCommandForced("--redemption_grace_period=5m", "--roid_suffix=Q9JYB4C", "xn--q9jyb4c");
}
@Test
public void testFailure_invalidPendingDeleteLength() throws Exception {
thrown.expect(IllegalArgumentException.class);
runCommandForced("--pending_delete_length=5m", "--roid_suffix=Q9JYB4C", "xn--q9jyb4c");
}
@Test
public void testFailure_invalidTldState() throws Exception {
thrown.expect(ParameterException.class);
runCommandForced("--initial_tld_state=INVALID_STATE", "--roid_suffix=Q9JYB4C", "xn--q9jyb4c");
}
@Test
public void testFailure_negativeInitialRenewBillingCost() throws Exception {
thrown.expect(IllegalArgumentException.class);
runCommandForced(
"--initial_renew_billing_cost=USD -42", "--roid_suffix=Q9JYB4C", "xn--q9jyb4c");
}
@Test
public void testFailure_noTldName() throws Exception {
thrown.expect(ParameterException.class);
runCommandForced();
}
@Test
public void testFailure_duplicateArguments() throws Exception {
thrown.expect(IllegalArgumentException.class);
runCommandForced("foo", "xn--q9jyb4c", "xn--q9jyb4c");
}
@Test
public void testFailure_alreadyExists() throws Exception {
thrown.expect(IllegalStateException.class);
createTld("xn--q9jyb4c");
runCommandForced("--roid_suffix=NOTDUPE", "xn--q9jyb4c");
}
@Test
public void testFailure_tldStartsWithDigit() throws Exception {
thrown.expect(IllegalArgumentException.class);
runCommandForced("1foo", "--roid_suffix=1FOO");
}
@Test
public void testSuccess_setAllowedRegistrants() throws Exception {
runCommandForced("--allowed_registrants=alice,bob", "--roid_suffix=Q9JYB4C", "xn--q9jyb4c");
assertThat(Registry.get("xn--q9jyb4c").getAllowedRegistrantContactIds())
.containsExactly("alice", "bob");
}
@Test
public void testSuccess_setAllowedNameservers() throws Exception {
runCommandForced(
"--allowed_nameservers=ns1.example.com,ns2.example.com",
"--roid_suffix=Q9JYB4C",
"xn--q9jyb4c");
assertThat(Registry.get("xn--q9jyb4c").getAllowedFullyQualifiedHostNames())
.containsExactly("ns1.example.com", "ns2.example.com");
}
@Test
public void testSuccess_setCommonReservedListOnTld() throws Exception {
runSuccessfulReservedListsTest("common_abuse");
}
@Test
public void testSuccess_setTldSpecificReservedListOnTld() throws Exception {
runSuccessfulReservedListsTest("xn--q9jyb4c_abuse");
}
@Test
public void testSuccess_setCommonReservedListAndTldSpecificReservedListOnTld() throws Exception {
runSuccessfulReservedListsTest("common_abuse,xn--q9jyb4c_abuse");
}
@Test
public void testFailure_setReservedListFromOtherTld() throws Exception {
runFailureReservedListsTest("tld_banned",
IllegalArgumentException.class,
"The reserved list(s) tld_banned cannot be applied to the tld xn--q9jyb4c");
}
@Test
public void testSuccess_setReservedListFromOtherTld_withOverride() throws Exception {
runReservedListsTestOverride("tld_banned");
}
@Test
public void testFailure_setCommonAndReservedListFromOtherTld() throws Exception {
runFailureReservedListsTest("common_abuse,tld_banned",
IllegalArgumentException.class,
"The reserved list(s) tld_banned cannot be applied to the tld xn--q9jyb4c");
}
@Test
public void testSuccess_setCommonAndReservedListFromOtherTld_withOverride() throws Exception {
ByteArrayOutputStream errContent = new ByteArrayOutputStream();
System.setErr(new PrintStream(errContent));
runReservedListsTestOverride("common_abuse,tld_banned");
String errMsg =
"Error overriden: The reserved list(s) tld_banned cannot be applied to the tld xn--q9jyb4c";
assertThat(errContent.toString()).contains(errMsg);
System.setOut(null);
}
@Test
public void testFailure_setMultipleReservedListsFromOtherTld() throws Exception {
runFailureReservedListsTest("tld_banned,soy_expurgated",
IllegalArgumentException.class,
"The reserved list(s) tld_banned, soy_expurgated cannot be applied to the tld xn--q9jyb4c");
}
@Test
public void testSuccess_setMultipleReservedListsFromOtherTld_withOverride() throws Exception {
runReservedListsTestOverride("tld_banned,soy_expurgated");
}
@Test
public void testFailure_setNonExistentReservedLists() throws Exception {
runFailureReservedListsTest("xn--q9jyb4c_asdf,common_asdsdgh",
IllegalStateException.class,
"Could not find reserved list xn--q9jyb4c_asdf to add to the tld");
}
@Test
public void testSuccess_setPremiumList() throws Exception {
runCommandForced("--premium_list=xn--q9jyb4c", "--roid_suffix=Q9JYB4C", "xn--q9jyb4c");
assertThat(Registry.get("xn--q9jyb4c").getPremiumList().getName()).isEqualTo("xn--q9jyb4c");
}
@Test
public void testSuccess_setDriveFolderIdToValue() throws Exception {
runCommandForced("--drive_folder_id=madmax2030", "--roid_suffix=Q9JYB4C", "xn--q9jyb4c");
assertThat(Registry.get("xn--q9jyb4c").getDriveFolderId()).isEqualTo("madmax2030");
}
@Test
public void testSuccess_setDriveFolderIdToNull() throws Exception {
runCommandForced("--drive_folder_id=null", "--roid_suffix=Q9JYB4C", "xn--q9jyb4c");
assertThat(Registry.get("xn--q9jyb4c").getDriveFolderId()).isNull();
}
@Test
public void testFailure_setPremiumListThatDoesntExist() throws Exception {
thrown.expect(IllegalArgumentException.class, "The premium list 'phonies' doesn't exist");
runCommandForced("--premium_list=phonies", "--roid_suffix=Q9JYB4C", "xn--q9jyb4c");
}
@Test
public void testFailure_roidSuffixAlreadyInUse() throws Exception {
createTld("foo", "BLAH");
thrown.expect(IllegalArgumentException.class, "The roid suffix BLAH is already in use");
runCommandForced("--roid_suffix=BLAH", "randomtld");
}
private void runSuccessfulReservedListsTest(String reservedLists) throws Exception {
runCommandForced("--reserved_lists", reservedLists, "--roid_suffix=Q9JYB4C", "xn--q9jyb4c");
}
private void runReservedListsTestOverride(String reservedLists) throws Exception {
runCommandForced("--override_reserved_list_rules",
"--reserved_lists",
reservedLists,
"--roid_suffix=Q9JYB4C",
"xn--q9jyb4c");
}
private void runFailureReservedListsTest(
String reservedLists,
Class<? extends Exception> errorClass,
String errorMsg) throws Exception {
thrown.expect(errorClass, errorMsg);
runCommandForced("--reserved_lists", reservedLists, "--roid_suffix=Q9JYB4C", "xn--q9jyb4c");
}
}

View file

@ -0,0 +1,137 @@
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.domain.registry.tools;
import static com.google.common.truth.Truth.assertThat;
import static com.google.domain.registry.model.common.EntityGroupRoot.getCrossTldKey;
import static com.google.domain.registry.model.ofy.ObjectifyService.ofy;
import static com.google.domain.registry.testing.DatastoreHelper.createTld;
import static com.google.domain.registry.testing.DatastoreHelper.persistResource;
import static org.joda.money.CurrencyUnit.USD;
import com.google.domain.registry.model.billing.RegistrarCredit;
import com.google.domain.registry.model.billing.RegistrarCredit.CreditType;
import com.google.domain.registry.model.billing.RegistrarCreditBalance;
import com.google.domain.registry.model.registrar.Registrar;
import com.google.domain.registry.model.registry.Registry;
import com.beust.jcommander.ParameterException;
import com.googlecode.objectify.Key;
import org.joda.money.Money;
import org.joda.time.DateTime;
import org.junit.Before;
import org.junit.Test;
/** Unit tests for {@link DeleteCreditCommand}. */
public class DeleteCreditCommandTest extends CommandTestCase<DeleteCreditCommand> {
private Registrar registrar;
private RegistrarCredit creditA;
private RegistrarCredit creditB;
private RegistrarCreditBalance balanceA1;
private RegistrarCreditBalance balanceA2;
private RegistrarCreditBalance balanceB1;
private long creditAId;
private long creditBId;
@Before
public void setUp() {
registrar = Registrar.loadByClientId("TheRegistrar");
createTld("tld");
assertThat(Registry.get("tld").getCurrency()).isEqualTo(USD);
DateTime creditCreationTime = Registry.get("tld").getCreationTime().plusMillis(1);
creditA = persistResource(
new RegistrarCredit.Builder()
.setParent(registrar)
.setType(CreditType.PROMOTION)
.setTld("tld")
.setCurrency(USD)
.setCreationTime(creditCreationTime)
.build());
creditB = persistResource(
new RegistrarCredit.Builder()
.setParent(registrar)
.setType(CreditType.AUCTION)
.setTld("tld")
.setCurrency(USD)
.setCreationTime(creditCreationTime)
.build());
balanceA1 = persistResource(
new RegistrarCreditBalance.Builder()
.setParent(creditA)
.setEffectiveTime(DateTime.parse("2014-11-01T00:00:00Z"))
.setAmount(Money.of(USD, 100))
.setWrittenTime(creditCreationTime)
.build());
balanceA2 = persistResource(
new RegistrarCreditBalance.Builder()
.setParent(creditA)
.setEffectiveTime(DateTime.parse("2014-12-01T00:00:00Z"))
.setAmount(Money.of(USD, 50))
.setWrittenTime(creditCreationTime)
.build());
balanceB1 = persistResource(
new RegistrarCreditBalance.Builder()
.setParent(creditB)
.setEffectiveTime(DateTime.parse("2014-11-01T00:00:00Z"))
.setAmount(Money.of(USD, 42))
.setWrittenTime(creditCreationTime)
.build());
creditAId = Key.create(creditA).getId();
creditBId = Key.create(creditB).getId();
}
@Test
public void testSuccess() throws Exception {
assertThat(RegistrarCredit.loadAllForRegistrar(registrar)).containsAllOf(creditA, creditB);
assertThat(ofy().load().type(RegistrarCreditBalance.class).ancestor(getCrossTldKey()))
.containsAllOf(balanceA1, balanceA2, balanceB1);
runCommandForced("--registrar=TheRegistrar", "--credit_id=" + creditAId);
assertThat(RegistrarCredit.loadAllForRegistrar(registrar)).doesNotContain(creditA);
assertThat(RegistrarCredit.loadAllForRegistrar(registrar)).contains(creditB);
assertThat(ofy().load().type(RegistrarCreditBalance.class).ancestor(getCrossTldKey()))
.containsNoneOf(balanceA1, balanceA2);
assertThat(ofy().load().type(RegistrarCreditBalance.class).ancestor(getCrossTldKey()))
.contains(balanceB1);
}
@Test
public void testFailure_nonexistentParentRegistrar() throws Exception {
thrown.expect(NullPointerException.class, "FakeRegistrar");
runCommandForced("--registrar=FakeRegistrar", "--credit_id=" + creditAId);
}
@Test
public void testFailure_nonexistentCreditId() throws Exception {
long badId = creditAId + creditBId + 1;
thrown.expect(NullPointerException.class, "ID " + badId);
runCommandForced("--registrar=TheRegistrar", "--credit_id=" + badId);
}
@Test
public void testFailure_noRegistrar() throws Exception {
thrown.expect(ParameterException.class, "--registrar");
runCommandForced("--credit_id=" + creditAId);
}
@Test
public void testFailure_noCreditId() throws Exception {
thrown.expect(ParameterException.class, "--credit_id");
runCommandForced("--registrar=TheRegistrar");
}
}

View file

@ -0,0 +1,83 @@
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.domain.registry.tools;
import com.beust.jcommander.ParameterException;
import org.junit.Test;
/** Unit tests for {@link DeleteDomainCommand}. */
public class DeleteDomainCommandTest extends EppToolCommandTestCase<DeleteDomainCommand> {
@Test
public void testSuccess() throws Exception {
runCommand("--client=NewRegistrar", "--domain_name=example.tld", "--force",
"--reason=Test");
verifySent("testdata/domain_delete.xml", false, false);
}
@Test
public void testSuccess_multipleWordReason() throws Exception {
runCommand("--client=NewRegistrar", "--domain_name=example.tld", "--force",
"--reason=\"Test test\"");
verifySent("testdata/domain_delete_multiple_word_reason.xml", false, false);
}
@Test
public void testSuccess_requestedByRegistrarFalse() throws Exception {
runCommand("--client=NewRegistrar", "--domain_name=example.tld", "--force",
"--reason=Test", "--registrar_request=false");
verifySent("testdata/domain_delete.xml", false, false);
}
@Test
public void testSuccess_requestedByRegistrarTrue() throws Exception {
runCommand("--client=NewRegistrar", "--domain_name=example.tld", "--force",
"--reason=Test", "--registrar_request=true");
verifySent("testdata/domain_delete_by_registrar.xml", false, false);
}
@Test
public void testFailure_noReason() throws Exception {
thrown.expect(ParameterException.class);
runCommand("--client=NewRegistrar", "--domain_name=example.tld", "--force");
}
@Test
public void testFailure_missingClientId() throws Exception {
thrown.expect(ParameterException.class);
runCommand("--domain_name=example.tld", "--force", "--reason=Test");
}
@Test
public void testFailure_missingDomainName() throws Exception {
thrown.expect(ParameterException.class);
runCommand("--client=NewRegistrar", "--force", "--reason=Test");
}
@Test
public void testFailure_unknownFlag() throws Exception {
thrown.expect(ParameterException.class);
runCommand("--client=NewRegistrar", "--domain_name=example.tld",
"--force", "--reason=Test", "--foo");
}
@Test
public void testFailure_mainParameter() throws Exception {
thrown.expect(ParameterException.class);
runCommand("--client=NewRegistrar", "--domain_name=example.tld",
"--force", "--reason=Test", "foo");
}
}

View file

@ -0,0 +1,59 @@
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.domain.registry.tools;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyMap;
import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import com.google.common.collect.ImmutableMap;
import com.google.common.net.MediaType;
import com.google.domain.registry.tools.ServerSideCommand.Connection;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
/** Unit tests for {@link DeleteEntityCommand}. */
public class DeleteEntityCommandTest extends CommandTestCase<DeleteEntityCommand> {
@Mock
private Connection connection;
@Before
public void init() {
command.setConnection(connection);
}
@SuppressWarnings("unchecked")
@Test
public void test_deleteTwoEntities() throws Exception {
String firstKey = "alphaNumericKey1";
String secondKey = "alphaNumericKey2";
String rawKeys = String.format("%s,%s", firstKey, secondKey);
when(connection.send(anyString(), anyMap(), any(MediaType.class), any(byte[].class)))
.thenReturn("Deleted 1 raw entities and 1 registered entities.");
runCommandForced(firstKey, secondKey);
verify(connection).send(
eq("/_dr/admin/deleteEntity"),
eq(ImmutableMap.of("rawKeys", rawKeys)),
eq(MediaType.PLAIN_TEXT_UTF_8),
eq(new byte[0]));
assertInStdout("Deleted 1 raw entities and 1 registered entities.");
}
}

View file

@ -0,0 +1,64 @@
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.domain.registry.tools;
import static com.google.common.truth.Truth.assertThat;
import static com.google.domain.registry.model.ofy.ObjectifyService.ofy;
import static com.google.domain.registry.testing.DatastoreHelper.createTld;
import static com.google.domain.registry.testing.DatastoreHelper.persistPremiumList;
import static com.google.domain.registry.testing.DatastoreHelper.persistResource;
import com.google.domain.registry.model.registry.Registry;
import com.google.domain.registry.model.registry.label.PremiumList;
import com.google.domain.registry.model.registry.label.PremiumList.PremiumListEntry;
import org.junit.Test;
/** Unit tests for {@link DeletePremiumListCommand}. */
public class DeletePremiumListCommandTest extends CommandTestCase<DeletePremiumListCommand> {
@Test
public void testSuccess() throws Exception {
PremiumList premiumList = persistPremiumList("xn--q9jyb4c", "blah,USD 100");
assertThat(premiumList.getPremiumListEntries()).hasSize(1);
runCommand("--force", "--name=xn--q9jyb4c");
assertThat(PremiumList.get("xn--q9jyb4c")).isAbsent();
// Ensure that the Datastore premium list entry entities were deleted correctly.
assertThat(ofy().load()
.type(PremiumListEntry.class)
.ancestor(premiumList.getRevisionKey())
.keys())
.isEmpty();
}
@Test
public void testFailure_whenPremiumListDoesNotExist() throws Exception {
thrown.expect(IllegalArgumentException.class,
"Cannot delete the premium list foo because it doesn't exist.");
runCommandForced("--name=foo");
}
@Test
public void testFailure_whenPremiumListIsInUse() throws Exception {
PremiumList premiumList = persistPremiumList("xn--q9jyb4c", "blah,USD 100");
createTld("xn--q9jyb4c");
persistResource(Registry.get("xn--q9jyb4c").asBuilder().setPremiumList(premiumList).build());
thrown.expect(IllegalArgumentException.class,
"Cannot delete premium list because it is used on these tld(s): xn--q9jyb4c");
runCommandForced("--name=" + premiumList.getName());
assertThat(PremiumList.get(premiumList.getName())).isPresent();
}
}

View file

@ -0,0 +1,62 @@
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.domain.registry.tools;
import static com.google.common.truth.Truth.assertThat;
import static com.google.domain.registry.testing.DatastoreHelper.createTld;
import static com.google.domain.registry.testing.DatastoreHelper.persistReservedList;
import static com.google.domain.registry.testing.DatastoreHelper.persistResource;
import com.google.domain.registry.model.registry.Registry;
import com.google.domain.registry.model.registry.label.ReservedList;
import org.junit.Before;
import org.junit.Test;
/** Unit tests for {@link DeleteReservedListCommand}. */
public class DeleteReservedListCommandTest extends CommandTestCase<DeleteReservedListCommand> {
ReservedList reservedList;
@Before
public void init() {
reservedList = persistReservedList("common", "blah,FULLY_BLOCKED");
}
@Test
public void testSuccess() throws Exception {
assertThat(reservedList.getReservedListEntries()).hasSize(1);
runCommandForced("--name=common");
assertThat(ReservedList.get("common")).isAbsent();
}
@Test
public void testFailure_whenReservedListDoesNotExist() throws Exception {
String expectedError =
"Cannot delete the reserved list doesntExistReservedList because it doesn't exist.";
thrown.expect(IllegalArgumentException.class, expectedError);
runCommandForced("--name=doesntExistReservedList");
}
@Test
public void testFailure_whenReservedListIsInUse() throws Exception {
createTld("xn--q9jyb4c");
persistResource(Registry.get("xn--q9jyb4c").asBuilder().setReservedLists(reservedList).build());
thrown.expect(IllegalArgumentException.class,
"Cannot delete reserved list because it is used on these tld(s): xn--q9jyb4c");
runCommandForced("--name=" + reservedList.getName());
assertThat(ReservedList.get(reservedList.getName())).isPresent();
}
}

View file

@ -0,0 +1,79 @@
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.domain.registry.tools;
import com.beust.jcommander.ParameterException;
import org.junit.Test;
/** Unit tests for {@link DomainApplicationInfoCommand}. */
public class DomainApplicationInfoCommandTest
extends EppToolCommandTestCase<DomainApplicationInfoCommand> {
@Test
public void testSuccess() throws Exception {
runCommandForced("--client=NewRegistrar", "--domain_name=example.tld",
"--phase=landrush", "--id=123");
verifySent("testdata/domain_info_landrush.xml", false, false);
}
@Test
public void testSuccess_subphase() throws Exception {
// Sunrush: phase=sunrise, subphase=landrush
runCommandForced("--client=NewRegistrar", "--domain_name=example.tld",
"--phase=sunrush", "--id=123");
verifySent("testdata/domain_info_sunrush.xml", false, false);
}
@Test
public void testFailure_invalidPhase() throws Exception {
thrown.expect(IllegalArgumentException.class);
runCommandForced("--client=NewRegistrar", "--domain_name=example.tld",
"--phase=landrise", "--id=123");
}
@Test
public void testFailure_missingClientId() throws Exception {
thrown.expect(ParameterException.class);
runCommandForced("--domain_name=example.tld", "--phase=sunrush", "--id=123");
}
@Test
public void testFailure_missingPhase() throws Exception {
thrown.expect(ParameterException.class);
runCommandForced("--client=NewRegistrar", "--domain_name=example.tld", "--id=123");
}
@Test
public void testFailure_missingApplicationId() throws Exception {
thrown.expect(ParameterException.class);
runCommandForced("--client=NewRegistrar", "--domain_name=example.tld",
"--phase=landrush");
}
@Test
public void testFailure_mainParameter() throws Exception {
thrown.expect(ParameterException.class);
runCommandForced("--client=NewRegistrar", "--domain_name=example.tld",
"--phase=landrush", "--id=123", "foo");
}
@Test
public void testFailure_unknownFlag() throws Exception {
thrown.expect(ParameterException.class);
runCommandForced("--client=NewRegistrar", "--domain_name=example.tld",
"--phase=landrush", "--id=123", "--foo=bar");
}
}

View file

@ -0,0 +1,86 @@
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.domain.registry.tools;
import com.google.common.collect.ImmutableList;
import com.beust.jcommander.ParameterException;
import org.junit.Test;
/** Unit tests for {@link DomainCheckClaimsCommand}. */
public class DomainCheckClaimsCommandTest extends EppToolCommandTestCase<DomainCheckClaimsCommand> {
@Test
public void testSuccess() throws Exception {
runCommandForced("--client=NewRegistrar", "example.tld");
verifySent("testdata/domain_check_claims.xml", false, false);
}
@Test
public void testSuccess_multipleTlds() throws Exception {
runCommandForced("--client=NewRegistrar", "example.tld", "example.tld2");
verifySent(
ImmutableList.of(
"testdata/domain_check_claims.xml",
"testdata/domain_check_claims_second_tld.xml"),
false,
false);
}
@Test
public void testSuccess_multipleDomains() throws Exception {
runCommandForced(
"--client=NewRegistrar",
"example.tld",
"example2.tld",
"example3.tld");
verifySent("testdata/domain_check_claims_multiple.xml", false, false);
}
@Test
public void testSuccess_multipleDomainsAndTlds() throws Exception {
runCommandForced(
"--client=NewRegistrar",
"example.tld",
"example2.tld",
"example3.tld",
"example.tld2");
verifySent(
ImmutableList.of(
"testdata/domain_check_claims_multiple.xml",
"testdata/domain_check_claims_second_tld.xml"),
false,
false);
}
@Test
public void testFailure_missingClientId() throws Exception {
thrown.expect(ParameterException.class);
runCommandForced("example.tld");
}
@Test
public void testFailure_NoMainParameter() throws Exception {
thrown.expect(ParameterException.class);
runCommandForced("--client=NewRegistrar");
}
@Test
public void testFailure_unknownFlag() throws Exception {
thrown.expect(ParameterException.class);
runCommandForced("--client=NewRegistrar", "--unrecognized=foo", "example.tld");
}
}

View file

@ -0,0 +1,86 @@
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.domain.registry.tools;
import com.google.common.collect.ImmutableList;
import com.beust.jcommander.ParameterException;
import org.junit.Test;
/** Unit tests for {@link DomainCheckCommand}. */
public class DomainCheckCommandTest extends EppToolCommandTestCase<DomainCheckCommand> {
@Test
public void testSuccess() throws Exception {
runCommandForced("--client=NewRegistrar", "example.tld");
verifySent("testdata/domain_check.xml", false, false);
}
@Test
public void testSuccess_multipleTlds() throws Exception {
runCommandForced("--client=NewRegistrar", "example.tld", "example.tld2");
verifySent(
ImmutableList.of(
"testdata/domain_check.xml",
"testdata/domain_check_second_tld.xml"),
false,
false);
}
@Test
public void testSuccess_multipleDomains() throws Exception {
runCommandForced(
"--client=NewRegistrar",
"example.tld",
"example2.tld",
"example3.tld");
verifySent("testdata/domain_check_multiple.xml", false, false);
}
@Test
public void testSuccess_multipleDomainsAndTlds() throws Exception {
runCommandForced(
"--client=NewRegistrar",
"example.tld",
"example2.tld",
"example3.tld",
"example.tld2");
verifySent(
ImmutableList.of(
"testdata/domain_check_multiple.xml",
"testdata/domain_check_second_tld.xml"),
false,
false);
}
@Test
public void testFailure_missingClientId() throws Exception {
thrown.expect(ParameterException.class);
runCommandForced("example.tld");
}
@Test
public void testFailure_NoMainParameter() throws Exception {
thrown.expect(ParameterException.class);
runCommandForced("--client=NewRegistrar");
}
@Test
public void testFailure_unknownFlag() throws Exception {
thrown.expect(ParameterException.class);
runCommandForced("--client=NewRegistrar", "--unrecognized=foo", "example.tld");
}
}

View file

@ -0,0 +1,86 @@
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.domain.registry.tools;
import com.google.common.collect.ImmutableList;
import com.beust.jcommander.ParameterException;
import org.junit.Test;
/** Unit tests for {@link DomainCheckFeeCommand}. */
public class DomainCheckFeeCommandTest extends EppToolCommandTestCase<DomainCheckFeeCommand> {
@Test
public void testSuccess() throws Exception {
runCommandForced("--client=NewRegistrar", "example.tld");
verifySent("testdata/domain_check_fee.xml", false, false);
}
@Test
public void testSuccess_multipleTlds() throws Exception {
runCommandForced("--client=NewRegistrar", "example.tld", "example.tld2");
verifySent(
ImmutableList.of(
"testdata/domain_check_fee.xml",
"testdata/domain_check_fee_second_tld.xml"),
false,
false);
}
@Test
public void testSuccess_multipleDomains() throws Exception {
runCommandForced(
"--client=NewRegistrar",
"example.tld",
"example2.tld",
"example3.tld");
verifySent("testdata/domain_check_fee_multiple.xml", false, false);
}
@Test
public void testSuccess_multipleDomainsAndTlds() throws Exception {
runCommandForced(
"--client=NewRegistrar",
"example.tld",
"example2.tld",
"example3.tld",
"example.tld2");
verifySent(
ImmutableList.of(
"testdata/domain_check_fee_multiple.xml",
"testdata/domain_check_fee_second_tld.xml"),
false,
false);
}
@Test
public void testFailure_missingClientId() throws Exception {
thrown.expect(ParameterException.class);
runCommandForced("example.tld");
}
@Test
public void testFailure_NoMainParameter() throws Exception {
thrown.expect(ParameterException.class);
runCommandForced("--client=NewRegistrar");
}
@Test
public void testFailure_unknownFlag() throws Exception {
thrown.expect(ParameterException.class);
runCommandForced("--client=NewRegistrar", "--unrecognized=foo", "example.tld");
}
}

View file

@ -0,0 +1,79 @@
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.domain.registry.tools;
import static com.google.common.truth.Truth.assertThat;
import static com.google.domain.registry.util.ResourceUtils.readResourceBytes;
import com.google.common.io.ByteSource;
import com.google.common.io.Files;
import com.google.domain.registry.rde.RdeKeyringModule;
import com.google.domain.registry.rde.RdeTestData;
import com.google.domain.registry.rde.RydePgpCompressionOutputStreamFactory;
import com.google.domain.registry.rde.RydePgpEncryptionOutputStreamFactory;
import com.google.domain.registry.rde.RydePgpFileOutputStreamFactory;
import com.google.domain.registry.rde.RydePgpSigningOutputStreamFactory;
import com.google.domain.registry.rde.RydeTarOutputStreamFactory;
import com.google.domain.registry.testing.BouncyCastleProviderRule;
import com.google.domain.registry.testing.Providers;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import java.io.File;
/** Unit tests for {@link EncryptEscrowDepositCommand}. */
public class EncryptEscrowDepositCommandTest
extends CommandTestCase<EncryptEscrowDepositCommand> {
@Rule
public final BouncyCastleProviderRule bouncy = new BouncyCastleProviderRule();
private final ByteSource depositXml =
readResourceBytes(RdeTestData.class, "testdata/deposit_full.xml");
static EscrowDepositEncryptor createEncryptor() {
EscrowDepositEncryptor res = new EscrowDepositEncryptor();
res.pgpCompressionFactory = new RydePgpCompressionOutputStreamFactory(Providers.of(1024));
res.pgpEncryptionFactory = new RydePgpEncryptionOutputStreamFactory(Providers.of(1024));
res.pgpFileFactory = new RydePgpFileOutputStreamFactory(Providers.of(1024));
res.pgpSigningFactory = new RydePgpSigningOutputStreamFactory();
res.tarFactory = new RydeTarOutputStreamFactory();
res.rdeReceiverKey = new RdeKeyringModule().get().getRdeReceiverKey();
res.rdeSigningKey = new RdeKeyringModule().get().getRdeSigningKey();
return res;
}
@Before
public void before() throws Exception {
command.encryptor = createEncryptor();
}
@Test
public void testSuccess() throws Exception {
File outDir = tmpDir.newFolder();
File depositFile = tmpDir.newFile("deposit.xml");
Files.write(depositXml.read(), depositFile);
runCommand(
"--tld=lol",
"--input=" + depositFile.getPath(),
"--outdir=" + outDir.getPath());
assertThat(outDir.list()).asList().containsExactly(
"lol_2010-10-17_full_S1_R0.ryde",
"lol_2010-10-17_full_S1_R0.sig",
"lol.pub");
}
}

View file

@ -0,0 +1,87 @@
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.domain.registry.tools;
import static com.google.domain.registry.flows.EppServletUtils.APPLICATION_EPP_XML_UTF8;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.verify;
import com.google.common.collect.ImmutableMap;
import com.beust.jcommander.Parameter;
import com.beust.jcommander.Parameters;
import org.junit.Test;
import java.util.List;
/** Unit tests for {@link EppToolCommand}. */
public class EppToolCommandTest extends EppToolCommandTestCase<EppToolCommand> {
/** Dummy implementation of EppToolCommand. */
@Parameters(separators = " =", commandDescription = "Dummy EppToolCommand")
static class TestEppToolCommand extends EppToolCommand {
@Parameter(names = {"--client"})
String clientId;
@Parameter
List<String> xmlPayloads;
@Override
void initEppToolCommand() throws Exception {
for (String xmlData : xmlPayloads) {
addXmlCommand(clientId, xmlData);
}
}
}
@Override
protected EppToolCommand newCommandInstance() {
return new TestEppToolCommand();
}
@Test
public void testSuccess_singleXmlCommand() throws Exception {
runCommandForced("--client=NewRegistrar", "xml");
ImmutableMap<String, Object> params = ImmutableMap.<String, Object>of(
"clientIdentifier", "NewRegistrar",
"superuser", false,
"dryRun", false);
verify(connection)
.send(eq("/_dr/epptool"), eq(params), eq(APPLICATION_EPP_XML_UTF8), eq("xml".getBytes()));
}
@Test
public void testSuccess_multipleXmlCommands() throws Exception {
runCommandForced("--client=NewRegistrar", "one", "two", "three");
ImmutableMap<String, Object> params = ImmutableMap.<String, Object>of(
"clientIdentifier", "NewRegistrar",
"superuser", false,
"dryRun", false);
verify(connection)
.send(eq("/_dr/epptool"), eq(params), eq(APPLICATION_EPP_XML_UTF8), eq("one".getBytes()));
verify(connection)
.send(eq("/_dr/epptool"), eq(params), eq(APPLICATION_EPP_XML_UTF8), eq("two".getBytes()));
verify(connection)
.send(eq("/_dr/epptool"), eq(params), eq(APPLICATION_EPP_XML_UTF8), eq("three".getBytes()));
}
@Test
public void testFailure_nonexistentClientId() throws Exception {
thrown.expect(IllegalArgumentException.class, "fakeclient");
runCommandForced("--client=fakeclient", "fake-xml");
}
}

View file

@ -0,0 +1,91 @@
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.domain.registry.tools;
import static com.google.common.truth.Truth.assertThat;
import static com.google.domain.registry.flows.EppServletUtils.APPLICATION_EPP_XML_UTF8;
import static com.google.domain.registry.testing.DatastoreHelper.createTlds;
import static com.google.domain.registry.util.ResourceUtils.readResourceUtf8;
import static com.google.domain.registry.xml.XmlTestUtils.assertXmlEquals;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import com.google.common.collect.ImmutableMap;
import com.google.domain.registry.testing.InjectRule;
import com.google.domain.registry.tools.ServerSideCommand.Connection;
import org.junit.Before;
import org.junit.Rule;
import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
import org.mockito.Mock;
import java.util.List;
/**
* Abstract class for commands that construct + send EPP commands.
*
* @param <C> the command type
*/
public abstract class EppToolCommandTestCase<C extends EppToolCommand> extends CommandTestCase<C> {
@Rule
public InjectRule inject = new InjectRule();
@Mock
Connection connection;
@Captor
ArgumentCaptor<byte[]> xml;
@Before
public void init() throws Exception {
// Create two TLDs for commands that allow multiple TLDs at once.
createTlds("tld", "tld2");
command.setConnection(connection);
initEppToolCommandTestCase();
}
/** Subclasses can override this to perform additional initialization. */
void initEppToolCommandTestCase() throws Exception {}
void verifySent(String fileToMatch, boolean dryRun, boolean superuser) throws Exception {
ImmutableMap<String, ?> params = ImmutableMap.of(
"clientIdentifier", "NewRegistrar",
"superuser", superuser,
"dryRun", dryRun);
verify(connection)
.send(eq("/_dr/epptool"), eq(params), eq(APPLICATION_EPP_XML_UTF8), xml.capture());
assertXmlEquals(readResourceUtf8(getClass(), fileToMatch), new String(xml.getValue(), UTF_8));
}
void verifySent(List<String> filesToMatch, boolean dryRun, boolean superuser) throws Exception {
ImmutableMap<String, ?> params = ImmutableMap.of(
"clientIdentifier", "NewRegistrar",
"superuser", superuser,
"dryRun", dryRun);
verify(connection, times(filesToMatch.size()))
.send(eq("/_dr/epptool"), eq(params), eq(APPLICATION_EPP_XML_UTF8), xml.capture());
List<byte[]> capturedXml = xml.getAllValues();
assertThat(filesToMatch).hasSize(capturedXml.size());
for (String fileToMatch : filesToMatch) {
assertXmlEquals(
readResourceUtf8(getClass(), fileToMatch),
new String(capturedXml.get(filesToMatch.indexOf(fileToMatch)), UTF_8));
}
}
}

View file

@ -0,0 +1,94 @@
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.domain.registry.tools;
import static com.google.domain.registry.util.ResourceUtils.readResourceUtf8;
import static java.nio.charset.StandardCharsets.UTF_8;
import com.google.common.collect.ImmutableList;
import com.beust.jcommander.ParameterException;
import org.junit.Test;
import java.io.ByteArrayInputStream;
/** Unit tests for {@link ExecuteEppCommand}. */
public class ExecuteEppCommandTest extends EppToolCommandTestCase<ExecuteEppCommand> {
private String xmlInput;
private String eppFile;
@Override
void initEppToolCommandTestCase() throws Exception {
xmlInput = readResourceUtf8(ExecuteEppCommandTest.class, "testdata/contact_create.xml");
eppFile = writeToNamedTmpFile("eppFile", xmlInput);
}
@Test
public void testSuccess() throws Exception {
runCommand("--client=NewRegistrar", "--force", eppFile);
verifySent("testdata/contact_create.xml", false, false);
}
@Test
public void testSuccess_dryRun() throws Exception {
runCommand("--client=NewRegistrar", "--dry_run", eppFile);
verifySent("testdata/contact_create.xml", true, false);
}
@Test
public void testSuccess_withSuperuser() throws Exception {
runCommand("--client=NewRegistrar", "--superuser", "--force", eppFile);
verifySent("testdata/contact_create.xml", false, true);
}
@Test
public void testSuccess_fromStdin() throws Exception {
inject.setStaticField(
ExecuteEppCommand.class, "stdin", new ByteArrayInputStream(xmlInput.getBytes(UTF_8)));
runCommand("--client=NewRegistrar", "--force");
verifySent("testdata/contact_create.xml", false, false);
}
@Test
public void testSuccess_multipleFiles() throws Exception {
String xmlInput2 = readResourceUtf8(ExecuteEppCommandTest.class, "testdata/domain_check.xml");
String eppFile2 = writeToNamedTmpFile("eppFile2", xmlInput2);
runCommand("--client=NewRegistrar", "--force", eppFile, eppFile2);
verifySent(
ImmutableList.of("testdata/contact_create.xml", "testdata/domain_check.xml"),
false,
false);
}
@Test
public void testFailure_missingClientId() throws Exception {
thrown.expect(ParameterException.class);
runCommand("--force", "foo.xml");
}
@Test
public void testFailure_forceAndDryRunIncompatible() throws Exception {
thrown.expect(IllegalArgumentException.class);
runCommand("--client=NewRegistrar", "--force", "--dry_run", eppFile);
}
@Test
public void testFailure_unknownFlag() throws Exception {
thrown.expect(ParameterException.class);
runCommand("--client=NewRegistrar", "--unrecognized=foo", "--force", "foo.xml");
}
}

View file

@ -0,0 +1,45 @@
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.domain.registry.tools;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Strings.isNullOrEmpty;
import static com.google.common.collect.Lists.charactersOf;
import com.google.common.collect.Iterators;
import java.util.Iterator;
/** A password generator that produces a password from a predefined string. */
class FakePasswordGenerator implements PasswordGenerator {
private Iterator<Character> iterator;
/** Produces a password from the password source string. */
@Override
public String createPassword(int length) {
checkArgument(length > 0, "Password length must be positive.");
String password = "";
for (int i = 0; i < length; i++) {
password += iterator.next();
}
return password;
}
public FakePasswordGenerator(String passwordSource) {
checkArgument(!isNullOrEmpty(passwordSource), "Password source cannot be null or empty.");
iterator = Iterators.cycle(charactersOf(passwordSource));
}
}

View file

@ -0,0 +1,341 @@
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.domain.registry.tools;
import static com.google.common.truth.Truth.assertThat;
import static com.google.domain.registry.testing.DatastoreHelper.createTld;
import static com.google.domain.registry.testing.DatastoreHelper.newContactResourceWithRoid;
import static com.google.domain.registry.testing.DatastoreHelper.newDomainApplication;
import static com.google.domain.registry.testing.DatastoreHelper.newSunriseApplication;
import static com.google.domain.registry.testing.DatastoreHelper.persistResource;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.joda.time.DateTimeZone.UTC;
import com.google.common.base.Joiner;
import com.google.common.collect.ImmutableList;
import com.google.domain.registry.model.contact.ContactAddress;
import com.google.domain.registry.model.contact.ContactPhoneNumber;
import com.google.domain.registry.model.contact.ContactResource;
import com.google.domain.registry.model.contact.PostalInfo;
import com.google.domain.registry.model.domain.launch.ApplicationStatus;
import com.google.domain.registry.model.ofy.Ofy;
import com.google.domain.registry.testing.FakeClock;
import com.google.domain.registry.testing.InjectRule;
import com.beust.jcommander.ParameterException;
import org.joda.time.DateTime;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
/** Unit tests for {@link GenerateAuctionDataCommand}. */
public class GenerateAuctionDataCommandTest extends CommandTestCase<GenerateAuctionDataCommand> {
@Rule
public final TemporaryFolder folder = new TemporaryFolder();
@Rule
public final InjectRule inject = new InjectRule();
FakeClock clock = new FakeClock(DateTime.parse("2000-01-01TZ"));
Path output;
ContactResource contact1;
ContactResource contact2;
String getOutput() throws IOException {
return new String(Files.readAllBytes(output), UTF_8).trim();
}
@Before
public void init() throws Exception {
inject.setStaticField(Ofy.class, "clock", clock);
output = Paths.get(folder.newFile().toString());
createTld("xn--q9jyb4c");
contact1 = persistResource(
newContactResourceWithRoid("contact1", "C1-ROID").asBuilder()
.setLocalizedPostalInfo(new PostalInfo.Builder()
.setType(PostalInfo.Type.LOCALIZED)
.setName("Joe Registrant")
.setOrg("Google")
.setAddress(new ContactAddress.Builder()
.setStreet(ImmutableList.of("111 8th Ave", "4th Floor", "Suite 100"))
.setCity("New York")
.setState("NY")
.setZip("10011")
.setCountryCode("US")
.build())
.build())
.setVoiceNumber(new ContactPhoneNumber.Builder()
.setPhoneNumber("867-5000")
.setExtension("0000")
.build())
.setFaxNumber(new ContactPhoneNumber.Builder()
.setPhoneNumber("867-5000")
.setExtension("0001")
.build())
.setEmailAddress("joe.registrant@example.com")
.build());
contact2 = persistResource(
newContactResourceWithRoid("contact1", "C2-ROID").asBuilder()
.setLocalizedPostalInfo(new PostalInfo.Builder()
.setType(PostalInfo.Type.LOCALIZED)
.setName("Jáne Registrant")
.setOrg("Charleston Road Registry")
.setAddress(new ContactAddress.Builder()
.setStreet(ImmutableList.of("1600 Charleston Road"))
.setCity("Mountain View")
.setState("CA")
.setZip("94043")
.setCountryCode("US")
.build())
.build())
.setInternationalizedPostalInfo(new PostalInfo.Builder()
.setType(PostalInfo.Type.INTERNATIONALIZED)
.setName("Jane Registrant")
.setOrg("Charleston Road Registry")
.setAddress(new ContactAddress.Builder()
.setStreet(ImmutableList.of("1600 Charleston Road"))
.setCity("Mountain View")
.setState("CA")
.setZip("94043")
.setCountryCode("US")
.build())
.build())
.setVoiceNumber(new ContactPhoneNumber.Builder()
.setPhoneNumber("555-1234")
.setExtension("0000")
.build())
.setFaxNumber(new ContactPhoneNumber.Builder()
.setPhoneNumber("555-1235")
.setExtension("0001")
.build())
.setEmailAddress("jane.registrant@example.com")
.build());
}
@Test
public void testSuccess_emptyOutput() throws Exception {
runCommand("--output=" + output, "xn--q9jyb4c");
assertThat(getOutput()).isEmpty();
}
@Test
public void testSuccess_nullApplicationFields() throws Exception {
// Make two contacts with different email addresses.
ContactResource contact = persistResource(
newContactResourceWithRoid("contact1234", "C1234-ROID")
.asBuilder()
.setEmailAddress("foo@bar.baz")
.build());
ContactResource otherContact = persistResource(
newContactResourceWithRoid("contact5678", "C5678-ROID")
.asBuilder()
.setEmailAddress("bar@baz.foo")
.build());
persistResource(newDomainApplication("label.xn--q9jyb4c", contact));
persistResource(newDomainApplication("label.xn--q9jyb4c", otherContact));
runCommand("--output=" + output, "xn--q9jyb4c");
assertThat(getOutput()).isEqualTo(Joiner.on('\n').join(ImmutableList.of(
"label.xn--q9jyb4c|2-Q9JYB4C|2000-01-01 00:00:00||TheRegistrar|||||||||foo@bar.baz"
+ "|||Landrush",
"label.xn--q9jyb4c|3-Q9JYB4C|2000-01-01 00:00:00||TheRegistrar|||||||||bar@baz.foo"
+ "|||Landrush",
"TheRegistrar|John Doe|The Registrar|123 Example Bőulevard||Williamsburg|NY|"
+ "11211|US|new.registrar@example.com|+1.2223334444")));
}
@Test
public void testSuccess_multipleRegistrars() throws Exception {
persistResource(newDomainApplication("label.xn--q9jyb4c", contact1));
persistResource(newDomainApplication("label.xn--q9jyb4c", contact2)
.asBuilder()
.setCurrentSponsorClientId("NewRegistrar")
.build());
runCommand("--output=" + output, "xn--q9jyb4c");
assertThat(getOutput()).isEqualTo(Joiner.on('\n').join(ImmutableList.of(
"label.xn--q9jyb4c|2-Q9JYB4C|2000-01-01 00:00:00||TheRegistrar|Joe Registrant|Google|"
+ "111 8th Ave|4th Floor Suite 100|New York|NY|10011|US|joe.registrant@example.com|"
+ "867-5000 x0000||Landrush",
"label.xn--q9jyb4c|3-Q9JYB4C|2000-01-01 00:00:00||NewRegistrar|Jane Registrant|"
+ "Charleston Road Registry|1600 Charleston Road||Mountain View|CA|94043|US|"
+ "jane.registrant@example.com|555-1234 x0000||Landrush",
"NewRegistrar|Jane Doe|New Registrar|123 Example Bőulevard||Williamsburg|NY|"
+ "11211|US|new.registrar@example.com|+1.3334445555",
"TheRegistrar|John Doe|The Registrar|123 Example Bőulevard||Williamsburg|NY|"
+ "11211|US|new.registrar@example.com|+1.2223334444")));
}
@Test
public void testSuccess_allFieldsPopulated() throws Exception {
persistResource(newDomainApplication("label.xn--q9jyb4c", contact1)
.asBuilder()
.setLastEppUpdateTime(DateTime.parse("2006-06-06T00:30:00Z"))
.build());
persistResource(newDomainApplication("label.xn--q9jyb4c", contact2)
.asBuilder()
.setLastEppUpdateTime(DateTime.parse("2006-06-07T00:30:00Z"))
.build());
runCommand("--output=" + output, "xn--q9jyb4c");
assertThat(getOutput()).isEqualTo(Joiner.on('\n').join(ImmutableList.of(
"label.xn--q9jyb4c|2-Q9JYB4C|2000-01-01 00:00:00|2006-06-06 00:30:00|TheRegistrar|"
+ "Joe Registrant|Google|111 8th Ave|4th Floor Suite 100|New York|NY|10011|US|"
+ "joe.registrant@example.com|867-5000 x0000||Landrush",
"label.xn--q9jyb4c|3-Q9JYB4C|2000-01-01 00:00:00|2006-06-07 00:30:00|TheRegistrar|"
+ "Jane Registrant|Charleston Road Registry|1600 Charleston Road||Mountain View|CA|"
+ "94043|US|jane.registrant@example.com|555-1234 x0000||Landrush",
"TheRegistrar|John Doe|The Registrar|123 Example Bőulevard||Williamsburg|NY|"
+ "11211|US|new.registrar@example.com|+1.2223334444")));
}
@Test
public void testSuccess_multipleSunriseMultipleLandrushApplications() throws Exception {
persistResource(newDomainApplication("label.xn--q9jyb4c", contact1)
.asBuilder()
.setLastEppUpdateTime(DateTime.parse("2006-06-07T00:30:00Z"))
.build());
persistResource(newDomainApplication("label.xn--q9jyb4c", contact2)
.asBuilder()
.setLastEppUpdateTime(DateTime.parse("2006-06-08T00:30:00Z"))
.build());
persistResource(newSunriseApplication("label.xn--q9jyb4c", contact1)
.asBuilder()
.setLastEppUpdateTime(DateTime.parse("2006-06-09T00:30:00Z"))
.build());
persistResource(newSunriseApplication("label.xn--q9jyb4c", contact2)
.asBuilder()
.setLastEppUpdateTime(DateTime.parse("2006-06-10T00:30:00Z"))
.build());
runCommand("--output=" + output, "xn--q9jyb4c");
assertThat(getOutput()).isEqualTo(Joiner.on('\n').join(ImmutableList.of(
"label.xn--q9jyb4c|4-Q9JYB4C|2000-01-01 00:00:00|2006-06-09 00:30:00|TheRegistrar|"
+ "Joe Registrant|Google|111 8th Ave|4th Floor Suite 100|New York|NY|10011|US|"
+ "joe.registrant@example.com|867-5000 x0000||Sunrise",
"label.xn--q9jyb4c|5-Q9JYB4C|2000-01-01 00:00:00|2006-06-10 00:30:00|TheRegistrar|"
+ "Jane Registrant|Charleston Road Registry|1600 Charleston Road||Mountain View|CA|"
+ "94043|US|jane.registrant@example.com|555-1234 x0000||Sunrise",
"TheRegistrar|John Doe|The Registrar|123 Example Bőulevard||Williamsburg|NY|"
+ "11211|US|new.registrar@example.com|+1.2223334444")));
}
@Test
public void testSuccess_multipleLabels() throws Exception {
persistResource(newDomainApplication("label.xn--q9jyb4c", contact1)
.asBuilder()
.setLastEppUpdateTime(DateTime.parse("2006-06-06T00:30:00Z"))
.build());
persistResource(newDomainApplication("label.xn--q9jyb4c", contact2)
.asBuilder()
.setLastEppUpdateTime(DateTime.parse("2006-06-07T00:30:00Z"))
.build());
persistResource(newSunriseApplication("label2.xn--q9jyb4c", contact1)
.asBuilder()
.setLastEppUpdateTime(DateTime.parse("2006-06-09T00:30:00Z"))
.build());
persistResource(newSunriseApplication("label2.xn--q9jyb4c", contact2)
.asBuilder()
.setLastEppUpdateTime(DateTime.parse("2006-06-10T00:30:00Z"))
.build());
runCommand("--output=" + output, "xn--q9jyb4c");
assertThat(getOutput()).isEqualTo(Joiner.on('\n').join(ImmutableList.of(
"label.xn--q9jyb4c|2-Q9JYB4C|2000-01-01 00:00:00|2006-06-06 00:30:00|TheRegistrar|"
+ "Joe Registrant|Google|111 8th Ave|4th Floor Suite 100|New York|NY|10011|US|"
+ "joe.registrant@example.com|867-5000 x0000||Landrush",
"label.xn--q9jyb4c|3-Q9JYB4C|2000-01-01 00:00:00|2006-06-07 00:30:00|TheRegistrar|"
+ "Jane Registrant|Charleston Road Registry|1600 Charleston Road||Mountain View|CA|"
+ "94043|US|jane.registrant@example.com|555-1234 x0000||Landrush",
"label2.xn--q9jyb4c|4-Q9JYB4C|2000-01-01 00:00:00|2006-06-09 00:30:00|TheRegistrar|"
+ "Joe Registrant|Google|111 8th Ave|4th Floor Suite 100|New York|NY|10011|US|"
+ "joe.registrant@example.com|867-5000 x0000||Sunrise",
"label2.xn--q9jyb4c|5-Q9JYB4C|2000-01-01 00:00:00|2006-06-10 00:30:00|TheRegistrar|"
+ "Jane Registrant|Charleston Road Registry|1600 Charleston Road||Mountain View|CA|"
+ "94043|US|jane.registrant@example.com|555-1234 x0000||Sunrise",
"TheRegistrar|John Doe|The Registrar|123 Example Bőulevard||Williamsburg|NY|"
+ "11211|US|new.registrar@example.com|+1.2223334444")));
}
@Test
public void testSuccess_oneSunriseApplication() throws Exception {
persistResource(newSunriseApplication("label.xn--q9jyb4c"));
runCommand("--output=" + output, "xn--q9jyb4c");
assertThat(getOutput()).isEmpty();
}
@Test
public void testSuccess_twoSunriseApplicationsOneRejected() throws Exception {
persistResource(newSunriseApplication("label.xn--q9jyb4c"));
persistResource(newSunriseApplication("label.xn--q9jyb4c")
.asBuilder()
.setApplicationStatus(ApplicationStatus.REJECTED)
.build());
runCommand("--output=" + output, "xn--q9jyb4c");
assertThat(getOutput()).isEmpty();
}
@Test
public void testSuccess_twoSunriseApplicationsOneDeleted() throws Exception {
persistResource(newSunriseApplication("label.xn--q9jyb4c"));
DateTime deletionTime = DateTime.now(UTC);
persistResource(newSunriseApplication("label.xn--q9jyb4c")
.asBuilder()
.setDeletionTime(deletionTime)
.build());
clock.setTo(deletionTime);
runCommand("--output=" + output, "xn--q9jyb4c");
assertThat(getOutput()).isEmpty();
}
@Test
public void testSuccess_oneLandrushApplication() throws Exception {
persistResource(newDomainApplication("label.xn--q9jyb4c"));
runCommand("--output=" + output, "xn--q9jyb4c");
assertThat(getOutput()).isEmpty();
}
@Test
public void testSuccess_oneSunriseApplicationMultipleLandrushApplications() throws Exception {
persistResource(newSunriseApplication("label.xn--q9jyb4c"));
persistResource(newDomainApplication("label.xn--q9jyb4c"));
persistResource(newDomainApplication("label.xn--q9jyb4c"));
runCommand("--output=" + output, "xn--q9jyb4c");
assertThat(getOutput()).isEmpty();
}
@Test
public void testFailure_missingTldName() throws Exception {
thrown.expect(ParameterException.class);
runCommand();
}
@Test
public void testFailure_tooManyParameters() throws Exception {
thrown.expect(IllegalArgumentException.class);
runCommand("xn--q9jyb4c", "foobar");
}
@Test
public void testFailure_nonexistentTld() throws Exception {
thrown.expect(IllegalArgumentException.class);
runCommand("foobarbaz");
}
}

View file

@ -0,0 +1,223 @@
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.domain.registry.tools;
import static com.google.common.io.BaseEncoding.base16;
import static com.google.common.truth.Truth.assertThat;
import static com.google.domain.registry.testing.DatastoreHelper.createTlds;
import static com.google.domain.registry.testing.DatastoreHelper.newDomainResource;
import static com.google.domain.registry.testing.DatastoreHelper.newHostResource;
import static com.google.domain.registry.testing.DatastoreHelper.persistActiveDomain;
import static com.google.domain.registry.testing.DatastoreHelper.persistActiveHost;
import static com.google.domain.registry.testing.DatastoreHelper.persistResource;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.joda.time.DateTimeZone.UTC;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.net.InetAddresses;
import com.google.domain.registry.model.domain.DomainResource;
import com.google.domain.registry.model.domain.ReferenceUnion;
import com.google.domain.registry.model.domain.secdns.DelegationSignerData;
import com.google.domain.registry.model.eppcommon.StatusValue;
import com.google.domain.registry.model.host.HostResource;
import com.google.domain.registry.testing.FakeClock;
import com.beust.jcommander.ParameterException;
import com.googlecode.objectify.Ref;
import org.joda.time.DateTime;
import org.json.simple.JSONValue;
import org.json.simple.parser.ParseException;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import java.io.IOException;
import java.io.Reader;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
/** Unit tests for {@link GenerateDnsReportCommand}. */
public class GenerateDnsReportCommandTest extends CommandTestCase<GenerateDnsReportCommand> {
@Rule
public final TemporaryFolder folder = new TemporaryFolder();
private final DateTime now = DateTime.now(UTC);
private final FakeClock clock = new FakeClock();
private Path output;
private Object getOutputAsJson() throws IOException, ParseException {
try (Reader reader = Files.newBufferedReader(output, UTF_8)) {
return JSONValue.parseWithException(reader);
}
}
private HostResource nameserver1;
private HostResource nameserver2;
private HostResource nameserver3;
private HostResource nameserver4;
private DomainResource domain1;
private static final ImmutableMap<String, ?> DOMAIN1_OUTPUT = ImmutableMap.of(
"domain", "example.xn--q9jyb4c",
"nameservers", ImmutableList.of(
"ns1.example.xn--q9jyb4c",
"ns2.example.xn--q9jyb4c"),
"dsData", ImmutableList.of(
ImmutableMap.of(
"keyTag", 12345L,
"algorithm", 3L,
"digestType", 1L,
"digest", "49FD46E6C4B45C55D4AC"),
ImmutableMap.of(
"keyTag", 56789L,
"algorithm", 2L,
"digestType", 4L,
"digest", "69FD46E6C4A45C55D4AC")));
private static final ImmutableMap<String, ?> DOMAIN2_OUTPUT = ImmutableMap.of(
"domain", "foobar.xn--q9jyb4c",
"nameservers", ImmutableList.of(
"ns1.google.com",
"ns2.google.com"));
private static final ImmutableMap<String, ?> NAMESERVER1_OUTPUT = ImmutableMap.of(
"host", "ns1.example.xn--q9jyb4c",
"ips", ImmutableList.of(
"192.168.1.2",
"2607:f8b0:400d:c00:0:0:0:c0"));
private static final ImmutableMap<String, ?> NAMESERVER2_OUTPUT = ImmutableMap.of(
"host", "ns2.example.xn--q9jyb4c",
"ips", ImmutableList.of(
"192.168.1.1",
"2607:f8b0:400d:c00:0:0:0:c1"));
@Before
public void init() throws Exception {
output = Paths.get(folder.newFile().toString());
command.clock = clock;
clock.setTo(now);
createTlds("xn--q9jyb4c", "example");
nameserver1 = persistResource(
newHostResource("ns1.example.xn--q9jyb4c")
.asBuilder()
.setInetAddresses(ImmutableSet.of(
InetAddresses.forString("2607:f8b0:400d:c00::c0"),
InetAddresses.forString("192.168.1.2")))
.build());
nameserver2 = persistResource(
newHostResource("ns2.example.xn--q9jyb4c")
.asBuilder()
.setInetAddresses(ImmutableSet.of(
InetAddresses.forString("192.168.1.1"),
InetAddresses.forString("2607:f8b0:400d:c00::c1")))
.build());
nameserver3 = persistActiveHost("ns1.google.com");
nameserver4 = persistActiveHost("ns2.google.com");
domain1 = persistResource(newDomainResource("example.xn--q9jyb4c").asBuilder()
.setNameservers(ImmutableSet.of(
ReferenceUnion.create(Ref.create(nameserver1)),
ReferenceUnion.create(Ref.create(nameserver2))))
.setDsData(ImmutableSet.of(
DelegationSignerData.create(12345, 3, 1, base16().decode("49FD46E6C4B45C55D4AC")),
DelegationSignerData.create(56789, 2, 4, base16().decode("69FD46E6C4A45C55D4AC"))))
.build());
persistResource(newDomainResource("foobar.xn--q9jyb4c").asBuilder()
.setNameservers(ImmutableSet.of(
ReferenceUnion.create(Ref.create(nameserver3)),
ReferenceUnion.create(Ref.create(nameserver4))))
.build());
// Persist a domain in a different tld that should be ignored.
persistActiveDomain("should-be-ignored.example");
}
@Test
public void testSuccess() throws Exception {
runCommand("--output=" + output, "--tld=xn--q9jyb4c");
assertThat(getOutputAsJson()).isEqualTo(
ImmutableList.of(DOMAIN1_OUTPUT, DOMAIN2_OUTPUT, NAMESERVER1_OUTPUT, NAMESERVER2_OUTPUT));
}
@Test
public void testSuccess_skipDeletedDomain() throws Exception {
persistResource(domain1.asBuilder().setDeletionTime(now).build());
runCommand("--output=" + output, "--tld=xn--q9jyb4c");
assertThat(getOutputAsJson())
.isEqualTo(ImmutableList.of(DOMAIN2_OUTPUT, NAMESERVER1_OUTPUT, NAMESERVER2_OUTPUT));
}
@Test
public void testSuccess_skipDeletedNameserver() throws Exception {
persistResource(
nameserver1.asBuilder().setDeletionTime(now).build());
runCommand("--output=" + output, "--tld=xn--q9jyb4c");
assertThat(getOutputAsJson())
.isEqualTo(ImmutableList.of(DOMAIN1_OUTPUT, DOMAIN2_OUTPUT, NAMESERVER2_OUTPUT));
}
@Test
public void testSuccess_skipClientHoldDomain() throws Exception {
persistResource(domain1.asBuilder().addStatusValue(StatusValue.CLIENT_HOLD).build());
runCommand("--output=" + output, "--tld=xn--q9jyb4c");
assertThat(getOutputAsJson())
.isEqualTo(ImmutableList.of(DOMAIN2_OUTPUT, NAMESERVER1_OUTPUT, NAMESERVER2_OUTPUT));
}
@Test
public void testSuccess_skipServerHoldDomain() throws Exception {
persistResource(domain1.asBuilder().addStatusValue(StatusValue.SERVER_HOLD).build());
runCommand("--output=" + output, "--tld=xn--q9jyb4c");
assertThat(getOutputAsJson())
.isEqualTo(ImmutableList.of(DOMAIN2_OUTPUT, NAMESERVER1_OUTPUT, NAMESERVER2_OUTPUT));
}
@Test
public void testSuccess_skipPendingDeleteDomain() throws Exception {
persistResource(domain1.asBuilder()
.addStatusValue(StatusValue.PENDING_DELETE)
.setDeletionTime(now.plusDays(30))
.build());
runCommand("--output=" + output, "--tld=xn--q9jyb4c");
assertThat(getOutputAsJson())
.isEqualTo(ImmutableList.of(DOMAIN2_OUTPUT, NAMESERVER1_OUTPUT, NAMESERVER2_OUTPUT));
}
@Test
public void testSuccess_skipDomainsWithoutNameservers() throws Exception {
persistResource(domain1.asBuilder().setNameservers(null).build());
runCommand("--output=" + output, "--tld=xn--q9jyb4c");
assertThat(getOutputAsJson())
.isEqualTo(ImmutableList.of(DOMAIN2_OUTPUT, NAMESERVER1_OUTPUT, NAMESERVER2_OUTPUT));
}
@Test
public void testFailure_tldDoesNotExist() throws Exception {
thrown.expect(IllegalArgumentException.class);
runCommand("--tld=foobar");
}
@Test
public void testFailure_missingTldParameter() throws Exception {
thrown.expect(ParameterException.class);
runCommand("");
}
}

View file

@ -0,0 +1,240 @@
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.domain.registry.tools;
import static com.google.common.truth.Truth.assertThat;
import static com.google.domain.registry.testing.DatastoreHelper.createTld;
import static com.google.domain.registry.testing.DatastoreHelper.createTlds;
import static com.google.domain.registry.testing.DatastoreHelper.generateNewContactHostRoid;
import static com.google.domain.registry.testing.DatastoreHelper.persistResourceWithCommitLog;
import static com.google.domain.registry.util.ResourceUtils.readResourceUtf8;
import static java.nio.charset.StandardCharsets.UTF_8;
import static java.util.Arrays.asList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.net.InetAddresses;
import com.google.domain.registry.config.TestRegistryConfig;
import com.google.domain.registry.model.eppcommon.StatusValue;
import com.google.domain.registry.model.host.HostResource;
import com.google.domain.registry.model.ofy.Ofy;
import com.google.domain.registry.rde.RdeCounter;
import com.google.domain.registry.rde.RdeResourceType;
import com.google.domain.registry.rde.RdeUtil;
import com.google.domain.registry.testing.BouncyCastleProviderRule;
import com.google.domain.registry.testing.FakeClock;
import com.google.domain.registry.testing.InjectRule;
import com.google.domain.registry.util.Idn;
import com.google.domain.registry.xjc.XjcXmlTransformer;
import com.google.domain.registry.xjc.rde.XjcRdeContentType;
import com.google.domain.registry.xjc.rde.XjcRdeDeposit;
import com.google.domain.registry.xjc.rde.XjcRdeDepositTypeType;
import com.google.domain.registry.xjc.rdeheader.XjcRdeHeader;
import com.google.domain.registry.xjc.rdeheader.XjcRdeHeaderCount;
import com.google.domain.registry.xjc.rdehost.XjcRdeHost;
import com.google.domain.registry.xjc.rderegistrar.XjcRdeRegistrar;
import com.google.domain.registry.xml.XmlException;
import com.google.domain.registry.xml.XmlTestUtils;
import com.beust.jcommander.ParameterException;
import org.joda.time.DateTime;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import java.io.ByteArrayInputStream;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.JAXBElement;
/** Unit tests for {@link GenerateEscrowDepositCommand}. */
public class GenerateEscrowDepositCommandTest
extends CommandTestCase<GenerateEscrowDepositCommand> {
@Rule
public final InjectRule inject = new InjectRule();
@Rule
public final BouncyCastleProviderRule bouncy = new BouncyCastleProviderRule();
private final FakeClock clock = new FakeClock(DateTime.parse("2010-10-17T04:20:00Z"));
private final List<? super XjcRdeContentType> alreadyExtracted = new ArrayList<>();
@Before
public void before() throws Exception {
inject.setStaticField(Ofy.class, "clock", clock);
command.encryptor = EncryptEscrowDepositCommandTest.createEncryptor();
command.counter = new RdeCounter();
command.eppResourceIndexBucketCount = new TestRegistryConfig().getEppResourceIndexBucketCount();
}
@Test
public void testRun_randomDomain_generatesXmlAndEncryptsItToo() throws Exception {
createTld("xn--q9jyb4c");
runCommand(
"--outdir=" + tmpDir.getRoot(),
"--tld=xn--q9jyb4c",
"--watermark=" + clock.nowUtc().withTimeAtStartOfDay());
assertThat(tmpDir.getRoot().list()).asList().containsExactly(
"xn--q9jyb4c_2010-10-17_full_S1_R0.xml",
"xn--q9jyb4c_2010-10-17_full_S1_R0-report.xml",
"xn--q9jyb4c_2010-10-17_full_S1_R0.ryde",
"xn--q9jyb4c_2010-10-17_full_S1_R0.sig",
"xn--q9jyb4c.pub");
}
@Test
public void testRun_missingTldName_fails() throws Exception {
thrown.expect(ParameterException.class);
runCommand(
"--outdir=" + tmpDir.getRoot(),
"--watermark=" + clock.nowUtc());
}
@Test
public void testRun_nonexistentTld_fails() throws Exception {
thrown.expect(IllegalArgumentException.class);
runCommand(
"--outdir=" + tmpDir.getRoot(),
"--tld=xn--q9jyb4c",
"--watermark=" + clock.nowUtc());
}
@Test
public void testRun_oneHostNotDeletedOrFuture_producesValidDepositXml() throws Exception {
createTlds("lol", "ussr", "xn--q9jyb4c");
clock.setTo(DateTime.parse("1980-01-01TZ"));
persistResourceWithCommitLog(
newHostResource("communism.ussr", "dead:beef::cafe").asBuilder()
.setDeletionTime(DateTime.parse("1991-12-25TZ")) // nope you're deleted
.build());
clock.setTo(DateTime.parse("1999-12-31TZ"));
saveHostResource("ns1.cat.lol", "feed::a:bee"); // different tld doesn't matter
clock.setTo(DateTime.parse("2020-12-31TZ"));
saveHostResource("ns2.cat.lol", "a:fed::acab"); // nope you're from the future
clock.setTo(DateTime.parse("2010-10-17TZ"));
runCommand(
"--outdir=" + tmpDir.getRoot(),
"--tld=xn--q9jyb4c",
"--watermark=" + clock.nowUtc());
XmlTestUtils.assertXmlEquals(
readResourceUtf8(getClass(), "testdata/xn--q9jyb4c_2010-10-17_full_S1_R0.xml"),
new String(
Files.readAllBytes(
Paths.get(tmpDir.getRoot().toString(), "xn--q9jyb4c_2010-10-17_full_S1_R0.xml")),
UTF_8),
"deposit.contents.registrar.crDate",
"deposit.contents.registrar.upDate");
}
@Test
public void testRun_generatedXml_isSchemaValidAndHasStuffInIt() throws Exception {
clock.setTo(DateTime.parse("1984-12-17TZ"));
createTld("xn--q9jyb4c");
saveHostResource("ns1.cat.lol", "feed::a:bee");
clock.setTo(DateTime.parse("1984-12-18TZ"));
runCommand(
"--outdir=" + tmpDir.getRoot(),
"--tld=xn--q9jyb4c",
"--watermark=" + clock.nowUtc());
XjcRdeDeposit deposit = (XjcRdeDeposit)
unmarshal(Files.readAllBytes(
Paths.get(tmpDir.getRoot().toString(), "xn--q9jyb4c_1984-12-18_full_S1_R0.xml")));
assertThat(deposit.getType()).isEqualTo(XjcRdeDepositTypeType.FULL);
assertThat(deposit.getId()).isEqualTo(RdeUtil.timestampToId(DateTime.parse("1984-12-18TZ")));
assertThat(deposit.getWatermark()).isEqualTo(DateTime.parse("1984-12-18TZ"));
XjcRdeRegistrar registrar1 = extractAndRemoveContentWithType(XjcRdeRegistrar.class, deposit);
XjcRdeRegistrar registrar2 = extractAndRemoveContentWithType(XjcRdeRegistrar.class, deposit);
XjcRdeHost host = extractAndRemoveContentWithType(XjcRdeHost.class, deposit);
XjcRdeHeader header = extractAndRemoveContentWithType(XjcRdeHeader.class, deposit);
assertThat(host.getName()).isEqualTo("ns1.cat.lol");
assertThat(asList(registrar1.getName(), registrar2.getName()))
.containsExactly("New Registrar", "The Registrar");
assertThat(mapifyCounts(header)).containsEntry(RdeResourceType.HOST.getUri(), 1L);
assertThat(mapifyCounts(header)).containsEntry(RdeResourceType.REGISTRAR.getUri(), 2L);
}
@Test
public void testRun_thinBrdaDeposit_hostsGetExcluded() throws Exception {
clock.setTo(DateTime.parse("1984-12-17TZ"));
createTld("xn--q9jyb4c");
saveHostResource("ns1.cat.lol", "feed::a:bee");
clock.setTo(DateTime.parse("1984-12-18TZ"));
runCommand(
"--outdir=" + tmpDir.getRoot(),
"--tld=xn--q9jyb4c",
"--watermark=" + clock.nowUtc(),
"--mode=THIN");
XjcRdeDeposit deposit = (XjcRdeDeposit)
unmarshal(Files.readAllBytes(
Paths.get(tmpDir.getRoot().toString(), "xn--q9jyb4c_1984-12-18_thin_S1_R0.xml")));
assertThat(deposit.getType()).isEqualTo(XjcRdeDepositTypeType.FULL);
assertThat(deposit.getId()).isEqualTo(RdeUtil.timestampToId(DateTime.parse("1984-12-18TZ")));
assertThat(deposit.getWatermark()).isEqualTo(DateTime.parse("1984-12-18TZ"));
XjcRdeHeader header = extractAndRemoveContentWithType(XjcRdeHeader.class, deposit);
assertThat(mapifyCounts(header)).doesNotContainKey(RdeResourceType.HOST.getUri());
assertThat(mapifyCounts(header)).containsEntry(RdeResourceType.REGISTRAR.getUri(), 2L);
}
private HostResource saveHostResource(String fqdn, String ip) {
clock.advanceOneMilli();
return persistResourceWithCommitLog(newHostResource(fqdn, ip));
}
private HostResource newHostResource(String fqdn, String ip) {
return new HostResource.Builder()
.setRepoId(generateNewContactHostRoid())
.setCreationClientId("LawyerCat")
.setCreationTimeForTest(clock.nowUtc())
.setCurrentSponsorClientId("BusinessCat")
.setFullyQualifiedHostName(Idn.toASCII(fqdn))
.setInetAddresses(ImmutableSet.of(InetAddresses.forString(ip)))
.setLastTransferTime(DateTime.parse("1910-01-01T00:00:00Z"))
.setLastEppUpdateClientId("CeilingCat")
.setLastEppUpdateTime(clock.nowUtc())
.setStatusValues(ImmutableSet.of(
StatusValue.OK,
StatusValue.PENDING_UPDATE))
.build();
}
public static Object unmarshal(byte[] xml) throws XmlException {
return XjcXmlTransformer.unmarshal(new ByteArrayInputStream(xml));
}
private static ImmutableMap<String, Long> mapifyCounts(XjcRdeHeader header) {
ImmutableMap.Builder<String, Long> builder = new ImmutableMap.Builder<>();
for (XjcRdeHeaderCount count : header.getCounts()) {
builder.put(count.getUri(), count.getValue());
}
return builder.build();
}
private <T extends XjcRdeContentType>
T extractAndRemoveContentWithType(Class<T> type, XjcRdeDeposit deposit) {
for (JAXBElement<? extends XjcRdeContentType> content : deposit.getContents().getContents()) {
XjcRdeContentType piece = content.getValue();
if (type.isInstance(piece) && !alreadyExtracted.contains(piece)) {
alreadyExtracted.add(piece);
return type.cast(piece);
}
}
throw new AssertionError("Expected deposit to contain another " + type.getSimpleName());
}
}

View file

@ -0,0 +1,105 @@
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.domain.registry.tools;
import static com.google.domain.registry.testing.DatastoreHelper.createTld;
import static com.google.domain.registry.testing.DatastoreHelper.newDomainApplication;
import static com.google.domain.registry.testing.DatastoreHelper.persistActiveDomainApplication;
import static com.google.domain.registry.testing.DatastoreHelper.persistDeletedDomainApplication;
import static com.google.domain.registry.testing.DatastoreHelper.persistResource;
import static org.joda.time.DateTimeZone.UTC;
import com.beust.jcommander.ParameterException;
import org.joda.time.DateTime;
import org.junit.Before;
import org.junit.Test;
/** Unit tests for {@link GetApplicationCommand}. */
public class GetApplicationCommandTest extends CommandTestCase<GetApplicationCommand> {
DateTime now = DateTime.now(UTC);
@Before
public void initialize() {
createTld("tld");
}
@Test
public void testSuccess() throws Exception {
persistActiveDomainApplication("example.tld");
runCommand("2-TLD");
assertInStdout("fullyQualifiedDomainName=example.tld");
assertInStdout("contactId=ReferenceUnion");
}
@Test
public void testSuccess_expand() throws Exception {
persistActiveDomainApplication("example.tld");
runCommand("2-TLD", "--expand");
assertInStdout("fullyQualifiedDomainName=example.tld");
assertInStdout("contactId=contact1234");
assertNotInStdout("ReferenceUnion");
assertNotInStdout("LiveRef");
}
@Test
public void testSuccess_multipleArguments() throws Exception {
persistActiveDomainApplication("example.tld");
persistActiveDomainApplication("example2.tld");
persistActiveDomainApplication("example3.tld");
runCommand("2-TLD", "4-TLD", "6-TLD");
assertInStdout("fullyQualifiedDomainName=example.tld");
assertInStdout("fullyQualifiedDomainName=example2.tld");
assertInStdout("fullyQualifiedDomainName=example3.tld");
}
@Test
public void testSuccess_applicationDeletedInFuture() throws Exception {
persistResource(
newDomainApplication("example.tld").asBuilder().setDeletionTime(now.plusDays(1)).build());
runCommand("--read_timestamp=" + now.plusMonths(1), "2-TLD");
assertInStdout("DomainApplication '2-TLD' does not exist or is deleted");
}
@Test
public void testSuccess_deletedApplication() throws Exception {
persistDeletedDomainApplication("example.tld", now);
runCommand("2-TLD");
assertInStdout("DomainApplication '2-TLD' does not exist or is deleted");
}
@Test
public void testSuccess_applicationDoesNotExist() throws Exception {
runCommand("42-TLD");
assertInStdout("DomainApplication '42-TLD' does not exist or is deleted");
}
@Test
public void testFailure_noApplicationId() throws Exception {
thrown.expect(ParameterException.class);
runCommand();
}
@Test
public void testSuccess_oneApplicationDoesNotExist() throws Exception {
persistActiveDomainApplication("example.tld");
persistActiveDomainApplication("example2.tld");
runCommand("2-TLD", "4-TLD", "55-TLD");
assertInStdout("fullyQualifiedDomainName=example.tld");
assertInStdout("fullyQualifiedDomainName=example2.tld");
assertInStdout("DomainApplication '55-TLD' does not exist or is deleted");
}
}

View file

@ -0,0 +1,106 @@
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.domain.registry.tools;
import static com.google.domain.registry.testing.DatastoreHelper.createTld;
import static com.google.domain.registry.testing.DatastoreHelper.newDomainApplication;
import static com.google.domain.registry.testing.DatastoreHelper.persistActiveContact;
import static com.google.domain.registry.testing.DatastoreHelper.persistResource;
import static org.joda.time.DateTimeZone.UTC;
import com.google.domain.registry.model.domain.launch.LaunchPhase;
import com.beust.jcommander.ParameterException;
import org.joda.time.DateTime;
import org.junit.Before;
import org.junit.Test;
/** Unit tests for {@link GetApplicationIdsCommand}. */
public class GetApplicationIdsCommandTest extends CommandTestCase<GetApplicationIdsCommand> {
DateTime now = DateTime.now(UTC);
@Before
public void initialize() {
createTld("tld");
}
@Test
public void testSuccess() throws Exception {
persistDomainApplication("example.tld", "1-TLD");
runCommand("example.tld");
assertInStdout("1-TLD (TheRegistrar)");
}
@Test
public void testSuccess_multipleArguments() throws Exception {
persistDomainApplication("example.tld", "1-TLD");
persistDomainApplication("example2.tld", "2-TLD");
runCommand("example.tld", "example2.tld");
assertInStdout("1-TLD (TheRegistrar)");
assertInStdout("2-TLD (TheRegistrar)");
}
@Test
public void testSuccess_domainDoesNotExist() throws Exception {
runCommand("something.tld");
assertInStdout("No applications exist for 'something.tld'.");
}
@Test
public void testFailure_tldDoesNotExist() throws Exception {
thrown.expect(NullPointerException.class);
runCommand("example.foo");
}
@Test
public void testSuccess_afterDeletion() throws Exception {
persistResource(
newDomainApplication("example.tld").asBuilder().setDeletionTime(now.plusDays(1)).build());
runCommand("example.tld", "--read_timestamp=" + now.plusMonths(1));
assertInStdout("No applications exist for 'example.tld'.");
}
@Test
public void testSuccess_deletedApplication() throws Exception {
persistResource(
newDomainApplication("example.tld").asBuilder().setDeletionTime(now.minusDays(1)).build());
runCommand("example.tld");
assertInStdout("No applications exist for 'example.tld'.");
}
@Test
public void testFailure_noDomainName() throws Exception {
thrown.expect(ParameterException.class);
runCommand();
}
private void persistDomainApplication(String domainName, String repoId) {
persistResource(
newDomainApplication(
domainName, repoId, persistActiveContact("icn1001"), LaunchPhase.OPEN));
}
@Test
public void testSuccess_oneDomainDoesNotExist() throws Exception {
persistDomainApplication("example.tld", "1-TLD");
createTld("com");
runCommand("example.com", "example.tld", "example2.com");
assertInStdout("1-TLD (TheRegistrar)");
assertInStdout("No applications exist for 'example.com'.");
assertInStdout("No applications exist for 'example2.com'.");
}
}

View file

@ -0,0 +1,49 @@
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.domain.registry.tools;
import static com.google.common.truth.Truth.assertThat;
import static java.nio.charset.StandardCharsets.UTF_8;
import static java.nio.file.Files.readAllLines;
import static org.joda.time.DateTimeZone.UTC;
import com.google.common.collect.ImmutableMap;
import com.google.domain.registry.model.tmch.ClaimsListShard;
import org.joda.time.DateTime;
import org.junit.Test;
import java.io.File;
import java.nio.file.Files;
/** Unit tests for {@link GetClaimsListCommand}. */
public class GetClaimsListCommandTest extends CommandTestCase<GetClaimsListCommand> {
@Test
public void testSuccess_getWorks() throws Exception {
ClaimsListShard.create(DateTime.now(UTC), ImmutableMap.of("a", "1", "b", "2")).save();
File output = tmpDir.newFile();
runCommand("--output=" + output.getAbsolutePath());
assertThat(readAllLines(output.toPath(), UTF_8)).containsExactly("a,1", "b,2");
}
@Test
public void testSuccess_endsWithNewline() throws Exception {
ClaimsListShard.create(DateTime.now(UTC), ImmutableMap.of("a", "1")).save();
File output = tmpDir.newFile();
runCommand("--output=" + output.getAbsolutePath());
assertThat(new String(Files.readAllBytes(output.toPath()), UTF_8)).endsWith("\n");
}
}

View file

@ -0,0 +1,95 @@
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.domain.registry.tools;
import static com.google.domain.registry.testing.DatastoreHelper.createTld;
import static com.google.domain.registry.testing.DatastoreHelper.newContactResource;
import static com.google.domain.registry.testing.DatastoreHelper.persistActiveContact;
import static com.google.domain.registry.testing.DatastoreHelper.persistDeletedContact;
import static com.google.domain.registry.testing.DatastoreHelper.persistResource;
import static org.joda.time.DateTimeZone.UTC;
import com.beust.jcommander.ParameterException;
import org.joda.time.DateTime;
import org.junit.Before;
import org.junit.Test;
/** Unit tests for {@link GetContactCommand}. */
public class GetContactCommandTest extends CommandTestCase<GetContactCommand> {
DateTime now = DateTime.now(UTC);
@Before
public void initialize() {
createTld("tld");
}
@Test
public void testSuccess() throws Exception {
persistActiveContact("sh8013");
runCommand("sh8013");
assertInStdout("contactId=sh8013");
assertInStdout("Websafe key: agR0ZXN0chsLEg9Db250YWN0UmVzb3VyY2UiBjItUk9JRAw");
}
@Test
public void testSuccess_expand() throws Exception {
persistActiveContact("sh8013");
runCommand("sh8013", "--expand");
assertInStdout("contactId=sh8013");
assertInStdout("Websafe key: agR0ZXN0chsLEg9Db250YWN0UmVzb3VyY2UiBjItUk9JRAw");
assertNotInStdout("ReferenceUnion");
assertNotInStdout("LiveRef");
}
@Test
public void testSuccess_multipleArguments() throws Exception {
persistActiveContact("sh8013");
persistActiveContact("jd1234");
runCommand("sh8013", "jd1234");
assertInStdout("contactId=sh8013");
assertInStdout("contactId=jd1234");
assertInStdout("Websafe key: agR0ZXN0chsLEg9Db250YWN0UmVzb3VyY2UiBjItUk9JRAw");
assertInStdout("Websafe key: agR0ZXN0chsLEg9Db250YWN0UmVzb3VyY2UiBjMtUk9JRAw");
}
@Test
public void testSuccess_deletedContact() throws Exception {
persistDeletedContact("sh8013", now);
runCommand("sh8013");
assertInStdout("Contact 'sh8013' does not exist or is deleted");
}
@Test
public void testSuccess_contactDoesNotExist() throws Exception {
runCommand("nope");
assertInStdout("Contact 'nope' does not exist or is deleted");
}
@Test
public void testFailure_noContact() throws Exception {
thrown.expect(ParameterException.class);
runCommand();
}
@Test
public void testSuccess_contactDeletedInFuture() throws Exception {
persistResource(
newContactResource("sh8013").asBuilder().setDeletionTime(now.plusDays(1)).build());
runCommand("sh8013", "--read_timestamp=" + now.plusMonths(1));
assertInStdout("Contact 'sh8013' does not exist or is deleted");
}
}

View file

@ -0,0 +1,112 @@
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.domain.registry.tools;
import static com.google.domain.registry.testing.DatastoreHelper.createTld;
import static com.google.domain.registry.testing.DatastoreHelper.newDomainResource;
import static com.google.domain.registry.testing.DatastoreHelper.persistActiveDomain;
import static com.google.domain.registry.testing.DatastoreHelper.persistDeletedDomain;
import static com.google.domain.registry.testing.DatastoreHelper.persistResource;
import static org.joda.time.DateTimeZone.UTC;
import com.beust.jcommander.ParameterException;
import org.joda.time.DateTime;
import org.junit.Before;
import org.junit.Test;
/** Unit tests for {@link GetDomainCommand}. */
public class GetDomainCommandTest extends CommandTestCase<GetDomainCommand> {
DateTime now = DateTime.now(UTC);
@Before
public void initialize() {
createTld("tld");
}
@Test
public void testSuccess() throws Exception {
persistActiveDomain("example.tld");
runCommand("example.tld");
assertInStdout("fullyQualifiedDomainName=example.tld");
assertInStdout("contactId=ReferenceUnion");
assertInStdout("Websafe key: agR0ZXN0chULEgpEb21haW5CYXNlIgUyLVRMRAw");
}
@Test
public void testSuccess_expand() throws Exception {
persistActiveDomain("example.tld");
runCommand("example.tld", "--expand");
assertInStdout("fullyQualifiedDomainName=example.tld");
assertInStdout("contactId=contact1234");
assertInStdout("Websafe key: agR0ZXN0chULEgpEb21haW5CYXNlIgUyLVRMRAw");
assertNotInStdout("ReferenceUnion");
assertNotInStdout("LiveRef");
}
@Test
public void testSuccess_multipleArguments() throws Exception {
persistActiveDomain("example.tld");
persistActiveDomain("example2.tld");
runCommand("example.tld", "example2.tld");
assertInStdout("fullyQualifiedDomainName=example.tld");
assertInStdout("fullyQualifiedDomainName=example2.tld");
assertInStdout("Websafe key: agR0ZXN0chULEgpEb21haW5CYXNlIgUyLVRMRAw");
assertInStdout("Websafe key: agR0ZXN0chULEgpEb21haW5CYXNlIgU0LVRMRAw");
}
@Test
public void testSuccess_domainDeletedInFuture() throws Exception {
persistResource(newDomainResource("example.tld").asBuilder()
.setDeletionTime(now.plusDays(1)).build());
runCommand("example.tld", "--read_timestamp=" + now.plusMonths(1));
assertInStdout("Domain 'example.tld' does not exist or is deleted");
}
@Test
public void testSuccess_deletedDomain() throws Exception {
persistDeletedDomain("example.tld", now);
runCommand("example.tld");
assertInStdout("Domain 'example.tld' does not exist or is deleted");
}
@Test
public void testSuccess_domainDoesNotExist() throws Exception {
runCommand("something.tld");
assertInStdout("Domain 'something.tld' does not exist or is deleted");
}
@Test
public void testFailure_tldDoesNotExist() throws Exception {
runCommand("example.foo");
assertInStdout("Domain 'example.foo' does not exist or is deleted");
}
@Test
public void testFailure_noDomainName() throws Exception {
thrown.expect(ParameterException.class);
runCommand();
}
@Test
public void testSuccess_oneDomainDoesNotExist() throws Exception {
persistActiveDomain("example.tld");
createTld("com");
runCommand("example.com", "example.tld");
assertInStdout("fullyQualifiedDomainName=example.tld");
assertInStdout("Domain 'example.com' does not exist or is deleted");
}
}

View file

@ -0,0 +1,114 @@
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.domain.registry.tools;
import static com.google.domain.registry.testing.DatastoreHelper.createTld;
import static com.google.domain.registry.testing.DatastoreHelper.newHostResource;
import static com.google.domain.registry.testing.DatastoreHelper.persistActiveHost;
import static com.google.domain.registry.testing.DatastoreHelper.persistDeletedHost;
import static com.google.domain.registry.testing.DatastoreHelper.persistResource;
import static org.joda.time.DateTimeZone.UTC;
import com.beust.jcommander.ParameterException;
import org.joda.time.DateTime;
import org.junit.Before;
import org.junit.Test;
/** Unit tests for {@link GetHostCommand}. */
public class GetHostCommandTest extends CommandTestCase<GetHostCommand> {
DateTime now = DateTime.now(UTC);
@Before
public void initialize() {
createTld("tld");
}
@Test
public void testSuccess() throws Exception {
persistActiveHost("ns1.example.tld");
runCommand("ns1.example.tld");
assertInStdout("fullyQualifiedHostName=ns1.example.tld");
assertInStdout("Websafe key: agR0ZXN0chgLEgxIb3N0UmVzb3VyY2UiBjItUk9JRAw");
}
@Test
public void testSuccess_expand() throws Exception {
persistActiveHost("ns1.example.tld");
runCommand("ns1.example.tld", "--expand");
assertInStdout("fullyQualifiedHostName=ns1.example.tld");
assertInStdout("Websafe key: agR0ZXN0chgLEgxIb3N0UmVzb3VyY2UiBjItUk9JRAw");
assertNotInStdout("ReferenceUnion");
assertNotInStdout("LiveRef");
}
@Test
public void testSuccess_multipleArguments() throws Exception {
persistActiveHost("ns1.example.tld");
persistActiveHost("ns2.example.tld");
runCommand("ns1.example.tld", "ns2.example.tld");
assertInStdout("fullyQualifiedHostName=ns1.example.tld");
assertInStdout("fullyQualifiedHostName=ns2.example.tld");
assertInStdout("Websafe key: agR0ZXN0chgLEgxIb3N0UmVzb3VyY2UiBjItUk9JRAw");
assertInStdout("Websafe key: agR0ZXN0chgLEgxIb3N0UmVzb3VyY2UiBjMtUk9JRAw");
}
@Test
public void testSuccess_multipleTlds() throws Exception {
persistActiveHost("ns1.example.tld");
createTld("tld2");
persistActiveHost("ns1.example.tld2");
runCommand("ns1.example.tld", "ns1.example.tld2");
assertInStdout("fullyQualifiedHostName=ns1.example.tld");
assertInStdout("fullyQualifiedHostName=ns1.example.tld2");
}
@Test
public void testSuccess_deletedHost() throws Exception {
persistDeletedHost("ns1.example.tld", now);
runCommand("ns1.example.tld");
assertInStdout("Host 'ns1.example.tld' does not exist or is deleted");
}
@Test
public void testSuccess_hostDoesNotExist() throws Exception {
runCommand("foo.example.tld");
assertInStdout("Host 'foo.example.tld' does not exist or is deleted");
}
@Test
public void testSuccess_hostDeletedInFuture() throws Exception {
persistResource(
newHostResource("ns1.example.tld").asBuilder()
.setDeletionTime(now.plusDays(1))
.build());
runCommand("ns1.example.tld", "--read_timestamp=" + now.plusMonths(1));
assertInStdout("Host 'ns1.example.tld' does not exist or is deleted");
}
@Test
public void testSuccess_externalHost() throws Exception {
persistActiveHost("ns1.example.foo");
runCommand("ns1.example.foo");
assertInStdout("fullyQualifiedHostName=ns1.example.foo");
}
@Test
public void testFailure_noHostName() throws Exception {
thrown.expect(ParameterException.class);
runCommand();
}
}

View file

@ -0,0 +1,53 @@
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.domain.registry.tools;
import com.beust.jcommander.ParameterException;
import org.junit.Test;
/** Unit tests for {@link GetRegistrarCommand}. */
public class GetRegistrarCommandTest extends CommandTestCase<GetRegistrarCommand> {
@Test
public void testSuccess() throws Exception {
// This registrar is created by AppEngineRule.
runCommand("NewRegistrar");
}
@Test
public void testSuccess_multipleArguments() throws Exception {
// Registrars are created by AppEngineRule.
runCommand("NewRegistrar", "TheRegistrar");
}
@Test
public void testFailure_registrarDoesNotExist() throws Exception {
thrown.expect(IllegalStateException.class);
runCommand("ClientZ");
}
@Test
public void testFailure_noRegistrarName() throws Exception {
thrown.expect(ParameterException.class);
runCommand();
}
@Test
public void testFailure_oneRegistrarDoesNotExist() throws Exception {
thrown.expect(IllegalStateException.class);
runCommand("NewRegistrar", "ClientZ");
}
}

View file

@ -0,0 +1,213 @@
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.domain.registry.tools;
import static com.google.domain.registry.testing.DatastoreHelper.createTld;
import static com.google.domain.registry.testing.DatastoreHelper.persistActiveContact;
import static com.google.domain.registry.testing.DatastoreHelper.persistActiveDomain;
import static com.google.domain.registry.testing.DatastoreHelper.persistActiveHost;
import static com.google.domain.registry.testing.DatastoreHelper.persistDeletedContact;
import static com.google.domain.registry.testing.DatastoreHelper.persistDeletedDomain;
import static com.google.domain.registry.testing.DatastoreHelper.persistDeletedHost;
import static org.joda.time.DateTimeZone.UTC;
import com.beust.jcommander.ParameterException;
import org.joda.time.DateTime;
import org.junit.Before;
import org.junit.Test;
/** Unit tests for {@link GetResourceByKeyCommand}. */
public class GetResourceByKeyCommandTest extends CommandTestCase<GetResourceByKeyCommand> {
DateTime now = DateTime.now(UTC);
@Before
public void initialize() {
createTld("tld");
}
@Test
public void testSuccess_domain() throws Exception {
persistActiveDomain("example.tld");
runCommand("agR0ZXN0chULEgpEb21haW5CYXNlIgUyLVRMRAw");
assertInStdout("fullyQualifiedDomainName=example.tld");
assertInStdout("contactId=ReferenceUnion");
}
@Test
public void testSuccess_domain_expand() throws Exception {
persistActiveDomain("example.tld");
runCommand("agR0ZXN0chULEgpEb21haW5CYXNlIgUyLVRMRAw", "--expand");
assertInStdout("fullyQualifiedDomainName=example.tld");
assertInStdout("contactId=contact1234");
assertNotInStdout("ReferenceUnion");
assertNotInStdout("LiveRef");
}
@Test
public void testSuccess_domain_multipleArguments() throws Exception {
persistActiveDomain("example.tld");
persistActiveDomain("example2.tld");
runCommand(
"agR0ZXN0chULEgpEb21haW5CYXNlIgUyLVRMRAw", "agR0ZXN0chULEgpEb21haW5CYXNlIgU0LVRMRAw");
assertInStdout("fullyQualifiedDomainName=example.tld");
assertInStdout("fullyQualifiedDomainName=example2.tld");
}
@Test
public void testFailure_domain_oneDoesNotExist() throws Exception {
persistActiveDomain("example.tld");
thrown.expect(
NullPointerException.class,
"Could not load resource for key: Key<?>(DomainBase(\"4-TLD\"))");
runCommand(
"agR0ZXN0chULEgpEb21haW5CYXNlIgUyLVRMRAw", "agR0ZXN0chULEgpEb21haW5CYXNlIgU0LVRMRAw");
}
@Test
public void testSuccess_deletedDomain() throws Exception {
persistDeletedDomain("example.tld", now);
runCommand("agR0ZXN0chULEgpEb21haW5CYXNlIgUyLVRMRAw");
assertInStdout("fullyQualifiedDomainName=example.tld");
assertInStdout("deletionTime=" + now.minusDays(1));
}
@Test
public void testSuccess_contact() throws Exception {
persistActiveContact("sh8013");
runCommand("agR0ZXN0chsLEg9Db250YWN0UmVzb3VyY2UiBjItUk9JRAw");
assertInStdout("contactId=sh8013");
}
@Test
public void testSuccess_contact_expand() throws Exception {
persistActiveContact("sh8013");
runCommand("agR0ZXN0chsLEg9Db250YWN0UmVzb3VyY2UiBjItUk9JRAw", "--expand");
assertInStdout("contactId=sh8013");
assertNotInStdout("ReferenceUnion");
assertNotInStdout("LiveRef");
}
@Test
public void testSuccess_contact_multipleArguments() throws Exception {
persistActiveContact("sh8013");
persistActiveContact("jd1234");
runCommand(
"agR0ZXN0chsLEg9Db250YWN0UmVzb3VyY2UiBjItUk9JRAw",
"agR0ZXN0chsLEg9Db250YWN0UmVzb3VyY2UiBjMtUk9JRAw");
assertInStdout("contactId=sh8013");
assertInStdout("contactId=jd1234");
}
@Test
public void testFailure_contact_oneDoesNotExist() throws Exception {
thrown.expect(
NullPointerException.class,
"Could not load resource for key: Key<?>(ContactResource(\"3-ROID\"))");
persistActiveContact("sh8013");
runCommand(
"agR0ZXN0chsLEg9Db250YWN0UmVzb3VyY2UiBjItUk9JRAw",
"agR0ZXN0chsLEg9Db250YWN0UmVzb3VyY2UiBjMtUk9JRAw");
}
@Test
public void testSuccess_deletedContact() throws Exception {
persistDeletedContact("sh8013", now);
runCommand("agR0ZXN0chsLEg9Db250YWN0UmVzb3VyY2UiBjItUk9JRAw");
assertInStdout("contactId=sh8013");
assertInStdout("deletionTime=" + now.minusDays(1));
}
@Test
public void testSuccess_host() throws Exception {
persistActiveHost("ns1.example.tld");
runCommand("agR0ZXN0chgLEgxIb3N0UmVzb3VyY2UiBjItUk9JRAw");
assertInStdout("fullyQualifiedHostName=ns1.example.tld");
}
@Test
public void testSuccess_host_expand() throws Exception {
persistActiveHost("ns1.example.tld");
runCommand("agR0ZXN0chgLEgxIb3N0UmVzb3VyY2UiBjItUk9JRAw", "--expand");
assertInStdout("fullyQualifiedHostName=ns1.example.tld");
assertNotInStdout("ReferenceUnion");
assertNotInStdout("LiveRef");
}
@Test
public void testSuccess_host_multipleArguments() throws Exception {
persistActiveHost("ns1.example.tld");
persistActiveHost("ns2.example.tld");
runCommand(
"agR0ZXN0chgLEgxIb3N0UmVzb3VyY2UiBjItUk9JRAw",
"agR0ZXN0chgLEgxIb3N0UmVzb3VyY2UiBjMtUk9JRAw");
assertInStdout("fullyQualifiedHostName=ns1.example.tld");
assertInStdout("fullyQualifiedHostName=ns2.example.tld");
}
@Test
public void testFailure_host_oneDoesNotExist() throws Exception {
thrown.expect(
NullPointerException.class,
"Could not load resource for key: Key<?>(HostResource(\"3-ROID\"))");
persistActiveHost("ns1.example.tld");
runCommand(
"agR0ZXN0chgLEgxIb3N0UmVzb3VyY2UiBjItUk9JRAw",
"agR0ZXN0chgLEgxIb3N0UmVzb3VyY2UiBjMtUk9JRAw");
}
@Test
public void testSuccess_deletedHost() throws Exception {
persistDeletedHost("ns1.example.tld", now);
runCommand("agR0ZXN0chgLEgxIb3N0UmVzb3VyY2UiBjItUk9JRAw");
assertInStdout("fullyQualifiedHostName=ns1.example.tld");
assertInStdout("deletionTime=" + now.minusDays(1));
}
@Test
public void testSuccess_mixedTypes() throws Exception {
persistActiveDomain("example.tld");
persistActiveContact("sh8013");
persistActiveHost("ns1.example.tld");
runCommand(
"agR0ZXN0chULEgpEb21haW5CYXNlIgUyLVRMRAw",
"agR0ZXN0chsLEg9Db250YWN0UmVzb3VyY2UiBjQtUk9JRAw",
"agR0ZXN0chgLEgxIb3N0UmVzb3VyY2UiBjUtUk9JRAw");
assertInStdout("fullyQualifiedDomainName=example.tld");
assertInStdout("contactId=sh8013");
assertInStdout("fullyQualifiedHostName=ns1.example.tld");
}
@Test
public void testFailure_keyDoesNotExist() throws Exception {
thrown.expect(
NullPointerException.class,
"Could not load resource for key: Key<?>(DomainBase(\"2-TLD\"))");
runCommand("agR0ZXN0chULEgpEb21haW5CYXNlIgUyLVRMRAw");
}
@Test
public void testFailure_nonsenseKey() throws Exception {
thrown.expect(IllegalArgumentException.class, "Could not parse Reference");
runCommand("agR0ZXN0chULEgpEb21haW5CYXN");
}
@Test
public void testFailure_noParameters() throws Exception {
thrown.expect(ParameterException.class);
runCommand();
}
}

View file

@ -0,0 +1,58 @@
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.domain.registry.tools;
import static com.google.domain.registry.testing.DatastoreHelper.createTld;
import static com.google.domain.registry.testing.DatastoreHelper.createTlds;
import com.beust.jcommander.ParameterException;
import org.junit.Test;
/** Unit tests for {@link GetTldCommand}. */
public class GetTldCommandTest extends CommandTestCase<GetTldCommand> {
@Test
public void testSuccess() throws Exception {
createTld("xn--q9jyb4c");
runCommand("xn--q9jyb4c");
}
@Test
public void testSuccess_multipleArguments() throws Exception {
createTlds("xn--q9jyb4c", "example");
runCommand("xn--q9jyb4c", "example");
}
@Test
public void testFailure_tldDoesNotExist() throws Exception {
thrown.expect(IllegalArgumentException.class);
runCommand("xn--q9jyb4c");
}
@Test
public void testFailure_noTldName() throws Exception {
thrown.expect(ParameterException.class);
runCommand();
}
@Test
public void testFailure_oneTldDoesNotExist() throws Exception {
thrown.expect(IllegalArgumentException.class);
createTld("xn--q9jyb4c");
runCommand("xn--q9jyb4c", "example");
}
}

View file

@ -0,0 +1,137 @@
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.domain.registry.tools;
import static com.google.common.truth.Truth.assertThat;
import static java.nio.charset.StandardCharsets.UTF_8;
import com.google.domain.registry.keyring.api.Keyring;
import com.google.domain.registry.rde.Ghostryde;
import com.google.domain.registry.rde.Ghostryde.DecodeResult;
import com.google.domain.registry.rde.RdeKeyringModule;
import com.google.domain.registry.testing.BouncyCastleProviderRule;
import com.google.domain.registry.testing.InjectRule;
import org.joda.time.DateTime;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.attribute.FileTime;
/** Unit tests for {@link GhostrydeCommand}. */
public class GhostrydeCommandTest extends CommandTestCase<GhostrydeCommand> {
private static final DateTime MODIFIED_TIME = DateTime.parse("1984-12-18T04:20:00Z");
private static final byte[] SONG_BY_CHRISTINA_ROSSETTI = (""
+ "When I am dead, my dearest, \n"
+ " Sing no sad songs for me; \n"
+ "Plant thou no roses at my head, \n"
+ " Nor shady cypress tree: \n"
+ "Be the green grass above me \n"
+ " With showers and dewdrops wet; \n"
+ "And if thou wilt, remember, \n"
+ " And if thou wilt, forget. \n"
+ " \n"
+ "I shall not see the shadows, \n"
+ " I shall not feel the rain; \n"
+ "I shall not hear the nightingale \n"
+ " Sing on, as if in pain: \n"
+ "And dreaming through the twilight \n"
+ " That doth not rise nor set, \n"
+ "Haply I may remember, \n"
+ " And haply may forget. \n").getBytes(UTF_8);
@Rule
public final InjectRule inject = new InjectRule();
@Rule
public final BouncyCastleProviderRule bouncy = new BouncyCastleProviderRule();
private Keyring keyring;
@Before
public void before() throws Exception {
keyring = new RdeKeyringModule().get();
command.ghostryde = new Ghostryde(1024);
command.rdeStagingDecryptionKey = keyring.getRdeStagingDecryptionKey();
command.rdeStagingEncryptionKey = keyring.getRdeStagingEncryptionKey();
}
@Test
public void testEncrypt_outputIsAFile_writesToFile() throws Exception {
Path inFile = Paths.get(tmpDir.newFile("atrain.txt").toString());
Path outFile = Paths.get(tmpDir.newFile().toString());
Files.write(inFile, SONG_BY_CHRISTINA_ROSSETTI);
Files.setLastModifiedTime(inFile, FileTime.fromMillis(MODIFIED_TIME.getMillis()));
runCommand("--encrypt", "--input=" + inFile, "--output=" + outFile);
DecodeResult decoded = Ghostryde.decode(
Files.readAllBytes(outFile),
keyring.getRdeStagingDecryptionKey());
assertThat(decoded.getData()).isEqualTo(SONG_BY_CHRISTINA_ROSSETTI);
assertThat(decoded.getName()).isEqualTo("atrain.txt");
assertThat(decoded.getModified()).isEqualTo(MODIFIED_TIME);
}
@Test
public void testEncrypt_outputIsADirectory_appendsGhostrydeExtension() throws Exception {
Path inFile = Paths.get(tmpDir.newFile("atrain.txt").toString());
Path outDir = Paths.get(tmpDir.newFolder().toString());
Files.write(inFile, SONG_BY_CHRISTINA_ROSSETTI);
Files.setLastModifiedTime(inFile, FileTime.fromMillis(MODIFIED_TIME.getMillis()));
runCommand("--encrypt", "--input=" + inFile, "--output=" + outDir);
Path outFile = outDir.resolve("atrain.txt.ghostryde");
DecodeResult decoded = Ghostryde.decode(
Files.readAllBytes(outFile),
keyring.getRdeStagingDecryptionKey());
assertThat(decoded.getData()).isEqualTo(SONG_BY_CHRISTINA_ROSSETTI);
assertThat(decoded.getName()).isEqualTo("atrain.txt");
assertThat(decoded.getModified()).isEqualTo(MODIFIED_TIME);
}
@Test
public void testDecrypt_outputIsAFile_writesToFile() throws Exception {
Path inFile = Paths.get(tmpDir.newFile().toString());
Path outFile = Paths.get(tmpDir.newFile().toString());
Files.write(inFile, Ghostryde.encode(
SONG_BY_CHRISTINA_ROSSETTI,
keyring.getRdeStagingEncryptionKey(),
"atrain.txt",
MODIFIED_TIME));
runCommand("--decrypt", "--input=" + inFile, "--output=" + outFile);
assertThat(Files.readAllBytes(outFile)).isEqualTo(SONG_BY_CHRISTINA_ROSSETTI);
assertThat(Files.getLastModifiedTime(outFile))
.isEqualTo(FileTime.fromMillis(MODIFIED_TIME.getMillis()));
}
@Test
public void testDecrypt_outputIsADirectory_writesToFileFromInnerName() throws Exception {
Path inFile = Paths.get(tmpDir.newFile().toString());
Path outDir = Paths.get(tmpDir.newFolder().toString());
Files.write(inFile, Ghostryde.encode(
SONG_BY_CHRISTINA_ROSSETTI,
keyring.getRdeStagingEncryptionKey(),
"atrain.txt",
MODIFIED_TIME));
runCommand("--decrypt", "--input=" + inFile, "--output=" + outDir);
Path outFile = outDir.resolve("atrain.txt");
assertThat(Files.readAllBytes(outFile)).isEqualTo(SONG_BY_CHRISTINA_ROSSETTI);
assertThat(Files.getLastModifiedTime(outFile))
.isEqualTo(FileTime.fromMillis(MODIFIED_TIME.getMillis()));
}
}

View file

@ -0,0 +1,104 @@
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.domain.registry.tools;
import static com.google.common.base.CaseFormat.LOWER_UNDERSCORE;
import static com.google.common.base.CaseFormat.UPPER_CAMEL;
import static com.google.common.reflect.Reflection.getPackageName;
import static com.google.common.truth.Truth.assertWithMessage;
import com.google.common.base.Joiner;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Sets;
import com.google.common.reflect.ClassPath;
import com.google.common.reflect.ClassPath.ClassInfo;
import com.google.common.truth.Expect;
import com.google.domain.registry.tools.Command.GtechCommand;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import java.io.IOException;
import java.lang.reflect.Modifier;
import java.util.Map;
import java.util.Set;
/** Unit tests for {@link GtechTool}. */
@RunWith(JUnit4.class)
public class GtechToolTest {
@Rule
public final ExpectedException thrown = ExpectedException.none();
@Rule
public final Expect expect = Expect.create();
@Before
public void init() {
RegistryToolEnvironment.UNITTEST.setup();
}
@Test
public void testThatAllCommandsAreInCliOptions() throws Exception {
Set<Class<? extends GtechCommand>> commandMapClasses =
ImmutableSet.copyOf(GtechTool.COMMAND_MAP.values());
Set<Class<? extends GtechCommand>> commandsWithoutCliInvokers =
Sets.difference(getAllCommandClasses(), commandMapClasses);
String errorMsg =
"These Command classes are missing from GtechTool.COMMAND_MAP: "
+ Joiner.on(", ").join(commandsWithoutCliInvokers);
assertWithMessage(errorMsg).that(commandsWithoutCliInvokers).isEmpty();
}
@Test
public void testThatCommandNamesAreDerivedFromClassNames() throws Exception {
for (Map.Entry<String, ? extends Class<? extends Command>> commandEntry :
GtechTool.COMMAND_MAP.entrySet()) {
String className = commandEntry.getValue().getSimpleName();
expect.that(commandEntry.getKey())
// JCommander names should match the class name, up to "Command" and case formatting.
.isEqualTo(UPPER_CAMEL.to(LOWER_UNDERSCORE, className.replaceFirst("Command$", "")));
}
}
/**
* Gets the set of all non-abstract classes implementing the {@link GtechCommand} interface
* (abstract class and interface subtypes of Command aren't expected to have cli commands). Note
* that this also filters out HelpCommand, which has special handling in {@link RegistryCli} and
* isn't in the command map.
*
* @throws IOException if reading the classpath resources fails.
*/
@SuppressWarnings("unchecked")
private ImmutableSet<Class<? extends GtechCommand>> getAllCommandClasses() throws IOException {
ImmutableSet.Builder<Class<? extends GtechCommand>> builder = new ImmutableSet.Builder<>();
for (ClassInfo classInfo : ClassPath
.from(getClass().getClassLoader())
.getTopLevelClasses(getPackageName(getClass()))) {
Class<?> clazz = classInfo.load();
if (GtechCommand.class.isAssignableFrom(clazz)
&& !Modifier.isAbstract(clazz.getModifiers())
&& !Modifier.isInterface(clazz.getModifiers())
&& !clazz.equals(HelpCommand.class)) {
builder.add((Class<? extends GtechCommand>) clazz);
}
}
return builder.build();
}
}

View file

@ -0,0 +1,70 @@
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.domain.registry.tools;
import static com.google.common.truth.Truth.assertThat;
import static com.google.domain.registry.testing.DatastoreHelper.createTlds;
import static com.google.domain.registry.testing.DatastoreHelper.persistResource;
import com.google.domain.registry.model.registry.Registry;
import com.google.domain.registry.model.registry.RegistryCursor;
import com.google.domain.registry.model.registry.RegistryCursor.CursorType;
import com.beust.jcommander.ParameterException;
import org.joda.time.DateTime;
import org.junit.Test;
/** Unit tests for {@link ListCursorsCommand}. */
public class ListCursorsCommandTest extends CommandTestCase<ListCursorsCommand> {
@Test
public void testListCursors_noTlds_printsNothing() throws Exception {
runCommand("--type=BRDA");
assertThat(getStdoutAsString()).isEmpty();
}
@Test
public void testListCursors_twoTldsOneAbsent_printsAbsentAndTimestampSorted() throws Exception {
createTlds("foo", "bar");
persistResource(RegistryCursor.create(
Registry.get("bar"), CursorType.BRDA, DateTime.parse("1984-12-18TZ")));
runCommand("--type=BRDA");
assertThat(getStdoutAsLines())
.containsExactly(
"1984-12-18T00:00:00.000Z bar",
"absent foo")
.inOrder();
}
@Test
public void testListCursors_badCursor_throwsIae() throws Exception {
thrown.expect(ParameterException.class, "Invalid value for --type parameter.");
runCommand("--type=love");
}
@Test
public void testListCursors_lowercaseCursor_isAllowed() throws Exception {
runCommand("--type=brda");
}
@Test
public void testListCursors_filterEscrowEnabled_doesWhatItSays() throws Exception {
createTlds("foo", "bar");
persistResource(Registry.get("bar").asBuilder().setEscrowEnabled(true).build());
runCommand("--type=BRDA", "--escrow_enabled");
assertThat(getStdoutAsLines()).containsExactly("absent bar");
}
}

View file

@ -0,0 +1,39 @@
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.domain.registry.tools;
import com.google.domain.registry.tools.server.ListDomainsAction;
import org.junit.runner.RunWith;
import org.mockito.runners.MockitoJUnitRunner;
/**
* Unit tests for {@link ListDomainsCommand}.
*
* @see ListObjectsCommandTestCase
*/
@RunWith(MockitoJUnitRunner.class)
public class ListDomainsCommandTest extends ListObjectsCommandTestCase<ListDomainsCommand> {
@Override
final String getTaskPath() {
return ListDomainsAction.PATH;
}
@Override
final String getTld() {
return "foo";
}
}

View file

@ -0,0 +1,35 @@
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.domain.registry.tools;
import com.google.domain.registry.tools.server.ListHostsAction;
/**
* Unit tests for {@link ListHostsCommand}.
*
* @see ListObjectsCommandTestCase
*/
public class ListHostsCommandTest extends ListObjectsCommandTestCase<ListHostsCommand> {
@Override
final String getTaskPath() {
return ListHostsAction.PATH;
}
@Override
final String getTld() {
return null;
}
}

View file

@ -0,0 +1,178 @@
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.domain.registry.tools;
import static com.google.domain.registry.request.JsonResponse.JSON_SAFETY_PREFIX;
import static com.google.domain.registry.testing.DatastoreHelper.createTld;
import static com.google.domain.registry.tools.server.ListObjectsAction.FIELDS_PARAM;
import static com.google.domain.registry.tools.server.ListObjectsAction.FULL_FIELD_NAMES_PARAM;
import static com.google.domain.registry.tools.server.ListObjectsAction.PRINT_HEADER_ROW_PARAM;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyMapOf;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import com.google.common.base.Optional;
import com.google.common.collect.ImmutableMap;
import com.google.common.net.MediaType;
import com.google.domain.registry.tools.ServerSideCommand.Connection;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
/** Abstract base class for unit tests of commands that list object data using a back-end task. */
public abstract class ListObjectsCommandTestCase<C extends ListObjectsCommand>
extends CommandTestCase<C> {
@Mock
Connection connection;
/**
* Where to find the servlet task; set by the subclass.
*/
abstract String getTaskPath();
/**
* The TLD to be used (for those subclasses that use TLDs; may be null).
*/
abstract String getTld();
/**
* The TLD argument to be passed on the command line; null if not needed.
*/
String tldArgumentString;
@Before
public void init() throws Exception {
String tld = getTld();
if (tld == null) {
tldArgumentString = null;
} else {
createTld(tld);
tldArgumentString = "--tld=" + tld;
}
command.setConnection(connection);
when(
connection.send(
eq(getTaskPath()),
anyMapOf(String.class, Object.class),
eq(MediaType.PLAIN_TEXT_UTF_8),
any(byte[].class)))
.thenReturn(JSON_SAFETY_PREFIX + "{\"status\":\"success\",\"lines\":[]}");
}
private void verifySent(
String fields,
Optional<Boolean> printHeaderRow,
Optional<Boolean> fullFieldNames) throws Exception {
ImmutableMap.Builder<String, Object> params = ImmutableMap.<String, Object>builder();
if (fields != null) {
params.put(FIELDS_PARAM, fields);
}
if (printHeaderRow.isPresent()) {
params.put(PRINT_HEADER_ROW_PARAM, printHeaderRow.get());
}
if (fullFieldNames.isPresent()) {
params.put(FULL_FIELD_NAMES_PARAM, fullFieldNames.get());
}
String tld = getTld();
if (tld != null) {
params.put("tld", tld);
}
verify(connection).send(
eq(getTaskPath()),
eq(params.build()),
eq(MediaType.PLAIN_TEXT_UTF_8),
eq(new byte[0]));
}
@Test
public void testRun_noFields() throws Exception {
if (tldArgumentString == null) {
runCommand();
} else {
runCommand(tldArgumentString);
}
verifySent(null, Optional.<Boolean>absent(), Optional.<Boolean>absent());
}
@Test
public void testRun_oneField() throws Exception {
if (tldArgumentString == null) {
runCommand("--fields=fieldName");
} else {
runCommand("--fields=fieldName", tldArgumentString);
}
verifySent("fieldName", Optional.<Boolean>absent(), Optional.<Boolean>absent());
}
@Test
public void testRun_wildcardField() throws Exception {
if (tldArgumentString == null) {
runCommand("--fields=*");
} else {
runCommand("--fields=*", tldArgumentString);
}
verifySent("*", Optional.<Boolean>absent(), Optional.<Boolean>absent());
}
@Test
public void testRun_header() throws Exception {
if (tldArgumentString == null) {
runCommand("--fields=fieldName", "--header=true");
} else {
runCommand("--fields=fieldName", "--header=true", tldArgumentString);
}
verifySent("fieldName", Optional.of(Boolean.TRUE), Optional.<Boolean>absent());
}
@Test
public void testRun_noHeader() throws Exception {
if (tldArgumentString == null) {
runCommand("--fields=fieldName", "--header=false");
} else {
runCommand("--fields=fieldName", "--header=false", tldArgumentString);
}
verifySent("fieldName", Optional.of(Boolean.FALSE), Optional.<Boolean>absent());
}
@Test
public void testRun_fullFieldNames() throws Exception {
if (tldArgumentString == null) {
runCommand("--fields=fieldName", "--full_field_names");
} else {
runCommand("--fields=fieldName", "--full_field_names", tldArgumentString);
}
verifySent("fieldName", Optional.<Boolean>absent(), Optional.of(Boolean.TRUE));
}
@Test
public void testRun_allParameters() throws Exception {
if (tldArgumentString == null) {
runCommand("--fields=fieldName,otherFieldName,*", "--header=true", "--full_field_names");
} else {
runCommand(
"--fields=fieldName,otherFieldName,*",
"--header=true",
"--full_field_names",
tldArgumentString);
}
verifySent(
"fieldName,otherFieldName,*", Optional.of(Boolean.TRUE), Optional.of(Boolean.TRUE));
}
}

View file

@ -0,0 +1,36 @@
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.domain.registry.tools;
import com.google.domain.registry.tools.server.ListPremiumListsAction;
/**
* Unit tests for {@link ListPremiumListsCommand}.
*
* @see ListObjectsCommandTestCase
*/
public class ListPremiumListsCommandTest
extends ListObjectsCommandTestCase<ListPremiumListsCommand> {
@Override
final String getTaskPath() {
return ListPremiumListsAction.PATH;
}
@Override
final String getTld() {
return null;
}
}

View file

@ -0,0 +1,36 @@
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.domain.registry.tools;
import com.google.domain.registry.tools.server.ListRegistrarsAction;
/**
* Unit tests for {@link ListRegistrarsCommand}.
*
* @see ListObjectsCommandTestCase
*/
public class ListRegistrarsCommandTest
extends ListObjectsCommandTestCase<ListRegistrarsCommand> {
@Override
final String getTaskPath() {
return ListRegistrarsAction.PATH;
}
@Override
final String getTld() {
return null;
}
}

View file

@ -0,0 +1,36 @@
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.domain.registry.tools;
import com.google.domain.registry.tools.server.ListReservedListsAction;
/**
* Unit tests for {@link ListReservedListsCommand}.
*
* @see ListObjectsCommandTestCase
*/
public class ListReservedListsCommandTest
extends ListObjectsCommandTestCase<ListReservedListsCommand> {
@Override
final String getTaskPath() {
return ListReservedListsAction.PATH;
}
@Override
final String getTld() {
return null;
}
}

View file

@ -0,0 +1,36 @@
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.domain.registry.tools;
import com.google.domain.registry.tools.server.ListTldsAction;
/**
* Unit tests for {@link ListTldsCommand}.
*
* @see ListObjectsCommandTestCase
*/
public class ListTldsCommandTest
extends ListObjectsCommandTestCase<ListTldsCommand> {
@Override
final String getTaskPath() {
return ListTldsAction.PATH;
}
@Override
final String getTld() {
return null;
}
}

View file

@ -0,0 +1,428 @@
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.domain.registry.tools;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
import static com.google.domain.registry.model.ofy.ObjectifyService.ofy;
import static com.google.domain.registry.testing.DatastoreHelper.createTld;
import static com.google.domain.registry.testing.DatastoreHelper.deleteResource;
import static com.google.domain.registry.testing.DatastoreHelper.persistActiveHost;
import static com.google.domain.registry.testing.DatastoreHelper.persistResource;
import static org.joda.time.DateTimeZone.UTC;
import com.google.domain.registry.model.host.HostResource;
import com.google.domain.registry.model.registrar.Registrar;
import com.google.domain.registry.testing.AppEngineRule;
import com.google.domain.registry.testing.ExceptionRule;
import org.joda.time.DateTime;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.runners.MockitoJUnitRunner;
import java.util.Arrays;
/** Unit tests for {@link MutatingCommand}. */
@RunWith(MockitoJUnitRunner.class)
public class MutatingCommandTest {
@Rule
public final AppEngineRule appEngine = AppEngineRule.builder()
.withDatastore()
.build();
@Rule
public final ExceptionRule thrown = new ExceptionRule();
Registrar registrar1;
Registrar registrar2;
Registrar newRegistrar1;
Registrar newRegistrar2;
HostResource host1;
HostResource host2;
HostResource newHost1;
HostResource newHost2;
@Before
public void init() {
registrar1 = persistResource(new Registrar.Builder()
.setType(Registrar.Type.REAL)
.setClientIdentifier("Registrar1")
.setIanaIdentifier(1L)
.build());
registrar2 = persistResource(new Registrar.Builder()
.setType(Registrar.Type.REAL)
.setClientIdentifier("Registrar2")
.setIanaIdentifier(2L)
.build());
newRegistrar1 = registrar1.asBuilder().setBillingIdentifier(42L).build();
newRegistrar2 = registrar2.asBuilder().setBlockPremiumNames(true).build();
createTld("tld");
host1 = persistActiveHost("host1.example.tld");
host2 = persistActiveHost("host2.example.tld");
newHost1 = host1.asBuilder()
.setLastEppUpdateTime(DateTime.parse("2014-09-09T09:09:09.000Z"))
.build();
newHost2 = host2.asBuilder().setCurrentSponsorClientId("Registrar2").build();
}
@Test
public void testSuccess_noChanges() throws Exception {
MutatingCommand command = new MutatingCommand() {
@Override
protected void init() {}
};
command.init();
assertThat(command.prompt()).isEqualTo("No entity changes to apply.");
assertThat(command.execute()).isEqualTo("Updated 0 entities.\n");
}
@Test
public void testSuccess_update() throws Exception {
MutatingCommand command = new MutatingCommand() {
@Override
public void init() {
stageEntityChange(host1, newHost1);
stageEntityChange(host2, newHost2);
stageEntityChange(registrar1, newRegistrar1);
stageEntityChange(registrar2, newRegistrar2);
}
};
command.init();
String changes = command.prompt();
assertThat(changes).isEqualTo(
"Update HostResource@2-ROID\n"
+ "lastEppUpdateTime -> [null, 2014-09-09T09:09:09.000Z]\n"
+ "\n"
+ "Update HostResource@3-ROID\n"
+ "currentSponsorClientId -> [TheRegistrar, Registrar2]\n"
+ "\n"
+ "Update Registrar@Registrar1\n"
+ "billingIdentifier -> [null, 42]\n"
+ "\n"
+ "Update Registrar@Registrar2\n"
+ "blockPremiumNames -> [false, true]\n");
String results = command.execute();
assertThat(results).isEqualTo("Updated 4 entities.\n");
assertThat(ofy().load().entity(host1).now()).isEqualTo(newHost1);
assertThat(ofy().load().entity(host2).now()).isEqualTo(newHost2);
assertThat(ofy().load().entity(registrar1).now()).isEqualTo(newRegistrar1);
assertThat(ofy().load().entity(registrar2).now()).isEqualTo(newRegistrar2);
}
@Test
public void testSuccess_create() throws Exception {
ofy().deleteWithoutBackup().entities(Arrays.asList(host1, host2, registrar1, registrar2));
MutatingCommand command = new MutatingCommand() {
@Override
protected void init() {
stageEntityChange(null, newHost1);
stageEntityChange(null, newHost2);
stageEntityChange(null, newRegistrar1);
stageEntityChange(null, newRegistrar2);
}
};
command.init();
String changes = command.prompt();
assertThat(changes).isEqualTo(
"Create HostResource@2-ROID\n"
+ newHost1 + "\n"
+ "\n"
+ "Create HostResource@3-ROID\n"
+ newHost2 + "\n"
+ "\n"
+ "Create Registrar@Registrar1\n"
+ newRegistrar1 + "\n"
+ "\n"
+ "Create Registrar@Registrar2\n"
+ newRegistrar2 + "\n");
String results = command.execute();
assertThat(results).isEqualTo("Updated 4 entities.\n");
assertThat(ofy().load().entity(newHost1).now()).isEqualTo(newHost1);
assertThat(ofy().load().entity(newHost2).now()).isEqualTo(newHost2);
assertThat(ofy().load().entity(newRegistrar1).now()).isEqualTo(newRegistrar1);
assertThat(ofy().load().entity(newRegistrar2).now()).isEqualTo(newRegistrar2);
}
@Test
public void testSuccess_delete() throws Exception {
MutatingCommand command = new MutatingCommand() {
@Override
protected void init() {
stageEntityChange(host1, null);
stageEntityChange(host2, null);
stageEntityChange(registrar1, null);
stageEntityChange(registrar2, null);
}
};
command.init();
String changes = command.prompt();
assertThat(changes).isEqualTo(
"Delete HostResource@2-ROID\n"
+ host1 + "\n"
+ "\n"
+ "Delete HostResource@3-ROID\n"
+ host2 + "\n"
+ "\n"
+ "Delete Registrar@Registrar1\n"
+ registrar1 + "\n"
+ "\n"
+ "Delete Registrar@Registrar2\n"
+ registrar2 + "\n");
String results = command.execute();
assertThat(results).isEqualTo("Updated 4 entities.\n");
assertThat(ofy().load().entity(host1).now()).isNull();
assertThat(ofy().load().entity(host2).now()).isNull();
assertThat(ofy().load().entity(registrar1).now()).isNull();
assertThat(ofy().load().entity(registrar2).now()).isNull();
}
@Test
public void testSuccess_noopUpdate() throws Exception {
MutatingCommand command = new MutatingCommand() {
@Override
protected void init() {
stageEntityChange(host1, host1);
stageEntityChange(registrar1, registrar1);
}
};
command.init();
String changes = command.prompt();
System.out.println(changes);
assertThat(changes).isEqualTo(
"Update HostResource@2-ROID\n"
+ "[no changes]\n"
+ "\n"
+ "Update Registrar@Registrar1\n"
+ "[no changes]\n");
String results = command.execute();
assertThat(results).isEqualTo("Updated 2 entities.\n");
assertThat(ofy().load().entity(host1).now()).isEqualTo(host1);
assertThat(ofy().load().entity(registrar1).now()).isEqualTo(registrar1);
}
@Test
public void testSuccess_batching() throws Exception {
MutatingCommand command = new MutatingCommand() {
@Override
protected void init() {
stageEntityChange(host1, null);
stageEntityChange(host2, newHost2);
flushTransaction();
flushTransaction(); // Flushing should be idempotent.
stageEntityChange(registrar1, null);
stageEntityChange(registrar2, newRegistrar2);
// Even though there is no trailing flushTransaction(), these last two should be executed.
}
};
command.init();
String changes = command.prompt();
assertThat(changes).isEqualTo(
"Delete HostResource@2-ROID\n"
+ host1 + "\n"
+ "\n"
+ "Update HostResource@3-ROID\n"
+ "currentSponsorClientId -> [TheRegistrar, Registrar2]\n"
+ "\n"
+ "Delete Registrar@Registrar1\n"
+ registrar1 + "\n"
+ "\n"
+ "Update Registrar@Registrar2\n"
+ "blockPremiumNames -> [false, true]\n");
String results = command.execute();
assertThat(results).isEqualTo("Updated 4 entities.\n");
assertThat(ofy().load().entity(host1).now()).isNull();
assertThat(ofy().load().entity(host2).now()).isEqualTo(newHost2);
assertThat(ofy().load().entity(registrar1).now()).isNull();
assertThat(ofy().load().entity(registrar2).now()).isEqualTo(newRegistrar2);
}
@Test
public void testSuccess_batching_partialExecutionWorks() throws Exception {
// The expected behavior here is that the first transaction will work and be committed, and
// the second transaction will throw an IllegalStateException and not commit.
MutatingCommand command = new MutatingCommand() {
@Override
protected void init() {
stageEntityChange(host1, null);
stageEntityChange(host2, newHost2);
flushTransaction();
stageEntityChange(registrar1, null);
stageEntityChange(registrar2, newRegistrar2); // This will fail.
flushTransaction();
}
};
command.init();
// Save an update to registrar2 that will cause the second transaction to fail because the
// resource has been updated since the command inited the resources to process.
registrar2 = persistResource(registrar2.asBuilder().setContactsRequireSyncing(false).build());
String changes = command.prompt();
assertThat(changes).isEqualTo(
"Delete HostResource@2-ROID\n"
+ host1 + "\n"
+ "\n"
+ "Update HostResource@3-ROID\n"
+ "currentSponsorClientId -> [TheRegistrar, Registrar2]\n"
+ "\n"
+ "Delete Registrar@Registrar1\n"
+ registrar1 + "\n"
+ "\n"
+ "Update Registrar@Registrar2\n"
+ "blockPremiumNames -> [false, true]\n");
try {
command.execute();
} catch (IllegalStateException e) {
assertThat(e.getMessage()).contains("Entity changed since init() was called.");
assertThat(ofy().load().entity(host1).now()).isNull();
assertThat(ofy().load().entity(host2).now()).isEqualTo(newHost2);
// These two shouldn't've changed.
assertThat(ofy().load().entity(registrar1).now()).isEqualTo(registrar1);
assertThat(ofy().load().entity(registrar2).now()).isEqualTo(registrar2);
return;
}
assertWithMessage("Expected transaction to fail with IllegalStateException").fail();
}
@Test
public void testFailure_nullEntityChange() throws Exception {
thrown.expect(IllegalArgumentException.class);
MutatingCommand command = new MutatingCommand() {
@Override
protected void init() {
stageEntityChange(null, null);
}
};
command.init();
}
@Test
public void testFailure_updateSameEntityTwice() throws Exception {
MutatingCommand command = new MutatingCommand() {
@Override
protected void init() {
stageEntityChange(host1, newHost1);
stageEntityChange(host1, host1.asBuilder()
.setLastEppUpdateTime(DateTime.now(UTC))
.build());
}
};
thrown.expect(
IllegalArgumentException.class, "Cannot apply multiple changes for the same entity");
command.init();
}
@Test
public void testFailure_updateDifferentLongId() throws Exception {
MutatingCommand command = new MutatingCommand() {
@Override
protected void init() {
stageEntityChange(host1, host2);
}
};
thrown.expect(
IllegalArgumentException.class,
"Both entity versions in an update must have the same Key.");
command.init();
}
@Test
public void testFailure_updateDifferentStringId() throws Exception {
MutatingCommand command = new MutatingCommand() {
@Override
public void init() {
stageEntityChange(registrar1, registrar2);
}
};
thrown.expect(
IllegalArgumentException.class,
"Both entity versions in an update must have the same Key.");
command.init();
}
@Test
public void testFailure_updateDifferentKind() throws Exception {
MutatingCommand command = new MutatingCommand() {
@Override
public void init() {
stageEntityChange(host1, registrar1);
}
};
thrown.expect(
IllegalArgumentException.class,
"Both entity versions in an update must have the same Key.");
command.init();
}
@Test
public void testFailure_updateModifiedEntity() throws Exception {
MutatingCommand command = new MutatingCommand() {
@Override
public void init() {
stageEntityChange(host1, newHost1);
}
};
command.init();
persistResource(newHost1);
thrown.expect(IllegalStateException.class, "Entity changed since init() was called.");
command.execute();
}
@Test
public void testFailure_createExistingEntity() throws Exception {
MutatingCommand command = new MutatingCommand() {
@Override
protected void init() {
stageEntityChange(null, newHost1);
}
};
command.init();
persistResource(newHost1);
thrown.expect(IllegalStateException.class, "Entity changed since init() was called.");
command.execute();
}
@Test
public void testFailure_deleteChangedEntity() throws Exception {
MutatingCommand command = new MutatingCommand() {
@Override
protected void init() {
stageEntityChange(host1, null);
}
};
command.init();
persistResource(newHost1);
thrown.expect(IllegalStateException.class, "Entity changed since init() was called.");
command.execute();
}
@Test
public void testFailure_deleteRemovedEntity() throws Exception {
MutatingCommand command = new MutatingCommand() {
@Override
protected void init() {
stageEntityChange(host1, null);
}
};
command.init();
deleteResource(host1);
thrown.expect(IllegalStateException.class, "Entity changed since init() was called.");
command.execute();
}
}

View file

@ -0,0 +1,96 @@
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.domain.registry.tools;
import static org.mockito.Matchers.anyMapOf;
import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import com.google.common.collect.ImmutableMap;
import com.google.domain.registry.tools.ServerSideCommand.Connection;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
/** Unit tests for {@link PublishDetailReportCommand}. */
public class PublishDetailReportCommandTest extends CommandTestCase<PublishDetailReportCommand> {
@Mock
private Connection connection;
@Before
public void init() throws Exception {
command.setConnection(connection);
when(connection.sendJson(anyString(), anyMapOf(String.class, Object.class)))
.thenReturn(ImmutableMap.<String, Object>of("driveId", "some123id"));
}
@Test
public void testSuccess_normalUsage() throws Exception {
runCommandForced(
"--registrar_id=TheRegistrar",
"--report_name=report.csv",
"--gcs_bucket=mah-buckit",
"--gcs_folder=some/folder");
verify(connection).sendJson(
eq("/_dr/publishDetailReport"),
eq(ImmutableMap.of(
"registrar", "TheRegistrar",
"report", "report.csv",
"gcsFolder", "some/folder/",
"bucket", "mah-buckit")));
assertInStdout("Success!");
assertInStdout("some123id");
}
@Test
public void testSuccess_gcsFolderWithTrailingSlash() throws Exception {
runCommandForced(
"--registrar_id=TheRegistrar",
"--report_name=report.csv",
"--gcs_bucket=mah-buckit",
"--gcs_folder=some/folder/");
verify(connection).sendJson(
eq("/_dr/publishDetailReport"),
eq(ImmutableMap.of(
"registrar", "TheRegistrar",
"report", "report.csv",
"gcsFolder", "some/folder/",
"bucket", "mah-buckit")));
assertInStdout("Success!");
assertInStdout("some123id");
}
@Test
public void testSuccess_emptyGcsFolder() throws Exception {
runCommandForced(
"--registrar_id=TheRegistrar",
"--report_name=report.csv",
"--gcs_bucket=mah-buckit",
"--gcs_folder=");
verify(connection).sendJson(
eq("/_dr/publishDetailReport"),
eq(ImmutableMap.of(
"registrar", "TheRegistrar",
"report", "report.csv",
"gcsFolder", "",
"bucket", "mah-buckit")));
assertInStdout("Success!");
assertInStdout("some123id");
}
}

View file

@ -0,0 +1,195 @@
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.domain.registry.tools;
import static com.google.common.truth.Truth.assertThat;
import static com.google.domain.registry.model.registrar.RegistrarContact.Type.ABUSE;
import static com.google.domain.registry.model.registrar.RegistrarContact.Type.ADMIN;
import static com.google.domain.registry.model.registrar.RegistrarContact.Type.WHOIS;
import static com.google.domain.registry.testing.DatastoreHelper.persistSimpleGlobalResources;
import static java.nio.charset.StandardCharsets.UTF_8;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.domain.registry.model.registrar.Registrar;
import com.google.domain.registry.model.registrar.RegistrarContact;
import org.junit.Before;
import org.junit.Test;
import java.nio.file.Files;
import java.nio.file.Paths;
/** Unit tests for {@link RegistrarContactCommand}. */
public class RegistrarContactCommandTest extends CommandTestCase<RegistrarContactCommand> {
private String output;
@Before
public void before() throws Exception {
output = tmpDir.newFile().toString();
}
@Test
public void testList() throws Exception {
Registrar registrar = Registrar.loadByClientId("NewRegistrar");
RegistrarContact.updateContacts(registrar, ImmutableSet.of(
new RegistrarContact.Builder()
.setParent(registrar)
.setName("John Doe")
.setEmailAddress("john.doe@example.com")
.setTypes(ImmutableSet.of(ADMIN))
.setVisibleInWhoisAsAdmin(true)
.build()));
runCommand("-f", "--mode=LIST", "--output=" + output, "NewRegistrar");
assertThat(Files.readAllLines(Paths.get(output), UTF_8)).containsExactly(
"John Doe",
"john.doe@example.com",
"Types: [ADMIN]",
"Visible in WHOIS as Admin contact: Yes",
"Visible in WHOIS as Technical contact: No");
}
@Test
public void testUpdate() throws Exception {
Registrar registrar = Registrar.loadByClientId("NewRegistrar");
ImmutableList<RegistrarContact> contacts = ImmutableList.of(
new RegistrarContact.Builder()
.setParent(registrar)
.setName("Judith Doe")
.setEmailAddress("judith.doe@example.com")
.setTypes(ImmutableSet.of(WHOIS))
.setVisibleInWhoisAsAdmin(true)
.setVisibleInWhoisAsTech(true)
.build());
persistSimpleGlobalResources(contacts);
runCommand(
"--force",
"--mode=UPDATE",
"--name=Judith Registrar",
"--email=judith.doe@example.com",
"--phone=+1.2125650000",
"--fax=+1.2125650001",
"--contact_type=WHOIS",
"--visible_in_whois_as_admin=true",
"--visible_in_whois_as_tech=true",
"NewRegistrar");
RegistrarContact registrarContact =
Registrar.loadByClientId("NewRegistrar").getContacts().asList().get(1);
assertThat(registrarContact).isEqualTo(
new RegistrarContact.Builder()
.setParent(registrar)
.setName("Judith Registrar")
.setEmailAddress("judith.doe@example.com")
.setPhoneNumber("+1.2125650000")
.setFaxNumber("+1.2125650001")
.setTypes(ImmutableSet.of(WHOIS))
.setVisibleInWhoisAsAdmin(true)
.setVisibleInWhoisAsTech(true)
.build());
}
@Test
public void testUpdate_enableConsoleAccess() throws Exception {
Registrar registrar = Registrar.loadByClientId("NewRegistrar");
persistSimpleGlobalResources(ImmutableList.of(
new RegistrarContact.Builder()
.setParent(registrar)
.setName("Jane Doe")
.setEmailAddress("jane.doe@example.com")
.build()));
runCommand(
"--force",
"--mode=UPDATE",
"--email=jane.doe@example.com",
"--allow_console_access=true",
"NewRegistrar");
RegistrarContact registrarContact =
Registrar.loadByClientId("NewRegistrar").getContacts().asList().get(1);
assertThat(registrarContact.getGaeUserId()).matches("-?[0-9]+");
}
@Test
public void testUpdate_disableConsoleAccess() throws Exception {
Registrar registrar = Registrar.loadByClientId("NewRegistrar");
persistSimpleGlobalResources(ImmutableList.of(
new RegistrarContact.Builder()
.setParent(registrar)
.setName("Judith Doe")
.setEmailAddress("judith.doe@example.com")
.setGaeUserId("11111")
.build()));
runCommand(
"--force",
"--mode=UPDATE",
"--email=judith.doe@example.com",
"--allow_console_access=false",
"NewRegistrar");
RegistrarContact registrarContact =
Registrar.loadByClientId("NewRegistrar").getContacts().asList().get(1);
assertThat(registrarContact.getGaeUserId()).isNull();
}
@Test
public void testCreate_withAdminType() throws Exception {
Registrar registrar = Registrar.loadByClientId("NewRegistrar");
runCommand(
"--force",
"--mode=CREATE",
"--name=Jim Doe",
"--email=jim.doe@example.com",
"--contact_type=ADMIN,ABUSE",
"--visible_in_whois_as_admin=true",
"--visible_in_whois_as_tech=true",
"NewRegistrar");
RegistrarContact registrarContact =
Registrar.loadByClientId("NewRegistrar").getContacts().asList().get(1);
assertThat(registrarContact).isEqualTo(
new RegistrarContact.Builder()
.setParent(registrar)
.setName("Jim Doe")
.setEmailAddress("jim.doe@example.com")
.setTypes(ImmutableSet.of(ADMIN, ABUSE))
.setVisibleInWhoisAsAdmin(true)
.setVisibleInWhoisAsTech(true)
.build());
assertThat(registrarContact.getGaeUserId()).isNull();
}
@Test
public void testDelete() throws Exception {
runCommand(
"--force",
"--mode=DELETE",
"--email=janedoe@theregistrar.com",
"NewRegistrar");
assertThat(Registrar.loadByClientId("NewRegistrar").getContacts()).isEmpty();
}
@Test
public void testCreate_withConsoleAccessEnabled() throws Exception {
runCommand(
"--force",
"--mode=CREATE",
"--name=Jim Doe",
"--email=jim.doe@example.com",
"--allow_console_access=true",
"--contact_type=ADMIN,ABUSE",
"NewRegistrar");
RegistrarContact registrarContact =
Registrar.loadByClientId("NewRegistrar").getContacts().asList().get(1);
assertThat(registrarContact.getGaeUserId()).matches("-?[0-9]+");
}
}

View file

@ -0,0 +1,112 @@
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.domain.registry.tools;
import static com.google.common.truth.Truth.assertThat;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
/** Unit tests for {@link RegistryToolEnvironment}. */
@RunWith(JUnit4.class)
public class RegistryToolEnvironmentTest {
@Rule
public final ExpectedException thrown = ExpectedException.none();
@Test
public void testGet_withoutSetup_throws() throws Exception {
thrown.expect(IllegalStateException.class);
RegistryToolEnvironment.get();
}
@Test
public void testSetup_changesEnvironmentReturnedByGet() throws Exception {
RegistryToolEnvironment.UNITTEST.setup();
assertThat(RegistryToolEnvironment.get()).isEqualTo(RegistryToolEnvironment.UNITTEST);
RegistryToolEnvironment.ALPHA.setup();
assertThat(RegistryToolEnvironment.get()).isEqualTo(RegistryToolEnvironment.ALPHA);
}
@Test
public void testFromArgs_shortNotation_works() throws Exception {
assertThat(RegistryToolEnvironment.parseFromArgs(new String[] { "-e", "alpha" }))
.isEqualTo(RegistryToolEnvironment.ALPHA);
}
@Test
public void testFromArgs_longNotation_works() throws Exception {
assertThat(RegistryToolEnvironment.parseFromArgs(new String[] { "--environment", "alpha" }))
.isEqualTo(RegistryToolEnvironment.ALPHA);
}
@Test
public void testFromArgs_uppercase_works() throws Exception {
assertThat(RegistryToolEnvironment.parseFromArgs(new String[] { "-e", "QA" }))
.isEqualTo(RegistryToolEnvironment.QA);
}
@Test
public void testFromArgs_equalsNotation_works() throws Exception {
assertThat(RegistryToolEnvironment.parseFromArgs(new String[] { "-e=sandbox" }))
.isEqualTo(RegistryToolEnvironment.SANDBOX);
assertThat(RegistryToolEnvironment.parseFromArgs(new String[] { "--environment=sandbox" }))
.isEqualTo(RegistryToolEnvironment.SANDBOX);
}
@Test
public void testFromArgs_envFlagAfterCommandName_getsIgnored() throws Exception {
thrown.expect(IllegalArgumentException.class);
RegistryToolEnvironment.parseFromArgs(new String[] {
"registrar_activity_report",
"-e", "1406851199"});
}
@Test
public void testFromArgs_missingEnvironmentFlag_throwsIae() throws Exception {
thrown.expect(IllegalArgumentException.class);
RegistryToolEnvironment.parseFromArgs(new String[] {});
}
@Test
public void testFromArgs_extraEnvFlagAfterCommandName_getsIgnored() throws Exception {
String[] args = new String[] {
"-e", "alpha",
"registrar_activity_report",
"-e", "1406851199"};
assertThat(RegistryToolEnvironment.parseFromArgs(args))
.isEqualTo(RegistryToolEnvironment.ALPHA);
}
@Test
public void testFromArgs_loggingFlagWithUnderscores_isntConsideredCommand() throws Exception {
String[] args = new String[] {
"--logging_properties_file", "my_file.properties",
"-e", "alpha",
"list_tlds"};
assertThat(RegistryToolEnvironment.parseFromArgs(args))
.isEqualTo(RegistryToolEnvironment.ALPHA);
}
@Test
public void testFromArgs_badName_throwsIae() throws Exception {
thrown.expect(IllegalArgumentException.class);
RegistryToolEnvironment.parseFromArgs(new String[] { "-e", "alphaville" });
}
}

View file

@ -0,0 +1,103 @@
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.domain.registry.tools;
import static com.google.common.base.CaseFormat.LOWER_UNDERSCORE;
import static com.google.common.base.CaseFormat.UPPER_CAMEL;
import static com.google.common.reflect.Reflection.getPackageName;
import static com.google.common.truth.Truth.assertWithMessage;
import com.google.common.base.Joiner;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Sets;
import com.google.common.reflect.ClassPath;
import com.google.common.reflect.ClassPath.ClassInfo;
import com.google.common.truth.Expect;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import java.io.IOException;
import java.lang.reflect.Modifier;
import java.util.Map;
import java.util.Set;
/** Unit tests for {@link RegistryTool}. */
@RunWith(JUnit4.class)
public class RegistryToolTest {
@Rule
public final ExpectedException thrown = ExpectedException.none();
@Rule
public final Expect expect = Expect.create();
@Before
public void init() {
RegistryToolEnvironment.UNITTEST.setup();
}
@Test
public void testThatAllCommandsAreInCliOptions() throws Exception {
Set<Class<? extends Command>> commandMapClasses =
ImmutableSet.copyOf(RegistryTool.COMMAND_MAP.values());
Set<Class<? extends Command>> commandsWithoutCliInvokers =
Sets.difference(getAllCommandClasses(), commandMapClasses);
String errorMsg =
"These Command classes are missing from RegistryTool.COMMAND_MAP: "
+ Joiner.on(", ").join(commandsWithoutCliInvokers);
assertWithMessage(errorMsg).that(commandsWithoutCliInvokers).isEmpty();
}
@Test
public void testThatCommandNamesAreDerivedFromClassNames() throws Exception {
for (Map.Entry<String, ? extends Class<? extends Command>> commandEntry :
RegistryTool.COMMAND_MAP.entrySet()) {
String className = commandEntry.getValue().getSimpleName();
expect.that(commandEntry.getKey())
// JCommander names should match the class name, up to "Command" and case formatting.
.isEqualTo(UPPER_CAMEL.to(LOWER_UNDERSCORE, className.replaceFirst("Command$", "")));
}
}
/**
* Gets the set of all non-abstract classes implementing the {@link Command} interface (abstract
* class and interface subtypes of Command aren't expected to have cli commands). Note that this
* also filters out HelpCommand, which has special handling in {@link RegistryCli} and isn't in
* the command map.
*
* @throws IOException if reading the classpath resources fails.
*/
@SuppressWarnings("unchecked")
private ImmutableSet<Class<? extends Command>> getAllCommandClasses() throws IOException {
ImmutableSet.Builder<Class<? extends Command>> builder = new ImmutableSet.Builder<>();
for (ClassInfo classInfo : ClassPath
.from(getClass().getClassLoader())
.getTopLevelClasses(getPackageName(getClass()))) {
Class<?> clazz = classInfo.load();
if (Command.class.isAssignableFrom(clazz)
&& !Modifier.isAbstract(clazz.getModifiers())
&& !Modifier.isInterface(clazz.getModifiers())
&& !clazz.equals(HelpCommand.class)) {
builder.add((Class<? extends Command>) clazz);
}
}
return builder.build();
}
}

View file

@ -0,0 +1,87 @@
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.domain.registry.tools;
import static com.google.common.collect.Iterables.getOnlyElement;
import static com.google.common.collect.Iterables.transform;
import static com.google.common.truth.Truth.assertThat;
import static com.google.domain.registry.model.ofy.ObjectifyService.ofy;
import static com.google.domain.registry.testing.DatastoreHelper.createTld;
import com.google.common.base.Function;
import com.google.domain.registry.model.ImmutableObject;
import com.google.domain.registry.model.ofy.CommitLogManifest;
import com.google.domain.registry.model.ofy.CommitLogMutation;
import com.google.domain.registry.model.registrar.Registrar;
import com.google.domain.registry.model.registrar.RegistrarContact;
import com.google.domain.registry.model.registry.Registry;
import org.junit.Test;
/** Unit tests for {@link ResaveEnvironmentEntitiesCommand}. */
public class ResaveEnvironmentEntitiesCommandTest
extends CommandTestCase<ResaveEnvironmentEntitiesCommand> {
@Test
public void testSuccess_noop() throws Exception {
// Get rid of all the entities that this command runs on so that it does nothing.
deleteEntitiesOfTypes(
Registry.class,
Registrar.class,
RegistrarContact.class,
CommitLogManifest.class,
CommitLogMutation.class);
runCommand();
assertThat(ofy().load().type(CommitLogManifest.class).keys()).isEmpty();
assertThat(ofy().load().type(CommitLogMutation.class).keys()).isEmpty();
}
@Test
public void testSuccess_createsCommitLogs() throws Exception {
createTld("tld");
deleteEntitiesOfTypes(CommitLogManifest.class, CommitLogMutation.class);
assertThat(ofy().load().type(CommitLogManifest.class).keys()).isEmpty();
assertThat(ofy().load().type(CommitLogMutation.class).keys()).isEmpty();
runCommand();
// There are five entities that have been re-saved at this point (each in a separate
// transaction), so expect five manifests and five mutations.
assertThat(ofy().load().type(CommitLogManifest.class).keys()).hasSize(5);
Iterable<ImmutableObject> savedEntities =
transform(
ofy().load().type(CommitLogMutation.class).list(),
new Function<CommitLogMutation, ImmutableObject>() {
@Override
public ImmutableObject apply(CommitLogMutation mutation) {
return ofy().load().fromEntity(mutation.getEntity());
}
});
assertThat(savedEntities)
.containsExactly(
// The Registrars and RegistrarContacts are created by AppEngineRule.
Registrar.loadByClientId("TheRegistrar"),
Registrar.loadByClientId("NewRegistrar"),
Registry.get("tld"),
getOnlyElement(Registrar.loadByClientId("TheRegistrar").getContacts()),
getOnlyElement(Registrar.loadByClientId("NewRegistrar").getContacts()));
}
@SafeVarargs
private static void deleteEntitiesOfTypes(Class<? extends ImmutableObject>... types) {
for (Class<? extends ImmutableObject> type : types) {
ofy().deleteWithoutBackup().keys(ofy().load().type(type).keys()).now();
}
}
}

View file

@ -0,0 +1,294 @@
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.domain.registry.tools;
import static com.google.common.truth.Truth.assertThat;
import static com.google.domain.registry.model.registrar.Registrar.State.ACTIVE;
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.DatastoreHelper.createTld;
import static com.google.domain.registry.testing.DatastoreHelper.persistPremiumList;
import static com.google.domain.registry.testing.DatastoreHelper.persistResource;
import static org.joda.time.DateTimeZone.UTC;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.domain.registry.model.registrar.Registrar;
import com.google.domain.registry.model.registry.Registry;
import com.google.domain.registry.model.registry.Registry.TldState;
import com.google.domain.registry.util.CidrAddressBlock;
import com.beust.jcommander.ParameterException;
import org.joda.time.DateTime;
import org.joda.time.Duration;
import org.junit.Before;
import org.junit.Test;
import java.security.cert.CertificateParsingException;
/** Unit tests for {@link SetupOteCommand}. */
public class SetupOteCommandTest extends CommandTestCase<SetupOteCommand> {
ImmutableList<String> passwords = ImmutableList.of(
"abcdefghijklmnop", "qrstuvwxyzabcdef", "ghijklmnopqrstuv", "wxyzabcdefghijkl");
FakePasswordGenerator passwordGenerator = new FakePasswordGenerator("abcdefghijklmnopqrstuvwxyz");
@Before
public void init() {
command.passwordGenerator = passwordGenerator;
persistPremiumList("default_sandbox_list", "sandbox,USD 1000");
persistPremiumList("alternate_list", "rich,USD 3000");
}
/** Verify TLD creation. */
private void verifyTldCreation(
String tldName,
String roidSuffix,
TldState tldState,
String premiumList,
Duration addGracePeriodLength,
Duration redemptionGracePeriodLength,
Duration pendingDeleteLength) {
Registry registry = Registry.get(tldName);
assertThat(registry).isNotNull();
assertThat(registry.getRoidSuffix()).isEqualTo(roidSuffix);
assertThat(registry.getTldState(DateTime.now(UTC))).isEqualTo(tldState);
assertThat(registry.getPremiumList()).isNotNull();
assertThat(registry.getPremiumList().getName()).isEqualTo(premiumList);
assertThat(registry.getAddGracePeriodLength()).isEqualTo(addGracePeriodLength);
assertThat(registry.getRedemptionGracePeriodLength()).isEqualTo(redemptionGracePeriodLength);
assertThat(registry.getPendingDeleteLength()).isEqualTo(pendingDeleteLength);
}
/** Verify TLD creation with registry default durations. */
private void verifyTldCreation(
String tldName, String roidSuffix, TldState tldState, String premiumList) {
verifyTldCreation(
tldName,
roidSuffix,
tldState,
premiumList,
Registry.DEFAULT_ADD_GRACE_PERIOD,
Registry.DEFAULT_REDEMPTION_GRACE_PERIOD,
Registry.DEFAULT_PENDING_DELETE_LENGTH);
}
private void verifyRegistrarCreation(
String registrarName,
String allowedTld,
String password,
ImmutableList<CidrAddressBlock> ipWhitelist) {
Registrar registrar = Registrar.loadByClientId(registrarName);
assertThat(registrar).isNotNull();
assertThat(registrar.getAllowedTlds()).containsExactlyElementsIn(ImmutableSet.of(allowedTld));
assertThat(registrar.getRegistrarName()).isEqualTo(registrarName);
assertThat(registrar.getState()).isEqualTo(ACTIVE);
assertThat(registrar.testPassword(password)).isTrue();
assertThat(registrar.getIpAddressWhitelist()).isEqualTo(ipWhitelist);
assertThat(registrar.getClientCertificate()).isEqualTo(SAMPLE_CERT);
assertThat(registrar.getClientCertificateHash()).isEqualTo(SAMPLE_CERT_HASH);
}
@Test
public void testSuccess() throws Exception {
runCommandForced(
"--ip_whitelist=1.1.1.1",
"--registrar=blobio",
"--certfile=" + getCertFilename());
verifyTldCreation("blobio-sunrise", "BLOBIOS0", TldState.SUNRISE, "default_sandbox_list");
verifyTldCreation("blobio-landrush", "BLOBIOL1", TldState.LANDRUSH, "default_sandbox_list");
verifyTldCreation(
"blobio-ga",
"BLOBIOG2",
TldState.GENERAL_AVAILABILITY,
"default_sandbox_list",
Duration.standardMinutes(60),
Duration.standardMinutes(10),
Duration.standardMinutes(5));
ImmutableList<CidrAddressBlock> ipAddress = ImmutableList.of(
CidrAddressBlock.create("1.1.1.1"));
verifyRegistrarCreation("blobio-1", "blobio-sunrise", passwords.get(0), ipAddress);
verifyRegistrarCreation("blobio-2", "blobio-landrush", passwords.get(1), ipAddress);
verifyRegistrarCreation("blobio-3", "blobio-ga", passwords.get(2), ipAddress);
verifyRegistrarCreation("blobio-4", "blobio-ga", passwords.get(3), ipAddress);
}
@Test
public void testSuccess_multipleIps() throws Exception {
runCommandForced(
"--ip_whitelist=1.1.1.1,2.2.2.2",
"--registrar=blobio",
"--certfile=" + getCertFilename());
verifyTldCreation("blobio-sunrise", "BLOBIOS0", TldState.SUNRISE, "default_sandbox_list");
verifyTldCreation("blobio-landrush", "BLOBIOL1", TldState.LANDRUSH, "default_sandbox_list");
verifyTldCreation(
"blobio-ga",
"BLOBIOG2",
TldState.GENERAL_AVAILABILITY,
"default_sandbox_list",
Duration.standardMinutes(60),
Duration.standardMinutes(10),
Duration.standardMinutes(5));
ImmutableList<CidrAddressBlock> ipAddresses = ImmutableList.of(
CidrAddressBlock.create("1.1.1.1"),
CidrAddressBlock.create("2.2.2.2"));
verifyRegistrarCreation("blobio-1", "blobio-sunrise", passwords.get(0), ipAddresses);
verifyRegistrarCreation("blobio-2", "blobio-landrush", passwords.get(1), ipAddresses);
verifyRegistrarCreation("blobio-3", "blobio-ga", passwords.get(2), ipAddresses);
verifyRegistrarCreation("blobio-4", "blobio-ga", passwords.get(3), ipAddresses);
}
public void testSuccess_alternatePremiumList() throws Exception {
runCommandForced(
"--ip_whitelist=1.1.1.1",
"--registrar=blobio",
"--certfile=" + getCertFilename(),
"--premium_list=alternate_list");
verifyTldCreation("blobio-sunrise", "BLOBIOS0", TldState.SUNRISE, "alternate_list");
verifyTldCreation("blobio-landrush", "BLOBIOL1", TldState.LANDRUSH, "alternate_list");
verifyTldCreation(
"blobio-ga",
"BLOBIOG2",
TldState.GENERAL_AVAILABILITY,
"alternate_list",
Duration.standardMinutes(60),
Duration.standardMinutes(10),
Duration.standardMinutes(5));
ImmutableList<CidrAddressBlock> ipAddress = ImmutableList.of(
CidrAddressBlock.create("1.1.1.1"));
verifyRegistrarCreation("blobio-1", "blobio-sunrise", passwords.get(0), ipAddress);
verifyRegistrarCreation("blobio-2", "blobio-landrush", passwords.get(1), ipAddress);
verifyRegistrarCreation("blobio-3", "blobio-ga", passwords.get(2), ipAddress);
verifyRegistrarCreation("blobio-4", "blobio-ga", passwords.get(3), ipAddress);
}
@Test
public void testFailure_missingIpWhitelist() throws Exception {
thrown.expect(ParameterException.class);
runCommandForced(
"--registrar=blobio",
"--certfile=" + getCertFilename());
}
@Test
public void testFailure_missingRegistrar() throws Exception {
thrown.expect(ParameterException.class);
runCommandForced(
"--ip_whitelist=1.1.1.1",
"--certfile=" + getCertFilename());
}
@Test
public void testFailure_missingCertificateFile() throws Exception {
thrown.expect(ParameterException.class);
runCommandForced(
"--ip_whitelist=1.1.1.1",
"--registrar=blobio");
}
@Test
public void testFailure_invalidCert() throws Exception {
thrown.expect(CertificateParsingException.class);
runCommandForced(
"--ip_whitelist=1.1.1.1",
"--registrar=blobio",
"--certfile=/dev/null");
}
@Test
public void testFailure_invalidRegistrar() throws Exception {
thrown.expect(IllegalArgumentException.class);
runCommandForced(
"--ip_whitelist=1.1.1.1",
"--registrar=3blobio",
"--certfile=" + getCertFilename());
}
@Test
public void testFailure_registrarTooShort() throws Exception {
thrown.expect(IllegalArgumentException.class);
runCommandForced(
"--ip_whitelist=1.1.1.1",
"--registrar=bl",
"--certfile=" + getCertFilename());
}
@Test
public void testFailure_registrarTooLong() throws Exception {
thrown.expect(IllegalArgumentException.class);
runCommandForced(
"--ip_whitelist=1.1.1.1",
"--registrar=blobiotoooolong",
"--certfile=" + getCertFilename());
}
@Test
public void testFailure_registrarInvalidCharacter() throws Exception {
thrown.expect(IllegalArgumentException.class);
runCommandForced(
"--ip_whitelist=1.1.1.1",
"--registrar=blo#bio",
"--certfile=" + getCertFilename());
}
@Test
public void testFailure_invalidPremiumList() throws Exception {
thrown.expect(IllegalArgumentException.class);
runCommandForced(
"--ip_whitelist=1.1.1.1",
"--registrar=blobio",
"--certfile=" + getCertFilename(),
"--premium_list=foo");
}
@Test
public void testFailure_tldExists() throws Exception {
thrown.expect(IllegalStateException.class);
createTld("blobio-sunrise");
runCommandForced(
"--ip_whitelist=1.1.1.1",
"--registrar=blobio",
"--certfile=" + getCertFilename());
}
@Test
public void testFailure_registrarExists() throws Exception {
thrown.expect(IllegalStateException.class);
Registrar registrar = Registrar.loadByClientId("TheRegistrar").asBuilder()
.setClientIdentifier("blobio-1")
.setRegistrarName("blobio-1")
.build();
persistResource(registrar);
runCommandForced(
"--ip_whitelist=1.1.1.1",
"--registrar=blobio",
"--certfile=" + getCertFilename());
}
}

View file

@ -0,0 +1,286 @@
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.domain.registry.tools;
import static com.google.common.collect.Iterables.getLast;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assert_;
import static com.google.domain.registry.model.domain.launch.ApplicationStatus.ALLOCATED;
import static com.google.domain.registry.model.domain.launch.ApplicationStatus.PENDING_ALLOCATION;
import static com.google.domain.registry.model.domain.launch.ApplicationStatus.REJECTED;
import static com.google.domain.registry.model.ofy.ObjectifyService.ofy;
import static com.google.domain.registry.testing.DatastoreHelper.createTld;
import static com.google.domain.registry.testing.DatastoreHelper.newContactResourceWithRoid;
import static com.google.domain.registry.testing.DatastoreHelper.newDomainApplication;
import static com.google.domain.registry.testing.DatastoreHelper.persistResource;
import static com.google.domain.registry.testing.DomainApplicationSubject.assertAboutApplications;
import static com.google.domain.registry.testing.HistoryEntrySubject.assertAboutHistoryEntries;
import static org.joda.time.DateTimeZone.UTC;
import com.google.common.collect.FluentIterable;
import com.google.domain.registry.model.domain.DomainApplication;
import com.google.domain.registry.model.eppcommon.StatusValue;
import com.google.domain.registry.model.eppcommon.Trid;
import com.google.domain.registry.model.poll.PendingActionNotificationResponse.DomainPendingActionNotificationResponse;
import com.google.domain.registry.model.poll.PollMessage;
import com.google.domain.registry.model.registrar.Registrar;
import com.google.domain.registry.model.reporting.HistoryEntry;
import org.joda.time.DateTime;
import org.junit.Before;
import org.junit.Test;
/** Unit tests for {@link UpdateApplicationStatusCommand}. */
public class UpdateApplicationStatusCommandTest
extends CommandTestCase<UpdateApplicationStatusCommand> {
private Trid trid = Trid.create("ABC123");
private DomainApplication domainApplication;
private DateTime creationTime;
@Before
public void init() {
// Since the command's history client ID defaults to CharlestonRoad, resave TheRegistrar as
// CharlestonRoad so we don't have to pass in --history_client_id everywhere below.
persistResource(Registrar.loadByClientId("TheRegistrar").asBuilder()
.setClientIdentifier("CharlestonRoad")
.build());
createTld("xn--q9jyb4c");
domainApplication = persistResource(newDomainApplication(
"label.xn--q9jyb4c", persistResource(newContactResourceWithRoid("contact1", "C1-ROID")))
.asBuilder()
.setCurrentSponsorClientId("TheRegistrar")
.build());
this.creationTime = domainApplication.getCreationTime();
// Add a history entry under this application that corresponds to its creation.
persistResource(
new HistoryEntry.Builder()
.setParent(domainApplication)
.setModificationTime(creationTime)
.setTrid(trid)
.setType(HistoryEntry.Type.DOMAIN_APPLICATION_CREATE)
.build());
// Add a second history entry with a different Trid just to make sure we are always retrieving
// the right one.
persistResource(
new HistoryEntry.Builder()
.setParent(domainApplication)
.setModificationTime(creationTime)
.setTrid(Trid.create("ABC124"))
.setType(HistoryEntry.Type.DOMAIN_APPLICATION_CREATE)
.build());
}
private HistoryEntry loadLastHistoryEntry() {
// Loading everything and using getLast() is inefficient, but to do it right would require a new
// descending index on modification time, and this is fine for testing.
return getLast(ofy().load()
.type(HistoryEntry.class)
.ancestor(domainApplication)
.order("modificationTime")
.list());
}
@Test
public void testSuccess_rejected() throws Exception {
DateTime before = new DateTime(UTC);
assertAboutApplications()
.that(domainApplication)
.hasStatusValue(StatusValue.PENDING_CREATE).and()
.doesNotHaveApplicationStatus(REJECTED);
assertThat(getPollMessageCount()).isEqualTo(0);
Trid creationTrid = Trid.create("DEF456");
persistResource(reloadResource(domainApplication).asBuilder()
.setCreationTrid(creationTrid)
.build());
runCommandForced("--ids=2-Q9JYB4C", "--msg=\"Application rejected\"", "--status=REJECTED");
domainApplication = ofy().load().entity(domainApplication).now();
assertAboutApplications().that(domainApplication)
.doesNotHaveStatusValue(StatusValue.PENDING_CREATE).and()
.hasApplicationStatus(REJECTED).and()
.hasLastEppUpdateTimeAtLeast(before).and()
.hasLastEppUpdateClientId("TheRegistrar");
assertAboutHistoryEntries().that(loadLastHistoryEntry())
.hasType(HistoryEntry.Type.DOMAIN_APPLICATION_STATUS_UPDATE).and()
.hasClientId("CharlestonRoad");
assertThat(getPollMessageCount()).isEqualTo(1);
PollMessage pollMessage = getFirstPollMessage();
assertThat(pollMessage.getMsg()).isEqualTo("Application rejected");
DomainPendingActionNotificationResponse response = (DomainPendingActionNotificationResponse)
FluentIterable.from(pollMessage.getResponseData()).first().get();
assertThat(response.getTrid()).isEqualTo(creationTrid);
assertThat(response.getActionResult()).isFalse();
}
private PollMessage getFirstPollMessage() {
return ofy().load().type(PollMessage.class).first().safe();
}
@Test
public void testSuccess_allocated() throws Exception {
DateTime before = new DateTime(UTC);
assertAboutApplications().that(domainApplication)
.hasStatusValue(StatusValue.PENDING_CREATE).and()
.doesNotHaveApplicationStatus(ALLOCATED);
assertThat(getPollMessageCount()).isEqualTo(0);
Trid creationTrid = Trid.create("DEF456");
persistResource(reloadResource(domainApplication).asBuilder()
.setCreationTrid(creationTrid)
.build());
runCommandForced("--ids=2-Q9JYB4C", "--msg=\"Application allocated\"", "--status=ALLOCATED");
domainApplication = ofy().load().entity(domainApplication).now();
assertAboutApplications().that(domainApplication)
.doesNotHaveStatusValue(StatusValue.PENDING_CREATE).and()
.hasApplicationStatus(ALLOCATED).and()
.hasLastEppUpdateTimeAtLeast(before).and()
.hasLastEppUpdateClientId("TheRegistrar");
assertAboutHistoryEntries().that(loadLastHistoryEntry())
.hasType(HistoryEntry.Type.DOMAIN_APPLICATION_STATUS_UPDATE).and()
.hasClientId("CharlestonRoad");
assertThat(getPollMessageCount()).isEqualTo(1);
PollMessage pollMessage = getFirstPollMessage();
assertThat(pollMessage.getMsg()).isEqualTo("Application allocated");
DomainPendingActionNotificationResponse response = (DomainPendingActionNotificationResponse)
FluentIterable.from(pollMessage.getResponseData()).first().get();
assertThat(response.getTrid()).isEqualTo(creationTrid);
assertThat(response.getActionResult()).isTrue();
}
@Test
public void testSuccess_pendingAllocation() throws Exception {
DateTime before = new DateTime(UTC);
assertAboutApplications().that(domainApplication)
.doesNotHaveApplicationStatus(PENDING_ALLOCATION).and()
.hasStatusValue(StatusValue.PENDING_CREATE);
assertThat(getPollMessageCount()).isEqualTo(0);
Trid creationTrid = Trid.create("DEF456");
persistResource(reloadResource(domainApplication).asBuilder()
.setCreationTrid(creationTrid)
.build());
runCommandForced(
"--ids=2-Q9JYB4C",
"--msg=\"Application pending allocation\"",
"--status=PENDING_ALLOCATION");
domainApplication = ofy().load().entity(domainApplication).now();
assertAboutApplications().that(domainApplication)
.hasStatusValue(StatusValue.PENDING_CREATE).and()
.hasApplicationStatus(PENDING_ALLOCATION).and()
.hasLastEppUpdateTimeAtLeast(before).and()
.hasLastEppUpdateClientId("TheRegistrar");
assertAboutHistoryEntries().that(loadLastHistoryEntry())
.hasType(HistoryEntry.Type.DOMAIN_APPLICATION_STATUS_UPDATE).and()
.hasClientId("CharlestonRoad");
assertThat(getPollMessageCount()).isEqualTo(1);
PollMessage pollMessage = getFirstPollMessage();
assertThat(pollMessage.getMsg()).isEqualTo("Application pending allocation");
assertThat(pollMessage.getResponseData()).isEmpty();
assertThat(pollMessage.getResponseExtensions()).isNotEmpty();
}
@Test
public void testSuccess_rejectedTridFromHistoryEntry() throws Exception {
DateTime before = new DateTime(UTC);
assertAboutApplications().that(domainApplication)
.hasStatusValue(StatusValue.PENDING_CREATE).and()
.doesNotHaveApplicationStatus(REJECTED);
assertThat(getPollMessageCount()).isEqualTo(0);
runCommandForced("--ids=2-Q9JYB4C", "--msg=\"Application rejected\"", "--status=REJECTED");
domainApplication = ofy().load().entity(domainApplication).now();
assertAboutApplications().that(domainApplication)
.doesNotHaveStatusValue(StatusValue.PENDING_CREATE).and()
.hasApplicationStatus(REJECTED).and()
.hasLastEppUpdateTimeAtLeast(before).and()
.hasLastEppUpdateClientId("TheRegistrar");
assertAboutHistoryEntries().that(loadLastHistoryEntry())
.hasType(HistoryEntry.Type.DOMAIN_APPLICATION_STATUS_UPDATE).and()
.hasClientId("CharlestonRoad");
assertThat(getPollMessageCount()).isEqualTo(1);
PollMessage pollMessage = getFirstPollMessage();
DomainPendingActionNotificationResponse response = (DomainPendingActionNotificationResponse)
FluentIterable.from(pollMessage.getResponseData()).first().get();
assertThat(response.getTrid()).isEqualTo(trid);
}
@Test
public void testFailure_applicationAlreadyRejected() throws Exception {
assertThat(getPollMessageCount()).isEqualTo(0);
persistResource(reloadResource(domainApplication).asBuilder()
.setApplicationStatus(REJECTED)
.build());
runCommandForced("--ids=2-Q9JYB4C", "--msg=\"Application rejected\"", "--status=REJECTED");
assertAboutApplications().that(ofy().load().entity(domainApplication).now())
.hasApplicationStatus(REJECTED);
assertThat(getPollMessageCount()).isEqualTo(0);
assertAboutHistoryEntries().that(loadLastHistoryEntry())
.hasType(HistoryEntry.Type.DOMAIN_APPLICATION_CREATE);
}
@Test
public void testFailure_applicationAlreadyAllocated() throws Exception {
persistResource(reloadResource(domainApplication).asBuilder()
.setApplicationStatus(ALLOCATED)
.build());
try {
runCommandForced("--ids=2-Q9JYB4C", "--msg=\"Application rejected\"", "--status=REJECTED");
} catch (IllegalStateException e) {
assertThat(e.getMessage()).contains("Domain application has final status ALLOCATED");
assertAboutApplications().that(ofy().load().entity(domainApplication).now())
.hasApplicationStatus(ALLOCATED);
assertThat(getPollMessageCount()).isEqualTo(0);
assertAboutHistoryEntries().that(loadLastHistoryEntry())
.hasType(HistoryEntry.Type.DOMAIN_APPLICATION_CREATE);
return;
}
assert_().fail(
"Expected IllegalStateException \"Domain application has final status ALLOCATED\"");
}
@Test
public void testFailure_applicationDoesNotExist() throws Exception {
thrown.expect(IllegalArgumentException.class);
runCommandForced("--ids=555-Q9JYB4C", "--msg=\"Application rejected\"", "--status=REJECTED");
}
@Test
public void testFailure_historyClientIdDoesNotExist() throws Exception {
thrown.expect(IllegalArgumentException.class, "fakeclient");
runCommandForced(
"--history_client_id=fakeclient", "--ids=2-Q9JYB4C", "--msg=Ignored", "--status=REJECTED");
}
}

View file

@ -0,0 +1,167 @@
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.domain.registry.tools;
import static com.google.domain.registry.model.ofy.ObjectifyService.ofy;
import static com.google.domain.registry.testing.DatastoreHelper.createTld;
import static com.google.domain.registry.testing.DatastoreHelper.newDomainApplication;
import static com.google.domain.registry.testing.DatastoreHelper.persistResource;
import static com.google.domain.registry.testing.DomainApplicationSubject.assertAboutApplications;
import static com.google.domain.registry.util.DateTimeUtils.END_OF_TIME;
import static com.google.domain.registry.util.DateTimeUtils.START_OF_TIME;
import static org.joda.time.DateTimeZone.UTC;
import com.google.common.collect.ImmutableList;
import com.google.domain.registry.model.domain.DomainApplication;
import com.google.domain.registry.model.domain.launch.LaunchNotice;
import com.google.domain.registry.model.domain.launch.LaunchNotice.InvalidChecksumException;
import com.google.domain.registry.model.reporting.HistoryEntry;
import com.google.domain.registry.model.smd.EncodedSignedMark;
import org.joda.time.DateTime;
import org.junit.Before;
import org.junit.Test;
/** Unit tests for {@link UpdateClaimsNoticeCommandTest}. */
public class UpdateClaimsNoticeCommandTest extends CommandTestCase<UpdateClaimsNoticeCommand> {
DomainApplication domainApplication;
@Before
public void init() {
createTld("xn--q9jyb4c");
domainApplication = persistResource(newDomainApplication("example-one.xn--q9jyb4c")
.asBuilder()
.setCurrentSponsorClientId("TheRegistrar")
.build());
}
private DomainApplication reloadDomainApplication() {
return ofy().load().entity(domainApplication).now();
}
@Test
public void testSuccess_noLaunchNotice() throws Exception {
DateTime before = new DateTime(UTC);
assertAboutApplications().that(domainApplication).hasLaunchNotice(null);
runCommand(
"--id=2-Q9JYB4C",
"--tcn_id=370d0b7c9223372036854775807",
"--expiration_time=2010-08-16T09:00:00.0Z",
"--accepted_time=2009-08-16T09:00:00.0Z");
assertAboutApplications().that(reloadDomainApplication())
.hasLaunchNotice(LaunchNotice.create(
"370d0b7c9223372036854775807",
"tmch",
DateTime.parse("2010-08-16T09:00:00.0Z"),
DateTime.parse("2009-08-16T09:00:00.0Z"))).and()
.hasLastEppUpdateTimeAtLeast(before).and()
.hasLastEppUpdateClientId("TheRegistrar").and()
.hasOnlyOneHistoryEntryWhich()
.hasType(HistoryEntry.Type.DOMAIN_APPLICATION_UPDATE).and()
.hasClientId("TheRegistrar");
}
@Test
public void testSuccess_paddedChecksum() throws Exception {
DateTime before = new DateTime(UTC);
domainApplication = persistResource(newDomainApplication("imdb.xn--q9jyb4c"));
runCommand(
"--id=4-Q9JYB4C",
"--tcn_id=0a07ec6e0000000000010995975",
"--expiration_time=2014-02-28T12:00:00.0Z",
"--accepted_time=2014-02-26T12:00:00.0Z");
assertAboutApplications().that(reloadDomainApplication())
.hasLaunchNotice(LaunchNotice.create(
"0a07ec6e0000000000010995975",
"tmch",
DateTime.parse("2014-02-28T12:00:00.0Z"),
DateTime.parse("2014-02-26T12:00:00.0Z"))).and()
.hasLastEppUpdateTimeAtLeast(before).and()
.hasLastEppUpdateClientId("TheRegistrar").and()
.hasOnlyOneHistoryEntryWhich()
.hasType(HistoryEntry.Type.DOMAIN_APPLICATION_UPDATE).and()
.hasClientId("TheRegistrar");
}
@Test
public void testSuccess_replaceExistingLaunchNotice() throws Exception {
DateTime before = new DateTime(UTC);
// Set a launch notice which should get overwritten.
domainApplication = persistResource(domainApplication.asBuilder()
.setLaunchNotice(LaunchNotice.create("foobar", "tmch", END_OF_TIME, START_OF_TIME))
.build());
runCommand(
"--id=2-Q9JYB4C",
"--tcn_id=370d0b7c9223372036854775807",
"--expiration_time=2010-08-16T09:00:00.0Z",
"--accepted_time=2009-08-16T09:00:00.0Z");
assertAboutApplications().that(reloadDomainApplication())
.hasLaunchNotice(LaunchNotice.create(
"370d0b7c9223372036854775807",
"tmch",
DateTime.parse("2010-08-16T09:00:00.0Z"),
DateTime.parse("2009-08-16T09:00:00.0Z"))).and()
.hasLastEppUpdateTimeAtLeast(before).and()
.hasLastEppUpdateClientId("TheRegistrar").and()
.hasOnlyOneHistoryEntryWhich()
.hasType(HistoryEntry.Type.DOMAIN_APPLICATION_UPDATE).and()
.hasClientId("TheRegistrar");
}
@Test
public void testFailure_badClaimsNotice() throws Exception {
thrown.expect(IllegalArgumentException.class);
runCommand(
"--id=1-Q9JYB4C",
"--tcn_id=foobarbaz",
"--expiration_time=2010-08-16T09:00:00.0Z",
"--accepted_time=2009-08-16T09:00:00.0Z");
}
@Test
public void testFailure_claimsNoticeForWrongLabel() throws Exception {
thrown.expectRootCause(InvalidChecksumException.class);
domainApplication = persistResource(newDomainApplication("bad-label.xn--q9jyb4c"));
runCommand(
"--id=4-Q9JYB4C",
"--tcn_id=370d0b7c9223372036854775807",
"--expiration_time=2010-08-16T09:00:00.0Z",
"--accepted_time=2009-08-16T09:00:00.0Z");
}
@Test
public void testFailure_sunriseApplication() throws Exception {
thrown.expect(IllegalArgumentException.class);
// Add an encoded signed mark to the application to make it a sunrise application.
domainApplication = persistResource(domainApplication.asBuilder()
.setEncodedSignedMarks(ImmutableList.of(EncodedSignedMark.create("base64", "AAAAA")))
.build());
runCommand(
"--id=1-Q9JYB4C",
"--tcn_id=370d0b7c9223372036854775807",
"--expiration_time=2010-08-16T09:00:00.0Z",
"--accepted_time=2009-08-16T09:00:00.0Z");
}
}

View file

@ -0,0 +1,58 @@
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.domain.registry.tools;
import static com.google.common.truth.Truth.assertThat;
import static com.google.domain.registry.testing.DatastoreHelper.createTld;
import static com.google.domain.registry.testing.DatastoreHelper.persistResource;
import com.google.domain.registry.model.registry.Registry;
import com.google.domain.registry.model.registry.RegistryCursor;
import com.google.domain.registry.model.registry.RegistryCursor.CursorType;
import org.joda.time.DateTime;
import org.junit.Before;
import org.junit.Test;
/** Unit tests for {@link UpdateCursorsCommand}. */
public class UpdateCursorsCommandTest extends CommandTestCase<UpdateCursorsCommand> {
Registry registry;
@Before
public void before() {
createTld("foo");
registry = Registry.get("foo");
}
void doUpdateTest() throws Exception {
runCommandForced("--type=brda", "--timestamp=1984-12-18T00:00:00Z", "foo");
assertThat(RegistryCursor.load(registry, CursorType.BRDA))
.hasValue(DateTime.parse("1984-12-18TZ"));
}
@Test
public void testUpdateCursors_oldValueIsAbsent() throws Exception {
assertThat(RegistryCursor.load(registry, CursorType.BRDA)).isAbsent();
doUpdateTest();
}
@Test
public void testUpdateCursors_hasOldValue() throws Exception {
persistResource(
RegistryCursor.create(registry, CursorType.BRDA, DateTime.parse("1950-12-18TZ")));
doUpdateTest();
}
}

View file

@ -0,0 +1,80 @@
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.domain.registry.tools;
import static com.google.domain.registry.request.JsonResponse.JSON_SAFETY_PREFIX;
import static com.google.domain.registry.util.ResourceUtils.readResourceUtf8;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyMapOf;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.when;
import com.google.common.collect.ImmutableMap;
import com.google.common.net.MediaType;
import com.google.domain.registry.tools.ServerSideCommand.Connection;
import com.google.domain.registry.tools.server.UpdatePremiumListAction;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
/** Unit tests for {@link UpdatePremiumListCommand}. */
public class UpdatePremiumListCommandTest<C extends UpdatePremiumListCommand>
extends CreateOrUpdatePremiumListCommandTestCase<C> {
@Mock
Connection connection;
String premiumTermsPath;
String premiumTermsCsv;
String servletPath;
@Before
public void init() throws Exception {
command.setConnection(connection);
servletPath = "/_dr/admin/updatePremiumList";
premiumTermsPath = writeToNamedTmpFile(
"example_premium_terms.csv",
readResourceUtf8(
UpdatePremiumListCommandTest.class,
"testdata/example_premium_terms.csv"));
when(connection.send(
eq(UpdatePremiumListAction.PATH),
anyMapOf(String.class, String.class),
any(MediaType.class),
any(byte[].class)))
.thenReturn(JSON_SAFETY_PREFIX + "{\"status\":\"success\",\"lines\":[]}");
}
@Test
public void testRun() throws Exception {
runCommandForced("-i=" + premiumTermsPath, "-n=foo");
verifySentParams(
connection,
servletPath,
ImmutableMap.of("name", "foo", "inputData", generateInputData(premiumTermsPath)));
}
@Test
public void testRun_noProvidedName_usesBasenameOfInputFile() throws Exception {
runCommandForced("-i=" + premiumTermsPath);
assertInStdout("Successfully");
verifySentParams(
connection,
servletPath,
ImmutableMap.of(
"name", "example_premium_terms", "inputData", generateInputData(premiumTermsPath)));
}
}

View file

@ -0,0 +1,559 @@
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.domain.registry.tools;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Strings.isNullOrEmpty;
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_HASH;
import static com.google.domain.registry.testing.DatastoreHelper.createTlds;
import static com.google.domain.registry.testing.DatastoreHelper.persistResource;
import static org.joda.time.DateTimeZone.UTC;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.domain.registry.model.billing.RegistrarBillingEntry;
import com.google.domain.registry.model.registrar.Registrar;
import com.google.domain.registry.model.registrar.Registrar.BillingMethod;
import com.google.domain.registry.model.registrar.Registrar.State;
import com.google.domain.registry.model.registrar.Registrar.Type;
import com.google.domain.registry.util.CidrAddressBlock;
import com.beust.jcommander.ParameterException;
import org.joda.money.Money;
import org.joda.time.DateTime;
import org.junit.Test;
/** Unit tests for {@link UpdateRegistrarCommand}. */
public class UpdateRegistrarCommandTest extends CommandTestCase<UpdateRegistrarCommand> {
@Test
public void testSuccess_password() throws Exception {
assertThat(loadByClientId("NewRegistrar").testPassword("some_password")).isFalse();
runCommand("--password=some_password", "--force", "NewRegistrar");
assertThat(loadByClientId("NewRegistrar").testPassword("some_password")).isTrue();
}
@Test
public void testSuccess_registrarType() throws Exception {
persistResource(
loadByClientId("NewRegistrar")
.asBuilder()
.setType(Registrar.Type.OTE)
.setIanaIdentifier(null)
.build());
assertThat(loadByClientId("NewRegistrar").getType()).isEqualTo(Type.OTE);
runCommand("--registrar_type=TEST", "--force", "NewRegistrar");
assertThat(loadByClientId("NewRegistrar").getType()).isEqualTo(Type.TEST);
}
@Test
public void testFailure_noPasscodeOnChangeToReal() throws Exception {
thrown.expect(IllegalArgumentException.class, "--passcode is required for REAL registrars.");
persistResource(
loadByClientId("NewRegistrar")
.asBuilder()
.setType(Registrar.Type.OTE)
.setIanaIdentifier(null)
.setPhonePasscode(null)
.build());
runCommand("--registrar_type=REAL", "--iana_id=1000", "--force", "NewRegistrar");
}
@Test
public void testSuccess_registrarState() throws Exception {
assertThat(loadByClientId("NewRegistrar").getState()).isEqualTo(State.ACTIVE);
runCommand("--registrar_state=SUSPENDED", "--force", "NewRegistrar");
assertThat(loadByClientId("NewRegistrar").getState()).isEqualTo(State.SUSPENDED);
}
@Test
public void testSuccess_allowedTlds() throws Exception {
createTlds("xn--q9jyb4c", "foobar");
persistResource(
loadByClientId("NewRegistrar")
.asBuilder()
.setAllowedTlds(ImmutableSet.of("xn--q9jyb4c"))
.build());
runCommand("--allowed_tlds=xn--q9jyb4c,foobar", "--force", "NewRegistrar");
assertThat(loadByClientId("NewRegistrar").getAllowedTlds())
.containsExactly("xn--q9jyb4c", "foobar");
}
@Test
public void testSuccess_addAllowedTlds() throws Exception {
createTlds("xn--q9jyb4c", "foo", "bar");
persistResource(
loadByClientId("NewRegistrar")
.asBuilder()
.setAllowedTlds(ImmutableSet.of("xn--q9jyb4c"))
.build());
runCommand("--add_allowed_tlds=foo,bar", "--force", "NewRegistrar");
assertThat(loadByClientId("NewRegistrar").getAllowedTlds())
.containsExactly("xn--q9jyb4c", "foo", "bar");
}
@Test
public void testSuccess_addAllowedTldsWithDupes() throws Exception {
createTlds("xn--q9jyb4c", "foo", "bar");
persistResource(
loadByClientId("NewRegistrar")
.asBuilder()
.setAllowedTlds(ImmutableSet.of("xn--q9jyb4c"))
.build());
runCommand("--add_allowed_tlds=xn--q9jyb4c,foo,bar", "--force", "NewRegistrar");
assertThat(loadByClientId("NewRegistrar").getAllowedTlds())
.isEqualTo(ImmutableSet.of("xn--q9jyb4c", "foo", "bar"));
}
@Test
public void testSuccess_ipWhitelist() throws Exception {
assertThat(loadByClientId("NewRegistrar").getIpAddressWhitelist()).isEmpty();
runCommand("--ip_whitelist=192.168.1.1,192.168.0.2/16", "--force", "NewRegistrar");
assertThat(loadByClientId("NewRegistrar").getIpAddressWhitelist())
.containsExactly(
CidrAddressBlock.create("192.168.1.1"), CidrAddressBlock.create("192.168.0.2/16"))
.inOrder();
}
@Test
public void testSuccess_clearIpWhitelist() throws Exception {
persistResource(
loadByClientId("NewRegistrar")
.asBuilder()
.setIpAddressWhitelist(
ImmutableList.of(
CidrAddressBlock.create("192.168.1.1"),
CidrAddressBlock.create("192.168.0.2/16")))
.build());
assertThat(loadByClientId("NewRegistrar").getIpAddressWhitelist()).isNotEmpty();
runCommand("--ip_whitelist=null", "--force", "NewRegistrar");
assertThat(loadByClientId("NewRegistrar").getIpAddressWhitelist()).isEmpty();
}
@Test
public void testSuccess_certFile() throws Exception {
Registrar registrar = checkNotNull(loadByClientId("NewRegistrar"));
assertThat(registrar.getClientCertificate()).isNull();
assertThat(registrar.getClientCertificateHash()).isNull();
runCommand("--cert_file=" + getCertFilename(), "--force", "NewRegistrar");
registrar = checkNotNull(loadByClientId("NewRegistrar"));
// NB: Hash was computed manually using 'openssl x509 -fingerprint -sha256 -in ...' and then
// converting the result from a hex string to non-padded base64 encoded string.
assertThat(registrar.getClientCertificate()).isEqualTo(SAMPLE_CERT);
assertThat(registrar.getClientCertificateHash()).isEqualTo(SAMPLE_CERT_HASH);
}
@Test
public void testSuccess_certHash() throws Exception {
assertThat(loadByClientId("NewRegistrar").getClientCertificateHash()).isNull();
runCommand("--cert_hash=" + SAMPLE_CERT_HASH, "--force", "NewRegistrar");
assertThat(loadByClientId("NewRegistrar").getClientCertificateHash())
.isEqualTo(SAMPLE_CERT_HASH);
}
@Test
public void testSuccess_clearCert() throws Exception {
persistResource(
loadByClientId("NewRegistrar")
.asBuilder()
.setClientCertificate(SAMPLE_CERT, DateTime.now(UTC))
.build());
assertThat(isNullOrEmpty(loadByClientId("NewRegistrar").getClientCertificate())).isFalse();
runCommand("--cert_file=/dev/null", "--force", "NewRegistrar");
assertThat(loadByClientId("NewRegistrar").getClientCertificate()).isNull();
}
@Test
public void testSuccess_clearCertHash() throws Exception {
persistResource(
loadByClientId("NewRegistrar")
.asBuilder()
.setClientCertificateHash(SAMPLE_CERT_HASH)
.build());
assertThat(isNullOrEmpty(loadByClientId("NewRegistrar").getClientCertificateHash())).isFalse();
runCommand("--cert_hash=null", "--force", "NewRegistrar");
assertThat(loadByClientId("NewRegistrar").getClientCertificateHash()).isNull();
}
@Test
public void testSuccess_ianaId() throws Exception {
assertThat(loadByClientId("NewRegistrar").getIanaIdentifier()).isEqualTo(8);
runCommand("--iana_id=12345", "--force", "NewRegistrar");
assertThat(loadByClientId("NewRegistrar").getIanaIdentifier()).isEqualTo(12345);
}
@Test
public void testSuccess_billingId() throws Exception {
assertThat(loadByClientId("NewRegistrar").getBillingIdentifier()).isNull();
runCommand("--billing_id=12345", "--force", "NewRegistrar");
assertThat(loadByClientId("NewRegistrar").getBillingIdentifier()).isEqualTo(12345);
}
@Test
public void testSuccess_changeBillingMethodToBraintreeWhenBalanceIsZero() throws Exception {
createTlds("xn--q9jyb4c");
assertThat(loadByClientId("NewRegistrar").getBillingMethod()).isEqualTo(BillingMethod.EXTERNAL);
runCommand("--billing_method=braintree", "--force", "NewRegistrar");
assertThat(loadByClientId("NewRegistrar").getBillingMethod())
.isEqualTo(BillingMethod.BRAINTREE);
}
@Test
public void testFailure_changeBillingMethodWhenBalanceIsNonZero() throws Exception {
createTlds("xn--q9jyb4c");
Registrar registrar = checkNotNull(loadByClientId("NewRegistrar"));
persistResource(
new RegistrarBillingEntry.Builder()
.setPrevious(null)
.setParent(registrar)
.setCreated(DateTime.parse("1984-12-18TZ"))
.setDescription("USD Invoice for December")
.setAmount(Money.parse("USD 10.00"))
.build());
assertThat(registrar.getBillingMethod()).isEqualTo(BillingMethod.EXTERNAL);
thrown.expect(IllegalStateException.class,
"Refusing to change billing method on Registrar 'NewRegistrar' from EXTERNAL to BRAINTREE"
+ " because current balance is non-zero: {USD=USD 10.00}");
runCommand("--billing_method=braintree", "--force", "NewRegistrar");
}
@Test
public void testSuccess_streetAddress() throws Exception {
runCommand("--street=\"1234 Main St\"", "--street \"4th Floor\"", "--street \"Suite 1\"",
"--city Brooklyn", "--state NY", "--zip 11223", "--cc US", "--force", "NewRegistrar");
Registrar registrar = checkNotNull(loadByClientId("NewRegistrar"));
assertThat(registrar.getLocalizedAddress() != null).isTrue();
assertThat(registrar.getLocalizedAddress().getStreet()).hasSize(3);
assertThat(registrar.getLocalizedAddress().getStreet().get(0)).isEqualTo("1234 Main St");
assertThat(registrar.getLocalizedAddress().getStreet().get(1)).isEqualTo("4th Floor");
assertThat(registrar.getLocalizedAddress().getStreet().get(2)).isEqualTo("Suite 1");
assertThat(registrar.getLocalizedAddress().getCity()).isEqualTo("Brooklyn");
assertThat(registrar.getLocalizedAddress().getState()).isEqualTo("NY");
assertThat(registrar.getLocalizedAddress().getZip()).isEqualTo("11223");
assertThat(registrar.getLocalizedAddress().getCountryCode()).isEqualTo("US");
}
@Test
public void testSuccess_blockPremiumNames() throws Exception {
assertThat(loadByClientId("NewRegistrar").getBlockPremiumNames()).isFalse();
runCommand("--block_premium=true", "--force", "NewRegistrar");
assertThat(loadByClientId("NewRegistrar").getBlockPremiumNames()).isTrue();
}
@Test
public void testSuccess_resetBlockPremiumNames() throws Exception {
persistResource(loadByClientId("NewRegistrar").asBuilder().setBlockPremiumNames(true).build());
runCommand("--block_premium=false", "--force", "NewRegistrar");
assertThat(loadByClientId("NewRegistrar").getBlockPremiumNames()).isFalse();
}
@Test
public void testSuccess_blockPremiumNamesUnspecified() throws Exception {
persistResource(loadByClientId("NewRegistrar").asBuilder().setBlockPremiumNames(true).build());
// Make some unrelated change where we don't specify "--block_premium".
runCommand("--billing_id=12345", "--force", "NewRegistrar");
// Make sure the field didn't get reset back to false.
assertThat(loadByClientId("NewRegistrar").getBlockPremiumNames()).isTrue();
}
@Test
public void testSuccess_updateMultiple() throws Exception {
assertThat(loadByClientId("TheRegistrar").getState()).isEqualTo(State.ACTIVE);
assertThat(loadByClientId("NewRegistrar").getState()).isEqualTo(State.ACTIVE);
runCommand("--registrar_state=SUSPENDED", "--force", "TheRegistrar", "NewRegistrar");
assertThat(loadByClientId("TheRegistrar").getState()).isEqualTo(State.SUSPENDED);
assertThat(loadByClientId("NewRegistrar").getState()).isEqualTo(State.SUSPENDED);
}
@Test
public void testSuccess_resetOptionalParamsNullString() throws Exception {
Registrar registrar = checkNotNull(loadByClientId("NewRegistrar"));
registrar = persistResource(registrar.asBuilder()
.setType(Type.PDT) // for non-null IANA ID
.setIanaIdentifier(9995L)
.setBillingIdentifier(1L)
.setPhoneNumber("+1.2125555555")
.setFaxNumber("+1.2125555556")
.setEmailAddress("registrar@example.tld")
.setUrl("http://www.example.tld")
.setDriveFolderId("id")
.build());
assertThat(registrar.getIanaIdentifier()).isNotNull();
assertThat(registrar.getBillingIdentifier()).isNotNull();
assertThat(registrar.getPhoneNumber()).isNotNull();
assertThat(registrar.getFaxNumber()).isNotNull();
assertThat(registrar.getEmailAddress()).isNotNull();
assertThat(registrar.getUrl()).isNotNull();
assertThat(registrar.getDriveFolderId()).isNotNull();
runCommand(
"--registrar_type=TEST", // necessary for null IANA ID
"--iana_id=null",
"--billing_id=null",
"--phone=null",
"--fax=null",
"--email=null",
"--url=null",
"--drive_id=null",
"--force",
"NewRegistrar");
registrar = checkNotNull(loadByClientId("NewRegistrar"));
assertThat(registrar.getIanaIdentifier()).isNull();
assertThat(registrar.getBillingIdentifier()).isNull();
assertThat(registrar.getPhoneNumber()).isNull();
assertThat(registrar.getFaxNumber()).isNull();
assertThat(registrar.getEmailAddress()).isNull();
assertThat(registrar.getUrl()).isNull();
assertThat(registrar.getDriveFolderId()).isNull();
}
@Test
public void testSuccess_resetOptionalParamsEmptyString() throws Exception {
Registrar registrar = checkNotNull(loadByClientId("NewRegistrar"));
registrar = persistResource(registrar.asBuilder()
.setType(Type.PDT) // for non-null IANA ID
.setIanaIdentifier(9995L)
.setBillingIdentifier(1L)
.setPhoneNumber("+1.2125555555")
.setFaxNumber("+1.2125555556")
.setEmailAddress("registrar@example.tld")
.setUrl("http://www.example.tld")
.setDriveFolderId("id")
.build());
assertThat(registrar.getIanaIdentifier()).isNotNull();
assertThat(registrar.getBillingIdentifier()).isNotNull();
assertThat(registrar.getPhoneNumber()).isNotNull();
assertThat(registrar.getFaxNumber()).isNotNull();
assertThat(registrar.getEmailAddress()).isNotNull();
assertThat(registrar.getUrl()).isNotNull();
assertThat(registrar.getDriveFolderId()).isNotNull();
runCommand(
"--registrar_type=TEST", // necessary for null IANA ID
"--iana_id=",
"--billing_id=",
"--phone=",
"--fax=",
"--email=",
"--url=",
"--drive_id=",
"--force",
"NewRegistrar");
registrar = checkNotNull(loadByClientId("NewRegistrar"));
assertThat(registrar.getIanaIdentifier()).isNull();
assertThat(registrar.getBillingIdentifier()).isNull();
assertThat(registrar.getPhoneNumber()).isNull();
assertThat(registrar.getFaxNumber()).isNull();
assertThat(registrar.getEmailAddress()).isNull();
assertThat(registrar.getUrl()).isNull();
assertThat(registrar.getDriveFolderId()).isNull();
}
@Test
public void testSuccess_setWhoisServer_works() throws Exception {
runCommand("--whois=whois.goth.black", "--force", "NewRegistrar");
assertThat(loadByClientId("NewRegistrar").getWhoisServer()).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
public void testFailure_invalidRegistrarType() throws Exception {
thrown.expect(ParameterException.class);
runCommand("--registrar_type=INVALID_TYPE", "--force", "NewRegistrar");
}
@Test
public void testFailure_invalidRegistrarState() throws Exception {
thrown.expect(ParameterException.class);
runCommand("--registrar_state=INVALID_STATE", "--force", "NewRegistrar");
}
@Test
public void testFailure_negativeIanaId() throws Exception {
thrown.expect(IllegalArgumentException.class);
runCommand("--iana_id=-1", "--force", "NewRegistrar");
}
@Test
public void testFailure_nonIntegerIanaId() throws Exception {
thrown.expect(ParameterException.class);
runCommand("--iana_id=ABC123", "--force", "NewRegistrar");
}
@Test
public void testFailure_negativeBillingId() throws Exception {
thrown.expect(IllegalArgumentException.class);
runCommand("--billing_id=-1", "--force", "NewRegistrar");
}
@Test
public void testFailure_nonIntegerBillingId() throws Exception {
thrown.expect(ParameterException.class);
runCommand("--billing_id=ABC123", "--force", "NewRegistrar");
}
@Test
public void testFailure_passcodeTooShort() throws Exception {
thrown.expect(IllegalArgumentException.class);
runCommand("--passcode=0123", "--force", "NewRegistrar");
}
@Test
public void testFailure_passcodeTooLong() throws Exception {
thrown.expect(IllegalArgumentException.class);
runCommand("--passcode=012345", "--force", "NewRegistrar");
}
@Test
public void testFailure_invalidPasscode() throws Exception {
thrown.expect(IllegalArgumentException.class);
runCommand("--passcode=code1", "--force", "NewRegistrar");
}
@Test
public void testFailure_allowedTldDoesNotExist() throws Exception {
thrown.expect(IllegalArgumentException.class);
runCommand("--allowed_tlds=foobar", "--force", "NewRegistrar");
}
@Test
public void testFailure_addAllowedTldDoesNotExist() throws Exception {
thrown.expect(IllegalArgumentException.class);
runCommand("--add_allowed_tlds=foobar", "--force", "NewRegistrar");
}
@Test
public void testFailure_allowedTldsAndAddAllowedTlds() throws Exception {
thrown.expect(IllegalArgumentException.class);
runCommand("--allowed_tlds=bar", "--add_allowed_tlds=foo", "--force", "NewRegistrar");
}
@Test
public void testFailure_invalidIpWhitelist() throws Exception {
thrown.expect(IllegalArgumentException.class);
runCommand("--ip_whitelist=foobarbaz", "--force", "NewRegistrar");
}
@Test
public void testFailure_invalidCertFileContents() throws Exception {
thrown.expect(Exception.class);
runCommand("--cert_file=" + writeToTmpFile("ABCDEF"), "--force", "NewRegistrar");
}
@Test
public void testFailure_certHashAndCertFile() throws Exception {
thrown.expect(IllegalArgumentException.class);
runCommand("--cert_file=" + getCertFilename(), "--cert_hash=ABCDEF", "--force", "NewRegistrar");
}
@Test
public void testFailure_missingClientId() throws Exception {
thrown.expect(ParameterException.class);
runCommand("--force");
}
@Test
public void testFailure_missingStreetLines() throws Exception {
thrown.expect(IllegalArgumentException.class);
runCommand("--city Brooklyn", "--state NY", "--zip 11223", "--cc US", "--force",
"NewRegistrar");
}
@Test
public void testFailure_missingCity() throws Exception {
thrown.expect(IllegalArgumentException.class);
runCommand("--street=\"1234 Main St\"", "--street \"4th Floor\"", "--street \"Suite 1\"",
"--state NY", "--zip 11223", "--cc US", "--force", "NewRegistrar");
}
@Test
public void testFailure_missingState() throws Exception {
thrown.expect(IllegalArgumentException.class);
runCommand("--street=\"1234 Main St\"", "--street \"4th Floor\"", "--street \"Suite 1\"",
"--city Brooklyn", "--zip 11223", "--cc US", "--force", "NewRegistrar");
}
@Test
public void testFailure_missingZip() throws Exception {
thrown.expect(IllegalArgumentException.class);
runCommand("--street=\"1234 Main St\"", "--street \"4th Floor\"", "--street \"Suite 1\"",
"--city Brooklyn", "--state NY", "--cc US", "--force", "NewRegistrar");
}
@Test
public void testFailure_missingCc() throws Exception {
thrown.expect(IllegalArgumentException.class);
runCommand("--street=\"1234 Main St\"", "--street \"4th Floor\"", "--street \"Suite 1\"",
"--city Brooklyn", "--state NY", "--zip 11223", "--force", "NewRegistrar");
}
@Test
public void testFailure_missingInvalidCc() throws Exception {
thrown.expect(IllegalArgumentException.class);
runCommand("--street=\"1234 Main St\"", "--street \"4th Floor\"", "--street \"Suite 1\"",
"--city Brooklyn", "--state NY", "--zip 11223", "--cc USA", "--force", "NewRegistrar");
}
@Test
public void testFailure_tooManyStreetLines() throws Exception {
thrown.expect(IllegalArgumentException.class);
runCommand("--street \"Attn:Hey You Guys\"", "--street \"1234 Main St\"",
"--street \"4th Floor\"", "--street \"Suite 1\"", "--city Brooklyn", "--state NY",
"--zip 11223", "--cc USA", "--force", "NewRegistrar");
}
@Test
public void testFailure_tooFewStreetLines() throws Exception {
thrown.expect(IllegalArgumentException.class);
runCommand("--street", "--city Brooklyn", "--state NY", "--zip 11223", "--cc USA", "--force",
"NewRegistrar");
}
@Test
public void testFailure_unknownFlag() throws Exception {
thrown.expect(ParameterException.class);
runCommand("--force", "--unrecognized_flag=foo", "NewRegistrar");
}
@Test
public void testFailure_doesNotExist() throws Exception {
thrown.expect(NullPointerException.class);
runCommand("--force", "ClientZ");
}
@Test
public void testFailure_registrarNameSimilarToExisting() throws Exception {
thrown.expect(IllegalArgumentException.class);
// Normalizes identically to "The Registrar" which is created by AppEngineRule.
runCommand("--name tHeRe GiStRaR", "--force", "NewRegistrar");
}
}

View file

@ -0,0 +1,98 @@
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.domain.registry.tools;
import static com.google.common.truth.Truth.assertThat;
import static com.google.domain.registry.model.registry.label.ReservationType.FULLY_BLOCKED;
import static com.google.domain.registry.testing.DatastoreHelper.persistResource;
import static com.google.domain.registry.util.DateTimeUtils.START_OF_TIME;
import com.google.common.collect.ImmutableList;
import com.google.domain.registry.model.registry.label.ReservedList;
import org.junit.Test;
/** Unit tests for {@link UpdateReservedListCommand}. */
public class UpdateReservedListCommandTest extends
CreateOrUpdateReservedListCommandTestCase<UpdateReservedListCommand> {
private void populateInitialReservedList(boolean shouldPublish) {
persistResource(
new ReservedList.Builder()
.setName("xn--q9jyb4c_common-reserved")
.setReservedListMapFromLines(ImmutableList.of("helicopter,FULLY_BLOCKED"))
.setCreationTime(START_OF_TIME)
.setLastUpdateTime(START_OF_TIME)
.setShouldPublish(shouldPublish)
.build());
}
@Test
public void testSuccess() throws Exception {
runSuccessfulUpdateTest("--name=xn--q9jyb4c_common-reserved", "--input=" + reservedTermsPath);
}
@Test
public void testSuccess_unspecifiedNameDefaultsToFileName() throws Exception {
runSuccessfulUpdateTest("--input=" + reservedTermsPath);
}
@Test
public void testSuccess_lastUpdateTime_updatedCorrectly() throws Exception {
populateInitialReservedList(true);
ReservedList original = ReservedList.get("xn--q9jyb4c_common-reserved").get();
runCommandForced("--input=" + reservedTermsPath);
ReservedList updated = ReservedList.get("xn--q9jyb4c_common-reserved").get();
assertThat(updated.getLastUpdateTime()).isGreaterThan(original.getLastUpdateTime());
assertThat(updated.getCreationTime()).isEqualTo(original.getCreationTime());
assertThat(updated.getLastUpdateTime()).isGreaterThan(updated.getCreationTime());
}
@Test
public void testSuccess_shouldPublish_setToFalseCorrectly() throws Exception {
runSuccessfulUpdateTest("--input=" + reservedTermsPath, "--should_publish=false");
assertThat(ReservedList.get("xn--q9jyb4c_common-reserved")).isPresent();
ReservedList reservedList = ReservedList.get("xn--q9jyb4c_common-reserved").get();
assertThat(reservedList.getShouldPublish()).isFalse();
}
@Test
public void testSuccess_shouldPublish_doesntOverrideFalseIfNotSpecified() throws Exception {
populateInitialReservedList(false);
runCommandForced("--input=" + reservedTermsPath);
assertThat(ReservedList.get("xn--q9jyb4c_common-reserved")).isPresent();
ReservedList reservedList = ReservedList.get("xn--q9jyb4c_common-reserved").get();
assertThat(reservedList.getShouldPublish()).isFalse();
}
private void runSuccessfulUpdateTest(String... args) throws Exception {
populateInitialReservedList(true);
runCommandForced(args);
assertThat(ReservedList.get("xn--q9jyb4c_common-reserved")).isPresent();
ReservedList reservedList = ReservedList.get("xn--q9jyb4c_common-reserved").get();
assertThat(reservedList.getReservedListEntries()).hasSize(2);
assertThat(reservedList.getReservationInList("baddies")).hasValue(FULLY_BLOCKED);
assertThat(reservedList.getReservationInList("ford")).hasValue(FULLY_BLOCKED);
assertThat(reservedList.getReservationInList("helicopter")).isAbsent();
}
@Test
public void testFailure_reservedListDoesntExist() throws Exception {
String errorMessage =
"Could not update reserved list xn--q9jyb4c_poobah because it doesn't exist.";
thrown.expect(IllegalArgumentException.class, errorMessage);
runCommand("--force", "--name=xn--q9jyb4c_poobah", "--input=" + reservedTermsPath);
}
}

View file

@ -0,0 +1,127 @@
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.domain.registry.tools;
import com.beust.jcommander.ParameterException;
import org.junit.Test;
/** Unit tests for {@link UpdateServerLocksCommand}. */
public class UpdateServerLocksCommandTest extends EppToolCommandTestCase<UpdateServerLocksCommand> {
@Test
public void testSuccess_applyOne() throws Exception {
runCommandForced("--client=NewRegistrar", "--registrar_request=true", "--reason=Test",
"--domain_name=example.tld", "--apply=serverRenewProhibited");
verifySent("testdata/update_server_locks_apply_one.xml", false, false);
}
@Test
public void testSuccess_multipleWordReason() throws Exception {
runCommandForced("--client=NewRegistrar", "--registrar_request=false",
"--reason=\"Test this\"", "--domain_name=example.tld", "--apply=serverRenewProhibited");
verifySent("testdata/update_server_locks_multiple_word_reason.xml", false, false);
}
@Test
public void testSuccess_removeOne() throws Exception {
runCommandForced("--client=NewRegistrar", "--registrar_request=true", "--reason=Test",
"--domain_name=example.tld", "--remove=serverRenewProhibited");
verifySent("testdata/update_server_locks_remove_one.xml", false, false);
}
@Test
public void testSuccess_applyAll() throws Exception {
runCommandForced("--client=NewRegistrar", "--registrar_request=true", "--reason=Test",
"--domain_name=example.tld", "--apply=all");
verifySent("testdata/update_server_locks_apply_all.xml", false, false);
}
@Test
public void testSuccess_removeAll() throws Exception {
runCommandForced("--client=NewRegistrar", "--registrar_request=true", "--reason=Test",
"--domain_name=example.tld", "--remove=all");
verifySent("testdata/update_server_locks_remove_all.xml", false, false);
}
@Test
public void testFailure_applyAllRemoveOne_failsDueToOverlap() throws Exception {
thrown.expect(IllegalArgumentException.class);
runCommandForced("--client=NewRegistrar", "--registrar_request=true", "--reason=Test",
"--domain_name=example.tld", "--apply=all", "--remove=serverRenewProhibited");
}
@Test
public void testFailure_illegalStatus() throws Exception {
// The EPP status is a valid one by RFC, but invalid for this command.
thrown.expect(IllegalArgumentException.class);
runCommandForced("--client=NewRegistrar", "--registrar_request=true", "--reason=Test",
"--domain_name=example.tld", "--apply=clientRenewProhibited");
}
@Test
public void testFailure_unrecognizedStatus() throws Exception {
// Handles a status passed to the command that doesn't correspond to any
// EPP-valid status.
thrown.expect(IllegalArgumentException.class);
runCommandForced("--client=NewRegistrar", "--registrar_request=true", "--reason=Test",
"--domain_name=example.tld", "--apply=foo");
}
@Test
public void testFailure_mainParameter() throws Exception {
thrown.expect(ParameterException.class);
runCommandForced("--client=NewRegistrar", "--registrar_request=true", "--reason=Test",
"--domain_name=example.tld", "example2.tld", "--apply=serverRenewProhibited");
}
@Test
public void testFailure_noOp() throws Exception {
thrown.expect(IllegalArgumentException.class);
runCommandForced("--client=NewRegistrar", "--domain_name=example.tld", "--apply=all",
"--remove=serverRenewProhibited,serverTransferProhibited,"
+ "serverDeleteProhibited,serverUpdateProhibited,serverHold",
"--registrar_request=true", "--reason=Test");
}
@Test
public void testFailure_missingClientId() throws Exception {
thrown.expect(ParameterException.class);
runCommandForced("--domain_name=example.tld", "--registrar_request=true",
"--apply=serverRenewProhibited", "--reason=Test");
}
@Test
public void testFailure_unknownFlag() throws Exception {
thrown.expect(ParameterException.class);
runCommandForced("--client=NewRegistrar", "--registrar_request=true", "--reason=Test",
"--domain_name=example.tld", "--apply=serverRenewProhibited", "--foo=bar");
}
@Test
public void testFailure_noReasonWhenNotRegistrarRequested() throws Exception {
thrown.expect(IllegalArgumentException.class);
runCommandForced("--client=NewRegistrar", "--registrar_request=false",
"--domain_name=example.tld", "--apply=serverRenewProhibited");
}
@Test
public void testFailure_missingRegistrarRequest() throws Exception {
thrown.expect(ParameterException.class);
runCommandForced("--client=NewRegistrar", "--reason=Test",
"--domain_name=example.tld", "--apply=serverRenewProhibited");
}
}

View file

@ -0,0 +1,149 @@
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.domain.registry.tools;
import static com.google.common.io.BaseEncoding.base64;
import static com.google.domain.registry.model.ofy.ObjectifyService.ofy;
import static com.google.domain.registry.testing.DatastoreHelper.createTld;
import static com.google.domain.registry.testing.DatastoreHelper.newDomainApplication;
import static com.google.domain.registry.testing.DatastoreHelper.persistResource;
import static com.google.domain.registry.testing.DomainApplicationSubject.assertAboutApplications;
import static com.google.domain.registry.util.ResourceUtils.readResourceUtf8;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.joda.time.DateTimeZone.UTC;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.domain.registry.flows.EppException.ParameterValuePolicyErrorException;
import com.google.domain.registry.flows.EppException.ParameterValueSyntaxErrorException;
import com.google.domain.registry.flows.EppException.RequiredParameterMissingException;
import com.google.domain.registry.model.domain.DomainApplication;
import com.google.domain.registry.model.reporting.HistoryEntry;
import com.google.domain.registry.model.smd.EncodedSignedMark;
import com.google.domain.registry.model.smd.SignedMarkRevocationList;
import com.google.domain.registry.tmch.TmchData;
import org.joda.time.DateTime;
import org.junit.Before;
import org.junit.Test;
/** Unit tests for {@link UpdateSmdCommandTest}. */
public class UpdateSmdCommandTest extends CommandTestCase<UpdateSmdCommand> {
/** This is the id of the SMD stored in "Court-Agent-English-Active.xml". */
public static final String ACTIVE_SMD_ID = "0000001761376042759136-65535";
DomainApplication domainApplication;
private static final String ACTIVE_SMD =
readResourceUtf8(UpdateSmdCommandTest.class, "testdata/Court-Agent-English-Active.smd");
private static final String DIFFERENT_LABEL_SMD =
readResourceUtf8(UpdateSmdCommandTest.class, "testdata/Court-Agent-Chinese-Active.smd");
private static final String INVALID_SMD =
readResourceUtf8(UpdateSmdCommandTest.class,
"testdata/InvalidSignature-Trademark-Agent-English-Active.smd");
private static final String REVOKED_TMV_SMD =
readResourceUtf8(UpdateSmdCommandTest.class,
"testdata/TMVRevoked-Trademark-Agent-English-Active.smd");
@Before
public void init() {
createTld("xn--q9jyb4c");
domainApplication = persistResource(newDomainApplication("test-validate.xn--q9jyb4c")
.asBuilder()
.setCurrentSponsorClientId("TheRegistrar")
.setEncodedSignedMarks(ImmutableList.of(EncodedSignedMark.create("base64", "garbage")))
.build());
}
private DomainApplication reloadDomainApplication() {
return ofy().load().entity(domainApplication).now();
}
@Test
public void testSuccess() throws Exception {
DateTime before = new DateTime(UTC);
String smdFile = writeToTmpFile(ACTIVE_SMD);
runCommand("--id=2-Q9JYB4C", "--smd=" + smdFile);
EncodedSignedMark encodedSignedMark = TmchData.readEncodedSignedMark(ACTIVE_SMD);
assertAboutApplications().that(reloadDomainApplication())
.hasExactlyEncodedSignedMarks(encodedSignedMark).and()
.hasLastEppUpdateTimeAtLeast(before).and()
.hasLastEppUpdateClientId("TheRegistrar").and()
.hasOnlyOneHistoryEntryWhich()
.hasType(HistoryEntry.Type.DOMAIN_APPLICATION_UPDATE).and()
.hasClientId("TheRegistrar");
}
@Test
public void testFailure_invalidSmd() throws Exception {
thrown.expectRootCause(ParameterValuePolicyErrorException.class);
String smdFile = writeToTmpFile(INVALID_SMD);
runCommand("--id=2-Q9JYB4C", "--smd=" + smdFile);
}
@Test
public void testFailure_revokedSmd() throws Exception {
thrown.expectRootCause(ParameterValuePolicyErrorException.class);
DateTime now = new DateTime(UTC);
SignedMarkRevocationList.create(now, ImmutableMap.of(ACTIVE_SMD_ID, now)).save();
String smdFile = writeToTmpFile(ACTIVE_SMD);
runCommand("--id=2-Q9JYB4C", "--smd=" + smdFile);
}
@Test
public void testFailure_revokedTmv() throws Exception {
thrown.expectRootCause(ParameterValuePolicyErrorException.class);
String smdFile = writeToTmpFile(REVOKED_TMV_SMD);
runCommand("--id=2-Q9JYB4C", "--smd=" + smdFile);
}
@Test
public void testFailure_unparseableXml() throws Exception {
thrown.expectRootCause(ParameterValueSyntaxErrorException.class);
String smdFile = writeToTmpFile(base64().encode("This is not XML!".getBytes(UTF_8)));
runCommand("--id=2-Q9JYB4C", "--smd=" + smdFile);
}
@Test
public void testFailure_badlyEncodedData() throws Exception {
thrown.expectRootCause(ParameterValueSyntaxErrorException.class);
String smdFile = writeToTmpFile("Bad base64 data ~!@#$#@%%$#^$%^&^**&^)(*)(_".getBytes(UTF_8));
runCommand("--id=2-Q9JYB4C", "--smd=" + smdFile);
}
@Test
public void testFailure_wrongLabel() throws Exception {
thrown.expectRootCause(RequiredParameterMissingException.class);
String smdFile = writeToTmpFile(DIFFERENT_LABEL_SMD);
runCommand("--id=2-Q9JYB4C", "--smd=" + smdFile);
}
@Test
public void testFailure_nonExistentApplication() throws Exception {
thrown.expectRootCause(IllegalArgumentException.class);
String smdFile = writeToTmpFile(ACTIVE_SMD);
runCommand("--id=3-Q9JYB4C", "--smd=" + smdFile);
}
@Test
public void testFailure_deletedApplication() throws Exception {
thrown.expectRootCause(IllegalArgumentException.class);
persistResource(domainApplication.asBuilder().setDeletionTime(new DateTime(UTC)).build());
String smdFile = writeToTmpFile(ACTIVE_SMD);
runCommand("--id=2-Q9JYB4C", "--smd=" + smdFile);
}
}

View file

@ -0,0 +1,767 @@
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.domain.registry.tools;
import static com.google.common.collect.Iterables.transform;
import static com.google.common.truth.Truth.assertThat;
import static com.google.domain.registry.model.registry.label.ReservedListTest.GET_NAME_FUNCTION;
import static com.google.domain.registry.testing.DatastoreHelper.createTld;
import static com.google.domain.registry.testing.DatastoreHelper.persistPremiumList;
import static com.google.domain.registry.testing.DatastoreHelper.persistReservedList;
import static com.google.domain.registry.testing.DatastoreHelper.persistResource;
import static com.google.domain.registry.util.DateTimeUtils.END_OF_TIME;
import static com.google.domain.registry.util.DateTimeUtils.START_OF_TIME;
import static org.joda.money.CurrencyUnit.JPY;
import static org.joda.money.CurrencyUnit.USD;
import static org.joda.time.DateTimeZone.UTC;
import static org.joda.time.Duration.standardMinutes;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableSortedMap;
import com.google.domain.registry.model.registry.Registry;
import com.google.domain.registry.model.registry.Registry.TldState;
import com.google.domain.registry.model.registry.label.PremiumList;
import com.beust.jcommander.ParameterException;
import com.googlecode.objectify.Key;
import org.joda.money.Money;
import org.joda.time.DateTime;
import org.junit.Before;
import org.junit.Test;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
/** Unit tests for {@link UpdateTldCommand}. */
public class UpdateTldCommandTest extends CommandTestCase<UpdateTldCommand> {
private final DateTime now = DateTime.now(UTC);
@Before
public void initTest() {
persistReservedList("common_abuse", "baa,FULLY_BLOCKED");
persistReservedList("xn--q9jyb4c_abuse", "lamb,FULLY_BLOCKED");
persistReservedList("tld_banned", "kilo,FULLY_BLOCKED", "lima,MISTAKEN_PREMIUM");
persistReservedList("soy_expurgated", "fireflies,FULLY_BLOCKED");
persistPremiumList("xn--q9jyb4c", "minecraft,USD 1000");
persistReservedList("xn--q9jyb4c_r1", "foo,FULLY_BLOCKED");
persistReservedList("xn--q9jyb4c_r2", "moop,FULLY_BLOCKED");
createTld("xn--q9jyb4c");
}
@Test
public void testSuccess_tldStateTransitions() throws Exception {
DateTime sunriseStart = now;
DateTime sunrushStart = sunriseStart.plusMonths(2);
DateTime quietPeriodStart = sunrushStart.plusMonths(1);
DateTime gaStart = quietPeriodStart.plusWeeks(1);
runCommandForced(
String.format(
"--tld_state_transitions=%s=PREDELEGATION,%s=SUNRISE,%s=SUNRUSH,%s=QUIET_PERIOD,"
+ "%s=GENERAL_AVAILABILITY",
START_OF_TIME,
sunriseStart,
sunrushStart,
quietPeriodStart,
gaStart),
"xn--q9jyb4c");
Registry registry = Registry.get("xn--q9jyb4c");
assertThat(registry.getTldState(sunriseStart.minusMillis(1))).isEqualTo(TldState.PREDELEGATION);
assertThat(registry.getTldState(sunriseStart)).isEqualTo(TldState.SUNRISE);
assertThat(registry.getTldState(sunriseStart.plusMillis(1))).isEqualTo(TldState.SUNRISE);
assertThat(registry.getTldState(sunrushStart.minusMillis(1))).isEqualTo(TldState.SUNRISE);
assertThat(registry.getTldState(sunrushStart)).isEqualTo(TldState.SUNRUSH);
assertThat(registry.getTldState(sunrushStart.plusMillis(1))).isEqualTo(TldState.SUNRUSH);
assertThat(registry.getTldState(quietPeriodStart.minusMillis(1))).isEqualTo(TldState.SUNRUSH);
assertThat(registry.getTldState(quietPeriodStart)).isEqualTo(TldState.QUIET_PERIOD);
assertThat(registry.getTldState(quietPeriodStart.plusMillis(1)))
.isEqualTo(TldState.QUIET_PERIOD);
assertThat(registry.getTldState(gaStart.minusMillis(1))).isEqualTo(TldState.QUIET_PERIOD);
assertThat(registry.getTldState(gaStart)).isEqualTo(TldState.GENERAL_AVAILABILITY);
assertThat(registry.getTldState(gaStart.plusMillis(1)))
.isEqualTo(TldState.GENERAL_AVAILABILITY);
assertThat(registry.getTldState(END_OF_TIME)).isEqualTo(TldState.GENERAL_AVAILABILITY);
}
@Test
public void testSuccess_renewBillingCostTransitions() throws Exception {
DateTime later = now.plusMonths(1);
runCommandForced(
String.format(
"--renew_billing_cost_transitions=\"%s=USD 1,%s=USD 2.00,%s=USD 100\"",
START_OF_TIME,
now,
later),
"xn--q9jyb4c");
Registry registry = Registry.get("xn--q9jyb4c");
assertThat(registry.getStandardRenewCost(START_OF_TIME)).isEqualTo(Money.of(USD, 1));
assertThat(registry.getStandardRenewCost(now.minusMillis(1))).isEqualTo(Money.of(USD, 1));
assertThat(registry.getStandardRenewCost(now)).isEqualTo(Money.of(USD, 2));
assertThat(registry.getStandardRenewCost(now.plusMillis(1))).isEqualTo(Money.of(USD, 2));
assertThat(registry.getStandardRenewCost(later.minusMillis(1))).isEqualTo(Money.of(USD, 2));
assertThat(registry.getStandardRenewCost(later)).isEqualTo(Money.of(USD, 100));
assertThat(registry.getStandardRenewCost(later.plusMillis(1))).isEqualTo(Money.of(USD, 100));
assertThat(registry.getStandardRenewCost(END_OF_TIME)).isEqualTo(Money.of(USD, 100));
}
@Test
public void testSuccess_multipleArguments() throws Exception {
assertThat(Registry.get("xn--q9jyb4c").getAddGracePeriodLength())
.isNotEqualTo(standardMinutes(5));
createTld("example");
assertThat(Registry.get("example").getAddGracePeriodLength()).isNotEqualTo(standardMinutes(5));
runCommandForced("--add_grace_period=PT300S", "xn--q9jyb4c", "example");
assertThat(Registry.get("xn--q9jyb4c").getAddGracePeriodLength()).isEqualTo(standardMinutes(5));
assertThat(Registry.get("example").getAddGracePeriodLength()).isEqualTo(standardMinutes(5));
}
@Test
public void testSuccess_addGracePeriodFlag() throws Exception {
assertThat(Registry.get("xn--q9jyb4c").getAddGracePeriodLength())
.isNotEqualTo(standardMinutes(5));
runCommandForced("--add_grace_period=PT300S", "xn--q9jyb4c");
assertThat(Registry.get("xn--q9jyb4c").getAddGracePeriodLength()).isEqualTo(standardMinutes(5));
}
@Test
public void testSuccess_redemptionGracePeriodFlag() throws Exception {
assertThat(Registry.get("xn--q9jyb4c").getRedemptionGracePeriodLength())
.isNotEqualTo(standardMinutes(5));
runCommandForced("--redemption_grace_period=PT300S", "xn--q9jyb4c");
assertThat(Registry.get("xn--q9jyb4c").getRedemptionGracePeriodLength())
.isEqualTo(standardMinutes(5));
}
@Test
public void testSuccess_pendingDeleteLengthFlag() throws Exception {
assertThat(Registry.get("xn--q9jyb4c").getPendingDeleteLength())
.isNotEqualTo(standardMinutes(5));
runCommandForced("--pending_delete_length=PT300S", "xn--q9jyb4c");
assertThat(Registry.get("xn--q9jyb4c").getPendingDeleteLength()).isEqualTo(standardMinutes(5));
}
@Test
public void testSuccess_escrow() throws Exception {
runCommandForced("--escrow=true", "xn--q9jyb4c");
assertThat(Registry.get("xn--q9jyb4c").getEscrowEnabled()).isTrue();
}
@Test
public void testSuccess_noEscrow() throws Exception {
runCommandForced("--escrow=false", "xn--q9jyb4c");
assertThat(Registry.get("xn--q9jyb4c").getEscrowEnabled()).isFalse();
}
@Test
public void testSuccess_createBillingCostFlag() throws Exception {
runCommandForced("--create_billing_cost=\"USD 42.42\"", "xn--q9jyb4c");
assertThat(Registry.get("xn--q9jyb4c").getStandardCreateCost()).isEqualTo(Money.of(USD, 42.42));
}
@Test
public void testSuccess_restoreBillingCostFlag() throws Exception {
runCommandForced("--restore_billing_cost=\"USD 42.42\"", "xn--q9jyb4c");
assertThat(Registry.get("xn--q9jyb4c").getStandardRestoreCost())
.isEqualTo(Money.of(USD, 42.42));
}
@Test
public void testSuccess_nonUsdBillingCostFlag() throws Exception {
persistResource(
Registry.get("xn--q9jyb4c")
.asBuilder()
.setCurrency(JPY)
.setCreateBillingCost(Money.ofMajor(JPY, 1))
.setRestoreBillingCost(Money.ofMajor(JPY, 1))
.setRenewBillingCostTransitions(
ImmutableSortedMap.of(START_OF_TIME, Money.ofMajor(JPY, 1)))
.setServerStatusChangeBillingCost(Money.ofMajor(JPY, 1))
.build());
runCommandForced(
"--create_billing_cost=\"JPY 12345\"",
"--restore_billing_cost=\"JPY 67890\"",
"--renew_billing_cost_transitions=\"0=JPY 101112\"",
"--server_status_change_cost=\"JPY 97865\"",
"xn--q9jyb4c");
assertThat(Registry.get("xn--q9jyb4c").getStandardCreateCost())
.isEqualTo(Money.ofMajor(JPY, 12345));
assertThat(Registry.get("xn--q9jyb4c").getStandardRestoreCost())
.isEqualTo(Money.ofMajor(JPY, 67890));
assertThat(Registry.get("xn--q9jyb4c").getStandardRenewCost(START_OF_TIME))
.isEqualTo(Money.ofMajor(JPY, 101112));
}
@Test
public void testSuccess_setPremiumPriceAckRequired() throws Exception {
runCommandForced("--premium_price_ack_required=true", "xn--q9jyb4c");
assertThat(Registry.get("xn--q9jyb4c").getPremiumPriceAckRequired()).isTrue();
}
@Test
public void testSuccess_clearPremiumPriceAckRequired() throws Exception {
persistResource(Registry.get("xn--q9jyb4c").asBuilder().setPremiumPriceAckRequired(true).build());
runCommandForced("--premium_price_ack_required=false", "xn--q9jyb4c");
assertThat(Registry.get("xn--q9jyb4c").getPremiumPriceAckRequired()).isFalse();
}
@Test
public void testSuccess_setLordnUsername() throws Exception {
runCommandForced("--lordn_username=lordn000", "xn--q9jyb4c");
assertThat(Registry.get("xn--q9jyb4c").getLordnUsername()).isEqualTo("lordn000");
}
@Test
public void testSuccess_setOptionalParamsNullString() throws Exception {
persistResource(Registry.get("xn--q9jyb4c").asBuilder().setLordnUsername("lordn000").build());
runCommandForced("--lordn_username=null", "xn--q9jyb4c");
assertThat(Registry.get("xn--q9jyb4c").getLordnUsername()).isNull();
}
@Test
public void testSuccess_setOptionalParamsEmptyString() throws Exception {
persistResource(Registry.get("xn--q9jyb4c").asBuilder().setLordnUsername("lordn000").build());
runCommandForced("--lordn_username=", "xn--q9jyb4c");
assertThat(Registry.get("xn--q9jyb4c").getLordnUsername()).isNull();
}
@Test
public void testSuccess_setReservedLists() throws Exception {
runCommandForced("--reserved_lists=xn--q9jyb4c_r1,xn--q9jyb4c_r2", "xn--q9jyb4c");
assertThat(transform(Registry.get("xn--q9jyb4c").getReservedLists(), GET_NAME_FUNCTION))
.containsExactly("xn--q9jyb4c_r1", "xn--q9jyb4c_r2");
}
@Test
public void testSuccess_setReservedListsOverwrites() throws Exception {
persistResource(Registry.get("xn--q9jyb4c").asBuilder()
.setReservedListsByName(ImmutableSet.of("xn--q9jyb4c_r1", "xn--q9jyb4c_r2"))
.build());
runCommandForced("--reserved_lists=xn--q9jyb4c_r2", "xn--q9jyb4c");
assertThat(transform(Registry.get("xn--q9jyb4c").getReservedLists(), GET_NAME_FUNCTION))
.containsExactly("xn--q9jyb4c_r2");
}
@Test
public void testSuccess_addReservedLists() throws Exception {
persistResource(Registry.get("xn--q9jyb4c").asBuilder()
.setReservedListsByName(ImmutableSet.of("xn--q9jyb4c_r1"))
.build());
runCommandForced("--add_reserved_lists=xn--q9jyb4c_r2", "xn--q9jyb4c");
assertThat(transform(Registry.get("xn--q9jyb4c").getReservedLists(), GET_NAME_FUNCTION))
.containsExactly("xn--q9jyb4c_r1", "xn--q9jyb4c_r2");
}
@Test
public void testSuccess_removeAllReservedLists() throws Exception {
persistResource(Registry.get("xn--q9jyb4c").asBuilder()
.setReservedListsByName(ImmutableSet.of("xn--q9jyb4c_r1", "xn--q9jyb4c_r2"))
.build());
runCommandForced("--remove_reserved_lists=xn--q9jyb4c_r1,xn--q9jyb4c_r2", "xn--q9jyb4c");
assertThat(Registry.get("xn--q9jyb4c").getReservedLists()).isEmpty();
}
@Test
public void testSuccess_removeSomeReservedLists() throws Exception {
persistResource(Registry.get("xn--q9jyb4c").asBuilder()
.setReservedListsByName(ImmutableSet.of("xn--q9jyb4c_r1", "xn--q9jyb4c_r2"))
.build());
runCommandForced("--remove_reserved_lists=xn--q9jyb4c_r1", "xn--q9jyb4c");
assertThat(transform(Registry.get("xn--q9jyb4c").getReservedLists(), GET_NAME_FUNCTION))
.containsExactly("xn--q9jyb4c_r2");
}
@Test
public void testSuccess_setAllowedRegistrants() throws Exception {
runCommandForced("--allowed_registrants=alice,bob", "xn--q9jyb4c");
assertThat(Registry.get("xn--q9jyb4c").getAllowedRegistrantContactIds())
.containsExactly("alice", "bob");
}
@Test
public void testSuccess_setAllowedRegistrantsOverwrites() throws Exception {
persistResource(
Registry.get("xn--q9jyb4c").asBuilder()
.setAllowedRegistrantContactIds(ImmutableSet.of("jane", "john"))
.build());
runCommandForced("--allowed_registrants=alice,bob", "xn--q9jyb4c");
assertThat(Registry.get("xn--q9jyb4c").getAllowedRegistrantContactIds())
.containsExactly("alice", "bob");
}
@Test
public void testSuccess_addAllowedRegistrants() throws Exception {
persistResource(
Registry.get("xn--q9jyb4c").asBuilder()
.setAllowedRegistrantContactIds(ImmutableSet.of("alice"))
.build());
runCommandForced("--add_allowed_registrants=bob", "xn--q9jyb4c");
assertThat(Registry.get("xn--q9jyb4c").getAllowedRegistrantContactIds())
.containsExactly("alice", "bob");
}
@Test
public void testSuccess_removeAllAllowedRegistrants() throws Exception {
persistResource(
Registry.get("xn--q9jyb4c").asBuilder()
.setAllowedRegistrantContactIds(ImmutableSet.of("alice", "bob"))
.build());
runCommandForced("--remove_allowed_registrants=alice,bob", "xn--q9jyb4c");
assertThat(Registry.get("xn--q9jyb4c").getAllowedRegistrantContactIds()).isEmpty();
}
@Test
public void testSuccess_removeSomeAllowedRegistrants() throws Exception {
persistResource(
Registry.get("xn--q9jyb4c").asBuilder()
.setAllowedRegistrantContactIds(ImmutableSet.of("alice", "bob"))
.build());
runCommandForced("--remove_allowed_registrants=alice", "xn--q9jyb4c");
assertThat(Registry.get("xn--q9jyb4c").getAllowedRegistrantContactIds()).containsExactly("bob");
}
@Test
public void testSuccess_setAllowedNameservers() throws Exception {
runCommandForced("--allowed_nameservers=ns1.example.com,ns2.example.com", "xn--q9jyb4c");
assertThat(Registry.get("xn--q9jyb4c").getAllowedFullyQualifiedHostNames())
.containsExactly("ns1.example.com", "ns2.example.com");
}
@Test
public void testSuccess_setAllowedNameserversOverwrites() throws Exception {
persistResource(
Registry.get("xn--q9jyb4c").asBuilder()
.setAllowedFullyQualifiedHostNames(
ImmutableSet.of("ns1.example.tld", "ns2.example.tld"))
.build());
runCommandForced("--allowed_nameservers=ns1.example.com,ns2.example.com", "xn--q9jyb4c");
assertThat(Registry.get("xn--q9jyb4c").getAllowedFullyQualifiedHostNames())
.containsExactly("ns1.example.com", "ns2.example.com");
}
@Test
public void testSuccess_addAllowedNameservers() throws Exception {
persistResource(
Registry.get("xn--q9jyb4c").asBuilder()
.setAllowedFullyQualifiedHostNames(ImmutableSet.of("ns1.example.com"))
.build());
runCommandForced("--add_allowed_nameservers=ns2.example.com", "xn--q9jyb4c");
assertThat(Registry.get("xn--q9jyb4c").getAllowedFullyQualifiedHostNames())
.containsExactly("ns1.example.com", "ns2.example.com");
}
@Test
public void testSuccess_removeAllAllowedNameservers() throws Exception {
persistResource(
Registry.get("xn--q9jyb4c").asBuilder()
.setAllowedFullyQualifiedHostNames(
ImmutableSet.of("ns1.example.com", "ns2.example.com"))
.build());
runCommandForced("--remove_allowed_nameservers=ns1.example.com,ns2.example.com", "xn--q9jyb4c");
assertThat(Registry.get("xn--q9jyb4c").getAllowedFullyQualifiedHostNames()).isEmpty();
}
@Test
public void testSuccess_removeSomeAllowedNameservers() throws Exception {
persistResource(
Registry.get("xn--q9jyb4c").asBuilder()
.setAllowedFullyQualifiedHostNames(
ImmutableSet.of("ns1.example.com", "ns2.example.com"))
.build());
runCommandForced("--remove_allowed_nameservers=ns1.example.com", "xn--q9jyb4c");
assertThat(Registry.get("xn--q9jyb4c").getAllowedFullyQualifiedHostNames())
.containsExactly("ns2.example.com");
}
@Test
public void testFailure_invalidAddGracePeriod() throws Exception {
thrown.expect(IllegalArgumentException.class);
runCommandForced("--add_grace_period=5m", "xn--q9jyb4c");
}
@Test
public void testFailure_invalidRedemptionGracePeriod() throws Exception {
thrown.expect(IllegalArgumentException.class);
runCommandForced("--redemption_grace_period=5m", "xn--q9jyb4c");
}
@Test
public void testFailure_invalidPendingDeleteLength() throws Exception {
thrown.expect(IllegalArgumentException.class);
runCommandForced("--pending_delete_length=5m", "xn--q9jyb4c");
}
@Test
public void testFailure_invalidTldState() throws Exception {
thrown.expect(ParameterException.class);
runCommandForced("--tld_state_transitions=" + START_OF_TIME + "=INVALID_STATE", "xn--q9jyb4c");
}
@Test
public void testFailure_invalidTldStateTransitionTime() throws Exception {
thrown.expect(ParameterException.class);
runCommandForced("--tld_state_transitions=tomorrow=INVALID_STATE", "xn--q9jyb4c");
}
@Test
public void testFailure_tldStatesOutOfOrder() throws Exception {
thrown.expect(IllegalArgumentException.class);
runCommandForced(
String.format(
"--tld_state_transitions=%s=SUNRISE,%s=PREDELEGATION", now, now.plusMonths(1)),
"xn--q9jyb4c");
}
@Test
public void testFailure_duplicateTldStateTransitions() throws Exception {
thrown.expect(IllegalArgumentException.class);
runCommandForced(
String.format("--tld_state_transitions=%s=SUNRISE,%s=SUNRISE", now, now.plusMonths(1)),
"xn--q9jyb4c");
}
@Test
public void testFailure_duplicateTldStateTransitionTimes() throws Exception {
thrown.expect(ParameterException.class);
runCommandForced(
String.format("--tld_state_transitions=%s=PREDELEGATION,%s=SUNRISE", now, now),
"xn--q9jyb4c");
}
@Test
public void testFailure_outOfOrderTldStateTransitionTimes() throws Exception {
thrown.expect(ParameterException.class);
runCommandForced(
String.format("--tld_state_transitions=%s=PREDELEGATION,%s=SUNRISE", now, now.minus(1)),
"xn--q9jyb4c");
}
@Test
public void testFailure_invalidRenewBillingCost() throws Exception {
thrown.expect(ParameterException.class);
runCommandForced(
String.format("--renew_billing_cost_transitions=%s=US42", START_OF_TIME),
"xn--q9jyb4c");
}
@Test
public void testFailure_negativeRenewBillingCost() throws Exception {
thrown.expect(IllegalArgumentException.class);
runCommandForced(
String.format("--renew_billing_cost_transitions=%s=USD-42", START_OF_TIME),
"xn--q9jyb4c");
}
@Test
public void testFailure_invalidRenewCostTransitionTime() throws Exception {
thrown.expect(ParameterException.class);
runCommandForced("--renew_billing_cost_transitions=tomorrow=USD 1", "xn--q9jyb4c");
}
@Test
public void testFailure_duplicateRenewCostTransitionTimes() throws Exception {
thrown.expect(ParameterException.class);
runCommandForced(
String.format("--renew_billing_cost_transitions=\"%s=USD 1,%s=USD 2\"", now, now),
"xn--q9jyb4c");
}
@Test
public void testFailure_outOfOrderRenewCostTransitionTimes() throws Exception {
thrown.expect(ParameterException.class);
runCommandForced(
String.format("--renew_billing_cost_transitions=\"%s=USD 1,%s=USD 2\"", now, now.minus(1)),
"xn--q9jyb4c");
}
@Test
public void testFailure_noTldName() throws Exception {
thrown.expect(ParameterException.class);
runCommandForced();
}
@Test
public void testFailure_oneArgumentDoesNotExist() throws Exception {
thrown.expect(IllegalArgumentException.class);
runCommandForced("foo", "xn--q9jyb4c");
}
@Test
public void testFailure_duplicateArguments() throws Exception {
thrown.expect(IllegalArgumentException.class);
runCommandForced("xn--q9jyb4c", "xn--q9jyb4c");
}
@Test
public void testFailure_tldDoesNotExist() throws Exception {
thrown.expect(IllegalArgumentException.class);
runCommandForced("foobarbaz");
}
@Test
public void testFailure_setNonExistentReservedLists() throws Exception {
thrown.expect(
IllegalStateException.class,
"Could not find reserved list xn--q9jyb4c_ZZZ to add to the tld");
runCommandForced("--reserved_lists", "xn--q9jyb4c_ZZZ", "xn--q9jyb4c");
}
@Test
public void testFailure_cantAddDuplicateReservedList() throws Exception {
persistResource(Registry.get("xn--q9jyb4c").asBuilder()
.setReservedListsByName(ImmutableSet.of("xn--q9jyb4c_r1", "xn--q9jyb4c_r2"))
.build());
thrown.expect(IllegalArgumentException.class, "xn--q9jyb4c_r1");
runCommandForced("--add_reserved_lists=xn--q9jyb4c_r1", "xn--q9jyb4c");
}
@Test
public void testFailure_cantRemoveReservedListThatIsntPresent() throws Exception {
persistResource(Registry.get("xn--q9jyb4c").asBuilder()
.setReservedListsByName(ImmutableSet.of("xn--q9jyb4c_r1", "xn--q9jyb4c_r2"))
.build());
thrown.expect(IllegalArgumentException.class, "xn--q9jyb4c_Z");
runCommandForced("--remove_reserved_lists=xn--q9jyb4c_Z", "xn--q9jyb4c");
}
@Test
public void testFailure_cantAddAndRemoveSameReservedListSimultaneously() throws Exception {
thrown.expect(IllegalArgumentException.class, "xn--q9jyb4c_r1");
runCommandForced(
"--add_reserved_lists=xn--q9jyb4c_r1",
"--remove_reserved_lists=xn--q9jyb4c_r1",
"xn--q9jyb4c");
}
@Test
public void testFailure_cantAddDuplicateAllowedRegistrants() throws Exception {
persistResource(
Registry.get("xn--q9jyb4c").asBuilder()
.setAllowedRegistrantContactIds(ImmutableSet.of("alice", "bob"))
.build());
thrown.expect(IllegalArgumentException.class, "alice");
runCommandForced("--add_allowed_registrants=alice", "xn--q9jyb4c");
}
@Test
public void testFailure_cantRemoveAllowedRegistrantThatIsntPresent() throws Exception {
persistResource(
Registry.get("xn--q9jyb4c").asBuilder()
.setAllowedRegistrantContactIds(ImmutableSet.of("alice"))
.build());
thrown.expect(IllegalArgumentException.class, "bob");
runCommandForced("--remove_allowed_registrants=bob", "xn--q9jyb4c");
}
@Test
public void testFailure_cantAddAndRemoveSameAllowedRegistrantsSimultaneously() throws Exception {
thrown.expect(IllegalArgumentException.class, "alice");
runCommandForced(
"--add_allowed_registrants=alice",
"--remove_allowed_registrants=alice",
"xn--q9jyb4c");
}
@Test
public void testFailure_cantAddDuplicateAllowedNameservers() throws Exception {
persistResource(
Registry.get("xn--q9jyb4c").asBuilder()
.setAllowedFullyQualifiedHostNames(
ImmutableSet.of("ns1.example.com", "ns2.example.com"))
.build());
thrown.expect(IllegalArgumentException.class, "ns1.example.com");
runCommandForced("--add_allowed_nameservers=ns1.example.com", "xn--q9jyb4c");
}
@Test
public void testFailure_cantRemoveAllowedNameserverThatIsntPresent() throws Exception {
persistResource(
Registry.get("xn--q9jyb4c").asBuilder()
.setAllowedFullyQualifiedHostNames(
ImmutableSet.of("ns1.example.com"))
.build());
thrown.expect(IllegalArgumentException.class, "ns2.example.com");
runCommandForced("--remove_allowed_nameservers=ns2.example.com", "xn--q9jyb4c");
}
@Test
public void testFailure_cantAddAndRemoveSameAllowedNameserversSimultaneously() throws Exception {
thrown.expect(IllegalArgumentException.class, "ns1.example.com");
runCommandForced(
"--add_allowed_nameservers=ns1.example.com",
"--remove_allowed_nameservers=ns1.example.com",
"xn--q9jyb4c");
}
@Test
public void testFailure_roidSuffixAlreadyInUse() throws Exception {
createTld("foo", "BLAH");
createTld("bar", "BAR");
thrown.expect(IllegalArgumentException.class, "The roid suffix BLAH is already in use");
runCommandForced("--roid_suffix=BLAH", "bar");
}
@Test
public void testSuccess_canSetRoidSuffixToWhatItAlreadyIs() throws Exception {
createTld("foo", "BLAH");
runCommandForced("--roid_suffix=BLAH", "foo");
assertThat(Registry.get("foo").getRoidSuffix()).isEqualTo("BLAH");
}
@Test
public void testSuccess_updateRoidSuffix() throws Exception {
createTld("foo", "ARGLE");
runCommandForced("--roid_suffix=BARGLE", "foo");
assertThat(Registry.get("foo").getRoidSuffix()).isEqualTo("BARGLE");
}
@Test
public void testSuccess_removePremiumListWithNull() throws Exception {
runCommandForced("--premium_list=null", "xn--q9jyb4c");
assertThat(Registry.get("xn--q9jyb4c").getPremiumList()).isNull();
}
@Test
public void testSuccess_removePremiumListWithBlank() throws Exception {
runCommandForced("--premium_list=", "xn--q9jyb4c");
assertThat(Registry.get("xn--q9jyb4c").getPremiumList()).isNull();
}
@Test
public void testSuccess_premiumListNotRemovedWhenNotSpecified() throws Exception {
runCommandForced("--add_reserved_lists=xn--q9jyb4c_r1,xn--q9jyb4c_r2", "xn--q9jyb4c");
Key<PremiumList> premiumListKey = Registry.get("xn--q9jyb4c").getPremiumList();
assertThat(premiumListKey).isNotNull();
assertThat(premiumListKey.getName()).isEqualTo("xn--q9jyb4c");
}
@Test
public void testSuccess_driveFolderId_notRemovedWhenNotSpecified() throws Exception {
persistResource(Registry.get("xn--q9jyb4c").asBuilder().setDriveFolderId("foobar").build());
runCommandForced("xn--q9jyb4c");
assertThat(Registry.get("xn--q9jyb4c").getDriveFolderId()).isEqualTo("foobar");
}
@Test
public void testSuccess_setCommonReservedListOnTld() throws Exception {
runSuccessfulReservedListsTest("common_abuse");
}
@Test
public void testSuccess_setTldSpecificReservedListOnTld() throws Exception {
runSuccessfulReservedListsTest("xn--q9jyb4c_abuse");
}
@Test
public void testSuccess_setCommonReservedListAndTldSpecificReservedListOnTld() throws Exception {
runSuccessfulReservedListsTest("common_abuse,xn--q9jyb4c_abuse");
}
@Test
public void testFailure_setReservedListFromOtherTld() throws Exception {
runFailureReservedListsTest("tld_banned",
IllegalArgumentException.class,
"The reserved list(s) tld_banned cannot be applied to the tld xn--q9jyb4c");
}
@Test
public void testSuccess_setReservedListFromOtherTld_withOverride() throws Exception {
runReservedListsTestOverride("tld_banned");
}
@Test
public void testFailure_setCommonAndReservedListFromOtherTld() throws Exception {
runFailureReservedListsTest("common_abuse,tld_banned",
IllegalArgumentException.class,
"The reserved list(s) tld_banned cannot be applied to the tld xn--q9jyb4c");
}
@Test
public void testSuccess_setCommonAndReservedListFromOtherTld_withOverride() throws Exception {
ByteArrayOutputStream errContent = new ByteArrayOutputStream();
System.setErr(new PrintStream(errContent));
runReservedListsTestOverride("common_abuse,tld_banned");
String errMsg =
"Error overriden: The reserved list(s) tld_banned cannot be applied to the tld xn--q9jyb4c";
assertThat(errContent.toString()).contains(errMsg);
System.setOut(null);
}
@Test
public void testFailure_setMultipleReservedListsFromOtherTld() throws Exception {
runFailureReservedListsTest("tld_banned,soy_expurgated",
IllegalArgumentException.class,
"The reserved list(s) tld_banned, soy_expurgated cannot be applied to the tld xn--q9jyb4c");
}
@Test
public void testSuccess_setMultipleReservedListsFromOtherTld_withOverride() throws Exception {
runReservedListsTestOverride("tld_banned,soy_expurgated");
}
@Test
public void testSuccess_setPremiumList() throws Exception {
runCommandForced("--premium_list=xn--q9jyb4c", "xn--q9jyb4c");
assertThat(Registry.get("xn--q9jyb4c").getPremiumList().getName()).isEqualTo("xn--q9jyb4c");
}
@Test
public void testSuccess_setDriveFolderIdToValue() throws Exception {
runCommandForced("--drive_folder_id=madmax2030", "xn--q9jyb4c");
assertThat(Registry.get("xn--q9jyb4c").getDriveFolderId()).isEqualTo("madmax2030");
}
@Test
public void testSuccess_setDriveFolderIdToNull() throws Exception {
runCommandForced("--drive_folder_id=null", "xn--q9jyb4c");
assertThat(Registry.get("xn--q9jyb4c").getDriveFolderId()).isNull();
}
@Test
public void testFailure_setPremiumListThatDoesntExist() throws Exception {
thrown.expect(IllegalArgumentException.class, "The premium list 'phonies' doesn't exist");
runCommandForced("--premium_list=phonies", "xn--q9jyb4c");
}
private void runSuccessfulReservedListsTest(String reservedLists) throws Exception {
runCommandForced("--reserved_lists", reservedLists, "xn--q9jyb4c");
}
private void runReservedListsTestOverride(String reservedLists) throws Exception {
runCommandForced("--override_reserved_list_rules",
"--reserved_lists",
reservedLists,
"xn--q9jyb4c");
}
private void runFailureReservedListsTest(
String reservedLists,
Class<? extends Exception> errorClass,
String errorMsg) throws Exception {
thrown.expect(errorClass, errorMsg);
runCommandForced("--reserved_lists", reservedLists, "xn--q9jyb4c");
}
}

View file

@ -0,0 +1,165 @@
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.domain.registry.tools;
import static com.google.common.truth.Truth.assertThat;
import com.google.domain.registry.model.tmch.ClaimsListShard;
import org.joda.time.DateTime;
import org.junit.Test;
import java.io.FileNotFoundException;
/** Unit tests for {@link UploadClaimsListCommand}. */
public class UploadClaimsListCommandTest extends CommandTestCase<UploadClaimsListCommand> {
@Test
public void testSuccess() throws Exception {
String filename = writeToTmpFile(
"1,2012-08-16T00:00:00.0Z",
"DNL,lookup-key,insertion-datetime",
"example,2013041500/2/6/9/rJ1NrDO92vDsAzf7EQzgjX4R0000000001,2010-07-14T00:00:00.0Z",
"another-example,2013041500/6/A/5/alJAqG2vI2BmCv5PfUvuDkf40000000002,2012-08-16T00:00:00.0Z",
"anotherexample,2013041500/A/C/7/rHdC4wnrWRvPY6nneCVtQhFj0000000003,2011-08-16T12:00:00.0Z");
runCommand("--force", filename);
ClaimsListShard claimsList = ClaimsListShard.get();
assertThat(claimsList.getCreationTime()).isEqualTo(DateTime.parse("2012-08-16T00:00:00.0Z"));
assertThat(claimsList.getClaimKey("example"))
.isEqualTo("2013041500/2/6/9/rJ1NrDO92vDsAzf7EQzgjX4R0000000001");
assertThat(claimsList.getClaimKey("another-example"))
.isEqualTo("2013041500/6/A/5/alJAqG2vI2BmCv5PfUvuDkf40000000002");
assertThat(claimsList.getClaimKey("anotherexample"))
.isEqualTo("2013041500/A/C/7/rHdC4wnrWRvPY6nneCVtQhFj0000000003");
}
public void testFailure_wrongNumberOfFieldsOnFirstLine() throws Exception {
thrown.expect(IllegalArgumentException.class);
String filename = writeToTmpFile(
"1,2012-08-16T00:00:00.0Z,random-extra-field",
"DNL,lookup-key,insertion-datetime",
"example,2013041500/2/6/9/rJ1NrDO92vDsAzf7EQzgjX4R0000000001,2010-07-14T00:00:00.0Z",
"another-example,2013041500/6/A/5/alJAqG2vI2BmCv5PfUvuDkf40000000002,2012-08-16T00:00:00.0Z",
"anotherexample,2013041500/A/C/7/rHdC4wnrWRvPY6nneCVtQhFj0000000003,2011-08-16T12:00:00.0Z");
runCommand("--force", filename);
}
public void testFailure_wrongVersion() throws Exception {
thrown.expect(IllegalArgumentException.class);
String filename = writeToTmpFile(
"2,2012-08-16T00:00:00.0Z",
"DNL,lookup-key,insertion-datetime",
"example,2013041500/2/6/9/rJ1NrDO92vDsAzf7EQzgjX4R0000000001,2010-07-14T00:00:00.0Z",
"another-example,2013041500/6/A/5/alJAqG2vI2BmCv5PfUvuDkf40000000002,2012-08-16T00:00:00.0Z",
"anotherexample,2013041500/A/C/7/rHdC4wnrWRvPY6nneCVtQhFj0000000003,2011-08-16T12:00:00.0Z");
runCommand("--force", filename);
}
public void testFailure_badCreationTime() throws Exception {
thrown.expect(IllegalArgumentException.class);
String filename = writeToTmpFile(
"1,foo",
"DNL,lookup-key,insertion-datetime",
"example,2013041500/2/6/9/rJ1NrDO92vDsAzf7EQzgjX4R0000000001,2010-07-14T00:00:00.0Z",
"another-example,2013041500/6/A/5/alJAqG2vI2BmCv5PfUvuDkf40000000002,2012-08-16T00:00:00.0Z",
"anotherexample,2013041500/A/C/7/rHdC4wnrWRvPY6nneCVtQhFj0000000003,2011-08-16T12:00:00.0Z");
runCommand("--force", filename);
}
public void testFailure_badFirstHeader() throws Exception {
thrown.expect(IllegalArgumentException.class);
String filename = writeToTmpFile(
"1,foo",
"SNL,lookup-key,insertion-datetime",
"example,2013041500/2/6/9/rJ1NrDO92vDsAzf7EQzgjX4R0000000001,2010-07-14T00:00:00.0Z",
"another-example,2013041500/6/A/5/alJAqG2vI2BmCv5PfUvuDkf40000000002,2012-08-16T00:00:00.0Z",
"anotherexample,2013041500/A/C/7/rHdC4wnrWRvPY6nneCVtQhFj0000000003,2011-08-16T12:00:00.0Z");
runCommand("--force", filename);
}
public void testFailure_badSecondHeader() throws Exception {
thrown.expect(IllegalArgumentException.class);
String filename = writeToTmpFile(
"1,foo",
"DNL,lookup-keys,insertion-datetime",
"example,2013041500/2/6/9/rJ1NrDO92vDsAzf7EQzgjX4R0000000001,2010-07-14T00:00:00.0Z",
"another-example,2013041500/6/A/5/alJAqG2vI2BmCv5PfUvuDkf40000000002,2012-08-16T00:00:00.0Z",
"anotherexample,2013041500/A/C/7/rHdC4wnrWRvPY6nneCVtQhFj0000000003,2011-08-16T12:00:00.0Z");
runCommand("--force", filename);
}
public void testFailure_badThirdHeader() throws Exception {
thrown.expect(IllegalArgumentException.class);
String filename = writeToTmpFile(
"1,foo",
"DNL,lookup-key,insertion-datetimes",
"example,2013041500/2/6/9/rJ1NrDO92vDsAzf7EQzgjX4R0000000001,2010-07-14T00:00:00.0Z",
"another-example,2013041500/6/A/5/alJAqG2vI2BmCv5PfUvuDkf40000000002,2012-08-16T00:00:00.0Z",
"anotherexample,2013041500/A/C/7/rHdC4wnrWRvPY6nneCVtQhFj0000000003,2011-08-16T12:00:00.0Z");
runCommand("--force", filename);
}
public void testFailure_wrongNumberOfHeaders() throws Exception {
thrown.expect(IllegalArgumentException.class);
String filename = writeToTmpFile(
"1,foo",
"DNL,lookup-key,insertion-datetime,extra-field",
"example,2013041500/2/6/9/rJ1NrDO92vDsAzf7EQzgjX4R0000000001,2010-07-14T00:00:00.0Z",
"another-example,2013041500/6/A/5/alJAqG2vI2BmCv5PfUvuDkf40000000002,2012-08-16T00:00:00.0Z",
"anotherexample,2013041500/A/C/7/rHdC4wnrWRvPY6nneCVtQhFj0000000003,2011-08-16T12:00:00.0Z");
runCommand("--force", filename);
}
public void testFailure_wrongNumberOfFields() throws Exception {
thrown.expect(IllegalArgumentException.class);
String filename = writeToTmpFile(
"1,foo",
"DNL,lookup-key,insertion-datetime",
"example,2013041500/2/6/9/rJ1NrDO92vDsAzf7EQzgjX4R0000000001,2010-07-14T00:00:00.0Z,extra",
"another-example,2013041500/6/A/5/alJAqG2vI2BmCv5PfUvuDkf40000000002,2012-08-16T00:00:00.0Z",
"anotherexample,2013041500/A/C/7/rHdC4wnrWRvPY6nneCVtQhFj0000000003,2011-08-16T12:00:00.0Z");
runCommand("--force", filename);
}
public void testFailure_badInsertionTime() throws Exception {
thrown.expect(IllegalArgumentException.class);
String filename = writeToTmpFile(
"1,foo",
"DNL,lookup-key,insertion-datetime",
"example,2013041500/2/6/9/rJ1NrDO92vDsAzf7EQzgjX4R0000000001,2010-07-14T00:00:00.0Z",
"another-example,2013041500/6/A/5/alJAqG2vI2BmCv5PfUvuDkf40000000002,foo",
"anotherexample,2013041500/A/C/7/rHdC4wnrWRvPY6nneCVtQhFj0000000003,2011-08-16T12:00:00.0Z");
runCommand("--force", filename);
}
@Test
public void testFailure_fileDoesNotExist() throws Exception {
thrown.expect(FileNotFoundException.class);
runCommand("--force", "nonexistent_file.csv");
}
@Test
public void testFailure_noFileNamePassed() throws Exception {
thrown.expect(IllegalArgumentException.class);
runCommand("--force");
}
@Test
public void testFailure_tooManyArguments() throws Exception {
thrown.expect(IllegalArgumentException.class);
runCommand("--force", "foo", "bar");
}
}

View file

@ -0,0 +1,109 @@
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.domain.registry.tools;
import static com.google.common.truth.Truth.assertThat;
import com.google.domain.registry.rde.RdeTestData;
import com.google.domain.registry.xml.XmlException;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
/** Unit tests for {@link ValidateEscrowDepositCommand}. */
@RunWith(JUnit4.class)
public class ValidateEscrowDepositCommandTest
extends CommandTestCase<ValidateEscrowDepositCommand> {
@Test
public void testRun_plainXml() throws Exception {
String file = writeToTmpFile(RdeTestData.get("deposit_full.xml").read());
runCommand("--input=" + file);
assertThat(getStdoutAsString()).isEqualTo(""
+ "ID: 20101017001\n"
+ "Previous ID: 20101010001\n"
+ "Type: FULL\n"
+ "Watermark: 2010-10-17T00:00:00.000Z\n"
+ "RDE Version: 1.0\n"
+ "\n"
+ "RDE Object URIs:\n"
+ " - urn:ietf:params:xml:ns:rdeContact-1.0\n"
+ " - urn:ietf:params:xml:ns:rdeDomain-1.0\n"
+ " - urn:ietf:params:xml:ns:rdeEppParams-1.0\n"
+ " - urn:ietf:params:xml:ns:rdeHeader-1.0\n"
+ " - urn:ietf:params:xml:ns:rdeHost-1.0\n"
+ " - urn:ietf:params:xml:ns:rdeIDN-1.0\n"
+ " - urn:ietf:params:xml:ns:rdeNNDN-1.0\n"
+ " - urn:ietf:params:xml:ns:rdeRegistrar-1.0\n"
+ "\n"
+ "Contents:\n"
+ " - XjcRdeContact: 1 entry\n"
+ " - XjcRdeDomain: 2 entries\n"
+ " - XjcRdeEppParams: 1 entry\n"
+ " - XjcRdeHeader: 1 entry\n"
+ " - XjcRdeHost: 2 entries\n"
+ " - XjcRdeIdn: 1 entry\n"
+ " - XjcRdeNndn: 1 entry\n"
+ " - XjcRdePolicy: 1 entry\n"
+ " - XjcRdeRegistrar: 1 entry\n"
+ "\n"
+ "RDE deposit is XML schema valid\n");
}
@Test
public void testRun_plainXml_badReference() throws Exception {
String file = writeToTmpFile(RdeTestData.get("deposit_full_badref.xml").read());
runCommand("--input=" + file);
assertThat(getStdoutAsString()).isEqualTo(""
+ "ID: 20101017001\n"
+ "Previous ID: 20101010001\n"
+ "Type: FULL\n"
+ "Watermark: 2010-10-17T00:00:00.000Z\n"
+ "RDE Version: 1.0\n"
+ "\n"
+ "RDE Object URIs:\n"
+ " - urn:ietf:params:xml:ns:rdeContact-1.0\n"
+ " - urn:ietf:params:xml:ns:rdeDomain-1.0\n"
+ " - urn:ietf:params:xml:ns:rdeEppParams-1.0\n"
+ " - urn:ietf:params:xml:ns:rdeHeader-1.0\n"
+ " - urn:ietf:params:xml:ns:rdeHost-1.0\n"
+ " - urn:ietf:params:xml:ns:rdeIDN-1.0\n"
+ " - urn:ietf:params:xml:ns:rdeNNDN-1.0\n"
+ " - urn:ietf:params:xml:ns:rdeRegistrar-1.0\n"
+ "\n"
+ "Contents:\n"
+ " - XjcRdeContact: 1 entry\n"
+ " - XjcRdeDomain: 2 entries\n"
+ " - XjcRdeEppParams: 1 entry\n"
+ " - XjcRdeHeader: 1 entry\n"
+ " - XjcRdeHost: 2 entries\n"
+ " - XjcRdeIdn: 1 entry\n"
+ " - XjcRdeNndn: 1 entry\n"
+ " - XjcRdePolicy: 1 entry\n"
+ " - XjcRdeRegistrar: 1 entry\n"
+ "\n"
+ "Bad host refs: ns1.LAFFO.com\n"
+ "RDE deposit is XML schema valid but has bad references\n");
}
@Test
public void testRun_badXml() throws Exception {
String file = writeToTmpFile(RdeTestData.loadUtf8("deposit_full.xml").substring(0, 2000));
thrown.expect(XmlException.class, "Syntax error at line 46, column 38: "
+ "XML document structures must start and end within the same entity.");
runCommand("--input=" + file);
}
}

View file

@ -0,0 +1,131 @@
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.domain.registry.tools;
import static com.google.domain.registry.model.registrar.Registrar.State.ACTIVE;
import static com.google.domain.registry.testing.DatastoreHelper.createTld;
import static com.google.domain.registry.testing.DatastoreHelper.persistResource;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.domain.registry.flows.EppException;
import com.google.domain.registry.model.registrar.Registrar;
import com.google.domain.registry.testing.CertificateSamples;
import com.google.domain.registry.util.CidrAddressBlock;
import com.beust.jcommander.ParameterException;
import org.junit.Before;
import org.junit.Test;
/** Unit tests for {@link ValidateLoginCredentialsCommand}. */
public class ValidateLoginCredentialsCommandTest
extends CommandTestCase<ValidateLoginCredentialsCommand> {
private static final String PASSWORD = "foo-BAR2";
private static final String CERT_HASH = CertificateSamples.SAMPLE_CERT_HASH;
private static final String CLIENT_IP = "1.2.3.4";
@Before
public void init() {
createTld("tld");
persistResource(Registrar.loadByClientId("NewRegistrar").asBuilder()
.setPassword(PASSWORD)
.setClientCertificateHash(CERT_HASH)
.setIpAddressWhitelist(ImmutableList.of(new CidrAddressBlock(CLIENT_IP)))
.setState(ACTIVE)
.setAllowedTlds(ImmutableSet.of("tld"))
.build());
}
@Test
public void testSuccess() throws Exception {
runCommand(
"--client=NewRegistrar",
"--password=" + PASSWORD,
"--cert_hash=" + CERT_HASH,
"--ip_address=" + CLIENT_IP);
}
@Test
public void testFailure_loginWithBadPassword() throws Exception {
thrown.expect(EppException.class);
runCommand(
"--client=NewRegistrar",
"--password=" + new StringBuffer(PASSWORD).reverse(),
"--cert_hash=" + CERT_HASH,
"--ip_address=" + CLIENT_IP);
}
@Test
public void testFailure_loginWithBadCertificateHash() throws Exception {
thrown.expect(EppException.class);
runCommand(
"--client=NewRegistrar",
"--password=" + PASSWORD,
"--cert_hash=" + new StringBuffer(CERT_HASH).reverse(),
"--ip_address=" + CLIENT_IP);
}
@Test
public void testFailure_loginWithBadIp() throws Exception {
thrown.expect(EppException.class);
runCommand(
"--client=NewRegistrar",
"--password=" + PASSWORD,
"--cert_hash=" + CERT_HASH,
"--ip_address=" + new StringBuffer(CLIENT_IP).reverse());
}
@Test
public void testFailure_missingClientId() throws Exception {
thrown.expect(ParameterException.class);
runCommand(
"--password=" + PASSWORD,
"--cert_hash=" + CERT_HASH,
"--ip_address=" + CLIENT_IP);
}
@Test
public void testFailure_missingPassword() throws Exception {
thrown.expect(ParameterException.class);
runCommand(
"--client=NewRegistrar",
"--cert_hash=" + CERT_HASH,
"--ip_address=" + CLIENT_IP);
}
@Test
public void testFailure_unknownFlag() throws Exception {
thrown.expect(ParameterException.class);
runCommand(
"--client=NewRegistrar",
"--password=" + PASSWORD,
"--cert_hash=" + CERT_HASH,
"--ip_address=" + CLIENT_IP,
"--unrecognized_flag=foo");
}
@Test
public void testFailure_certHashAndCertFile() throws Exception {
thrown.expect(IllegalArgumentException.class);
runCommand(
"--client=NewRegistrar",
"--password=" + PASSWORD,
"--cert_hash=" + CERT_HASH,
"--cert_file=" + tmpDir.newFile(),
"--ip_address=" + CLIENT_IP);
}
}

View file

@ -0,0 +1,28 @@
package(
default_visibility = ["//java/com/google/domain/registry:registry_project"],
)
java_library(
name = "params",
srcs = glob(["*.java"]),
deps = [
"//java/com/google/common/base",
"//java/com/google/domain/registry/tools/params",
"//javatests/com/google/domain/registry/testing",
"//third_party/java/hamcrest",
"//third_party/java/jcommander",
"//third_party/java/joda_money",
"//third_party/java/joda_time",
"//third_party/java/junit",
"//third_party/java/truth",
],
)
load("//java/com/google/testing/builddefs:GenTestRules.bzl", "GenTestRules")
GenTestRules(
name = "GeneratedTestRules",
test_files = glob(["*Test.java"]),
deps = [":params"],
)

View file

@ -0,0 +1,133 @@
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.domain.registry.tools.params;
import static com.google.common.truth.Truth.assertThat;
import static org.joda.time.DateTimeZone.UTC;
import com.google.domain.registry.testing.ExceptionRule;
import com.beust.jcommander.ParameterException;
import org.joda.time.DateTime;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
/** Unit tests for {@link DateTimeParameter}. */
@RunWith(JUnit4.class)
public class DateTimeParameterTest {
@Rule
public final ExceptionRule thrown = new ExceptionRule();
private final DateTimeParameter instance = new DateTimeParameter();
@Test
public void testConvert_numeric_returnsMillisFromEpochUtc() throws Exception {
assertThat(instance.convert("1234")).isEqualTo(new DateTime(1234L, UTC));
}
@Test
public void testConvert_iso8601_returnsSameAsDateTimeParse() throws Exception {
String exampleDate = "2014-01-01T01:02:03.004Z";
assertThat(instance.convert(exampleDate))
.isEqualTo(DateTime.parse(exampleDate));
}
@Test
public void testConvert_isoDateTimeWithMillis_returnsSameAsDateTimeParse() throws Exception {
String exampleDate = "2014-01-01T01:02:03.004Z";
assertThat(instance.convert(exampleDate)).isEqualTo(DateTime.parse(exampleDate));
}
@Test
public void testConvert_weirdTimezone_convertsToUtc() throws Exception {
assertThat(instance.convert("1984-12-18T00:00:00-0520"))
.isEqualTo(DateTime.parse("1984-12-18T05:20:00Z"));
}
@Test
public void testConvert_null_throwsException() throws Exception {
thrown.expect(NullPointerException.class);
instance.convert(null);
}
@Test
public void testConvert_empty_throwsException() throws Exception {
thrown.expect(IllegalArgumentException.class);
instance.convert("");
}
@Test
public void testConvert_sillyString_throwsException() throws Exception {
thrown.expect(IllegalArgumentException.class);
instance.convert("foo");
}
@Test
public void testConvert_partialDate_throwsException() throws Exception {
thrown.expect(IllegalArgumentException.class);
instance.convert("2014-01");
}
@Test
public void testConvert_onlyDate_throwsException() throws Exception {
thrown.expect(IllegalArgumentException.class);
instance.convert("2014-01-01");
}
@Test
public void testConvert_partialTime_throwsException() throws Exception {
thrown.expect(IllegalArgumentException.class);
instance.convert("T01:02");
}
@Test
public void testConvert_onlyTime_throwsException() throws Exception {
thrown.expect(IllegalArgumentException.class);
instance.convert("T01:02:03");
}
@Test
public void testConvert_partialDateAndPartialTime_throwsException() throws Exception {
thrown.expect(IllegalArgumentException.class);
instance.convert("9T9");
}
@Test
public void testConvert_dateAndPartialTime_throwsException() throws Exception {
thrown.expect(IllegalArgumentException.class);
instance.convert("2014-01-01T01:02");
}
@Test
public void testConvert_noTimeZone_throwsException() throws Exception {
thrown.expect(IllegalArgumentException.class);
instance.convert("2014-01-01T01:02:03");
}
@Test
public void testValidate_sillyString_throwsParameterException() throws Exception {
thrown.expect(ParameterException.class, "--time=foo not an ISO");
instance.validate("--time", "foo");
}
@Test
public void testValidate_correctInput_doesntThrow() throws Exception {
instance.validate("--time", "123");
}
}

View file

@ -0,0 +1,101 @@
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.domain.registry.tools.params;
import static com.google.common.truth.Truth.assertThat;
import com.google.domain.registry.testing.ExceptionRule;
import com.beust.jcommander.ParameterException;
import org.joda.time.Duration;
import org.joda.time.Period;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
/** Unit tests for {@link DurationParameter}. */
@RunWith(JUnit4.class)
public class DurationParameterTest {
@Rule
public final ExceptionRule thrown = new ExceptionRule();
private final DurationParameter instance = new DurationParameter();
@Test
public void testConvert_isoHours() throws Exception {
assertThat(instance.convert("PT36H")).isEqualTo(Duration.standardHours(36));
}
@Test
public void testConvert_isoDaysAndHours() throws Exception {
assertThat(instance.convert("P1DT12H")).isEqualTo(Duration.standardHours(36));
}
@Test
public void testConvert_isoLowercase_isAllowed() throws Exception {
assertThat(instance.convert("pt36h")).isEqualTo(Duration.standardHours(36));
}
@Test
public void demonstrateThat_isoMissingP_notAllowed() throws Exception {
thrown.expect(IllegalArgumentException.class);
Period.parse("T36H");
}
@Test
public void demonstrateThat_isoMissingPT_notAllowed() throws Exception {
thrown.expect(IllegalArgumentException.class);
Period.parse("36H");
}
@Test
public void testConvert_isoMissingP_notAllowed() throws Exception {
thrown.expect(IllegalArgumentException.class);
instance.convert("T36H");
}
@Test
public void testConvert_null_throws() throws Exception {
thrown.expect(NullPointerException.class);
instance.convert(null);
}
@Test
public void testConvert_empty_throws() throws Exception {
thrown.expect(IllegalArgumentException.class);
instance.convert("");
}
@Test
public void testConvert_numeric_throws() throws Exception {
thrown.expect(IllegalArgumentException.class);
instance.convert("1234");
}
@Test
public void testConvert_sillyString_throws() throws Exception {
thrown.expect(IllegalArgumentException.class);
instance.convert("foo");
}
@Test
public void testValidate_sillyString_throws() throws Exception {
thrown.expect(ParameterException.class, "--time=foo not an");
instance.validate("--time", "foo");
}
}

View file

@ -0,0 +1,52 @@
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.domain.registry.tools.params;
import static com.google.common.truth.Truth.assertThat;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
/** Unit tests for {@link HostAndPortParameter}. */
@RunWith(JUnit4.class)
public class HostAndPortParameterTest {
private final HostAndPortParameter instance = new HostAndPortParameter();
@Test
public void testConvert_hostOnly() throws Exception {
assertThat(instance.convert("foo.bar").getHostText()).isEqualTo("foo.bar");
assertThat(instance.convert("foo.bar").getPortOrDefault(31337)).isEqualTo(31337);
}
@Test
public void testConvert_hostAndPort() throws Exception {
assertThat(instance.convert("foo.bar:1234").getHostText()).isEqualTo("foo.bar");
assertThat(instance.convert("foo.bar:1234").getPortOrDefault(31337)).isEqualTo(1234);
}
@Test
public void testConvert_ipv6_hostOnly() throws Exception {
assertThat(instance.convert("[feed:a:bee]").getHostText()).isEqualTo("feed:a:bee");
assertThat(instance.convert("[feed:a:bee]").getPortOrDefault(31337)).isEqualTo(31337);
}
@Test
public void testConvert_ipv6_hostAndPort() throws Exception {
assertThat(instance.convert("[feed:a:bee]:1234").getHostText()).isEqualTo("feed:a:bee");
assertThat(instance.convert("[feed:a:bee]:1234").getPortOrDefault(31337)).isEqualTo(1234);
}
}

View file

@ -0,0 +1,92 @@
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.domain.registry.tools.params;
import static com.google.common.truth.Truth.assertThat;
import com.google.domain.registry.testing.ExceptionRule;
import com.beust.jcommander.ParameterException;
import org.joda.money.Money;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
/** Unit tests for {@link MoneyParameter}. */
@RunWith(JUnit4.class)
public class MoneyParameterTest {
@Rule
public final ExceptionRule thrown = new ExceptionRule();
private final MoneyParameter instance = new MoneyParameter();
@Test
public void testConvert_withCurrency() throws Exception {
assertThat(instance.convert("USD 777.99")).isEqualTo(Money.parse("USD 777.99"));
}
@Test
public void testConvert_negative() throws Exception {
assertThat(instance.convert("USD -777.99")).isEqualTo(Money.parse("USD -777.99"));
}
@Test
public void testConvert_missingSpace_isForgiving() throws Exception {
assertThat(instance.convert("USD777.99")).isEqualTo(Money.parse("USD 777.99"));
}
@Test
public void testConvert_lowercase_isForgiving() throws Exception {
assertThat(instance.convert("usd777.99")).isEqualTo(Money.parse("USD 777.99"));
}
@Test
public void testConvert_badCurrency_throws() throws Exception {
thrown.expect(IllegalArgumentException.class);
instance.convert("FOO 1337");
}
@Test
public void testConvert_null_throws() throws Exception {
thrown.expect(NullPointerException.class);
instance.convert(null);
}
@Test
public void testConvert_empty_throws() throws Exception {
thrown.expect(IllegalArgumentException.class);
instance.convert("");
}
@Test
public void testConvert_sillyString_throws() throws Exception {
thrown.expect(IllegalArgumentException.class);
instance.convert("foo");
}
@Test
public void testValidate_sillyString_throws() throws Exception {
thrown.expect(ParameterException.class, "--money=foo not valid");
instance.validate("--money", "foo");
}
@Test
public void testValidate_correctInput() throws Exception {
instance.validate("--money", "USD 777");
}
}

View file

@ -0,0 +1,172 @@
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.domain.registry.tools.params;
import static com.google.common.truth.Truth.assertThat;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.not;
import static org.hamcrest.Matchers.startsWith;
import static org.junit.Assume.assumeThat;
import static org.junit.Assume.assumeTrue;
import com.google.domain.registry.testing.ExceptionRule;
import com.beust.jcommander.ParameterException;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import java.io.File;
import java.nio.file.FileSystemNotFoundException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.attribute.PosixFilePermissions;
/** Unit tests for {@link PathParameter}. */
@RunWith(JUnit4.class)
public class PathParameterTest {
@Rule
public final ExceptionRule thrown = new ExceptionRule();
@Rule
public final TemporaryFolder folder = new TemporaryFolder();
// ================================ Test Convert ==============================================
private final PathParameter vanilla = new PathParameter();
@Test
public void testConvert_etcPasswd_returnsPath() throws Exception {
assertThat((Object) vanilla.convert("/etc/passwd")).isEqualTo(Paths.get("/etc/passwd"));
}
@Test
public void testConvert_null_throws() throws Exception {
thrown.expect(NullPointerException.class);
vanilla.convert(null);
}
@Test
public void testConvert_empty_throws() throws Exception {
thrown.expect(IllegalArgumentException.class);
vanilla.convert("");
}
@Test
public void testConvert_relativePath_returnsOriginalFile() throws Exception {
Path currentDirectory = Paths.get("").toAbsolutePath();
Path file = Paths.get(folder.newFile().toString());
Path relative = file.relativize(currentDirectory);
assumeThat(relative, is(not(equalTo(file))));
assumeThat(relative.toString(), startsWith("../"));
Path converted = vanilla.convert(file.toString());
assertThat((Object) converted).isEqualTo(file);
}
@Test
public void testConvert_extraSlash_returnsWithoutSlash() throws Exception {
Path file = Paths.get(folder.newFile().toString());
assertThat((Object) vanilla.convert(file + "/")).isEqualTo(file);
}
@Test
public void testConvert_uriNotProvided() throws Exception {
thrown.expect(FileSystemNotFoundException.class);
vanilla.convert("bog://bucket/lolcat");
}
// =========================== Test InputFile Validate ========================================
private final PathParameter inputFile = new PathParameter.InputFile();
@Test
public void testInputFileValidate_normalFile_works() throws Exception {
inputFile.validate("input", folder.newFile().toString());
}
@Test
public void testInputFileValidate_missingFile_throws() throws Exception {
thrown.expect(ParameterException.class, "not found");
inputFile.validate("input", new File(folder.getRoot(), "foo").toString());
}
@Test
public void testInputFileValidate_directory_throws() throws Exception {
thrown.expect(ParameterException.class, "is a directory");
inputFile.validate("input", folder.getRoot().toString());
}
@Test
public void testInputFileValidate_unreadableFile_throws() throws Exception {
Path file = Paths.get(folder.newFile().toString());
Files.setPosixFilePermissions(file, PosixFilePermissions.fromString("-w-------"));
thrown.expect(ParameterException.class, "not readable");
inputFile.validate("input", file.toString());
}
// =========================== Test OutputFile Validate ========================================
private final PathParameter outputFile = new PathParameter.OutputFile();
@Test
public void testOutputFileValidate_normalFile_works() throws Exception {
outputFile.validate("input", folder.newFile().toString());
}
@Test
public void testInputFileValidate_characterDeviceBehindSymbolicLinks_works() throws Exception {
assumeTrue(Files.exists(Paths.get("/dev/stdin")));
outputFile.validate("input", "/dev/stdin");
}
@Test
public void testOutputFileValidate_missingFile_works() throws Exception {
outputFile.validate("input", new File(folder.getRoot(), "foo").toString());
}
@Test
public void testOutputFileValidate_directory_throws() throws Exception {
thrown.expect(ParameterException.class, "is a directory");
outputFile.validate("input", folder.getRoot().toString());
}
@Test
public void testOutputFileValidate_notWritable_throws() throws Exception {
Path file = Paths.get(folder.newFile().toString());
Files.setPosixFilePermissions(file, PosixFilePermissions.fromString("r--------"));
thrown.expect(ParameterException.class, "not writable");
outputFile.validate("input", file.toString());
}
@Test
public void testOutputFileValidate_parentDirMissing_throws() throws Exception {
Path file = Paths.get(folder.getRoot().toString(), "MISSINGNO", "foo.txt");
thrown.expect(ParameterException.class, "parent dir doesn't exist");
outputFile.validate("input", file.toString());
}
@Test
public void testOutputFileValidate_parentDirIsFile_throws() throws Exception {
Path file = Paths.get(folder.newFile().toString(), "foo.txt");
thrown.expect(ParameterException.class, "parent is non-directory");
outputFile.validate("input", file.toString());
}
}

View file

@ -0,0 +1,55 @@
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.domain.registry.tools.params;
import static com.google.common.truth.Truth.assertThat;
import com.google.domain.registry.testing.ExceptionRule;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
/** Unit tests for {@link PhoneNumberParameter}. */
@RunWith(JUnit4.class)
public class PhoneNumberParameterTest {
@Rule
public final ExceptionRule thrown = new ExceptionRule();
private final OptionalPhoneNumberParameter instance = new OptionalPhoneNumberParameter();
@Test
public void testConvert_e164() throws Exception {
assertThat(instance.convert("+1.2125550777")).hasValue("+1.2125550777");
}
@Test
public void testConvert_sillyString_throws() throws Exception {
thrown.expect(IllegalArgumentException.class);
instance.convert("foo");
}
@Test
public void testConvert_empty_returnsAbsent() throws Exception {
assertThat(instance.convert("")).isAbsent();
}
@Test
public void testConvert_nullString_returnsAbsent() throws Exception {
assertThat(instance.convert("null")).isAbsent();
}
}

View file

@ -0,0 +1,83 @@
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.domain.registry.tools.params;
import static com.google.common.truth.Truth.assertThat;
import com.google.domain.registry.testing.ExceptionRule;
import com.beust.jcommander.ParameterException;
import org.joda.time.YearMonth;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
/** Unit tests for {@link YearMonthParameter}. */
@RunWith(JUnit4.class)
public class YearMonthParameterTest {
@Rule
public final ExceptionRule thrown = new ExceptionRule();
private final YearMonthParameter instance = new YearMonthParameter();
@Test
public void testConvert_awfulMonth() throws Exception {
assertThat(instance.convert("1984-12")).isEqualTo(new YearMonth(1984, 12));
}
@Test
public void testConvert_null_throwsException() throws Exception {
thrown.expect(NullPointerException.class);
instance.convert(null);
}
@Test
public void testConvert_empty_throwsException() throws Exception {
thrown.expect(IllegalArgumentException.class);
instance.convert("");
}
@Test
public void testConvert_sillyString_throwsException() throws Exception {
thrown.expect(IllegalArgumentException.class);
instance.convert("foo");
}
@Test
public void testConvert_wrongOrder() throws Exception {
thrown.expect(IllegalArgumentException.class);
instance.convert("12-1984");
}
@Test
public void testConvert_noHyphen() throws Exception {
thrown.expect(IllegalArgumentException.class);
instance.convert("198412");
}
@Test
public void testValidate_sillyString_throwsParameterException() throws Exception {
thrown.expect(ParameterException.class, "--time=foo not a valid");
instance.validate("--time", "foo");
}
@Test
public void testValidate_correctInput_doesntThrow() throws Exception {
instance.validate("--time", "1984-12");
}
}

View file

@ -0,0 +1,41 @@
package(
default_visibility = ["//java/com/google/domain/registry:registry_project"],
)
load("//java/com/google/testing/builddefs:GenTestRules.bzl", "GenTestRules")
java_library(
name = "server",
srcs = glob(["*.java"]),
resources = glob(["testdata/*"]),
deps = [
"//java/com/google/common/base",
"//java/com/google/common/collect",
"//java/com/google/domain/registry/groups",
"//java/com/google/domain/registry/mapreduce",
"//java/com/google/domain/registry/model",
"//java/com/google/domain/registry/request",
"//java/com/google/domain/registry/tools/server",
"//java/com/google/domain/registry/util",
"//javatests/com/google/domain/registry/model",
"//javatests/com/google/domain/registry/testing",
"//javatests/com/google/domain/registry/testing/mapreduce",
"//third_party/java/appengine:appengine-api-testonly",
"//third_party/java/appengine_gcs_client",
"//third_party/java/appengine_mapreduce2:appengine_mapreduce",
"//third_party/java/joda_money",
"//third_party/java/joda_time",
"//third_party/java/junit",
"//third_party/java/mockito",
"//third_party/java/objectify:objectify-v4_1",
"//third_party/java/servlet/servlet_api",
"//third_party/java/truth",
],
)
GenTestRules(
name = "GeneratedTestRules",
test_files = glob(["*Test.java"]),
deps = [":server"],
)

View file

@ -0,0 +1,155 @@
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.domain.registry.tools.server;
import static com.google.common.truth.Truth.assertThat;
import static javax.servlet.http.HttpServletResponse.SC_OK;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import com.google.common.base.Optional;
import com.google.domain.registry.groups.DirectoryGroupsConnection;
import com.google.domain.registry.groups.GroupsConnection.Role;
import com.google.domain.registry.request.HttpException.BadRequestException;
import com.google.domain.registry.request.HttpException.InternalServerErrorException;
import com.google.domain.registry.request.Response;
import com.google.domain.registry.testing.AppEngineRule;
import com.google.domain.registry.testing.ExceptionRule;
import com.google.domain.registry.testing.InjectRule;
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
/**
* Unit tests for {@link CreateGroupsAction}.
*/
@RunWith(MockitoJUnitRunner.class)
public class CreateGroupsActionTest {
@Rule
public final AppEngineRule appEngine = AppEngineRule.builder()
.withDatastore()
.build();
@Rule
public final ExceptionRule thrown = new ExceptionRule();
@Rule
public final InjectRule inject = new InjectRule();
@Mock
private DirectoryGroupsConnection connection;
@Mock
private Response response;
private void runAction(String clientId) {
CreateGroupsAction action = new CreateGroupsAction();
action.response = response;
action.groupsConnection = connection;
action.publicDomainName = "domain-registry.example";
action.clientId = Optional.fromNullable(clientId);
action.run();
}
@Test
public void test_invalidRequest_missingClientId() throws Exception {
thrown.expect(BadRequestException.class,
"Error creating Google Groups, missing parameter: clientId");
runAction(null);
}
@Test
public void test_invalidRequest_invalidClientId() throws Exception {
thrown.expect(BadRequestException.class,
"Error creating Google Groups; could not find registrar with id completelyMadeUpClientId");
runAction("completelyMadeUpClientId");
}
@Test
public void test_createsAllGroupsSuccessfully() throws Exception {
runAction("NewRegistrar");
verify(response).setStatus(SC_OK);
verify(response).setPayload("Success!");
verifyGroupCreationCallsForNewRegistrar();
verify(connection).addMemberToGroup("registrar-primary-contacts@domain-registry.example",
"newregistrar-primary-contacts@domain-registry.example",
Role.MEMBER);
}
@Test
public void test_createsSomeGroupsSuccessfully_whenOthersFail() throws Exception {
when(connection.createGroup("newregistrar-primary-contacts@domain-registry.example"))
.thenThrow(new RuntimeException("Could not contact server."));
doThrow(new RuntimeException("Invalid access.")).when(connection).addMemberToGroup(
"registrar-technical-contacts@domain-registry.example",
"newregistrar-technical-contacts@domain-registry.example",
Role.MEMBER);
try {
runAction("NewRegistrar");
} catch (InternalServerErrorException e) {
String responseString = e.toString();
assertThat(responseString).contains("abuse => Success");
assertThat(responseString).contains("billing => Success");
assertThat(responseString).contains("legal => Success");
assertThat(responseString).contains("marketing => Success");
assertThat(responseString).contains("whois-inquiry => Success");
assertThat(responseString).contains(
"primary => java.lang.RuntimeException: Could not contact server.");
assertThat(responseString).contains(
"technical => java.lang.RuntimeException: Invalid access.");
verifyGroupCreationCallsForNewRegistrar();
return;
}
Assert.fail("Should have thrown InternalServerErrorException.");
}
private void verifyGroupCreationCallsForNewRegistrar() throws Exception {
verify(connection).createGroup("newregistrar-abuse-contacts@domain-registry.example");
verify(connection).createGroup("newregistrar-primary-contacts@domain-registry.example");
verify(connection).createGroup("newregistrar-billing-contacts@domain-registry.example");
verify(connection).createGroup("newregistrar-legal-contacts@domain-registry.example");
verify(connection).createGroup("newregistrar-marketing-contacts@domain-registry.example");
verify(connection).createGroup("newregistrar-technical-contacts@domain-registry.example");
verify(connection).createGroup("newregistrar-whois-inquiry-contacts@domain-registry.example");
verify(connection).addMemberToGroup("registrar-abuse-contacts@domain-registry.example",
"newregistrar-abuse-contacts@domain-registry.example",
Role.MEMBER);
// Note that addMemberToGroup for primary is verified separately for the success test because
// the exception thrown on group creation in the failure test causes the servlet not to get to
// this line.
verify(connection).addMemberToGroup("registrar-billing-contacts@domain-registry.example",
"newregistrar-billing-contacts@domain-registry.example",
Role.MEMBER);
verify(connection).addMemberToGroup("registrar-legal-contacts@domain-registry.example",
"newregistrar-legal-contacts@domain-registry.example",
Role.MEMBER);
verify(connection).addMemberToGroup("registrar-marketing-contacts@domain-registry.example",
"newregistrar-marketing-contacts@domain-registry.example",
Role.MEMBER);
verify(connection).addMemberToGroup("registrar-technical-contacts@domain-registry.example",
"newregistrar-technical-contacts@domain-registry.example",
Role.MEMBER);
verify(connection).addMemberToGroup(
"registrar-whois-inquiry-contacts@domain-registry.example",
"newregistrar-whois-inquiry-contacts@domain-registry.example",
Role.MEMBER);
}
}

View file

@ -0,0 +1,102 @@
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.domain.registry.tools.server;
import static com.google.common.truth.Truth.assertThat;
import static com.google.domain.registry.testing.DatastoreHelper.createTlds;
import static javax.servlet.http.HttpServletResponse.SC_OK;
import com.google.domain.registry.model.registry.label.PremiumList;
import com.google.domain.registry.testing.AppEngineRule;
import com.google.domain.registry.testing.ExceptionRule;
import com.google.domain.registry.testing.FakeJsonResponse;
import org.joda.money.Money;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
/**
* Unit tests for {@link CreatePremiumListAction}.
*/
@RunWith(JUnit4.class)
public class CreatePremiumListActionTest {
@Rule
public final AppEngineRule appEngine = AppEngineRule.builder()
.withDatastore()
.build();
@Rule
public final ExceptionRule thrown = new ExceptionRule();
CreatePremiumListAction action;
FakeJsonResponse response;
@Before
public void init() throws Exception {
createTlds("foo", "xn--q9jyb4c", "how");
PremiumList.get("foo").get().delete();
action = new CreatePremiumListAction();
response = new FakeJsonResponse();
action.response = response;
}
@Test
public void test_invalidRequest_missingInput_returnsErrorStatus() throws Exception {
action.name = "foo";
action.run();
assertThat(response.getResponseMap().get("status")).isEqualTo("error");
}
@Test
public void test_invalidRequest_listAlreadyExists_returnsErrorStatus() throws Exception {
action.name = "how";
action.inputData = "richer,JPY 5000";
action.run();
assertThat(response.getResponseMap().get("status")).isEqualTo("error");
Object obj = response.getResponseMap().get("error");
assertThat(obj).isInstanceOf(String.class);
String error = obj.toString();
assertThat(error).contains("A premium list of this name already exists");
}
@Test
public void test_nonExistentTld_successWithOverride() throws Exception {
action.name = "zanzibar";
action.inputData = "zanzibar,USD 100";
action.override = true;
action.run();
assertThat(response.getStatus()).isEqualTo(SC_OK);
PremiumList premiumList = PremiumList.get("zanzibar").get();
assertThat(premiumList.getPremiumListEntries()).hasSize(1);
assertThat(premiumList.getPremiumPrice("zanzibar")).hasValue(Money.parse("USD 100"));
assertThat(premiumList.getPremiumPrice("diamond")).isAbsent();
}
@Test
public void test_success() throws Exception {
action.name = "foo";
action.inputData = "rich,USD 25\nricher,USD 1000\n";
action.run();
assertThat(response.getStatus()).isEqualTo(SC_OK);
PremiumList premiumList = PremiumList.get("foo").get();
assertThat(premiumList.getPremiumListEntries()).hasSize(2);
assertThat(premiumList.getPremiumPrice("rich")).hasValue(Money.parse("USD 25"));
assertThat(premiumList.getPremiumPrice("diamond")).isAbsent();
}
}

View file

@ -0,0 +1,108 @@
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.domain.registry.tools.server;
import static com.google.appengine.api.datastore.DatastoreServiceFactory.getDatastoreService;
import static com.google.common.truth.Truth.assertThat;
import static com.google.domain.registry.model.ofy.ObjectifyService.ofy;
import static com.googlecode.objectify.Key.create;
import com.google.appengine.api.datastore.Entity;
import com.google.appengine.api.datastore.KeyFactory;
import com.google.domain.registry.model.registry.label.ReservedList;
import com.google.domain.registry.request.HttpException.BadRequestException;
import com.google.domain.registry.testing.AppEngineRule;
import com.google.domain.registry.testing.ExceptionRule;
import com.google.domain.registry.testing.FakeResponse;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.runners.MockitoJUnitRunner;
/** Unit tests for {@link DeleteEntityAction}. */
@RunWith(MockitoJUnitRunner.class)
public class DeleteEntityActionTest {
@Rule
public final AppEngineRule appEngine = AppEngineRule.builder().withDatastore().build();
@Rule
public final ExceptionRule thrown = new ExceptionRule();
FakeResponse response = new FakeResponse();
DeleteEntityAction action = new DeleteEntityAction();
@Before
public void init() throws Exception {
action.response = response;
}
@Test
public void test_deleteSingleRawEntitySuccessfully() throws Exception {
Entity entity = new Entity("single", "raw");
getDatastoreService().put(entity);
action.rawKeys = KeyFactory.keyToString(entity.getKey());
action.run();
assertThat(response.getPayload())
.isEqualTo("Deleted 1 raw entities and 0 registered entities");
}
@Test
public void test_deleteSingleRegisteredEntitySuccessfully() throws Exception {
ReservedList ofyEntity = new ReservedList.Builder().setName("foo").build();
ofy().saveWithoutBackup().entity(ofyEntity).now();
action.rawKeys = KeyFactory.keyToString(create(ofyEntity).getRaw());
action.run();
assertThat(response.getPayload())
.isEqualTo("Deleted 0 raw entities and 1 registered entities");
}
@Test
public void test_deleteOneRawEntityAndOneRegisteredEntitySuccessfully() throws Exception {
Entity entity = new Entity("first", "raw");
getDatastoreService().put(entity);
String rawKey = KeyFactory.keyToString(entity.getKey());
ReservedList ofyEntity = new ReservedList.Builder().setName("registered").build();
ofy().saveWithoutBackup().entity(ofyEntity).now();
String ofyKey = KeyFactory.keyToString(create(ofyEntity).getRaw());
action.rawKeys = String.format("%s,%s", rawKey, ofyKey);
action.run();
assertThat(response.getPayload())
.isEqualTo("Deleted 1 raw entities and 1 registered entities");
}
@Test
public void test_deleteNonExistentEntityRepliesWithError() throws Exception {
Entity entity = new Entity("not", "here");
String rawKey = KeyFactory.keyToString(entity.getKey());
action.rawKeys = rawKey;
thrown.expect(BadRequestException.class, "Could not find entity with key " + rawKey);
action.run();
}
@Test
public void test_deleteOneEntityAndNonExistentEntityRepliesWithError() throws Exception {
ReservedList ofyEntity = new ReservedList.Builder().setName("first_registered").build();
ofy().saveWithoutBackup().entity(ofyEntity).now();
String ofyKey = KeyFactory.keyToString(create(ofyEntity).getRaw());
Entity entity = new Entity("non", "existent");
String rawKey = KeyFactory.keyToString(entity.getKey());
action.rawKeys = String.format("%s,%s", ofyKey, rawKey);
thrown.expect(BadRequestException.class, "Could not find entity with key " + rawKey);
action.run();
}
}

View file

@ -0,0 +1,179 @@
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.domain.registry.tools.server;
import static com.google.common.truth.Truth.assertThat;
import static com.google.domain.registry.model.ofy.ObjectifyService.ofy;
import static com.google.domain.registry.testing.DatastoreHelper.createTld;
import static com.google.domain.registry.testing.DatastoreHelper.persistActiveDomain;
import static com.google.domain.registry.testing.DatastoreHelper.persistDeletedDomain;
import static com.google.domain.registry.testing.DatastoreHelper.persistResource;
import static com.google.domain.registry.testing.DatastoreHelper.persistSimpleResource;
import static com.google.domain.registry.util.DateTimeUtils.START_OF_TIME;
import com.google.common.base.Optional;
import com.google.common.collect.ImmutableSet;
import com.google.domain.registry.mapreduce.MapreduceRunner;
import com.google.domain.registry.model.ImmutableObject;
import com.google.domain.registry.model.billing.BillingEvent;
import com.google.domain.registry.model.billing.BillingEvent.Reason;
import com.google.domain.registry.model.domain.DomainResource;
import com.google.domain.registry.model.index.EppResourceIndex;
import com.google.domain.registry.model.index.ForeignKeyIndex;
import com.google.domain.registry.model.poll.PollMessage;
import com.google.domain.registry.model.registry.Registry;
import com.google.domain.registry.model.registry.Registry.TldType;
import com.google.domain.registry.model.reporting.HistoryEntry;
import com.google.domain.registry.testing.ExceptionRule;
import com.google.domain.registry.testing.FakeResponse;
import com.google.domain.registry.testing.mapreduce.MapreduceTestCase;
import com.googlecode.objectify.Key;
import org.joda.money.Money;
import org.joda.time.DateTime;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import java.util.Set;
/** Unit tests for {@link DeleteProberDataAction}. */
@RunWith(JUnit4.class)
public class DeleteProberDataActionTest extends MapreduceTestCase<DeleteProberDataAction> {
private static final DateTime DELETION_TIME = DateTime.parse("2010-01-01T00:00:00.000Z");
@Rule
public final ExceptionRule thrown = new ExceptionRule();
@Before
public void init() {
// Entities in these two should not be touched.
createTld("tld", "TLD");
// Since "example" doesn't end with .test, its entities won't be deleted even though it is of
// TEST type.
createTld("example", "EXAMPLE");
persistResource(Registry.get("example").asBuilder().setTldType(TldType.TEST).build());
// Entities in these two should be deleted.
createTld("ib-any.test", "IBANYT");
persistResource(Registry.get("ib-any.test").asBuilder().setTldType(TldType.TEST).build());
createTld("oa-canary.test", "OACANT");
persistResource(Registry.get("oa-canary.test").asBuilder().setTldType(TldType.TEST).build());
action = new DeleteProberDataAction();
action.mrRunner = new MapreduceRunner(Optional.<Integer>absent(), Optional.<Integer>absent());
action.response = new FakeResponse();
action.isDryRun = false;
}
private void runMapreduce() throws Exception {
action.run();
executeTasksUntilEmpty("mapreduce");
}
@Test
public void test_deletesAllAndOnlyProberData() throws Exception {
Set<ImmutableObject> tldEntities = persistLotsOfDomains("tld");
Set<ImmutableObject> exampleEntities = persistLotsOfDomains("example");
Set<ImmutableObject> ibEntities = persistLotsOfDomains("ib-any.test");
Set<ImmutableObject> oaEntities = persistLotsOfDomains("oa-canary.test");
runMapreduce();
assertNotDeleted(tldEntities);
assertNotDeleted(exampleEntities);
assertDeleted(ibEntities);
assertDeleted(oaEntities);
}
@Test
public void testSuccess_doesntDeleteNicDomainForProbers() throws Exception {
DomainResource nic = persistActiveDomain("nic.ib-any.test");
ForeignKeyIndex<DomainResource> fkiNic =
ForeignKeyIndex.load(DomainResource.class, "nic.ib-any.test", START_OF_TIME);
Set<ImmutableObject> ibEntities = persistLotsOfDomains("ib-any.test");
runMapreduce();
assertDeleted(ibEntities);
assertNotDeleted(ImmutableSet.<ImmutableObject>of(nic, fkiNic));
}
@Test
public void testSuccess_dryRunDoesntDeleteData() throws Exception {
Set<ImmutableObject> tldEntities = persistLotsOfDomains("tld");
Set<ImmutableObject> oaEntities = persistLotsOfDomains("oa-canary.test");
action.isDryRun = true;
assertNotDeleted(tldEntities);
assertNotDeleted(oaEntities);
}
/**
* Persists and returns a domain and a descendant history entry, billing event, and poll message,
* along with the ForeignKeyIndex and EppResourceIndex.
*/
private static Set<ImmutableObject> persistDomainAndDescendants(String fqdn) {
DomainResource domain = persistDeletedDomain(fqdn, DELETION_TIME);
HistoryEntry historyEntry = persistSimpleResource(
new HistoryEntry.Builder()
.setParent(domain)
.setType(HistoryEntry.Type.DOMAIN_CREATE)
.build());
BillingEvent.OneTime billingEvent = persistSimpleResource(
new BillingEvent.OneTime.Builder()
.setParent(historyEntry)
.setBillingTime(DELETION_TIME.plusYears(1))
.setCost(Money.parse("USD 10"))
.setPeriodYears(1)
.setReason(Reason.CREATE)
.setClientId("TheRegistrar")
.setEventTime(DELETION_TIME)
.setTargetId(fqdn)
.build());
PollMessage.OneTime pollMessage = persistSimpleResource(
new PollMessage.OneTime.Builder()
.setParent(historyEntry)
.setEventTime(DELETION_TIME)
.setClientId("TheRegistrar")
.setMsg("Domain registered")
.build());
ForeignKeyIndex<DomainResource> fki =
ForeignKeyIndex.load(DomainResource.class, fqdn, START_OF_TIME);
EppResourceIndex eppIndex =
ofy().load().entity(EppResourceIndex.create(Key.create(domain))).now();
return ImmutableSet.<ImmutableObject>of(
domain, historyEntry, billingEvent, pollMessage, fki, eppIndex);
}
private static Set<ImmutableObject> persistLotsOfDomains(String tld) {
ImmutableSet.Builder<ImmutableObject> persistedObjects = new ImmutableSet.Builder<>();
for (int i = 0; i < 20; i++) {
persistedObjects.addAll(persistDomainAndDescendants(String.format("domain%d.%s", i, tld)));
}
return persistedObjects.build();
}
private static void assertNotDeleted(Iterable<ImmutableObject> entities) {
for (ImmutableObject entity : entities) {
assertThat(ofy().load().entity(entity).now()).isNotNull();
}
}
private static void assertDeleted(Iterable<ImmutableObject> entities) {
for (ImmutableObject entity : entities) {
assertThat(ofy().load().entity(entity).now()).isNull();
}
}
}

View file

@ -0,0 +1,133 @@
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.domain.registry.tools.server;
import static com.google.appengine.tools.cloudstorage.GcsServiceFactory.createGcsService;
import static com.google.common.truth.Truth.assertThat;
import static com.google.domain.registry.testing.DatastoreHelper.createTld;
import static com.google.domain.registry.testing.DatastoreHelper.newDomainResource;
import static com.google.domain.registry.testing.DatastoreHelper.newHostResource;
import static com.google.domain.registry.testing.DatastoreHelper.persistActiveContact;
import static com.google.domain.registry.testing.DatastoreHelper.persistActiveDomain;
import static com.google.domain.registry.testing.DatastoreHelper.persistActiveDomainApplication;
import static com.google.domain.registry.testing.DatastoreHelper.persistActiveHost;
import static com.google.domain.registry.testing.DatastoreHelper.persistResource;
import static com.google.domain.registry.testing.GcsTestingUtils.readGcsFile;
import static com.google.domain.registry.util.ResourceUtils.readResourceUtf8;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.joda.time.Duration.standardDays;
import com.google.appengine.tools.cloudstorage.GcsFilename;
import com.google.appengine.tools.cloudstorage.GcsService;
import com.google.common.base.Optional;
import com.google.common.base.Splitter;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.domain.registry.mapreduce.MapreduceRunner;
import com.google.domain.registry.model.domain.ReferenceUnion;
import com.google.domain.registry.model.domain.secdns.DelegationSignerData;
import com.google.domain.registry.model.host.HostResource;
import com.google.domain.registry.testing.FakeClock;
import com.google.domain.registry.testing.mapreduce.MapreduceTestCase;
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import java.net.InetAddress;
import java.util.Map;
/** Tests for {@link GenerateZoneFilesAction}.*/
@RunWith(JUnit4.class)
public class GenerateZoneFilesActionTest extends MapreduceTestCase<GenerateZoneFilesAction> {
private final GcsService gcsService = createGcsService();
@Test
public void testGenerate() throws Exception {
DateTime now = DateTime.now(DateTimeZone.UTC).withTimeAtStartOfDay();
createTld("tld");
createTld("com");
ImmutableSet<InetAddress> ips =
ImmutableSet.of(InetAddress.getByName("127.0.0.1"), InetAddress.getByName("::1"));
HostResource host1 =
persistResource(newHostResource("ns.foo.tld").asBuilder().addInetAddresses(ips).build());
HostResource host2 =
persistResource(newHostResource("ns.bar.tld").asBuilder().addInetAddresses(ips).build());
ImmutableSet<ReferenceUnion<HostResource>> nameservers =
ImmutableSet.of(
ReferenceUnion.<HostResource>create(host1),
ReferenceUnion.<HostResource>create(host2));
persistResource(newDomainResource("ns-and-ds.tld").asBuilder()
.addNameservers(nameservers)
.setDsData(ImmutableSet.of(DelegationSignerData.create(1, 2, 3, new byte[] {0, 1, 2})))
.build());
persistResource(newDomainResource("ns-only.tld").asBuilder()
.addNameservers(nameservers)
.build());
persistResource(newDomainResource("ds-only.tld").asBuilder()
.setDsData(ImmutableSet.of(DelegationSignerData.create(1, 2, 3, new byte[] {0, 1, 2})))
.build());
// These should be ignored; contact and applications aren't in DNS, hosts need to be from the
// same tld and have ip addresses, and domains need to be from the same tld and have hosts.
persistActiveContact("ignored_contact");
persistActiveDomainApplication("ignored_application.tld");
persistActiveHost("ignored.host.tld"); // No ips.
persistActiveDomain("ignored_domain.tld"); // No hosts or DS data.
persistResource(newHostResource("ignored.foo.com").asBuilder().addInetAddresses(ips).build());
persistResource(newDomainResource("ignored.com")
.asBuilder()
.addNameservers(nameservers)
.setDsData(ImmutableSet.of(DelegationSignerData.create(1, 2, 3, new byte[] {0, 1, 2})))
.build());
GenerateZoneFilesAction action = new GenerateZoneFilesAction();
action.mrRunner = new MapreduceRunner(Optional.<Integer>absent(), Optional.<Integer>absent());
action.bucket = "zonefiles-bucket";
action.gcsBufferSize = 123;
action.datastoreRetention = standardDays(29);
action.clock = new FakeClock(now.plusMinutes(2)); // Move past the actions' 2 minute check.
Map<String, Object> response = action.handleJsonRequest(ImmutableMap.<String, Object>of(
"tlds", ImmutableList.of("tld"),
"exportTime", now));
assertThat(response).containsEntry(
"filenames",
ImmutableList.of("gs://zonefiles-bucket/tld-" + now + ".zone"));
executeTasksUntilEmpty("mapreduce");
GcsFilename gcsFilename =
new GcsFilename("zonefiles-bucket", String.format("tld-%s.zone", now));
String generatedFile = new String(readGcsFile(gcsService, gcsFilename), UTF_8);
// The generated file contains spaces and tabs, but the golden file contains only spaces, as
// files with literal tabs irritate our build tools.
Splitter splitter = Splitter.on('\n').omitEmptyStrings();
Iterable<String> generatedFileLines = splitter.split(generatedFile.replaceAll("\t", " "));
Iterable<String> goldenFileLines =
splitter.split(readResourceUtf8(getClass(), "testdata/tld.zone"));
// The first line needs to be the same as the golden file.
assertThat(generatedFileLines.iterator().next()).isEqualTo(goldenFileLines.iterator().next());
// The remaining lines can be in any order.
assertThat(generatedFileLines).containsExactlyElementsIn(goldenFileLines);
}
}

View file

@ -0,0 +1,240 @@
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.domain.registry.tools.server;
import static com.google.appengine.api.datastore.DatastoreServiceFactory.getDatastoreService;
import static com.google.common.base.Predicates.in;
import static com.google.common.base.Predicates.instanceOf;
import static com.google.common.base.Predicates.not;
import static com.google.common.collect.Multimaps.filterKeys;
import static com.google.common.truth.Truth.assertThat;
import static com.google.domain.registry.model.ofy.ObjectifyService.ofy;
import static com.google.domain.registry.model.server.ServerSecret.getServerSecret;
import static com.google.domain.registry.testing.DatastoreHelper.createTld;
import static com.google.domain.registry.testing.DatastoreHelper.newContactResource;
import static com.google.domain.registry.testing.DatastoreHelper.newDomainApplication;
import static com.google.domain.registry.testing.DatastoreHelper.newDomainResource;
import static com.google.domain.registry.testing.DatastoreHelper.newHostResource;
import static com.google.domain.registry.testing.DatastoreHelper.persistPremiumList;
import static com.google.domain.registry.testing.DatastoreHelper.persistReservedList;
import static com.google.domain.registry.testing.DatastoreHelper.persistResource;
import static com.google.domain.registry.testing.DatastoreHelper.persistResourceWithCommitLog;
import static com.google.domain.registry.util.DateTimeUtils.END_OF_TIME;
import static com.google.domain.registry.util.DateTimeUtils.START_OF_TIME;
import static java.util.Arrays.asList;
import static org.joda.money.CurrencyUnit.USD;
import com.google.appengine.api.datastore.Entity;
import com.google.common.base.Predicate;
import com.google.common.collect.FluentIterable;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
import com.google.domain.registry.mapreduce.MapreduceAction;
import com.google.domain.registry.model.EntityClasses;
import com.google.domain.registry.model.EppResource;
import com.google.domain.registry.model.ImmutableObject;
import com.google.domain.registry.model.annotations.VirtualEntity;
import com.google.domain.registry.model.billing.BillingEvent;
import com.google.domain.registry.model.billing.BillingEvent.Reason;
import com.google.domain.registry.model.billing.RegistrarBillingEntry;
import com.google.domain.registry.model.billing.RegistrarCredit;
import com.google.domain.registry.model.billing.RegistrarCredit.CreditType;
import com.google.domain.registry.model.billing.RegistrarCreditBalance;
import com.google.domain.registry.model.common.EntityGroupRoot;
import com.google.domain.registry.model.common.GaeUserIdConverter;
import com.google.domain.registry.model.export.LogsExportCursor;
import com.google.domain.registry.model.ofy.CommitLogCheckpoint;
import com.google.domain.registry.model.ofy.CommitLogCheckpointRoot;
import com.google.domain.registry.model.poll.PollMessage;
import com.google.domain.registry.model.rde.RdeMode;
import com.google.domain.registry.model.rde.RdeRevision;
import com.google.domain.registry.model.registrar.Registrar;
import com.google.domain.registry.model.registry.Registry;
import com.google.domain.registry.model.registry.RegistryCursor;
import com.google.domain.registry.model.registry.RegistryCursor.CursorType;
import com.google.domain.registry.model.reporting.HistoryEntry;
import com.google.domain.registry.model.server.Lock;
import com.google.domain.registry.model.smd.SignedMarkRevocationList;
import com.google.domain.registry.model.tmch.ClaimsListShard;
import com.google.domain.registry.model.tmch.TmchCrl;
import com.google.domain.registry.testing.mapreduce.MapreduceTestCase;
import com.googlecode.objectify.Key;
import com.googlecode.objectify.Ref;
import com.googlecode.objectify.VoidWork;
import org.joda.money.Money;
import org.junit.Test;
public abstract class KillAllActionTestCase<T> extends MapreduceTestCase<T>{
private final ImmutableSet<String> affectedKinds;
private static final ImmutableSet<String> ALL_PERSISTED_KINDS = FluentIterable
.from(EntityClasses.ALL_CLASSES)
.filter(
new Predicate<Class<?>>() {
@Override
public boolean apply(Class<?> clazz) {
return !clazz.isAnnotationPresent(VirtualEntity.class);
}})
.transform(EntityClasses.CLASS_TO_KIND_FUNCTION)
.toSet();
public KillAllActionTestCase(ImmutableSet<String> affectedKinds) {
this.affectedKinds = affectedKinds;
}
/** Create at least one of each type of entity in the schema. */
void createData() {
createTld("tld1");
createTld("tld2");
persistResource(CommitLogCheckpointRoot.create(START_OF_TIME.plusDays(1)));
persistResource(
CommitLogCheckpoint.create(
START_OF_TIME.plusDays(1),
ImmutableMap.of(1, START_OF_TIME.plusDays(2))));
for (EppResource resource : asList(
newDomainResource("foo.tld1"),
newDomainResource("foo.tld2"),
newDomainApplication("foo.tld1"),
newDomainApplication("foo.tld2"),
newContactResource("foo1"),
newContactResource("foo2"),
newHostResource("ns.foo.tld1"),
newHostResource("ns.foo.tld2"))) {
persistResourceWithCommitLog(resource);
HistoryEntry history =
persistResource(new HistoryEntry.Builder().setParent(resource).build());
BillingEvent.OneTime oneTime = persistResource(new BillingEvent.OneTime.Builder()
.setParent(history)
.setBillingTime(START_OF_TIME)
.setEventTime(START_OF_TIME)
.setClientId("")
.setTargetId("")
.setReason(Reason.ERROR)
.setCost(Money.of(USD, 1))
.build());
for (ImmutableObject descendant : asList(
new PollMessage.OneTime.Builder()
.setParent(history)
.setClientId("")
.setEventTime(START_OF_TIME)
.build(),
new PollMessage.Autorenew.Builder()
.setParent(history)
.setClientId("")
.setEventTime(START_OF_TIME)
.build(),
new BillingEvent.Cancellation.Builder()
.setOneTimeEventRef(Ref.create(oneTime))
.setParent(history)
.setBillingTime(START_OF_TIME)
.setEventTime(START_OF_TIME)
.setClientId("")
.setTargetId("")
.setReason(Reason.ERROR)
.build(),
new BillingEvent.Modification.Builder()
.setEventRef(Ref.create(oneTime))
.setParent(history)
.setEventTime(START_OF_TIME)
.setClientId("")
.setTargetId("")
.setReason(Reason.ERROR)
.setCost(Money.of(USD, 1))
.build(),
new BillingEvent.Recurring.Builder()
.setParent(history)
.setEventTime(START_OF_TIME)
.setClientId("")
.setTargetId("")
.setReason(Reason.ERROR)
.build())) {
persistResource(descendant);
}
}
persistResource(new RegistrarBillingEntry.Builder()
.setParent(Registrar.loadByClientId("TheRegistrar"))
.setCreated(START_OF_TIME)
.setDescription("description")
.setAmount(Money.of(USD, 1))
.build());
RegistrarCredit credit = persistResource(new RegistrarCredit.Builder()
.setParent(Registrar.loadByClientId("TheRegistrar"))
.setCreationTime(START_OF_TIME)
.setCurrency(USD)
.setDescription("description")
.setTld("tld1")
.setType(CreditType.AUCTION)
.build());
persistResource(new RegistrarCreditBalance.Builder()
.setParent(credit)
.setAmount(Money.of(USD, 1))
.setEffectiveTime(START_OF_TIME)
.setWrittenTime(START_OF_TIME)
.build());
persistPremiumList("premium", "a,USD 100", "b,USD 200");
persistReservedList("reserved", "lol,RESERVED_FOR_ANCHOR_TENANT,foobar1");
getServerSecret(); // Forces persist.
TmchCrl.set("crl content");
persistResource(new LogsExportCursor.Builder().build());
persistPremiumList("premium", "a,USD 100", "b,USD 200");
SignedMarkRevocationList.create(
START_OF_TIME, ImmutableMap.of("a", START_OF_TIME, "b", END_OF_TIME)).save();
ClaimsListShard.create(START_OF_TIME, ImmutableMap.of("a", "1", "b", "2")).save();
// These entities must be saved within a transaction.
ofy().transact(new VoidWork() {
@Override
public void vrun() {
RegistryCursor.save(Registry.get("tld1"), CursorType.BRDA, START_OF_TIME);
RdeRevision.saveRevision("tld1", START_OF_TIME, RdeMode.FULL, 0);
}});
// These entities intentionally don't expose constructors or factory methods.
getDatastoreService().put(new Entity(EntityGroupRoot.getCrossTldKey().getRaw()));
getDatastoreService().put(new Entity(Key.getKind(GaeUserIdConverter.class), 1));
getDatastoreService().put(new Entity(Key.getKind(Lock.class), 1));
}
abstract MapreduceAction createAction();
@Test
public void testKill() throws Exception {
createData();
ImmutableMultimap<String, Object> beforeContents = getDatastoreContents();
assertThat(beforeContents.keySet()).named("persisted test data")
.containsAllIn(ALL_PERSISTED_KINDS);
MapreduceAction action = createAction();
action.run();
executeTasksUntilEmpty("mapreduce");
ImmutableMultimap<String, Object> afterContents = getDatastoreContents();
assertThat(afterContents.keySet()).containsNoneIn(affectedKinds);
assertThat(afterContents)
.containsExactlyEntriesIn(filterKeys(beforeContents, not(in(affectedKinds))));
}
private ImmutableMultimap<String, Object> getDatastoreContents() {
ofy().clearSessionCache();
ImmutableMultimap.Builder<String, Object> contentsBuilder = new ImmutableMultimap.Builder<>();
// Filter out raw Entity objects created by the mapreduce.
for (Object obj : Iterables.filter(ofy().load(), not(instanceOf(Entity.class)))) {
contentsBuilder.put(Key.getKind(obj.getClass()), obj);
}
return contentsBuilder.build();
}
}

View file

@ -0,0 +1,57 @@
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.domain.registry.tools.server;
import static com.google.domain.registry.model.EntityClasses.CLASS_TO_KIND_FUNCTION;
import static java.util.Arrays.asList;
import com.google.common.base.Optional;
import com.google.common.collect.FluentIterable;
import com.google.domain.registry.mapreduce.MapreduceAction;
import com.google.domain.registry.mapreduce.MapreduceRunner;
import com.google.domain.registry.model.ofy.CommitLogBucket;
import com.google.domain.registry.model.ofy.CommitLogCheckpoint;
import com.google.domain.registry.model.ofy.CommitLogCheckpointRoot;
import com.google.domain.registry.model.ofy.CommitLogManifest;
import com.google.domain.registry.model.ofy.CommitLogMutation;
import com.google.domain.registry.testing.FakeResponse;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
/** Tests for {@link KillAllCommitLogsAction}.*/
@RunWith(JUnit4.class)
public class KillAllCommitLogsActionTest extends KillAllActionTestCase<KillAllCommitLogsAction> {
public KillAllCommitLogsActionTest() {
super(FluentIterable
.from(asList(
CommitLogBucket.class,
CommitLogCheckpoint.class,
CommitLogCheckpointRoot.class,
CommitLogMutation.class,
CommitLogManifest.class))
.transform(CLASS_TO_KIND_FUNCTION)
.toSet());
}
@Override
MapreduceAction createAction() {
action = new KillAllCommitLogsAction();
action.mrRunner = new MapreduceRunner(Optional.<Integer>absent(), Optional.<Integer>absent());
action.response = new FakeResponse();
return action;
}
}

View file

@ -0,0 +1,82 @@
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.domain.registry.tools.server;
import static com.google.domain.registry.model.EntityClasses.CLASS_TO_KIND_FUNCTION;
import static java.util.Arrays.asList;
import com.google.common.base.Optional;
import com.google.common.collect.FluentIterable;
import com.google.domain.registry.mapreduce.MapreduceAction;
import com.google.domain.registry.mapreduce.MapreduceRunner;
import com.google.domain.registry.model.billing.RegistrarBillingEntry;
import com.google.domain.registry.model.billing.RegistrarCredit;
import com.google.domain.registry.model.billing.RegistrarCreditBalance;
import com.google.domain.registry.model.common.EntityGroupRoot;
import com.google.domain.registry.model.export.LogsExportCursor;
import com.google.domain.registry.model.registrar.Registrar;
import com.google.domain.registry.model.registrar.RegistrarContact;
import com.google.domain.registry.model.registry.Registry;
import com.google.domain.registry.model.registry.RegistryCursor;
import com.google.domain.registry.model.registry.label.PremiumList;
import com.google.domain.registry.model.registry.label.PremiumList.PremiumListEntry;
import com.google.domain.registry.model.registry.label.ReservedList;
import com.google.domain.registry.model.server.ServerSecret;
import com.google.domain.registry.model.smd.SignedMarkRevocationList;
import com.google.domain.registry.model.tmch.ClaimsListShard;
import com.google.domain.registry.model.tmch.ClaimsListShard.ClaimsListSingleton;
import com.google.domain.registry.model.tmch.TmchCrl;
import com.google.domain.registry.testing.FakeResponse;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
/** Tests for {@link KillAllCommitLogsAction}.*/
@RunWith(JUnit4.class)
public class KillAllCrossTldEntitiesActionTest
extends KillAllActionTestCase<KillAllCrossTldEntitiesAction> {
public KillAllCrossTldEntitiesActionTest() {
super(FluentIterable
.from(asList(
ClaimsListShard.class,
ClaimsListSingleton.class,
EntityGroupRoot.class,
LogsExportCursor.class,
PremiumList.class,
PremiumListEntry.class,
Registrar.class,
RegistrarBillingEntry.class,
RegistrarContact.class,
RegistrarCredit.class,
RegistrarCreditBalance.class,
Registry.class,
RegistryCursor.class,
ReservedList.class,
ServerSecret.class,
SignedMarkRevocationList.class,
TmchCrl.class))
.transform(CLASS_TO_KIND_FUNCTION)
.toSet());
}
@Override
MapreduceAction createAction() {
action = new KillAllCrossTldEntitiesAction();
action.mrRunner = new MapreduceRunner(Optional.<Integer>absent(), Optional.<Integer>absent());
action.response = new FakeResponse();
return action;
}
}

View file

@ -0,0 +1,73 @@
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.domain.registry.tools.server;
import static com.google.domain.registry.model.EntityClasses.CLASS_TO_KIND_FUNCTION;
import static java.util.Arrays.asList;
import com.google.common.base.Optional;
import com.google.common.collect.FluentIterable;
import com.google.domain.registry.mapreduce.MapreduceAction;
import com.google.domain.registry.mapreduce.MapreduceRunner;
import com.google.domain.registry.model.billing.BillingEvent;
import com.google.domain.registry.model.contact.ContactResource;
import com.google.domain.registry.model.domain.DomainBase;
import com.google.domain.registry.model.host.HostResource;
import com.google.domain.registry.model.index.DomainApplicationIndex;
import com.google.domain.registry.model.index.EppResourceIndex;
import com.google.domain.registry.model.index.ForeignKeyIndex.ForeignKeyContactIndex;
import com.google.domain.registry.model.index.ForeignKeyIndex.ForeignKeyDomainIndex;
import com.google.domain.registry.model.index.ForeignKeyIndex.ForeignKeyHostIndex;
import com.google.domain.registry.model.poll.PollMessage;
import com.google.domain.registry.model.reporting.HistoryEntry;
import com.google.domain.registry.testing.FakeResponse;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
/** Tests for {@link KillAllEppResourcesAction}.*/
@RunWith(JUnit4.class)
public class KillAllEppResourcesActionTest
extends KillAllActionTestCase<KillAllEppResourcesAction> {
public KillAllEppResourcesActionTest() {
super(FluentIterable
.from(asList(
EppResourceIndex.class,
ForeignKeyContactIndex.class,
ForeignKeyDomainIndex.class,
ForeignKeyHostIndex.class,
DomainApplicationIndex.class,
DomainBase.class,
ContactResource.class,
HostResource.class,
HistoryEntry.class,
PollMessage.class,
BillingEvent.OneTime.class,
BillingEvent.Recurring.class,
BillingEvent.Cancellation.class,
BillingEvent.Modification.class))
.transform(CLASS_TO_KIND_FUNCTION)
.toSet());
}
@Override
MapreduceAction createAction() {
action = new KillAllEppResourcesAction();
action.mrRunner = new MapreduceRunner(Optional.<Integer>absent(), Optional.<Integer>absent());
action.response = new FakeResponse();
return action;
}
}

View file

@ -0,0 +1,92 @@
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.domain.registry.tools.server;
import static com.google.common.truth.Truth.assertThat;
import static javax.servlet.http.HttpServletResponse.SC_OK;
import com.google.common.base.Optional;
import com.google.domain.registry.testing.AppEngineRule;
import com.google.domain.registry.testing.ExceptionRule;
import com.google.domain.registry.testing.FakeJsonResponse;
import org.junit.Rule;
import java.util.List;
import java.util.regex.Pattern;
/**
* Base class for tests of list actions.
*/
public class ListActionTestCase {
@Rule
public final AppEngineRule appEngine = AppEngineRule.builder()
.withDatastore()
.build();
@Rule
public final ExceptionRule thrown = new ExceptionRule();
private FakeJsonResponse response;
void runAction(
ListObjectsAction<?> action,
Optional<String> fields,
Optional<Boolean> printHeaderRow,
Optional<Boolean> fullFieldNames) {
response = new FakeJsonResponse();
action.response = response;
action.fields = fields;
action.printHeaderRow = printHeaderRow;
action.fullFieldNames = fullFieldNames;
action.run();
assertThat(response.getStatus()).isEqualTo(SC_OK);
}
void testRunSuccess(
ListObjectsAction<?> action,
Optional<String> fields,
Optional<Boolean> printHeaderRow,
Optional<Boolean> fullFieldNames,
String ... expectedLinePatterns) {
assertThat(expectedLinePatterns).isNotNull();
runAction(action, fields, printHeaderRow, fullFieldNames);
assertThat(response.getResponseMap().get("status")).isEqualTo("success");
Object obj = response.getResponseMap().get("lines");
assertThat(obj).isInstanceOf(List.class);
@SuppressWarnings("unchecked")
List<String> lines = (List<String>) obj;
assertThat(lines).hasSize(expectedLinePatterns.length);
for (int i = 0; i < lines.size(); i++) {
assertThat(lines.get(i)).containsMatch(Pattern.compile(expectedLinePatterns[i]));
}
}
void testRunError(
ListObjectsAction<?> action,
Optional<String> fields,
Optional<Boolean> printHeaderRow,
Optional<Boolean> fullFieldNames,
String expectedErrorPattern) {
assertThat(expectedErrorPattern).isNotNull();
runAction(action, fields, printHeaderRow, fullFieldNames);
assertThat(response.getResponseMap().get("status")).isEqualTo("error");
Object obj = response.getResponseMap().get("error");
assertThat(obj).isInstanceOf(String.class);
String error = obj.toString();
assertThat(error).containsMatch(Pattern.compile(expectedErrorPattern));
}
}

View file

@ -0,0 +1,215 @@
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.domain.registry.tools.server;
import static com.google.domain.registry.testing.DatastoreHelper.createTld;
import static com.google.domain.registry.testing.DatastoreHelper.createTlds;
import static com.google.domain.registry.testing.DatastoreHelper.persistActiveDomain;
import com.google.common.base.Optional;
import com.google.domain.registry.testing.FakeClock;
import org.joda.time.DateTime;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
/**
* Unit tests for {@link ListDomainsAction}.
*/
@RunWith(JUnit4.class)
public class ListDomainsActionTest extends ListActionTestCase {
ListDomainsAction action;
@Before
public void init() throws Exception {
createTld("foo");
action = new ListDomainsAction();
action.clock = new FakeClock(DateTime.parse("2000-01-01TZ"));
}
@Test
public void testRun_invalidRequest_missingTld() throws Exception {
action.tld = null;
testRunError(
action,
null,
null,
null,
"^Null or empty TLD specified$");
}
@Test
public void testRun_invalidRequest_invalidTld() throws Exception {
action.tld = "%%%badtld%%%";
testRunError(
action,
null,
null,
null,
"^TLD %%%badtld%%% does not exist$");
}
@Test
public void testRun_noParameters() throws Exception {
action.tld = "foo";
testRunSuccess(
action,
null,
null,
null);
}
@Test
public void testRun_twoLinesWithIdOnly() throws Exception {
action.tld = "foo";
createTlds("bar", "sim");
persistActiveDomain("dontlist.bar");
persistActiveDomain("example1.foo");
persistActiveDomain("example2.foo");
persistActiveDomain("notlistedaswell.sim");
// Only list the two domains in .foo, not the .bar or .sim ones.
testRunSuccess(
action,
null,
null,
null,
"^example1.foo$",
"^example2.foo$");
}
@Test
public void testRun_twoLinesWithIdOnlyNoHeader() throws Exception {
action.tld = "foo";
persistActiveDomain("example1.foo");
persistActiveDomain("example2.foo");
testRunSuccess(
action,
null,
Optional.of(false),
null,
"^example1.foo$",
"^example2.foo$");
}
@Test
public void testRun_twoLinesWithIdOnlyExplicitHeader() throws Exception {
action.tld = "foo";
persistActiveDomain("example1.foo");
persistActiveDomain("example2.foo");
testRunSuccess(
action,
null,
Optional.of(true),
null,
"^fullyQualifiedDomainName$",
"^-+\\s*$",
"^example1.foo\\s*$",
"^example2.foo\\s*$");
}
@Test
public void testRun_twoLinesWithRepoId() throws Exception {
action.tld = "foo";
persistActiveDomain("example1.foo");
persistActiveDomain("example3.foo");
testRunSuccess(
action,
Optional.of("repoId"),
null,
null,
"^fullyQualifiedDomainName\\s+repoId\\s*$",
"^-+\\s+-+\\s*$",
"^example1.foo\\s+2-FOO\\s*$",
"^example3.foo\\s+4-FOO\\s*$");
}
@Test
public void testRun_twoLinesWithRepoIdNoHeader() throws Exception {
action.tld = "foo";
persistActiveDomain("example1.foo");
persistActiveDomain("example3.foo");
testRunSuccess(
action,
Optional.of("repoId"),
Optional.of(false),
null,
"^example1.foo 2-FOO$",
"^example3.foo 4-FOO$");
}
@Test
public void testRun_twoLinesWithRepoIdExplicitHeader() throws Exception {
action.tld = "foo";
persistActiveDomain("example1.foo");
persistActiveDomain("example3.foo");
testRunSuccess(
action,
Optional.of("repoId"),
Optional.of(true),
null,
"^fullyQualifiedDomainName\\s+repoId\\s*$",
"^-+\\s+-+\\s*$",
"^example1.foo\\s+2-FOO\\s*$",
"^example3.foo\\s+4-FOO\\s*$");
}
@Test
public void testRun_twoLinesWithWildcard() throws Exception {
action.tld = "foo";
persistActiveDomain("example1.foo");
persistActiveDomain("example3.foo");
testRunSuccess(
action,
Optional.of("*"),
null,
null,
"^fullyQualifiedDomainName\\s+.*repoId",
"^-+\\s+-+",
"^example1.foo\\s+.*2-FOO",
"^example3.foo\\s+.*4-FOO");
}
@Test
public void testRun_twoLinesWithWildcardAndAnotherField() throws Exception {
action.tld = "foo";
persistActiveDomain("example1.foo");
persistActiveDomain("example3.foo");
testRunSuccess(
action,
Optional.of("*,repoId"),
null,
null,
"^fullyQualifiedDomainName\\s+.*repoId",
"^-+\\s+-+",
"^example1.foo\\s+.*2-FOO",
"^example3.foo\\s+.*4-FOO");
}
@Test
public void testRun_withBadField_returnsError() throws Exception {
action.tld = "foo";
persistActiveDomain("example2.foo");
persistActiveDomain("example1.foo");
testRunError(
action,
Optional.of("badfield"),
null,
null,
"^Field 'badfield' not found - recognized fields are:");
}
}

View file

@ -0,0 +1,109 @@
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.domain.registry.tools.server;
import static com.google.domain.registry.testing.DatastoreHelper.createTld;
import static com.google.domain.registry.testing.DatastoreHelper.persistActiveHost;
import com.google.common.base.Optional;
import com.google.domain.registry.testing.FakeClock;
import org.joda.time.DateTime;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
/**
* Unit tests for {@link ListHostsAction}.
*/
@RunWith(JUnit4.class)
public class ListHostsActionTest extends ListActionTestCase {
ListHostsAction action;
@Before
public void init() throws Exception {
createTld("foo");
action = new ListHostsAction();
action.clock = new FakeClock(DateTime.parse("2000-01-01TZ"));
}
@Test
public void testRun_noParameters() throws Exception {
testRunSuccess(
action,
null,
null,
null);
}
@Test
public void testRun_twoLinesWithRepoId() throws Exception {
persistActiveHost("example2.foo");
persistActiveHost("example1.foo");
testRunSuccess(
action,
Optional.of("repoId"),
null,
null,
"^fullyQualifiedHostName\\s+repoId\\s*$",
"^-+\\s+-+\\s*$",
"^example1.foo\\s+3-ROID\\s*$",
"^example2.foo\\s+2-ROID\\s*$");
}
@Test
public void testRun_twoLinesWithWildcard() throws Exception {
persistActiveHost("example2.foo");
persistActiveHost("example1.foo");
testRunSuccess(
action,
Optional.of("*"),
null,
null,
"^fullyQualifiedHostName\\s+.*repoId",
"^-+\\s+-+",
"^example1.foo\\s+.*2",
"^example2.foo\\s+.*1");
}
@Test
public void testRun_twoLinesWithWildcardAndAnotherField() throws Exception {
persistActiveHost("example2.foo");
persistActiveHost("example1.foo");
testRunSuccess(
action,
Optional.of("*,repoId"),
null,
null,
"^fullyQualifiedHostName\\s+.*repoId",
"^-+\\s+-+",
"^example1.foo\\s+.*2",
"^example2.foo\\s+.*1");
}
@Test
public void testRun_withBadField_returnsError() throws Exception {
persistActiveHost("example2.foo");
persistActiveHost("example1.foo");
testRunError(
action,
Optional.of("badfield"),
null,
null,
"^Field 'badfield' not found - recognized fields are:");
}
}

View file

@ -0,0 +1,92 @@
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.domain.registry.tools.server;
import static com.google.domain.registry.testing.DatastoreHelper.persistPremiumList;
import com.google.common.base.Optional;
import com.google.domain.registry.model.registry.label.PremiumList;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
/**
* Unit tests for {@link ListPremiumListsAction}.
*/
@RunWith(JUnit4.class)
public class ListPremiumListsActionTest extends ListActionTestCase {
ListPremiumListsAction action;
@Before
public void init() throws Exception {
persistPremiumList("xn--q9jyb4c", "rich,USD 100");
persistPremiumList("how", "richer,JPY 5000");
PremiumList.get("how").get().asBuilder()
.setDescription("foobar")
.build()
.saveAndUpdateEntries();
action = new ListPremiumListsAction();
}
@Test
public void testRun_noParameters() throws Exception {
testRunSuccess(
action,
null,
null,
null,
"^how $",
"^xn--q9jyb4c$");
}
@Test
public void testRun_withParameters() throws Exception {
testRunSuccess(
action,
Optional.of("revisionKey,description"),
null,
null,
"^name\\s+revisionKey\\s+description\\s*$",
"^-+\\s+-+\\s+-+\\s*$",
"^how\\s+.*PremiumList.*$",
"^xn--q9jyb4c\\s+.*PremiumList.*$");
}
@Test
public void testRun_withWildcard() throws Exception {
testRunSuccess(
action,
Optional.of("*"),
null,
null,
"^name\\s+.*revisionKey",
"^-+\\s+-+.*",
"^how\\s+.*PremiumList",
"^xn--q9jyb4c\\s+.*PremiumList");
}
@Test
public void testRun_withBadField_returnsError() throws Exception {
testRunError(
action,
Optional.of("badfield"),
null,
null,
"^Field 'badfield' not found - recognized fields are:");
}
}

View file

@ -0,0 +1,101 @@
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.domain.registry.tools.server;
import static com.google.domain.registry.testing.DatastoreHelper.createTlds;
import static com.google.domain.registry.testing.DatastoreHelper.persistResource;
import com.google.common.base.Optional;
import com.google.common.collect.ImmutableSet;
import com.google.domain.registry.model.registrar.Registrar;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
/**
* Unit tests for {@link ListRegistrarsAction}.
*/
@RunWith(JUnit4.class)
public class ListRegistrarsActionTest extends ListActionTestCase {
ListRegistrarsAction action;
@Before
public void init() throws Exception {
action = new ListRegistrarsAction();
createTlds("xn--q9jyb4c", "example");
// Ensure that NewRegistrar only has access to xn--q9jyb4c and that TheRegistrar only has access
// to example.
persistResource(
Registrar.loadByClientId("NewRegistrar")
.asBuilder()
.setAllowedTlds(ImmutableSet.of("xn--q9jyb4c"))
.build());
persistResource(
Registrar.loadByClientId("TheRegistrar")
.asBuilder()
.setAllowedTlds(ImmutableSet.of("example"))
.build());
}
@Test
public void testRun_noParameters() throws Exception {
testRunSuccess(
action,
null,
null,
null,
"^NewRegistrar$",
"^TheRegistrar$");
}
@Test
public void testRun_withParameters() throws Exception {
testRunSuccess(
action,
Optional.of("allowedTlds"),
null,
null,
"^clientId\\s+allowedTlds\\s*$",
"-+\\s+-+\\s*$",
"^NewRegistrar\\s+\\[xn--q9jyb4c\\]\\s*$",
"^TheRegistrar\\s+\\[example\\]\\s*$");
}
@Test
public void testRun_withWildcard() throws Exception {
testRunSuccess(
action,
Optional.of("*"),
null,
null,
"^clientId\\s+.*allowedTlds",
"^-+\\s+-+",
"^NewRegistrar\\s+.*\\[xn--q9jyb4c\\]",
"^TheRegistrar\\s+.*\\[example\\]");
}
@Test
public void testRun_withBadField_returnsError() throws Exception {
testRunError(
action,
Optional.of("badfield"),
null,
null,
"^Field 'badfield' not found - recognized fields are:");
}
}

View file

@ -0,0 +1,93 @@
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.domain.registry.tools.server;
import static com.google.domain.registry.testing.DatastoreHelper.createTld;
import static com.google.domain.registry.testing.DatastoreHelper.persistReservedList;
import static com.google.domain.registry.testing.DatastoreHelper.persistResource;
import com.google.common.base.Optional;
import com.google.domain.registry.model.registry.Registry;
import com.google.domain.registry.model.registry.label.ReservedList;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
/**
* Unit tests for {@link ListReservedListsAction}.
*/
@RunWith(JUnit4.class)
public class ListReservedListsActionTest extends ListActionTestCase {
ListReservedListsAction action;
@Before
public void init() throws Exception {
ReservedList rl1 = persistReservedList("xn--q9jyb4c-published", true, "blah,FULLY_BLOCKED");
ReservedList rl2 = persistReservedList("xn--q9jyb4c-private", false, "dugong,FULLY_BLOCKED");
createTld("xn--q9jyb4c");
persistResource(Registry.get("xn--q9jyb4c").asBuilder().setReservedLists(rl1, rl2).build());
action = new ListReservedListsAction();
}
@Test
public void testRun_noParameters() throws Exception {
testRunSuccess(
action,
null,
null,
null,
"^xn--q9jyb4c-private\\s*$",
"^xn--q9jyb4c-published\\s*$");
}
@Test
public void testRun_withParameters() throws Exception {
testRunSuccess(
action,
Optional.of("shouldPublish"),
null,
null,
"^name\\s+shouldPublish\\s*$",
"^-+\\s+-+\\s*$",
"^xn--q9jyb4c-private\\s+false\\s*$",
"^xn--q9jyb4c-published\\s+true\\s*$");
}
@Test
public void testRun_withWildcard() throws Exception {
testRunSuccess(
action,
Optional.of("*"),
null,
null,
"^name\\s+.*shouldPublish.*",
"^-+\\s+-+",
"^xn--q9jyb4c-private\\s+.*false",
"^xn--q9jyb4c-published\\s+.*true");
}
@Test
public void testRun_withBadField_returnsError() throws Exception {
testRunError(
action,
Optional.of("badfield"),
null,
null,
"^Field 'badfield' not found - recognized fields are:");
}
}

View file

@ -0,0 +1,81 @@
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.domain.registry.tools.server;
import static com.google.domain.registry.testing.DatastoreHelper.createTld;
import com.google.common.base.Optional;
import com.google.domain.registry.testing.FakeClock;
import org.joda.time.DateTime;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
/**
* Unit tests for {@link ListTldsAction}.
*/
@RunWith(JUnit4.class)
public class ListTldsActionTest extends ListActionTestCase {
ListTldsAction action;
@Before
public void init() throws Exception {
createTld("xn--q9jyb4c");
action = new ListTldsAction();
action.clock = new FakeClock(DateTime.parse("2000-01-01TZ"));
}
@Test
public void testRun_noParameters() throws Exception {
testRunSuccess(action, null, null, null, "xn--q9jyb4c");
}
@Test
public void testRun_withParameters() throws Exception {
testRunSuccess(
action,
Optional.of("tldType"),
null,
null,
"TLD tldType",
"----------- -------",
"xn--q9jyb4c REAL ");
}
@Test
public void testRun_withWildcard() throws Exception {
testRunSuccess(
action,
Optional.of("*"),
null,
null,
"^TLD .*tldType",
"^----------- .*-------",
"^xn--q9jyb4c .*REAL ");
}
@Test
public void testRun_withBadField_returnsError() throws Exception {
testRunError(
action,
Optional.of("badfield"),
null,
null,
"^Field 'badfield' not found - recognized fields are:");
}
}

View file

@ -0,0 +1,61 @@
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.domain.registry.tools.server;
import static com.google.common.truth.Truth.assertThat;
import static com.google.domain.registry.model.ofy.ObjectifyService.ofy;
import static com.google.domain.registry.testing.DatastoreHelper.persistActiveContact;
import com.google.common.base.Optional;
import com.google.domain.registry.mapreduce.MapreduceRunner;
import com.google.domain.registry.model.contact.ContactResource;
import com.google.domain.registry.testing.FakeResponse;
import com.google.domain.registry.testing.mapreduce.MapreduceTestCase;
import org.joda.time.DateTime;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
/** Unit tests for {@link ResaveAllEppResourcesAction}. */
@RunWith(JUnit4.class)
public class ResaveAllEppResourcesActionTest
extends MapreduceTestCase<ResaveAllEppResourcesAction> {
@Before
public void init() {
action = new ResaveAllEppResourcesAction();
action.mrRunner = new MapreduceRunner(Optional.<Integer>absent(), Optional.<Integer>absent());
action.response = new FakeResponse();
}
private void runMapreduce() throws Exception {
action.run();
executeTasksUntilEmpty("mapreduce");
}
@Test
public void test_mapreduceSuccessfullyResavesEntity() throws Exception {
ContactResource contact = persistActiveContact("test123");
DateTime creationTime = contact.getUpdateAutoTimestamp().getTimestamp();
assertThat(ofy().load().entity(contact).now().getUpdateAutoTimestamp().getTimestamp())
.isEqualTo(creationTime);
ofy().clearSessionCache();
runMapreduce();
assertThat(ofy().load().entity(contact).now().getUpdateAutoTimestamp().getTimestamp())
.isGreaterThan(creationTime);
}
}

View file

@ -0,0 +1,90 @@
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.domain.registry.tools.server;
import static com.google.common.truth.Truth.assertThat;
import static com.google.domain.registry.testing.DatastoreHelper.createTlds;
import static javax.servlet.http.HttpServletResponse.SC_OK;
import com.google.domain.registry.model.registry.label.PremiumList;
import com.google.domain.registry.testing.AppEngineRule;
import com.google.domain.registry.testing.ExceptionRule;
import com.google.domain.registry.testing.FakeJsonResponse;
import org.joda.money.Money;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
/**
* Unit tests for {@link UpdatePremiumListAction}.
*/
@RunWith(JUnit4.class)
public class UpdatePremiumListActionTest {
@Rule
public final AppEngineRule appEngine = AppEngineRule.builder()
.withDatastore()
.build();
@Rule
public final ExceptionRule thrown = new ExceptionRule();
UpdatePremiumListAction action;
FakeJsonResponse response;
@Before
public void init() throws Exception {
createTlds("foo", "xn--q9jyb4c", "how");
action = new UpdatePremiumListAction();
response = new FakeJsonResponse();
action.response = response;
}
@Test
public void test_invalidRequest_missingInput_returnsErrorStatus() throws Exception {
action.name = "foo";
action.run();
assertThat(response.getResponseMap().get("status")).isEqualTo("error");
}
@Test
public void test_invalidRequest_listDoesNotExist_returnsErrorStatus() throws Exception {
action.name = "bamboozle";
action.inputData = "richer,JPY 5000";
action.run();
assertThat(response.getResponseMap().get("status")).isEqualTo("error");
Object obj = response.getResponseMap().get("error");
assertThat(obj).isInstanceOf(String.class);
String error = obj.toString();
assertThat(error).contains("Could not update premium list");
}
@Test
public void test_success() throws Exception {
action.name = "foo";
action.inputData = "rich,USD 75\nricher,USD 5000\npoor, USD 0.99";
action.run();
assertThat(response.getStatus()).isEqualTo(SC_OK);
PremiumList premiumList = PremiumList.get("foo").get();
assertThat(premiumList.getPremiumListEntries()).hasSize(3);
assertThat(premiumList.getPremiumPrice("rich")).hasValue(Money.parse("USD 75"));
assertThat(premiumList.getPremiumPrice("richer")).hasValue(Money.parse("USD 5000"));
assertThat(premiumList.getPremiumPrice("poor")).hasValue(Money.parse("USD 0.99"));
assertThat(premiumList.getPremiumPrice("diamond")).isAbsent();
}
}

View file

@ -0,0 +1,16 @@
$ORIGIN tld.
ns.bar.tld 3600 IN A 127.0.0.1
ns.bar.tld 3600 IN AAAA 0:0:0:0:0:0:0:1
ns-only.tld 180 IN NS ns.foo.tld.
ns-only.tld 180 IN NS ns.bar.tld.
ds-only.tld 86400 IN DS 1 2 3 000102
ns-and-ds.tld 180 IN NS ns.foo.tld.
ns-and-ds.tld 180 IN NS ns.bar.tld.
ns-and-ds.tld 86400 IN DS 1 2 3 000102
ns.foo.tld 3600 IN A 127.0.0.1
ns.foo.tld 3600 IN AAAA 0:0:0:0:0:0:0:1

View file

@ -0,0 +1,102 @@
Marks: 标记&记录
smdID: 0000001871376042761364-65535
U-labels: 标记-记录, 标记和记录, 标记记录
notBefore: 2013-08-09 12:06:01
notAfter: 2017-07-24 00:00:00
-----BEGIN ENCODED SMD-----
PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHNtZDpzaWduZWRNYXJrIHht
bG5zOnNtZD0idXJuOmlldGY6cGFyYW1zOnhtbDpuczpzaWduZWRNYXJrLTEuMCIgaWQ9Il9mYTgw
NGYzNC1hZDg3LTQwNTYtYTQxMi03NzM4MTcxYzU0YzMiPgogIDxzbWQ6aWQ+MDAwMDAwMTg3MTM3
NjA0Mjc2MTM2NC02NTUzNTwvc21kOmlkPgogIDxzbWQ6aXNzdWVySW5mbyBpc3N1ZXJJRD0iNjU1
MzUiPgogICAgPHNtZDpvcmc+SUNBTk4gVE1DSCBURVNUSU5HIFRNVjwvc21kOm9yZz4KICAgIDxz
bWQ6ZW1haWw+bm90YXZhaWxhYmxlQGV4YW1wbGUuY29tPC9zbWQ6ZW1haWw+CiAgICA8c21kOnVy
bD5odHRwOi8vd3d3LmV4YW1wbGUuY29tPC9zbWQ6dXJsPgogICAgPHNtZDp2b2ljZT4rMzIuMDAw
MDAwPC9zbWQ6dm9pY2U+CiAgPC9zbWQ6aXNzdWVySW5mbz4KICA8c21kOm5vdEJlZm9yZT4yMDEz
LTA4LTA5VDEwOjA2OjAxLjM2NFo8L3NtZDpub3RCZWZvcmU+CiAgPHNtZDpub3RBZnRlcj4yMDE3
LTA3LTIzVDIyOjAwOjAwLjAwMFo8L3NtZDpub3RBZnRlcj4KICA8bWFyazptYXJrIHhtbG5zOm1h
cms9InVybjppZXRmOnBhcmFtczp4bWw6bnM6bWFyay0xLjAiPgogICAgPG1hcms6Y291cnQ+CiAg
ICAgIDxtYXJrOmlkPjAwMDUyODEzNzM0NzI2NTMxMzczNDcyNjUzLTY1NTM1PC9tYXJrOmlkPgog
ICAgICA8bWFyazptYXJrTmFtZT7moIforrAmYW1wO+iusOW9lTwvbWFyazptYXJrTmFtZT4KICAg
ICAgPG1hcms6aG9sZGVyIGVudGl0bGVtZW50PSJvd25lciI+CiAgICAgICAgPG1hcms6b3JnPuW3
peeoi+WkhDwvbWFyazpvcmc+CiAgICAgICAgPG1hcms6YWRkcj4KICAgICAgICAgIDxtYXJrOnN0
cmVldD7pppnmuK/kuJzot6825Y+377yMNeWPt+alvO+8jDjlj7flrqQ8L21hcms6c3RyZWV0Pgog
ICAgICAgICAgPG1hcms6Y2l0eT7pnZLlspvluII8L21hcms6Y2l0eT4KICAgICAgICAgIDxtYXJr
OnBjPjM1MDA8L21hcms6cGM+CiAgICAgICAgICA8bWFyazpjYz5DTjwvbWFyazpjYz4KICAgICAg
ICA8L21hcms6YWRkcj4KICAgICAgPC9tYXJrOmhvbGRlcj4KICAgICAgPG1hcms6Y29udGFjdCB0
eXBlPSJhZ2VudCI+CiAgICAgICAgPG1hcms6bmFtZT7mnY7lsI/mlrk8L21hcms6bmFtZT4KICAg
ICAgICA8bWFyazpvcmc+5bel56iL5aSEPC9tYXJrOm9yZz4KICAgICAgICA8bWFyazphZGRyPgog
ICAgICAgICAgPG1hcms6c3RyZWV0Pummmea4r+S4nOi3rzblj7fvvIw15Y+35qW877yMOOWPt+Wu
pDwvbWFyazpzdHJlZXQ+CiAgICAgICAgICA8bWFyazpjaXR5PumdkuWym+W4gjwvbWFyazpjaXR5
PgogICAgICAgICAgPG1hcms6cGM+MzUwMDwvbWFyazpwYz4KICAgICAgICAgIDxtYXJrOmNjPkNO
PC9tYXJrOmNjPgogICAgICAgIDwvbWFyazphZGRyPgogICAgICAgIDxtYXJrOnZvaWNlPis4Ni4x
MDg0NjU3MTczPC9tYXJrOnZvaWNlPgogICAgICAgIDxtYXJrOmZheD4rODYuMTA4NDY1NzE3NTwv
bWFyazpmYXg+CiAgICAgICAgPG1hcms6ZW1haWw+aW5mb0BjaGluZXNlLWFnZW5jeS5jb208L21h
cms6ZW1haWw+CiAgICAgIDwvbWFyazpjb250YWN0PgogICAgICA8bWFyazpsYWJlbD54bi0tMHRy
dzR3MDJnbHIyYmJhPC9tYXJrOmxhYmVsPgogICAgICA8bWFyazpsYWJlbD54bi0tLS1rdzNidTB4
bHIyYmJhPC9tYXJrOmxhYmVsPgogICAgICA8bWFyazpsYWJlbD54bi0tdzJ0OTZxcjY0YWE8L21h
cms6bGFiZWw+CiAgICAgIDxtYXJrOmdvb2RzQW5kU2VydmljZXM+5ZCJ5LuWPC9tYXJrOmdvb2Rz
QW5kU2VydmljZXM+CiAgICAgIDxtYXJrOnJlZk51bT4xMjM0PC9tYXJrOnJlZk51bT4KICAgICAg
PG1hcms6cHJvRGF0ZT4yMDEyLTEyLTMxVDIzOjAwOjAwLjAwMFo8L21hcms6cHJvRGF0ZT4KICAg
ICAgPG1hcms6Y2M+Q048L21hcms6Y2M+CiAgICAgIDxtYXJrOmNvdXJ0TmFtZT5Ib3ZlPC9tYXJr
OmNvdXJ0TmFtZT4KICAgIDwvbWFyazpjb3VydD4KICA8L21hcms6bWFyaz4KPGRzOlNpZ25hdHVy
ZSB4bWxuczpkcz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC8wOS94bWxkc2lnIyIgSWQ9Il8wNTU2
MmVkOS1mYTVjLTQ4YzktYTBlNy0wMjRiMjlmOTgyYTAiPjxkczpTaWduZWRJbmZvPjxkczpDYW5v
bmljYWxpemF0aW9uTWV0aG9kIEFsZ29yaXRobT0iaHR0cDovL3d3dy53My5vcmcvMjAwMS8xMC94
bWwtZXhjLWMxNG4jIi8+PGRzOlNpZ25hdHVyZU1ldGhvZCBBbGdvcml0aG09Imh0dHA6Ly93d3cu
dzMub3JnLzIwMDEvMDQveG1sZHNpZy1tb3JlI3JzYS1zaGEyNTYiLz48ZHM6UmVmZXJlbmNlIFVS
ST0iI19mYTgwNGYzNC1hZDg3LTQwNTYtYTQxMi03NzM4MTcxYzU0YzMiPjxkczpUcmFuc2Zvcm1z
PjxkczpUcmFuc2Zvcm0gQWxnb3JpdGhtPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwLzA5L3htbGRz
aWcjZW52ZWxvcGVkLXNpZ25hdHVyZSIvPjxkczpUcmFuc2Zvcm0gQWxnb3JpdGhtPSJodHRwOi8v
d3d3LnczLm9yZy8yMDAxLzEwL3htbC1leGMtYzE0biMiLz48L2RzOlRyYW5zZm9ybXM+PGRzOkRp
Z2VzdE1ldGhvZCBBbGdvcml0aG09Imh0dHA6Ly93d3cudzMub3JnLzIwMDEvMDQveG1sZW5jI3No
YTI1NiIvPjxkczpEaWdlc3RWYWx1ZT5sMmx5Q3JTb3draHFuVzhRcGxYNDdiU2lzWDQvV2JjYjIy
d3FaT1c3TGY0PTwvZHM6RGlnZXN0VmFsdWU+PC9kczpSZWZlcmVuY2U+PGRzOlJlZmVyZW5jZSBV
Ukk9IiNfMjQ0ZjBjOGUtNjdmOS00MmUzLTkwYTgtOTM0YTE3ZWM0YTZlIj48ZHM6VHJhbnNmb3Jt
cz48ZHM6VHJhbnNmb3JtIEFsZ29yaXRobT0iaHR0cDovL3d3dy53My5vcmcvMjAwMS8xMC94bWwt
ZXhjLWMxNG4jIi8+PC9kczpUcmFuc2Zvcm1zPjxkczpEaWdlc3RNZXRob2QgQWxnb3JpdGhtPSJo
dHRwOi8vd3d3LnczLm9yZy8yMDAxLzA0L3htbGVuYyNzaGEyNTYiLz48ZHM6RGlnZXN0VmFsdWU+
cmZneDFERFh3Njl2bHo4ZHJ6Z3gwUEpqaWtYZVU1WkhDcTVTcFdSSVFXRT08L2RzOkRpZ2VzdFZh
bHVlPjwvZHM6UmVmZXJlbmNlPjwvZHM6U2lnbmVkSW5mbz48ZHM6U2lnbmF0dXJlVmFsdWUgSWQ9
Il9mZTdhZjY1Ni1jNTdiLTQwMGMtYmFhMS01M2EwZjNjOWY3Y2MiPlljc3BScEpPbUF0U0MySlJE
eExMSVdYT1V2aGtwa0hhK0Rpa240R1BYQ2RnSitPU05aN2pDV0FkNFJoRDYyTW5haXpmaXR6cTcx
MkkKcm41ZHJhbUIxbjNjdjZoM3UyYVQ5Y0UwVmFLbmpLdVVWczM5aDFHU2tncXcwZTUwR1NtZ3lF
ZDJGNjEvRGUxcytsWURQeGZJVWpNYgo0YlBoOWNJZ1dpYWRSUGd2ZVM1Ty9xanpaTXpFSHc4RThU
ZjFEVVNKTFhkdGkwYmVXM0svdFY5UkJGWTNoZjdRWlkwLzVKcEVIRjljCnRBQ3F4S2R3RnJFUkZu
ZzV2TW1yNUlKNHdFNVR3ZW9Ra3NRaURtSXk0L25JaVJmSktsNTkvMTVVOWgvdDdoZUwwMy9TU1Nz
TEhzencKVU5wRHdSZlRKRzBTNnlVUHF3VWlMUGFSaGROM0pVT2NTRzZaa3c9PTwvZHM6U2lnbmF0
dXJlVmFsdWU+PGRzOktleUluZm8gSWQ9Il8yNDRmMGM4ZS02N2Y5LTQyZTMtOTBhOC05MzRhMTdl
YzRhNmUiPjxkczpYNTA5RGF0YT48ZHM6WDUwOUNlcnRpZmljYXRlPk1JSUZMekNDQkJlZ0F3SUJB
Z0lnTHJBYmV2b2FlNTJ5M2Y2QzJ0QjBTbjNwN1hKbTBUMDJGb2d4S0NmTmhYb3dEUVlKS29aSWh2
Y04KQVFFTEJRQXdmREVMTUFrR0ExVUVCaE1DVlZNeFBEQTZCZ05WQkFvVE0wbHVkR1Z5Ym1WMElF
TnZjbkJ2Y21GMGFXOXVJR1p2Y2lCQgpjM05wWjI1bFpDQk9ZVzFsY3lCaGJtUWdUblZ0WW1WeWN6
RXZNQzBHQTFVRUF4TW1TVU5CVGs0Z1ZISmhaR1Z0WVhKcklFTnNaV0Z5CmFXNW5hRzkxYzJVZ1VH
bHNiM1FnUTBFd0hoY05NVE13TmpJMk1EQXdNREF3V2hjTk1UZ3dOakkxTWpNMU9UVTVXakNCanpF
TE1Ba0cKQTFVRUJoTUNRa1V4SURBZUJnTlZCQWdURjBKeWRYTnpaV3h6TFVOaGNHbDBZV3dnVW1W
bmFXOXVNUkV3RHdZRFZRUUhFd2hDY25WegpjMlZzY3pFUk1BOEdBMVVFQ2hNSVJHVnNiMmwwZEdV
eE9EQTJCZ05WQkFNVEwwbERRVTVPSUZSTlEwZ2dRWFYwYUc5eWFYcGxaQ0JVCmNtRmtaVzFoY21z
Z1VHbHNiM1FnVm1Gc2FXUmhkRzl5TUlJQklqQU5CZ2txaGtpRzl3MEJBUUVGQUFPQ0FROEFNSUlC
Q2dLQ0FRRUEKeGxwM0twWUhYM1d5QXNGaFNrM0x3V2ZuR2x4blVERnFGWkEzVW91TVlqL1hpZ2JN
a05lRVhJamxrUk9LVDRPUEdmUngvTEF5UmxRUQpqQ012NHFoYmtjWDFwN2FyNjNmbHE0U1pOVmNs
MTVsN2gwdVQ1OEZ6U2ZubHowdTVya0hmSkltRDQzK21hUC84Z3YzNkZSMjdqVzhSCjl3WTRoaytX
czRJQjBpRlNkOFNYdjFLcjh3L0ptTVFTRGtpdUcrUmZJaXVid1EvZnk3RWtqNVFXaFBadyttTXhO
S25IVUx5M3hZejIKTHdWZmZ0andVdWVhY3ZxTlJDa01YbENsT0FEcWZUOG9TWm9lRFhlaEh2bFBz
TENlbUdCb1RLdXJza0lTNjlGMHlQRUg1Z3plMEgrZgo4RlJPc0lvS1NzVlEzNEI0Uy9qb0U2N25w
c0pQVGRLc05QSlR5UUlEQVFBQm80SUJoekNDQVlNd0RBWURWUjBUQVFIL0JBSXdBREFkCkJnTlZI
UTRFRmdRVW9GcFk3NnA1eW9ORFJHdFFwelZ1UjgxVVdRMHdnY1lHQTFVZEl3U0J2akNCdTRBVXc2
MCtwdFlSQUVXQVhEcFgKU29wdDNERU5ubkdoZ1lDa2ZqQjhNUXN3Q1FZRFZRUUdFd0pWVXpFOE1E
b0dBMVVFQ2hNelNXNTBaWEp1WlhRZ1EyOXljRzl5WVhScApiMjRnWm05eUlFRnpjMmxuYm1Wa0lF
NWhiV1Z6SUdGdVpDQk9kVzFpWlhKek1TOHdMUVlEVlFRREV5WkpRMEZPVGlCVWNtRmtaVzFoCmNt
c2dRMnhsWVhKcGJtZG9iM1Z6WlNCUWFXeHZkQ0JEUVlJZ0xyQWJldm9hZTUyeTNmNkMydEIwU24z
cDdYSm0wVDAyRm9neEtDZk4KaFhrd0RnWURWUjBQQVFIL0JBUURBZ2VBTURRR0ExVWRId1F0TUNz
d0thQW5vQ1dHSTJoMGRIQTZMeTlqY213dWFXTmhibTR1YjNKbgpMM1J0WTJoZmNHbHNiM1F1WTNK
c01FVUdBMVVkSUFRK01Ed3dPZ1lES2dNRU1ETXdNUVlJS3dZQkJRVUhBZ0VXSldoMGRIQTZMeTkz
CmQzY3VhV05oYm00dWIzSm5MM0JwYkc5MFgzSmxjRzl6YVhSdmNua3dEUVlKS29aSWh2Y05BUUVM
QlFBRGdnRUJBSWVEWVlKcjYwVzMKeTlRcyszelJWSTlrZWtLb201dmtIT2FsQjN3SGFaSWFBRllw
STk4dFkwYVZOOWFHT04wdjZXUUYrbnZ6MUtSWlFiQXowMUJYdGFSSgo0bVBrYXJoaHVMbjlOa0J4
cDhIUjVxY2MrS0g3Z3Y2ci9jMGlHM2JDTkorUVNyN1FmKzVNbE1vNnpMNVVkZFUvVDJqaWJNWENq
L2YyCjFRdzN4OVFnb3lYTEZKOW96YUxnUTlSTWtMbE9temtDQWlYTjVBYjQzYUo5ZjdOMmdFMk5u
UmpOS21tQzlBQlEwVFJ3RUtWTGhWbDEKVUdxQ0hKM0FsQlhXSVhONXNqUFFjRC8rbkhlRVhNeFl2
bEF5cXhYb0QzTVd0UVZqN2oyb3FsYWtPQk1nRzgrcTJxWWxtQnRzNEZOaQp3NzQ4SWw1ODZIS0JS
cXhIdFpkUktXMlZxYVE9PC9kczpYNTA5Q2VydGlmaWNhdGU+PC9kczpYNTA5RGF0YT48L2RzOktl
eUluZm8+PC9kczpTaWduYXR1cmU+PC9zbWQ6c2lnbmVkTWFyaz4=
-----END ENCODED SMD-----

View file

@ -0,0 +1,107 @@
Marks: Test & Validate
smdID: 0000001761376042759136-65535
U-labels: test---validate, test--validate, test-and-validate, test-andvalidate, test-validate, testand-validate, testandvalidate, testvalidate
notBefore: 2013-08-09 12:05:59
notAfter: 2017-07-24 00:00:00
-----BEGIN ENCODED SMD-----
PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHNtZDpzaWduZWRNYXJrIHht
bG5zOnNtZD0idXJuOmlldGY6cGFyYW1zOnhtbDpuczpzaWduZWRNYXJrLTEuMCIgaWQ9Il8zOGFj
NTg2ZC05OTg5LTQ4MTctYjcwOC1kOGU4MzQ0NzZkOTUiPgogIDxzbWQ6aWQ+MDAwMDAwMTc2MTM3
NjA0Mjc1OTEzNi02NTUzNTwvc21kOmlkPgogIDxzbWQ6aXNzdWVySW5mbyBpc3N1ZXJJRD0iNjU1
MzUiPgogICAgPHNtZDpvcmc+SUNBTk4gVE1DSCBURVNUSU5HIFRNVjwvc21kOm9yZz4KICAgIDxz
bWQ6ZW1haWw+bm90YXZhaWxhYmxlQGV4YW1wbGUuY29tPC9zbWQ6ZW1haWw+CiAgICA8c21kOnVy
bD5odHRwOi8vd3d3LmV4YW1wbGUuY29tPC9zbWQ6dXJsPgogICAgPHNtZDp2b2ljZT4rMzIuMDAw
MDAwPC9zbWQ6dm9pY2U+CiAgPC9zbWQ6aXNzdWVySW5mbz4KICA8c21kOm5vdEJlZm9yZT4yMDEz
LTA4LTA5VDEwOjA1OjU5LjEzNlo8L3NtZDpub3RCZWZvcmU+CiAgPHNtZDpub3RBZnRlcj4yMDE3
LTA3LTIzVDIyOjAwOjAwLjAwMFo8L3NtZDpub3RBZnRlcj4KICA8bWFyazptYXJrIHhtbG5zOm1h
cms9InVybjppZXRmOnBhcmFtczp4bWw6bnM6bWFyay0xLjAiPgogICAgPG1hcms6Y291cnQ+CiAg
ICAgIDxtYXJrOmlkPjAwMDUyMDEzNzM0NjkxNjkxMzczNDY5MTY5LTY1NTM1PC9tYXJrOmlkPgog
ICAgICA8bWFyazptYXJrTmFtZT5UZXN0ICZhbXA7IFZhbGlkYXRlPC9tYXJrOm1hcmtOYW1lPgog
ICAgICA8bWFyazpob2xkZXIgZW50aXRsZW1lbnQ9Im93bmVyIj4KICAgICAgICA8bWFyazpvcmc+
QWcgY29ycG9yYXRpb248L21hcms6b3JnPgogICAgICAgIDxtYXJrOmFkZHI+CiAgICAgICAgICA8
bWFyazpzdHJlZXQ+MTMwNSBCcmlnaHQgQXZlbnVlPC9tYXJrOnN0cmVldD4KICAgICAgICAgIDxt
YXJrOmNpdHk+QXJjYWRpYTwvbWFyazpjaXR5PgogICAgICAgICAgPG1hcms6c3A+Q0E8L21hcms6
c3A+CiAgICAgICAgICA8bWFyazpwYz45MDAyODwvbWFyazpwYz4KICAgICAgICAgIDxtYXJrOmNj
PlVTPC9tYXJrOmNjPgogICAgICAgIDwvbWFyazphZGRyPgogICAgICA8L21hcms6aG9sZGVyPgog
ICAgICA8bWFyazpjb250YWN0IHR5cGU9ImFnZW50Ij4KICAgICAgICA8bWFyazpuYW1lPlRvbnkg
SG9sbGFuZDwvbWFyazpuYW1lPgogICAgICAgIDxtYXJrOm9yZz5BZyBjb3Jwb3JhdGlvbjwvbWFy
azpvcmc+CiAgICAgICAgPG1hcms6YWRkcj4KICAgICAgICAgIDxtYXJrOnN0cmVldD4xMzA1IEJy
aWdodCBBdmVudWU8L21hcms6c3RyZWV0PgogICAgICAgICAgPG1hcms6Y2l0eT5BcmNhZGlhPC9t
YXJrOmNpdHk+CiAgICAgICAgICA8bWFyazpzcD5DQTwvbWFyazpzcD4KICAgICAgICAgIDxtYXJr
OnBjPjkwMDI4PC9tYXJrOnBjPgogICAgICAgICAgPG1hcms6Y2M+VVM8L21hcms6Y2M+CiAgICAg
ICAgPC9tYXJrOmFkZHI+CiAgICAgICAgPG1hcms6dm9pY2U+KzEuMjAyNTU2MjMwMjwvbWFyazp2
b2ljZT4KICAgICAgICA8bWFyazpmYXg+KzEuMjAyNTU2MjMwMTwvbWFyazpmYXg+CiAgICAgICAg
PG1hcms6ZW1haWw+aW5mb0BhZ2NvcnBvcmF0aW9uLmNvbTwvbWFyazplbWFpbD4KICAgICAgPC9t
YXJrOmNvbnRhY3Q+CiAgICAgIDxtYXJrOmxhYmVsPnRlc3RhbmR2YWxpZGF0ZTwvbWFyazpsYWJl
bD4KICAgICAgPG1hcms6bGFiZWw+dGVzdC0tLXZhbGlkYXRlPC9tYXJrOmxhYmVsPgogICAgICA8
bWFyazpsYWJlbD50ZXN0YW5kLXZhbGlkYXRlPC9tYXJrOmxhYmVsPgogICAgICA8bWFyazpsYWJl
bD50ZXN0LXZhbGlkYXRlPC9tYXJrOmxhYmVsPgogICAgICA8bWFyazpsYWJlbD50ZXN0LWFuZHZh
bGlkYXRlPC9tYXJrOmxhYmVsPgogICAgICA8bWFyazpsYWJlbD50ZXN0LS12YWxpZGF0ZTwvbWFy
azpsYWJlbD4KICAgICAgPG1hcms6bGFiZWw+dGVzdHZhbGlkYXRlPC9tYXJrOmxhYmVsPgogICAg
ICA8bWFyazpsYWJlbD50ZXN0LWFuZC12YWxpZGF0ZTwvbWFyazpsYWJlbD4KICAgICAgPG1hcms6
Z29vZHNBbmRTZXJ2aWNlcz5NdXNpY2FsIGluc3RydW1lbnRzPC9tYXJrOmdvb2RzQW5kU2Vydmlj
ZXM+CiAgICAgIDxtYXJrOnJlZk51bT4xMjM0PC9tYXJrOnJlZk51bT4KICAgICAgPG1hcms6cHJv
RGF0ZT4yMDEyLTEyLTMxVDIzOjAwOjAwLjAwMFo8L21hcms6cHJvRGF0ZT4KICAgICAgPG1hcms6
Y2M+VVM8L21hcms6Y2M+CiAgICAgIDxtYXJrOmNvdXJ0TmFtZT5Ib3ZlPC9tYXJrOmNvdXJ0TmFt
ZT4KICAgIDwvbWFyazpjb3VydD4KICA8L21hcms6bWFyaz4KPGRzOlNpZ25hdHVyZSB4bWxuczpk
cz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC8wOS94bWxkc2lnIyIgSWQ9Il9mZDBmMTM0Ni03MTM4
LTRiMGMtODRkNy0yZTdlYmY2YTExNmMiPjxkczpTaWduZWRJbmZvPjxkczpDYW5vbmljYWxpemF0
aW9uTWV0aG9kIEFsZ29yaXRobT0iaHR0cDovL3d3dy53My5vcmcvMjAwMS8xMC94bWwtZXhjLWMx
NG4jIi8+PGRzOlNpZ25hdHVyZU1ldGhvZCBBbGdvcml0aG09Imh0dHA6Ly93d3cudzMub3JnLzIw
MDEvMDQveG1sZHNpZy1tb3JlI3JzYS1zaGEyNTYiLz48ZHM6UmVmZXJlbmNlIFVSST0iI18zOGFj
NTg2ZC05OTg5LTQ4MTctYjcwOC1kOGU4MzQ0NzZkOTUiPjxkczpUcmFuc2Zvcm1zPjxkczpUcmFu
c2Zvcm0gQWxnb3JpdGhtPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwLzA5L3htbGRzaWcjZW52ZWxv
cGVkLXNpZ25hdHVyZSIvPjxkczpUcmFuc2Zvcm0gQWxnb3JpdGhtPSJodHRwOi8vd3d3LnczLm9y
Zy8yMDAxLzEwL3htbC1leGMtYzE0biMiLz48L2RzOlRyYW5zZm9ybXM+PGRzOkRpZ2VzdE1ldGhv
ZCBBbGdvcml0aG09Imh0dHA6Ly93d3cudzMub3JnLzIwMDEvMDQveG1sZW5jI3NoYTI1NiIvPjxk
czpEaWdlc3RWYWx1ZT55WDRLTWgrUDJ2OVUxNnh0eTl2ZGU5S0JTZmZFTjRHbTVVa2tLblI5cDdZ
PTwvZHM6RGlnZXN0VmFsdWU+PC9kczpSZWZlcmVuY2U+PGRzOlJlZmVyZW5jZSBVUkk9IiNfYjg5
MjI1NWItMWJjOC00MTdiLWE0NGYtZWE5OGJjMzQ5OWE0Ij48ZHM6VHJhbnNmb3Jtcz48ZHM6VHJh
bnNmb3JtIEFsZ29yaXRobT0iaHR0cDovL3d3dy53My5vcmcvMjAwMS8xMC94bWwtZXhjLWMxNG4j
Ii8+PC9kczpUcmFuc2Zvcm1zPjxkczpEaWdlc3RNZXRob2QgQWxnb3JpdGhtPSJodHRwOi8vd3d3
LnczLm9yZy8yMDAxLzA0L3htbGVuYyNzaGEyNTYiLz48ZHM6RGlnZXN0VmFsdWU+dDNuNkFBTHdi
aUhNbGRyZkpEQjNYQ3FkSlFzOEhjeU5pK1lXT3ZoV1krdz08L2RzOkRpZ2VzdFZhbHVlPjwvZHM6
UmVmZXJlbmNlPjwvZHM6U2lnbmVkSW5mbz48ZHM6U2lnbmF0dXJlVmFsdWUgSWQ9Il82OWQzMDRl
NC04NzlmLTRmNzEtYmMxMi02ZjJhZDlmOTM5OGYiPmJSVFIzTzUxM0dnTkExS2pxb0g0VXE3cUlh
N2NJaTljaXZmZmFyVmE0VVQyVEUzdzEzc2xsUDFXbkdYYjcyYUw0dXhkbDFUaTZZbFoKVnVjSC92
ZU5zUnlWZFZwSFF0eEJNTDFLU0tZbXc3ZjdPNnVsYWtrYnFrTkdYVmFZdEVsa1dBZnZFSDBsNURk
NkFZT0k2UGN5SzBCWgo2VEl3cWZhQ1luVk5DdTFpdDIzMm9EREtiWU9RNk02YnhmU3BvVFYvaTVV
dEVyak0vZWFFanp4MXFxZzlFZmxOcm1obmRtZW42Q2JYCjVrNmZ4Y1o0V2NtWkM4V0Ruc0t0VWVj
aGtmbko4L0Jwc2ppM1Foekg4YzFiL0RqTmR5UFFyOGlndXBqR2dlU0JmMHhRRUtoK3pRT2oKYTNv
MEhRWjZ1UlUvejdWN2RoNU9qUEhmV2lLc0pqRjVwc2ppRlE9PTwvZHM6U2lnbmF0dXJlVmFsdWU+
PGRzOktleUluZm8gSWQ9Il9iODkyMjU1Yi0xYmM4LTQxN2ItYTQ0Zi1lYTk4YmMzNDk5YTQiPjxk
czpYNTA5RGF0YT48ZHM6WDUwOUNlcnRpZmljYXRlPk1JSUZMekNDQkJlZ0F3SUJBZ0lnTHJBYmV2
b2FlNTJ5M2Y2QzJ0QjBTbjNwN1hKbTBUMDJGb2d4S0NmTmhYb3dEUVlKS29aSWh2Y04KQVFFTEJR
QXdmREVMTUFrR0ExVUVCaE1DVlZNeFBEQTZCZ05WQkFvVE0wbHVkR1Z5Ym1WMElFTnZjbkJ2Y21G
MGFXOXVJR1p2Y2lCQgpjM05wWjI1bFpDQk9ZVzFsY3lCaGJtUWdUblZ0WW1WeWN6RXZNQzBHQTFV
RUF4TW1TVU5CVGs0Z1ZISmhaR1Z0WVhKcklFTnNaV0Z5CmFXNW5hRzkxYzJVZ1VHbHNiM1FnUTBF
d0hoY05NVE13TmpJMk1EQXdNREF3V2hjTk1UZ3dOakkxTWpNMU9UVTVXakNCanpFTE1Ba0cKQTFV
RUJoTUNRa1V4SURBZUJnTlZCQWdURjBKeWRYTnpaV3h6TFVOaGNHbDBZV3dnVW1WbmFXOXVNUkV3
RHdZRFZRUUhFd2hDY25WegpjMlZzY3pFUk1BOEdBMVVFQ2hNSVJHVnNiMmwwZEdVeE9EQTJCZ05W
QkFNVEwwbERRVTVPSUZSTlEwZ2dRWFYwYUc5eWFYcGxaQ0JVCmNtRmtaVzFoY21zZ1VHbHNiM1Fn
Vm1Gc2FXUmhkRzl5TUlJQklqQU5CZ2txaGtpRzl3MEJBUUVGQUFPQ0FROEFNSUlCQ2dLQ0FRRUEK
eGxwM0twWUhYM1d5QXNGaFNrM0x3V2ZuR2x4blVERnFGWkEzVW91TVlqL1hpZ2JNa05lRVhJamxr
Uk9LVDRPUEdmUngvTEF5UmxRUQpqQ012NHFoYmtjWDFwN2FyNjNmbHE0U1pOVmNsMTVsN2gwdVQ1
OEZ6U2ZubHowdTVya0hmSkltRDQzK21hUC84Z3YzNkZSMjdqVzhSCjl3WTRoaytXczRJQjBpRlNk
OFNYdjFLcjh3L0ptTVFTRGtpdUcrUmZJaXVid1EvZnk3RWtqNVFXaFBadyttTXhOS25IVUx5M3hZ
ejIKTHdWZmZ0andVdWVhY3ZxTlJDa01YbENsT0FEcWZUOG9TWm9lRFhlaEh2bFBzTENlbUdCb1RL
dXJza0lTNjlGMHlQRUg1Z3plMEgrZgo4RlJPc0lvS1NzVlEzNEI0Uy9qb0U2N25wc0pQVGRLc05Q
SlR5UUlEQVFBQm80SUJoekNDQVlNd0RBWURWUjBUQVFIL0JBSXdBREFkCkJnTlZIUTRFRmdRVW9G
cFk3NnA1eW9ORFJHdFFwelZ1UjgxVVdRMHdnY1lHQTFVZEl3U0J2akNCdTRBVXc2MCtwdFlSQUVX
QVhEcFgKU29wdDNERU5ubkdoZ1lDa2ZqQjhNUXN3Q1FZRFZRUUdFd0pWVXpFOE1Eb0dBMVVFQ2hN
elNXNTBaWEp1WlhRZ1EyOXljRzl5WVhScApiMjRnWm05eUlFRnpjMmxuYm1Wa0lFNWhiV1Z6SUdG
dVpDQk9kVzFpWlhKek1TOHdMUVlEVlFRREV5WkpRMEZPVGlCVWNtRmtaVzFoCmNtc2dRMnhsWVhK
cGJtZG9iM1Z6WlNCUWFXeHZkQ0JEUVlJZ0xyQWJldm9hZTUyeTNmNkMydEIwU24zcDdYSm0wVDAy
Rm9neEtDZk4KaFhrd0RnWURWUjBQQVFIL0JBUURBZ2VBTURRR0ExVWRId1F0TUNzd0thQW5vQ1dH
STJoMGRIQTZMeTlqY213dWFXTmhibTR1YjNKbgpMM1J0WTJoZmNHbHNiM1F1WTNKc01FVUdBMVVk
SUFRK01Ed3dPZ1lES2dNRU1ETXdNUVlJS3dZQkJRVUhBZ0VXSldoMGRIQTZMeTkzCmQzY3VhV05o
Ym00dWIzSm5MM0JwYkc5MFgzSmxjRzl6YVhSdmNua3dEUVlKS29aSWh2Y05BUUVMQlFBRGdnRUJB
SWVEWVlKcjYwVzMKeTlRcyszelJWSTlrZWtLb201dmtIT2FsQjN3SGFaSWFBRllwSTk4dFkwYVZO
OWFHT04wdjZXUUYrbnZ6MUtSWlFiQXowMUJYdGFSSgo0bVBrYXJoaHVMbjlOa0J4cDhIUjVxY2Mr
S0g3Z3Y2ci9jMGlHM2JDTkorUVNyN1FmKzVNbE1vNnpMNVVkZFUvVDJqaWJNWENqL2YyCjFRdzN4
OVFnb3lYTEZKOW96YUxnUTlSTWtMbE9temtDQWlYTjVBYjQzYUo5ZjdOMmdFMk5uUmpOS21tQzlB
QlEwVFJ3RUtWTGhWbDEKVUdxQ0hKM0FsQlhXSVhONXNqUFFjRC8rbkhlRVhNeFl2bEF5cXhYb0Qz
TVd0UVZqN2oyb3FsYWtPQk1nRzgrcTJxWWxtQnRzNEZOaQp3NzQ4SWw1ODZIS0JScXhIdFpkUktX
MlZxYVE9PC9kczpYNTA5Q2VydGlmaWNhdGU+PC9kczpYNTA5RGF0YT48L2RzOktleUluZm8+PC9k
czpTaWduYXR1cmU+PC9zbWQ6c2lnbmVkTWFyaz4=
-----END ENCODED SMD-----

View file

@ -0,0 +1,109 @@
Marks: Test & Validate
smdID: 0000001751376056503931-65535
U-labels: test---validate, test--validate, test-et-validate, test-etvalidate, test-validate, testand-validate, testandvalidate, testet-validate, testetvalidate, testvalidate
notBefore: 2013-08-09 15:55:03
notAfter: 2017-07-24 00:00:00
-----BEGIN ENCODED SMD-----
PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHNtZDpzaWduZWRNYXJrIHht
bG5zOnNtZD0idXJuOmlldGY6cGFyYW1zOnhtbDpuczpzaWduZWRNYXJrLTEuMCIgaWQ9Il84Yzk0
ZjRmMS1jZTlmLTRjOTAtOTUzMS01MzE1ZDIzY2EzYmQiPgogIDxzbWQ6aWQ+MDAwMDAwMTc1MTM3
NjA1NjUwMzkzMS02NTUzNTwvc21kOmlkPgogIDxzbWQ6aXNzdWVySW5mbyBpc3N1ZXJJRD0iNjU1
MzUiPgogICAgPHNtZDpvcmc+SUNBTk4gVE1DSCBURVNUSU5HIFRNVjwvc21kOm9yZz4KICAgIDxz
bWQ6ZW1haWw+bm90YXZhaWxhYmxlQGV4YW1wbGUuY29tPC9zbWQ6ZW1haWw+CiAgICA8c21kOnVy
bD5odHRwOi8vd3d3LmV4YW1wbGUuY29tPC9zbWQ6dXJsPgogICAgPHNtZDp2b2ljZT4rMzIuMDAw
MDAwPC9zbWQ6dm9pY2U+CiAgPC9zbWQ6aXNzdWVySW5mbz4KICA8c21kOm5vdEJlZm9yZT4yMDEz
LTA4LTA5VDEzOjU1OjAzLjkzMVo8L3NtZDpub3RCZWZvcmU+CiAgPHNtZDpub3RBZnRlcj4yMDE3
LTA3LTIzVDIyOjAwOjAwLjAwMFo8L3NtZDpub3RBZnRlcj4KICA8bWFyazptYXJrIHhtbG5zOm1h
cms9InVybjppZXRmOnBhcmFtczp4bWw6bnM6bWFyay0xLjAiPgogICAgPG1hcms6dHJhZGVtYXJr
PgogICAgICA8bWFyazppZD4wMDA1MjAxMzczNDY4OTczMTM3MzQ2ODk3My02NTUzNTwvbWFyazpp
ZD4KICAgICAgPG1hcms6bWFya05hbWU+VGVzdCAmYW1wOyBWYWxpZGF0ZTwvbWFyazptYXJrTmFt
ZT4KICAgICAgPG1hcms6aG9sZGVyIGVudGl0bGVtZW50PSJvd25lciI+CiAgICAgICAgPG1hcms6
b3JnPkFnIGNvcnBvcmF0aW9uPC9tYXJrOm9yZz4KICAgICAgICA8bWFyazphZGRyPgogICAgICAg
ICAgPG1hcms6c3RyZWV0PjEzMDUgQnJpZ2h0IEF2ZW51ZTwvbWFyazpzdHJlZXQ+CiAgICAgICAg
ICA8bWFyazpjaXR5PkFyY2FkaWE8L21hcms6Y2l0eT4KICAgICAgICAgIDxtYXJrOnNwPkNBPC9t
YXJrOnNwPgogICAgICAgICAgPG1hcms6cGM+OTAwMjg8L21hcms6cGM+CiAgICAgICAgICA8bWFy
azpjYz5VUzwvbWFyazpjYz4KICAgICAgICA8L21hcms6YWRkcj4KICAgICAgPC9tYXJrOmhvbGRl
cj4KICAgICAgPG1hcms6Y29udGFjdCB0eXBlPSJhZ2VudCI+CiAgICAgICAgPG1hcms6bmFtZT5U
b255IEhvbGxhbmQ8L21hcms6bmFtZT4KICAgICAgICA8bWFyazpvcmc+QWcgY29ycG9yYXRpb248
L21hcms6b3JnPgogICAgICAgIDxtYXJrOmFkZHI+CiAgICAgICAgICA8bWFyazpzdHJlZXQ+MTMw
NSBCcmlnaHQgQXZlbnVlPC9tYXJrOnN0cmVldD4KICAgICAgICAgIDxtYXJrOmNpdHk+QXJjYWRp
YTwvbWFyazpjaXR5PgogICAgICAgICAgPG1hcms6c3A+Q0E8L21hcms6c3A+CiAgICAgICAgICA8
bWFyazpwYz45MDAyODwvbWFyazpwYz4KICAgICAgICAgIDxtYXJrOmNjPlVTPC9tYXJrOmNjPgog
ICAgICAgIDwvbWFyazphZGRyPgogICAgICAgIDxtYXJrOnZvaWNlPisxLjIwMjU1NjIzMDI8L21h
cms6dm9pY2U+CiAgICAgICAgPG1hcms6ZmF4PisxLjIwMjU1NjIzMDE8L21hcms6ZmF4PgogICAg
ICAgIDxtYXJrOmVtYWlsPmluZm9AYWdjb3Jwb3JhdGlvbi5jb208L21hcms6ZW1haWw+CiAgICAg
IDwvbWFyazpjb250YWN0PgogICAgICA8bWFyazpqdXJpc2RpY3Rpb24+VVM8L21hcms6anVyaXNk
aWN0aW9uPgogICAgICA8bWFyazpjbGFzcz4xNTwvbWFyazpjbGFzcz4KICAgICAgPG1hcms6bGFi
ZWw+dGVzdGFuZHZhbGlkYXRlPC9tYXJrOmxhYmVsPgogICAgICA8bWFyazpsYWJlbD50ZXN0LS0t
dmFsaWRhdGU8L21hcms6bGFiZWw+CiAgICAgIDxtYXJrOmxhYmVsPnRlc3RhbmQtdmFsaWRhdGU8
L21hcms6bGFiZWw+CiAgICAgIDxtYXJrOmxhYmVsPnRlc3QtZXQtdmFsaWRhdGU8L21hcms6bGFi
ZWw+CiAgICAgIDxtYXJrOmxhYmVsPnRlc3QtdmFsaWRhdGU8L21hcms6bGFiZWw+CiAgICAgIDxt
YXJrOmxhYmVsPnRlc3QtLXZhbGlkYXRlPC9tYXJrOmxhYmVsPgogICAgICA8bWFyazpsYWJlbD50
ZXN0LWV0dmFsaWRhdGU8L21hcms6bGFiZWw+CiAgICAgIDxtYXJrOmxhYmVsPnRlc3RldHZhbGlk
YXRlPC9tYXJrOmxhYmVsPgogICAgICA8bWFyazpsYWJlbD50ZXN0dmFsaWRhdGU8L21hcms6bGFi
ZWw+CiAgICAgIDxtYXJrOmxhYmVsPnRlc3RldC12YWxpZGF0ZTwvbWFyazpsYWJlbD4KICAgICAg
PG1hcms6Z29vZHNBbmRTZXJ2aWNlcz5ndWl0YXI8L21hcms6Z29vZHNBbmRTZXJ2aWNlcz4KICAg
ICAgPG1hcms6cmVnTnVtPjEyMzQ8L21hcms6cmVnTnVtPgogICAgICA8bWFyazpyZWdEYXRlPjIw
MTItMTItMzFUMjM6MDA6MDAuMDAwWjwvbWFyazpyZWdEYXRlPgogICAgPC9tYXJrOnRyYWRlbWFy
az4KICA8L21hcms6bWFyaz4KPGRzOlNpZ25hdHVyZSB4bWxuczpkcz0iaHR0cDovL3d3dy53My5v
cmcvMjAwMC8wOS94bWxkc2lnIyIgSWQ9Il9kNzE5MmM5NC02MWY2LTRhNTgtYmYwMC00NmQzMTk4
MmJmM2EiPjxkczpTaWduZWRJbmZvPjxkczpDYW5vbmljYWxpemF0aW9uTWV0aG9kIEFsZ29yaXRo
bT0iaHR0cDovL3d3dy53My5vcmcvMjAwMS8xMC94bWwtZXhjLWMxNG4jIi8+PGRzOlNpZ25hdHVy
ZU1ldGhvZCBBbGdvcml0aG09Imh0dHA6Ly93d3cudzMub3JnLzIwMDEvMDQveG1sZHNpZy1tb3Jl
I3JzYS1zaGEyNTYiLz48ZHM6UmVmZXJlbmNlIFVSST0iI18yMmNlOTgwNi04NjYwLTQ4MzItOWQy
Ny0xM2E5NjFkMWRhYjMiPjxkczpUcmFuc2Zvcm1zPjxkczpUcmFuc2Zvcm0gQWxnb3JpdGhtPSJo
dHRwOi8vd3d3LnczLm9yZy8yMDAwLzA5L3htbGRzaWcjZW52ZWxvcGVkLXNpZ25hdHVyZSIvPjxk
czpUcmFuc2Zvcm0gQWxnb3JpdGhtPSJodHRwOi8vd3d3LnczLm9yZy8yMDAxLzEwL3htbC1leGMt
YzE0biMiLz48L2RzOlRyYW5zZm9ybXM+PGRzOkRpZ2VzdE1ldGhvZCBBbGdvcml0aG09Imh0dHA6
Ly93d3cudzMub3JnLzIwMDEvMDQveG1sZW5jI3NoYTI1NiIvPjxkczpEaWdlc3RWYWx1ZT53ZFJB
eE13My9qK2JEalhxQTgzc0QvdC9YTHVmWXk5QzR1VU5JWE1RRnp3PTwvZHM6RGlnZXN0VmFsdWU+
PC9kczpSZWZlcmVuY2U+PGRzOlJlZmVyZW5jZSBVUkk9IiNfOTUwZDllZTQtM2ZiZS00ZWRjLTkw
NjktMjE4MzA2ZjgwNzJmIj48ZHM6VHJhbnNmb3Jtcz48ZHM6VHJhbnNmb3JtIEFsZ29yaXRobT0i
aHR0cDovL3d3dy53My5vcmcvMjAwMS8xMC94bWwtZXhjLWMxNG4jIi8+PC9kczpUcmFuc2Zvcm1z
PjxkczpEaWdlc3RNZXRob2QgQWxnb3JpdGhtPSJodHRwOi8vd3d3LnczLm9yZy8yMDAxLzA0L3ht
bGVuYyNzaGEyNTYiLz48ZHM6RGlnZXN0VmFsdWU+S213NFBpbmZvYVNsRlZJS0lDR2pXWStTS0RO
eHlBUDYxakJFWlQzRzh6ST08L2RzOkRpZ2VzdFZhbHVlPjwvZHM6UmVmZXJlbmNlPjwvZHM6U2ln
bmVkSW5mbz48ZHM6U2lnbmF0dXJlVmFsdWUgSWQ9Il9lMDg5M2QwZS1kOGIxLTRlOWYtODgzOC05
MjY4ZmNjYjQwMTIiPnA2WG9KcklFcWxRMHcvR3h4RFJSQktBdFhyTHR5dm1DTDN4UU9NenFvSTM3
dEVLc2lWTGNBRXNxcTI0RTNQa1JCekk1RGZhbW10WDEKWjJPS0lwNEN4T2lWSjBMY1hrcVVseEFv
eitJVS9vRXVranJ4ZTl4cHlqdnFOcU53THdrVTdVenU4Yy9BbW5Ia3E0a2tiMldXYVJ4Swozcmpj
RHoxV1RpRVZJakw4V2RWQnBUbjRPczZHcWZ6MlZJVnZ1eWVHSmVKZnZBcjBsQUQxUnp5RENET3c5
dmRNOUM5ZitNM2RGTFQ1CkZvaStDU1lHRTdNMjR5K2JsZTZxMUtMOEw5Rjl4SFMxWkM0cWdBYmps
bksyRk9nQ3BodTdFdG5pejJleFJZTUwwUlFRanRweHIxTjEKZlYxM0UyTCtRMzZkbnF4TXp1UlJU
SWViQkpZek95Uk5QTUdWekE9PTwvZHM6U2lnbmF0dXJlVmFsdWU+PGRzOktleUluZm8gSWQ9Il85
NTBkOWVlNC0zZmJlLTRlZGMtOTA2OS0yMTgzMDZmODA3MmYiPjxkczpYNTA5RGF0YT48ZHM6WDUw
OUNlcnRpZmljYXRlPk1JSUZMekNDQkJlZ0F3SUJBZ0lnTHJBYmV2b2FlNTJ5M2Y2QzJ0QjBTbjNw
N1hKbTBUMDJGb2d4S0NmTmhYb3dEUVlKS29aSWh2Y04KQVFFTEJRQXdmREVMTUFrR0ExVUVCaE1D
VlZNeFBEQTZCZ05WQkFvVE0wbHVkR1Z5Ym1WMElFTnZjbkJ2Y21GMGFXOXVJR1p2Y2lCQgpjM05w
WjI1bFpDQk9ZVzFsY3lCaGJtUWdUblZ0WW1WeWN6RXZNQzBHQTFVRUF4TW1TVU5CVGs0Z1ZISmha
R1Z0WVhKcklFTnNaV0Z5CmFXNW5hRzkxYzJVZ1VHbHNiM1FnUTBFd0hoY05NVE13TmpJMk1EQXdN
REF3V2hjTk1UZ3dOakkxTWpNMU9UVTVXakNCanpFTE1Ba0cKQTFVRUJoTUNRa1V4SURBZUJnTlZC
QWdURjBKeWRYTnpaV3h6TFVOaGNHbDBZV3dnVW1WbmFXOXVNUkV3RHdZRFZRUUhFd2hDY25Wegpj
MlZzY3pFUk1BOEdBMVVFQ2hNSVJHVnNiMmwwZEdVeE9EQTJCZ05WQkFNVEwwbERRVTVPSUZSTlEw
Z2dRWFYwYUc5eWFYcGxaQ0JVCmNtRmtaVzFoY21zZ1VHbHNiM1FnVm1Gc2FXUmhkRzl5TUlJQklq
QU5CZ2txaGtpRzl3MEJBUUVGQUFPQ0FROEFNSUlCQ2dLQ0FRRUEKeGxwM0twWUhYM1d5QXNGaFNr
M0x3V2ZuR2x4blVERnFGWkEzVW91TVlqL1hpZ2JNa05lRVhJamxrUk9LVDRPUEdmUngvTEF5UmxR
UQpqQ012NHFoYmtjWDFwN2FyNjNmbHE0U1pOVmNsMTVsN2gwdVQ1OEZ6U2ZubHowdTVya0hmSklt
RDQzK21hUC84Z3YzNkZSMjdqVzhSCjl3WTRoaytXczRJQjBpRlNkOFNYdjFLcjh3L0ptTVFTRGtp
dUcrUmZJaXVid1EvZnk3RWtqNVFXaFBadyttTXhOS25IVUx5M3hZejIKTHdWZmZ0andVdWVhY3Zx
TlJDa01YbENsT0FEcWZUOG9TWm9lRFhlaEh2bFBzTENlbUdCb1RLdXJza0lTNjlGMHlQRUg1Z3pl
MEgrZgo4RlJPc0lvS1NzVlEzNEI0Uy9qb0U2N25wc0pQVGRLc05QSlR5UUlEQVFBQm80SUJoekND
QVlNd0RBWURWUjBUQVFIL0JBSXdBREFkCkJnTlZIUTRFRmdRVW9GcFk3NnA1eW9ORFJHdFFwelZ1
UjgxVVdRMHdnY1lHQTFVZEl3U0J2akNCdTRBVXc2MCtwdFlSQUVXQVhEcFgKU29wdDNERU5ubkdo
Z1lDa2ZqQjhNUXN3Q1FZRFZRUUdFd0pWVXpFOE1Eb0dBMVVFQ2hNelNXNTBaWEp1WlhRZ1EyOXlj
Rzl5WVhScApiMjRnWm05eUlFRnpjMmxuYm1Wa0lFNWhiV1Z6SUdGdVpDQk9kVzFpWlhKek1TOHdM
UVlEVlFRREV5WkpRMEZPVGlCVWNtRmtaVzFoCmNtc2dRMnhsWVhKcGJtZG9iM1Z6WlNCUWFXeHZk
Q0JEUVlJZ0xyQWJldm9hZTUyeTNmNkMydEIwU24zcDdYSm0wVDAyRm9neEtDZk4KaFhrd0RnWURW
UjBQQVFIL0JBUURBZ2VBTURRR0ExVWRId1F0TUNzd0thQW5vQ1dHSTJoMGRIQTZMeTlqY213dWFX
TmhibTR1YjNKbgpMM1J0WTJoZmNHbHNiM1F1WTNKc01FVUdBMVVkSUFRK01Ed3dPZ1lES2dNRU1E
TXdNUVlJS3dZQkJRVUhBZ0VXSldoMGRIQTZMeTkzCmQzY3VhV05oYm00dWIzSm5MM0JwYkc5MFgz
SmxjRzl6YVhSdmNua3dEUVlKS29aSWh2Y05BUUVMQlFBRGdnRUJBSWVEWVlKcjYwVzMKeTlRcysz
elJWSTlrZWtLb201dmtIT2FsQjN3SGFaSWFBRllwSTk4dFkwYVZOOWFHT04wdjZXUUYrbnZ6MUtS
WlFiQXowMUJYdGFSSgo0bVBrYXJoaHVMbjlOa0J4cDhIUjVxY2MrS0g3Z3Y2ci9jMGlHM2JDTkor
UVNyN1FmKzVNbE1vNnpMNVVkZFUvVDJqaWJNWENqL2YyCjFRdzN4OVFnb3lYTEZKOW96YUxnUTlS
TWtMbE9temtDQWlYTjVBYjQzYUo5ZjdOMmdFMk5uUmpOS21tQzlBQlEwVFJ3RUtWTGhWbDEKVUdx
Q0hKM0FsQlhXSVhONXNqUFFjRC8rbkhlRVhNeFl2bEF5cXhYb0QzTVd0UVZqN2oyb3FsYWtPQk1n
RzgrcTJxWWxtQnRzNEZOaQp3NzQ4SWw1ODZIS0JScXhIdFpkUktXMlZxYVE9PC9kczpYNTA5Q2Vy
dGlmaWNhdGU+PC9kczpYNTA5RGF0YT48L2RzOktleUluZm8+PC9kczpTaWduYXR1cmU+PC9zbWQ6
c2lnbmVkTWFyaz4K
-----END ENCODED SMD-----

Some files were not shown because too many files have changed in this diff Show more