mirror of
https://github.com/google/nomulus.git
synced 2025-07-14 06:55:20 +02:00
Centralize RDAP test initialization and login
All RDAP actions inherit from a common RdapActionBase class. All RDAP search actions inherit from a comman RdapSearchActionBase class, which inherits from RdapActionBase Each of the base classes has @Before initialization needed for the tests, as well as utility functions (such as login and logout). Currently, these were copied in all test classes. Instead, we created a similar test inheritance tree to centralize the initialization and place common utility functions. This way, the @Before of every test only needs to initialize the variables new to the specific action, making the code somewhat clearer. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=217856844
This commit is contained in:
parent
b254269d2f
commit
3a3b0b738a
45 changed files with 456 additions and 758 deletions
|
@ -49,6 +49,7 @@ import google.registry.request.Response;
|
|||
import google.registry.request.auth.AuthResult;
|
||||
import google.registry.request.auth.UserAuthInfo;
|
||||
import google.registry.ui.server.registrar.AuthenticatedRegistrarAccessor;
|
||||
import google.registry.util.Clock;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
|
@ -87,6 +88,7 @@ public abstract class RdapActionBase implements Runnable {
|
|||
}
|
||||
|
||||
@Inject Response response;
|
||||
@Inject Clock clock;
|
||||
@Inject @RequestMethod Action.Method requestMethod;
|
||||
@Inject @RequestPath String requestPath;
|
||||
@Inject @FullServletPath String fullServletPath;
|
||||
|
|
|
@ -29,7 +29,6 @@ import google.registry.request.Action;
|
|||
import google.registry.request.HttpException.BadRequestException;
|
||||
import google.registry.request.HttpException.NotFoundException;
|
||||
import google.registry.request.auth.Auth;
|
||||
import google.registry.util.Clock;
|
||||
import javax.inject.Inject;
|
||||
import org.joda.time.DateTime;
|
||||
|
||||
|
@ -44,8 +43,7 @@ public class RdapDomainAction extends RdapActionBase {
|
|||
|
||||
public static final String PATH = "/rdap/domain/";
|
||||
|
||||
@Inject Clock clock;
|
||||
@Inject RdapDomainAction() {}
|
||||
@Inject public RdapDomainAction() {}
|
||||
|
||||
@Override
|
||||
public String getHumanReadableObjectTypeName() {
|
||||
|
|
|
@ -45,7 +45,6 @@ import google.registry.request.HttpException.NotFoundException;
|
|||
import google.registry.request.HttpException.UnprocessableEntityException;
|
||||
import google.registry.request.Parameter;
|
||||
import google.registry.request.auth.Auth;
|
||||
import google.registry.util.Clock;
|
||||
import google.registry.util.Idn;
|
||||
import google.registry.util.NonFinalForTesting;
|
||||
import java.net.InetAddress;
|
||||
|
@ -83,11 +82,10 @@ public class RdapDomainSearchAction extends RdapSearchActionBase {
|
|||
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
|
||||
@Inject Clock clock;
|
||||
@Inject @Parameter("name") Optional<String> nameParam;
|
||||
@Inject @Parameter("nsLdhName") Optional<String> nsLdhNameParam;
|
||||
@Inject @Parameter("nsIp") Optional<String> nsIpParam;
|
||||
@Inject RdapDomainSearchAction() {}
|
||||
@Inject public RdapDomainSearchAction() {}
|
||||
|
||||
@Override
|
||||
public String getHumanReadableObjectTypeName() {
|
||||
|
|
|
@ -31,7 +31,6 @@ import google.registry.request.Action;
|
|||
import google.registry.request.HttpException.BadRequestException;
|
||||
import google.registry.request.HttpException.NotFoundException;
|
||||
import google.registry.request.auth.Auth;
|
||||
import google.registry.util.Clock;
|
||||
import java.util.Optional;
|
||||
import javax.inject.Inject;
|
||||
import org.joda.time.DateTime;
|
||||
|
@ -58,8 +57,7 @@ public class RdapEntityAction extends RdapActionBase {
|
|||
|
||||
private static final Pattern ROID_PATTERN = Pattern.compile("[-_.a-zA-Z0-9]+");
|
||||
|
||||
@Inject Clock clock;
|
||||
@Inject RdapEntityAction() {}
|
||||
@Inject public RdapEntityAction() {}
|
||||
|
||||
@Override
|
||||
public String getHumanReadableObjectTypeName() {
|
||||
|
|
|
@ -39,7 +39,6 @@ import google.registry.request.HttpException.NotFoundException;
|
|||
import google.registry.request.HttpException.UnprocessableEntityException;
|
||||
import google.registry.request.Parameter;
|
||||
import google.registry.request.auth.Auth;
|
||||
import google.registry.util.Clock;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
@ -84,11 +83,10 @@ public class RdapEntitySearchAction extends RdapSearchActionBase {
|
|||
|
||||
public static final String PATH = "/rdap/entities";
|
||||
|
||||
@Inject Clock clock;
|
||||
@Inject @Parameter("fn") Optional<String> fnParam;
|
||||
@Inject @Parameter("handle") Optional<String> handleParam;
|
||||
@Inject @Parameter("subtype") Optional<String> subtypeParam;
|
||||
@Inject RdapEntitySearchAction() {}
|
||||
@Inject public RdapEntitySearchAction() {}
|
||||
|
||||
private enum QueryType {
|
||||
FULL_NAME,
|
||||
|
|
|
@ -23,7 +23,6 @@ import google.registry.rdap.RdapJsonFormatter.BoilerplateType;
|
|||
import google.registry.rdap.RdapMetrics.EndpointType;
|
||||
import google.registry.request.Action;
|
||||
import google.registry.request.auth.Auth;
|
||||
import google.registry.util.Clock;
|
||||
import javax.inject.Inject;
|
||||
|
||||
/** RDAP (new WHOIS) action for help requests. */
|
||||
|
@ -37,8 +36,7 @@ public class RdapHelpAction extends RdapActionBase {
|
|||
|
||||
public static final String PATH = "/rdap/help";
|
||||
|
||||
@Inject Clock clock;
|
||||
@Inject RdapHelpAction() {}
|
||||
@Inject public RdapHelpAction() {}
|
||||
|
||||
@Override
|
||||
public String getHumanReadableObjectTypeName() {
|
||||
|
|
|
@ -29,7 +29,6 @@ import com.google.common.collect.ImmutableSet;
|
|||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Ordering;
|
||||
import com.google.common.collect.Streams;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.common.net.InetAddresses;
|
||||
import com.googlecode.objectify.Key;
|
||||
import google.registry.config.RdapNoticeDescriptor;
|
||||
|
@ -83,8 +82,6 @@ public class RdapJsonFormatter {
|
|||
@Inject @Config("rdapHelpMap") ImmutableMap<String, RdapNoticeDescriptor> rdapHelpMap;
|
||||
@Inject RdapJsonFormatter() {}
|
||||
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
|
||||
/**
|
||||
* What type of data to generate. Summary data includes only information about the object itself,
|
||||
* while full data includes associated items (e.g. for domains, full data includes the hosts,
|
||||
|
|
|
@ -29,7 +29,6 @@ import google.registry.request.Action;
|
|||
import google.registry.request.HttpException.BadRequestException;
|
||||
import google.registry.request.HttpException.NotFoundException;
|
||||
import google.registry.request.auth.Auth;
|
||||
import google.registry.util.Clock;
|
||||
import javax.inject.Inject;
|
||||
import org.joda.time.DateTime;
|
||||
|
||||
|
@ -44,8 +43,7 @@ public class RdapNameserverAction extends RdapActionBase {
|
|||
|
||||
public static final String PATH = "/rdap/nameserver/";
|
||||
|
||||
@Inject Clock clock;
|
||||
@Inject RdapNameserverAction() {}
|
||||
@Inject public RdapNameserverAction() {}
|
||||
|
||||
@Override
|
||||
public String getHumanReadableObjectTypeName() {
|
||||
|
|
|
@ -38,7 +38,6 @@ import google.registry.request.HttpException.NotFoundException;
|
|||
import google.registry.request.HttpException.UnprocessableEntityException;
|
||||
import google.registry.request.Parameter;
|
||||
import google.registry.request.auth.Auth;
|
||||
import google.registry.util.Clock;
|
||||
import google.registry.util.Idn;
|
||||
import java.net.InetAddress;
|
||||
import java.util.ArrayList;
|
||||
|
@ -66,10 +65,9 @@ public class RdapNameserverSearchAction extends RdapSearchActionBase {
|
|||
|
||||
public static final String PATH = "/rdap/nameservers";
|
||||
|
||||
@Inject Clock clock;
|
||||
@Inject @Parameter("name") Optional<String> nameParam;
|
||||
@Inject @Parameter("ip") Optional<String> ipParam;
|
||||
@Inject RdapNameserverSearchAction() {}
|
||||
@Inject public RdapNameserverSearchAction() {}
|
||||
|
||||
@Override
|
||||
public String getHumanReadableObjectTypeName() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue