1
0
mirror of https://github.com/google/nomulus synced 2025-12-23 14:25:44 +00:00

Return RDAP 404 for domain w/nonexistent TLD (#2808)

The TLD is technically valid but it doesn't exist for us -- we should
return 404 instead of 400 in these situations according to the RDAP
conformance docs
This commit is contained in:
gbrodman
2025-08-21 11:31:51 -04:00
committed by GitHub
parent 16859bb36a
commit 7e07fabf7e
4 changed files with 8 additions and 15 deletions

View File

@@ -1397,7 +1397,7 @@ public class DomainFlowUtils {
}
/** Domain name is under tld which doesn't exist. */
static class TldDoesNotExistException extends ParameterValueRangeErrorException {
public static class TldDoesNotExistException extends ParameterValueRangeErrorException {
public TldDoesNotExistException(String tld) {
super(String.format("Domain name is under tld %s which doesn't exist", tld));
}

View File

@@ -333,7 +333,6 @@ final class RdapDataStructures {
*/
@RestrictJsonNames("status[]")
enum RdapStatus implements Jsonable {
// Status values specified in RFC 9083 § 10.2.2.
VALIDATED("validated"),
RENEW_PROHIBITED("renew prohibited"),

View File

@@ -57,6 +57,9 @@ public class RdapDomainAction extends RdapActionBase {
InternetDomainName domainName;
try {
domainName = validateDomainName(pathSearchString);
} catch (DomainFlowUtils.TldDoesNotExistException e) {
// A special case where a valid domain name on a nonexistent TLD should return 404
throw new NotFoundException(pathSearchString + " not found");
} catch (EppException e) {
throw new BadRequestException(
String.format(

View File

@@ -57,12 +57,7 @@ import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
/**
* Unit tests for {@link RdapDomainAction}.
*
* <p>TODO(b/26872828): The next time we do any work on RDAP, consider adding the APNIC RDAP
* conformance checker to the unit test suite.
*/
/** Unit tests for {@link RdapDomainAction}. */
class RdapDomainActionTest extends RdapActionBaseTestCase<RdapDomainAction> {
RdapDomainActionTest() {
@@ -260,15 +255,11 @@ class RdapDomainActionTest extends RdapActionBaseTestCase<RdapDomainAction> {
}
@Test
void testUnknownDomain_returns400() {
void testUnknownDomain_returns404() {
assertAboutJson()
.that(generateActualJson("missingdomain.com"))
.isEqualTo(
generateExpectedJsonError(
"missingdomain.com is not a valid domain name: Domain name is under tld com which"
+ " doesn't exist",
400));
assertThat(response.getStatus()).isEqualTo(400);
.isEqualTo(generateExpectedJsonError("missingdomain.com not found", 404));
assertThat(response.getStatus()).isEqualTo(404);
}
@Test