mirror of
https://github.com/google/nomulus.git
synced 2025-04-30 12:07:51 +02:00
Validate potentially-invalid domain names when (un)locking domains (#698)
* Validate potentially-invalid domain names when (un)locking domains
This commit is contained in:
parent
11eeda4233
commit
d10aea2ff1
2 changed files with 12 additions and 0 deletions
|
@ -30,6 +30,7 @@ import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.flogger.FluentLogger;
|
import com.google.common.flogger.FluentLogger;
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import google.registry.config.RegistryConfig.Config;
|
import google.registry.config.RegistryConfig.Config;
|
||||||
|
import google.registry.flows.domain.DomainFlowUtils;
|
||||||
import google.registry.model.registrar.Registrar;
|
import google.registry.model.registrar.Registrar;
|
||||||
import google.registry.model.registrar.RegistrarContact;
|
import google.registry.model.registrar.RegistrarContact;
|
||||||
import google.registry.request.Action;
|
import google.registry.request.Action;
|
||||||
|
@ -118,6 +119,7 @@ public class RegistryLockPostAction implements Runnable, JsonActionRunner.JsonAc
|
||||||
String registrarId = postInput.registrarId;
|
String registrarId = postInput.registrarId;
|
||||||
checkArgument(!Strings.isNullOrEmpty(registrarId), "Missing key for registrarId");
|
checkArgument(!Strings.isNullOrEmpty(registrarId), "Missing key for registrarId");
|
||||||
checkArgument(!Strings.isNullOrEmpty(postInput.domainName), "Missing key for domainName");
|
checkArgument(!Strings.isNullOrEmpty(postInput.domainName), "Missing key for domainName");
|
||||||
|
DomainFlowUtils.validateDomainName(postInput.domainName);
|
||||||
checkNotNull(postInput.isLock, "Missing key for isLock");
|
checkNotNull(postInput.isLock, "Missing key for isLock");
|
||||||
UserAuthInfo userAuthInfo =
|
UserAuthInfo userAuthInfo =
|
||||||
authResult
|
authResult
|
||||||
|
|
|
@ -280,6 +280,16 @@ public final class RegistryLockPostActionTest {
|
||||||
assertFailureWithMessage(response, "Missing key for domainName");
|
assertFailureWithMessage(response, "Missing key for domainName");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testFailure_nonPunycodeDomainName() {
|
||||||
|
Map<String, ?> response = action.handleJsonRequest(ImmutableMap.of(
|
||||||
|
"isLock", true,
|
||||||
|
"registrarId", "TheRegistrar",
|
||||||
|
"domainName", "example.みんな",
|
||||||
|
"password", "hi"));
|
||||||
|
assertFailureWithMessage(response, "Domain names can only contain a-z, 0-9, '.' and '-'");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_noLockParam() {
|
public void testFailure_noLockParam() {
|
||||||
Map<String, ?> response =
|
Map<String, ?> response =
|
||||||
|
|
Loading…
Add table
Reference in a new issue