Make FlowRunner log ICANN activity report field name

As part of b/36599833, this makes FlowRunner log the appropriate ICANN activity
report field name for each flow it runs as part of a structured JSON log
statement which can be parsed to generate ICANN activity reports (under the key
"icannActivityReportField").

In order to support this, we introduce an annotation for Flow classes called
@ReportingSpec and a corresponding enum of values for this annotation, which is
IcannReportingTypes.ActivityReportField, that stores the mapping of constant
enum values to field names.

The mapping from flows to fields is fairly obvious, with three exceptions:

 - Application flows are all accounted under domains, since applications are
   technically just deferred domain creates within the EPP protocol
 - ClaimsCheckFlow is counted as a domain check
 - DomainAllocateFlow is counted as a domain create

In addition, I've added tests to all the corresponding flows that we are
indeed logging what we expect.

We'll also need to log the TLD for this to be useful, but I'm doing that in a
follow-up CL.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=151283411
This commit is contained in:
nickfelt 2017-03-26 21:18:15 -07:00 committed by Ben McIlwain
parent b03bd3b525
commit 91c2558feb
72 changed files with 520 additions and 24 deletions

View file

@ -27,6 +27,7 @@ import google.registry.flows.FlowModule.DryRun;
import google.registry.flows.FlowModule.InputXml;
import google.registry.flows.FlowModule.Superuser;
import google.registry.flows.FlowModule.Transactional;
import google.registry.flows.annotations.ReportingSpec;
import google.registry.model.eppcommon.Trid;
import google.registry.model.eppoutput.EppOutput;
import google.registry.monitoring.whitebox.EppMetric;
@ -92,7 +93,8 @@ public class FlowRunner {
"trid", trid.getServerTransactionId(),
"clientId", clientId,
"xml", prettyXml,
"xmlBytes", xmlBase64)));
"xmlBytes", xmlBase64,
"icannActivityReportField", extractActivityReportField(flowClass))));
metric.setCommandNameFromFlow(flowClass.getSimpleName());
if (!isTransactional) {
metric.incrementAttempts();
@ -132,4 +134,16 @@ public class FlowRunner {
this.output = output;
}
}
/**
* Returns the ICANN activity report field for the given flow class, or the empty string if no
* activity report field specification is found.
*/
private static final String extractActivityReportField(Class<? extends Flow> flowClass) {
ReportingSpec reportingSpec = flowClass.getAnnotation(ReportingSpec.class);
if (reportingSpec != null) {
return reportingSpec.value().getFieldName();
}
return "";
}
}

View file

@ -0,0 +1,32 @@
// 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.annotations;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import google.registry.model.reporting.IcannReportingTypes.ActivityReportField;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
/** Annotation for flow classes to indicate how this flow should be recorded for reporting. */
@Documented
@Retention(RUNTIME)
@Target(TYPE)
public @interface ReportingSpec {
/** The ICANN activity reporting field to record for this flow. */
ActivityReportField value();
}

View file

@ -24,12 +24,14 @@ import google.registry.flows.EppException;
import google.registry.flows.ExtensionManager;
import google.registry.flows.Flow;
import google.registry.flows.FlowModule.ClientId;
import google.registry.flows.annotations.ReportingSpec;
import google.registry.model.contact.ContactCommand.Check;
import google.registry.model.contact.ContactResource;
import google.registry.model.eppinput.ResourceCommand;
import google.registry.model.eppoutput.CheckData.ContactCheck;
import google.registry.model.eppoutput.CheckData.ContactCheckData;
import google.registry.model.eppoutput.EppResponse;
import google.registry.model.reporting.IcannReportingTypes.ActivityReportField;
import google.registry.util.Clock;
import java.util.List;
import java.util.Set;
@ -42,6 +44,7 @@ import javax.inject.Inject;
*
* @error {@link google.registry.flows.exceptions.TooManyResourceChecksException}
*/
@ReportingSpec(ActivityReportField.CONTACT_CHECK)
public final class ContactCheckFlow implements Flow {
@Inject ResourceCommand resourceCommand;

View file

@ -28,6 +28,7 @@ import google.registry.flows.ExtensionManager;
import google.registry.flows.FlowModule.ClientId;
import google.registry.flows.FlowModule.TargetId;
import google.registry.flows.TransactionalFlow;
import google.registry.flows.annotations.ReportingSpec;
import google.registry.model.contact.ContactCommand.Create;
import google.registry.model.contact.ContactResource;
import google.registry.model.contact.ContactResource.Builder;
@ -39,6 +40,7 @@ import google.registry.model.index.EppResourceIndex;
import google.registry.model.index.ForeignKeyIndex;
import google.registry.model.ofy.ObjectifyService;
import google.registry.model.reporting.HistoryEntry;
import google.registry.model.reporting.IcannReportingTypes.ActivityReportField;
import javax.inject.Inject;
import org.joda.time.DateTime;
@ -49,6 +51,7 @@ import org.joda.time.DateTime;
* @error {@link ContactFlowUtils.BadInternationalizedPostalInfoException}
* @error {@link ContactFlowUtils.DeclineContactDisclosureFieldDisallowedPolicyException}
*/
@ReportingSpec(ActivityReportField.CONTACT_CREATE)
public final class ContactCreateFlow implements TransactionalFlow {
@Inject ResourceCommand resourceCommand;

View file

@ -33,6 +33,7 @@ import google.registry.flows.FlowModule.ClientId;
import google.registry.flows.FlowModule.Superuser;
import google.registry.flows.FlowModule.TargetId;
import google.registry.flows.TransactionalFlow;
import google.registry.flows.annotations.ReportingSpec;
import google.registry.flows.async.AsyncFlowEnqueuer;
import google.registry.model.contact.ContactResource;
import google.registry.model.domain.DomainBase;
@ -41,6 +42,7 @@ import google.registry.model.eppcommon.AuthInfo;
import google.registry.model.eppcommon.StatusValue;
import google.registry.model.eppoutput.EppResponse;
import google.registry.model.reporting.HistoryEntry;
import google.registry.model.reporting.IcannReportingTypes.ActivityReportField;
import javax.inject.Inject;
import org.joda.time.DateTime;
@ -58,6 +60,7 @@ import org.joda.time.DateTime;
* @error {@link google.registry.flows.exceptions.ResourceStatusProhibitsOperationException}
* @error {@link google.registry.flows.exceptions.ResourceToDeleteIsReferencedException}
*/
@ReportingSpec(ActivityReportField.CONTACT_DELETE)
public final class ContactDeleteFlow implements TransactionalFlow {
private static final ImmutableSet<StatusValue> DISALLOWED_STATUSES = ImmutableSet.of(

View file

@ -27,11 +27,13 @@ import google.registry.flows.ExtensionManager;
import google.registry.flows.Flow;
import google.registry.flows.FlowModule.ClientId;
import google.registry.flows.FlowModule.TargetId;
import google.registry.flows.annotations.ReportingSpec;
import google.registry.model.contact.ContactInfoData;
import google.registry.model.contact.ContactResource;
import google.registry.model.eppcommon.AuthInfo;
import google.registry.model.eppcommon.StatusValue;
import google.registry.model.eppoutput.EppResponse;
import google.registry.model.reporting.IcannReportingTypes.ActivityReportField;
import google.registry.util.Clock;
import javax.inject.Inject;
import org.joda.time.DateTime;
@ -46,6 +48,7 @@ import org.joda.time.DateTime;
*
* @error {@link google.registry.flows.ResourceFlowUtils.ResourceDoesNotExistException}
*/
@ReportingSpec(ActivityReportField.CONTACT_INFO)
public final class ContactInfoFlow implements Flow {
@Inject ExtensionManager extensionManager;

View file

@ -31,6 +31,7 @@ import google.registry.flows.ExtensionManager;
import google.registry.flows.FlowModule.ClientId;
import google.registry.flows.FlowModule.TargetId;
import google.registry.flows.TransactionalFlow;
import google.registry.flows.annotations.ReportingSpec;
import google.registry.model.contact.ContactResource;
import google.registry.model.domain.metadata.MetadataExtension;
import google.registry.model.eppcommon.AuthInfo;
@ -38,6 +39,7 @@ import google.registry.model.eppinput.ResourceCommand;
import google.registry.model.eppoutput.EppResponse;
import google.registry.model.poll.PollMessage;
import google.registry.model.reporting.HistoryEntry;
import google.registry.model.reporting.IcannReportingTypes.ActivityReportField;
import google.registry.model.transfer.TransferStatus;
import javax.inject.Inject;
import org.joda.time.DateTime;
@ -55,6 +57,7 @@ import org.joda.time.DateTime;
* @error {@link google.registry.flows.ResourceFlowUtils.ResourceDoesNotExistException}
* @error {@link google.registry.flows.exceptions.NotPendingTransferException}
*/
@ReportingSpec(ActivityReportField.CONTACT_TRANSFER_APPROVE)
public final class ContactTransferApproveFlow implements TransactionalFlow {
@Inject ResourceCommand resourceCommand;

View file

@ -31,6 +31,7 @@ import google.registry.flows.ExtensionManager;
import google.registry.flows.FlowModule.ClientId;
import google.registry.flows.FlowModule.TargetId;
import google.registry.flows.TransactionalFlow;
import google.registry.flows.annotations.ReportingSpec;
import google.registry.model.contact.ContactResource;
import google.registry.model.domain.metadata.MetadataExtension;
import google.registry.model.eppcommon.AuthInfo;
@ -38,6 +39,7 @@ import google.registry.model.eppinput.ResourceCommand;
import google.registry.model.eppoutput.EppResponse;
import google.registry.model.poll.PollMessage;
import google.registry.model.reporting.HistoryEntry;
import google.registry.model.reporting.IcannReportingTypes.ActivityReportField;
import google.registry.model.transfer.TransferStatus;
import javax.inject.Inject;
import org.joda.time.DateTime;
@ -55,6 +57,7 @@ import org.joda.time.DateTime;
* @error {@link google.registry.flows.exceptions.NotPendingTransferException}
* @error {@link google.registry.flows.exceptions.NotTransferInitiatorException}
*/
@ReportingSpec(ActivityReportField.CONTACT_TRANSFER_CANCEL)
public final class ContactTransferCancelFlow implements TransactionalFlow {
@Inject ResourceCommand resourceCommand;

View file

@ -25,11 +25,13 @@ import google.registry.flows.ExtensionManager;
import google.registry.flows.Flow;
import google.registry.flows.FlowModule.ClientId;
import google.registry.flows.FlowModule.TargetId;
import google.registry.flows.annotations.ReportingSpec;
import google.registry.flows.exceptions.NoTransferHistoryToQueryException;
import google.registry.flows.exceptions.NotAuthorizedToViewTransferException;
import google.registry.model.contact.ContactResource;
import google.registry.model.eppcommon.AuthInfo;
import google.registry.model.eppoutput.EppResponse;
import google.registry.model.reporting.IcannReportingTypes.ActivityReportField;
import google.registry.util.Clock;
import javax.inject.Inject;
@ -48,6 +50,7 @@ import javax.inject.Inject;
* @error {@link google.registry.flows.exceptions.NoTransferHistoryToQueryException}
* @error {@link google.registry.flows.exceptions.NotAuthorizedToViewTransferException}
*/
@ReportingSpec(ActivityReportField.CONTACT_TRANSFER_QUERY)
public final class ContactTransferQueryFlow implements Flow {
@Inject ExtensionManager extensionManager;

View file

@ -31,12 +31,14 @@ import google.registry.flows.ExtensionManager;
import google.registry.flows.FlowModule.ClientId;
import google.registry.flows.FlowModule.TargetId;
import google.registry.flows.TransactionalFlow;
import google.registry.flows.annotations.ReportingSpec;
import google.registry.model.contact.ContactResource;
import google.registry.model.domain.metadata.MetadataExtension;
import google.registry.model.eppcommon.AuthInfo;
import google.registry.model.eppoutput.EppResponse;
import google.registry.model.poll.PollMessage;
import google.registry.model.reporting.HistoryEntry;
import google.registry.model.reporting.IcannReportingTypes.ActivityReportField;
import google.registry.model.transfer.TransferStatus;
import javax.inject.Inject;
import org.joda.time.DateTime;
@ -54,6 +56,7 @@ import org.joda.time.DateTime;
* @error {@link google.registry.flows.ResourceFlowUtils.ResourceNotOwnedException}
* @error {@link google.registry.flows.exceptions.NotPendingTransferException}
*/
@ReportingSpec(ActivityReportField.CONTACT_TRANSFER_REJECT)
public final class ContactTransferRejectFlow implements TransactionalFlow {
@Inject ExtensionManager extensionManager;

View file

@ -34,6 +34,7 @@ import google.registry.flows.ExtensionManager;
import google.registry.flows.FlowModule.ClientId;
import google.registry.flows.FlowModule.TargetId;
import google.registry.flows.TransactionalFlow;
import google.registry.flows.annotations.ReportingSpec;
import google.registry.flows.exceptions.AlreadyPendingTransferException;
import google.registry.flows.exceptions.ObjectAlreadySponsoredException;
import google.registry.model.contact.ContactResource;
@ -44,6 +45,7 @@ import google.registry.model.eppcommon.Trid;
import google.registry.model.eppoutput.EppResponse;
import google.registry.model.poll.PollMessage;
import google.registry.model.reporting.HistoryEntry;
import google.registry.model.reporting.IcannReportingTypes.ActivityReportField;
import google.registry.model.transfer.TransferData;
import google.registry.model.transfer.TransferStatus;
import javax.inject.Inject;
@ -66,6 +68,7 @@ import org.joda.time.Duration;
* @error {@link google.registry.flows.exceptions.ObjectAlreadySponsoredException}
* @error {@link google.registry.flows.exceptions.ResourceStatusProhibitsOperationException}
*/
@ReportingSpec(ActivityReportField.CONTACT_TRANSFER_REQUEST)
public final class ContactTransferRequestFlow implements TransactionalFlow {
private static final ImmutableSet<StatusValue> DISALLOWED_STATUSES = ImmutableSet.of(

View file

@ -35,6 +35,7 @@ import google.registry.flows.FlowModule.ClientId;
import google.registry.flows.FlowModule.Superuser;
import google.registry.flows.FlowModule.TargetId;
import google.registry.flows.TransactionalFlow;
import google.registry.flows.annotations.ReportingSpec;
import google.registry.flows.exceptions.ResourceHasClientUpdateProhibitedException;
import google.registry.model.contact.ContactCommand.Update;
import google.registry.model.contact.ContactCommand.Update.Change;
@ -47,6 +48,7 @@ import google.registry.model.eppcommon.StatusValue;
import google.registry.model.eppinput.ResourceCommand;
import google.registry.model.eppoutput.EppResponse;
import google.registry.model.reporting.HistoryEntry;
import google.registry.model.reporting.IcannReportingTypes.ActivityReportField;
import javax.annotation.Nullable;
import javax.inject.Inject;
import org.joda.time.DateTime;
@ -63,6 +65,7 @@ import org.joda.time.DateTime;
* @error {@link ContactFlowUtils.BadInternationalizedPostalInfoException}
* @error {@link ContactFlowUtils.DeclineContactDisclosureFieldDisallowedPolicyException}
*/
@ReportingSpec(ActivityReportField.CONTACT_UPDATE)
public final class ContactUpdateFlow implements TransactionalFlow {
/**

View file

@ -33,6 +33,7 @@ import google.registry.flows.ExtensionManager;
import google.registry.flows.Flow;
import google.registry.flows.FlowModule.ClientId;
import google.registry.flows.FlowModule.Superuser;
import google.registry.flows.annotations.ReportingSpec;
import google.registry.model.domain.DomainCommand.Check;
import google.registry.model.domain.launch.LaunchCheckExtension;
import google.registry.model.domain.launch.LaunchCheckResponseExtension;
@ -42,6 +43,7 @@ import google.registry.model.eppinput.ResourceCommand;
import google.registry.model.eppoutput.EppResponse;
import google.registry.model.registry.Registry;
import google.registry.model.registry.Registry.TldState;
import google.registry.model.reporting.IcannReportingTypes.ActivityReportField;
import google.registry.model.tmch.ClaimsListShard;
import google.registry.util.Clock;
import java.util.HashSet;
@ -60,6 +62,7 @@ import org.joda.time.DateTime;
* @error {@link DomainFlowUtils.TldDoesNotExistException}
* @error {@link ClaimsCheckNotAllowedInSunrise}
*/
@ReportingSpec(ActivityReportField.DOMAIN_CHECK) // Claims check is a special domain check.
public final class ClaimsCheckFlow implements Flow {
@Inject ExtensionManager extensionManager;

View file

@ -53,6 +53,7 @@ import google.registry.flows.FlowModule.ClientId;
import google.registry.flows.FlowModule.Superuser;
import google.registry.flows.FlowModule.TargetId;
import google.registry.flows.TransactionalFlow;
import google.registry.flows.annotations.ReportingSpec;
import google.registry.flows.domain.DomainFlowUtils.DomainNotAllowedForTldWithCreateRestrictionException;
import google.registry.flows.domain.DomainFlowUtils.NameserversNotSpecifiedForNameserverRestrictedDomainException;
import google.registry.flows.domain.DomainFlowUtils.NameserversNotSpecifiedForTldWithNameserverWhitelistException;
@ -87,6 +88,7 @@ import google.registry.model.poll.PollMessage;
import google.registry.model.registry.Registry;
import google.registry.model.registry.label.ReservationType;
import google.registry.model.reporting.HistoryEntry;
import google.registry.model.reporting.IcannReportingTypes.ActivityReportField;
import google.registry.tmch.LordnTask;
import java.util.Set;
import javax.inject.Inject;
@ -107,6 +109,7 @@ import org.joda.time.DateTime;
* @error {@link NameserversNotSpecifiedForNameserverRestrictedDomainException}
* @error {@link NameserversNotSpecifiedForTldWithNameserverWhitelistException}
*/
@ReportingSpec(ActivityReportField.DOMAIN_CREATE) // Allocates are special domain creates.
public class DomainAllocateFlow implements TransactionalFlow {
private static final String COLLISION_MESSAGE =

View file

@ -58,6 +58,7 @@ import google.registry.flows.FlowModule.ClientId;
import google.registry.flows.FlowModule.Superuser;
import google.registry.flows.FlowModule.TargetId;
import google.registry.flows.TransactionalFlow;
import google.registry.flows.annotations.ReportingSpec;
import google.registry.flows.custom.DomainApplicationCreateFlowCustomLogic;
import google.registry.flows.custom.DomainApplicationCreateFlowCustomLogic.AfterValidationParameters;
import google.registry.flows.custom.DomainApplicationCreateFlowCustomLogic.BeforeResponseParameters;
@ -93,6 +94,7 @@ import google.registry.model.ofy.ObjectifyService;
import google.registry.model.registry.Registry;
import google.registry.model.registry.Registry.TldState;
import google.registry.model.reporting.HistoryEntry;
import google.registry.model.reporting.IcannReportingTypes.ActivityReportField;
import google.registry.model.smd.AbstractSignedMark;
import google.registry.model.smd.EncodedSignedMark;
import javax.inject.Inject;
@ -166,6 +168,7 @@ import org.joda.time.DateTime;
* @error {@link DomainFlowUtils.UnsupportedFeeAttributeException}
* @error {@link DomainFlowUtils.UnsupportedMarkTypeException}
*/
@ReportingSpec(ActivityReportField.DOMAIN_CREATE) // Applications are technically domains in EPP.
public final class DomainApplicationCreateFlow implements TransactionalFlow {
@Inject ExtensionManager extensionManager;

View file

@ -36,6 +36,7 @@ import google.registry.flows.FlowModule.ClientId;
import google.registry.flows.FlowModule.Superuser;
import google.registry.flows.FlowModule.TargetId;
import google.registry.flows.TransactionalFlow;
import google.registry.flows.annotations.ReportingSpec;
import google.registry.model.domain.DomainApplication;
import google.registry.model.domain.launch.LaunchDeleteExtension;
import google.registry.model.domain.launch.LaunchPhase;
@ -46,6 +47,7 @@ import google.registry.model.eppoutput.EppResponse;
import google.registry.model.registry.Registry;
import google.registry.model.registry.Registry.TldState;
import google.registry.model.reporting.HistoryEntry;
import google.registry.model.reporting.IcannReportingTypes.ActivityReportField;
import javax.inject.Inject;
import org.joda.time.DateTime;
@ -61,6 +63,7 @@ import org.joda.time.DateTime;
* @error {@link DomainFlowUtils.LaunchPhaseMismatchException}
* @error {@link DomainFlowUtils.NotAuthorizedForTldException}
*/
@ReportingSpec(ActivityReportField.DOMAIN_DELETE) // Applications are technically domains in EPP.
public final class DomainApplicationDeleteFlow implements TransactionalFlow {
@Inject ExtensionManager extensionManager;

View file

@ -36,6 +36,7 @@ import google.registry.flows.Flow;
import google.registry.flows.FlowModule.ApplicationId;
import google.registry.flows.FlowModule.ClientId;
import google.registry.flows.FlowModule.TargetId;
import google.registry.flows.annotations.ReportingSpec;
import google.registry.model.domain.DomainApplication;
import google.registry.model.domain.DomainCommand.Info;
import google.registry.model.domain.DomainInfoData;
@ -47,6 +48,7 @@ import google.registry.model.eppinput.ResourceCommand;
import google.registry.model.eppoutput.EppResponse;
import google.registry.model.eppoutput.EppResponse.ResponseExtension;
import google.registry.model.mark.Mark;
import google.registry.model.reporting.IcannReportingTypes.ActivityReportField;
import google.registry.model.smd.EncodedSignedMark;
import google.registry.model.smd.SignedMark;
import google.registry.util.Clock;
@ -64,6 +66,7 @@ import javax.inject.Inject;
* @error {@link DomainApplicationInfoFlow.ApplicationLaunchPhaseMismatchException}
* @error {@link MissingApplicationIdException}
*/
@ReportingSpec(ActivityReportField.DOMAIN_INFO) // Applications are technically domains in EPP.
public final class DomainApplicationInfoFlow implements Flow {
@Inject ResourceCommand resourceCommand;

View file

@ -58,6 +58,7 @@ import google.registry.flows.FlowModule.ClientId;
import google.registry.flows.FlowModule.Superuser;
import google.registry.flows.FlowModule.TargetId;
import google.registry.flows.TransactionalFlow;
import google.registry.flows.annotations.ReportingSpec;
import google.registry.flows.domain.DomainFlowUtils.FeesRequiredForNonFreeOperationException;
import google.registry.model.ImmutableObject;
import google.registry.model.domain.DomainApplication;
@ -76,6 +77,7 @@ import google.registry.model.eppinput.ResourceCommand;
import google.registry.model.eppoutput.EppResponse;
import google.registry.model.registry.Registry;
import google.registry.model.reporting.HistoryEntry;
import google.registry.model.reporting.IcannReportingTypes.ActivityReportField;
import javax.inject.Inject;
import org.joda.time.DateTime;
@ -114,6 +116,7 @@ import org.joda.time.DateTime;
* @error {@link DomainFlowUtils.UrgentAttributeNotSupportedException}
* @error {@link DomainApplicationUpdateFlow.ApplicationStatusProhibitsUpdateException}
*/
@ReportingSpec(ActivityReportField.DOMAIN_UPDATE) // Applications are technically domains in EPP.
public class DomainApplicationUpdateFlow implements TransactionalFlow {
/**

View file

@ -42,6 +42,7 @@ import google.registry.flows.ExtensionManager;
import google.registry.flows.Flow;
import google.registry.flows.FlowModule.ClientId;
import google.registry.flows.FlowModule.Superuser;
import google.registry.flows.annotations.ReportingSpec;
import google.registry.flows.custom.DomainCheckFlowCustomLogic;
import google.registry.flows.custom.DomainCheckFlowCustomLogic.BeforeResponseParameters;
import google.registry.flows.custom.DomainCheckFlowCustomLogic.BeforeResponseReturnData;
@ -61,6 +62,7 @@ import google.registry.model.eppoutput.EppResponse.ResponseExtension;
import google.registry.model.registry.Registry;
import google.registry.model.registry.Registry.TldState;
import google.registry.model.registry.label.ReservationType;
import google.registry.model.reporting.IcannReportingTypes.ActivityReportField;
import google.registry.util.Clock;
import java.util.HashSet;
import java.util.List;
@ -94,6 +96,7 @@ import org.joda.time.DateTime;
* @error {@link DomainFlowUtils.UnknownFeeCommandException}
* @error {@link OnlyCheckedNamesCanBeFeeCheckedException}
*/
@ReportingSpec(ActivityReportField.DOMAIN_CHECK)
public final class DomainCheckFlow implements Flow {
/**

View file

@ -58,6 +58,7 @@ import google.registry.flows.FlowModule.ClientId;
import google.registry.flows.FlowModule.Superuser;
import google.registry.flows.FlowModule.TargetId;
import google.registry.flows.TransactionalFlow;
import google.registry.flows.annotations.ReportingSpec;
import google.registry.flows.custom.DomainCreateFlowCustomLogic;
import google.registry.flows.custom.DomainCreateFlowCustomLogic.BeforeResponseParameters;
import google.registry.flows.custom.DomainCreateFlowCustomLogic.BeforeResponseReturnData;
@ -95,6 +96,7 @@ import google.registry.model.poll.PollMessage.Autorenew;
import google.registry.model.registry.Registry;
import google.registry.model.registry.Registry.TldState;
import google.registry.model.reporting.HistoryEntry;
import google.registry.model.reporting.IcannReportingTypes.ActivityReportField;
import google.registry.tmch.LordnTask;
import javax.inject.Inject;
import org.joda.time.DateTime;
@ -155,6 +157,7 @@ import org.joda.time.DateTime;
* @error {@link DomainCreateFlow.DomainHasOpenApplicationsException}
* @error {@link DomainCreateFlow.NoGeneralRegistrationsInCurrentPhaseException}
*/
@ReportingSpec(ActivityReportField.DOMAIN_CREATE)
public class DomainCreateFlow implements TransactionalFlow {
private static final ImmutableSet<TldState> SUNRISE_STATES =

View file

@ -46,6 +46,7 @@ import google.registry.flows.FlowModule.TargetId;
import google.registry.flows.ResourceFlowUtils;
import google.registry.flows.SessionMetadata;
import google.registry.flows.TransactionalFlow;
import google.registry.flows.annotations.ReportingSpec;
import google.registry.flows.custom.DomainDeleteFlowCustomLogic;
import google.registry.flows.custom.DomainDeleteFlowCustomLogic.AfterValidationParameters;
import google.registry.flows.custom.DomainDeleteFlowCustomLogic.BeforeResponseParameters;
@ -77,6 +78,7 @@ import google.registry.model.poll.PollMessage;
import google.registry.model.poll.PollMessage.OneTime;
import google.registry.model.registry.Registry;
import google.registry.model.reporting.HistoryEntry;
import google.registry.model.reporting.IcannReportingTypes.ActivityReportField;
import google.registry.model.transfer.TransferStatus;
import java.util.Set;
import javax.annotation.Nullable;
@ -95,6 +97,7 @@ import org.joda.time.DateTime;
* @error {@link DomainFlowUtils.BadCommandForRegistryPhaseException}
* @error {@link DomainFlowUtils.NotAuthorizedForTldException}
*/
@ReportingSpec(ActivityReportField.DOMAIN_DELETE)
public final class DomainDeleteFlow implements TransactionalFlow {
private static final ImmutableSet<StatusValue> DISALLOWED_STATUSES = ImmutableSet.of(

View file

@ -32,6 +32,7 @@ import google.registry.flows.ExtensionManager;
import google.registry.flows.Flow;
import google.registry.flows.FlowModule.ClientId;
import google.registry.flows.FlowModule.TargetId;
import google.registry.flows.annotations.ReportingSpec;
import google.registry.flows.custom.DomainInfoFlowCustomLogic;
import google.registry.flows.custom.DomainInfoFlowCustomLogic.AfterValidationParameters;
import google.registry.flows.custom.DomainInfoFlowCustomLogic.BeforeResponseParameters;
@ -49,6 +50,7 @@ import google.registry.model.eppinput.EppInput;
import google.registry.model.eppinput.ResourceCommand;
import google.registry.model.eppoutput.EppResponse;
import google.registry.model.eppoutput.EppResponse.ResponseExtension;
import google.registry.model.reporting.IcannReportingTypes.ActivityReportField;
import google.registry.util.Clock;
import javax.inject.Inject;
import org.joda.time.DateTime;
@ -68,6 +70,7 @@ import org.joda.time.DateTime;
* @error {@link DomainFlowUtils.RestoresAreAlwaysForOneYearException}
* @error {@link DomainFlowUtils.TransfersAreAlwaysForOneYearException}
*/
@ReportingSpec(ActivityReportField.DOMAIN_INFO)
public final class DomainInfoFlow implements Flow {
@Inject ExtensionManager extensionManager;

View file

@ -41,6 +41,7 @@ import google.registry.flows.FlowModule.ClientId;
import google.registry.flows.FlowModule.Superuser;
import google.registry.flows.FlowModule.TargetId;
import google.registry.flows.TransactionalFlow;
import google.registry.flows.annotations.ReportingSpec;
import google.registry.flows.custom.DomainRenewFlowCustomLogic;
import google.registry.flows.custom.DomainRenewFlowCustomLogic.AfterValidationParameters;
import google.registry.flows.custom.DomainRenewFlowCustomLogic.BeforeResponseParameters;
@ -69,6 +70,7 @@ import google.registry.model.eppoutput.EppResponse;
import google.registry.model.poll.PollMessage;
import google.registry.model.registry.Registry;
import google.registry.model.reporting.HistoryEntry;
import google.registry.model.reporting.IcannReportingTypes.ActivityReportField;
import javax.inject.Inject;
import org.joda.money.Money;
import org.joda.time.DateTime;
@ -99,6 +101,7 @@ import org.joda.time.DateTime;
* @error {@link DomainFlowUtils.UnsupportedFeeAttributeException}
* @error {@link DomainRenewFlow.IncorrectCurrentExpirationDateException}
*/
@ReportingSpec(ActivityReportField.DOMAIN_RENEW)
public final class DomainRenewFlow implements TransactionalFlow {
private static final ImmutableSet<StatusValue> RENEW_DISALLOWED_STATUSES = ImmutableSet.of(

View file

@ -42,6 +42,7 @@ import google.registry.flows.FlowModule.ClientId;
import google.registry.flows.FlowModule.Superuser;
import google.registry.flows.FlowModule.TargetId;
import google.registry.flows.TransactionalFlow;
import google.registry.flows.annotations.ReportingSpec;
import google.registry.model.ImmutableObject;
import google.registry.model.billing.BillingEvent;
import google.registry.model.billing.BillingEvent.OneTime;
@ -63,6 +64,7 @@ import google.registry.model.eppoutput.EppResponse;
import google.registry.model.poll.PollMessage;
import google.registry.model.registry.Registry;
import google.registry.model.reporting.HistoryEntry;
import google.registry.model.reporting.IcannReportingTypes.ActivityReportField;
import javax.inject.Inject;
import org.joda.money.Money;
import org.joda.time.DateTime;
@ -101,6 +103,7 @@ import org.joda.time.DateTime;
* @error {@link DomainRestoreRequestFlow.DomainNotEligibleForRestoreException}
* @error {@link DomainRestoreRequestFlow.RestoreCommandIncludesChangesException}
*/
@ReportingSpec(ActivityReportField.DOMAIN_RGP_RESTORE_REQUEST)
public final class DomainRestoreRequestFlow implements TransactionalFlow {
@Inject ResourceCommand resourceCommand;

View file

@ -38,6 +38,7 @@ import google.registry.flows.ExtensionManager;
import google.registry.flows.FlowModule.ClientId;
import google.registry.flows.FlowModule.TargetId;
import google.registry.flows.TransactionalFlow;
import google.registry.flows.annotations.ReportingSpec;
import google.registry.model.ImmutableObject;
import google.registry.model.billing.BillingEvent;
import google.registry.model.billing.BillingEvent.Flag;
@ -51,6 +52,7 @@ import google.registry.model.eppoutput.EppResponse;
import google.registry.model.poll.PollMessage;
import google.registry.model.registry.Registry;
import google.registry.model.reporting.HistoryEntry;
import google.registry.model.reporting.IcannReportingTypes.ActivityReportField;
import google.registry.model.transfer.TransferData;
import google.registry.model.transfer.TransferStatus;
import javax.inject.Inject;
@ -74,6 +76,7 @@ import org.joda.time.DateTime;
* @error {@link google.registry.flows.exceptions.NotPendingTransferException}
* @error {@link DomainFlowUtils.NotAuthorizedForTldException}
*/
@ReportingSpec(ActivityReportField.DOMAIN_TRANSFER_APPROVE)
public final class DomainTransferApproveFlow implements TransactionalFlow {
@Inject ExtensionManager extensionManager;

View file

@ -34,12 +34,14 @@ import google.registry.flows.ExtensionManager;
import google.registry.flows.FlowModule.ClientId;
import google.registry.flows.FlowModule.TargetId;
import google.registry.flows.TransactionalFlow;
import google.registry.flows.annotations.ReportingSpec;
import google.registry.model.ImmutableObject;
import google.registry.model.domain.DomainResource;
import google.registry.model.domain.metadata.MetadataExtension;
import google.registry.model.eppcommon.AuthInfo;
import google.registry.model.eppoutput.EppResponse;
import google.registry.model.reporting.HistoryEntry;
import google.registry.model.reporting.IcannReportingTypes.ActivityReportField;
import google.registry.model.transfer.TransferStatus;
import javax.inject.Inject;
import org.joda.time.DateTime;
@ -62,6 +64,7 @@ import org.joda.time.DateTime;
* @error {@link google.registry.flows.exceptions.NotTransferInitiatorException}
* @error {@link DomainFlowUtils.NotAuthorizedForTldException}
*/
@ReportingSpec(ActivityReportField.DOMAIN_TRANSFER_CANCEL)
public final class DomainTransferCancelFlow implements TransactionalFlow {
@Inject ExtensionManager extensionManager;

View file

@ -26,11 +26,13 @@ import google.registry.flows.ExtensionManager;
import google.registry.flows.Flow;
import google.registry.flows.FlowModule.ClientId;
import google.registry.flows.FlowModule.TargetId;
import google.registry.flows.annotations.ReportingSpec;
import google.registry.flows.exceptions.NoTransferHistoryToQueryException;
import google.registry.flows.exceptions.NotAuthorizedToViewTransferException;
import google.registry.model.domain.DomainResource;
import google.registry.model.eppcommon.AuthInfo;
import google.registry.model.eppoutput.EppResponse;
import google.registry.model.reporting.IcannReportingTypes.ActivityReportField;
import google.registry.model.transfer.TransferData;
import google.registry.model.transfer.TransferStatus;
import google.registry.util.Clock;
@ -52,6 +54,7 @@ import org.joda.time.DateTime;
* @error {@link google.registry.flows.exceptions.NoTransferHistoryToQueryException}
* @error {@link google.registry.flows.exceptions.NotAuthorizedToViewTransferException}
*/
@ReportingSpec(ActivityReportField.DOMAIN_TRANSFER_QUERY)
public final class DomainTransferQueryFlow implements Flow {
@Inject ExtensionManager extensionManager;

View file

@ -34,12 +34,14 @@ import google.registry.flows.ExtensionManager;
import google.registry.flows.FlowModule.ClientId;
import google.registry.flows.FlowModule.TargetId;
import google.registry.flows.TransactionalFlow;
import google.registry.flows.annotations.ReportingSpec;
import google.registry.model.ImmutableObject;
import google.registry.model.domain.DomainResource;
import google.registry.model.domain.metadata.MetadataExtension;
import google.registry.model.eppcommon.AuthInfo;
import google.registry.model.eppoutput.EppResponse;
import google.registry.model.reporting.HistoryEntry;
import google.registry.model.reporting.IcannReportingTypes.ActivityReportField;
import google.registry.model.transfer.TransferStatus;
import javax.inject.Inject;
import org.joda.time.DateTime;
@ -62,6 +64,7 @@ import org.joda.time.DateTime;
* @error {@link google.registry.flows.exceptions.NotPendingTransferException}
* @error {@link DomainFlowUtils.NotAuthorizedForTldException}
*/
@ReportingSpec(ActivityReportField.DOMAIN_TRANSFER_REJECT)
public final class DomainTransferRejectFlow implements TransactionalFlow {
@Inject ExtensionManager extensionManager;

View file

@ -42,6 +42,7 @@ import google.registry.flows.FlowModule.ClientId;
import google.registry.flows.FlowModule.Superuser;
import google.registry.flows.FlowModule.TargetId;
import google.registry.flows.TransactionalFlow;
import google.registry.flows.annotations.ReportingSpec;
import google.registry.flows.exceptions.AlreadyPendingTransferException;
import google.registry.flows.exceptions.ObjectAlreadySponsoredException;
import google.registry.flows.exceptions.TransferPeriodMustBeOneYearException;
@ -61,6 +62,7 @@ import google.registry.model.eppoutput.EppResponse;
import google.registry.model.poll.PollMessage;
import google.registry.model.registry.Registry;
import google.registry.model.reporting.HistoryEntry;
import google.registry.model.reporting.IcannReportingTypes.ActivityReportField;
import google.registry.model.transfer.TransferData;
import google.registry.model.transfer.TransferData.Builder;
import google.registry.model.transfer.TransferData.TransferServerApproveEntity;
@ -100,6 +102,7 @@ import org.joda.time.DateTime;
* @error {@link DomainFlowUtils.PremiumNameBlockedException}
* @error {@link DomainFlowUtils.UnsupportedFeeAttributeException}
*/
@ReportingSpec(ActivityReportField.DOMAIN_TRANSFER_REQUEST)
public final class DomainTransferRequestFlow implements TransactionalFlow {
private static final ImmutableSet<StatusValue> DISALLOWED_STATUSES = ImmutableSet.of(

View file

@ -55,6 +55,7 @@ import google.registry.flows.FlowModule.ClientId;
import google.registry.flows.FlowModule.Superuser;
import google.registry.flows.FlowModule.TargetId;
import google.registry.flows.TransactionalFlow;
import google.registry.flows.annotations.ReportingSpec;
import google.registry.flows.custom.DomainUpdateFlowCustomLogic;
import google.registry.flows.custom.DomainUpdateFlowCustomLogic.AfterValidationParameters;
import google.registry.flows.custom.DomainUpdateFlowCustomLogic.BeforeSaveParameters;
@ -80,6 +81,7 @@ import google.registry.model.eppinput.ResourceCommand;
import google.registry.model.eppoutput.EppResponse;
import google.registry.model.registry.Registry;
import google.registry.model.reporting.HistoryEntry;
import google.registry.model.reporting.IcannReportingTypes.ActivityReportField;
import javax.inject.Inject;
import org.joda.time.DateTime;
@ -129,6 +131,7 @@ import org.joda.time.DateTime;
* @error {@link DomainFlowUtils.TooManyNameserversException}
* @error {@link DomainFlowUtils.UrgentAttributeNotSupportedException}
*/
@ReportingSpec(ActivityReportField.DOMAIN_UPDATE)
public final class DomainUpdateFlow implements TransactionalFlow {
/**

View file

@ -24,12 +24,14 @@ import google.registry.flows.EppException;
import google.registry.flows.ExtensionManager;
import google.registry.flows.Flow;
import google.registry.flows.FlowModule.ClientId;
import google.registry.flows.annotations.ReportingSpec;
import google.registry.model.eppinput.ResourceCommand;
import google.registry.model.eppoutput.CheckData.HostCheck;
import google.registry.model.eppoutput.CheckData.HostCheckData;
import google.registry.model.eppoutput.EppResponse;
import google.registry.model.host.HostCommand.Check;
import google.registry.model.host.HostResource;
import google.registry.model.reporting.IcannReportingTypes.ActivityReportField;
import google.registry.util.Clock;
import java.util.List;
import java.util.Set;
@ -42,6 +44,7 @@ import javax.inject.Inject;
*
* @error {@link google.registry.flows.exceptions.TooManyResourceChecksException}
*/
@ReportingSpec(ActivityReportField.HOST_CHECK)
public final class HostCheckFlow implements Flow {
@Inject ResourceCommand resourceCommand;

View file

@ -36,6 +36,7 @@ import google.registry.flows.ExtensionManager;
import google.registry.flows.FlowModule.ClientId;
import google.registry.flows.FlowModule.TargetId;
import google.registry.flows.TransactionalFlow;
import google.registry.flows.annotations.ReportingSpec;
import google.registry.model.ImmutableObject;
import google.registry.model.domain.DomainResource;
import google.registry.model.domain.metadata.MetadataExtension;
@ -49,6 +50,7 @@ import google.registry.model.index.EppResourceIndex;
import google.registry.model.index.ForeignKeyIndex;
import google.registry.model.ofy.ObjectifyService;
import google.registry.model.reporting.HistoryEntry;
import google.registry.model.reporting.IcannReportingTypes.ActivityReportField;
import javax.inject.Inject;
import org.joda.time.DateTime;
@ -73,6 +75,7 @@ import org.joda.time.DateTime;
* @error {@link SubordinateHostMustHaveIpException}
* @error {@link UnexpectedExternalHostIpException}
*/
@ReportingSpec(ActivityReportField.HOST_CREATE)
public final class HostCreateFlow implements TransactionalFlow {
@Inject ResourceCommand resourceCommand;

View file

@ -32,6 +32,7 @@ import google.registry.flows.FlowModule.ClientId;
import google.registry.flows.FlowModule.Superuser;
import google.registry.flows.FlowModule.TargetId;
import google.registry.flows.TransactionalFlow;
import google.registry.flows.annotations.ReportingSpec;
import google.registry.flows.async.AsyncFlowEnqueuer;
import google.registry.model.EppResource;
import google.registry.model.domain.DomainBase;
@ -40,6 +41,7 @@ import google.registry.model.eppcommon.StatusValue;
import google.registry.model.eppoutput.EppResponse;
import google.registry.model.host.HostResource;
import google.registry.model.reporting.HistoryEntry;
import google.registry.model.reporting.IcannReportingTypes.ActivityReportField;
import javax.inject.Inject;
import org.joda.time.DateTime;
@ -60,6 +62,7 @@ import org.joda.time.DateTime;
* @error {@link HostFlowUtils.HostNameNotNormalizedException}
* @error {@link HostFlowUtils.HostNameNotPunyCodedException}
*/
@ReportingSpec(ActivityReportField.HOST_DELETE)
public final class HostDeleteFlow implements TransactionalFlow {
private static final ImmutableSet<StatusValue> DISALLOWED_STATUSES = ImmutableSet.of(

View file

@ -27,12 +27,14 @@ import google.registry.flows.ExtensionManager;
import google.registry.flows.Flow;
import google.registry.flows.FlowModule.ClientId;
import google.registry.flows.FlowModule.TargetId;
import google.registry.flows.annotations.ReportingSpec;
import google.registry.model.domain.DomainResource;
import google.registry.model.eppcommon.StatusValue;
import google.registry.model.eppoutput.EppResponse;
import google.registry.model.host.HostInfoData;
import google.registry.model.host.HostInfoData.Builder;
import google.registry.model.host.HostResource;
import google.registry.model.reporting.IcannReportingTypes.ActivityReportField;
import google.registry.util.Clock;
import javax.inject.Inject;
import org.joda.time.DateTime;
@ -48,6 +50,7 @@ import org.joda.time.DateTime;
* @error {@link HostFlowUtils.HostNameNotNormalizedException}
* @error {@link HostFlowUtils.HostNameNotPunyCodedException}
*/
@ReportingSpec(ActivityReportField.HOST_INFO)
public final class HostInfoFlow implements Flow {
@Inject ExtensionManager extensionManager;

View file

@ -42,6 +42,7 @@ import google.registry.flows.FlowModule.ClientId;
import google.registry.flows.FlowModule.Superuser;
import google.registry.flows.FlowModule.TargetId;
import google.registry.flows.TransactionalFlow;
import google.registry.flows.annotations.ReportingSpec;
import google.registry.flows.async.AsyncFlowEnqueuer;
import google.registry.flows.exceptions.ResourceHasClientUpdateProhibitedException;
import google.registry.model.EppResource;
@ -57,6 +58,7 @@ import google.registry.model.host.HostCommand.Update.Change;
import google.registry.model.host.HostResource;
import google.registry.model.index.ForeignKeyIndex;
import google.registry.model.reporting.HistoryEntry;
import google.registry.model.reporting.IcannReportingTypes.ActivityReportField;
import java.util.Objects;
import javax.inject.Inject;
import org.joda.time.DateTime;
@ -94,6 +96,7 @@ import org.joda.time.DateTime;
* @error {@link HostAlreadyExistsException}
* @error {@link RenameHostToExternalRemoveIpException}
*/
@ReportingSpec(ActivityReportField.HOST_UPDATE)
public final class HostUpdateFlow implements TransactionalFlow {
/**

View file

@ -0,0 +1,69 @@
// 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.model.reporting;
/** Types used for ICANN reporting. */
public final class IcannReportingTypes {
private IcannReportingTypes() {}
/**
* Represents the set of possible ICANN Monthly Registry Functions Activity Report fields.
*
* <p>Refer to the <a
* href="https://newgtlds.icann.org/sites/default/files/agreements/agreement-approved-09jan14-en.htm#_DV_M278>ICANN
* registry agreement Specification 3 Section 2</a> for details.
*/
public enum ActivityReportField {
DOMAIN_CHECK("srs-dom-check"),
DOMAIN_CREATE("srs-dom-create"),
DOMAIN_DELETE("srs-dom-delete"),
DOMAIN_INFO("srs-dom-info"),
DOMAIN_RENEW("srs-dom-renew"),
DOMAIN_RGP_RESTORE_REPORT("srs-dom-rgp-restore-report"),
DOMAIN_RGP_RESTORE_REQUEST("srs-dom-rgp-restore-request"),
DOMAIN_TRANSFER_APPROVE("srs-dom-transfer-approve"),
DOMAIN_TRANSFER_CANCEL("srs-dom-transfer-cancel"),
DOMAIN_TRANSFER_QUERY("srs-dom-transfer-query"),
DOMAIN_TRANSFER_REJECT("srs-dom-transfer-reject"),
DOMAIN_TRANSFER_REQUEST("srs-dom-transfer-request"),
DOMAIN_UPDATE("srs-dom-update"), // Note: does not include domain restore requests.
HOST_CHECK("srs-host-check"),
HOST_CREATE("srs-host-create"),
HOST_DELETE("srs-host-delete"),
HOST_INFO("srs-host-info"),
HOST_UPDATE("srs-host-update"),
CONTACT_CHECK("srs-cont-check"),
CONTACT_CREATE("srs-cont-create"),
CONTACT_DELETE("srs-cont-delete"),
CONTACT_INFO("srs-cont-info"),
CONTACT_TRANSFER_APPROVE("srs-cont-transfer-approve"),
CONTACT_TRANSFER_CANCEL("srs-cont-transfer-cancel"),
CONTACT_TRANSFER_QUERY("srs-cont-transfer-query"),
CONTACT_TRANSFER_REJECT("srs-cont-transfer-reject"),
CONTACT_TRANSFER_REQUEST("srs-cont-transfer-request"),
CONTACT_UPDATE("srs-cont-update");
/** Returns the actual field name from the specification. */
private final String fieldName;
ActivityReportField(String fieldName) {
this.fieldName = fieldName;
}
public String getFieldName() {
return fieldName;
}
}
}

View file

@ -29,9 +29,11 @@ import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
import com.google.common.testing.TestLogHandler;
import google.registry.flows.annotations.ReportingSpec;
import google.registry.model.eppcommon.Trid;
import google.registry.model.eppoutput.EppOutput.ResponseOrGreeting;
import google.registry.model.eppoutput.EppResponse;
import google.registry.model.reporting.IcannReportingTypes.ActivityReportField;
import google.registry.monitoring.whitebox.EppMetric;
import google.registry.testing.AppEngineRule;
import google.registry.testing.FakeClock;
@ -67,6 +69,14 @@ public class FlowRunnerTest extends ShardableTestCase {
}
}
@ReportingSpec(ActivityReportField.CONTACT_CHECK)
static class TestReportingSpecCommandFlow implements Flow {
@Override
public ResponseOrGreeting run() throws EppException {
return mock(EppResponse.class);
}
}
@Before
public void before() {
Logger.getLogger(FlowRunner.class.getCanonicalName()).addHandler(handler);
@ -85,18 +95,6 @@ public class FlowRunnerTest extends ShardableTestCase {
flowRunner.trid = Trid.create("client-123", "server-456");
}
@Test
public void testRun_reportingLogStatement_basic() throws Exception {
flowRunner.run();
assertThat(parseJsonMap(findLogMessageByPrefix(handler, "EPP-REPORTING-LOG-SIGNATURE: ")))
.containsExactly(
"trid", "server-456",
"clientId", "TheRegistrar",
"xml", "<?xml version=\"1.0\" encoding=\"UTF-8\"?><xml/>\n",
// Base64-encoding of "<xml/>":
"xmlBytes", "PHhtbC8+");
}
@Test
public void testRun_nonTransactionalCommand_incrementsMetricAttempts() throws Exception {
flowRunner.run();
@ -123,6 +121,31 @@ public class FlowRunnerTest extends ShardableTestCase {
assertThat(flowRunner.metric.build().getCommandName()).hasValue("TestCommand");
}
@Test
public void testRun_reportingLogStatement_basic() throws Exception {
flowRunner.run();
assertThat(parseJsonMap(findLogMessageByPrefix(handler, "EPP-REPORTING-LOG-SIGNATURE: ")))
.containsExactly(
"trid", "server-456",
"clientId", "TheRegistrar",
"xml", "<?xml version=\"1.0\" encoding=\"UTF-8\"?><xml/>\n",
"xmlBytes", "PHhtbC8+", // Base64-encoding of "<xml/>".
"icannActivityReportField", "");
}
@Test
public void testRun_reportingLogStatement_withReportingSpec() throws Exception {
flowRunner.flowClass = TestReportingSpecCommandFlow.class;
flowRunner.run();
assertThat(parseJsonMap(findLogMessageByPrefix(handler, "EPP-REPORTING-LOG-SIGNATURE: ")))
.containsExactly(
"trid", "server-456",
"clientId", "TheRegistrar",
"xml", "<?xml version=\"1.0\" encoding=\"UTF-8\"?><xml/>\n",
"xmlBytes", "PHhtbC8+", // Base64-encoding of "<xml/>".
"icannActivityReportField", "srs-cont-check");
}
@Test
public void testRun_reportingLogStatement_noClientId() throws Exception {
flowRunner.clientId = "";
@ -132,8 +155,8 @@ public class FlowRunnerTest extends ShardableTestCase {
"trid", "server-456",
"clientId", "",
"xml", "<?xml version=\"1.0\" encoding=\"UTF-8\"?><xml/>\n",
// Base64-encoding of "<xml/>":
"xmlBytes", "PHhtbC8+");
"xmlBytes", "PHhtbC8+", // Base64-encoding of "<xml/>".
"icannActivityReportField", "");
}
@Test
@ -147,7 +170,8 @@ public class FlowRunnerTest extends ShardableTestCase {
"trid", "server-456",
"clientId", "TheRegistrar",
"xml", domainCreateXml,
"xmlBytes", base64().encode(domainCreateXml.getBytes(UTF_8)));
"xmlBytes", base64().encode(domainCreateXml.getBytes(UTF_8)),
"icannActivityReportField", "");
}
@Test

View file

@ -18,12 +18,14 @@ import static com.google.common.truth.Truth.assertThat;
import static google.registry.model.EppResourceUtils.loadByForeignKey;
import static google.registry.model.ofy.ObjectifyService.ofy;
import static google.registry.model.tmch.ClaimsListShardTest.createTestClaimsListShard;
import static google.registry.testing.LogsSubject.assertAboutLogs;
import static google.registry.testing.TaskQueueHelper.assertTasksEnqueued;
import com.google.common.base.Predicate;
import com.google.common.collect.FluentIterable;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.testing.TestLogHandler;
import com.googlecode.objectify.Key;
import google.registry.flows.FlowUtils.NotLoggedInException;
import google.registry.model.EppResource;
@ -38,8 +40,11 @@ import google.registry.model.tmch.ClaimsListShard.ClaimsListRevision;
import google.registry.model.tmch.ClaimsListShard.ClaimsListSingleton;
import google.registry.testing.TaskQueueHelper.TaskMatcher;
import google.registry.util.TypeUtils.TypeInstantiator;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.joda.time.DateTime;
import org.joda.time.Duration;
import org.junit.Before;
import org.junit.Test;
/**
@ -51,6 +56,16 @@ import org.junit.Test;
public abstract class ResourceFlowTestCase<F extends Flow, R extends EppResource>
extends FlowTestCase<F> {
private final TestLogHandler logHandler = new TestLogHandler();
@Before
public void beforeResourceFlowTestCase() {
// Attach TestLogHandler to the root logger so it has access to all log messages.
// Note that in theory for assertIcannReportingActivityFieldLogged() below it would suffice to
// attach it only to the FlowRunner logger, but for some reason this doesn't work for all flows.
Logger.getLogger("").addHandler(logHandler);
}
protected R reloadResourceByForeignKey(DateTime now) throws Exception {
// Force the session to be cleared so that when we read it back, we read from Datastore and
// not from the transaction cache or memcache.
@ -151,4 +166,11 @@ public abstract class ResourceFlowTestCase<F extends Flow, R extends EppResource
.etaDelta(Duration.standardSeconds(75), Duration.standardSeconds(105)) // expected: 90
.payload(expectedPayload));
}
protected void assertIcannReportingActivityFieldLogged(String fieldName) {
assertAboutLogs().that(logHandler)
.hasLogAtLevelWithMessage(Level.INFO, "EPP-REPORTING-LOG-SIGNATURE")
.which()
.contains(fieldName);
}
}

View file

@ -79,4 +79,10 @@ public class ContactCheckFlowTest
thrown.expect(TooManyResourceChecksException.class);
runFlow();
}
@Test
public void testIcannActivityReportField_getsLogged() throws Exception {
runFlow();
assertIcannReportingActivityFieldLogged("srs-cont-check");
}
}

View file

@ -91,4 +91,10 @@ public class ContactCreateFlowTest
thrown.expect(DeclineContactDisclosureFieldDisallowedPolicyException.class);
runFlow();
}
@Test
public void testIcannActivityReportField_getsLogged() throws Exception {
runFlow();
assertIcannReportingActivityFieldLogged("srs-cont-create");
}
}

View file

@ -151,4 +151,12 @@ public class ContactDeleteFlowTest
thrown.expect(ResourceToDeleteIsReferencedException.class);
runFlow();
}
@Test
public void testIcannActivityReportField_getsLogged() throws Exception {
persistActiveContact(getUniqueIdFromCommand());
clock.advanceOneMilli();
runFlow();
assertIcannReportingActivityFieldLogged("srs-cont-delete");
}
}

View file

@ -177,4 +177,11 @@ public class ContactInfoFlowTest extends ResourceFlowTestCase<ContactInfoFlow, C
String.format("(%s)", getUniqueIdFromCommand()));
runFlow();
}
@Test
public void testIcannActivityReportField_getsLogged() throws Exception {
persistContactResource(true);
runFlow();
assertIcannReportingActivityFieldLogged("srs-cont-info");
}
}

View file

@ -209,4 +209,10 @@ public class ContactTransferApproveFlowTest
String.format("(%s)", getUniqueIdFromCommand()));
doFailingTest("contact_transfer_approve.xml");
}
@Test
public void testIcannActivityReportField_getsLogged() throws Exception {
runFlow();
assertIcannReportingActivityFieldLogged("srs-cont-transfer-approve");
}
}

View file

@ -195,4 +195,10 @@ public class ContactTransferCancelFlowTest
String.format("(%s)", getUniqueIdFromCommand()));
doFailingTest("contact_transfer_cancel.xml");
}
@Test
public void testIcannActivityReportField_getsLogged() throws Exception {
runFlow();
assertIcannReportingActivityFieldLogged("srs-cont-transfer-cancel");
}
}

View file

@ -183,4 +183,10 @@ public class ContactTransferQueryFlowTest
String.format("(%s)", getUniqueIdFromCommand()));
doFailingTest("contact_transfer_query.xml");
}
@Test
public void testIcannActivityReportField_getsLogged() throws Exception {
runFlow();
assertIcannReportingActivityFieldLogged("srs-cont-transfer-query");
}
}

View file

@ -205,4 +205,10 @@ public class ContactTransferRejectFlowTest
String.format("(%s)", getUniqueIdFromCommand()));
doFailingTest("contact_transfer_reject.xml");
}
@Test
public void testIcannActivityReportField_getsLogged() throws Exception {
runFlow();
assertIcannReportingActivityFieldLogged("srs-cont-transfer-reject");
}
}

View file

@ -213,4 +213,10 @@ public class ContactTransferRequestFlowTest
thrown.expect(ResourceStatusProhibitsOperationException.class, "pendingDelete");
doFailingTest("contact_transfer_request.xml");
}
@Test
public void testIcannActivityReportField_getsLogged() throws Exception {
runFlow();
assertIcannReportingActivityFieldLogged("srs-cont-transfer-request");
}
}

View file

@ -392,4 +392,12 @@ public class ContactUpdateFlowTest
thrown.expect(AddRemoveSameValueException.class);
runFlow();
}
@Test
public void testIcannActivityReportField_getsLogged() throws Exception {
persistActiveContact(getUniqueIdFromCommand());
clock.advanceOneMilli();
runFlow();
assertIcannReportingActivityFieldLogged("srs-cont-update");
}
}

View file

@ -153,4 +153,10 @@ public class ClaimsCheckFlowTest extends ResourceFlowTestCase<ClaimsCheckFlow, D
thrown.expect(ClaimsPeriodEndedException.class);
runFlow();
}
@Test
public void testIcannActivityReportField_getsLogged() throws Exception {
runFlow();
assertIcannReportingActivityFieldLogged("srs-dom-check");
}
}

View file

@ -701,4 +701,11 @@ public class DomainAllocateFlowTest
thrown.expect(ExceedsMaxRegistrationYearsException.class);
runFlowAsSuperuser();
}
@Test
public void testIcannActivityReportField_getsLogged() throws Exception {
setupDomainApplication("tld", TldState.QUIET_PERIOD);
runFlow(CommitMode.LIVE, UserPrivileges.SUPERUSER);
assertIcannReportingActivityFieldLogged("srs-dom-create");
}
}

View file

@ -1860,4 +1860,12 @@ public class DomainApplicationCreateFlowTest
// .tld
doFailingDomainNameTest("xn--k3hel9n7bxlu1e.tld", InvalidIdnDomainLabelException.class);
}
@Test
public void testIcannActivityReportField_getsLogged() throws Exception {
persistContactsAndHosts();
clock.advanceOneMilli();
runFlow();
assertIcannReportingActivityFieldLogged("srs-dom-create");
}
}

View file

@ -305,4 +305,13 @@ public class DomainApplicationDeleteFlowTest
thrown.expect(ApplicationDomainNameMismatchException.class);
runFlow();
}
@Test
public void testIcannActivityReportField_getsLogged() throws Exception {
persistResource(
newDomainApplication("example.tld").asBuilder().setRepoId("1-TLD").build());
clock.advanceOneMilli();
runFlow();
assertIcannReportingActivityFieldLogged("srs-dom-delete");
}
}

View file

@ -357,4 +357,11 @@ public class DomainApplicationInfoFlowTest
.size();
assertThat(numReadsWithContactsOrHosts).isEqualTo(1);
}
@Test
public void testIcannActivityReportField_getsLogged() throws Exception {
persistTestEntities(HostsState.HOSTS_EXIST, MarksState.NO_MARKS_EXIST);
runFlow();
assertIcannReportingActivityFieldLogged("srs-dom-info");
}
}

View file

@ -923,4 +923,13 @@ public class DomainApplicationUpdateFlowTest
thrown.expect(FeesMismatchException.class);
runFlow();
}
@Test
public void testIcannActivityReportField_getsLogged() throws Exception {
persistReferencedEntities();
persistApplication();
clock.advanceOneMilli();
runFlow();
assertIcannReportingActivityFieldLogged("srs-dom-update");
}
}

View file

@ -872,4 +872,10 @@ public class DomainCheckFlowTest
// TODO: If at some point we have more than one type of fees that are time dependent, populate
// this test to test if the notAfter date is the earliest of the end points of the ranges.
}
@Test
public void testIcannActivityReportField_getsLogged() throws Exception {
runFlow();
assertIcannReportingActivityFieldLogged("srs-dom-check");
}
}

View file

@ -1952,4 +1952,11 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
thrown.expect(ExceedsMaxRegistrationYearsException.class);
runFlow();
}
@Test
public void testIcannActivityReportField_getsLogged() throws Exception {
persistContactsAndHosts();
runFlow();
assertIcannReportingActivityFieldLogged("srs-dom-create");
}
}

View file

@ -737,4 +737,12 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
thrown.expect(OnlyToolCanPassMetadataException.class);
runFlow();
}
@Test
public void testIcannActivityReportField_getsLogged() throws Exception {
setupSuccessfulTest();
clock.advanceOneMilli();
runFlow();
assertIcannReportingActivityFieldLogged("srs-dom-delete");
}
}

View file

@ -662,4 +662,11 @@ public class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Dom
.size();
assertThat(numReadsWithContactsOrHosts).isEqualTo(1);
}
@Test
public void testIcannActivityReportField_getsLogged() throws Exception {
persistTestEntities(false);
runFlow();
assertIcannReportingActivityFieldLogged("srs-dom-info");
}
}

View file

@ -640,4 +640,11 @@ public class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, D
thrown.expect(FeesRequiredForPremiumNameException.class);
runFlow();
}
@Test
public void testIcannActivityReportField_getsLogged() throws Exception {
persistDomain();
runFlow();
assertIcannReportingActivityFieldLogged("srs-dom-renew");
}
}

View file

@ -547,4 +547,11 @@ public class DomainRestoreRequestFlowTest extends
thrown.expect(FeesRequiredForPremiumNameException.class);
runFlow();
}
@Test
public void testIcannActivityReportField_getsLogged() throws Exception {
persistPendingDeleteDomain();
runFlow();
assertIcannReportingActivityFieldLogged("srs-dom-rgp-restore-request");
}
}

View file

@ -425,4 +425,10 @@ public class DomainTransferApproveFlowTest
// NB: No need to test pending delete status since pending transfers will get cancelled upon
// entering pending delete phase. So it's already handled in that test case.
@Test
public void testIcannActivityReportField_getsLogged() throws Exception {
runFlow();
assertIcannReportingActivityFieldLogged("srs-dom-transfer-approve");
}
}

View file

@ -301,4 +301,11 @@ public class DomainTransferCancelFlowTest
// NB: No need to test pending delete status since pending transfers will get cancelled upon
// entering pending delete phase. So it's already handled in that test case.
@Test
public void testIcannActivityReportField_getsLogged() throws Exception {
clock.advanceOneMilli();
runFlow();
assertIcannReportingActivityFieldLogged("srs-dom-transfer-cancel");
}
}

View file

@ -221,4 +221,10 @@ public class DomainTransferQueryFlowTest
String.format("(%s)", getUniqueIdFromCommand()));
doFailingTest("domain_transfer_query.xml");
}
@Test
public void testIcannActivityReportField_getsLogged() throws Exception {
runFlow();
assertIcannReportingActivityFieldLogged("srs-dom-transfer-query");
}
}

View file

@ -265,4 +265,10 @@ public class DomainTransferRejectFlowTest
// NB: No need to test pending delete status since pending transfers will get cancelled upon
// entering pending delete phase. So it's already handled in that test case.
@Test
public void testIcannActivityReportField_getsLogged() throws Exception {
runFlow();
assertIcannReportingActivityFieldLogged("srs-dom-transfer-reject");
}
}

View file

@ -949,4 +949,12 @@ public class DomainTransferRequestFlowTest
thrown.expect(ResourceStatusProhibitsOperationException.class, "pendingDelete");
doFailingTest("domain_transfer_request.xml");
}
@Test
public void testIcannActivityReportField_getsLogged() throws Exception {
setupDomain("example", "tld");
clock.advanceOneMilli();
runTest("domain_transfer_request.xml", UserPrivileges.NORMAL);
assertIcannReportingActivityFieldLogged("srs-dom-transfer-request");
}
}

View file

@ -1393,4 +1393,12 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
thrown.expect(FeesRequiredForNonFreeOperationException.class);
runFlow();
}
@Test
public void testIcannActivityReportField_getsLogged() throws Exception {
persistReferencedEntities();
persistDomain();
runFlow();
assertIcannReportingActivityFieldLogged("srs-dom-update");
}
}

View file

@ -78,4 +78,10 @@ public class HostCheckFlowTest extends ResourceCheckFlowTestCase<HostCheckFlow,
thrown.expect(TooManyResourceChecksException.class);
runFlow();
}
@Test
public void testIcannActivityReportField_getsLogged() throws Exception {
runFlow();
assertIcannReportingActivityFieldLogged("srs-host-check");
}
}

View file

@ -261,4 +261,10 @@ public class HostCreateFlowTest extends ResourceFlowTestCase<HostCreateFlow, Hos
thrown.expect(HostNameTooShallowException.class);
runFlow();
}
@Test
public void testIcannActivityReportField_getsLogged() throws Exception {
runFlow();
assertIcannReportingActivityFieldLogged("srs-host-create");
}
}

View file

@ -274,4 +274,12 @@ public class HostDeleteFlowTest extends ResourceFlowTestCase<HostDeleteFlow, Hos
thrown.expect(HostNameNotNormalizedException.class);
runFlow();
}
@Test
public void testIcannActivityReportField_getsLogged() throws Exception {
persistActiveHost("ns1.example.tld");
clock.advanceOneMilli();
runFlow();
assertIcannReportingActivityFieldLogged("srs-host-delete");
}
}

View file

@ -179,4 +179,11 @@ public class HostInfoFlowTest extends ResourceFlowTestCase<HostInfoFlow, HostRes
thrown.expect(HostNameNotNormalizedException.class);
runFlow();
}
@Test
public void testIcannActivityReportField_getsLogged() throws Exception {
persistHostResource();
runFlow();
assertIcannReportingActivityFieldLogged("srs-host-info");
}
}

View file

@ -1224,4 +1224,13 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
.hasMetadataReason("host-update-test").and()
.hasMetadataRequestedByRegistrar(false);
}
@Test
public void testIcannActivityReportField_getsLogged() throws Exception {
createTld("tld");
persistActiveSubordinateHost(oldHostName(), persistActiveDomain("example.tld"));
clock.advanceOneMilli();
runFlow();
assertIcannReportingActivityFieldLogged("srs-host-update");
}
}

View file

@ -15,16 +15,16 @@
package google.registry.testing;
import static com.google.common.truth.Truth.assertAbout;
import static com.google.common.truth.Truth.assertThat;
import com.google.common.collect.ImmutableList;
import com.google.common.testing.TestLogHandler;
import com.google.common.truth.AbstractVerb.DelegatedVerb;
import com.google.common.truth.Correspondence;
import com.google.common.truth.FailureStrategy;
import com.google.common.truth.StringSubject;
import com.google.common.truth.Subject;
import google.registry.testing.TruthChainer.And;
import google.registry.testing.TruthChainer.Which;
import java.util.List;
import java.util.logging.Handler;
import java.util.logging.Level;
@ -64,21 +64,27 @@ public class LogsSubject extends Subject<LogsSubject, TestLogHandler> {
return builder.build();
}
public And<LogsSubject> hasNoLogsAtLevel(Level level) {
public void hasNoLogsAtLevel(Level level) {
check()
.withFailureMessage("Logs at level %s", level)
.that(getMessagesAtLevel(level))
.isEmpty();
return new And<>(this);
}
public And<LogsSubject> hasLogAtLevelWithMessage(Level level, String message) {
public Which<StringSubject> hasLogAtLevelWithMessage(Level level, String message) {
List<String> messagesAtLevel = getMessagesAtLevel(level);
check()
.withFailureMessage("Logs at level %s", level)
.that(getMessagesAtLevel(level))
.that(messagesAtLevel)
.comparingElementsUsing(CONTAINS_CORRESPONDENCE)
.contains(message);
return new And<>(this);
for (String messageCandidate : messagesAtLevel) {
if (messageCandidate.contains(message)) {
return new Which<>(assertThat(messageCandidate)
.named(String.format("log message at %s matching '%s'", level, message)));
}
}
throw new AssertionError("Message check passed yet matching message not found");
}
public static DelegatedVerb<LogsSubject, TestLogHandler> assertAboutLogs() {