Correctly set clientId on EPP metrics in LoginFlow

This wasn't being recorded correctly because the clientId is only
set in LoginFlow after the flow succeeds, whereas we were
previously logging the clientId before executing the flow. This
adds special handling for LoginFlow. Note that we only set the
metric label to the clientId for valid registrar logins, to ensure
that metric cardinality doesn't grow unbounded (as it might if we
used every arbitrary string passed in as an attempted login).

This also refactors creation and handling of FakesAndMocksModule so
as to be able to make test assertions about EPP metrics from
integration flow tests.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=154048280
This commit is contained in:
mcilwain 2017-04-24 07:44:31 -07:00 committed by Ben McIlwain
parent 7dc3ddfc14
commit c1643fa3cd
7 changed files with 98 additions and 35 deletions

View file

@ -53,27 +53,31 @@ interface EppTestComponent {
@Module
static class FakesAndMocksModule {
final BigQueryMetricsEnqueuer metricsEnqueuer;
final DnsQueue dnsQueue;
final DomainFlowTmchUtils domainFlowTmchUtils;
final EppMetric.Builder metricBuilder;
final FakeClock clock;
final ModulesService modulesService;
final Sleeper sleeper;
private BigQueryMetricsEnqueuer metricsEnqueuer;
private DnsQueue dnsQueue;
private DomainFlowTmchUtils domainFlowTmchUtils;
private EppMetric.Builder metricBuilder;
private FakeClock clock;
private ModulesService modulesService;
private Sleeper sleeper;
FakesAndMocksModule() {
this(new FakeClock(), TmchCaMode.PILOT);
public static FakesAndMocksModule create() {
FakeClock clock = new FakeClock();
return create(clock, TmchCaMode.PILOT, EppMetric.builderForRequest("request-id-1", clock));
}
FakesAndMocksModule(FakeClock clock, TmchCaMode tmchCaMode) {
this.clock = clock;
this.domainFlowTmchUtils =
public static FakesAndMocksModule create(
FakeClock clock, TmchCaMode tmchCaMode, EppMetric.Builder eppMetricBuilder) {
FakesAndMocksModule instance = new FakesAndMocksModule();
instance.clock = clock;
instance.domainFlowTmchUtils =
new DomainFlowTmchUtils(new TmchXmlSignature(new TmchCertificateAuthority(tmchCaMode)));
this.sleeper = new FakeSleeper(clock);
this.dnsQueue = DnsQueue.create();
this.metricBuilder = EppMetric.builderForRequest("request-id-1", clock);
this.modulesService = mock(ModulesService.class);
this.metricsEnqueuer = mock(BigQueryMetricsEnqueuer.class);
instance.sleeper = new FakeSleeper(clock);
instance.dnsQueue = DnsQueue.create();
instance.metricBuilder = eppMetricBuilder;
instance.modulesService = mock(ModulesService.class);
instance.metricsEnqueuer = mock(BigQueryMetricsEnqueuer.class);
return instance;
}
@Provides