google-nomulus/javatests/google/registry/flows/EppLifecycleLoginTest.java
mcilwain c1643fa3cd 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
2017-04-26 10:56:13 -04:00

40 lines
1.5 KiB
Java

// 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.flows;
import static com.google.common.truth.Truth.assertThat;
import google.registry.testing.AppEngineRule;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
/** Tests for login lifecycle. */
@RunWith(JUnit4.class)
public class EppLifecycleLoginTest extends EppTestCase {
@Rule
public final AppEngineRule appEngine =
AppEngineRule.builder().withDatastore().withTaskQueue().build();
@Test
public void testLoginAndLogout_recordClientIdInEppMetric() throws Exception {
assertCommandAndResponse("login_valid.xml", "login_response.xml");
assertThat(getRecordedEppMetric().getClientId()).hasValue("NewRegistrar");
assertCommandAndResponse("logout.xml", "logout_response.xml");
assertThat(getRecordedEppMetric().getClientId()).hasValue("NewRegistrar");
}
}