Set clock used to validate Tmch signature in tests

The signature has expired on Mon Jun 25 23:59:59 UTC 2018.

Instead of fixing all the test files with a new signed mark, we inject the
clock used to validate the signature.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=202116721
This commit is contained in:
guyben 2018-06-26 06:09:22 -07:00 committed by Ben McIlwain
parent 94044847ee
commit 44c517f111
5 changed files with 14 additions and 1 deletions

View file

@ -20,6 +20,7 @@ import static google.registry.config.RegistryConfig.getSingletonCacheRefreshDura
import static google.registry.util.ResourceUtils.readResourceUtf8;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
@ -119,7 +120,8 @@ public final class TmchCertificateAuthority {
}});
@NonFinalForTesting
private static Clock clock = new SystemClock();
@VisibleForTesting
public static Clock clock = new SystemClock();
/**
* Check that {@code cert} is signed by the ICANN TMCH CA root and not revoked.

View file

@ -20,6 +20,7 @@ import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSortedMap;
import google.registry.model.registry.Registry.TldState;
import google.registry.testing.AppEngineRule;
import google.registry.tmch.TmchCertificateAuthority;
import google.registry.util.DateTimeUtils;
import org.joda.time.DateTime;
import org.junit.Before;
@ -42,6 +43,8 @@ public class EppLifecycleDomainApplicationTest extends EppTestCase {
@Before
public void initTld() {
// Setting the clock used for SignedMark signature validity.
TmchCertificateAuthority.clock = () -> DateTime.parse("2015-01-01TZ");
createTld("example", ImmutableSortedMap.of(
DateTimeUtils.START_OF_TIME, TldState.SUNRISE,
START_OF_GA, TldState.GENERAL_AVAILABILITY));

View file

@ -45,6 +45,7 @@ import google.registry.model.registry.Registry;
import google.registry.model.registry.Registry.TldState;
import google.registry.model.reporting.HistoryEntry.Type;
import google.registry.testing.AppEngineRule;
import google.registry.tmch.TmchCertificateAuthority;
import java.util.Objects;
import java.util.Optional;
import org.joda.money.Money;
@ -65,6 +66,8 @@ public class EppLifecycleDomainTest extends EppTestCase {
@Before
public void initTld() {
// Setting the clock used for SignedMark signature validity.
TmchCertificateAuthority.clock = () -> DateTime.parse("2015-01-01TZ");
createTlds("example", "tld");
}

View file

@ -151,6 +151,7 @@ import google.registry.model.reporting.DomainTransactionRecord.TransactionReport
import google.registry.model.reporting.HistoryEntry;
import google.registry.monitoring.whitebox.EppMetric;
import google.registry.testing.TaskQueueHelper.TaskMatcher;
import google.registry.tmch.TmchCertificateAuthority;
import java.util.Map;
import org.joda.money.CurrencyUnit;
import org.joda.money.Money;
@ -172,6 +173,8 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
@Before
public void initCreateTest() {
// Setting the clock used for SignedMark signature validity.
TmchCertificateAuthority.clock = () -> DateTime.parse("2015-01-01TZ");
createTld("tld");
persistResource(
Registry.get("tld")

View file

@ -73,6 +73,8 @@ public class UpdateSmdCommandTest extends CommandTestCase<UpdateSmdCommand> {
@Before
public void init() {
// Setting the clock used for SignedMark signature validity.
TmchCertificateAuthority.clock = () -> DateTime.parse("2015-01-01TZ");
inject.setStaticField(Ofy.class, "clock", clock);
createTld("xn--q9jyb4c");
clock.advanceOneMilli();