Simplify some of the RDAP Action classes

Overriding getter methods to change values is a bit overkill when these values
are static (don't change based on internal state).

Just setting them in the base class' constructor is simpler.

Also, we can read the PATH of an Action based on the Annotation instead
returning it manually for each Action.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=246135754
This commit is contained in:
guyben 2019-05-01 08:32:29 -07:00 committed by jianglai
parent 99aeedc598
commit 90c53152bf
21 changed files with 81 additions and 204 deletions

View file

@ -18,6 +18,7 @@ import static com.google.common.base.Charsets.UTF_8;
import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.net.HttpHeaders.ACCESS_CONTROL_ALLOW_ORIGIN; import static com.google.common.net.HttpHeaders.ACCESS_CONTROL_ALLOW_ORIGIN;
import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.model.ofy.ObjectifyService.ofy;
import static google.registry.request.Actions.getPathForAction;
import static google.registry.util.DateTimeUtils.END_OF_TIME; import static google.registry.util.DateTimeUtils.END_OF_TIME;
import static google.registry.util.DomainNameUtils.canonicalizeDomainName; import static google.registry.util.DomainNameUtils.canonicalizeDomainName;
import static javax.servlet.http.HttpServletResponse.SC_BAD_REQUEST; import static javax.servlet.http.HttpServletResponse.SC_BAD_REQUEST;
@ -106,14 +107,25 @@ public abstract class RdapActionBase implements Runnable {
final RdapMetrics.RdapMetricInformation.Builder metricInformationBuilder = final RdapMetrics.RdapMetricInformation.Builder metricInformationBuilder =
RdapMetrics.RdapMetricInformation.builder(); RdapMetrics.RdapMetricInformation.builder();
/** Returns a string like "domain name" or "nameserver", used for error strings. */ private final String humanReadableObjectTypeName;
abstract String getHumanReadableObjectTypeName();
/** Returns the endpoint type used for recording metrics. */ /** Returns a string like "domain name" or "nameserver", used for error strings. */
abstract EndpointType getEndpointType(); final String getHumanReadableObjectTypeName() {
return humanReadableObjectTypeName;
}
/** The endpoint type used for recording metrics. */
private final EndpointType endpointType;
/** Returns the servlet action path; used to extract the search string from the incoming path. */ /** Returns the servlet action path; used to extract the search string from the incoming path. */
abstract String getActionPath(); final String getActionPath() {
return getPathForAction(getClass());
}
RdapActionBase(String humanReadableObjectTypeName, EndpointType endpointType) {
this.humanReadableObjectTypeName = humanReadableObjectTypeName;
this.endpointType = endpointType;
}
/** /**
* Does the actual search and returns an RDAP JSON object. * Does the actual search and returns an RDAP JSON object.
@ -135,7 +147,7 @@ public abstract class RdapActionBase implements Runnable {
metricInformationBuilder.setRegistrarSpecified(registrarParam.isPresent()); metricInformationBuilder.setRegistrarSpecified(registrarParam.isPresent());
metricInformationBuilder.setRole(getAuthorization().role()); metricInformationBuilder.setRole(getAuthorization().role());
metricInformationBuilder.setRequestMethod(requestMethod); metricInformationBuilder.setRequestMethod(requestMethod);
metricInformationBuilder.setEndpointType(getEndpointType()); metricInformationBuilder.setEndpointType(endpointType);
try { try {
// Extract what we're searching for from the request path. Some RDAP commands use trailing // Extract what we're searching for from the request path. Some RDAP commands use trailing
// data in the path itself (e.g. /rdap/domain/mydomain.com), and some use the query string // data in the path itself (e.g. /rdap/domain/mydomain.com), and some use the query string

View file

@ -32,29 +32,14 @@ import javax.inject.Inject;
*/ */
@Action( @Action(
service = Action.Service.PUBAPI, service = Action.Service.PUBAPI,
path = RdapAutnumAction.PATH, path = "/rdap/autnum/",
method = {GET, HEAD}, method = {GET, HEAD},
isPrefix = true, isPrefix = true,
auth = Auth.AUTH_PUBLIC_ANONYMOUS) auth = Auth.AUTH_PUBLIC_ANONYMOUS)
public class RdapAutnumAction extends RdapActionBase { public class RdapAutnumAction extends RdapActionBase {
public static final String PATH = "/rdap/autnum/"; @Inject RdapAutnumAction() {
super("authnum", EndpointType.AUTNUM);
@Inject RdapAutnumAction() {}
@Override
public String getHumanReadableObjectTypeName() {
return "autnum";
}
@Override
public EndpointType getEndpointType() {
return EndpointType.AUTNUM;
}
@Override
public String getActionPath() {
return PATH;
} }
@Override @Override

View file

@ -36,29 +36,14 @@ import org.joda.time.DateTime;
/** RDAP (new WHOIS) action for domain requests. */ /** RDAP (new WHOIS) action for domain requests. */
@Action( @Action(
service = Action.Service.PUBAPI, service = Action.Service.PUBAPI,
path = RdapDomainAction.PATH, path = "/rdap/domain/",
method = {GET, HEAD}, method = {GET, HEAD},
isPrefix = true, isPrefix = true,
auth = Auth.AUTH_PUBLIC) auth = Auth.AUTH_PUBLIC)
public class RdapDomainAction extends RdapActionBase { public class RdapDomainAction extends RdapActionBase {
public static final String PATH = "/rdap/domain/"; @Inject public RdapDomainAction() {
super("domain name", EndpointType.DOMAIN);
@Inject public RdapDomainAction() {}
@Override
public String getHumanReadableObjectTypeName() {
return "domain name";
}
@Override
public String getActionPath() {
return PATH;
}
@Override
public EndpointType getEndpointType() {
return EndpointType.DOMAIN;
} }
@Override @Override

View file

@ -68,13 +68,11 @@ import org.joda.time.DateTime;
*/ */
@Action( @Action(
service = Action.Service.PUBAPI, service = Action.Service.PUBAPI,
path = RdapDomainSearchAction.PATH, path = "/rdap/domains",
method = {GET, HEAD}, method = {GET, HEAD},
auth = Auth.AUTH_PUBLIC) auth = Auth.AUTH_PUBLIC)
public class RdapDomainSearchAction extends RdapSearchActionBase { public class RdapDomainSearchAction extends RdapSearchActionBase {
static final String PATH = "/rdap/domains";
static final int RESULT_SET_SIZE_SCALING_FACTOR = 30; static final int RESULT_SET_SIZE_SCALING_FACTOR = 30;
@NonFinalForTesting @NonFinalForTesting
@ -85,21 +83,8 @@ public class RdapDomainSearchAction extends RdapSearchActionBase {
@Inject @Parameter("name") Optional<String> nameParam; @Inject @Parameter("name") Optional<String> nameParam;
@Inject @Parameter("nsLdhName") Optional<String> nsLdhNameParam; @Inject @Parameter("nsLdhName") Optional<String> nsLdhNameParam;
@Inject @Parameter("nsIp") Optional<String> nsIpParam; @Inject @Parameter("nsIp") Optional<String> nsIpParam;
@Inject public RdapDomainSearchAction() {} @Inject public RdapDomainSearchAction() {
super("domain search", EndpointType.DOMAINS);
@Override
public String getHumanReadableObjectTypeName() {
return "domain search";
}
@Override
public EndpointType getEndpointType() {
return EndpointType.DOMAINS;
}
@Override
public String getActionPath() {
return PATH;
} }
/** /**

View file

@ -47,31 +47,16 @@ import org.joda.time.DateTime;
*/ */
@Action( @Action(
service = Action.Service.PUBAPI, service = Action.Service.PUBAPI,
path = RdapEntityAction.PATH, path = "/rdap/entity/",
method = {GET, HEAD}, method = {GET, HEAD},
isPrefix = true, isPrefix = true,
auth = Auth.AUTH_PUBLIC) auth = Auth.AUTH_PUBLIC)
public class RdapEntityAction extends RdapActionBase { public class RdapEntityAction extends RdapActionBase {
public static final String PATH = "/rdap/entity/";
private static final Pattern ROID_PATTERN = Pattern.compile("[-_.a-zA-Z0-9]+"); private static final Pattern ROID_PATTERN = Pattern.compile("[-_.a-zA-Z0-9]+");
@Inject public RdapEntityAction() {} @Inject public RdapEntityAction() {
super("entity", EndpointType.ENTITY);
@Override
public String getHumanReadableObjectTypeName() {
return "entity";
}
@Override
public EndpointType getEndpointType() {
return EndpointType.ENTITY;
}
@Override
public String getActionPath() {
return PATH;
} }
@Override @Override

View file

@ -76,17 +76,17 @@ import org.joda.time.DateTime;
*/ */
@Action( @Action(
service = Action.Service.PUBAPI, service = Action.Service.PUBAPI,
path = RdapEntitySearchAction.PATH, path = "/rdap/entities",
method = {GET, HEAD}, method = {GET, HEAD},
auth = Auth.AUTH_PUBLIC) auth = Auth.AUTH_PUBLIC)
public class RdapEntitySearchAction extends RdapSearchActionBase { public class RdapEntitySearchAction extends RdapSearchActionBase {
public static final String PATH = "/rdap/entities";
@Inject @Parameter("fn") Optional<String> fnParam; @Inject @Parameter("fn") Optional<String> fnParam;
@Inject @Parameter("handle") Optional<String> handleParam; @Inject @Parameter("handle") Optional<String> handleParam;
@Inject @Parameter("subtype") Optional<String> subtypeParam; @Inject @Parameter("subtype") Optional<String> subtypeParam;
@Inject public RdapEntitySearchAction() {} @Inject public RdapEntitySearchAction() {
super("entity search", EndpointType.ENTITIES);
}
private enum QueryType { private enum QueryType {
FULL_NAME, FULL_NAME,
@ -108,21 +108,6 @@ public class RdapEntitySearchAction extends RdapSearchActionBase {
private static final String CONTACT_CURSOR_PREFIX = "c:"; private static final String CONTACT_CURSOR_PREFIX = "c:";
private static final String REGISTRAR_CURSOR_PREFIX = "r:"; private static final String REGISTRAR_CURSOR_PREFIX = "r:";
@Override
public String getHumanReadableObjectTypeName() {
return "entity search";
}
@Override
public EndpointType getEndpointType() {
return EndpointType.ENTITIES;
}
@Override
public String getActionPath() {
return PATH;
}
/** Parses the parameters and calls the appropriate search function. */ /** Parses the parameters and calls the appropriate search function. */
@Override @Override
public ImmutableMap<String, Object> getJsonObjectForResource( public ImmutableMap<String, Object> getJsonObjectForResource(

View file

@ -28,29 +28,14 @@ import javax.inject.Inject;
/** RDAP (new WHOIS) action for help requests. */ /** RDAP (new WHOIS) action for help requests. */
@Action( @Action(
service = Action.Service.PUBAPI, service = Action.Service.PUBAPI,
path = RdapHelpAction.PATH, path = "/rdap/help",
method = {GET, HEAD}, method = {GET, HEAD},
isPrefix = true, isPrefix = true,
auth = Auth.AUTH_PUBLIC_ANONYMOUS) auth = Auth.AUTH_PUBLIC_ANONYMOUS)
public class RdapHelpAction extends RdapActionBase { public class RdapHelpAction extends RdapActionBase {
public static final String PATH = "/rdap/help"; @Inject public RdapHelpAction() {
super("help", EndpointType.HELP);
@Inject public RdapHelpAction() {}
@Override
public String getHumanReadableObjectTypeName() {
return "help";
}
@Override
public EndpointType getEndpointType() {
return EndpointType.HELP;
}
@Override
public String getActionPath() {
return PATH;
} }
@Override @Override

View file

@ -32,29 +32,14 @@ import javax.inject.Inject;
*/ */
@Action( @Action(
service = Action.Service.PUBAPI, service = Action.Service.PUBAPI,
path = RdapIpAction.PATH, path = "/rdap/ip/",
method = {GET, HEAD}, method = {GET, HEAD},
isPrefix = true, isPrefix = true,
auth = Auth.AUTH_PUBLIC_ANONYMOUS) auth = Auth.AUTH_PUBLIC_ANONYMOUS)
public class RdapIpAction extends RdapActionBase { public class RdapIpAction extends RdapActionBase {
public static final String PATH = "/rdap/ip/"; @Inject RdapIpAction() {
super("ip", EndpointType.IP);
@Inject RdapIpAction() {}
@Override
public String getHumanReadableObjectTypeName() {
return "ip";
}
@Override
public EndpointType getEndpointType() {
return EndpointType.IP;
}
@Override
public String getActionPath() {
return PATH;
} }
@Override @Override

View file

@ -36,29 +36,14 @@ import org.joda.time.DateTime;
/** RDAP (new WHOIS) action for nameserver requests. */ /** RDAP (new WHOIS) action for nameserver requests. */
@Action( @Action(
service = Action.Service.PUBAPI, service = Action.Service.PUBAPI,
path = RdapNameserverAction.PATH, path = "/rdap/nameserver/",
method = {GET, HEAD}, method = {GET, HEAD},
isPrefix = true, isPrefix = true,
auth = Auth.AUTH_PUBLIC_ANONYMOUS) auth = Auth.AUTH_PUBLIC_ANONYMOUS)
public class RdapNameserverAction extends RdapActionBase { public class RdapNameserverAction extends RdapActionBase {
public static final String PATH = "/rdap/nameserver/"; @Inject public RdapNameserverAction() {
super("nameserver", EndpointType.NAMESERVER);
@Inject public RdapNameserverAction() {}
@Override
public String getHumanReadableObjectTypeName() {
return "nameserver";
}
@Override
public EndpointType getEndpointType() {
return EndpointType.NAMESERVER;
}
@Override
public String getActionPath() {
return PATH;
} }
@Override @Override

View file

@ -58,7 +58,7 @@ import org.joda.time.DateTime;
*/ */
@Action( @Action(
service = Action.Service.PUBAPI, service = Action.Service.PUBAPI,
path = RdapNameserverSearchAction.PATH, path = "/rdap/nameservers",
method = {GET, HEAD}, method = {GET, HEAD},
auth = Auth.AUTH_PUBLIC_ANONYMOUS) auth = Auth.AUTH_PUBLIC_ANONYMOUS)
public class RdapNameserverSearchAction extends RdapSearchActionBase { public class RdapNameserverSearchAction extends RdapSearchActionBase {
@ -67,21 +67,8 @@ public class RdapNameserverSearchAction extends RdapSearchActionBase {
@Inject @Parameter("name") Optional<String> nameParam; @Inject @Parameter("name") Optional<String> nameParam;
@Inject @Parameter("ip") Optional<String> ipParam; @Inject @Parameter("ip") Optional<String> ipParam;
@Inject public RdapNameserverSearchAction() {} @Inject public RdapNameserverSearchAction() {
super("nameserver search", EndpointType.NAMESERVERS);
@Override
public String getHumanReadableObjectTypeName() {
return "nameserver search";
}
@Override
public EndpointType getEndpointType() {
return EndpointType.NAMESERVERS;
}
@Override
public String getActionPath() {
return PATH;
} }
private enum CursorType { private enum CursorType {

View file

@ -19,6 +19,7 @@ import static java.nio.charset.StandardCharsets.UTF_8;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableListMultimap; import com.google.common.collect.ImmutableListMultimap;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import google.registry.rdap.RdapMetrics.EndpointType;
import google.registry.request.Parameter; import google.registry.request.Parameter;
import google.registry.request.ParameterMap; import google.registry.request.ParameterMap;
import google.registry.request.RequestUrl; import google.registry.request.RequestUrl;
@ -44,6 +45,10 @@ public abstract class RdapSearchActionBase extends RdapActionBase {
protected Optional<String> cursorString; protected Optional<String> cursorString;
RdapSearchActionBase(String humanReadableObjectTypeName, EndpointType endpointType) {
super(humanReadableObjectTypeName, endpointType);
}
/** /**
* Decodes the cursor token passed in the HTTP request. * Decodes the cursor token passed in the HTTP request.
* *

View file

@ -17,6 +17,7 @@ package google.registry.rdap;
import static com.google.common.net.HttpHeaders.ACCESS_CONTROL_ALLOW_ORIGIN; import static com.google.common.net.HttpHeaders.ACCESS_CONTROL_ALLOW_ORIGIN;
import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertThat;
import static google.registry.request.Action.Method.GET; import static google.registry.request.Action.Method.GET;
import static google.registry.request.Action.Method.HEAD;
import static google.registry.testing.DatastoreHelper.createTld; import static google.registry.testing.DatastoreHelper.createTld;
import static google.registry.testing.TestDataHelper.loadFile; import static google.registry.testing.TestDataHelper.loadFile;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
@ -29,6 +30,7 @@ import google.registry.rdap.RdapMetrics.SearchType;
import google.registry.rdap.RdapMetrics.WildcardType; import google.registry.rdap.RdapMetrics.WildcardType;
import google.registry.rdap.RdapSearchResults.IncompletenessWarningType; import google.registry.rdap.RdapSearchResults.IncompletenessWarningType;
import google.registry.request.Action; import google.registry.request.Action;
import google.registry.request.auth.Auth;
import java.util.Optional; import java.util.Optional;
import org.json.simple.JSONValue; import org.json.simple.JSONValue;
import org.junit.Before; import org.junit.Before;
@ -41,29 +43,19 @@ import org.junit.runners.JUnit4;
public class RdapActionBaseTest extends RdapActionBaseTestCase<RdapActionBaseTest.RdapTestAction> { public class RdapActionBaseTest extends RdapActionBaseTestCase<RdapActionBaseTest.RdapTestAction> {
public RdapActionBaseTest() { public RdapActionBaseTest() {
super(RdapTestAction.class, RdapTestAction.PATH); super(RdapTestAction.class);
} }
/** /** Dummy RdapActionBase subclass used for testing. */
* Dummy RdapActionBase subclass used for testing. @Action(
*/ service = Action.Service.PUBAPI,
path = "/rdap/test/",
method = {GET, HEAD},
auth = Auth.AUTH_PUBLIC_ANONYMOUS)
public static class RdapTestAction extends RdapActionBase { public static class RdapTestAction extends RdapActionBase {
public static final String PATH = "/rdap/test/"; public RdapTestAction() {
super("human-readable string", EndpointType.HELP);
@Override
public String getHumanReadableObjectTypeName() {
return "human-readable string";
}
@Override
public EndpointType getEndpointType() {
return EndpointType.HELP;
}
@Override
public String getActionPath() {
return PATH;
} }
@Override @Override
@ -90,7 +82,7 @@ public class RdapActionBaseTest extends RdapActionBaseTestCase<RdapActionBaseTes
@Before @Before
public void setUp() { public void setUp() {
createTld("thing"); createTld("thing");
action.fullServletPath = "http://myserver.example.com" + RdapTestAction.PATH; action.fullServletPath = "http://myserver.example.com" + actionPath;
} }
@Test @Test
@ -188,7 +180,7 @@ public class RdapActionBaseTest extends RdapActionBaseTestCase<RdapActionBaseTes
@Test @Test
public void testUnformatted() { public void testUnformatted() {
action.requestPath = RdapTestAction.PATH + "no.thing"; action.requestPath = actionPath + "no.thing";
action.requestMethod = GET; action.requestMethod = GET;
action.run(); action.run();
assertThat(response.getPayload()) assertThat(response.getPayload())
@ -197,7 +189,7 @@ public class RdapActionBaseTest extends RdapActionBaseTestCase<RdapActionBaseTes
@Test @Test
public void testFormatted() { public void testFormatted() {
action.requestPath = RdapTestAction.PATH + "no.thing?formatOutput=true"; action.requestPath = actionPath + "no.thing?formatOutput=true";
action.requestMethod = GET; action.requestMethod = GET;
action.formatOutputParam = Optional.of(true); action.formatOutputParam = Optional.of(true);
action.run(); action.run();

View file

@ -27,6 +27,7 @@ import com.google.appengine.api.users.User;
import com.google.common.collect.ImmutableSetMultimap; import com.google.common.collect.ImmutableSetMultimap;
import google.registry.model.ofy.Ofy; import google.registry.model.ofy.Ofy;
import google.registry.request.Action; import google.registry.request.Action;
import google.registry.request.Actions;
import google.registry.request.auth.AuthLevel; import google.registry.request.auth.AuthLevel;
import google.registry.request.auth.AuthResult; import google.registry.request.auth.AuthResult;
import google.registry.request.auth.AuthenticatedRegistrarAccessor; import google.registry.request.auth.AuthenticatedRegistrarAccessor;
@ -79,9 +80,9 @@ public class RdapActionBaseTestCase<A extends RdapActionBase> {
protected final String actionPath; protected final String actionPath;
protected final Class<A> rdapActionClass; protected final Class<A> rdapActionClass;
protected RdapActionBaseTestCase(Class<A> rdapActionClass, String actionPath) { protected RdapActionBaseTestCase(Class<A> rdapActionClass) {
this.rdapActionClass = rdapActionClass; this.rdapActionClass = rdapActionClass;
this.actionPath = actionPath; this.actionPath = Actions.getPathForAction(rdapActionClass);
} }
@Before @Before

View file

@ -59,7 +59,7 @@ import org.junit.runners.JUnit4;
public class RdapDomainActionTest extends RdapActionBaseTestCase<RdapDomainAction> { public class RdapDomainActionTest extends RdapActionBaseTestCase<RdapDomainAction> {
public RdapDomainActionTest() { public RdapDomainActionTest() {
super(RdapDomainAction.class, RdapDomainAction.PATH); super(RdapDomainAction.class);
} }
@Before @Before

View file

@ -71,7 +71,7 @@ import org.junit.runners.JUnit4;
public class RdapDomainSearchActionTest extends RdapSearchActionTestCase<RdapDomainSearchAction> { public class RdapDomainSearchActionTest extends RdapSearchActionTestCase<RdapDomainSearchAction> {
public RdapDomainSearchActionTest() { public RdapDomainSearchActionTest() {
super(RdapDomainSearchAction.class, RdapDomainSearchAction.PATH); super(RdapDomainSearchAction.class);
} }
private Registrar registrar; private Registrar registrar;
@ -96,7 +96,7 @@ public class RdapDomainSearchActionTest extends RdapSearchActionTestCase<RdapDom
private Object generateActualJson( private Object generateActualJson(
RequestType requestType, String paramValue, String cursor) { RequestType requestType, String paramValue, String cursor) {
action.requestPath = RdapDomainSearchAction.PATH; action.requestPath = actionPath;
action.requestMethod = POST; action.requestMethod = POST;
String requestTypeParam = null; String requestTypeParam = null;
switch (requestType) { switch (requestType) {
@ -829,7 +829,7 @@ public class RdapDomainSearchActionTest extends RdapSearchActionTestCase<RdapDom
@Test @Test
public void testInvalidPath_rejected() { public void testInvalidPath_rejected() {
action.requestPath = RdapDomainSearchAction.PATH + "/path"; action.requestPath = actionPath + "/path";
action.run(); action.run();
assertThat(response.getStatus()).isEqualTo(400); assertThat(response.getStatus()).isEqualTo(400);
verifyErrorMetrics(SearchType.NONE, Optional.empty(), 400); verifyErrorMetrics(SearchType.NONE, Optional.empty(), 400);

View file

@ -52,7 +52,7 @@ import org.junit.runners.JUnit4;
public class RdapEntityActionTest extends RdapActionBaseTestCase<RdapEntityAction> { public class RdapEntityActionTest extends RdapActionBaseTestCase<RdapEntityAction> {
public RdapEntityActionTest() { public RdapEntityActionTest() {
super(RdapEntityAction.class, RdapEntityAction.PATH); super(RdapEntityAction.class);
} }
private Registrar registrarLol; private Registrar registrarLol;

View file

@ -58,7 +58,7 @@ import org.junit.runners.JUnit4;
public class RdapEntitySearchActionTest extends RdapSearchActionTestCase<RdapEntitySearchAction> { public class RdapEntitySearchActionTest extends RdapSearchActionTestCase<RdapEntitySearchAction> {
public RdapEntitySearchActionTest() { public RdapEntitySearchActionTest() {
super(RdapEntitySearchAction.class, RdapEntitySearchAction.PATH); super(RdapEntitySearchAction.class);
} }
private enum QueryType { private enum QueryType {
@ -418,7 +418,7 @@ public class RdapEntitySearchActionTest extends RdapSearchActionTestCase<RdapEnt
@Test @Test
public void testInvalidPath_rejected() { public void testInvalidPath_rejected() {
action.requestPath = RdapEntitySearchAction.PATH + "/path"; action.requestPath = actionPath + "/path";
action.run(); action.run();
assertThat(response.getStatus()).isEqualTo(400); assertThat(response.getStatus()).isEqualTo(400);
verifyErrorMetrics(Optional.empty(), 400); verifyErrorMetrics(Optional.empty(), 400);

View file

@ -31,7 +31,7 @@ import org.junit.Test;
public class RdapHelpActionTest extends RdapActionBaseTestCase<RdapHelpAction> { public class RdapHelpActionTest extends RdapActionBaseTestCase<RdapHelpAction> {
public RdapHelpActionTest() { public RdapHelpActionTest() {
super(RdapHelpAction.class, RdapHelpAction.PATH); super(RdapHelpAction.class);
} }
private Object generateExpectedJson(String name, String expectedOutputFile) { private Object generateExpectedJson(String name, String expectedOutputFile) {

View file

@ -45,7 +45,7 @@ import org.junit.runners.JUnit4;
public class RdapNameserverActionTest extends RdapActionBaseTestCase<RdapNameserverAction> { public class RdapNameserverActionTest extends RdapActionBaseTestCase<RdapNameserverAction> {
public RdapNameserverActionTest() { public RdapNameserverActionTest() {
super(RdapNameserverAction.class, RdapNameserverAction.PATH); super(RdapNameserverAction.class);
} }
@Before @Before

View file

@ -58,7 +58,7 @@ public class RdapNameserverSearchActionTest
extends RdapSearchActionTestCase<RdapNameserverSearchAction> { extends RdapSearchActionTestCase<RdapNameserverSearchAction> {
public RdapNameserverSearchActionTest() { public RdapNameserverSearchActionTest() {
super(RdapNameserverSearchAction.class, RdapNameserverSearchAction.PATH); super(RdapNameserverSearchAction.class);
} }
private DomainBase domainCatLol; private DomainBase domainCatLol;
@ -263,7 +263,7 @@ public class RdapNameserverSearchActionTest
@Test @Test
public void testInvalidPath_rejected() { public void testInvalidPath_rejected() {
action.requestPath = RdapDomainSearchAction.PATH + "/path"; action.requestPath = actionPath + "/path";
action.run(); action.run();
assertThat(response.getStatus()).isEqualTo(400); assertThat(response.getStatus()).isEqualTo(400);
verifyErrorMetrics(Optional.empty(), 400); verifyErrorMetrics(Optional.empty(), 400);

View file

@ -30,8 +30,8 @@ import org.junit.Before;
public class RdapSearchActionTestCase<A extends RdapSearchActionBase> public class RdapSearchActionTestCase<A extends RdapSearchActionBase>
extends RdapActionBaseTestCase<A> { extends RdapActionBaseTestCase<A> {
protected RdapSearchActionTestCase(Class<A> rdapActionClass, String path) { protected RdapSearchActionTestCase(Class<A> rdapActionClass) {
super(rdapActionClass, path); super(rdapActionClass);
} }
SearchType metricSearchType = SearchType.NONE; SearchType metricSearchType = SearchType.NONE;