google-nomulus/javatests/google/registry/tmch/TmchTestDataExpirationTest.java
mcilwain 892c1fc707 Update signed marks files and add an expiration test
We'll continue to use injected clocks for the rest of our tests that use signed marks files, so that they don't all fail after the current validity period. The new test TmchTestDataExpirationTest will let us know when the files are expired, so we can update them.

All updated test data files come from https://newgtlds.icann.org/en/about/trademark-clearinghouse/registries-registrars

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=202208196
2018-06-27 15:28:53 -04:00

63 lines
2.4 KiB
Java

// Copyright 2018 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.tmch;
import static google.registry.testing.TestDataHelper.listFiles;
import static org.joda.time.DateTimeZone.UTC;
import com.google.common.flogger.FluentLogger;
import google.registry.config.RegistryConfig.ConfigModule.TmchCaMode;
import google.registry.flows.EppException;
import google.registry.flows.domain.DomainFlowTmchUtils;
import google.registry.model.smd.EncodedSignedMark;
import google.registry.testing.AppEngineRule;
import google.registry.util.ResourceUtils;
import java.nio.file.Path;
import org.joda.time.DateTime;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
/** Tests that the ICANN testing signed mark files are valid and not expired. */
@RunWith(JUnit4.class)
public class TmchTestDataExpirationTest {
@Rule public final AppEngineRule appEngine = AppEngineRule.builder().withDatastore().build();
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
@Test
public void testActiveSignedMarkFiles_areValidAndNotExpired() throws Exception {
DomainFlowTmchUtils tmchUtils =
new DomainFlowTmchUtils(
new TmchXmlSignature(new TmchCertificateAuthority(TmchCaMode.PILOT)));
for (Path path : listFiles(TmchTestDataExpirationTest.class, "testdata/active/")) {
if (path.toString().endsWith(".smd")) {
logger.atInfo().log("Verifying: %s", path);
String tmchData = ResourceUtils.readResourceUtf8(path.toUri().toURL());
EncodedSignedMark smd = TmchData.readEncodedSignedMark(tmchData);
try {
tmchUtils.verifyEncodedSignedMark(smd, DateTime.now(UTC));
} catch (EppException e) {
throw new AssertionError("Error verifying signed mark " + path, e);
}
} else {
logger.atInfo().log("Ignored: %s", path);
}
}
}
}