mirror of
https://github.com/google/nomulus.git
synced 2025-05-13 16:07:15 +02:00
Make host flows only accept canonicalized host names as input
This now throws errors when a non-lower-cased, non-puny-coded, or non-canonicalized host name is passed in as an input parameter. The approach we'll take is to first notify registrars which hosts we'll be renaming, then issue EPP host update commands to effect those renames as superuser, then push this code live to production. This fixes #38 on GitHub. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=138441130
This commit is contained in:
parent
cbe76e8615
commit
9aa2f3b96e
12 changed files with 215 additions and 8 deletions
|
@ -48,6 +48,9 @@ import google.registry.flows.ResourceFlowUtils.ResourceNotOwnedException;
|
|||
import google.registry.flows.ResourceFlowUtils.StatusNotClientSettableException;
|
||||
import google.registry.flows.exceptions.ResourceHasClientUpdateProhibitedException;
|
||||
import google.registry.flows.exceptions.ResourceStatusProhibitsOperationException;
|
||||
import google.registry.flows.host.HostFlowUtils.HostNameNotLowerCaseException;
|
||||
import google.registry.flows.host.HostFlowUtils.HostNameNotNormalizedException;
|
||||
import google.registry.flows.host.HostFlowUtils.HostNameNotPunyCodedException;
|
||||
import google.registry.flows.host.HostFlowUtils.HostNameTooShallowException;
|
||||
import google.registry.flows.host.HostFlowUtils.InvalidHostNameException;
|
||||
import google.registry.flows.host.HostFlowUtils.SuperordinateDomainDoesNotExistException;
|
||||
|
@ -357,6 +360,19 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
|
|||
.hasStatusValue(StatusValue.SERVER_UPDATE_PROHIBITED);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_superuserCanSpecifyInvalidExistingHostName() throws Exception {
|
||||
persistActiveHost("NS1.çiça199.tld.");
|
||||
clock.advanceOneMilli();
|
||||
setEppHostUpdateInput("NS1.çiça199.tld.", "ns1.xn--ia199-xrab.tld", null, null);
|
||||
runFlowAssertResponse(
|
||||
CommitMode.LIVE, UserPrivileges.SUPERUSER, readFile("host_update_response.xml"));
|
||||
clock.advanceOneMilli();
|
||||
assertThat(loadByForeignKey(HostResource.class, "NS1.çiça199.tld.", clock.nowUtc())).isNull();
|
||||
assertThat(loadByForeignKey(HostResource.class, "ns1.xn--ia199-xrab.tld", clock.nowUtc()))
|
||||
.isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_subordToSubord_lastTransferTimeFromPreviousSuperordinateWinsOut()
|
||||
throws Exception {
|
||||
|
@ -700,6 +716,54 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
|
|||
runFlow();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_referToNonLowerCaseHostname() throws Exception {
|
||||
persistActiveHost("ns1.EXAMPLE.tld");
|
||||
setEppHostUpdateInput("ns1.EXAMPLE.tld", "ns2.example.tld", null, null);
|
||||
thrown.expect(HostNameNotLowerCaseException.class);
|
||||
runFlow();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_renameToNonLowerCaseHostname() throws Exception {
|
||||
persistActiveHost("ns1.example.tld");
|
||||
setEppHostUpdateInput("ns1.example.tld", "ns2.EXAMPLE.tld", null, null);
|
||||
thrown.expect(HostNameNotLowerCaseException.class);
|
||||
runFlow();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_referToNonPunyCodedHostname() throws Exception {
|
||||
persistActiveHost("ns1.çauçalito.tld");
|
||||
setEppHostUpdateInput("ns1.çauçalito.tld", "ns1.sausalito.tld", null, null);
|
||||
thrown.expect(HostNameNotPunyCodedException.class, "expected ns1.xn--aualito-txac.tld");
|
||||
runFlow();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_renameToNonPunyCodedHostname() throws Exception {
|
||||
persistActiveHost("ns1.sausalito.tld");
|
||||
setEppHostUpdateInput("ns1.sausalito.tld", "ns1.çauçalito.tld", null, null);
|
||||
thrown.expect(HostNameNotPunyCodedException.class, "expected ns1.xn--aualito-txac.tld");
|
||||
runFlow();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_referToNonCanonicalHostname() throws Exception {
|
||||
persistActiveHost("ns1.example.tld.");
|
||||
setEppHostUpdateInput("ns1.example.tld.", "ns2.example.tld", null, null);
|
||||
thrown.expect(HostNameNotNormalizedException.class);
|
||||
runFlow();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_renameToNonCanonicalHostname() throws Exception {
|
||||
persistActiveHost("ns1.example.tld");
|
||||
setEppHostUpdateInput("ns1.example.tld", "ns2.example.tld.", null, null);
|
||||
thrown.expect(HostNameNotNormalizedException.class);
|
||||
runFlow();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_clientUpdateProhibited() throws Exception {
|
||||
persistResource(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue