mirror of
https://github.com/google/nomulus.git
synced 2025-07-23 11:16:04 +02:00
As part of b/36599833, this makes FlowReporter log the tld(s) of every domain flow it executes, so we can provide ICANN reporting totals on a per-TLD basis. It also adds several other fields that we're computing anyway and which seem useful, particularly for debugging any issues we see in production with the data that we're attempting to record for ICANN reporting. The full set of fields is: - commandType (e.g. "create", "info", "transfer") - resourceType* (e.g. "domain", "contact", "host") - flowClassName (e.g. "ContactCreateFlow", "DomainRestoreRequestFlow") - targetId* (e.g. "ns1.foo.com", "bar.org", "contact-1234") - targetIds* - plural of the above, for multi-resource checks - tld** (e.g. "com", "co.uk") - extracted from targetId, lowercased - tlds** - plural of the above, deduplicated, for multi-resource checks * = only non-empty for resource flows (not e.g. login, logout, poll) ** = only non-empty for domain flows Note that TLD extraction is deliberately very lenient to avoid the complexity overhead of double-validation of the domain names in the common case. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=154070794
163 lines
5.7 KiB
Java
163 lines
5.7 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.domain;
|
|
|
|
import static google.registry.testing.DatastoreHelper.assertNoBillingEvents;
|
|
import static google.registry.testing.DatastoreHelper.createTld;
|
|
import static google.registry.testing.DatastoreHelper.persistResource;
|
|
|
|
import com.google.common.collect.ImmutableMap;
|
|
import com.google.common.collect.ImmutableSet;
|
|
import google.registry.flows.ResourceFlowTestCase;
|
|
import google.registry.flows.domain.ClaimsCheckFlow.ClaimsCheckNotAllowedInSunrise;
|
|
import google.registry.flows.domain.DomainFlowUtils.BadCommandForRegistryPhaseException;
|
|
import google.registry.flows.domain.DomainFlowUtils.ClaimsPeriodEndedException;
|
|
import google.registry.flows.domain.DomainFlowUtils.NotAuthorizedForTldException;
|
|
import google.registry.flows.domain.DomainFlowUtils.TldDoesNotExistException;
|
|
import google.registry.flows.exceptions.TooManyResourceChecksException;
|
|
import google.registry.model.domain.DomainResource;
|
|
import google.registry.model.registrar.Registrar;
|
|
import google.registry.model.registry.Registry;
|
|
import google.registry.model.registry.Registry.TldState;
|
|
import google.registry.testing.DatastoreHelper;
|
|
import org.junit.Before;
|
|
import org.junit.Test;
|
|
|
|
/** Unit tests for {@link ClaimsCheckFlow}. */
|
|
public class ClaimsCheckFlowTest extends ResourceFlowTestCase<ClaimsCheckFlow, DomainResource> {
|
|
|
|
public ClaimsCheckFlowTest() {
|
|
setEppInput("domain_check_claims.xml");
|
|
}
|
|
|
|
@Before
|
|
public void initCheckTest() {
|
|
createTld("tld");
|
|
persistResource(Registry.get("tld").asBuilder().build());
|
|
}
|
|
|
|
protected void doSuccessfulTest(String expectedXmlFilename) throws Exception {
|
|
assertTransactionalFlow(false);
|
|
assertNoHistory(); // Checks don't create a history event.
|
|
assertNoBillingEvents(); // Checks are always free.
|
|
runFlowAssertResponse(readFile(expectedXmlFilename));
|
|
}
|
|
|
|
@Test
|
|
public void testSuccess_noClaims() throws Exception {
|
|
doSuccessfulTest("domain_check_claims_response_none.xml");
|
|
}
|
|
|
|
@Test
|
|
public void testSuccess_sunrush() throws Exception {
|
|
createTld("tld", TldState.SUNRUSH);
|
|
persistResource(Registry.get("tld").asBuilder().build());
|
|
doSuccessfulTest("domain_check_claims_response_none.xml");
|
|
}
|
|
|
|
@Test
|
|
public void testSuccess_quietPeriod() throws Exception {
|
|
createTld("tld", TldState.QUIET_PERIOD);
|
|
persistResource(Registry.get("tld").asBuilder().build());
|
|
doSuccessfulTest("domain_check_claims_response_none.xml");
|
|
}
|
|
|
|
@Test
|
|
public void testSuccess_oneClaim() throws Exception {
|
|
persistClaimsList(
|
|
ImmutableMap.of("example2", "2013041500/2/6/9/rJ1NrDO92vDsAzf7EQzgjX4R0000000001"));
|
|
doSuccessfulTest("domain_check_claims_response.xml");
|
|
}
|
|
|
|
|
|
@Test
|
|
public void testSuccess_multipleTlds() throws Exception {
|
|
setEppInput("domain_check_claims_multiple_tlds.xml");
|
|
createTld("tld1");
|
|
createTld("tld2");
|
|
persistClaimsList(
|
|
ImmutableMap.of("example", "2013041500/2/6/9/rJ1NrDO92vDsAzf7EQzgjX4R0000000001"));
|
|
doSuccessfulTest("domain_check_claims_response_multiple_tlds.xml");
|
|
}
|
|
|
|
@Test
|
|
public void testSuccess_50IdsAllowed() throws Exception {
|
|
// Make sure we don't have a regression that reduces the number of allowed checks.
|
|
setEppInput("domain_check_claims_50.xml");
|
|
runFlow();
|
|
}
|
|
|
|
@Test
|
|
public void testFailure_TooManyIds() throws Exception {
|
|
setEppInput("domain_check_claims_51.xml");
|
|
thrown.expect(TooManyResourceChecksException.class);
|
|
runFlow();
|
|
}
|
|
|
|
@Test
|
|
public void testFailure_tldDoesntExist() throws Exception {
|
|
setEppInput("domain_check_claims_bad_tld.xml");
|
|
thrown.expect(TldDoesNotExistException.class);
|
|
runFlow();
|
|
}
|
|
|
|
@Test
|
|
public void testFailure_notAuthorizedForTld() throws Exception {
|
|
DatastoreHelper.persistResource(
|
|
Registrar.loadByClientId("TheRegistrar")
|
|
.asBuilder()
|
|
.setAllowedTlds(ImmutableSet.<String>of())
|
|
.build());
|
|
thrown.expect(NotAuthorizedForTldException.class);
|
|
runFlow();
|
|
}
|
|
|
|
@Test
|
|
public void testFailure_predelgation() throws Exception {
|
|
createTld("tld", TldState.PREDELEGATION);
|
|
persistResource(Registry.get("tld").asBuilder().build());
|
|
setEppInput("domain_check_claims.xml");
|
|
thrown.expect(BadCommandForRegistryPhaseException.class);
|
|
runFlow();
|
|
}
|
|
|
|
@Test
|
|
public void testFailure_sunrise() throws Exception {
|
|
createTld("tld", TldState.SUNRISE);
|
|
persistResource(Registry.get("tld").asBuilder().build());
|
|
setEppInput("domain_check_claims.xml");
|
|
thrown.expect(ClaimsCheckNotAllowedInSunrise.class);
|
|
runFlow();
|
|
}
|
|
|
|
@Test
|
|
public void testFailure_multipleTlds_oneHasEndedClaims() throws Exception {
|
|
createTld("tld1");
|
|
createTld("tld2");
|
|
persistResource(Registry.get("tld2").asBuilder()
|
|
.setClaimsPeriodEnd(clock.nowUtc().minusMillis(1))
|
|
.build());
|
|
setEppInput("domain_check_claims_multiple_tlds.xml");
|
|
thrown.expect(ClaimsPeriodEndedException.class);
|
|
runFlow();
|
|
}
|
|
|
|
@Test
|
|
public void testIcannActivityReportField_getsLogged() throws Exception {
|
|
runFlow();
|
|
assertIcannReportingActivityFieldLogged("srs-dom-check");
|
|
assertTldsFieldLogged("tld");
|
|
}
|
|
}
|