mirror of
https://github.com/google/nomulus.git
synced 2025-05-15 08:57:12 +02:00
Un-Ignore a test in DomainApplicationCreateFlowTest
A little injection-foo makes this test possible to run. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=154442134
This commit is contained in:
parent
8514f734e4
commit
927eb43cbc
6 changed files with 32 additions and 15 deletions
|
@ -56,7 +56,7 @@ import org.xml.sax.SAXException;
|
|||
|
||||
/** Helper class for verifying TMCH certificates and XML signatures. */
|
||||
@ThreadSafe
|
||||
public final class TmchXmlSignature {
|
||||
public class TmchXmlSignature {
|
||||
|
||||
@VisibleForTesting
|
||||
final TmchCertificateAuthority tmchCertificateAuthority;
|
||||
|
|
|
@ -25,7 +25,6 @@ import static org.joda.time.DateTimeZone.UTC;
|
|||
import static org.joda.time.Duration.standardDays;
|
||||
|
||||
import com.googlecode.objectify.Key;
|
||||
import google.registry.config.RegistryConfig.ConfigModule.TmchCaMode;
|
||||
import google.registry.flows.EppTestComponent.FakesAndMocksModule;
|
||||
import google.registry.model.domain.DomainResource;
|
||||
import google.registry.model.ofy.Ofy;
|
||||
|
@ -74,8 +73,7 @@ public class EppCommitLogsTest extends ShardableTestCase {
|
|||
sessionMetadata.setClientId("TheRegistrar");
|
||||
DaggerEppTestComponent.builder()
|
||||
.fakesAndMocksModule(
|
||||
FakesAndMocksModule.create(
|
||||
clock, TmchCaMode.PILOT, EppMetric.builderForRequest("request-id-1", clock)))
|
||||
FakesAndMocksModule.create(clock, EppMetric.builderForRequest("request-id-1", clock)))
|
||||
.build()
|
||||
.startRequest()
|
||||
.flowComponentBuilder()
|
||||
|
|
|
@ -23,7 +23,6 @@ import static javax.servlet.http.HttpServletResponse.SC_OK;
|
|||
import static org.joda.time.DateTimeZone.UTC;
|
||||
|
||||
import com.google.common.net.MediaType;
|
||||
import google.registry.config.RegistryConfig.ConfigModule.TmchCaMode;
|
||||
import google.registry.flows.EppTestComponent.FakesAndMocksModule;
|
||||
import google.registry.model.ofy.Ofy;
|
||||
import google.registry.monitoring.whitebox.EppMetric;
|
||||
|
@ -118,7 +117,7 @@ public class EppTestCase extends ShardableTestCase {
|
|||
handler.response = response;
|
||||
eppMetricBuilder = EppMetric.builderForRequest("request-id-1", clock);
|
||||
handler.eppController = DaggerEppTestComponent.builder()
|
||||
.fakesAndMocksModule(FakesAndMocksModule.create(clock, TmchCaMode.PILOT, eppMetricBuilder))
|
||||
.fakesAndMocksModule(FakesAndMocksModule.create(clock, eppMetricBuilder))
|
||||
.build()
|
||||
.startRequest()
|
||||
.eppController();
|
||||
|
|
|
@ -63,15 +63,23 @@ interface EppTestComponent {
|
|||
|
||||
public static FakesAndMocksModule create() {
|
||||
FakeClock clock = new FakeClock();
|
||||
return create(clock, TmchCaMode.PILOT, EppMetric.builderForRequest("request-id-1", clock));
|
||||
return create(clock, EppMetric.builderForRequest("request-id-1", clock));
|
||||
}
|
||||
|
||||
public static FakesAndMocksModule create(FakeClock clock, EppMetric.Builder metricBuilder) {
|
||||
return create(
|
||||
clock,
|
||||
metricBuilder,
|
||||
new TmchXmlSignature(new TmchCertificateAuthority(TmchCaMode.PILOT)));
|
||||
}
|
||||
|
||||
public static FakesAndMocksModule create(
|
||||
FakeClock clock, TmchCaMode tmchCaMode, EppMetric.Builder eppMetricBuilder) {
|
||||
FakeClock clock,
|
||||
EppMetric.Builder eppMetricBuilder,
|
||||
TmchXmlSignature tmchXmlSignature) {
|
||||
FakesAndMocksModule instance = new FakesAndMocksModule();
|
||||
instance.clock = clock;
|
||||
instance.domainFlowTmchUtils =
|
||||
new DomainFlowTmchUtils(new TmchXmlSignature(new TmchCertificateAuthority(tmchCaMode)));
|
||||
instance.domainFlowTmchUtils = new DomainFlowTmchUtils(tmchXmlSignature);
|
||||
instance.sleeper = new FakeSleeper(clock);
|
||||
instance.dnsQueue = DnsQueue.create();
|
||||
instance.metricBuilder = eppMetricBuilder;
|
||||
|
|
|
@ -56,6 +56,8 @@ import google.registry.testing.FakeHttpSession;
|
|||
import google.registry.testing.InjectRule;
|
||||
import google.registry.testing.ShardableTestCase;
|
||||
import google.registry.testing.TestDataHelper;
|
||||
import google.registry.tmch.TmchCertificateAuthority;
|
||||
import google.registry.tmch.TmchXmlSignature;
|
||||
import google.registry.util.TypeUtils.TypeInstantiator;
|
||||
import google.registry.xml.ValidationMode;
|
||||
import java.util.List;
|
||||
|
@ -98,6 +100,7 @@ public abstract class FlowTestCase<F extends Flow> extends ShardableTestCase {
|
|||
protected FakeClock clock = new FakeClock(DateTime.now(UTC));
|
||||
protected TransportCredentials credentials = new PasswordOnlyTransportCredentials();
|
||||
protected EppRequestSource eppRequestSource = EppRequestSource.UNIT_TEST;
|
||||
protected TmchXmlSignature testTmchXmlSignature = null;
|
||||
|
||||
private EppMetric.Builder eppMetricBuilder;
|
||||
|
||||
|
@ -288,10 +291,12 @@ public abstract class FlowTestCase<F extends Flow> extends ShardableTestCase {
|
|||
assertThat(FlowPicker.getFlowClass(eppLoader.getEpp()))
|
||||
.isEqualTo(new TypeInstantiator<F>(getClass()){}.getExactType());
|
||||
// Run the flow.
|
||||
TmchXmlSignature tmchXmlSignature =
|
||||
testTmchXmlSignature != null
|
||||
? testTmchXmlSignature
|
||||
: new TmchXmlSignature(new TmchCertificateAuthority(tmchCaMode));
|
||||
return DaggerEppTestComponent.builder()
|
||||
.fakesAndMocksModule(
|
||||
FakesAndMocksModule.create(
|
||||
clock, tmchCaMode, EppMetric.builderForRequest("request-id-1", clock)))
|
||||
.fakesAndMocksModule(FakesAndMocksModule.create(clock, eppMetricBuilder, tmchXmlSignature))
|
||||
.build()
|
||||
.startRequest()
|
||||
.flowComponentBuilder()
|
||||
|
|
|
@ -126,6 +126,8 @@ import google.registry.model.reporting.HistoryEntry;
|
|||
import google.registry.model.smd.SignedMarkRevocationList;
|
||||
import google.registry.testing.DatastoreHelper;
|
||||
import google.registry.tmch.TmchCertificateAuthority;
|
||||
import google.registry.tmch.TmchXmlSignature;
|
||||
import java.security.GeneralSecurityException;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
@ -134,7 +136,6 @@ import org.joda.money.Money;
|
|||
import org.joda.time.DateTime;
|
||||
import org.joda.time.Interval;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
/** Unit tests for {@link DomainApplicationCreateFlow}. */
|
||||
|
@ -291,13 +292,19 @@ public class DomainApplicationCreateFlowTest
|
|||
}
|
||||
|
||||
@Test
|
||||
@Ignore("I'm not sure how to get this to throw without creating a custom CA / certs")
|
||||
public void testFailure_signedMarkCertificateCorrupt() throws Exception {
|
||||
useTmchProdCert();
|
||||
createTld("tld", TldState.SUNRUSH);
|
||||
setEppInput("domain_create_sunrush_encoded_signed_mark_certificate_corrupt.xml");
|
||||
persistContactsAndHosts();
|
||||
clock.advanceOneMilli();
|
||||
// It's hard to make the real verification code throw a GeneralSecurityException. Instead,
|
||||
// replace the TmchXmlSignature with a stub that throws it for us.
|
||||
this.testTmchXmlSignature = new TmchXmlSignature(null) {
|
||||
@Override
|
||||
public void verify(byte[] smdXml) throws GeneralSecurityException {
|
||||
throw new GeneralSecurityException();
|
||||
}};
|
||||
thrown.expect(SignedMarkCertificateInvalidException.class);
|
||||
runFlow();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue