mirror of
https://github.com/google/nomulus.git
synced 2025-04-30 12:07:51 +02:00
Remove InjectExtension (#1739)
It is only used to set the clock used by Ofy, and it admits itself being an ugly hack... Also applied IntelliJ suggestions on touched files.
This commit is contained in:
parent
6d66f52359
commit
6d7f4ee6c6
46 changed files with 153 additions and 605 deletions
|
@ -56,7 +56,6 @@ import google.registry.model.domain.DomainHistory.DomainHistoryId;
|
||||||
import google.registry.model.domain.GracePeriod;
|
import google.registry.model.domain.GracePeriod;
|
||||||
import google.registry.model.domain.metadata.MetadataExtension;
|
import google.registry.model.domain.metadata.MetadataExtension;
|
||||||
import google.registry.model.domain.rgp.GracePeriodStatus;
|
import google.registry.model.domain.rgp.GracePeriodStatus;
|
||||||
import google.registry.model.domain.token.AllocationToken;
|
|
||||||
import google.registry.model.domain.token.AllocationTokenExtension;
|
import google.registry.model.domain.token.AllocationTokenExtension;
|
||||||
import google.registry.model.eppcommon.AuthInfo;
|
import google.registry.model.eppcommon.AuthInfo;
|
||||||
import google.registry.model.eppinput.EppInput;
|
import google.registry.model.eppinput.EppInput;
|
||||||
|
@ -129,15 +128,12 @@ public final class DomainTransferApproveFlow implements TransactionalFlow {
|
||||||
extensionManager.validate();
|
extensionManager.validate();
|
||||||
DateTime now = tm().getTransactionTime();
|
DateTime now = tm().getTransactionTime();
|
||||||
Domain existingDomain = loadAndVerifyExistence(Domain.class, targetId, now);
|
Domain existingDomain = loadAndVerifyExistence(Domain.class, targetId, now);
|
||||||
// Currently we do not do anything with this allocation token, but just want it loaded and
|
allocationTokenFlowUtils.verifyAllocationTokenIfPresent(
|
||||||
// available in this flow in case we use it in the future
|
existingDomain,
|
||||||
Optional<AllocationToken> allocationToken =
|
Registry.get(existingDomain.getTld()),
|
||||||
allocationTokenFlowUtils.verifyAllocationTokenIfPresent(
|
registrarId,
|
||||||
existingDomain,
|
now,
|
||||||
Registry.get(existingDomain.getTld()),
|
eppInput.getSingleExtension(AllocationTokenExtension.class));
|
||||||
registrarId,
|
|
||||||
now,
|
|
||||||
eppInput.getSingleExtension(AllocationTokenExtension.class));
|
|
||||||
verifyOptionalAuthInfo(authInfo, existingDomain);
|
verifyOptionalAuthInfo(authInfo, existingDomain);
|
||||||
verifyHasPendingTransfer(existingDomain);
|
verifyHasPendingTransfer(existingDomain);
|
||||||
verifyResourceOwnership(registrarId, existingDomain);
|
verifyResourceOwnership(registrarId, existingDomain);
|
||||||
|
@ -182,9 +178,9 @@ public final class DomainTransferApproveFlow implements TransactionalFlow {
|
||||||
getOnlyElement(existingDomain.getGracePeriodsOfType(GracePeriodStatus.AUTO_RENEW), null);
|
getOnlyElement(existingDomain.getGracePeriodsOfType(GracePeriodStatus.AUTO_RENEW), null);
|
||||||
if (autorenewGrace != null) {
|
if (autorenewGrace != null) {
|
||||||
// During a normal transfer, if the domain is in the auto-renew grace period, the auto-renew
|
// During a normal transfer, if the domain is in the auto-renew grace period, the auto-renew
|
||||||
// billing event is cancelled and the gaining registrar is charged for the one year renewal.
|
// billing event is cancelled and the gaining registrar is charged for the one-year renewal.
|
||||||
// But, if the superuser extension is used to request a transfer without an additional year
|
// But, if the superuser extension is used to request a transfer without an additional year
|
||||||
// then the gaining registrar is not charged for the one year renewal and the losing registrar
|
// then the gaining registrar is not charged for the one-year renewal and the losing registrar
|
||||||
// still needs to be charged for the auto-renew.
|
// still needs to be charged for the auto-renew.
|
||||||
if (billingEvent.isPresent()) {
|
if (billingEvent.isPresent()) {
|
||||||
entitiesToSave.add(
|
entitiesToSave.add(
|
||||||
|
|
|
@ -62,7 +62,6 @@ import google.registry.model.domain.fee.FeeTransferCommandExtension;
|
||||||
import google.registry.model.domain.fee.FeeTransformResponseExtension;
|
import google.registry.model.domain.fee.FeeTransformResponseExtension;
|
||||||
import google.registry.model.domain.metadata.MetadataExtension;
|
import google.registry.model.domain.metadata.MetadataExtension;
|
||||||
import google.registry.model.domain.superuser.DomainTransferRequestSuperuserExtension;
|
import google.registry.model.domain.superuser.DomainTransferRequestSuperuserExtension;
|
||||||
import google.registry.model.domain.token.AllocationToken;
|
|
||||||
import google.registry.model.domain.token.AllocationTokenExtension;
|
import google.registry.model.domain.token.AllocationTokenExtension;
|
||||||
import google.registry.model.eppcommon.AuthInfo;
|
import google.registry.model.eppcommon.AuthInfo;
|
||||||
import google.registry.model.eppcommon.StatusValue;
|
import google.registry.model.eppcommon.StatusValue;
|
||||||
|
@ -169,15 +168,12 @@ public final class DomainTransferRequestFlow implements TransactionalFlow {
|
||||||
extensionManager.validate();
|
extensionManager.validate();
|
||||||
DateTime now = tm().getTransactionTime();
|
DateTime now = tm().getTransactionTime();
|
||||||
Domain existingDomain = loadAndVerifyExistence(Domain.class, targetId, now);
|
Domain existingDomain = loadAndVerifyExistence(Domain.class, targetId, now);
|
||||||
// Currently we do not do anything with this allocation token, but just want it loaded and
|
allocationTokenFlowUtils.verifyAllocationTokenIfPresent(
|
||||||
// available in this flow in case we use it in the future
|
existingDomain,
|
||||||
Optional<AllocationToken> allocationToken =
|
Registry.get(existingDomain.getTld()),
|
||||||
allocationTokenFlowUtils.verifyAllocationTokenIfPresent(
|
gainingClientId,
|
||||||
existingDomain,
|
now,
|
||||||
Registry.get(existingDomain.getTld()),
|
eppInput.getSingleExtension(AllocationTokenExtension.class));
|
||||||
gainingClientId,
|
|
||||||
now,
|
|
||||||
eppInput.getSingleExtension(AllocationTokenExtension.class));
|
|
||||||
Optional<DomainTransferRequestSuperuserExtension> superuserExtension =
|
Optional<DomainTransferRequestSuperuserExtension> superuserExtension =
|
||||||
eppInput.getSingleExtension(DomainTransferRequestSuperuserExtension.class);
|
eppInput.getSingleExtension(DomainTransferRequestSuperuserExtension.class);
|
||||||
Period period =
|
Period period =
|
||||||
|
@ -210,9 +206,12 @@ public final class DomainTransferRequestFlow implements TransactionalFlow {
|
||||||
.setId(domainHistoryKey.getId())
|
.setId(domainHistoryKey.getId())
|
||||||
.setOtherRegistrarId(existingDomain.getCurrentSponsorRegistrarId());
|
.setOtherRegistrarId(existingDomain.getCurrentSponsorRegistrarId());
|
||||||
DateTime automaticTransferTime =
|
DateTime automaticTransferTime =
|
||||||
superuserExtension.isPresent()
|
superuserExtension
|
||||||
? now.plusDays(superuserExtension.get().getAutomaticTransferLength())
|
.map(
|
||||||
: now.plus(registry.getAutomaticTransferLength());
|
domainTransferRequestSuperuserExtension ->
|
||||||
|
now.plusDays(
|
||||||
|
domainTransferRequestSuperuserExtension.getAutomaticTransferLength()))
|
||||||
|
.orElseGet(() -> now.plus(registry.getAutomaticTransferLength()));
|
||||||
// If the domain will be in the auto-renew grace period at the moment of transfer, the transfer
|
// If the domain will be in the auto-renew grace period at the moment of transfer, the transfer
|
||||||
// will subsume the autorenew, so we don't add the normal extra year from the transfer.
|
// will subsume the autorenew, so we don't add the normal extra year from the transfer.
|
||||||
// The gaining registrar is still billed for the extra year; the losing registrar will get a
|
// The gaining registrar is still billed for the extra year; the losing registrar will get a
|
||||||
|
@ -325,7 +324,7 @@ public final class DomainTransferRequestFlow implements TransactionalFlow {
|
||||||
*
|
*
|
||||||
* <p>Even if not required, this policy is desirable because it dramatically simplifies the logic
|
* <p>Even if not required, this policy is desirable because it dramatically simplifies the logic
|
||||||
* in transfer flows. Registrars appear to never request 2+ year transfers in practice, and they
|
* in transfer flows. Registrars appear to never request 2+ year transfers in practice, and they
|
||||||
* can always decompose an multi-year transfer into a 1-year transfer followed by a manual renewal
|
* can always decompose a multi-year transfer into a 1-year transfer followed by a manual renewal
|
||||||
* afterwards. The <a href="https://tools.ietf.org/html/rfc5731#section-3.2.4">EPP Domain RFC,
|
* afterwards. The <a href="https://tools.ietf.org/html/rfc5731#section-3.2.4">EPP Domain RFC,
|
||||||
* section 3.2.4</a> says about EPP transfer periods that "the number of units available MAY be
|
* section 3.2.4</a> says about EPP transfer periods that "the number of units available MAY be
|
||||||
* subject to limits imposed by the server" so we're just limiting the units to one.
|
* subject to limits imposed by the server" so we're just limiting the units to one.
|
||||||
|
@ -370,7 +369,7 @@ public final class DomainTransferRequestFlow implements TransactionalFlow {
|
||||||
private DomainTransferResponse createResponse(
|
private DomainTransferResponse createResponse(
|
||||||
Period period, Domain existingDomain, Domain newDomain, DateTime now) {
|
Period period, Domain existingDomain, Domain newDomain, DateTime now) {
|
||||||
// If the registration were approved this instant, this is what the new expiration would be,
|
// If the registration were approved this instant, this is what the new expiration would be,
|
||||||
// because we cap at 10 years from the moment of approval. This is different than the server
|
// because we cap at 10 years from the moment of approval. This is different from the server
|
||||||
// approval new expiration time, which is capped at 10 years from the server approve time.
|
// approval new expiration time, which is capped at 10 years from the server approve time.
|
||||||
DateTime approveNowExtendedRegistrationTime =
|
DateTime approveNowExtendedRegistrationTime =
|
||||||
computeExDateForApprovalTime(existingDomain, now, period);
|
computeExDateForApprovalTime(existingDomain, now, period);
|
||||||
|
|
|
@ -33,7 +33,6 @@ import google.registry.testing.CloudTasksHelper;
|
||||||
import google.registry.testing.CloudTasksHelper.TaskMatcher;
|
import google.registry.testing.CloudTasksHelper.TaskMatcher;
|
||||||
import google.registry.testing.FakeClock;
|
import google.registry.testing.FakeClock;
|
||||||
import google.registry.testing.FakeSleeper;
|
import google.registry.testing.FakeSleeper;
|
||||||
import google.registry.testing.InjectExtension;
|
|
||||||
import google.registry.util.CapturingLogHandler;
|
import google.registry.util.CapturingLogHandler;
|
||||||
import google.registry.util.CloudTasksUtils;
|
import google.registry.util.CloudTasksUtils;
|
||||||
import google.registry.util.JdkLoggerConfig;
|
import google.registry.util.JdkLoggerConfig;
|
||||||
|
@ -57,12 +56,10 @@ public class AsyncTaskEnqueuerTest {
|
||||||
public final AppEngineExtension appEngine =
|
public final AppEngineExtension appEngine =
|
||||||
AppEngineExtension.builder().withCloudSql().withTaskQueue().build();
|
AppEngineExtension.builder().withCloudSql().withTaskQueue().build();
|
||||||
|
|
||||||
@RegisterExtension public final InjectExtension inject = new InjectExtension();
|
|
||||||
|
|
||||||
private AsyncTaskEnqueuer asyncTaskEnqueuer;
|
private AsyncTaskEnqueuer asyncTaskEnqueuer;
|
||||||
private final CapturingLogHandler logHandler = new CapturingLogHandler();
|
private final CapturingLogHandler logHandler = new CapturingLogHandler();
|
||||||
private final FakeClock clock = new FakeClock(DateTime.parse("2015-05-18T12:34:56Z"));
|
private final FakeClock clock = new FakeClock(DateTime.parse("2015-05-18T12:34:56Z"));
|
||||||
private CloudTasksHelper cloudTasksHelper = new CloudTasksHelper(clock);
|
private final CloudTasksHelper cloudTasksHelper = new CloudTasksHelper(clock);
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
void beforeEach() {
|
void beforeEach() {
|
||||||
|
|
|
@ -34,7 +34,6 @@ import google.registry.model.billing.BillingEvent.Flag;
|
||||||
import google.registry.model.billing.BillingEvent.Reason;
|
import google.registry.model.billing.BillingEvent.Reason;
|
||||||
import google.registry.model.domain.Domain;
|
import google.registry.model.domain.Domain;
|
||||||
import google.registry.model.domain.DomainHistory;
|
import google.registry.model.domain.DomainHistory;
|
||||||
import google.registry.model.ofy.Ofy;
|
|
||||||
import google.registry.model.poll.PollMessage;
|
import google.registry.model.poll.PollMessage;
|
||||||
import google.registry.model.reporting.HistoryEntry;
|
import google.registry.model.reporting.HistoryEntry;
|
||||||
import google.registry.persistence.transaction.QueryComposer.Comparator;
|
import google.registry.persistence.transaction.QueryComposer.Comparator;
|
||||||
|
@ -43,7 +42,6 @@ import google.registry.testing.DatabaseHelper;
|
||||||
import google.registry.testing.FakeClock;
|
import google.registry.testing.FakeClock;
|
||||||
import google.registry.testing.FakeLockHandler;
|
import google.registry.testing.FakeLockHandler;
|
||||||
import google.registry.testing.FakeResponse;
|
import google.registry.testing.FakeResponse;
|
||||||
import google.registry.testing.InjectExtension;
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
@ -59,14 +57,11 @@ class DeleteExpiredDomainsActionTest {
|
||||||
public final AppEngineExtension appEngine =
|
public final AppEngineExtension appEngine =
|
||||||
AppEngineExtension.builder().withCloudSql().withClock(clock).withTaskQueue().build();
|
AppEngineExtension.builder().withCloudSql().withClock(clock).withTaskQueue().build();
|
||||||
|
|
||||||
@RegisterExtension public final InjectExtension inject = new InjectExtension();
|
|
||||||
|
|
||||||
private final FakeResponse response = new FakeResponse();
|
private final FakeResponse response = new FakeResponse();
|
||||||
private DeleteExpiredDomainsAction action;
|
private DeleteExpiredDomainsAction action;
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
void beforeEach() {
|
void beforeEach() {
|
||||||
inject.setStaticField(Ofy.class, "clock", clock);
|
|
||||||
createTld("tld");
|
createTld("tld");
|
||||||
EppController eppController =
|
EppController eppController =
|
||||||
DaggerEppTestComponent.builder()
|
DaggerEppTestComponent.builder()
|
||||||
|
@ -103,7 +98,7 @@ class DeleteExpiredDomainsActionTest {
|
||||||
|
|
||||||
// A non-autorenewing domain that is past its expiration time and should be deleted.
|
// A non-autorenewing domain that is past its expiration time and should be deleted.
|
||||||
// (This is the only one that needs a full set of subsidiary resources, for the delete flow to
|
// (This is the only one that needs a full set of subsidiary resources, for the delete flow to
|
||||||
// to operate on.)
|
// operate on.)
|
||||||
Domain pendingExpirationDomain = persistNonAutorenewingDomain("fizz.tld");
|
Domain pendingExpirationDomain = persistNonAutorenewingDomain("fizz.tld");
|
||||||
|
|
||||||
assertThat(loadByEntity(pendingExpirationDomain).getStatusValues())
|
assertThat(loadByEntity(pendingExpirationDomain).getStatusValues())
|
||||||
|
|
|
@ -20,7 +20,6 @@ import static google.registry.batch.AsyncTaskEnqueuer.PARAM_RESOURCE_KEY;
|
||||||
import static google.registry.batch.AsyncTaskEnqueuer.QUEUE_ASYNC_ACTIONS;
|
import static google.registry.batch.AsyncTaskEnqueuer.QUEUE_ASYNC_ACTIONS;
|
||||||
import static google.registry.testing.DatabaseHelper.createTld;
|
import static google.registry.testing.DatabaseHelper.createTld;
|
||||||
import static google.registry.testing.DatabaseHelper.loadByEntity;
|
import static google.registry.testing.DatabaseHelper.loadByEntity;
|
||||||
import static google.registry.testing.DatabaseHelper.newDomain;
|
|
||||||
import static google.registry.testing.DatabaseHelper.persistActiveContact;
|
import static google.registry.testing.DatabaseHelper.persistActiveContact;
|
||||||
import static google.registry.testing.DatabaseHelper.persistDomainWithDependentResources;
|
import static google.registry.testing.DatabaseHelper.persistDomainWithDependentResources;
|
||||||
import static google.registry.testing.DatabaseHelper.persistDomainWithPendingTransfer;
|
import static google.registry.testing.DatabaseHelper.persistDomainWithPendingTransfer;
|
||||||
|
@ -35,14 +34,12 @@ import google.registry.model.domain.Domain;
|
||||||
import google.registry.model.domain.GracePeriod;
|
import google.registry.model.domain.GracePeriod;
|
||||||
import google.registry.model.domain.rgp.GracePeriodStatus;
|
import google.registry.model.domain.rgp.GracePeriodStatus;
|
||||||
import google.registry.model.eppcommon.StatusValue;
|
import google.registry.model.eppcommon.StatusValue;
|
||||||
import google.registry.model.ofy.Ofy;
|
|
||||||
import google.registry.request.Response;
|
import google.registry.request.Response;
|
||||||
import google.registry.testing.AppEngineExtension;
|
import google.registry.testing.AppEngineExtension;
|
||||||
import google.registry.testing.CloudTasksHelper;
|
import google.registry.testing.CloudTasksHelper;
|
||||||
import google.registry.testing.CloudTasksHelper.TaskMatcher;
|
import google.registry.testing.CloudTasksHelper.TaskMatcher;
|
||||||
import google.registry.testing.DatabaseHelper;
|
import google.registry.testing.DatabaseHelper;
|
||||||
import google.registry.testing.FakeClock;
|
import google.registry.testing.FakeClock;
|
||||||
import google.registry.testing.InjectExtension;
|
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
import org.joda.time.Duration;
|
import org.joda.time.Duration;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
@ -62,16 +59,13 @@ public class ResaveEntityActionTest {
|
||||||
public final AppEngineExtension appEngine =
|
public final AppEngineExtension appEngine =
|
||||||
AppEngineExtension.builder().withCloudSql().withTaskQueue().build();
|
AppEngineExtension.builder().withCloudSql().withTaskQueue().build();
|
||||||
|
|
||||||
@RegisterExtension public final InjectExtension inject = new InjectExtension();
|
|
||||||
|
|
||||||
@Mock private Response response;
|
@Mock private Response response;
|
||||||
private final FakeClock clock = new FakeClock(DateTime.parse("2016-02-11T10:00:00Z"));
|
private final FakeClock clock = new FakeClock(DateTime.parse("2016-02-11T10:00:00Z"));
|
||||||
private AsyncTaskEnqueuer asyncTaskEnqueuer;
|
private AsyncTaskEnqueuer asyncTaskEnqueuer;
|
||||||
private CloudTasksHelper cloudTasksHelper = new CloudTasksHelper(clock);
|
private final CloudTasksHelper cloudTasksHelper = new CloudTasksHelper(clock);
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
void beforeEach() {
|
void beforeEach() {
|
||||||
inject.setStaticField(Ofy.class, "clock", clock);
|
|
||||||
asyncTaskEnqueuer =
|
asyncTaskEnqueuer =
|
||||||
AsyncTaskEnqueuerTest.createForTesting(
|
AsyncTaskEnqueuerTest.createForTesting(
|
||||||
cloudTasksHelper.getTestCloudTasksUtils(), clock, Duration.ZERO);
|
cloudTasksHelper.getTestCloudTasksUtils(), clock, Duration.ZERO);
|
||||||
|
|
|
@ -15,7 +15,6 @@
|
||||||
package google.registry.batch;
|
package google.registry.batch;
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
import static com.google.common.truth.Truth8.assertThat;
|
|
||||||
import static google.registry.testing.AppEngineExtension.makeRegistrar1;
|
import static google.registry.testing.AppEngineExtension.makeRegistrar1;
|
||||||
import static google.registry.testing.DatabaseHelper.loadByEntity;
|
import static google.registry.testing.DatabaseHelper.loadByEntity;
|
||||||
import static google.registry.testing.DatabaseHelper.persistResource;
|
import static google.registry.testing.DatabaseHelper.persistResource;
|
||||||
|
@ -40,7 +39,6 @@ import google.registry.model.registrar.RegistrarPoc.Type;
|
||||||
import google.registry.testing.AppEngineExtension;
|
import google.registry.testing.AppEngineExtension;
|
||||||
import google.registry.testing.FakeClock;
|
import google.registry.testing.FakeClock;
|
||||||
import google.registry.testing.FakeResponse;
|
import google.registry.testing.FakeResponse;
|
||||||
import google.registry.testing.InjectExtension;
|
|
||||||
import google.registry.util.SelfSignedCaCertificate;
|
import google.registry.util.SelfSignedCaCertificate;
|
||||||
import google.registry.util.SendEmailService;
|
import google.registry.util.SendEmailService;
|
||||||
import java.security.cert.X509Certificate;
|
import java.security.cert.X509Certificate;
|
||||||
|
@ -57,11 +55,11 @@ class SendExpiringCertificateNotificationEmailActionTest {
|
||||||
|
|
||||||
private static final String EXPIRATION_WARNING_EMAIL_BODY_TEXT =
|
private static final String EXPIRATION_WARNING_EMAIL_BODY_TEXT =
|
||||||
" Dear %1$s,\n"
|
" Dear %1$s,\n"
|
||||||
+ "\n"
|
+ '\n'
|
||||||
+ "We would like to inform you that your %2$s certificate will expire at %3$s."
|
+ "We would like to inform you that your %2$s certificate will expire at %3$s."
|
||||||
+ "\n"
|
+ '\n'
|
||||||
+ " Kind update your account using the following steps: "
|
+ " Kind update your account using the following steps: "
|
||||||
+ "\n"
|
+ '\n'
|
||||||
+ " 1. Navigate to support and login using your %4$s@registry.example credentials.\n"
|
+ " 1. Navigate to support and login using your %4$s@registry.example credentials.\n"
|
||||||
+ " 2. Click Settings -> Privacy on the top left corner.\n"
|
+ " 2. Click Settings -> Privacy on the top left corner.\n"
|
||||||
+ " 3. Click Edit and enter certificate string."
|
+ " 3. Click Edit and enter certificate string."
|
||||||
|
@ -75,7 +73,6 @@ class SendExpiringCertificateNotificationEmailActionTest {
|
||||||
public final AppEngineExtension appEngine =
|
public final AppEngineExtension appEngine =
|
||||||
AppEngineExtension.builder().withCloudSql().withTaskQueue().build();
|
AppEngineExtension.builder().withCloudSql().withTaskQueue().build();
|
||||||
|
|
||||||
@RegisterExtension public final InjectExtension inject = new InjectExtension();
|
|
||||||
private final FakeClock clock = new FakeClock(DateTime.parse("2021-05-24T20:21:22Z"));
|
private final FakeClock clock = new FakeClock(DateTime.parse("2021-05-24T20:21:22Z"));
|
||||||
private final SendEmailService sendEmailService = mock(SendEmailService.class);
|
private final SendEmailService sendEmailService = mock(SendEmailService.class);
|
||||||
private CertificateChecker certificateChecker;
|
private CertificateChecker certificateChecker;
|
||||||
|
@ -708,7 +705,7 @@ class SendExpiringCertificateNotificationEmailActionTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns persisted sample contacts with a customized contact email type. */
|
/** Returns persisted sample contacts with a customized contact email type. */
|
||||||
private ImmutableList<RegistrarPoc> persistSampleContacts(
|
private static ImmutableList<RegistrarPoc> persistSampleContacts(
|
||||||
Registrar registrar, RegistrarPoc.Type emailType) {
|
Registrar registrar, RegistrarPoc.Type emailType) {
|
||||||
return persistSimpleResources(
|
return persistSimpleResources(
|
||||||
ImmutableList.of(
|
ImmutableList.of(
|
||||||
|
|
|
@ -38,7 +38,6 @@ import google.registry.testing.AppEngineExtension;
|
||||||
import google.registry.testing.DatabaseHelper;
|
import google.registry.testing.DatabaseHelper;
|
||||||
import google.registry.testing.FakeClock;
|
import google.registry.testing.FakeClock;
|
||||||
import google.registry.testing.FakeResponse;
|
import google.registry.testing.FakeResponse;
|
||||||
import google.registry.testing.InjectExtension;
|
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
@ -102,7 +101,6 @@ class WipeOutContactHistoryPiiActionTest {
|
||||||
public final AppEngineExtension appEngine =
|
public final AppEngineExtension appEngine =
|
||||||
AppEngineExtension.builder().withCloudSql().withTaskQueue().build();
|
AppEngineExtension.builder().withCloudSql().withTaskQueue().build();
|
||||||
|
|
||||||
@RegisterExtension public final InjectExtension inject = new InjectExtension();
|
|
||||||
private final FakeClock clock = new FakeClock(DateTime.parse("2021-08-26T20:21:22Z"));
|
private final FakeClock clock = new FakeClock(DateTime.parse("2021-08-26T20:21:22Z"));
|
||||||
|
|
||||||
private FakeResponse response;
|
private FakeResponse response;
|
||||||
|
|
|
@ -24,13 +24,11 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import google.registry.model.ofy.Ofy;
|
|
||||||
import google.registry.request.HttpException.NotFoundException;
|
import google.registry.request.HttpException.NotFoundException;
|
||||||
import google.registry.request.RequestModule;
|
import google.registry.request.RequestModule;
|
||||||
import google.registry.testing.AppEngineExtension;
|
import google.registry.testing.AppEngineExtension;
|
||||||
import google.registry.testing.CloudTasksHelper.CloudTasksHelperModule;
|
import google.registry.testing.CloudTasksHelper.CloudTasksHelperModule;
|
||||||
import google.registry.testing.FakeClock;
|
import google.registry.testing.FakeClock;
|
||||||
import google.registry.testing.InjectExtension;
|
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
@ -47,8 +45,6 @@ public final class DnsInjectionTest {
|
||||||
public final AppEngineExtension appEngine =
|
public final AppEngineExtension appEngine =
|
||||||
AppEngineExtension.builder().withCloudSql().withTaskQueue().build();
|
AppEngineExtension.builder().withCloudSql().withTaskQueue().build();
|
||||||
|
|
||||||
@RegisterExtension public final InjectExtension inject = new InjectExtension();
|
|
||||||
|
|
||||||
private final HttpServletRequest req = mock(HttpServletRequest.class);
|
private final HttpServletRequest req = mock(HttpServletRequest.class);
|
||||||
private final HttpServletResponse rsp = mock(HttpServletResponse.class);
|
private final HttpServletResponse rsp = mock(HttpServletResponse.class);
|
||||||
private final StringWriter httpOutput = new StringWriter();
|
private final StringWriter httpOutput = new StringWriter();
|
||||||
|
@ -58,7 +54,6 @@ public final class DnsInjectionTest {
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
void beforeEach() throws Exception {
|
void beforeEach() throws Exception {
|
||||||
inject.setStaticField(Ofy.class, "clock", clock);
|
|
||||||
when(rsp.getWriter()).thenReturn(new PrintWriter(httpOutput));
|
when(rsp.getWriter()).thenReturn(new PrintWriter(httpOutput));
|
||||||
component =
|
component =
|
||||||
DaggerDnsTestComponent.builder()
|
DaggerDnsTestComponent.builder()
|
||||||
|
|
|
@ -45,7 +45,6 @@ import google.registry.dns.DnsMetrics.CommitStatus;
|
||||||
import google.registry.dns.DnsMetrics.PublishStatus;
|
import google.registry.dns.DnsMetrics.PublishStatus;
|
||||||
import google.registry.dns.writer.DnsWriter;
|
import google.registry.dns.writer.DnsWriter;
|
||||||
import google.registry.model.domain.Domain;
|
import google.registry.model.domain.Domain;
|
||||||
import google.registry.model.ofy.Ofy;
|
|
||||||
import google.registry.model.tld.Registry;
|
import google.registry.model.tld.Registry;
|
||||||
import google.registry.request.HttpException.ServiceUnavailableException;
|
import google.registry.request.HttpException.ServiceUnavailableException;
|
||||||
import google.registry.request.lock.LockHandler;
|
import google.registry.request.lock.LockHandler;
|
||||||
|
@ -55,7 +54,6 @@ import google.registry.testing.CloudTasksHelper.TaskMatcher;
|
||||||
import google.registry.testing.FakeClock;
|
import google.registry.testing.FakeClock;
|
||||||
import google.registry.testing.FakeLockHandler;
|
import google.registry.testing.FakeLockHandler;
|
||||||
import google.registry.testing.FakeResponse;
|
import google.registry.testing.FakeResponse;
|
||||||
import google.registry.testing.InjectExtension;
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
|
@ -71,7 +69,6 @@ public class PublishDnsUpdatesActionTest {
|
||||||
public final AppEngineExtension appEngine =
|
public final AppEngineExtension appEngine =
|
||||||
AppEngineExtension.builder().withCloudSql().withTaskQueue().build();
|
AppEngineExtension.builder().withCloudSql().withTaskQueue().build();
|
||||||
|
|
||||||
@RegisterExtension public final InjectExtension inject = new InjectExtension();
|
|
||||||
private final FakeClock clock = new FakeClock(DateTime.parse("1971-01-01TZ"));
|
private final FakeClock clock = new FakeClock(DateTime.parse("1971-01-01TZ"));
|
||||||
private final FakeResponse response = new FakeResponse();
|
private final FakeResponse response = new FakeResponse();
|
||||||
private final FakeLockHandler lockHandler = new FakeLockHandler(true);
|
private final FakeLockHandler lockHandler = new FakeLockHandler(true);
|
||||||
|
@ -83,7 +80,6 @@ public class PublishDnsUpdatesActionTest {
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
void beforeEach() {
|
void beforeEach() {
|
||||||
inject.setStaticField(Ofy.class, "clock", clock);
|
|
||||||
createTld("xn--q9jyb4c");
|
createTld("xn--q9jyb4c");
|
||||||
persistResource(
|
persistResource(
|
||||||
Registry.get("xn--q9jyb4c")
|
Registry.get("xn--q9jyb4c")
|
||||||
|
|
|
@ -39,13 +39,12 @@ import google.registry.model.domain.Domain;
|
||||||
import google.registry.model.domain.secdns.DelegationSignerData;
|
import google.registry.model.domain.secdns.DelegationSignerData;
|
||||||
import google.registry.model.eppcommon.StatusValue;
|
import google.registry.model.eppcommon.StatusValue;
|
||||||
import google.registry.model.host.Host;
|
import google.registry.model.host.Host;
|
||||||
import google.registry.model.ofy.Ofy;
|
|
||||||
import google.registry.testing.AppEngineExtension;
|
import google.registry.testing.AppEngineExtension;
|
||||||
import google.registry.testing.DatabaseHelper;
|
import google.registry.testing.DatabaseHelper;
|
||||||
import google.registry.testing.FakeClock;
|
import google.registry.testing.FakeClock;
|
||||||
import google.registry.testing.InjectExtension;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
import org.joda.time.Duration;
|
import org.joda.time.Duration;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
@ -76,8 +75,6 @@ public class DnsUpdateWriterTest {
|
||||||
public final AppEngineExtension appEngine =
|
public final AppEngineExtension appEngine =
|
||||||
AppEngineExtension.builder().withCloudSql().withTaskQueue().build();
|
AppEngineExtension.builder().withCloudSql().withTaskQueue().build();
|
||||||
|
|
||||||
@RegisterExtension public final InjectExtension inject = new InjectExtension();
|
|
||||||
|
|
||||||
@Mock private DnsMessageTransport mockResolver;
|
@Mock private DnsMessageTransport mockResolver;
|
||||||
@Captor private ArgumentCaptor<Update> updateCaptor;
|
@Captor private ArgumentCaptor<Update> updateCaptor;
|
||||||
|
|
||||||
|
@ -87,8 +84,6 @@ public class DnsUpdateWriterTest {
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
void beforeEach() throws Exception {
|
void beforeEach() throws Exception {
|
||||||
inject.setStaticField(Ofy.class, "clock", clock);
|
|
||||||
|
|
||||||
createTld("tld");
|
createTld("tld");
|
||||||
when(mockResolver.send(any(Update.class))).thenReturn(messageWithResponseCode(Rcode.NOERROR));
|
when(mockResolver.send(any(Update.class))).thenReturn(messageWithResponseCode(Rcode.NOERROR));
|
||||||
|
|
||||||
|
@ -418,23 +413,23 @@ public class DnsUpdateWriterTest {
|
||||||
assertThat(thrown).hasMessageThat().contains("SERVFAIL");
|
assertThat(thrown).hasMessageThat().contains("SERVFAIL");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertThatUpdatedZoneIs(Update update, String zoneName) {
|
private static void assertThatUpdatedZoneIs(Update update, String zoneName) {
|
||||||
Record[] zoneRecords = update.getSectionArray(Section.ZONE);
|
List<Record> zoneRecords = update.getSection(Section.ZONE);
|
||||||
assertThat(zoneRecords[0].getName().toString()).isEqualTo(zoneName);
|
assertThat(zoneRecords.get(0).getName().toString()).isEqualTo(zoneName);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertThatTotalUpdateSetsIs(Update update, int count) {
|
private static void assertThatTotalUpdateSetsIs(Update update, int count) {
|
||||||
assertThat(update.getSectionRRsets(Section.UPDATE)).hasSize(count);
|
assertThat(update.getSectionRRsets(Section.UPDATE)).hasSize(count);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertThatUpdateDeletes(Update update, String resourceName, int recordType) {
|
private static void assertThatUpdateDeletes(Update update, String resourceName, int recordType) {
|
||||||
ImmutableList<Record> deleted = findUpdateRecords(update, resourceName, recordType);
|
ImmutableList<Record> deleted = findUpdateRecords(update, resourceName, recordType);
|
||||||
// There's only an empty (i.e. "delete") record.
|
// There's only an empty (i.e. "delete") record.
|
||||||
assertThat(deleted.get(0).rdataToString()).hasLength(0);
|
assertThat(deleted.get(0).rdataToString()).hasLength(0);
|
||||||
assertThat(deleted).hasSize(1);
|
assertThat(deleted).hasSize(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertThatUpdateAdds(
|
private static void assertThatUpdateAdds(
|
||||||
Update update, String resourceName, int recordType, String... resourceData) {
|
Update update, String resourceName, int recordType, String... resourceData) {
|
||||||
ArrayList<String> expectedData = new ArrayList<>();
|
ArrayList<String> expectedData = new ArrayList<>();
|
||||||
Collections.addAll(expectedData, resourceData);
|
Collections.addAll(expectedData, resourceData);
|
||||||
|
@ -446,7 +441,7 @@ public class DnsUpdateWriterTest {
|
||||||
assertThat(actualData).containsExactlyElementsIn(expectedData);
|
assertThat(actualData).containsExactlyElementsIn(expectedData);
|
||||||
}
|
}
|
||||||
|
|
||||||
private ImmutableList<Record> findUpdateRecords(
|
private static ImmutableList<Record> findUpdateRecords(
|
||||||
Update update, String resourceName, int recordType) {
|
Update update, String resourceName, int recordType) {
|
||||||
for (RRset set : update.getSectionRRsets(Section.UPDATE)) {
|
for (RRset set : update.getSectionRRsets(Section.UPDATE)) {
|
||||||
if (set.getName().toString().equals(resourceName) && set.getType() == recordType) {
|
if (set.getName().toString().equals(resourceName) && set.getType() == recordType) {
|
||||||
|
@ -460,7 +455,7 @@ public class DnsUpdateWriterTest {
|
||||||
throw new AssertionError();
|
throw new AssertionError();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Message messageWithResponseCode(int responseCode) {
|
private static Message messageWithResponseCode(int responseCode) {
|
||||||
Message message = new Message();
|
Message message = new Message();
|
||||||
message.getHeader().setOpcode(Opcode.UPDATE);
|
message.getHeader().setOpcode(Opcode.UPDATE);
|
||||||
message.getHeader().setFlag(Flags.QR);
|
message.getHeader().setFlag(Flags.QR);
|
||||||
|
|
|
@ -33,16 +33,13 @@ import com.google.cloud.storage.contrib.nio.testing.LocalStorageHelper;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.net.MediaType;
|
import com.google.common.net.MediaType;
|
||||||
import google.registry.gcs.GcsUtils;
|
import google.registry.gcs.GcsUtils;
|
||||||
import google.registry.model.ofy.Ofy;
|
|
||||||
import google.registry.model.tld.Registry;
|
import google.registry.model.tld.Registry;
|
||||||
import google.registry.model.tld.Registry.TldType;
|
import google.registry.model.tld.Registry.TldType;
|
||||||
import google.registry.storage.drive.DriveConnection;
|
import google.registry.storage.drive.DriveConnection;
|
||||||
import google.registry.testing.AppEngineExtension;
|
import google.registry.testing.AppEngineExtension;
|
||||||
import google.registry.testing.FakeClock;
|
import google.registry.testing.FakeClock;
|
||||||
import google.registry.testing.InjectExtension;
|
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Order;
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||||
import org.mockito.ArgumentCaptor;
|
import org.mockito.ArgumentCaptor;
|
||||||
|
@ -51,8 +48,8 @@ import org.mockito.ArgumentCaptor;
|
||||||
class ExportDomainListsActionTest {
|
class ExportDomainListsActionTest {
|
||||||
|
|
||||||
private final GcsUtils gcsUtils = new GcsUtils(LocalStorageHelper.getOptions());
|
private final GcsUtils gcsUtils = new GcsUtils(LocalStorageHelper.getOptions());
|
||||||
private DriveConnection driveConnection = mock(DriveConnection.class);
|
private final DriveConnection driveConnection = mock(DriveConnection.class);
|
||||||
private ArgumentCaptor<byte[]> bytesExportedToDrive = ArgumentCaptor.forClass(byte[].class);
|
private final ArgumentCaptor<byte[]> bytesExportedToDrive = ArgumentCaptor.forClass(byte[].class);
|
||||||
private ExportDomainListsAction action;
|
private ExportDomainListsAction action;
|
||||||
private final FakeClock clock = new FakeClock(DateTime.parse("2020-02-02T02:02:02Z"));
|
private final FakeClock clock = new FakeClock(DateTime.parse("2020-02-02T02:02:02Z"));
|
||||||
|
|
||||||
|
@ -60,11 +57,6 @@ class ExportDomainListsActionTest {
|
||||||
public final AppEngineExtension appEngine =
|
public final AppEngineExtension appEngine =
|
||||||
AppEngineExtension.builder().withCloudSql().withLocalModules().withTaskQueue().build();
|
AppEngineExtension.builder().withCloudSql().withLocalModules().withTaskQueue().build();
|
||||||
|
|
||||||
@Order(Order.DEFAULT - 1)
|
|
||||||
@RegisterExtension
|
|
||||||
public final InjectExtension inject =
|
|
||||||
new InjectExtension().withStaticFieldOverride(Ofy.class, "clock", clock);
|
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
void beforeEach() {
|
void beforeEach() {
|
||||||
createTld("tld");
|
createTld("tld");
|
||||||
|
|
|
@ -42,7 +42,6 @@ import google.registry.request.Response;
|
||||||
import google.registry.testing.AppEngineExtension;
|
import google.registry.testing.AppEngineExtension;
|
||||||
import google.registry.testing.FakeClock;
|
import google.registry.testing.FakeClock;
|
||||||
import google.registry.testing.FakeSleeper;
|
import google.registry.testing.FakeSleeper;
|
||||||
import google.registry.testing.InjectExtension;
|
|
||||||
import google.registry.util.Retrier;
|
import google.registry.util.Retrier;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
@ -59,8 +58,6 @@ public class SyncGroupMembersActionTest {
|
||||||
@RegisterExtension
|
@RegisterExtension
|
||||||
public final AppEngineExtension appEngine = AppEngineExtension.builder().withCloudSql().build();
|
public final AppEngineExtension appEngine = AppEngineExtension.builder().withCloudSql().build();
|
||||||
|
|
||||||
@RegisterExtension public final InjectExtension inject = new InjectExtension();
|
|
||||||
|
|
||||||
private final DirectoryGroupsConnection connection = mock(DirectoryGroupsConnection.class);
|
private final DirectoryGroupsConnection connection = mock(DirectoryGroupsConnection.class);
|
||||||
private final Response response = mock(Response.class);
|
private final Response response = mock(Response.class);
|
||||||
|
|
||||||
|
@ -76,8 +73,7 @@ public class SyncGroupMembersActionTest {
|
||||||
@Test
|
@Test
|
||||||
void test_getGroupEmailAddressForContactType_convertsToLowercase() {
|
void test_getGroupEmailAddressForContactType_convertsToLowercase() {
|
||||||
assertThat(
|
assertThat(
|
||||||
getGroupEmailAddressForContactType(
|
getGroupEmailAddressForContactType("SomeRegistrar", ADMIN, "domain-registry.example"))
|
||||||
"SomeRegistrar", RegistrarPoc.Type.ADMIN, "domain-registry.example"))
|
|
||||||
.isEqualTo("someregistrar-primary-contacts@domain-registry.example");
|
.isEqualTo("someregistrar-primary-contacts@domain-registry.example");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,14 +35,12 @@ import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import google.registry.model.common.Cursor;
|
import google.registry.model.common.Cursor;
|
||||||
import google.registry.model.ofy.Ofy;
|
|
||||||
import google.registry.model.registrar.Registrar;
|
import google.registry.model.registrar.Registrar;
|
||||||
import google.registry.model.registrar.RegistrarAddress;
|
import google.registry.model.registrar.RegistrarAddress;
|
||||||
import google.registry.model.registrar.RegistrarPoc;
|
import google.registry.model.registrar.RegistrarPoc;
|
||||||
import google.registry.testing.AppEngineExtension;
|
import google.registry.testing.AppEngineExtension;
|
||||||
import google.registry.testing.DatabaseHelper;
|
import google.registry.testing.DatabaseHelper;
|
||||||
import google.registry.testing.FakeClock;
|
import google.registry.testing.FakeClock;
|
||||||
import google.registry.testing.InjectExtension;
|
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
@ -60,8 +58,6 @@ public class SyncRegistrarsSheetTest {
|
||||||
@RegisterExtension
|
@RegisterExtension
|
||||||
public final AppEngineExtension appEngine = AppEngineExtension.builder().withCloudSql().build();
|
public final AppEngineExtension appEngine = AppEngineExtension.builder().withCloudSql().build();
|
||||||
|
|
||||||
@RegisterExtension public final InjectExtension inject = new InjectExtension();
|
|
||||||
|
|
||||||
@Captor private ArgumentCaptor<ImmutableList<ImmutableMap<String, String>>> rowsCaptor;
|
@Captor private ArgumentCaptor<ImmutableList<ImmutableMap<String, String>>> rowsCaptor;
|
||||||
@Mock private SheetSynchronizer sheetSynchronizer;
|
@Mock private SheetSynchronizer sheetSynchronizer;
|
||||||
|
|
||||||
|
@ -76,7 +72,6 @@ public class SyncRegistrarsSheetTest {
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
void beforeEach() {
|
void beforeEach() {
|
||||||
inject.setStaticField(Ofy.class, "clock", clock);
|
|
||||||
createTld("example");
|
createTld("example");
|
||||||
// Remove Registrar entities created by AppEngineExtension (and RegistrarContact's, for jpa).
|
// Remove Registrar entities created by AppEngineExtension (and RegistrarContact's, for jpa).
|
||||||
// We don't do this for ofy because ofy's loadAllOf() can't be called in a transaction but
|
// We don't do this for ofy because ofy's loadAllOf() can't be called in a transaction but
|
||||||
|
@ -215,7 +210,7 @@ public class SyncRegistrarsSheetTest {
|
||||||
+ "Phone number and email visible in domain WHOIS query as "
|
+ "Phone number and email visible in domain WHOIS query as "
|
||||||
+ "Registrar Abuse contact info: No\n"
|
+ "Registrar Abuse contact info: No\n"
|
||||||
+ "Registrar-Console access: No\n"
|
+ "Registrar-Console access: No\n"
|
||||||
+ "\n"
|
+ '\n'
|
||||||
+ "John Doe\n"
|
+ "John Doe\n"
|
||||||
+ "john.doe@example.tld\n"
|
+ "john.doe@example.tld\n"
|
||||||
+ "Tel: +1.1234567890\n"
|
+ "Tel: +1.1234567890\n"
|
||||||
|
|
|
@ -31,13 +31,11 @@ import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
import google.registry.flows.EppTestComponent.FakesAndMocksModule;
|
import google.registry.flows.EppTestComponent.FakesAndMocksModule;
|
||||||
import google.registry.model.domain.Domain;
|
import google.registry.model.domain.Domain;
|
||||||
import google.registry.model.ofy.Ofy;
|
|
||||||
import google.registry.monitoring.whitebox.EppMetric;
|
import google.registry.monitoring.whitebox.EppMetric;
|
||||||
import google.registry.testing.AppEngineExtension;
|
import google.registry.testing.AppEngineExtension;
|
||||||
import google.registry.testing.EppLoader;
|
import google.registry.testing.EppLoader;
|
||||||
import google.registry.testing.FakeClock;
|
import google.registry.testing.FakeClock;
|
||||||
import google.registry.testing.FakeHttpSession;
|
import google.registry.testing.FakeHttpSession;
|
||||||
import google.registry.testing.InjectExtension;
|
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
@ -52,14 +50,11 @@ class EppPointInTimeTest {
|
||||||
final AppEngineExtension appEngine =
|
final AppEngineExtension appEngine =
|
||||||
AppEngineExtension.builder().withCloudSql().withClock(clock).withTaskQueue().build();
|
AppEngineExtension.builder().withCloudSql().withClock(clock).withTaskQueue().build();
|
||||||
|
|
||||||
@RegisterExtension final InjectExtension inject = new InjectExtension();
|
|
||||||
|
|
||||||
private EppLoader eppLoader;
|
private EppLoader eppLoader;
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
void beforeEach() {
|
void beforeEach() {
|
||||||
createTld("tld");
|
createTld("tld");
|
||||||
inject.setStaticField(Ofy.class, "clock", clock);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void runFlow() throws Exception {
|
private void runFlow() throws Exception {
|
||||||
|
|
|
@ -36,7 +36,6 @@ import google.registry.model.billing.BillingEvent.Reason;
|
||||||
import google.registry.model.domain.Domain;
|
import google.registry.model.domain.Domain;
|
||||||
import google.registry.model.domain.DomainHistory;
|
import google.registry.model.domain.DomainHistory;
|
||||||
import google.registry.model.eppcommon.EppXmlTransformer;
|
import google.registry.model.eppcommon.EppXmlTransformer;
|
||||||
import google.registry.model.ofy.Ofy;
|
|
||||||
import google.registry.model.reporting.HistoryEntry.Type;
|
import google.registry.model.reporting.HistoryEntry.Type;
|
||||||
import google.registry.model.tld.Registry;
|
import google.registry.model.tld.Registry;
|
||||||
import google.registry.monitoring.whitebox.EppMetric;
|
import google.registry.monitoring.whitebox.EppMetric;
|
||||||
|
@ -44,7 +43,6 @@ import google.registry.persistence.VKey;
|
||||||
import google.registry.testing.FakeClock;
|
import google.registry.testing.FakeClock;
|
||||||
import google.registry.testing.FakeHttpSession;
|
import google.registry.testing.FakeHttpSession;
|
||||||
import google.registry.testing.FakeResponse;
|
import google.registry.testing.FakeResponse;
|
||||||
import google.registry.testing.InjectExtension;
|
|
||||||
import google.registry.util.ProxyHttpHeaders;
|
import google.registry.util.ProxyHttpHeaders;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
@ -52,16 +50,12 @@ import java.util.Optional;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import org.joda.money.Money;
|
import org.joda.money.Money;
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
|
||||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
|
||||||
|
|
||||||
public class EppTestCase {
|
public class EppTestCase {
|
||||||
|
|
||||||
private static final MediaType APPLICATION_EPP_XML_UTF8 =
|
private static final MediaType APPLICATION_EPP_XML_UTF8 =
|
||||||
MediaType.create("application", "epp+xml").withCharset(UTF_8);
|
MediaType.create("application", "epp+xml").withCharset(UTF_8);
|
||||||
|
|
||||||
@RegisterExtension public final InjectExtension inject = new InjectExtension();
|
|
||||||
|
|
||||||
protected final FakeClock clock = new FakeClock();
|
protected final FakeClock clock = new FakeClock();
|
||||||
|
|
||||||
private SessionMetadata sessionMetadata;
|
private SessionMetadata sessionMetadata;
|
||||||
|
@ -69,12 +63,6 @@ public class EppTestCase {
|
||||||
private EppMetric.Builder eppMetricBuilder;
|
private EppMetric.Builder eppMetricBuilder;
|
||||||
private boolean isSuperuser;
|
private boolean isSuperuser;
|
||||||
|
|
||||||
@BeforeEach
|
|
||||||
public void beforeEachEppTestCase() {
|
|
||||||
// For transactional flows
|
|
||||||
inject.setStaticField(Ofy.class, "clock", clock);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the transport credentials.
|
* Set the transport credentials.
|
||||||
*
|
*
|
||||||
|
@ -92,14 +80,14 @@ public class EppTestCase {
|
||||||
|
|
||||||
public class CommandAsserter {
|
public class CommandAsserter {
|
||||||
private final String inputFilename;
|
private final String inputFilename;
|
||||||
private @Nullable final Map<String, String> inputSubstitutions;
|
@Nullable private final Map<String, String> inputSubstitutions;
|
||||||
private DateTime now;
|
private DateTime now;
|
||||||
|
|
||||||
private CommandAsserter(
|
private CommandAsserter(
|
||||||
String inputFilename, @Nullable Map<String, String> inputSubstitutions) {
|
String inputFilename, @Nullable Map<String, String> inputSubstitutions) {
|
||||||
this.inputFilename = inputFilename;
|
this.inputFilename = inputFilename;
|
||||||
this.inputSubstitutions = inputSubstitutions;
|
this.inputSubstitutions = inputSubstitutions;
|
||||||
this.now = clock.nowUtc();
|
now = clock.nowUtc();
|
||||||
}
|
}
|
||||||
|
|
||||||
public CommandAsserter atTime(DateTime now) {
|
public CommandAsserter atTime(DateTime now) {
|
||||||
|
@ -121,9 +109,88 @@ public class EppTestCase {
|
||||||
inputFilename, inputSubstitutions, outputFilename, outputSubstitutions, now);
|
inputFilename, inputSubstitutions, outputFilename, outputSubstitutions, now);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String hasSuccessfulLogin() throws Exception {
|
public void hasSuccessfulLogin() throws Exception {
|
||||||
return assertLoginCommandAndResponse(inputFilename, inputSubstitutions, null, clock.nowUtc());
|
assertLoginCommandAndResponse(inputFilename, inputSubstitutions, null, clock.nowUtc());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void assertLoginCommandAndResponse(
|
||||||
|
String inputFilename,
|
||||||
|
@Nullable Map<String, String> inputSubstitutions,
|
||||||
|
@Nullable Map<String, String> outputSubstitutions,
|
||||||
|
DateTime now)
|
||||||
|
throws Exception {
|
||||||
|
String outputFilename = "generic_success_response.xml";
|
||||||
|
clock.setTo(now);
|
||||||
|
String input = loadFile(EppTestCase.class, inputFilename, inputSubstitutions);
|
||||||
|
String expectedOutput = loadFile(EppTestCase.class, outputFilename, outputSubstitutions);
|
||||||
|
setUpSession();
|
||||||
|
FakeResponse response = executeXmlCommand(input);
|
||||||
|
|
||||||
|
// Check that the logged-in header was added to the response
|
||||||
|
assertThat(response.getHeaders())
|
||||||
|
.isEqualTo(ImmutableMap.of(ProxyHttpHeaders.LOGGED_IN, "true"));
|
||||||
|
|
||||||
|
verifyAndReturnOutput(response.getPayload(), expectedOutput, inputFilename, outputFilename);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String assertCommandAndResponse(
|
||||||
|
String inputFilename,
|
||||||
|
@Nullable Map<String, String> inputSubstitutions,
|
||||||
|
String outputFilename,
|
||||||
|
@Nullable Map<String, String> outputSubstitutions,
|
||||||
|
DateTime now)
|
||||||
|
throws Exception {
|
||||||
|
clock.setTo(now);
|
||||||
|
String input = loadFile(EppTestCase.class, inputFilename, inputSubstitutions);
|
||||||
|
String expectedOutput = loadFile(EppTestCase.class, outputFilename, outputSubstitutions);
|
||||||
|
setUpSession();
|
||||||
|
FakeResponse response = executeXmlCommand(input);
|
||||||
|
|
||||||
|
// Checks that the Logged-In header is not in the response. If testing the login command, use
|
||||||
|
// assertLoginCommandAndResponse instead of this method.
|
||||||
|
assertThat(response.getHeaders()).doesNotContainEntry(ProxyHttpHeaders.LOGGED_IN, "true");
|
||||||
|
|
||||||
|
return verifyAndReturnOutput(
|
||||||
|
response.getPayload(), expectedOutput, inputFilename, outputFilename);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setUpSession() {
|
||||||
|
if (sessionMetadata == null) {
|
||||||
|
sessionMetadata =
|
||||||
|
new HttpSessionMetadata(new FakeHttpSession()) {
|
||||||
|
@Override
|
||||||
|
public void invalidate() {
|
||||||
|
// When a session is invalidated, reset the sessionMetadata field.
|
||||||
|
super.invalidate();
|
||||||
|
sessionMetadata = null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private FakeResponse executeXmlCommand(String inputXml) {
|
||||||
|
EppRequestHandler handler = new EppRequestHandler();
|
||||||
|
FakeResponse response = new FakeResponse();
|
||||||
|
handler.response = response;
|
||||||
|
FakesAndMocksModule fakesAndMocksModule = FakesAndMocksModule.create(clock);
|
||||||
|
eppMetricBuilder = fakesAndMocksModule.getMetricBuilder();
|
||||||
|
handler.eppController =
|
||||||
|
DaggerEppTestComponent.builder()
|
||||||
|
.fakesAndMocksModule(fakesAndMocksModule)
|
||||||
|
.build()
|
||||||
|
.startRequest()
|
||||||
|
.eppController();
|
||||||
|
handler.executeEpp(
|
||||||
|
sessionMetadata,
|
||||||
|
credentials,
|
||||||
|
EppRequestSource.UNIT_TEST,
|
||||||
|
false, // Not dryRun.
|
||||||
|
isSuperuser,
|
||||||
|
inputXml.getBytes(UTF_8));
|
||||||
|
assertThat(response.getStatus()).isEqualTo(SC_OK);
|
||||||
|
assertThat(response.getContentType()).isEqualTo(APPLICATION_EPP_XML_UTF8);
|
||||||
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected CommandAsserter assertThatCommand(String inputFilename) {
|
protected CommandAsserter assertThatCommand(String inputFilename) {
|
||||||
|
@ -148,63 +215,7 @@ public class EppTestCase {
|
||||||
assertThatCommand("logout.xml").hasResponse("logout_response.xml");
|
assertThatCommand("logout.xml").hasResponse("logout_response.xml");
|
||||||
}
|
}
|
||||||
|
|
||||||
private String assertLoginCommandAndResponse(
|
private static String verifyAndReturnOutput(
|
||||||
String inputFilename,
|
|
||||||
@Nullable Map<String, String> inputSubstitutions,
|
|
||||||
@Nullable Map<String, String> outputSubstitutions,
|
|
||||||
DateTime now)
|
|
||||||
throws Exception {
|
|
||||||
String outputFilename = "generic_success_response.xml";
|
|
||||||
clock.setTo(now);
|
|
||||||
String input = loadFile(EppTestCase.class, inputFilename, inputSubstitutions);
|
|
||||||
String expectedOutput = loadFile(EppTestCase.class, outputFilename, outputSubstitutions);
|
|
||||||
setUpSession();
|
|
||||||
FakeResponse response = executeXmlCommand(input);
|
|
||||||
|
|
||||||
// Check that the logged-in header was added to the response
|
|
||||||
assertThat(response.getHeaders())
|
|
||||||
.isEqualTo(ImmutableMap.of(ProxyHttpHeaders.LOGGED_IN, "true"));
|
|
||||||
|
|
||||||
return verifyAndReturnOutput(
|
|
||||||
response.getPayload(), expectedOutput, inputFilename, outputFilename);
|
|
||||||
}
|
|
||||||
|
|
||||||
private String assertCommandAndResponse(
|
|
||||||
String inputFilename,
|
|
||||||
@Nullable Map<String, String> inputSubstitutions,
|
|
||||||
String outputFilename,
|
|
||||||
@Nullable Map<String, String> outputSubstitutions,
|
|
||||||
DateTime now)
|
|
||||||
throws Exception {
|
|
||||||
clock.setTo(now);
|
|
||||||
String input = loadFile(EppTestCase.class, inputFilename, inputSubstitutions);
|
|
||||||
String expectedOutput = loadFile(EppTestCase.class, outputFilename, outputSubstitutions);
|
|
||||||
setUpSession();
|
|
||||||
FakeResponse response = executeXmlCommand(input);
|
|
||||||
|
|
||||||
// Checks that the Logged-In header is not in the response. If testing the login command, use
|
|
||||||
// assertLoginCommandAndResponse instead of this method.
|
|
||||||
assertThat(response.getHeaders()).doesNotContainEntry(ProxyHttpHeaders.LOGGED_IN, "true");
|
|
||||||
|
|
||||||
return verifyAndReturnOutput(
|
|
||||||
response.getPayload(), expectedOutput, inputFilename, outputFilename);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setUpSession() {
|
|
||||||
if (sessionMetadata == null) {
|
|
||||||
sessionMetadata =
|
|
||||||
new HttpSessionMetadata(new FakeHttpSession()) {
|
|
||||||
@Override
|
|
||||||
public void invalidate() {
|
|
||||||
// When a session is invalidated, reset the sessionMetadata field.
|
|
||||||
super.invalidate();
|
|
||||||
EppTestCase.this.sessionMetadata = null;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private String verifyAndReturnOutput(
|
|
||||||
String actualOutput, String expectedOutput, String inputFilename, String outputFilename)
|
String actualOutput, String expectedOutput, String inputFilename, String outputFilename)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
// Run the resulting xml through the unmarshaller to verify that it was valid.
|
// Run the resulting xml through the unmarshaller to verify that it was valid.
|
||||||
|
@ -219,30 +230,6 @@ public class EppTestCase {
|
||||||
return actualOutput;
|
return actualOutput;
|
||||||
}
|
}
|
||||||
|
|
||||||
private FakeResponse executeXmlCommand(String inputXml) {
|
|
||||||
EppRequestHandler handler = new EppRequestHandler();
|
|
||||||
FakeResponse response = new FakeResponse();
|
|
||||||
handler.response = response;
|
|
||||||
FakesAndMocksModule fakesAndMocksModule = FakesAndMocksModule.create(clock);
|
|
||||||
eppMetricBuilder = fakesAndMocksModule.getMetricBuilder();
|
|
||||||
handler.eppController =
|
|
||||||
DaggerEppTestComponent.builder()
|
|
||||||
.fakesAndMocksModule(fakesAndMocksModule)
|
|
||||||
.build()
|
|
||||||
.startRequest()
|
|
||||||
.eppController();
|
|
||||||
handler.executeEpp(
|
|
||||||
sessionMetadata,
|
|
||||||
credentials,
|
|
||||||
EppRequestSource.UNIT_TEST,
|
|
||||||
false, // Not dryRun.
|
|
||||||
isSuperuser,
|
|
||||||
inputXml.getBytes(UTF_8));
|
|
||||||
assertThat(response.getStatus()).isEqualTo(SC_OK);
|
|
||||||
assertThat(response.getContentType()).isEqualTo(APPLICATION_EPP_XML_UTF8);
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
|
|
||||||
EppMetric getRecordedEppMetric() {
|
EppMetric getRecordedEppMetric() {
|
||||||
return eppMetricBuilder.build();
|
return eppMetricBuilder.build();
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,6 @@ import google.registry.model.domain.GracePeriod;
|
||||||
import google.registry.model.eppcommon.ProtocolDefinition;
|
import google.registry.model.eppcommon.ProtocolDefinition;
|
||||||
import google.registry.model.eppinput.EppInput;
|
import google.registry.model.eppinput.EppInput;
|
||||||
import google.registry.model.eppoutput.EppOutput;
|
import google.registry.model.eppoutput.EppOutput;
|
||||||
import google.registry.model.ofy.Ofy;
|
|
||||||
import google.registry.model.reporting.HistoryEntryDao;
|
import google.registry.model.reporting.HistoryEntryDao;
|
||||||
import google.registry.monitoring.whitebox.EppMetric;
|
import google.registry.monitoring.whitebox.EppMetric;
|
||||||
import google.registry.testing.AppEngineExtension;
|
import google.registry.testing.AppEngineExtension;
|
||||||
|
@ -48,7 +47,6 @@ import google.registry.testing.DatabaseHelper;
|
||||||
import google.registry.testing.EppLoader;
|
import google.registry.testing.EppLoader;
|
||||||
import google.registry.testing.FakeClock;
|
import google.registry.testing.FakeClock;
|
||||||
import google.registry.testing.FakeHttpSession;
|
import google.registry.testing.FakeHttpSession;
|
||||||
import google.registry.testing.InjectExtension;
|
|
||||||
import google.registry.testing.TestDataHelper;
|
import google.registry.testing.TestDataHelper;
|
||||||
import google.registry.util.TypeUtils.TypeInstantiator;
|
import google.registry.util.TypeUtils.TypeInstantiator;
|
||||||
import google.registry.xml.ValidationMode;
|
import google.registry.xml.ValidationMode;
|
||||||
|
@ -58,7 +56,6 @@ import java.util.Map;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Order;
|
|
||||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -89,13 +86,6 @@ public abstract class FlowTestCase<F extends Flow> {
|
||||||
|
|
||||||
private EppMetric.Builder eppMetricBuilder;
|
private EppMetric.Builder eppMetricBuilder;
|
||||||
|
|
||||||
// Set the clock for transactional flows. We have to order this before the AppEngineExtension
|
|
||||||
// which populates data.
|
|
||||||
@Order(value = Order.DEFAULT - 1)
|
|
||||||
@RegisterExtension
|
|
||||||
final InjectExtension inject =
|
|
||||||
new InjectExtension().withStaticFieldOverride(Ofy.class, "clock", clock);
|
|
||||||
|
|
||||||
@RegisterExtension
|
@RegisterExtension
|
||||||
final AppEngineExtension appEngine =
|
final AppEngineExtension appEngine =
|
||||||
AppEngineExtension.builder().withClock(clock).withCloudSql().withTaskQueue().build();
|
AppEngineExtension.builder().withClock(clock).withCloudSql().withTaskQueue().build();
|
||||||
|
@ -171,13 +161,13 @@ public abstract class FlowTestCase<F extends Flow> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper to facilitate comparison of maps of GracePeriods to BillingEvents. This takes a map of
|
* Helper to facilitate comparison of maps of GracePeriods to BillingEvents. This takes a map of
|
||||||
* GracePeriods to BillingEvents and returns a map of the same entries that ignores the keys
|
* GracePeriods to BillingEvents and returns a map of the same entries that ignores the keys on
|
||||||
* on the grace periods and the IDs on the billing events (by setting them all to the same dummy
|
* the grace periods and the IDs on the billing events (by setting them all to the same dummy
|
||||||
* values), since they will vary between instantiations even when the other data is the same.
|
* values), since they will vary between instantiations even when the other data is the same.
|
||||||
*/
|
*/
|
||||||
private ImmutableMap<GracePeriod, BillingEvent>
|
private static ImmutableMap<GracePeriod, BillingEvent> canonicalizeGracePeriods(
|
||||||
canonicalizeGracePeriods(ImmutableMap<GracePeriod, ? extends BillingEvent> gracePeriods) {
|
ImmutableMap<GracePeriod, ? extends BillingEvent> gracePeriods) {
|
||||||
ImmutableMap.Builder<GracePeriod, BillingEvent> builder = new ImmutableMap.Builder<>();
|
ImmutableMap.Builder<GracePeriod, BillingEvent> builder = new ImmutableMap.Builder<>();
|
||||||
for (Map.Entry<GracePeriod, ? extends BillingEvent> entry : gracePeriods.entrySet()) {
|
for (Map.Entry<GracePeriod, ? extends BillingEvent> entry : gracePeriods.entrySet()) {
|
||||||
builder.put(
|
builder.put(
|
||||||
|
@ -210,7 +200,7 @@ public abstract class FlowTestCase<F extends Flow> {
|
||||||
* keys match the expected map of grace periods to billing events. For the expected map, the keys
|
* keys match the expected map of grace periods to billing events. For the expected map, the keys
|
||||||
* on the grace periods and IDs on the billing events are ignored.
|
* on the grace periods and IDs on the billing events are ignored.
|
||||||
*/
|
*/
|
||||||
protected void assertGracePeriods(
|
protected static void assertGracePeriods(
|
||||||
Iterable<GracePeriod> actual, ImmutableMap<GracePeriod, ? extends BillingEvent> expected) {
|
Iterable<GracePeriod> actual, ImmutableMap<GracePeriod, ? extends BillingEvent> expected) {
|
||||||
assertThat(canonicalizeGracePeriods(Maps.toMap(actual, FlowTestCase::expandGracePeriod)))
|
assertThat(canonicalizeGracePeriods(Maps.toMap(actual, FlowTestCase::expandGracePeriod)))
|
||||||
.isEqualTo(canonicalizeGracePeriods(expected));
|
.isEqualTo(canonicalizeGracePeriods(expected));
|
||||||
|
@ -258,7 +248,7 @@ public abstract class FlowTestCase<F extends Flow> {
|
||||||
return runFlow(CommitMode.LIVE, UserPrivileges.NORMAL);
|
return runFlow(CommitMode.LIVE, UserPrivileges.NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Shortcut to call {@link #runFlow(CommitMode, UserPrivileges)} as super user and live run. */
|
/** Shortcut to call {@link #runFlow(CommitMode, UserPrivileges)} as superuser and live run. */
|
||||||
protected EppOutput runFlowAsSuperuser() throws Exception {
|
protected EppOutput runFlowAsSuperuser() throws Exception {
|
||||||
return runFlow(CommitMode.LIVE, UserPrivileges.SUPERUSER);
|
return runFlow(CommitMode.LIVE, UserPrivileges.SUPERUSER);
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,12 +16,9 @@ package google.registry.model;
|
||||||
|
|
||||||
import static org.joda.time.DateTimeZone.UTC;
|
import static org.joda.time.DateTimeZone.UTC;
|
||||||
|
|
||||||
import google.registry.model.ofy.Ofy;
|
|
||||||
import google.registry.testing.AppEngineExtension;
|
import google.registry.testing.AppEngineExtension;
|
||||||
import google.registry.testing.FakeClock;
|
import google.registry.testing.FakeClock;
|
||||||
import google.registry.testing.InjectExtension;
|
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
|
||||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||||
|
|
||||||
/** Base class of all unit tests for entities which are persisted to Datastore via Objectify. */
|
/** Base class of all unit tests for entities which are persisted to Datastore via Objectify. */
|
||||||
|
@ -41,8 +38,6 @@ public abstract class EntityTestCase {
|
||||||
|
|
||||||
@RegisterExtension public final AppEngineExtension appEngine;
|
@RegisterExtension public final AppEngineExtension appEngine;
|
||||||
|
|
||||||
@RegisterExtension public InjectExtension inject = new InjectExtension();
|
|
||||||
|
|
||||||
protected EntityTestCase() {
|
protected EntityTestCase() {
|
||||||
this(JpaEntityCoverageCheck.DISABLED);
|
this(JpaEntityCoverageCheck.DISABLED);
|
||||||
}
|
}
|
||||||
|
@ -55,9 +50,4 @@ public abstract class EntityTestCase {
|
||||||
.withClock(fakeClock)
|
.withClock(fakeClock)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@BeforeEach
|
|
||||||
public void injectClock() {
|
|
||||||
inject.setStaticField(Ofy.class, "clock", fakeClock);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,10 +23,8 @@ import static google.registry.util.DateTimeUtils.START_OF_TIME;
|
||||||
import static org.joda.time.DateTimeZone.UTC;
|
import static org.joda.time.DateTimeZone.UTC;
|
||||||
|
|
||||||
import google.registry.model.host.Host;
|
import google.registry.model.host.Host;
|
||||||
import google.registry.model.ofy.Ofy;
|
|
||||||
import google.registry.testing.AppEngineExtension;
|
import google.registry.testing.AppEngineExtension;
|
||||||
import google.registry.testing.FakeClock;
|
import google.registry.testing.FakeClock;
|
||||||
import google.registry.testing.InjectExtension;
|
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
import org.joda.time.Duration;
|
import org.joda.time.Duration;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
@ -42,12 +40,9 @@ class EppResourceUtilsTest {
|
||||||
public final AppEngineExtension appEngine =
|
public final AppEngineExtension appEngine =
|
||||||
AppEngineExtension.builder().withCloudSql().withClock(clock).withTaskQueue().build();
|
AppEngineExtension.builder().withCloudSql().withClock(clock).withTaskQueue().build();
|
||||||
|
|
||||||
@RegisterExtension public final InjectExtension inject = new InjectExtension();
|
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
void beforeEach() {
|
void beforeEach() {
|
||||||
createTld("tld");
|
createTld("tld");
|
||||||
inject.setStaticField(Ofy.class, "clock", clock);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -28,14 +28,12 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
import google.registry.model.domain.DomainHistory;
|
import google.registry.model.domain.DomainHistory;
|
||||||
import google.registry.model.domain.Period;
|
import google.registry.model.domain.Period;
|
||||||
import google.registry.model.eppcommon.Trid;
|
import google.registry.model.eppcommon.Trid;
|
||||||
import google.registry.model.ofy.Ofy;
|
|
||||||
import google.registry.model.poll.PollMessageExternalKeyConverter.PollMessageExternalKeyParseException;
|
import google.registry.model.poll.PollMessageExternalKeyConverter.PollMessageExternalKeyParseException;
|
||||||
import google.registry.model.reporting.HistoryEntry;
|
import google.registry.model.reporting.HistoryEntry;
|
||||||
import google.registry.persistence.VKey;
|
import google.registry.persistence.VKey;
|
||||||
import google.registry.testing.AppEngineExtension;
|
import google.registry.testing.AppEngineExtension;
|
||||||
import google.registry.testing.DatabaseHelper;
|
import google.registry.testing.DatabaseHelper;
|
||||||
import google.registry.testing.FakeClock;
|
import google.registry.testing.FakeClock;
|
||||||
import google.registry.testing.InjectExtension;
|
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
@ -47,14 +45,11 @@ public class PollMessageExternalKeyConverterTest {
|
||||||
@RegisterExtension
|
@RegisterExtension
|
||||||
public final AppEngineExtension appEngine = AppEngineExtension.builder().withCloudSql().build();
|
public final AppEngineExtension appEngine = AppEngineExtension.builder().withCloudSql().build();
|
||||||
|
|
||||||
@RegisterExtension public InjectExtension inject = new InjectExtension();
|
|
||||||
|
|
||||||
private HistoryEntry historyEntry;
|
private HistoryEntry historyEntry;
|
||||||
private FakeClock clock = new FakeClock(DateTime.parse("2007-07-07T01:01:01Z"));
|
private FakeClock clock = new FakeClock(DateTime.parse("2007-07-07T01:01:01Z"));
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
void beforeEach() {
|
void beforeEach() {
|
||||||
inject.setStaticField(Ofy.class, "clock", clock);
|
|
||||||
createTld("foobar");
|
createTld("foobar");
|
||||||
historyEntry =
|
historyEntry =
|
||||||
persistResource(
|
persistResource(
|
||||||
|
|
|
@ -43,7 +43,6 @@ import google.registry.model.tld.Registry.TldState;
|
||||||
import google.registry.model.tld.label.PremiumList;
|
import google.registry.model.tld.label.PremiumList;
|
||||||
import google.registry.model.tld.label.PremiumListDao;
|
import google.registry.model.tld.label.PremiumListDao;
|
||||||
import google.registry.model.tld.label.ReservedList;
|
import google.registry.model.tld.label.ReservedList;
|
||||||
import google.registry.testing.DatabaseHelper;
|
|
||||||
import google.registry.util.SerializeUtils;
|
import google.registry.util.SerializeUtils;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
@ -61,8 +60,6 @@ public final class RegistryTest extends EntityTestCase {
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
void beforeEach() {
|
void beforeEach() {
|
||||||
// Auto-increment fakeClock in DatabaseHelper.
|
|
||||||
inject.setStaticField(DatabaseHelper.class, "clock", fakeClock);
|
|
||||||
createTld("tld");
|
createTld("tld");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,11 +27,9 @@ import com.googlecode.objectify.Key;
|
||||||
import com.googlecode.objectify.annotation.Entity;
|
import com.googlecode.objectify.annotation.Entity;
|
||||||
import com.googlecode.objectify.annotation.Id;
|
import com.googlecode.objectify.annotation.Id;
|
||||||
import google.registry.model.ImmutableObject;
|
import google.registry.model.ImmutableObject;
|
||||||
import google.registry.model.ofy.Ofy;
|
|
||||||
import google.registry.persistence.VKey;
|
import google.registry.persistence.VKey;
|
||||||
import google.registry.testing.AppEngineExtension;
|
import google.registry.testing.AppEngineExtension;
|
||||||
import google.registry.testing.FakeClock;
|
import google.registry.testing.FakeClock;
|
||||||
import google.registry.testing.InjectExtension;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
@ -54,8 +52,6 @@ public class TransactionManagerTest {
|
||||||
new TestEntity("entity2", "bar"),
|
new TestEntity("entity2", "bar"),
|
||||||
new TestEntity("entity3", "qux"));
|
new TestEntity("entity3", "qux"));
|
||||||
|
|
||||||
@RegisterExtension public InjectExtension inject = new InjectExtension();
|
|
||||||
|
|
||||||
@RegisterExtension
|
@RegisterExtension
|
||||||
public final AppEngineExtension appEngine =
|
public final AppEngineExtension appEngine =
|
||||||
AppEngineExtension.builder()
|
AppEngineExtension.builder()
|
||||||
|
@ -69,7 +65,6 @@ public class TransactionManagerTest {
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
void setUp() {
|
void setUp() {
|
||||||
inject.setStaticField(Ofy.class, "clock", fakeClock);
|
|
||||||
fakeClock.setAutoIncrementByOneMilli();
|
fakeClock.setAutoIncrementByOneMilli();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,8 +24,6 @@ import static org.mockito.Mockito.mock;
|
||||||
|
|
||||||
import com.google.appengine.api.users.User;
|
import com.google.appengine.api.users.User;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import google.registry.model.ofy.Ofy;
|
|
||||||
import google.registry.request.Action;
|
|
||||||
import google.registry.request.Actions;
|
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;
|
||||||
|
@ -33,7 +31,6 @@ import google.registry.request.auth.UserAuthInfo;
|
||||||
import google.registry.testing.AppEngineExtension;
|
import google.registry.testing.AppEngineExtension;
|
||||||
import google.registry.testing.FakeClock;
|
import google.registry.testing.FakeClock;
|
||||||
import google.registry.testing.FakeResponse;
|
import google.registry.testing.FakeResponse;
|
||||||
import google.registry.testing.InjectExtension;
|
|
||||||
import google.registry.util.Idn;
|
import google.registry.util.Idn;
|
||||||
import google.registry.util.TypeUtils;
|
import google.registry.util.TypeUtils;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -48,8 +45,6 @@ abstract class RdapActionBaseTestCase<A extends RdapActionBase> {
|
||||||
@RegisterExtension
|
@RegisterExtension
|
||||||
public final AppEngineExtension appEngine = AppEngineExtension.builder().withCloudSql().build();
|
public final AppEngineExtension appEngine = AppEngineExtension.builder().withCloudSql().build();
|
||||||
|
|
||||||
@RegisterExtension public final InjectExtension inject = new InjectExtension();
|
|
||||||
|
|
||||||
protected static final AuthResult AUTH_RESULT =
|
protected static final AuthResult AUTH_RESULT =
|
||||||
AuthResult.create(
|
AuthResult.create(
|
||||||
AuthLevel.USER,
|
AuthLevel.USER,
|
||||||
|
@ -72,19 +67,18 @@ abstract class RdapActionBaseTestCase<A extends RdapActionBase> {
|
||||||
|
|
||||||
RdapActionBaseTestCase(Class<A> rdapActionClass) {
|
RdapActionBaseTestCase(Class<A> rdapActionClass) {
|
||||||
this.rdapActionClass = rdapActionClass;
|
this.rdapActionClass = rdapActionClass;
|
||||||
this.actionPath = Actions.getPathForAction(rdapActionClass);
|
actionPath = Actions.getPathForAction(rdapActionClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
public void beforeEachRdapActionBaseTestCase() {
|
public void beforeEachRdapActionBaseTestCase() {
|
||||||
inject.setStaticField(Ofy.class, "clock", clock);
|
|
||||||
action = TypeUtils.instantiate(rdapActionClass);
|
action = TypeUtils.instantiate(rdapActionClass);
|
||||||
action.includeDeletedParam = Optional.empty();
|
action.includeDeletedParam = Optional.empty();
|
||||||
action.formatOutputParam = Optional.empty();
|
action.formatOutputParam = Optional.empty();
|
||||||
action.response = response;
|
action.response = response;
|
||||||
action.rdapJsonFormatter = RdapTestHelper.getTestRdapJsonFormatter(clock);
|
action.rdapJsonFormatter = RdapTestHelper.getTestRdapJsonFormatter(clock);
|
||||||
action.rdapMetrics = rdapMetrics;
|
action.rdapMetrics = rdapMetrics;
|
||||||
action.requestMethod = Action.Method.GET;
|
action.requestMethod = GET;
|
||||||
logout();
|
logout();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,6 @@ import google.registry.model.contact.ContactResource;
|
||||||
import google.registry.model.domain.Domain;
|
import google.registry.model.domain.Domain;
|
||||||
import google.registry.model.eppcommon.StatusValue;
|
import google.registry.model.eppcommon.StatusValue;
|
||||||
import google.registry.model.host.Host;
|
import google.registry.model.host.Host;
|
||||||
import google.registry.model.ofy.Ofy;
|
|
||||||
import google.registry.model.registrar.Registrar;
|
import google.registry.model.registrar.Registrar;
|
||||||
import google.registry.model.registrar.RegistrarPoc;
|
import google.registry.model.registrar.RegistrarPoc;
|
||||||
import google.registry.model.reporting.HistoryEntry;
|
import google.registry.model.reporting.HistoryEntry;
|
||||||
|
@ -51,7 +50,6 @@ import google.registry.rdap.RdapObjectClasses.ReplyPayloadBase;
|
||||||
import google.registry.rdap.RdapObjectClasses.TopLevelReplyObject;
|
import google.registry.rdap.RdapObjectClasses.TopLevelReplyObject;
|
||||||
import google.registry.testing.AppEngineExtension;
|
import google.registry.testing.AppEngineExtension;
|
||||||
import google.registry.testing.FakeClock;
|
import google.registry.testing.FakeClock;
|
||||||
import google.registry.testing.InjectExtension;
|
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
@ -63,8 +61,6 @@ class RdapJsonFormatterTest {
|
||||||
@RegisterExtension
|
@RegisterExtension
|
||||||
public final AppEngineExtension appEngine = AppEngineExtension.builder().withCloudSql().build();
|
public final AppEngineExtension appEngine = AppEngineExtension.builder().withCloudSql().build();
|
||||||
|
|
||||||
@RegisterExtension public final InjectExtension inject = new InjectExtension();
|
|
||||||
|
|
||||||
private final FakeClock clock = new FakeClock(DateTime.parse("1999-01-01T00:00:00Z"));
|
private final FakeClock clock = new FakeClock(DateTime.parse("1999-01-01T00:00:00Z"));
|
||||||
|
|
||||||
private RdapJsonFormatter rdapJsonFormatter;
|
private RdapJsonFormatter rdapJsonFormatter;
|
||||||
|
@ -85,8 +81,6 @@ class RdapJsonFormatterTest {
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
void beforeEach() {
|
void beforeEach() {
|
||||||
inject.setStaticField(Ofy.class, "clock", clock);
|
|
||||||
|
|
||||||
rdapJsonFormatter = RdapTestHelper.getTestRdapJsonFormatter(clock);
|
rdapJsonFormatter = RdapTestHelper.getTestRdapJsonFormatter(clock);
|
||||||
rdapJsonFormatter.rdapAuthorization =
|
rdapJsonFormatter.rdapAuthorization =
|
||||||
RdapAuthorization.create(RdapAuthorization.Role.REGISTRAR, "unicoderegistrar");
|
RdapAuthorization.create(RdapAuthorization.Role.REGISTRAR, "unicoderegistrar");
|
||||||
|
@ -299,7 +293,7 @@ class RdapJsonFormatterTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
private JsonObject loadJson(String expectedFileName) {
|
private JsonObject loadJson(String expectedFileName) {
|
||||||
return new Gson().fromJson(loadFile(this.getClass(), expectedFileName), JsonObject.class);
|
return new Gson().fromJson(loadFile(getClass(), expectedFileName), JsonObject.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -512,7 +506,7 @@ class RdapJsonFormatterTest {
|
||||||
assertThat(
|
assertThat(
|
||||||
TopLevelReplyObject.create(
|
TopLevelReplyObject.create(
|
||||||
new ReplyPayloadBase(BoilerplateType.OTHER) {
|
new ReplyPayloadBase(BoilerplateType.OTHER) {
|
||||||
@JsonableElement public String key = "value";
|
@JsonableElement public static final String key = "value";
|
||||||
},
|
},
|
||||||
rdapJsonFormatter.createTosNotice())
|
rdapJsonFormatter.createTosNotice())
|
||||||
.toJson())
|
.toJson())
|
||||||
|
@ -524,7 +518,7 @@ class RdapJsonFormatterTest {
|
||||||
assertThat(
|
assertThat(
|
||||||
TopLevelReplyObject.create(
|
TopLevelReplyObject.create(
|
||||||
new ReplyPayloadBase(BoilerplateType.DOMAIN) {
|
new ReplyPayloadBase(BoilerplateType.DOMAIN) {
|
||||||
@JsonableElement public String key = "value";
|
@JsonableElement public static final String key = "value";
|
||||||
},
|
},
|
||||||
rdapJsonFormatter.createTosNotice())
|
rdapJsonFormatter.createTosNotice())
|
||||||
.toJson())
|
.toJson())
|
||||||
|
|
|
@ -31,11 +31,9 @@ import com.google.common.collect.ImmutableSetMultimap;
|
||||||
import com.google.common.truth.Truth8;
|
import com.google.common.truth.Truth8;
|
||||||
import google.registry.model.common.Cursor;
|
import google.registry.model.common.Cursor;
|
||||||
import google.registry.model.common.Cursor.CursorType;
|
import google.registry.model.common.Cursor.CursorType;
|
||||||
import google.registry.model.ofy.Ofy;
|
|
||||||
import google.registry.model.tld.Registry;
|
import google.registry.model.tld.Registry;
|
||||||
import google.registry.testing.AppEngineExtension;
|
import google.registry.testing.AppEngineExtension;
|
||||||
import google.registry.testing.FakeClock;
|
import google.registry.testing.FakeClock;
|
||||||
import google.registry.testing.InjectExtension;
|
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
@ -44,8 +42,6 @@ import org.junit.jupiter.api.extension.RegisterExtension;
|
||||||
/** Unit tests for {@link PendingDepositChecker}. */
|
/** Unit tests for {@link PendingDepositChecker}. */
|
||||||
public class PendingDepositCheckerTest {
|
public class PendingDepositCheckerTest {
|
||||||
|
|
||||||
@RegisterExtension public final InjectExtension inject = new InjectExtension();
|
|
||||||
|
|
||||||
@RegisterExtension
|
@RegisterExtension
|
||||||
public final AppEngineExtension appEngine = AppEngineExtension.builder().withCloudSql().build();
|
public final AppEngineExtension appEngine = AppEngineExtension.builder().withCloudSql().build();
|
||||||
|
|
||||||
|
@ -54,7 +50,6 @@ public class PendingDepositCheckerTest {
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
void beforeEach() {
|
void beforeEach() {
|
||||||
inject.setStaticField(Ofy.class, "clock", clock);
|
|
||||||
checker.brdaDayOfWeek = TUESDAY;
|
checker.brdaDayOfWeek = TUESDAY;
|
||||||
checker.brdaInterval = standardDays(7);
|
checker.brdaInterval = standardDays(7);
|
||||||
checker.clock = clock;
|
checker.clock = clock;
|
||||||
|
|
|
@ -37,7 +37,6 @@ import google.registry.model.registrar.Registrar;
|
||||||
import google.registry.model.registrar.Registrar.State;
|
import google.registry.model.registrar.Registrar.State;
|
||||||
import google.registry.request.auth.AuthenticatedRegistrarAccessor.RegistrarAccessDeniedException;
|
import google.registry.request.auth.AuthenticatedRegistrarAccessor.RegistrarAccessDeniedException;
|
||||||
import google.registry.testing.AppEngineExtension;
|
import google.registry.testing.AppEngineExtension;
|
||||||
import google.registry.testing.InjectExtension;
|
|
||||||
import google.registry.util.JdkLoggerConfig;
|
import google.registry.util.JdkLoggerConfig;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
@ -61,8 +60,6 @@ class AuthenticatedRegistrarAccessorTest {
|
||||||
@RegisterExtension
|
@RegisterExtension
|
||||||
final AppEngineExtension appEngine = AppEngineExtension.builder().withCloudSql().build();
|
final AppEngineExtension appEngine = AppEngineExtension.builder().withCloudSql().build();
|
||||||
|
|
||||||
@RegisterExtension final InjectExtension inject = new InjectExtension();
|
|
||||||
|
|
||||||
@Mock private HttpServletRequest req;
|
@Mock private HttpServletRequest req;
|
||||||
@Mock private HttpServletResponse rsp;
|
@Mock private HttpServletResponse rsp;
|
||||||
@Mock private GroupsConnection groupsConnection;
|
@Mock private GroupsConnection groupsConnection;
|
||||||
|
@ -142,7 +139,7 @@ class AuthenticatedRegistrarAccessorTest {
|
||||||
verify(lazyGroupsConnection).get();
|
verify(lazyGroupsConnection).get();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Logged out users don't have access to anything. */
|
/** Logged-out users don't have access to anything. */
|
||||||
@Test
|
@Test
|
||||||
void getAllClientIdWithAccess_loggedOutUser() {
|
void getAllClientIdWithAccess_loggedOutUser() {
|
||||||
AuthenticatedRegistrarAccessor registrarAccessor =
|
AuthenticatedRegistrarAccessor registrarAccessor =
|
||||||
|
|
|
@ -22,7 +22,6 @@ import com.google.common.base.Splitter;
|
||||||
import google.registry.testing.AppEngineExtension;
|
import google.registry.testing.AppEngineExtension;
|
||||||
import google.registry.testing.FakeClock;
|
import google.registry.testing.FakeClock;
|
||||||
import google.registry.testing.FakeUserService;
|
import google.registry.testing.FakeUserService;
|
||||||
import google.registry.testing.InjectExtension;
|
|
||||||
import org.joda.time.Duration;
|
import org.joda.time.Duration;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
@ -34,8 +33,6 @@ class XsrfTokenManagerTest {
|
||||||
@RegisterExtension
|
@RegisterExtension
|
||||||
final AppEngineExtension appEngine = AppEngineExtension.builder().withCloudSql().build();
|
final AppEngineExtension appEngine = AppEngineExtension.builder().withCloudSql().build();
|
||||||
|
|
||||||
@RegisterExtension InjectExtension inject = new InjectExtension();
|
|
||||||
|
|
||||||
private final User testUser = new User("test@example.com", "test@example.com");
|
private final User testUser = new User("test@example.com", "test@example.com");
|
||||||
private final FakeClock clock = new FakeClock(START_OF_TIME);
|
private final FakeClock clock = new FakeClock(START_OF_TIME);
|
||||||
private final FakeUserService userService = new FakeUserService();
|
private final FakeUserService userService = new FakeUserService();
|
||||||
|
@ -81,7 +78,7 @@ class XsrfTokenManagerTest {
|
||||||
void testValidate_tokenTimestampTamperedWith() {
|
void testValidate_tokenTimestampTamperedWith() {
|
||||||
String encodedPart = Splitter.on(':').splitToList(token).get(2);
|
String encodedPart = Splitter.on(':').splitToList(token).get(2);
|
||||||
long fakeTimestamp = clock.nowUtc().plusMillis(1).getMillis();
|
long fakeTimestamp = clock.nowUtc().plusMillis(1).getMillis();
|
||||||
assertThat(xsrfTokenManager.validateToken("1:" + fakeTimestamp + ":" + encodedPart)).isFalse();
|
assertThat(xsrfTokenManager.validateToken("1:" + fakeTimestamp + ':' + encodedPart)).isFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -32,12 +32,8 @@ import google.registry.model.contact.ContactAddress;
|
||||||
import google.registry.model.contact.ContactResource;
|
import google.registry.model.contact.ContactResource;
|
||||||
import google.registry.model.contact.PostalInfo;
|
import google.registry.model.contact.PostalInfo;
|
||||||
import google.registry.model.domain.DesignatedContact;
|
import google.registry.model.domain.DesignatedContact;
|
||||||
import google.registry.model.ofy.Ofy;
|
|
||||||
import google.registry.testing.DatabaseHelper;
|
import google.registry.testing.DatabaseHelper;
|
||||||
import google.registry.testing.FakeClock;
|
|
||||||
import google.registry.testing.InjectExtension;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import org.joda.time.DateTime;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Datastore fixtures for the development webserver.
|
* Datastore fixtures for the development webserver.
|
||||||
|
@ -47,14 +43,6 @@ import org.joda.time.DateTime;
|
||||||
*/
|
*/
|
||||||
public enum Fixture {
|
public enum Fixture {
|
||||||
|
|
||||||
INJECTED_FAKE_CLOCK {
|
|
||||||
@Override
|
|
||||||
public void load() {
|
|
||||||
new InjectExtension()
|
|
||||||
.setStaticField(Ofy.class, "clock", new FakeClock(DateTime.parse("2000-01-01TZ")));
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
/** Fixture of two TLDs, three contacts, two domains, and six hosts. */
|
/** Fixture of two TLDs, three contacts, two domains, and six hosts. */
|
||||||
BASIC {
|
BASIC {
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,211 +0,0 @@
|
||||||
// Copyright 2017 The Nomulus Authors. All Rights Reserved.
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
package google.registry.testing;
|
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkState;
|
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import org.junit.jupiter.api.extension.AfterEachCallback;
|
|
||||||
import org.junit.jupiter.api.extension.BeforeEachCallback;
|
|
||||||
import org.junit.jupiter.api.extension.ExtensionContext;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* JUnit extension for overriding {@code private static} fields during a test.
|
|
||||||
*
|
|
||||||
* <p>This extension uses reflection to change the value of a field while your test is running and
|
|
||||||
* then restore it to its original value after it's done (even if the test fails). The injection
|
|
||||||
* will work even if the field is marked {@code private} (but not if it's {@code final}). The
|
|
||||||
* downside is that if you rename the field in the future, IDE refactoring won't be smart enough to
|
|
||||||
* update the injection site.
|
|
||||||
*
|
|
||||||
* <p>We encourage you to consider using {@link google.registry.util.NonFinalForTesting
|
|
||||||
* @NonFinalForTesting} to document your injected fields.
|
|
||||||
*
|
|
||||||
* <p>This class is a horrible evil hack, but it alleviates you of the toil of having to break
|
|
||||||
* encapsulation by making your fields non-{@code private}, using the {@link
|
|
||||||
* com.google.common.annotations.VisibleForTesting @VisibleForTesting} annotation to document
|
|
||||||
* why you've reduced visibility, creating a temporary field to store the old value, and then
|
|
||||||
* writing an {@link org.junit.After @After} method to restore it. So sometimes it feels good
|
|
||||||
* to be evil; but hopefully one day we'll be able to delete this class and do things
|
|
||||||
* <i>properly</i> with <a href="http://square.github.io/dagger/">Dagger</a> dependency injection.
|
|
||||||
*
|
|
||||||
* <p>You use this class in by declaring it as an {@link
|
|
||||||
* org.junit.jupiter.api.extension.RegisterExtension @RegisterExtension} field and then call
|
|
||||||
* {@link #setStaticField} from either your {@link org.junit.jupiter.api.Test @Test} or {@link
|
|
||||||
* org.junit.jupiter.api.BeforeEach @BeforeEach} methods. For example:
|
|
||||||
*
|
|
||||||
* <pre>
|
|
||||||
* // Doomsday.java
|
|
||||||
* public class Doomsday {
|
|
||||||
*
|
|
||||||
* private static Clock clock = new SystemClock();
|
|
||||||
*
|
|
||||||
* public long getTime() {
|
|
||||||
* return clock.currentTimeMillis();
|
|
||||||
* }
|
|
||||||
* }
|
|
||||||
*
|
|
||||||
* // DoomsdayTest.java
|
|
||||||
* public class DoomsdayTest {
|
|
||||||
*
|
|
||||||
* @RegisterExtension
|
|
||||||
* public InjectExtension inject = new InjectExtension();
|
|
||||||
*
|
|
||||||
* private final FakeClock clock = new FakeClock();
|
|
||||||
*
|
|
||||||
* @BeforeEach
|
|
||||||
* public void beforeEach() {
|
|
||||||
* inject.setStaticField(Doomsday.class, "clock", clock);
|
|
||||||
* }
|
|
||||||
*
|
|
||||||
* @Test
|
|
||||||
* public void test() {
|
|
||||||
* clock.advanceBy(666L);
|
|
||||||
* Doomsday doom = new Doomsday();
|
|
||||||
* assertEquals(666L, doom.getTime());
|
|
||||||
* }
|
|
||||||
* }
|
|
||||||
* </pre>
|
|
||||||
*
|
|
||||||
* @see google.registry.util.NonFinalForTesting
|
|
||||||
*/
|
|
||||||
public class InjectExtension implements AfterEachCallback, BeforeEachCallback {
|
|
||||||
|
|
||||||
private static class Change {
|
|
||||||
private final Field field;
|
|
||||||
@Nullable private Object oldValue;
|
|
||||||
@Nullable private final Object newValue;
|
|
||||||
private boolean active;
|
|
||||||
|
|
||||||
Change(Field field, @Nullable Object oldValue, @Nullable Object newValue, boolean active) {
|
|
||||||
this.field = field;
|
|
||||||
this.oldValue = oldValue;
|
|
||||||
this.newValue = newValue;
|
|
||||||
this.active = active;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private final List<Change> changes = new ArrayList<>();
|
|
||||||
private final Set<Field> injected = new HashSet<>();
|
|
||||||
|
|
||||||
/** Adds the specified field override to those set by the extension. */
|
|
||||||
public InjectExtension withStaticFieldOverride(
|
|
||||||
Class<?> clazz, String fieldName, @Nullable Object newValue) {
|
|
||||||
changes.add(new Change(getField(clazz, fieldName), null, newValue, false));
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets a static field and be restores its current value after the test completes.
|
|
||||||
*
|
|
||||||
* <p>Prefer to use withStaticFieldOverride(), which is more consistent with the extension
|
|
||||||
* pattern.
|
|
||||||
*
|
|
||||||
* <p>The field is allowed to be {@code private}, but it most not be {@code final}.
|
|
||||||
*
|
|
||||||
* <p>This method may be called either from either your {@link
|
|
||||||
* org.junit.jupiter.api.BeforeEach @BeforeEach} method or from the {@link
|
|
||||||
* org.junit.jupiter.api.Test @Test} method itself. However you may not inject the same field
|
|
||||||
* multiple times during the same test.
|
|
||||||
*
|
|
||||||
* @throws IllegalArgumentException if the static field could not be found or modified.
|
|
||||||
* @throws IllegalStateException if the field has already been injected during this test.
|
|
||||||
*/
|
|
||||||
public void setStaticField(Class<?> clazz, String fieldName, @Nullable Object newValue) {
|
|
||||||
Field field = getField(clazz, fieldName);
|
|
||||||
Change change = new Change(field, null, newValue, true);
|
|
||||||
activateChange(change);
|
|
||||||
changes.add(change);
|
|
||||||
injected.add(field);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void beforeEach(ExtensionContext context) {
|
|
||||||
for (Change change : changes) {
|
|
||||||
if (!change.active) {
|
|
||||||
activateChange(change);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void afterEach(ExtensionContext context) {
|
|
||||||
RuntimeException thrown = null;
|
|
||||||
for (Change change : changes) {
|
|
||||||
if (change.active) {
|
|
||||||
try {
|
|
||||||
checkState(
|
|
||||||
change.field.get(null).equals(change.newValue),
|
|
||||||
"Static field value was changed post-injection: %s.%s",
|
|
||||||
change.field.getDeclaringClass().getSimpleName(),
|
|
||||||
change.field.getName());
|
|
||||||
change.field.set(null, change.oldValue);
|
|
||||||
} catch (IllegalArgumentException | IllegalStateException | IllegalAccessException e) {
|
|
||||||
if (thrown == null) {
|
|
||||||
thrown = new RuntimeException(e);
|
|
||||||
} else {
|
|
||||||
thrown.addSuppressed(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
changes.clear();
|
|
||||||
injected.clear();
|
|
||||||
if (thrown != null) {
|
|
||||||
throw thrown;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private Field getField(Class<?> clazz, String fieldName) {
|
|
||||||
try {
|
|
||||||
return clazz.getDeclaredField(fieldName);
|
|
||||||
} catch (SecurityException | NoSuchFieldException e) {
|
|
||||||
throw new IllegalArgumentException(
|
|
||||||
String.format("Static field not found: %s.%s", clazz.getSimpleName(), fieldName), e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void activateChange(Change change) {
|
|
||||||
Class<?> clazz = change.field.getDeclaringClass();
|
|
||||||
try {
|
|
||||||
change.field.setAccessible(true);
|
|
||||||
change.oldValue = change.field.get(null);
|
|
||||||
} catch (IllegalArgumentException | IllegalAccessException e) {
|
|
||||||
throw new IllegalArgumentException(
|
|
||||||
String.format(
|
|
||||||
"Static field not gettable: %s.%s", clazz.getSimpleName(), change.field.getName()),
|
|
||||||
e);
|
|
||||||
}
|
|
||||||
checkState(
|
|
||||||
!injected.contains(change.field),
|
|
||||||
"Static field already injected: %s.%s",
|
|
||||||
clazz.getSimpleName(),
|
|
||||||
change.field.getName());
|
|
||||||
try {
|
|
||||||
change.field.set(null, change.newValue);
|
|
||||||
} catch (IllegalArgumentException | IllegalAccessException e) {
|
|
||||||
throw new IllegalArgumentException(
|
|
||||||
String.format(
|
|
||||||
"Static field not settable: %s.%s", clazz.getSimpleName(), change.field.getName()),
|
|
||||||
e);
|
|
||||||
}
|
|
||||||
change.active = true;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -24,11 +24,9 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
|
|
||||||
import google.registry.model.domain.Domain;
|
import google.registry.model.domain.Domain;
|
||||||
import google.registry.model.domain.launch.LaunchNotice;
|
import google.registry.model.domain.launch.LaunchNotice;
|
||||||
import google.registry.model.ofy.Ofy;
|
|
||||||
import google.registry.model.registrar.Registrar.Type;
|
import google.registry.model.registrar.Registrar.Type;
|
||||||
import google.registry.testing.AppEngineExtension;
|
import google.registry.testing.AppEngineExtension;
|
||||||
import google.registry.testing.FakeClock;
|
import google.registry.testing.FakeClock;
|
||||||
import google.registry.testing.InjectExtension;
|
|
||||||
import google.registry.testing.TaskQueueHelper.TaskMatcher;
|
import google.registry.testing.TaskQueueHelper.TaskMatcher;
|
||||||
import google.registry.util.Clock;
|
import google.registry.util.Clock;
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
|
@ -45,15 +43,12 @@ public class LordnTaskUtilsTest {
|
||||||
public final AppEngineExtension appEngine =
|
public final AppEngineExtension appEngine =
|
||||||
AppEngineExtension.builder().withCloudSql().withClock(clock).withTaskQueue().build();
|
AppEngineExtension.builder().withCloudSql().withClock(clock).withTaskQueue().build();
|
||||||
|
|
||||||
@RegisterExtension public final InjectExtension inject = new InjectExtension();
|
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
void beforeEach() {
|
void beforeEach() {
|
||||||
createTld("example");
|
createTld("example");
|
||||||
inject.setStaticField(Ofy.class, "clock", clock);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Domain.Builder newDomainBuilder() {
|
private static Domain.Builder newDomainBuilder() {
|
||||||
return new Domain.Builder()
|
return new Domain.Builder()
|
||||||
.setDomainName("fleece.example")
|
.setDomainName("fleece.example")
|
||||||
.setPersistedCurrentSponsorRegistrarId("TheRegistrar")
|
.setPersistedCurrentSponsorRegistrarId("TheRegistrar")
|
||||||
|
|
|
@ -48,14 +48,12 @@ import com.google.common.base.VerifyException;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import google.registry.model.domain.Domain;
|
import google.registry.model.domain.Domain;
|
||||||
import google.registry.model.domain.launch.LaunchNotice;
|
import google.registry.model.domain.launch.LaunchNotice;
|
||||||
import google.registry.model.ofy.Ofy;
|
|
||||||
import google.registry.model.tld.Registry;
|
import google.registry.model.tld.Registry;
|
||||||
import google.registry.testing.AppEngineExtension;
|
import google.registry.testing.AppEngineExtension;
|
||||||
import google.registry.testing.DatabaseHelper;
|
import google.registry.testing.DatabaseHelper;
|
||||||
import google.registry.testing.FakeClock;
|
import google.registry.testing.FakeClock;
|
||||||
import google.registry.testing.FakeSleeper;
|
import google.registry.testing.FakeSleeper;
|
||||||
import google.registry.testing.FakeUrlConnectionService;
|
import google.registry.testing.FakeUrlConnectionService;
|
||||||
import google.registry.testing.InjectExtension;
|
|
||||||
import google.registry.testing.TaskQueueHelper.TaskMatcher;
|
import google.registry.testing.TaskQueueHelper.TaskMatcher;
|
||||||
import google.registry.util.Retrier;
|
import google.registry.util.Retrier;
|
||||||
import google.registry.util.TaskQueueUtils;
|
import google.registry.util.TaskQueueUtils;
|
||||||
|
@ -95,8 +93,6 @@ class NordnUploadActionTest {
|
||||||
public final AppEngineExtension appEngine =
|
public final AppEngineExtension appEngine =
|
||||||
AppEngineExtension.builder().withCloudSql().withClock(clock).withTaskQueue().build();
|
AppEngineExtension.builder().withCloudSql().withClock(clock).withTaskQueue().build();
|
||||||
|
|
||||||
@RegisterExtension public final InjectExtension inject = new InjectExtension();
|
|
||||||
|
|
||||||
private final LordnRequestInitializer lordnRequestInitializer =
|
private final LordnRequestInitializer lordnRequestInitializer =
|
||||||
new LordnRequestInitializer(Optional.of("attack"));
|
new LordnRequestInitializer(Optional.of("attack"));
|
||||||
private final NordnUploadAction action = new NordnUploadAction();
|
private final NordnUploadAction action = new NordnUploadAction();
|
||||||
|
@ -108,7 +104,6 @@ class NordnUploadActionTest {
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
void beforeEach() throws Exception {
|
void beforeEach() throws Exception {
|
||||||
inject.setStaticField(Ofy.class, "clock", clock);
|
|
||||||
when(httpUrlConnection.getInputStream())
|
when(httpUrlConnection.getInputStream())
|
||||||
.thenReturn(new ByteArrayInputStream("Success".getBytes(UTF_8)));
|
.thenReturn(new ByteArrayInputStream("Success".getBytes(UTF_8)));
|
||||||
when(httpUrlConnection.getResponseCode()).thenReturn(SC_ACCEPTED);
|
when(httpUrlConnection.getResponseCode()).thenReturn(SC_ACCEPTED);
|
||||||
|
@ -164,7 +159,6 @@ class NordnUploadActionTest {
|
||||||
() -> NordnUploadAction.convertTasksToCsv(null, clock.nowUtc(), "header"));
|
() -> NordnUploadAction.convertTasksToCsv(null, clock.nowUtc(), "header"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
@Test
|
@Test
|
||||||
void test_loadAllTasks_retryLogic_thirdTrysTheCharm() {
|
void test_loadAllTasks_retryLogic_thirdTrysTheCharm() {
|
||||||
Queue queue = mock(Queue.class);
|
Queue queue = mock(Queue.class);
|
||||||
|
@ -230,7 +224,7 @@ class NordnUploadActionTest {
|
||||||
void testRun_claimsMode_payloadMatchesClaimsCsv() {
|
void testRun_claimsMode_payloadMatchesClaimsCsv() {
|
||||||
persistClaimsModeDomain();
|
persistClaimsModeDomain();
|
||||||
action.run();
|
action.run();
|
||||||
assertThat(new String(connectionOutputStream.toByteArray(), UTF_8)).contains(CLAIMS_CSV);
|
assertThat(connectionOutputStream.toString(UTF_8)).contains(CLAIMS_CSV);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -249,7 +243,7 @@ class NordnUploadActionTest {
|
||||||
void testRun_sunriseMode_payloadMatchesSunriseCsv() {
|
void testRun_sunriseMode_payloadMatchesSunriseCsv() {
|
||||||
persistSunriseModeDomain();
|
persistSunriseModeDomain();
|
||||||
action.run();
|
action.run();
|
||||||
assertThat(new String(connectionOutputStream.toByteArray(), UTF_8)).contains(SUNRISE_CSV);
|
assertThat(connectionOutputStream.toString(UTF_8)).contains(SUNRISE_CSV);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -258,7 +252,7 @@ class NordnUploadActionTest {
|
||||||
when(httpUrlConnection.getInputStream()).thenReturn(new ByteArrayInputStream(new byte[] {}));
|
when(httpUrlConnection.getInputStream()).thenReturn(new ByteArrayInputStream(new byte[] {}));
|
||||||
persistSunriseModeDomain();
|
persistSunriseModeDomain();
|
||||||
action.run();
|
action.run();
|
||||||
assertThat(new String(connectionOutputStream.toByteArray(), UTF_8)).contains(SUNRISE_CSV);
|
assertThat(connectionOutputStream.toString(UTF_8)).contains(SUNRISE_CSV);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -288,7 +282,7 @@ class NordnUploadActionTest {
|
||||||
assertThrows(UrlConnectionException.class, action::run);
|
assertThrows(UrlConnectionException.class, action::run);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void persistClaimsModeDomain() {
|
private static void persistClaimsModeDomain() {
|
||||||
Domain domain = DatabaseHelper.newDomain("claims-landrush1.tld");
|
Domain domain = DatabaseHelper.newDomain("claims-landrush1.tld");
|
||||||
persistDomainAndEnqueueLordn(
|
persistDomainAndEnqueueLordn(
|
||||||
domain
|
domain
|
||||||
|
|
|
@ -21,7 +21,6 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
import google.registry.config.RegistryConfig.ConfigModule.TmchCaMode;
|
import google.registry.config.RegistryConfig.ConfigModule.TmchCaMode;
|
||||||
import google.registry.testing.AppEngineExtension;
|
import google.registry.testing.AppEngineExtension;
|
||||||
import google.registry.testing.FakeClock;
|
import google.registry.testing.FakeClock;
|
||||||
import google.registry.testing.InjectExtension;
|
|
||||||
import google.registry.tmch.TmchXmlSignature.CertificateSignatureException;
|
import google.registry.tmch.TmchXmlSignature.CertificateSignatureException;
|
||||||
import java.security.cert.CertificateExpiredException;
|
import java.security.cert.CertificateExpiredException;
|
||||||
import java.security.cert.CertificateNotYetValidException;
|
import java.security.cert.CertificateNotYetValidException;
|
||||||
|
@ -42,8 +41,6 @@ class TmchXmlSignatureTest {
|
||||||
@RegisterExtension
|
@RegisterExtension
|
||||||
public final AppEngineExtension appEngine = AppEngineExtension.builder().withCloudSql().build();
|
public final AppEngineExtension appEngine = AppEngineExtension.builder().withCloudSql().build();
|
||||||
|
|
||||||
@RegisterExtension public final InjectExtension inject = new InjectExtension();
|
|
||||||
|
|
||||||
// This should be a date which falls within the validity range of the test files contained in the
|
// This should be a date which falls within the validity range of the test files contained in the
|
||||||
// testdata/active directory. Note that test files claiming to be valid for a particular date
|
// testdata/active directory. Note that test files claiming to be valid for a particular date
|
||||||
// range in the file header may not actually be valid the whole time, because they contain an
|
// range in the file header may not actually be valid the whole time, because they contain an
|
||||||
|
|
|
@ -25,7 +25,6 @@ import com.google.common.collect.ImmutableList;
|
||||||
import google.registry.model.domain.Domain;
|
import google.registry.model.domain.Domain;
|
||||||
import google.registry.model.domain.DomainHistory;
|
import google.registry.model.domain.DomainHistory;
|
||||||
import google.registry.model.domain.DomainHistory.DomainHistoryId;
|
import google.registry.model.domain.DomainHistory.DomainHistoryId;
|
||||||
import google.registry.model.ofy.Ofy;
|
|
||||||
import google.registry.model.poll.PollMessage;
|
import google.registry.model.poll.PollMessage;
|
||||||
import google.registry.model.poll.PollMessage.Autorenew;
|
import google.registry.model.poll.PollMessage.Autorenew;
|
||||||
import google.registry.model.poll.PollMessage.OneTime;
|
import google.registry.model.poll.PollMessage.OneTime;
|
||||||
|
@ -33,24 +32,19 @@ import google.registry.model.reporting.HistoryEntry;
|
||||||
import google.registry.persistence.VKey;
|
import google.registry.persistence.VKey;
|
||||||
import google.registry.testing.DatabaseHelper;
|
import google.registry.testing.DatabaseHelper;
|
||||||
import google.registry.testing.FakeClock;
|
import google.registry.testing.FakeClock;
|
||||||
import google.registry.testing.InjectExtension;
|
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
|
||||||
|
|
||||||
/** Unit tests for {@link AckPollMessagesCommand}. */
|
/** Unit tests for {@link AckPollMessagesCommand}. */
|
||||||
public class AckPollMessagesCommandTest extends CommandTestCase<AckPollMessagesCommand> {
|
public class AckPollMessagesCommandTest extends CommandTestCase<AckPollMessagesCommand> {
|
||||||
|
|
||||||
private FakeClock clock = new FakeClock(DateTime.parse("2015-02-04T08:16:32.064Z"));
|
private final FakeClock clock = new FakeClock(DateTime.parse("2015-02-04T08:16:32.064Z"));
|
||||||
|
|
||||||
@RegisterExtension public final InjectExtension inject = new InjectExtension();
|
|
||||||
|
|
||||||
private DomainHistory domainHistory;
|
private DomainHistory domainHistory;
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
final void beforeEach() {
|
final void beforeEach() {
|
||||||
inject.setStaticField(Ofy.class, "clock", clock);
|
|
||||||
command.clock = clock;
|
command.clock = clock;
|
||||||
createTld("tld");
|
createTld("tld");
|
||||||
Domain domain =
|
Domain domain =
|
||||||
|
|
|
@ -18,20 +18,14 @@ import static google.registry.testing.DatabaseHelper.createTlds;
|
||||||
import static google.registry.testing.DatabaseHelper.persistActiveDomain;
|
import static google.registry.testing.DatabaseHelper.persistActiveDomain;
|
||||||
import static google.registry.testing.DatabaseHelper.persistDeletedDomain;
|
import static google.registry.testing.DatabaseHelper.persistDeletedDomain;
|
||||||
|
|
||||||
import google.registry.model.ofy.Ofy;
|
|
||||||
import google.registry.testing.InjectExtension;
|
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
|
||||||
|
|
||||||
/** Unit tests for {@link CountDomainsCommand}. */
|
/** Unit tests for {@link CountDomainsCommand}. */
|
||||||
public class CountDomainsCommandTest extends CommandTestCase<CountDomainsCommand> {
|
public class CountDomainsCommandTest extends CommandTestCase<CountDomainsCommand> {
|
||||||
|
|
||||||
@RegisterExtension public final InjectExtension inject = new InjectExtension();
|
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
final void beforeEach() {
|
final void beforeEach() {
|
||||||
inject.setStaticField(Ofy.class, "clock", fakeClock);
|
|
||||||
command.clock = fakeClock;
|
command.clock = fakeClock;
|
||||||
createTlds("foo", "bar", "baz", "qux");
|
createTlds("foo", "bar", "baz", "qux");
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,9 +40,7 @@ import com.google.common.collect.Range;
|
||||||
import com.google.common.net.MediaType;
|
import com.google.common.net.MediaType;
|
||||||
import google.registry.flows.certs.CertificateChecker;
|
import google.registry.flows.certs.CertificateChecker;
|
||||||
import google.registry.flows.certs.CertificateChecker.InsecureCertificateException;
|
import google.registry.flows.certs.CertificateChecker.InsecureCertificateException;
|
||||||
import google.registry.model.ofy.Ofy;
|
|
||||||
import google.registry.model.registrar.Registrar;
|
import google.registry.model.registrar.Registrar;
|
||||||
import google.registry.testing.InjectExtension;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
@ -51,7 +49,6 @@ import org.joda.money.Money;
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
|
||||||
import org.mockito.ArgumentMatchers;
|
import org.mockito.ArgumentMatchers;
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
|
|
||||||
|
@ -60,11 +57,9 @@ class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarCommand>
|
||||||
|
|
||||||
@Mock private AppEngineConnection connection;
|
@Mock private AppEngineConnection connection;
|
||||||
|
|
||||||
@RegisterExtension final InjectExtension inject = new InjectExtension();
|
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
void beforeEach() {
|
void beforeEach() {
|
||||||
inject.setStaticField(Ofy.class, "clock", fakeClock);
|
|
||||||
command.setConnection(connection);
|
command.setConnection(connection);
|
||||||
command.certificateChecker =
|
command.certificateChecker =
|
||||||
new CertificateChecker(
|
new CertificateChecker(
|
||||||
|
|
|
@ -26,25 +26,19 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
|
|
||||||
import com.beust.jcommander.ParameterException;
|
import com.beust.jcommander.ParameterException;
|
||||||
import google.registry.model.domain.Domain;
|
import google.registry.model.domain.Domain;
|
||||||
import google.registry.model.ofy.Ofy;
|
|
||||||
import google.registry.model.poll.PollMessage;
|
import google.registry.model.poll.PollMessage;
|
||||||
import google.registry.model.reporting.HistoryEntry;
|
import google.registry.model.reporting.HistoryEntry;
|
||||||
import google.registry.testing.InjectExtension;
|
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
|
||||||
|
|
||||||
/** Unit tests for {@link EnqueuePollMessageCommand}. */
|
/** Unit tests for {@link EnqueuePollMessageCommand}. */
|
||||||
class EnqueuePollMessageCommandTest extends CommandTestCase<EnqueuePollMessageCommand> {
|
class EnqueuePollMessageCommandTest extends CommandTestCase<EnqueuePollMessageCommand> {
|
||||||
|
|
||||||
@RegisterExtension final InjectExtension inject = new InjectExtension();
|
|
||||||
|
|
||||||
private Domain domain;
|
private Domain domain;
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
void beforeEach() {
|
void beforeEach() {
|
||||||
createTld("tld");
|
createTld("tld");
|
||||||
inject.setStaticField(Ofy.class, "clock", fakeClock);
|
|
||||||
domain = persistActiveDomain("example.tld");
|
domain = persistActiveDomain("example.tld");
|
||||||
persistNewRegistrar("AdminRegistrar");
|
persistNewRegistrar("AdminRegistrar");
|
||||||
command.registryAdminClientId = "AdminRegistrar";
|
command.registryAdminClientId = "AdminRegistrar";
|
||||||
|
|
|
@ -21,10 +21,8 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
import com.beust.jcommander.ParameterException;
|
import com.beust.jcommander.ParameterException;
|
||||||
import google.registry.testing.CloudTasksHelper;
|
import google.registry.testing.CloudTasksHelper;
|
||||||
import google.registry.testing.CloudTasksHelper.TaskMatcher;
|
import google.registry.testing.CloudTasksHelper.TaskMatcher;
|
||||||
import google.registry.testing.InjectExtension;
|
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
|
||||||
import org.mockito.junit.jupiter.MockitoSettings;
|
import org.mockito.junit.jupiter.MockitoSettings;
|
||||||
import org.mockito.quality.Strictness;
|
import org.mockito.quality.Strictness;
|
||||||
|
|
||||||
|
@ -33,8 +31,6 @@ import org.mockito.quality.Strictness;
|
||||||
public class GenerateEscrowDepositCommandTest
|
public class GenerateEscrowDepositCommandTest
|
||||||
extends CommandTestCase<GenerateEscrowDepositCommand> {
|
extends CommandTestCase<GenerateEscrowDepositCommand> {
|
||||||
|
|
||||||
@RegisterExtension public final InjectExtension inject = new InjectExtension();
|
|
||||||
|
|
||||||
CloudTasksHelper cloudTasksHelper = new CloudTasksHelper();
|
CloudTasksHelper cloudTasksHelper = new CloudTasksHelper();
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
|
|
|
@ -22,7 +22,6 @@ import google.registry.keyring.api.Keyring;
|
||||||
import google.registry.rde.Ghostryde;
|
import google.registry.rde.Ghostryde;
|
||||||
import google.registry.testing.BouncyCastleProviderExtension;
|
import google.registry.testing.BouncyCastleProviderExtension;
|
||||||
import google.registry.testing.FakeKeyringModule;
|
import google.registry.testing.FakeKeyringModule;
|
||||||
import google.registry.testing.InjectExtension;
|
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
@ -51,8 +50,6 @@ class GhostrydeCommandTest extends CommandTestCase<GhostrydeCommand> {
|
||||||
+ "Haply I may remember, \n"
|
+ "Haply I may remember, \n"
|
||||||
+ " And haply may forget. \n").getBytes(UTF_8);
|
+ " And haply may forget. \n").getBytes(UTF_8);
|
||||||
|
|
||||||
@RegisterExtension final InjectExtension inject = new InjectExtension();
|
|
||||||
|
|
||||||
@RegisterExtension
|
@RegisterExtension
|
||||||
final BouncyCastleProviderExtension bouncy = new BouncyCastleProviderExtension();
|
final BouncyCastleProviderExtension bouncy = new BouncyCastleProviderExtension();
|
||||||
|
|
||||||
|
@ -78,7 +75,7 @@ class GhostrydeCommandTest extends CommandTestCase<GhostrydeCommand> {
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
() -> runCommand("--input=" + inputFile.toString(), "--output=bar.dat"));
|
() -> runCommand("--input=" + inputFile, "--output=bar.dat"));
|
||||||
assertThat(thrown).hasMessageThat().isEqualTo("Please specify either --encrypt or --decrypt");
|
assertThat(thrown).hasMessageThat().isEqualTo("Please specify either --encrypt or --decrypt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,8 +84,7 @@ class GhostrydeCommandTest extends CommandTestCase<GhostrydeCommand> {
|
||||||
Path inputFile = Files.createFile(tmpDir.resolve("foo.dat"));
|
Path inputFile = Files.createFile(tmpDir.resolve("foo.dat"));
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class, () -> runCommand("--encrypt", "--input=" + inputFile));
|
||||||
() -> runCommand("--encrypt", "--input=" + inputFile.toString()));
|
|
||||||
assertThat(thrown).hasMessageThat().isEqualTo("--output path is required in --encrypt mode");
|
assertThat(thrown).hasMessageThat().isEqualTo("--output path is required in --encrypt mode");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,13 +22,10 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
import com.beust.jcommander.ParameterException;
|
import com.beust.jcommander.ParameterException;
|
||||||
import google.registry.model.common.Cursor;
|
import google.registry.model.common.Cursor;
|
||||||
import google.registry.model.common.Cursor.CursorType;
|
import google.registry.model.common.Cursor.CursorType;
|
||||||
import google.registry.model.ofy.Ofy;
|
|
||||||
import google.registry.model.tld.Registry;
|
import google.registry.model.tld.Registry;
|
||||||
import google.registry.testing.InjectExtension;
|
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
|
||||||
|
|
||||||
/** Unit tests for {@link ListCursorsCommand}. */
|
/** Unit tests for {@link ListCursorsCommand}. */
|
||||||
public class ListCursorsCommandTest extends CommandTestCase<ListCursorsCommand> {
|
public class ListCursorsCommandTest extends CommandTestCase<ListCursorsCommand> {
|
||||||
|
@ -39,12 +36,9 @@ public class ListCursorsCommandTest extends CommandTestCase<ListCursorsCommand>
|
||||||
private static final String HEADER_TWO =
|
private static final String HEADER_TWO =
|
||||||
"--------------------------------------------------------------------------";
|
"--------------------------------------------------------------------------";
|
||||||
|
|
||||||
@RegisterExtension public final InjectExtension inject = new InjectExtension();
|
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
void beforeEach() {
|
void beforeEach() {
|
||||||
fakeClock.setTo(DateTime.parse("1984-12-21T06:07:08.789Z"));
|
fakeClock.setTo(DateTime.parse("1984-12-21T06:07:08.789Z"));
|
||||||
inject.setStaticField(Ofy.class, "clock", fakeClock);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -22,11 +22,9 @@ import static org.mockito.Mockito.verify;
|
||||||
import com.beust.jcommander.ParameterException;
|
import com.beust.jcommander.ParameterException;
|
||||||
import com.google.common.collect.ImmutableMultimap;
|
import com.google.common.collect.ImmutableMultimap;
|
||||||
import google.registry.testing.AppEngineAdminApiHelper;
|
import google.registry.testing.AppEngineAdminApiHelper;
|
||||||
import google.registry.testing.InjectExtension;
|
|
||||||
import google.registry.util.AppEngineServiceUtils;
|
import google.registry.util.AppEngineServiceUtils;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
import org.mockito.junit.jupiter.MockitoSettings;
|
import org.mockito.junit.jupiter.MockitoSettings;
|
||||||
import org.mockito.quality.Strictness;
|
import org.mockito.quality.Strictness;
|
||||||
|
@ -34,11 +32,9 @@ import org.mockito.quality.Strictness;
|
||||||
/** Unit tests for {@link SetNumInstancesCommand}. */
|
/** Unit tests for {@link SetNumInstancesCommand}. */
|
||||||
public class SetNumInstancesCommandTest extends CommandTestCase<SetNumInstancesCommand> {
|
public class SetNumInstancesCommandTest extends CommandTestCase<SetNumInstancesCommand> {
|
||||||
|
|
||||||
@RegisterExtension public final InjectExtension inject = new InjectExtension();
|
|
||||||
|
|
||||||
@Mock AppEngineServiceUtils appEngineServiceUtils;
|
@Mock AppEngineServiceUtils appEngineServiceUtils;
|
||||||
|
|
||||||
private final String projectId = "domain-registry-test";
|
private static final String projectId = "domain-registry-test";
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
void beforeEach() {
|
void beforeEach() {
|
||||||
|
|
|
@ -41,25 +41,19 @@ import google.registry.model.contact.ContactResource;
|
||||||
import google.registry.model.domain.Domain;
|
import google.registry.model.domain.Domain;
|
||||||
import google.registry.model.domain.DomainHistory;
|
import google.registry.model.domain.DomainHistory;
|
||||||
import google.registry.model.eppcommon.StatusValue;
|
import google.registry.model.eppcommon.StatusValue;
|
||||||
import google.registry.model.ofy.Ofy;
|
|
||||||
import google.registry.model.poll.PollMessage;
|
import google.registry.model.poll.PollMessage;
|
||||||
import google.registry.testing.DatabaseHelper;
|
import google.registry.testing.DatabaseHelper;
|
||||||
import google.registry.testing.InjectExtension;
|
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
|
||||||
|
|
||||||
/** Unit tests for {@link UnrenewDomainCommand}. */
|
/** Unit tests for {@link UnrenewDomainCommand}. */
|
||||||
public class UnrenewDomainCommandTest extends CommandTestCase<UnrenewDomainCommand> {
|
public class UnrenewDomainCommandTest extends CommandTestCase<UnrenewDomainCommand> {
|
||||||
|
|
||||||
@RegisterExtension public final InjectExtension inject = new InjectExtension();
|
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
void beforeEach() {
|
void beforeEach() {
|
||||||
createTld("tld");
|
createTld("tld");
|
||||||
fakeClock.setTo(DateTime.parse("2016-12-06T13:55:01Z"));
|
fakeClock.setTo(DateTime.parse("2016-12-06T13:55:01Z"));
|
||||||
inject.setStaticField(Ofy.class, "clock", fakeClock);
|
|
||||||
command.clock = fakeClock;
|
command.clock = fakeClock;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,17 +42,14 @@ import google.registry.model.domain.DomainHistory;
|
||||||
import google.registry.model.domain.GracePeriod;
|
import google.registry.model.domain.GracePeriod;
|
||||||
import google.registry.model.eppcommon.StatusValue;
|
import google.registry.model.eppcommon.StatusValue;
|
||||||
import google.registry.model.host.Host;
|
import google.registry.model.host.Host;
|
||||||
import google.registry.model.ofy.Ofy;
|
|
||||||
import google.registry.persistence.VKey;
|
import google.registry.persistence.VKey;
|
||||||
import google.registry.testing.DatabaseHelper;
|
import google.registry.testing.DatabaseHelper;
|
||||||
import google.registry.testing.InjectExtension;
|
|
||||||
import google.registry.util.CapturingLogHandler;
|
import google.registry.util.CapturingLogHandler;
|
||||||
import google.registry.util.JdkLoggerConfig;
|
import google.registry.util.JdkLoggerConfig;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import org.junit.jupiter.api.AfterEach;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
|
||||||
|
|
||||||
/** Unit tests for {@link UpdateDomainCommand}. */
|
/** Unit tests for {@link UpdateDomainCommand}. */
|
||||||
class UpdateDomainCommandTest extends EppToolCommandTestCase<UpdateDomainCommand> {
|
class UpdateDomainCommandTest extends EppToolCommandTestCase<UpdateDomainCommand> {
|
||||||
|
@ -61,11 +58,8 @@ class UpdateDomainCommandTest extends EppToolCommandTestCase<UpdateDomainCommand
|
||||||
|
|
||||||
private Domain domain;
|
private Domain domain;
|
||||||
|
|
||||||
@RegisterExtension public final InjectExtension inject = new InjectExtension();
|
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
void beforeEach() {
|
void beforeEach() {
|
||||||
inject.setStaticField(Ofy.class, "clock", fakeClock);
|
|
||||||
command.clock = fakeClock;
|
command.clock = fakeClock;
|
||||||
domain = persistActiveDomain("example.tld");
|
domain = persistActiveDomain("example.tld");
|
||||||
JdkLoggerConfig.getConfig(UpdateDomainCommand.class).addHandler(logHandler);
|
JdkLoggerConfig.getConfig(UpdateDomainCommand.class).addHandler(logHandler);
|
||||||
|
|
|
@ -28,7 +28,6 @@ import google.registry.request.HttpException.BadRequestException;
|
||||||
import google.registry.request.HttpException.InternalServerErrorException;
|
import google.registry.request.HttpException.InternalServerErrorException;
|
||||||
import google.registry.request.Response;
|
import google.registry.request.Response;
|
||||||
import google.registry.testing.AppEngineExtension;
|
import google.registry.testing.AppEngineExtension;
|
||||||
import google.registry.testing.InjectExtension;
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||||
|
@ -39,8 +38,6 @@ class CreateGroupsActionTest {
|
||||||
@RegisterExtension
|
@RegisterExtension
|
||||||
final AppEngineExtension appEngine = AppEngineExtension.builder().withCloudSql().build();
|
final AppEngineExtension appEngine = AppEngineExtension.builder().withCloudSql().build();
|
||||||
|
|
||||||
@RegisterExtension final InjectExtension inject = new InjectExtension();
|
|
||||||
|
|
||||||
private final DirectoryGroupsConnection connection = mock(DirectoryGroupsConnection.class);
|
private final DirectoryGroupsConnection connection = mock(DirectoryGroupsConnection.class);
|
||||||
private final Response response = mock(Response.class);
|
private final Response response = mock(Response.class);
|
||||||
|
|
||||||
|
|
|
@ -31,17 +31,14 @@ import static org.mockito.Mockito.verifyNoMoreInteractions;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import google.registry.dns.DnsQueue;
|
import google.registry.dns.DnsQueue;
|
||||||
import google.registry.model.ofy.Ofy;
|
|
||||||
import google.registry.testing.AppEngineExtension;
|
import google.registry.testing.AppEngineExtension;
|
||||||
import google.registry.testing.FakeClock;
|
import google.registry.testing.FakeClock;
|
||||||
import google.registry.testing.FakeResponse;
|
import google.registry.testing.FakeResponse;
|
||||||
import google.registry.testing.InjectExtension;
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import org.apache.http.HttpStatus;
|
import org.apache.http.HttpStatus;
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
import org.joda.time.Duration;
|
import org.joda.time.Duration;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Order;
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||||
import org.mockito.ArgumentCaptor;
|
import org.mockito.ArgumentCaptor;
|
||||||
|
@ -53,24 +50,18 @@ public class RefreshDnsForAllDomainsActionTest {
|
||||||
private final FakeClock clock = new FakeClock(DateTime.parse("2020-02-02T02:02:02Z"));
|
private final FakeClock clock = new FakeClock(DateTime.parse("2020-02-02T02:02:02Z"));
|
||||||
private final DnsQueue dnsQueue = mock(DnsQueue.class);
|
private final DnsQueue dnsQueue = mock(DnsQueue.class);
|
||||||
private RefreshDnsForAllDomainsAction action;
|
private RefreshDnsForAllDomainsAction action;
|
||||||
private FakeResponse response = new FakeResponse();
|
private final FakeResponse response = new FakeResponse();
|
||||||
|
|
||||||
@RegisterExtension
|
@RegisterExtension
|
||||||
public final AppEngineExtension appEngine =
|
public final AppEngineExtension appEngine =
|
||||||
AppEngineExtension.builder().withCloudSql().withLocalModules().withTaskQueue().build();
|
AppEngineExtension.builder().withCloudSql().withLocalModules().withTaskQueue().build();
|
||||||
|
|
||||||
@Order(Order.DEFAULT - 1)
|
|
||||||
@RegisterExtension
|
|
||||||
public final InjectExtension inject =
|
|
||||||
new InjectExtension().withStaticFieldOverride(Ofy.class, "clock", clock);
|
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
void beforeEach() {
|
void beforeEach() {
|
||||||
action = new RefreshDnsForAllDomainsAction();
|
action = new RefreshDnsForAllDomainsAction();
|
||||||
action.smearMinutes = 1;
|
action.smearMinutes = 1;
|
||||||
action.random = new Random();
|
action.random = new Random();
|
||||||
action.random.setSeed(123L);
|
action.random.setSeed(123L);
|
||||||
action.response = new FakeResponse();
|
|
||||||
action.clock = clock;
|
action.clock = clock;
|
||||||
action.dnsQueue = dnsQueue;
|
action.dnsQueue = dnsQueue;
|
||||||
action.response = response;
|
action.response = response;
|
||||||
|
|
|
@ -36,7 +36,6 @@ import com.google.common.collect.ImmutableSetMultimap;
|
||||||
import com.google.common.collect.ImmutableSortedMap;
|
import com.google.common.collect.ImmutableSortedMap;
|
||||||
import com.google.common.truth.Truth;
|
import com.google.common.truth.Truth;
|
||||||
import google.registry.flows.certs.CertificateChecker;
|
import google.registry.flows.certs.CertificateChecker;
|
||||||
import google.registry.model.ofy.Ofy;
|
|
||||||
import google.registry.model.registrar.RegistrarPoc;
|
import google.registry.model.registrar.RegistrarPoc;
|
||||||
import google.registry.request.JsonActionRunner;
|
import google.registry.request.JsonActionRunner;
|
||||||
import google.registry.request.JsonResponse;
|
import google.registry.request.JsonResponse;
|
||||||
|
@ -48,7 +47,6 @@ import google.registry.request.auth.UserAuthInfo;
|
||||||
import google.registry.testing.AppEngineExtension;
|
import google.registry.testing.AppEngineExtension;
|
||||||
import google.registry.testing.CloudTasksHelper;
|
import google.registry.testing.CloudTasksHelper;
|
||||||
import google.registry.testing.FakeClock;
|
import google.registry.testing.FakeClock;
|
||||||
import google.registry.testing.InjectExtension;
|
|
||||||
import google.registry.ui.server.SendEmailUtils;
|
import google.registry.ui.server.SendEmailUtils;
|
||||||
import google.registry.util.EmailMessage;
|
import google.registry.util.EmailMessage;
|
||||||
import google.registry.util.SendEmailService;
|
import google.registry.util.SendEmailService;
|
||||||
|
@ -81,8 +79,6 @@ public abstract class RegistrarSettingsActionTestCase {
|
||||||
public final AppEngineExtension appEngine =
|
public final AppEngineExtension appEngine =
|
||||||
AppEngineExtension.builder().withCloudSql().withClock(clock).withTaskQueue().build();
|
AppEngineExtension.builder().withCloudSql().withClock(clock).withTaskQueue().build();
|
||||||
|
|
||||||
@RegisterExtension public final InjectExtension inject = new InjectExtension();
|
|
||||||
|
|
||||||
@Mock HttpServletRequest req;
|
@Mock HttpServletRequest req;
|
||||||
@Mock HttpServletResponse rsp;
|
@Mock HttpServletResponse rsp;
|
||||||
@Mock SendEmailService emailService;
|
@Mock SendEmailService emailService;
|
||||||
|
@ -129,7 +125,6 @@ public abstract class RegistrarSettingsActionTestCase {
|
||||||
clock);
|
clock);
|
||||||
action.cloudTasksUtils = cloudTasksHelper.getTestCloudTasksUtils();
|
action.cloudTasksUtils = cloudTasksHelper.getTestCloudTasksUtils();
|
||||||
|
|
||||||
inject.setStaticField(Ofy.class, "clock", clock);
|
|
||||||
when(req.getMethod()).thenReturn("POST");
|
when(req.getMethod()).thenReturn("POST");
|
||||||
when(rsp.getWriter()).thenReturn(new PrintWriter(writer));
|
when(rsp.getWriter()).thenReturn(new PrintWriter(writer));
|
||||||
when(req.getContentType()).thenReturn("application/json");
|
when(req.getContentType()).thenReturn("application/json");
|
||||||
|
|
|
@ -47,7 +47,6 @@ import google.registry.model.contact.ContactResource;
|
||||||
import google.registry.model.domain.Domain;
|
import google.registry.model.domain.Domain;
|
||||||
import google.registry.model.eppcommon.Trid;
|
import google.registry.model.eppcommon.Trid;
|
||||||
import google.registry.model.host.Host;
|
import google.registry.model.host.Host;
|
||||||
import google.registry.model.ofy.Ofy;
|
|
||||||
import google.registry.model.registrar.Registrar;
|
import google.registry.model.registrar.Registrar;
|
||||||
import google.registry.model.tld.Registry;
|
import google.registry.model.tld.Registry;
|
||||||
import google.registry.model.transfer.DomainTransferData;
|
import google.registry.model.transfer.DomainTransferData;
|
||||||
|
@ -57,7 +56,6 @@ import google.registry.testing.FakeClock;
|
||||||
import google.registry.testing.FakeResponse;
|
import google.registry.testing.FakeResponse;
|
||||||
import google.registry.testing.FakeSleeper;
|
import google.registry.testing.FakeSleeper;
|
||||||
import google.registry.testing.FullFieldsTestEntityHelper;
|
import google.registry.testing.FullFieldsTestEntityHelper;
|
||||||
import google.registry.testing.InjectExtension;
|
|
||||||
import google.registry.testing.TestCacheExtension;
|
import google.registry.testing.TestCacheExtension;
|
||||||
import google.registry.util.Retrier;
|
import google.registry.util.Retrier;
|
||||||
import google.registry.whois.WhoisMetrics.WhoisMetric;
|
import google.registry.whois.WhoisMetrics.WhoisMetric;
|
||||||
|
@ -80,8 +78,6 @@ public class WhoisActionTest {
|
||||||
public final AppEngineExtension appEngine =
|
public final AppEngineExtension appEngine =
|
||||||
AppEngineExtension.builder().withCloudSql().withClock(clock).build();
|
AppEngineExtension.builder().withCloudSql().withClock(clock).build();
|
||||||
|
|
||||||
@RegisterExtension public final InjectExtension inject = new InjectExtension();
|
|
||||||
|
|
||||||
@RegisterExtension
|
@RegisterExtension
|
||||||
public final TestCacheExtension testCacheExtension =
|
public final TestCacheExtension testCacheExtension =
|
||||||
new TestCacheExtension.Builder()
|
new TestCacheExtension.Builder()
|
||||||
|
@ -109,7 +105,6 @@ public class WhoisActionTest {
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
void setUp() {
|
void setUp() {
|
||||||
createTlds("lol", "xn--q9jyb4c", "1.test");
|
createTlds("lol", "xn--q9jyb4c", "1.test");
|
||||||
inject.setStaticField(Ofy.class, "clock", clock);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -119,7 +114,7 @@ public class WhoisActionTest {
|
||||||
assertThat(response.getPayload()).isEqualTo(loadFile("whois_action_no_command.txt"));
|
assertThat(response.getPayload()).isEqualTo(loadFile("whois_action_no_command.txt"));
|
||||||
}
|
}
|
||||||
|
|
||||||
private Domain makeDomainWithRegistrar(Registrar registrar) {
|
private static Domain makeDomainWithRegistrar(Registrar registrar) {
|
||||||
return makeDomain(
|
return makeDomain(
|
||||||
"cat.lol",
|
"cat.lol",
|
||||||
persistResource(makeContactResource("5372808-ERL", "Goblin Market", "lol@cat.lol")),
|
persistResource(makeContactResource("5372808-ERL", "Goblin Market", "lol@cat.lol")),
|
||||||
|
@ -287,8 +282,7 @@ public class WhoisActionTest {
|
||||||
persistResource(FullFieldsTestEntityHelper.makeHost("ns1.cat.lol", "1.2.3.4")),
|
persistResource(FullFieldsTestEntityHelper.makeHost("ns1.cat.lol", "1.2.3.4")),
|
||||||
persistResource(
|
persistResource(
|
||||||
FullFieldsTestEntityHelper.makeHost("ns2.cat.lol", "bad:f00d:cafe::15:beef")),
|
FullFieldsTestEntityHelper.makeHost("ns2.cat.lol", "bad:f00d:cafe::15:beef")),
|
||||||
persistResource(
|
persistResource(registrar = makeRegistrar("example", "Example Registrar", ACTIVE)))
|
||||||
(registrar = makeRegistrar("example", "Example Registrar", ACTIVE))))
|
|
||||||
.asBuilder()
|
.asBuilder()
|
||||||
.setDeletionTime(clock.nowUtc().minusDays(1))
|
.setDeletionTime(clock.nowUtc().minusDays(1))
|
||||||
.build());
|
.build());
|
||||||
|
@ -339,7 +333,7 @@ public class WhoisActionTest {
|
||||||
persistResource(
|
persistResource(
|
||||||
FullFieldsTestEntityHelper.makeHost("ns2.google.lol", "4311::f143")),
|
FullFieldsTestEntityHelper.makeHost("ns2.google.lol", "4311::f143")),
|
||||||
persistResource(
|
persistResource(
|
||||||
(registrar = makeRegistrar("example", "Example Registrar", ACTIVE))))
|
registrar = makeRegistrar("example", "Example Registrar", ACTIVE)))
|
||||||
.asBuilder()
|
.asBuilder()
|
||||||
.setCreationTimeForTest(clock.nowUtc())
|
.setCreationTimeForTest(clock.nowUtc())
|
||||||
.build());
|
.build());
|
||||||
|
|
|
@ -36,14 +36,12 @@ import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import google.registry.model.contact.ContactResource;
|
import google.registry.model.contact.ContactResource;
|
||||||
import google.registry.model.ofy.Ofy;
|
|
||||||
import google.registry.model.registrar.Registrar;
|
import google.registry.model.registrar.Registrar;
|
||||||
import google.registry.model.tld.Registry;
|
import google.registry.model.tld.Registry;
|
||||||
import google.registry.testing.AppEngineExtension;
|
import google.registry.testing.AppEngineExtension;
|
||||||
import google.registry.testing.FakeClock;
|
import google.registry.testing.FakeClock;
|
||||||
import google.registry.testing.FakeResponse;
|
import google.registry.testing.FakeResponse;
|
||||||
import google.registry.testing.FullFieldsTestEntityHelper;
|
import google.registry.testing.FullFieldsTestEntityHelper;
|
||||||
import google.registry.testing.InjectExtension;
|
|
||||||
import google.registry.whois.WhoisMetrics.WhoisMetric;
|
import google.registry.whois.WhoisMetrics.WhoisMetric;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.Reader;
|
import java.io.Reader;
|
||||||
|
@ -65,8 +63,6 @@ class WhoisHttpActionTest {
|
||||||
@RegisterExtension
|
@RegisterExtension
|
||||||
final AppEngineExtension appEngine = AppEngineExtension.builder().withCloudSql().build();
|
final AppEngineExtension appEngine = AppEngineExtension.builder().withCloudSql().build();
|
||||||
|
|
||||||
@RegisterExtension final InjectExtension inject = new InjectExtension();
|
|
||||||
|
|
||||||
private final FakeResponse response = new FakeResponse();
|
private final FakeResponse response = new FakeResponse();
|
||||||
private final FakeClock clock = new FakeClock(DateTime.parse("2009-06-29T20:13:00Z"));
|
private final FakeClock clock = new FakeClock(DateTime.parse("2009-06-29T20:13:00Z"));
|
||||||
|
|
||||||
|
@ -88,7 +84,6 @@ class WhoisHttpActionTest {
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
void beforeEach() {
|
void beforeEach() {
|
||||||
createTlds("lol", "xn--q9jyb4c", "1.test");
|
createTlds("lol", "xn--q9jyb4c", "1.test");
|
||||||
inject.setStaticField(Ofy.class, "clock", clock);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
Loading…
Add table
Reference in a new issue