mirror of
https://github.com/google/nomulus
synced 2026-02-09 14:30:33 +00:00
Canonicalize domain/host names in nomulus tool commands (#1583)
* Canonicalize domain/host names in nomulus tool commands This helps prevent some common user errors.
This commit is contained in:
@@ -37,6 +37,12 @@ class CheckDomainClaimsCommandTest extends EppToolCommandTestCase<CheckDomainCla
|
||||
eppVerifier.expectDryRun().verifySent("domain_check_claims.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_canonicalizesInput() throws Exception {
|
||||
runCommand("--client=NewRegistrar", "exaMPle.TLD");
|
||||
eppVerifier.expectDryRun().verifySent("domain_check_claims.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_multipleTlds() throws Exception {
|
||||
runCommand("--client=NewRegistrar", "example.tld", "example.tld2");
|
||||
|
||||
@@ -29,7 +29,7 @@ class CreateHostCommandTest extends EppToolCommandTestCase<CreateHostCommand> {
|
||||
createTld("tld");
|
||||
runCommandForced(
|
||||
"--client=NewRegistrar",
|
||||
"--host=example.tld",
|
||||
"--host=example.TLD",
|
||||
"--addresses=162.100.102.99,2001:0db8:85a3:0000:0000:8a2e:0370:7334,4.5.6.7");
|
||||
eppVerifier.verifySent("host_create_complete.xml");
|
||||
}
|
||||
|
||||
@@ -55,7 +55,8 @@ class EnqueuePollMessageCommandTest extends CommandTestCase<EnqueuePollMessageCo
|
||||
|
||||
@TestOfyAndSql
|
||||
void testSuccess_domainAndMessage() throws Exception {
|
||||
runCommandForced("--domain=example.tld", "--message=This domain is bad");
|
||||
// Test canonicalization to lowercase example.tld as well.
|
||||
runCommandForced("--domain=EXAMPLE.TLD", "--message=This domain is bad");
|
||||
|
||||
HistoryEntry synthetic = getOnlyHistoryEntryOfType(domain, SYNTHETIC);
|
||||
assertAboutHistoryEntries()
|
||||
|
||||
@@ -18,7 +18,7 @@ import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.model.domain.token.AllocationToken.TokenType.SINGLE_USE;
|
||||
import static google.registry.model.domain.token.AllocationToken.TokenType.UNLIMITED_USE;
|
||||
import static google.registry.testing.DatabaseHelper.assertAllocationTokens;
|
||||
import static google.registry.testing.DatabaseHelper.createTld;
|
||||
import static google.registry.testing.DatabaseHelper.createTlds;
|
||||
import static google.registry.testing.DatabaseHelper.loadAllOf;
|
||||
import static google.registry.testing.DatabaseHelper.persistResource;
|
||||
import static google.registry.util.DateTimeUtils.START_OF_TIME;
|
||||
@@ -138,16 +138,18 @@ class GenerateAllocationTokensCommandTest extends CommandTestCase<GenerateAlloca
|
||||
|
||||
@TestOfyAndSql
|
||||
void testSuccess_domainNames() throws Exception {
|
||||
createTld("tld");
|
||||
createTlds("tld", "xn--q9jyb4c");
|
||||
File domainNamesFile = tmpDir.resolve("domain_names.txt").toFile();
|
||||
Files.asCharSink(domainNamesFile, UTF_8).write("foo1.tld\nboo2.tld\nbaz9.tld\n");
|
||||
Files.asCharSink(domainNamesFile, UTF_8).write("foo1.tld\nboo2.tld\nçauçalito.みんな\n");
|
||||
runCommand("--domain_names_file", domainNamesFile.getPath());
|
||||
assertAllocationTokens(
|
||||
createToken("123456789ABCDEFG", null, "foo1.tld"),
|
||||
createToken("HJKLMNPQRSTUVWXY", null, "boo2.tld"),
|
||||
createToken("Zabcdefghijkmnop", null, "baz9.tld"));
|
||||
createToken("Zabcdefghijkmnop", null, "xn--aualito-txac.xn--q9jyb4c"));
|
||||
assertInStdout(
|
||||
"foo1.tld,123456789ABCDEFG\nboo2.tld,HJKLMNPQRSTUVWXY\nbaz9.tld,Zabcdefghijkmnop");
|
||||
"foo1.tld,123456789ABCDEFG",
|
||||
"boo2.tld,HJKLMNPQRSTUVWXY",
|
||||
"xn--aualito-txac.xn--q9jyb4c,Zabcdefghijkmnop");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
|
||||
@@ -64,6 +64,15 @@ class GetDomainCommandTest extends CommandTestCase<GetDomainCommand> {
|
||||
assertNotInStdout("LiveRef");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_canonicalizeDomainName() throws Exception {
|
||||
createTld("xn--q9jyb4c");
|
||||
persistActiveDomain("xn--aualito-txac.xn--q9jyb4c");
|
||||
runCommand("çauçalito.みんな", "--expand");
|
||||
assertInStdout("fullyQualifiedDomainName=xn--aualito-txac.xn--q9jyb4c");
|
||||
assertInStdout("contactId=contact1234");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_multipleArguments() throws Exception {
|
||||
persistActiveDomain("example.tld");
|
||||
|
||||
Reference in New Issue
Block a user