Rename Runnable classes from Tasks to Actions

This is cleanup relating to a naming decision that we made awhile ago
but never got around to.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=117244827
This commit is contained in:
mcilwain 2016-03-15 09:14:24 -07:00 committed by Justine Tunney
parent 5f7bf57cf9
commit 57fa57968d
48 changed files with 320 additions and 318 deletions

View file

@ -132,7 +132,7 @@ public final class ConfigModule {
return projectId + "-icann-brda"; return projectId + "-icann-brda";
} }
/** @see com.google.domain.registry.rde.BrdaCopyTask */ /** @see com.google.domain.registry.rde.BrdaCopyAction */
@Provides @Provides
@Config("brdaDayOfWeek") @Config("brdaDayOfWeek")
public static int provideBrdaDayOfWeek() { public static int provideBrdaDayOfWeek() {
@ -238,8 +238,8 @@ public final class ConfigModule {
/** /**
* Returns the publicly accessible domain name for the running Google Apps instance. * Returns the publicly accessible domain name for the running Google Apps instance.
* *
* @see com.google.domain.registry.export.SyncGroupMembersTask * @see com.google.domain.registry.export.SyncGroupMembersAction
* @see com.google.domain.registry.tools.server.CreateGroupsTask * @see com.google.domain.registry.tools.server.CreateGroupsAction
*/ */
@Provides @Provides
@Config("publicDomainName") @Config("publicDomainName")
@ -264,7 +264,7 @@ public final class ConfigModule {
* <p>This file needs to be downloaded at least once a day and verified to make sure it was * <p>This file needs to be downloaded at least once a day and verified to make sure it was
* signed by {@code icann-tmch.crt}. * signed by {@code icann-tmch.crt}.
* *
* @see com.google.domain.registry.tmch.TmchCrlTask * @see com.google.domain.registry.tmch.TmchCrlAction
* @see "http://tools.ietf.org/html/draft-lozano-tmch-func-spec-08#section-5.2.3.2" * @see "http://tools.ietf.org/html/draft-lozano-tmch-func-spec-08#section-5.2.3.2"
*/ */
@Provides @Provides
@ -325,7 +325,7 @@ public final class ConfigModule {
* *
* <p>You must append {@code "/TLD/ID"} to this URL. * <p>You must append {@code "/TLD/ID"} to this URL.
* *
* @see com.google.domain.registry.rde.RdeReportTask * @see com.google.domain.registry.rde.RdeReportAction
*/ */
@Provides @Provides
@Config("rdeReportUrlPrefix") @Config("rdeReportUrlPrefix")
@ -382,7 +382,7 @@ public final class ConfigModule {
* which cloud storage files are uploaded. The password should not be included, as it's better to * which cloud storage files are uploaded. The password should not be included, as it's better to
* use public key authentication. * use public key authentication.
* *
* @see com.google.domain.registry.rde.RdeUploadTask * @see com.google.domain.registry.rde.RdeUploadAction
*/ */
@Provides @Provides
@Config("rdeUploadUrl") @Config("rdeUploadUrl")
@ -407,7 +407,7 @@ public final class ConfigModule {
* *
* <p>This ID, as you'd expect, comes from the URL of the spreadsheet. * <p>This ID, as you'd expect, comes from the URL of the spreadsheet.
* *
* @see com.google.domain.registry.export.sheet.SyncRegistrarsSheetTask * @see com.google.domain.registry.export.sheet.SyncRegistrarsSheetAction
*/ */
@Provides @Provides
@Config("sheetRegistrarId") @Config("sheetRegistrarId")
@ -437,7 +437,7 @@ public final class ConfigModule {
/** /**
* Returns SSH client connection and read timeout. * Returns SSH client connection and read timeout.
* *
* @see com.google.domain.registry.rde.RdeUploadTask * @see com.google.domain.registry.rde.RdeUploadAction
*/ */
@Provides @Provides
@Config("sshTimeout") @Config("sshTimeout")

View file

@ -28,15 +28,15 @@ import com.google.domain.registry.util.Clock;
import javax.inject.Inject; import javax.inject.Inject;
/** Endpoint for manually triggering refresh of DNS information. */ /** Action that manually triggers refresh of DNS information. */
@Action(path = "/_dr/dnsRefresh", automaticallyPrintOk = true) @Action(path = "/_dr/dnsRefresh", automaticallyPrintOk = true)
public final class RefreshDns implements Runnable { public final class RefreshDnsAction implements Runnable {
@Inject Clock clock; @Inject Clock clock;
@Inject DnsQueue dnsQueue; @Inject DnsQueue dnsQueue;
@Inject @Parameter("name") String domainOrHostName; @Inject @Parameter("name") String domainOrHostName;
@Inject @Parameter("type") TargetType type; @Inject @Parameter("type") TargetType type;
@Inject RefreshDns() {} @Inject RefreshDnsAction() {}
@Override @Override
public void run() { public void run() {

View file

@ -49,9 +49,9 @@ import java.util.concurrent.Callable;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Provider; import javax.inject.Provider;
/** Task that consumes pull-queue for zone updates to write to the DNS server. */ /** Action that consumes pull-queue for zone updates to write to the DNS server. */
@Action(path = "/_dr/task/writeDns", method = POST, automaticallyPrintOk = true) @Action(path = "/_dr/task/writeDns", method = POST, automaticallyPrintOk = true)
public final class WriteDnsTask implements Runnable, Callable<Void> { public final class WriteDnsAction implements Runnable, Callable<Void> {
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass(); private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass();
@ -59,7 +59,7 @@ public final class WriteDnsTask implements Runnable, Callable<Void> {
@Inject Provider<DnsWriter> writerProvider; @Inject Provider<DnsWriter> writerProvider;
@Inject @Config("dnsWriteLockTimeout") Duration timeout; @Inject @Config("dnsWriteLockTimeout") Duration timeout;
@Inject @Parameter(RequestParameters.PARAM_TLD) String tld; @Inject @Parameter(RequestParameters.PARAM_TLD) String tld;
@Inject WriteDnsTask() {} @Inject WriteDnsAction() {}
/** Runs the task. */ /** Runs the task. */
@Override @Override

View file

@ -34,9 +34,9 @@ import com.google.domain.registry.util.FormattingLogger;
import javax.inject.Inject; import javax.inject.Inject;
/** Exports the publicly viewable reserved terms list for a TLD to Google Drive. */ /** Action that exports the publicly viewable reserved terms list for a TLD to Google Drive. */
@Action(path = "/_dr/task/exportReservedTerms", method = POST) @Action(path = "/_dr/task/exportReservedTerms", method = POST)
public class ExportReservedTermsTask implements Runnable { public class ExportReservedTermsAction implements Runnable {
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass(); private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass();
static final MediaType EXPORT_MIME_TYPE = MediaType.PLAIN_TEXT_UTF_8; static final MediaType EXPORT_MIME_TYPE = MediaType.PLAIN_TEXT_UTF_8;
@ -45,7 +45,7 @@ public class ExportReservedTermsTask implements Runnable {
@Inject DriveConnection driveConnection; @Inject DriveConnection driveConnection;
@Inject @Parameter(RequestParameters.PARAM_TLD) String tld; @Inject @Parameter(RequestParameters.PARAM_TLD) String tld;
@Inject Response response; @Inject Response response;
@Inject ExportReservedTermsTask() {} @Inject ExportReservedTermsAction() {}
/** /**
* Exports the reserved terms for the TLD specified via the "tld" param to a newline-delimited * Exports the reserved terms for the TLD specified via the "tld" param to a newline-delimited

View file

@ -48,10 +48,12 @@ import javax.annotation.Nullable;
import javax.inject.Inject; import javax.inject.Inject;
/** /**
* Syncs changes to {@link RegistrarContact} entities with Google Groups using the Directory API. * Action that syncs changes to {@link RegistrarContact} entities with Google Groups.
*
* <p>This uses the <a href="https://developers.google.com/admin-sdk/directory/">Directory API</a>.
*/ */
@Action(path = "/_dr/task/syncGroupMembers", method = POST) @Action(path = "/_dr/task/syncGroupMembers", method = POST)
public final class SyncGroupMembersTask implements Runnable { public final class SyncGroupMembersAction implements Runnable {
/** /**
* The number of threads to run simultaneously (one per registrar) while processing group syncs. * The number of threads to run simultaneously (one per registrar) while processing group syncs.
@ -90,7 +92,7 @@ public final class SyncGroupMembersTask implements Runnable {
@Inject GroupsConnection groupsConnection; @Inject GroupsConnection groupsConnection;
@Inject Response response; @Inject Response response;
@Inject @Config("publicDomainName") String publicDomainName; @Inject @Config("publicDomainName") String publicDomainName;
@Inject SyncGroupMembersTask() {} @Inject SyncGroupMembersAction() {}
private void sendResponse(Result result, @Nullable List<Throwable> causes) { private void sendResponse(Result result, @Nullable List<Throwable> causes) {
for (Throwable cause : nullToEmpty(causes)) { for (Throwable cause : nullToEmpty(causes)) {

View file

@ -49,7 +49,7 @@ import javax.inject.Inject;
/** /**
* Class for synchronizing all {@link Registrar} datastore objects to a Google Spreadsheet. * Class for synchronizing all {@link Registrar} datastore objects to a Google Spreadsheet.
* *
* @see SyncRegistrarsSheetTask * @see SyncRegistrarsSheetAction
*/ */
class SyncRegistrarsSheet { class SyncRegistrarsSheet {

View file

@ -46,14 +46,14 @@ import javax.annotation.Nullable;
import javax.inject.Inject; import javax.inject.Inject;
/** /**
* Task for synchronizing the registrars spreadsheet. * Action for synchronizing the registrars spreadsheet.
* *
* <p>You can specify the spreadsheet ID by passing the "id" parameter. If this parameter is not * <p>You can specify the spreadsheet ID by passing the "id" parameter. If this parameter is not
* specified, then the spreadsheet ID will be obtained from the registry configuration. * specified, then the spreadsheet ID will be obtained from the registry configuration.
* *
* <p>Cron will run this task hourly. So in order to minimize Google Spreadsheets I/O, this task * <p>Cron will run this action hourly. So in order to minimize Google Spreadsheets I/O, this action
* will iterate through all registrars and check if any entries were modified in the past hour. If * will iterate through all registrars and check if any entries were modified in the past hour. If
* no modifications were made, the task will exit without performing any syncing. * no modifications were made, the action will exit without performing any syncing.
* *
* <p><b>Note:</b> Setting the "id" parameter will disable the registrar update check. * <p><b>Note:</b> Setting the "id" parameter will disable the registrar update check.
* *
@ -63,8 +63,8 @@ import javax.inject.Inject;
* *
* @see SyncRegistrarsSheet * @see SyncRegistrarsSheet
*/ */
@Action(path = SyncRegistrarsSheetTask.PATH, method = POST) @Action(path = SyncRegistrarsSheetAction.PATH, method = POST)
public class SyncRegistrarsSheetTask implements Runnable { public class SyncRegistrarsSheetAction implements Runnable {
private enum Result { private enum Result {
OK(SC_OK, "Sheet successfully updated."), OK(SC_OK, "Sheet successfully updated."),
@ -116,7 +116,7 @@ public class SyncRegistrarsSheetTask implements Runnable {
@Inject @Config("sheetRegistrarId") Optional<String> idConfig; @Inject @Config("sheetRegistrarId") Optional<String> idConfig;
@Inject @Config("sheetRegistrarInterval") Duration interval; @Inject @Config("sheetRegistrarInterval") Duration interval;
@Inject @Parameter("id") Optional<String> idParam; @Inject @Parameter("id") Optional<String> idParam;
@Inject SyncRegistrarsSheetTask() {} @Inject SyncRegistrarsSheetAction() {}
@Override @Override
public void run() { public void run() {

View file

@ -38,7 +38,7 @@ public interface Keyring extends AutoCloseable {
* <p>This keypair should only be known to the domain registry shared * <p>This keypair should only be known to the domain registry shared
* registry system. * registry system.
* *
* @see com.google.domain.registry.rde.RdeUploadTask * @see com.google.domain.registry.rde.RdeUploadAction
*/ */
PGPKeyPair getRdeSigningKey(); PGPKeyPair getRdeSigningKey();
@ -65,28 +65,28 @@ public interface Keyring extends AutoCloseable {
* invocation of the RDE upload thing. * invocation of the RDE upload thing.
* *
* @see #getRdeStagingEncryptionKey() * @see #getRdeStagingEncryptionKey()
* @see com.google.domain.registry.rde.RdeUploadTask * @see com.google.domain.registry.rde.RdeUploadAction
*/ */
PGPPrivateKey getRdeStagingDecryptionKey(); PGPPrivateKey getRdeStagingDecryptionKey();
/** /**
* Returns public key of escrow agent for encrypting deposits as they're uploaded. * Returns public key of escrow agent for encrypting deposits as they're uploaded.
* *
* @see com.google.domain.registry.rde.RdeUploadTask * @see com.google.domain.registry.rde.RdeUploadAction
*/ */
PGPPublicKey getRdeReceiverKey(); PGPPublicKey getRdeReceiverKey();
/** /**
* Returns the PGP key we use to sign Bulk Registration Data Access (BRDA) deposits. * Returns the PGP key we use to sign Bulk Registration Data Access (BRDA) deposits.
* *
* @see com.google.domain.registry.rde.BrdaCopyTask * @see com.google.domain.registry.rde.BrdaCopyAction
*/ */
PGPKeyPair getBrdaSigningKey(); PGPKeyPair getBrdaSigningKey();
/** /**
* Returns public key of receiver of Bulk Registration Data Access (BRDA) deposits. * Returns public key of receiver of Bulk Registration Data Access (BRDA) deposits.
* *
* @see com.google.domain.registry.rde.BrdaCopyTask * @see com.google.domain.registry.rde.BrdaCopyAction
*/ */
PGPPublicKey getBrdaReceiverKey(); PGPPublicKey getBrdaReceiverKey();
@ -97,7 +97,7 @@ public interface Keyring extends AutoCloseable {
* {@code ~/.ssh/id_rsa.pub} file. It's usually a single line with the name of * {@code ~/.ssh/id_rsa.pub} file. It's usually a single line with the name of
* the algorithm, the base64 key, and the email address of the owner. * the algorithm, the base64 key, and the email address of the owner.
* *
* @see com.google.domain.registry.rde.RdeUploadTask * @see com.google.domain.registry.rde.RdeUploadAction
*/ */
String getRdeSshClientPublicKey(); String getRdeSshClientPublicKey();
@ -112,21 +112,21 @@ public interface Keyring extends AutoCloseable {
* admin console. The request should originate from a backend task queue servlet * admin console. The request should originate from a backend task queue servlet
* invocation of the RDE upload thing. * invocation of the RDE upload thing.
* *
* @see com.google.domain.registry.rde.RdeUploadTask * @see com.google.domain.registry.rde.RdeUploadAction
*/ */
String getRdeSshClientPrivateKey(); String getRdeSshClientPrivateKey();
/** /**
* Returns password to be used when uploading reports to ICANN. * Returns password to be used when uploading reports to ICANN.
* *
* @see com.google.domain.registry.rde.RdeReportTask * @see com.google.domain.registry.rde.RdeReportAction
*/ */
String getIcannReportingPassword(); String getIcannReportingPassword();
/** /**
* Returns {@code user:password} login for TMCH MarksDB HTTP server DNL interface. * Returns {@code user:password} login for TMCH MarksDB HTTP server DNL interface.
* *
* @see com.google.domain.registry.tmch.TmchDnlTask * @see com.google.domain.registry.tmch.TmchDnlAction
*/ */
String getMarksdbDnlLogin(); String getMarksdbDnlLogin();
@ -140,7 +140,7 @@ public interface Keyring extends AutoCloseable {
/** /**
* Returns {@code user:password} login for TMCH MarksDB HTTP server SMDRL interface. * Returns {@code user:password} login for TMCH MarksDB HTTP server SMDRL interface.
* *
* @see com.google.domain.registry.tmch.TmchSmdrlTask * @see com.google.domain.registry.tmch.TmchSmdrlAction
*/ */
String getMarksdbSmdrlLogin(); String getMarksdbSmdrlLogin();

View file

@ -32,7 +32,7 @@ import javax.servlet.http.HttpServletRequest;
@Module @Module
public final class LoadTestModule { public final class LoadTestModule {
// There's already an @Parameter("clientId") for CreateGroupsTask that's only optional, and we // There's already an @Parameter("clientId") for CreateGroupsAction that's only optional, and we
// want this one to be required, so give it a different name. // want this one to be required, so give it a different name.
@Provides @Provides
@Parameter("loadtestClientId") @Parameter("loadtestClientId")

View file

@ -52,10 +52,10 @@ public class RegistryCursor extends ImmutableObject {
* of each other will be merged into a single deposit. This is problematic in situations where * of each other will be merged into a single deposit. This is problematic in situations where
* the cursor might be a few days behind and is trying to catch up. * the cursor might be a few days behind and is trying to catch up.
* *
* <p>The way we solve this problem is by having {@code RdeUploadTask} check this cursor before * <p>The way we solve this problem is by having {@code RdeUploadAction} check this cursor
* performing an upload for a given TLD. If the cursor is less than two hours old, the task will * before performing an upload for a given TLD. If the cursor is less than two hours old, the
* fail with a status code above 300 and App Engine will keep retrying the task until it's * action will fail with a status code above 300 and App Engine will keep retrying the action
* ready. * until it's ready.
*/ */
RDE_UPLOAD_SFTP; RDE_UPLOAD_SFTP;
} }

View file

@ -25,34 +25,34 @@ import com.google.domain.registry.cron.TldFanoutAction;
import com.google.domain.registry.dns.DnsModule; import com.google.domain.registry.dns.DnsModule;
import com.google.domain.registry.dns.PublishDnsUpdatesAction; import com.google.domain.registry.dns.PublishDnsUpdatesAction;
import com.google.domain.registry.dns.ReadDnsQueueAction; import com.google.domain.registry.dns.ReadDnsQueueAction;
import com.google.domain.registry.dns.RefreshDns; import com.google.domain.registry.dns.RefreshDnsAction;
import com.google.domain.registry.dns.WriteDnsTask; import com.google.domain.registry.dns.WriteDnsAction;
import com.google.domain.registry.export.BigqueryPollJobAction; import com.google.domain.registry.export.BigqueryPollJobAction;
import com.google.domain.registry.export.ExportDomainListsAction; import com.google.domain.registry.export.ExportDomainListsAction;
import com.google.domain.registry.export.ExportRequestModule; import com.google.domain.registry.export.ExportRequestModule;
import com.google.domain.registry.export.ExportReservedTermsTask; import com.google.domain.registry.export.ExportReservedTermsAction;
import com.google.domain.registry.export.SyncGroupMembersTask; import com.google.domain.registry.export.SyncGroupMembersAction;
import com.google.domain.registry.export.sheet.SheetModule; import com.google.domain.registry.export.sheet.SheetModule;
import com.google.domain.registry.export.sheet.SyncRegistrarsSheetTask; import com.google.domain.registry.export.sheet.SyncRegistrarsSheetAction;
import com.google.domain.registry.flows.async.AsyncFlowsModule; import com.google.domain.registry.flows.async.AsyncFlowsModule;
import com.google.domain.registry.flows.async.DeleteContactResourceAction; import com.google.domain.registry.flows.async.DeleteContactResourceAction;
import com.google.domain.registry.flows.async.DeleteHostResourceAction; import com.google.domain.registry.flows.async.DeleteHostResourceAction;
import com.google.domain.registry.flows.async.DnsRefreshForHostRenameAction; import com.google.domain.registry.flows.async.DnsRefreshForHostRenameAction;
import com.google.domain.registry.mapreduce.MapreduceModule; import com.google.domain.registry.mapreduce.MapreduceModule;
import com.google.domain.registry.rde.BrdaCopyTask; import com.google.domain.registry.rde.BrdaCopyAction;
import com.google.domain.registry.rde.RdeModule; import com.google.domain.registry.rde.RdeModule;
import com.google.domain.registry.rde.RdeReportTask; import com.google.domain.registry.rde.RdeReportAction;
import com.google.domain.registry.rde.RdeReporter; import com.google.domain.registry.rde.RdeReporter;
import com.google.domain.registry.rde.RdeStagingAction; import com.google.domain.registry.rde.RdeStagingAction;
import com.google.domain.registry.rde.RdeUploadTask; import com.google.domain.registry.rde.RdeUploadAction;
import com.google.domain.registry.request.RequestModule; import com.google.domain.registry.request.RequestModule;
import com.google.domain.registry.request.RequestScope; import com.google.domain.registry.request.RequestScope;
import com.google.domain.registry.tmch.NordnUploadAction; import com.google.domain.registry.tmch.NordnUploadAction;
import com.google.domain.registry.tmch.NordnVerifyAction; import com.google.domain.registry.tmch.NordnVerifyAction;
import com.google.domain.registry.tmch.TmchCrlTask; import com.google.domain.registry.tmch.TmchCrlAction;
import com.google.domain.registry.tmch.TmchDnlTask; import com.google.domain.registry.tmch.TmchDnlAction;
import com.google.domain.registry.tmch.TmchModule; import com.google.domain.registry.tmch.TmchModule;
import com.google.domain.registry.tmch.TmchSmdrlTask; import com.google.domain.registry.tmch.TmchSmdrlAction;
import dagger.Subcomponent; import dagger.Subcomponent;
@ -74,7 +74,7 @@ import dagger.Subcomponent;
}) })
interface BackendRequestComponent { interface BackendRequestComponent {
BigqueryPollJobAction bigqueryPollJobAction(); BigqueryPollJobAction bigqueryPollJobAction();
BrdaCopyTask brdaCopyTask(); BrdaCopyAction brdaCopyAction();
CommitLogCheckpointAction commitLogCheckpointAction(); CommitLogCheckpointAction commitLogCheckpointAction();
CommitLogFanoutAction commitLogFanoutAction(); CommitLogFanoutAction commitLogFanoutAction();
DeleteContactResourceAction deleteContactResourceAction(); DeleteContactResourceAction deleteContactResourceAction();
@ -83,22 +83,22 @@ interface BackendRequestComponent {
DnsRefreshForHostRenameAction dnsRefreshForHostRenameAction(); DnsRefreshForHostRenameAction dnsRefreshForHostRenameAction();
ExportCommitLogDiffAction exportCommitLogDiffAction(); ExportCommitLogDiffAction exportCommitLogDiffAction();
ExportDomainListsAction exportDomainListsAction(); ExportDomainListsAction exportDomainListsAction();
ExportReservedTermsTask exportReservedTermsTask(); ExportReservedTermsAction exportReservedTermsAction();
NordnUploadAction nordnUploadAction(); NordnUploadAction nordnUploadAction();
NordnVerifyAction nordnVerifyAction(); NordnVerifyAction nordnVerifyAction();
PublishDnsUpdatesAction publishDnsUpdatesAction(); PublishDnsUpdatesAction publishDnsUpdatesAction();
ReadDnsQueueAction readDnsQueueAction(); ReadDnsQueueAction readDnsQueueAction();
RdeReportTask rdeReportTask(); RdeReportAction rdeReportAction();
RdeStagingAction rdeStagingAction(); RdeStagingAction rdeStagingAction();
RdeUploadTask rdeUploadTask(); RdeUploadAction rdeUploadAction();
RdeReporter rdeReporter(); RdeReporter rdeReporter();
RefreshDns refreshDns(); RefreshDnsAction refreshDnsAction();
RestoreCommitLogsAction restoreCommitLogsAction(); RestoreCommitLogsAction restoreCommitLogsAction();
SyncGroupMembersTask syncGroupMembersTask(); SyncGroupMembersAction syncGroupMembersAction();
SyncRegistrarsSheetTask syncRegistrarsSheetTask(); SyncRegistrarsSheetAction syncRegistrarsSheetAction();
TldFanoutAction tldFanoutAction(); TldFanoutAction tldFanoutAction();
TmchCrlTask tmchCrlTask(); TmchCrlAction tmchCrlAction();
TmchDnlTask tmchDnlTask(); TmchDnlAction tmchDnlAction();
TmchSmdrlTask tmchSmdrlTask(); TmchSmdrlAction tmchSmdrlAction();
WriteDnsTask writeDnsTask(); WriteDnsAction writeDnsAction();
} }

View file

@ -22,7 +22,7 @@ import com.google.domain.registry.request.RequestModule;
import com.google.domain.registry.request.RequestScope; import com.google.domain.registry.request.RequestScope;
import com.google.domain.registry.tools.mapreduce.DeleteProberDataAction; import com.google.domain.registry.tools.mapreduce.DeleteProberDataAction;
import com.google.domain.registry.tools.mapreduce.ResaveAllEppResourcesAction; import com.google.domain.registry.tools.mapreduce.ResaveAllEppResourcesAction;
import com.google.domain.registry.tools.server.CreateGroupsTask; import com.google.domain.registry.tools.server.CreateGroupsAction;
import com.google.domain.registry.tools.server.CreatePremiumListAction; import com.google.domain.registry.tools.server.CreatePremiumListAction;
import com.google.domain.registry.tools.server.DeleteEntityAction; import com.google.domain.registry.tools.server.DeleteEntityAction;
import com.google.domain.registry.tools.server.GenerateZoneFilesAction; import com.google.domain.registry.tools.server.GenerateZoneFilesAction;
@ -52,7 +52,7 @@ import dagger.Subcomponent;
}) })
interface ToolsRequestComponent { interface ToolsRequestComponent {
AnnihilateNonDefaultNamespacesAction annihilateNonDefaultNamespacesAction(); AnnihilateNonDefaultNamespacesAction annihilateNonDefaultNamespacesAction();
CreateGroupsTask createGroupsTask(); CreateGroupsAction createGroupsAction();
CreatePremiumListAction createPremiumListAction(); CreatePremiumListAction createPremiumListAction();
DeleteEntityAction deleteEntityAction(); DeleteEntityAction deleteEntityAction();
DeleteProberDataAction deleteProberDataAction(); DeleteProberDataAction deleteProberDataAction();

View file

@ -43,11 +43,11 @@ import java.io.OutputStream;
import javax.inject.Inject; import javax.inject.Inject;
/** /**
* Task that re-encrypts a BRDA escrow deposit and puts it into the upload bucket. * Action that re-encrypts a BRDA escrow deposit and puts it into the upload bucket.
* *
* <p>This task is run by the mapreduce for each BRDA staging file it generates. The staging file is * <p>This action is run by the mapreduce for each BRDA staging file it generates. The staging file
* encrypted with our internal {@link Ghostryde} encryption. We then re-encrypt it as a RyDE file, * is encrypted with our internal {@link Ghostryde} encryption. We then re-encrypt it as a RyDE
* which is what the third-party escrow provider understands. * file, which is what the third-party escrow provider understands.
* *
* <p>Then we put the RyDE file (along with our digital signature) into the configured BRDA bucket. * <p>Then we put the RyDE file (along with our digital signature) into the configured BRDA bucket.
* This bucket is special because a separate script will rsync it to the third party escrow provider * This bucket is special because a separate script will rsync it to the third party escrow provider
@ -55,8 +55,8 @@ import javax.inject.Inject;
* *
* @see "http://newgtlds.icann.org/en/applicants/agb/agreement-approved-09jan14-en.htm" * @see "http://newgtlds.icann.org/en/applicants/agb/agreement-approved-09jan14-en.htm"
*/ */
@Action(path = BrdaCopyTask.PATH, method = POST, automaticallyPrintOk = true) @Action(path = BrdaCopyAction.PATH, method = POST, automaticallyPrintOk = true)
public final class BrdaCopyTask implements Runnable { public final class BrdaCopyAction implements Runnable {
static final String PATH = "/_dr/task/brdaCopy"; static final String PATH = "/_dr/task/brdaCopy";
@ -76,7 +76,7 @@ public final class BrdaCopyTask implements Runnable {
@Inject @Key("brdaReceiverKey") PGPPublicKey receiverKey; @Inject @Key("brdaReceiverKey") PGPPublicKey receiverKey;
@Inject @Key("brdaSigningKey") PGPKeyPair signingKey; @Inject @Key("brdaSigningKey") PGPKeyPair signingKey;
@Inject @Key("rdeStagingDecryptionKey") PGPPrivateKey stagingDecryptionKey; @Inject @Key("rdeStagingDecryptionKey") PGPPrivateKey stagingDecryptionKey;
@Inject BrdaCopyTask() {} @Inject BrdaCopyAction() {}
@Override @Override
public void run() { public void run() {

View file

@ -40,7 +40,7 @@ import javax.inject.Inject;
* as-needed basis. * as-needed basis.
* *
* @see JSchSftpChannel * @see JSchSftpChannel
* @see RdeUploadTask * @see RdeUploadAction
* @see com.jcraft.jsch.Session * @see com.jcraft.jsch.Session
*/ */
final class JSchSshSession implements Closeable { final class JSchSshSession implements Closeable {

View file

@ -48,10 +48,10 @@ import java.io.InputStream;
import javax.inject.Inject; import javax.inject.Inject;
/** /**
* Uploads a small XML RDE report to ICANN after {@link RdeUploadTask} has finished. * Action that uploads a small XML RDE report to ICANN after {@link RdeUploadAction} has finished.
*/ */
@Action(path = RdeReportTask.PATH, method = POST) @Action(path = RdeReportAction.PATH, method = POST)
public final class RdeReportTask implements Runnable, EscrowTask { public final class RdeReportAction implements Runnable, EscrowTask {
static final String PATH = "/_dr/task/rdeReport"; static final String PATH = "/_dr/task/rdeReport";
@ -67,7 +67,7 @@ public final class RdeReportTask implements Runnable, EscrowTask {
@Inject @Config("rdeInterval") Duration interval; @Inject @Config("rdeInterval") Duration interval;
@Inject @Config("rdeReportLockTimeout") Duration timeout; @Inject @Config("rdeReportLockTimeout") Duration timeout;
@Inject @Key("rdeStagingDecryptionKey") PGPPrivateKey stagingDecryptionKey; @Inject @Key("rdeStagingDecryptionKey") PGPPrivateKey stagingDecryptionKey;
@Inject RdeReportTask() {} @Inject RdeReportAction() {}
@Override @Override
public void run() { public void run() {
@ -80,7 +80,7 @@ public final class RdeReportTask implements Runnable, EscrowTask {
RegistryCursor.load(Registry.get(tld), CursorType.RDE_UPLOAD).or(START_OF_TIME); RegistryCursor.load(Registry.get(tld), CursorType.RDE_UPLOAD).or(START_OF_TIME);
if (!stagingCursor.isAfter(watermark)) { if (!stagingCursor.isAfter(watermark)) {
logger.infofmt("tld=%s reportCursor=%s uploadCursor=%s", tld, watermark, stagingCursor); logger.infofmt("tld=%s reportCursor=%s uploadCursor=%s", tld, watermark, stagingCursor);
throw new NoContentException("Waiting for RdeUploadTask to complete"); throw new NoContentException("Waiting for RdeUploadAction to complete");
} }
String prefix = RdeNamingUtils.makeRydeFilename(tld, watermark, FULL, 1, 0); String prefix = RdeNamingUtils.makeRydeFilename(tld, watermark, FULL, 1, 0);
GcsFilename reportFilename = new GcsFilename(bucket, prefix + "-report.xml.ghostryde"); GcsFilename reportFilename = new GcsFilename(bucket, prefix + "-report.xml.ghostryde");

View file

@ -51,7 +51,7 @@ import javax.inject.Inject;
/** /**
* Class that uploads a decrypted XML deposit report to ICANN's webserver. * Class that uploads a decrypted XML deposit report to ICANN's webserver.
* *
* @see RdeReportTask * @see RdeReportAction
*/ */
public class RdeReporter { public class RdeReporter {

View file

@ -67,7 +67,7 @@ import javax.inject.Inject;
* <p>The XML deposit files generated by this job are humongous. A tiny XML report file is generated * <p>The XML deposit files generated by this job are humongous. A tiny XML report file is generated
* for each deposit, telling us how much of what it contains. * for each deposit, telling us how much of what it contains.
* *
* <p>Once a deposit is successfully generated, an {@link RdeUploadTask} is enqueued which will * <p>Once a deposit is successfully generated, an {@link RdeUploadAction} is enqueued which will
* upload it via SFTP to the third-party escrow provider. * upload it via SFTP to the third-party escrow provider.
* *
* <p>To generate escrow deposits manually and locally, use the {@code registry_tool} command * <p>To generate escrow deposits manually and locally, use the {@code registry_tool} command
@ -128,7 +128,7 @@ import javax.inject.Inject;
* Duplicate jobs may exist {@code <=cursor}. So a transaction will not bother changing the cursor * Duplicate jobs may exist {@code <=cursor}. So a transaction will not bother changing the cursor
* if it's already been rolled forward. * if it's already been rolled forward.
* *
* <p>Enqueueing {@code RdeUploadTask} is also part of the cursor transaction. This is necessary * <p>Enqueueing {@code RdeUploadAction} is also part of the cursor transaction. This is necessary
* because the first thing the upload task does is check the staging cursor to verify it's been * because the first thing the upload task does is check the staging cursor to verify it's been
* completed, so we can't enqueue before we roll. We also can't enqueue after the roll, because then * completed, so we can't enqueue before we roll. We also can't enqueue after the roll, because then
* if enqueueing fails, the upload might never be enqueued. * if enqueueing fails, the upload might never be enqueued.

View file

@ -169,7 +169,7 @@ public final class RdeStagingReducer extends Reducer<PendingDeposit, DepositFrag
// Write a file to GCS containing the byte length (ASCII) of the raw unencrypted XML. // Write a file to GCS containing the byte length (ASCII) of the raw unencrypted XML.
// //
// This is necessary because RdeUploadTask creates a tar file which requires that the length // This is necessary because RdeUploadAction creates a tar file which requires that the length
// be outputted. We don't want to have to decrypt the entire ghostryde file to determine the // be outputted. We don't want to have to decrypt the entire ghostryde file to determine the
// length, so we just save it separately. // length, so we just save it separately.
logger.infofmt("Writing %s", xmlLengthFilename); logger.infofmt("Writing %s", xmlLengthFilename);
@ -195,7 +195,7 @@ public final class RdeStagingReducer extends Reducer<PendingDeposit, DepositFrag
} }
} }
// Now that we're done, kick off RdeUploadTask and roll forward the cursor transactionally. // Now that we're done, kick off RdeUploadAction and roll forward the cursor transactionally.
ofy().transact(new VoidWork() { ofy().transact(new VoidWork() {
@Override @Override
public void vrun() { public void vrun() {
@ -213,11 +213,11 @@ public final class RdeStagingReducer extends Reducer<PendingDeposit, DepositFrag
RdeRevision.saveRevision(tld, watermark, mode, revision); RdeRevision.saveRevision(tld, watermark, mode, revision);
if (mode == RdeMode.FULL) { if (mode == RdeMode.FULL) {
taskEnqueuer.enqueue(getQueue("rde-upload"), taskEnqueuer.enqueue(getQueue("rde-upload"),
withUrl(RdeUploadTask.PATH) withUrl(RdeUploadAction.PATH)
.param(RequestParameters.PARAM_TLD, tld)); .param(RequestParameters.PARAM_TLD, tld));
} else { } else {
taskEnqueuer.enqueue(getQueue("brda"), taskEnqueuer.enqueue(getQueue("brda"),
withUrl(BrdaCopyTask.PATH) withUrl(BrdaCopyAction.PATH)
.param(RequestParameters.PARAM_TLD, tld) .param(RequestParameters.PARAM_TLD, tld)
.param(RdeModule.PARAM_WATERMARK, watermark.toString())); .param(RdeModule.PARAM_WATERMARK, watermark.toString()));
} }

View file

@ -67,17 +67,17 @@ import javax.inject.Inject;
import javax.inject.Named; import javax.inject.Named;
/** /**
* Task that securely uploads an RDE XML file from Cloud Storage to a trusted third party (such as * Action that securely uploads an RDE XML file from Cloud Storage to a trusted third party (such as
* Iron Mountain) via SFTP. * Iron Mountain) via SFTP.
* *
* <p>This task is invoked by {@link RdeStagingAction} once it's created the files we need. The date * <p>This action is invoked by {@link RdeStagingAction} once it's created the files we need. The
* is calculated from {@link CursorType#RDE_UPLOAD}. * date is calculated from {@link CursorType#RDE_UPLOAD}.
* *
* <p>Once this task completes, it rolls the cursor forward a day and triggers * <p>Once this action completes, it rolls the cursor forward a day and triggers
* {@link RdeReportTask}. * {@link RdeReportAction}.
*/ */
@Action(path = RdeUploadTask.PATH, method = POST) @Action(path = RdeUploadAction.PATH, method = POST)
public final class RdeUploadTask implements Runnable, EscrowTask { public final class RdeUploadAction implements Runnable, EscrowTask {
static final String PATH = "/_dr/task/rdeUpload"; static final String PATH = "/_dr/task/rdeUpload";
@ -106,14 +106,14 @@ public final class RdeUploadTask implements Runnable, EscrowTask {
@Inject @Key("rdeSigningKey") PGPKeyPair signingKey; @Inject @Key("rdeSigningKey") PGPKeyPair signingKey;
@Inject @Key("rdeStagingDecryptionKey") PGPPrivateKey stagingDecryptionKey; @Inject @Key("rdeStagingDecryptionKey") PGPPrivateKey stagingDecryptionKey;
@Inject @Named("rde-report") Queue reportQueue; @Inject @Named("rde-report") Queue reportQueue;
@Inject RdeUploadTask() {} @Inject RdeUploadAction() {}
@Override @Override
public void run() { public void run() {
runner.lockRunAndRollForward(this, Registry.get(tld), timeout, CursorType.RDE_UPLOAD, interval); runner.lockRunAndRollForward(this, Registry.get(tld), timeout, CursorType.RDE_UPLOAD, interval);
taskEnqueuer.enqueue( taskEnqueuer.enqueue(
reportQueue, reportQueue,
withUrl(RdeReportTask.PATH).param(RequestParameters.PARAM_TLD, tld)); withUrl(RdeReportAction.PATH).param(RequestParameters.PARAM_TLD, tld));
} }
@Override @Override
@ -122,7 +122,7 @@ public final class RdeUploadTask implements Runnable, EscrowTask {
RegistryCursor.load(Registry.get(tld), CursorType.RDE_STAGING).or(START_OF_TIME); RegistryCursor.load(Registry.get(tld), CursorType.RDE_STAGING).or(START_OF_TIME);
if (!stagingCursor.isAfter(watermark)) { if (!stagingCursor.isAfter(watermark)) {
logger.infofmt("tld=%s uploadCursor=%s stagingCursor=%s", tld, watermark, stagingCursor); logger.infofmt("tld=%s uploadCursor=%s stagingCursor=%s", tld, watermark, stagingCursor);
throw new ServiceUnavailableException("Waiting for RdeStagingTask to complete"); throw new ServiceUnavailableException("Waiting for RdeStagingAction to complete");
} }
DateTime sftpCursor = DateTime sftpCursor =
RegistryCursor.load(Registry.get(tld), CursorType.RDE_UPLOAD_SFTP).or(START_OF_TIME); RegistryCursor.load(Registry.get(tld), CursorType.RDE_UPLOAD_SFTP).or(START_OF_TIME);

View file

@ -37,7 +37,7 @@ import javax.annotation.concurrent.Immutable;
* preferable to using a plain {@link URI}. * preferable to using a plain {@link URI}.
* *
* @see java.net.URI * @see java.net.URI
* @see RdeUploadTask * @see RdeUploadAction
*/ */
@Immutable @Immutable
final class RdeUploadUrl implements Comparable<RdeUploadUrl> { final class RdeUploadUrl implements Comparable<RdeUploadUrl> {

View file

@ -27,13 +27,13 @@ import java.security.GeneralSecurityException;
import javax.inject.Inject; import javax.inject.Inject;
/** Task to download the latest ICANN TMCH CRL from MarksDB. */ /** Action to download the latest ICANN TMCH CRL from MarksDB. */
@Action(path = "/_dr/task/tmchCrl", method = POST, automaticallyPrintOk = true) @Action(path = "/_dr/task/tmchCrl", method = POST, automaticallyPrintOk = true)
public final class TmchCrlTask implements Runnable { public final class TmchCrlAction implements Runnable {
@Inject Marksdb marksdb; @Inject Marksdb marksdb;
@Inject @Config("tmchCrlUrl") URL tmchCrlUrl; @Inject @Config("tmchCrlUrl") URL tmchCrlUrl;
@Inject TmchCrlTask() {} @Inject TmchCrlAction() {}
/** Synchronously fetches latest ICANN TMCH CRL and saves it to datastore. */ /** Synchronously fetches latest ICANN TMCH CRL and saves it to datastore. */
@Override @Override

View file

@ -30,9 +30,9 @@ import java.util.List;
import javax.inject.Inject; import javax.inject.Inject;
/** Task to download the latest domain name list (aka claims list) from MarksDB. */ /** Action to download the latest domain name list (aka claims list) from MarksDB. */
@Action(path = "/_dr/task/tmchDnl", method = POST, automaticallyPrintOk = true) @Action(path = "/_dr/task/tmchDnl", method = POST, automaticallyPrintOk = true)
public final class TmchDnlTask implements Runnable { public final class TmchDnlAction implements Runnable {
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass(); private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass();
private static final String DNL_CSV_PATH = "/dnl/dnl-latest.csv"; private static final String DNL_CSV_PATH = "/dnl/dnl-latest.csv";
@ -40,7 +40,7 @@ public final class TmchDnlTask implements Runnable {
@Inject Marksdb marksdb; @Inject Marksdb marksdb;
@Inject @Key("marksdbDnlLogin") Optional<String> marksdbDnlLogin; @Inject @Key("marksdbDnlLogin") Optional<String> marksdbDnlLogin;
@Inject TmchDnlTask() {} @Inject TmchDnlAction() {}
/** Synchronously fetches latest domain name list and saves it to datastore. */ /** Synchronously fetches latest domain name list and saves it to datastore. */
@Override @Override

View file

@ -30,9 +30,9 @@ import java.util.List;
import javax.inject.Inject; import javax.inject.Inject;
/** Task to download the latest signed mark revocation list from MarksDB. */ /** Action to download the latest signed mark revocation list from MarksDB. */
@Action(path = "/_dr/task/tmchSmdrl", method = POST, automaticallyPrintOk = true) @Action(path = "/_dr/task/tmchSmdrl", method = POST, automaticallyPrintOk = true)
public final class TmchSmdrlTask implements Runnable { public final class TmchSmdrlAction implements Runnable {
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass(); private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass();
private static final String SMDRL_CSV_PATH = "/smdrl/smdrl-latest.csv"; private static final String SMDRL_CSV_PATH = "/smdrl/smdrl-latest.csv";
@ -40,7 +40,7 @@ public final class TmchSmdrlTask implements Runnable {
@Inject Marksdb marksdb; @Inject Marksdb marksdb;
@Inject @Key("marksdbSmdrlLogin") Optional<String> marksdbSmdrlLogin; @Inject @Key("marksdbSmdrlLogin") Optional<String> marksdbSmdrlLogin;
@Inject TmchSmdrlTask() {} @Inject TmchSmdrlAction() {}
/** Synchronously fetches latest signed mark revocation list and saves it to datastore. */ /** Synchronously fetches latest signed mark revocation list and saves it to datastore. */
@Override @Override

View file

@ -23,7 +23,7 @@ import com.google.common.collect.ImmutableMap;
import com.google.common.net.MediaType; import com.google.common.net.MediaType;
import com.google.domain.registry.model.registrar.Registrar; import com.google.domain.registry.model.registrar.Registrar;
import com.google.domain.registry.tools.Command.GtechCommand; import com.google.domain.registry.tools.Command.GtechCommand;
import com.google.domain.registry.tools.server.CreateGroupsTask; import com.google.domain.registry.tools.server.CreateGroupsAction;
import com.beust.jcommander.Parameter; import com.beust.jcommander.Parameter;
import com.beust.jcommander.Parameters; import com.beust.jcommander.Parameters;
@ -77,8 +77,8 @@ public class CreateRegistrarGroupsCommand extends ConfirmingCommand
protected String execute() throws IOException { protected String execute() throws IOException {
for (Registrar registrar : registrars) { for (Registrar registrar : registrars) {
connection.send( connection.send(
CreateGroupsTask.PATH, CreateGroupsAction.PATH,
ImmutableMap.of(CreateGroupsTask.CLIENT_ID_PARAM, registrar.getClientIdentifier()), ImmutableMap.of(CreateGroupsAction.CLIENT_ID_PARAM, registrar.getClientIdentifier()),
MediaType.PLAIN_TEXT_UTF_8, MediaType.PLAIN_TEXT_UTF_8,
new byte[0]); new byte[0]);
} }

View file

@ -14,7 +14,7 @@
package com.google.domain.registry.tools.server; package com.google.domain.registry.tools.server;
import static com.google.domain.registry.export.SyncGroupMembersTask.getGroupEmailAddressForContactType; import static com.google.domain.registry.export.SyncGroupMembersAction.getGroupEmailAddressForContactType;
import static com.google.domain.registry.request.Action.Method.POST; import static com.google.domain.registry.request.Action.Method.POST;
import static java.util.Arrays.asList; import static java.util.Arrays.asList;
import static javax.servlet.http.HttpServletResponse.SC_OK; import static javax.servlet.http.HttpServletResponse.SC_OK;
@ -42,9 +42,9 @@ import java.util.List;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import javax.inject.Inject; import javax.inject.Inject;
/** A task that creates Google Groups for a registrar's mailing lists. */ /** Action that creates Google Groups for a registrar's mailing lists. */
@Action(path = CreateGroupsTask.PATH, method = POST) @Action(path = CreateGroupsAction.PATH, method = POST)
public class CreateGroupsTask implements Runnable { public class CreateGroupsAction implements Runnable {
public static final String PATH = "/_dr/admin/createGroups"; public static final String PATH = "/_dr/admin/createGroups";
public static final String CLIENT_ID_PARAM = "clientId"; public static final String CLIENT_ID_PARAM = "clientId";
@ -55,7 +55,7 @@ public class CreateGroupsTask implements Runnable {
@Inject Response response; @Inject Response response;
@Inject @Config("publicDomainName") String publicDomainName; @Inject @Config("publicDomainName") String publicDomainName;
@Inject @Parameter("clientId") Optional<String> clientId; @Inject @Parameter("clientId") Optional<String> clientId;
@Inject CreateGroupsTask() {} @Inject CreateGroupsAction() {}
@Override @Override
public void run() { public void run() {

View file

@ -36,7 +36,7 @@ public class ToolsServerModule {
@Provides @Provides
@Parameter("clientId") @Parameter("clientId")
static Optional<String> provideClientId(HttpServletRequest req) { static Optional<String> provideClientId(HttpServletRequest req) {
return Optional.fromNullable(emptyToNull(req.getParameter(CreateGroupsTask.CLIENT_ID_PARAM))); return Optional.fromNullable(emptyToNull(req.getParameter(CreateGroupsAction.CLIENT_ID_PARAM)));
} }
@Provides @Provides

View file

@ -29,7 +29,7 @@ import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Multimap; import com.google.common.collect.Multimap;
import com.google.domain.registry.config.RegistryConfig; import com.google.domain.registry.config.RegistryConfig;
import com.google.domain.registry.config.RegistryEnvironment; import com.google.domain.registry.config.RegistryEnvironment;
import com.google.domain.registry.export.sheet.SyncRegistrarsSheetTask; import com.google.domain.registry.export.sheet.SyncRegistrarsSheetAction;
import com.google.domain.registry.model.registrar.Registrar; import com.google.domain.registry.model.registrar.Registrar;
import com.google.domain.registry.model.registrar.RegistrarContact; import com.google.domain.registry.model.registrar.RegistrarContact;
import com.google.domain.registry.security.JsonResponseHelper; import com.google.domain.registry.security.JsonResponseHelper;
@ -148,7 +148,7 @@ public class RegistrarServlet extends ResourceServlet {
if (CollectionUtils.difference(changedKeys, "lastUpdateTime").isEmpty()) { if (CollectionUtils.difference(changedKeys, "lastUpdateTime").isEmpty()) {
return; return;
} }
SyncRegistrarsSheetTask.enqueueBackendTask(); SyncRegistrarsSheetAction.enqueueBackendTask();
ImmutableList<String> toEmailAddress = CONFIG.getRegistrarChangesNotificationEmailAddresses(); ImmutableList<String> toEmailAddress = CONFIG.getRegistrarChangesNotificationEmailAddresses();
if (!toEmailAddress.isEmpty()) { if (!toEmailAddress.isEmpty()) {
SendEmailUtils.sendEmail( SendEmailUtils.sendEmail(

View file

@ -78,12 +78,12 @@ public final class DnsInjectionTest {
} }
@Test @Test
public void testWriteDnsTask_injectsAndWorks() throws Exception { public void testWriteDnsAction_injectsAndWorks() throws Exception {
persistActiveSubordinateHost("ns1.example.lol", persistActiveDomain("example.lol")); persistActiveSubordinateHost("ns1.example.lol", persistActiveDomain("example.lol"));
clock.advanceOneMilli(); clock.advanceOneMilli();
dnsQueue.addDomainRefreshTask("example.lol"); dnsQueue.addDomainRefreshTask("example.lol");
when(req.getParameter("tld")).thenReturn("lol"); when(req.getParameter("tld")).thenReturn("lol");
component.writeDnsTask().run(); component.writeDnsAction().run();
assertNoDnsTasksEnqueued(); assertNoDnsTasksEnqueued();
} }

View file

@ -32,6 +32,6 @@ import dagger.Component;
}) })
interface DnsTestComponent { interface DnsTestComponent {
DnsQueue dnsQueue(); DnsQueue dnsQueue();
RefreshDns refreshDns(); RefreshDnsAction refreshDns();
WriteDnsTask writeDnsTask(); WriteDnsAction writeDnsAction();
} }

View file

@ -40,7 +40,7 @@ import org.mockito.runners.MockitoJUnitRunner;
import javax.inject.Provider; import javax.inject.Provider;
/** Unit tests for {@link WriteDnsTask}. */ /** Unit tests for {@link WriteDnsAction}. */
@RunWith(MockitoJUnitRunner.class) @RunWith(MockitoJUnitRunner.class)
public class PublishDnsUpdatesActionTest { public class PublishDnsUpdatesActionTest {

View file

@ -36,9 +36,9 @@ import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.junit.runners.JUnit4; import org.junit.runners.JUnit4;
/** Unit tests for {@link RefreshDns}. */ /** Unit tests for {@link RefreshDnsAction}. */
@RunWith(JUnit4.class) @RunWith(JUnit4.class)
public class RefreshDnsTest { public class RefreshDnsActionTest {
@Rule @Rule
public final AppEngineRule appEngine = AppEngineRule.builder() public final AppEngineRule appEngine = AppEngineRule.builder()
@ -53,12 +53,12 @@ public class RefreshDnsTest {
private final FakeClock clock = new FakeClock(); private final FakeClock clock = new FakeClock();
private void run(TargetType type, String name) { private void run(TargetType type, String name) {
RefreshDns refreshDns = new RefreshDns(); RefreshDnsAction action = new RefreshDnsAction();
refreshDns.clock = clock; action.clock = clock;
refreshDns.domainOrHostName = name; action.domainOrHostName = name;
refreshDns.type = type; action.type = type;
refreshDns.dnsQueue = dnsQueue; action.dnsQueue = dnsQueue;
refreshDns.run(); action.run();
} }
@Before @Before

View file

@ -46,9 +46,9 @@ import org.mockito.runners.MockitoJUnitRunner;
import javax.inject.Provider; import javax.inject.Provider;
/** Unit tests for {@link WriteDnsTask}. */ /** Unit tests for {@link WriteDnsAction}. */
@RunWith(MockitoJUnitRunner.class) @RunWith(MockitoJUnitRunner.class)
public class WriteDnsTaskTest { public class WriteDnsActionTest {
@Rule @Rule
public final AppEngineRule appEngine = AppEngineRule.builder() public final AppEngineRule appEngine = AppEngineRule.builder()
@ -77,16 +77,16 @@ public class WriteDnsTaskTest {
} }
private void run(String tld) { private void run(String tld) {
WriteDnsTask task = new WriteDnsTask(); WriteDnsAction action = new WriteDnsAction();
task.dnsQueue = dnsQueue; action.dnsQueue = dnsQueue;
task.timeout = Duration.standardSeconds(10); action.timeout = Duration.standardSeconds(10);
task.tld = tld; action.tld = tld;
task.writerProvider = new Provider<DnsWriter>() { action.writerProvider = new Provider<DnsWriter>() {
@Override @Override
public DnsWriter get() { public DnsWriter get() {
return dnsWriter; return dnsWriter;
}}; }};
task.run(); action.run();
} }
@After @After

View file

@ -14,8 +14,8 @@
package com.google.domain.registry.export; package com.google.domain.registry.export;
import static com.google.domain.registry.export.ExportReservedTermsTask.EXPORT_MIME_TYPE; import static com.google.domain.registry.export.ExportReservedTermsAction.EXPORT_MIME_TYPE;
import static com.google.domain.registry.export.ExportReservedTermsTask.RESERVED_TERMS_FILENAME; import static com.google.domain.registry.export.ExportReservedTermsAction.RESERVED_TERMS_FILENAME;
import static com.google.domain.registry.testing.DatastoreHelper.createTld; import static com.google.domain.registry.testing.DatastoreHelper.createTld;
import static com.google.domain.registry.testing.DatastoreHelper.persistReservedList; import static com.google.domain.registry.testing.DatastoreHelper.persistReservedList;
import static com.google.domain.registry.testing.DatastoreHelper.persistResource; import static com.google.domain.registry.testing.DatastoreHelper.persistResource;
@ -47,9 +47,9 @@ import org.mockito.runners.MockitoJUnitRunner;
import java.io.IOException; import java.io.IOException;
/** Unit tests for {@link ExportReservedTermsTask}. */ /** Unit tests for {@link ExportReservedTermsAction}. */
@RunWith(MockitoJUnitRunner.class) @RunWith(MockitoJUnitRunner.class)
public class ExportReservedTermsTaskTest { public class ExportReservedTermsActionTest {
@Rule @Rule
public final AppEngineRule appEngine = AppEngineRule.builder() public final AppEngineRule appEngine = AppEngineRule.builder()
@ -68,12 +68,12 @@ public class ExportReservedTermsTaskTest {
@Mock @Mock
private Response response; private Response response;
private void runTask(String tld) { private void runAction(String tld) {
ExportReservedTermsTask task = new ExportReservedTermsTask(); ExportReservedTermsAction action = new ExportReservedTermsAction();
task.response = response; action.response = response;
task.driveConnection = driveConnection; action.driveConnection = driveConnection;
task.tld = tld; action.tld = tld;
task.run(); action.run();
} }
@Before @Before
@ -96,7 +96,7 @@ public class ExportReservedTermsTaskTest {
@Test @Test
public void test_uploadFileToDrive_succeeds() throws Exception { public void test_uploadFileToDrive_succeeds() throws Exception {
runTask("tld"); runAction("tld");
byte[] expected = byte[] expected =
("This is a disclaimer.\ncat\nlol\n") ("This is a disclaimer.\ncat\nlol\n")
.getBytes(UTF_8); .getBytes(UTF_8);
@ -112,7 +112,7 @@ public class ExportReservedTermsTaskTest {
.setReservedLists(ImmutableSet.<ReservedList>of()) .setReservedLists(ImmutableSet.<ReservedList>of())
.setDriveFolderId(null) .setDriveFolderId(null)
.build()); .build());
runTask("tld"); runAction("tld");
verify(response).setStatus(SC_OK); verify(response).setStatus(SC_OK);
verify(response).setPayload("No reserved lists configured"); verify(response).setPayload("No reserved lists configured");
} }
@ -121,7 +121,7 @@ public class ExportReservedTermsTaskTest {
public void test_uploadFileToDrive_failsWhenDriveFolderIdIsNull() throws Exception { public void test_uploadFileToDrive_failsWhenDriveFolderIdIsNull() throws Exception {
thrown.expectRootCause(NullPointerException.class, "No drive folder associated with this TLD"); thrown.expectRootCause(NullPointerException.class, "No drive folder associated with this TLD");
persistResource(Registry.get("tld").asBuilder().setDriveFolderId(null).build()); persistResource(Registry.get("tld").asBuilder().setDriveFolderId(null).build());
runTask("tld"); runAction("tld");
verify(response).setStatus(SC_INTERNAL_SERVER_ERROR); verify(response).setStatus(SC_INTERNAL_SERVER_ERROR);
} }
@ -133,7 +133,7 @@ public class ExportReservedTermsTaskTest {
any(MediaType.class), any(MediaType.class),
anyString(), anyString(),
any(byte[].class))).thenThrow(new IOException("errorMessage")); any(byte[].class))).thenThrow(new IOException("errorMessage"));
runTask("tld"); runAction("tld");
verify(response).setStatus(SC_INTERNAL_SERVER_ERROR); verify(response).setStatus(SC_INTERNAL_SERVER_ERROR);
} }
@ -141,7 +141,7 @@ public class ExportReservedTermsTaskTest {
public void test_uploadFileToDrive_failsWhenTldDoesntExist() throws Exception { public void test_uploadFileToDrive_failsWhenTldDoesntExist() throws Exception {
thrown.expectRootCause( thrown.expectRootCause(
RegistryNotFoundException.class, "No registry object found for fakeTld"); RegistryNotFoundException.class, "No registry object found for fakeTld");
runTask("fakeTld"); runAction("fakeTld");
verify(response).setStatus(SC_INTERNAL_SERVER_ERROR); verify(response).setStatus(SC_INTERNAL_SERVER_ERROR);
} }
} }

View file

@ -15,7 +15,7 @@
package com.google.domain.registry.export; package com.google.domain.registry.export;
import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertThat;
import static com.google.domain.registry.export.SyncGroupMembersTask.getGroupEmailAddressForContactType; import static com.google.domain.registry.export.SyncGroupMembersAction.getGroupEmailAddressForContactType;
import static com.google.domain.registry.model.ofy.ObjectifyService.ofy; import static com.google.domain.registry.model.ofy.ObjectifyService.ofy;
import static com.google.domain.registry.model.registrar.RegistrarContact.Type.ADMIN; import static com.google.domain.registry.model.registrar.RegistrarContact.Type.ADMIN;
import static com.google.domain.registry.model.registrar.RegistrarContact.Type.MARKETING; import static com.google.domain.registry.model.registrar.RegistrarContact.Type.MARKETING;
@ -47,13 +47,13 @@ import org.mockito.runners.MockitoJUnitRunner;
import java.io.IOException; import java.io.IOException;
/** /**
* Unit tests for {@link SyncGroupMembersTask}. * Unit tests for {@link SyncGroupMembersAction}.
* *
* <p>Note that this relies on the registrars NewRegistrar and TheRegistrar created by default in * <p>Note that this relies on the registrars NewRegistrar and TheRegistrar created by default in
* {@link AppEngineRule}. * {@link AppEngineRule}.
*/ */
@RunWith(MockitoJUnitRunner.class) @RunWith(MockitoJUnitRunner.class)
public class SyncGroupMembersTaskTest { public class SyncGroupMembersActionTest {
@Rule @Rule
public final AppEngineRule appEngine = AppEngineRule.builder() public final AppEngineRule appEngine = AppEngineRule.builder()
@ -72,12 +72,12 @@ public class SyncGroupMembersTaskTest {
@Mock @Mock
private Response response; private Response response;
private void runTask() { private void runAction() {
SyncGroupMembersTask task = new SyncGroupMembersTask(); SyncGroupMembersAction action = new SyncGroupMembersAction();
task.groupsConnection = connection; action.groupsConnection = connection;
task.response = response; action.response = response;
task.publicDomainName = "domain-registry.example"; action.publicDomainName = "domain-registry.example";
task.run(); action.run();
} }
@Test @Test
@ -108,7 +108,7 @@ public class SyncGroupMembersTaskTest {
.asBuilder() .asBuilder()
.setContactsRequireSyncing(false) .setContactsRequireSyncing(false)
.build()); .build());
runTask(); runAction();
verify(response).setStatus(SC_OK); verify(response).setStatus(SC_OK);
verify(response).setPayload("NOT_MODIFIED No registrar contacts have been updated " verify(response).setPayload("NOT_MODIFIED No registrar contacts have been updated "
+ "since the last time servlet ran.\n"); + "since the last time servlet ran.\n");
@ -117,7 +117,7 @@ public class SyncGroupMembersTaskTest {
@Test @Test
public void test_doPost_syncsNewContact() throws Exception { public void test_doPost_syncsNewContact() throws Exception {
runTask(); runAction();
verify(connection).addMemberToGroup( verify(connection).addMemberToGroup(
"newregistrar-primary-contacts@domain-registry.example", "newregistrar-primary-contacts@domain-registry.example",
"janedoe@theregistrar.com", "janedoe@theregistrar.com",
@ -131,7 +131,7 @@ public class SyncGroupMembersTaskTest {
public void test_doPost_removesOldContact() throws Exception { public void test_doPost_removesOldContact() throws Exception {
when(connection.getMembersOfGroup("newregistrar-primary-contacts@domain-registry.example")) when(connection.getMembersOfGroup("newregistrar-primary-contacts@domain-registry.example"))
.thenReturn(ImmutableSet.of("defunct@example.com", "janedoe@theregistrar.com")); .thenReturn(ImmutableSet.of("defunct@example.com", "janedoe@theregistrar.com"));
runTask(); runAction();
verify(connection).removeMemberFromGroup( verify(connection).removeMemberFromGroup(
"newregistrar-primary-contacts@domain-registry.example", "defunct@example.com"); "newregistrar-primary-contacts@domain-registry.example", "defunct@example.com");
verify(response).setStatus(SC_OK); verify(response).setStatus(SC_OK);
@ -145,7 +145,7 @@ public class SyncGroupMembersTaskTest {
ofy().deleteWithoutBackup() ofy().deleteWithoutBackup()
.entities(Registrar.loadByClientId("NewRegistrar").getContacts()) .entities(Registrar.loadByClientId("NewRegistrar").getContacts())
.now(); .now();
runTask(); runAction();
verify(connection).removeMemberFromGroup( verify(connection).removeMemberFromGroup(
"newregistrar-primary-contacts@domain-registry.example", "defunct@example.com"); "newregistrar-primary-contacts@domain-registry.example", "defunct@example.com");
verify(connection).removeMemberFromGroup( verify(connection).removeMemberFromGroup(
@ -178,7 +178,7 @@ public class SyncGroupMembersTaskTest {
.setEmailAddress("hexadecimal@snow.fall") .setEmailAddress("hexadecimal@snow.fall")
.setTypes(ImmutableSet.of(TECH)) .setTypes(ImmutableSet.of(TECH))
.build()); .build());
runTask(); runAction();
verify(connection).removeMemberFromGroup( verify(connection).removeMemberFromGroup(
"newregistrar-primary-contacts@domain-registry.example", "defunct@example.com"); "newregistrar-primary-contacts@domain-registry.example", "defunct@example.com");
verify(connection).addMemberToGroup( verify(connection).addMemberToGroup(
@ -211,7 +211,7 @@ public class SyncGroupMembersTaskTest {
.thenReturn(ImmutableSet.<String> of()); .thenReturn(ImmutableSet.<String> of());
when(connection.getMembersOfGroup("theregistrar-primary-contacts@domain-registry.example")) when(connection.getMembersOfGroup("theregistrar-primary-contacts@domain-registry.example"))
.thenThrow(new IOException("Internet was deleted")); .thenThrow(new IOException("Internet was deleted"));
runTask(); runAction();
verify(connection).addMemberToGroup( verify(connection).addMemberToGroup(
"newregistrar-primary-contacts@domain-registry.example", "newregistrar-primary-contacts@domain-registry.example",
"janedoe@theregistrar.com", "janedoe@theregistrar.com",

View file

@ -39,9 +39,9 @@ import java.util.concurrent.Callable;
import javax.annotation.Nullable; import javax.annotation.Nullable;
/** Unit tests for {@link SyncRegistrarsSheetTask}. */ /** Unit tests for {@link SyncRegistrarsSheetAction}. */
@RunWith(JUnit4.class) @RunWith(JUnit4.class)
public class SyncRegistrarsSheetTaskTest { public class SyncRegistrarsSheetActionTest {
@Rule @Rule
public final AppEngineRule appEngine = AppEngineRule.builder() public final AppEngineRule appEngine = AppEngineRule.builder()
@ -52,20 +52,20 @@ public class SyncRegistrarsSheetTaskTest {
private final FakeResponse response = new FakeResponse(); private final FakeResponse response = new FakeResponse();
private final SyncRegistrarsSheet syncRegistrarsSheet = mock(SyncRegistrarsSheet.class); private final SyncRegistrarsSheet syncRegistrarsSheet = mock(SyncRegistrarsSheet.class);
private void runTask(@Nullable String idConfig, @Nullable String idParam) { private void runAction(@Nullable String idConfig, @Nullable String idParam) {
SyncRegistrarsSheetTask task = new SyncRegistrarsSheetTask(); SyncRegistrarsSheetAction action = new SyncRegistrarsSheetAction();
task.response = response; action.response = response;
task.syncRegistrarsSheet = syncRegistrarsSheet; action.syncRegistrarsSheet = syncRegistrarsSheet;
task.idConfig = Optional.fromNullable(idConfig); action.idConfig = Optional.fromNullable(idConfig);
task.idParam = Optional.fromNullable(idParam); action.idParam = Optional.fromNullable(idParam);
task.interval = Duration.standardHours(1); action.interval = Duration.standardHours(1);
task.timeout = Duration.standardHours(1); action.timeout = Duration.standardHours(1);
task.run(); action.run();
} }
@Test @Test
public void testPost_withoutParamsOrSystemProperty_dropsTask() throws Exception { public void testPost_withoutParamsOrSystemProperty_dropsTask() throws Exception {
runTask(null, null); runAction(null, null);
assertThat(response.getPayload()).startsWith("MISSINGNO"); assertThat(response.getPayload()).startsWith("MISSINGNO");
verifyZeroInteractions(syncRegistrarsSheet); verifyZeroInteractions(syncRegistrarsSheet);
} }
@ -73,7 +73,7 @@ public class SyncRegistrarsSheetTaskTest {
@Test @Test
public void testPost_withoutParams_runsSyncWithDefaultIdAndChecksIfModified() throws Exception { public void testPost_withoutParams_runsSyncWithDefaultIdAndChecksIfModified() throws Exception {
when(syncRegistrarsSheet.wasRegistrarsModifiedInLast(any(Duration.class))).thenReturn(true); when(syncRegistrarsSheet.wasRegistrarsModifiedInLast(any(Duration.class))).thenReturn(true);
runTask("jazz", null); runAction("jazz", null);
assertThat(response.getStatus()).isEqualTo(200); assertThat(response.getStatus()).isEqualTo(200);
assertThat(response.getContentType()).isEqualTo(PLAIN_TEXT_UTF_8); assertThat(response.getContentType()).isEqualTo(PLAIN_TEXT_UTF_8);
assertThat(response.getPayload()).startsWith("OK"); assertThat(response.getPayload()).startsWith("OK");
@ -85,7 +85,7 @@ public class SyncRegistrarsSheetTaskTest {
@Test @Test
public void testPost_noModificationsToRegistrarEntities_doesNothing() throws Exception { public void testPost_noModificationsToRegistrarEntities_doesNothing() throws Exception {
when(syncRegistrarsSheet.wasRegistrarsModifiedInLast(any(Duration.class))).thenReturn(false); when(syncRegistrarsSheet.wasRegistrarsModifiedInLast(any(Duration.class))).thenReturn(false);
runTask("NewRegistrar", null); runAction("NewRegistrar", null);
assertThat(response.getPayload()).startsWith("NOTMODIFIED"); assertThat(response.getPayload()).startsWith("NOTMODIFIED");
verify(syncRegistrarsSheet).wasRegistrarsModifiedInLast(any(Duration.class)); verify(syncRegistrarsSheet).wasRegistrarsModifiedInLast(any(Duration.class));
verifyNoMoreInteractions(syncRegistrarsSheet); verifyNoMoreInteractions(syncRegistrarsSheet);
@ -93,7 +93,7 @@ public class SyncRegistrarsSheetTaskTest {
@Test @Test
public void testPost_overrideId_runsSyncWithCustomIdAndDoesNotCheckModified() throws Exception { public void testPost_overrideId_runsSyncWithCustomIdAndDoesNotCheckModified() throws Exception {
runTask(null, "foobar"); runAction(null, "foobar");
assertThat(response.getPayload()).startsWith("OK"); assertThat(response.getPayload()).startsWith("OK");
verify(syncRegistrarsSheet).run(eq("foobar")); verify(syncRegistrarsSheet).run(eq("foobar"));
verifyNoMoreInteractions(syncRegistrarsSheet); verifyNoMoreInteractions(syncRegistrarsSheet);
@ -105,10 +105,10 @@ public class SyncRegistrarsSheetTaskTest {
Lock.executeWithLocks(new Callable<Void>() { Lock.executeWithLocks(new Callable<Void>() {
@Override @Override
public Void call() throws Exception { public Void call() throws Exception {
runTask(null, "foobar"); runAction(null, "foobar");
return null; return null;
} }
}, SyncRegistrarsSheetTask.class, "", Duration.standardHours(1), lockName); }, SyncRegistrarsSheetAction.class, "", Duration.standardHours(1), lockName);
assertThat(response.getPayload()).startsWith("LOCKED"); assertThat(response.getPayload()).startsWith("LOCKED");
verifyZeroInteractions(syncRegistrarsSheet); verifyZeroInteractions(syncRegistrarsSheet);
} }

View file

@ -53,9 +53,9 @@ import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
/** Unit tests for {@link BrdaCopyTask}. */ /** Unit tests for {@link BrdaCopyAction}. */
@RunWith(JUnit4.class) @RunWith(JUnit4.class)
public class BrdaCopyTaskTest { public class BrdaCopyActionTest {
private static final ByteSource DEPOSIT_XML = RdeTestData.get("deposit_full.xml"); // 2010-10-17 private static final ByteSource DEPOSIT_XML = RdeTestData.get("deposit_full.xml"); // 2010-10-17
@ -98,24 +98,24 @@ public class BrdaCopyTaskTest {
private final GcsService gcsService = GcsServiceFactory.createGcsService(); private final GcsService gcsService = GcsServiceFactory.createGcsService();
private final GcsUtils gcsUtils = new GcsUtils(gcsService, 1024); private final GcsUtils gcsUtils = new GcsUtils(gcsService, 1024);
private final BrdaCopyTask task = new BrdaCopyTask(); private final BrdaCopyAction action = new BrdaCopyAction();
@Before @Before
public void before() throws Exception { public void before() throws Exception {
task.gcsUtils = gcsUtils; action.gcsUtils = gcsUtils;
task.ghostryde = new Ghostryde(23); action.ghostryde = new Ghostryde(23);
task.pgpCompressionFactory = new RydePgpCompressionOutputStreamFactory(Providers.of(1024)); action.pgpCompressionFactory = new RydePgpCompressionOutputStreamFactory(Providers.of(1024));
task.pgpEncryptionFactory = new RydePgpEncryptionOutputStreamFactory(Providers.of(1024)); action.pgpEncryptionFactory = new RydePgpEncryptionOutputStreamFactory(Providers.of(1024));
task.pgpFileFactory = new RydePgpFileOutputStreamFactory(Providers.of(1024)); action.pgpFileFactory = new RydePgpFileOutputStreamFactory(Providers.of(1024));
task.pgpSigningFactory = new RydePgpSigningOutputStreamFactory(); action.pgpSigningFactory = new RydePgpSigningOutputStreamFactory();
task.tarFactory = new RydeTarOutputStreamFactory(); action.tarFactory = new RydeTarOutputStreamFactory();
task.tld = "lol"; action.tld = "lol";
task.watermark = DateTime.parse("2010-10-17TZ"); action.watermark = DateTime.parse("2010-10-17TZ");
task.brdaBucket = "tub"; action.brdaBucket = "tub";
task.stagingBucket = "keg"; action.stagingBucket = "keg";
task.receiverKey = receiverKey; action.receiverKey = receiverKey;
task.signingKey = signingKey; action.signingKey = signingKey;
task.stagingDecryptionKey = decryptKey; action.stagingDecryptionKey = decryptKey;
byte[] xml = DEPOSIT_XML.read(); byte[] xml = DEPOSIT_XML.read();
GcsTestingUtils.writeGcsFile(gcsService, STAGE_FILE, GcsTestingUtils.writeGcsFile(gcsService, STAGE_FILE,
@ -126,7 +126,7 @@ public class BrdaCopyTaskTest {
@Test @Test
public void testRun() throws Exception { public void testRun() throws Exception {
task.run(); action.run();
assertThat(gcsUtils.existsAndNotEmpty(STAGE_FILE)).isTrue(); assertThat(gcsUtils.existsAndNotEmpty(STAGE_FILE)).isTrue();
assertThat(gcsUtils.existsAndNotEmpty(RYDE_FILE)).isTrue(); assertThat(gcsUtils.existsAndNotEmpty(RYDE_FILE)).isTrue();
assertThat(gcsUtils.existsAndNotEmpty(SIG_FILE)).isTrue(); assertThat(gcsUtils.existsAndNotEmpty(SIG_FILE)).isTrue();
@ -135,7 +135,7 @@ public class BrdaCopyTaskTest {
@Test @Test
public void testRun_rydeFormat() throws Exception { public void testRun_rydeFormat() throws Exception {
assumeTrue(hasCommand("gpg --version")); assumeTrue(hasCommand("gpg --version"));
task.run(); action.run();
File rydeTmp = new File(gpg.getCwd(), "ryde"); File rydeTmp = new File(gpg.getCwd(), "ryde");
Files.write(readGcsFile(gcsService, RYDE_FILE), rydeTmp); Files.write(readGcsFile(gcsService, RYDE_FILE), rydeTmp);
@ -174,7 +174,7 @@ public class BrdaCopyTaskTest {
@Test @Test
public void testRun_rydeSignature() throws Exception { public void testRun_rydeSignature() throws Exception {
assumeTrue(hasCommand("gpg --version")); assumeTrue(hasCommand("gpg --version"));
task.run(); action.run();
File rydeTmp = new File(gpg.getCwd(), "ryde"); File rydeTmp = new File(gpg.getCwd(), "ryde");
File sigTmp = new File(gpg.getCwd(), "ryde.sig"); File sigTmp = new File(gpg.getCwd(), "ryde.sig");

View file

@ -66,9 +66,9 @@ import org.mockito.ArgumentCaptor;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.util.Map; import java.util.Map;
/** Unit tests for {@link RdeReportTask}. */ /** Unit tests for {@link RdeReportAction}. */
@RunWith(JUnit4.class) @RunWith(JUnit4.class)
public class RdeReportTaskTest { public class RdeReportActionTest {
private static final ByteSource REPORT_XML = RdeTestData.get("report.xml"); private static final ByteSource REPORT_XML = RdeTestData.get("report.xml");
private static final ByteSource IIRDEA_BAD_XML = RdeTestData.get("iirdea_bad.xml"); private static final ByteSource IIRDEA_BAD_XML = RdeTestData.get("iirdea_bad.xml");
@ -96,24 +96,24 @@ public class RdeReportTaskTest {
private final GcsFilename reportFile = private final GcsFilename reportFile =
new GcsFilename("tub", "test_2006-06-06_full_S1_R0-report.xml.ghostryde"); new GcsFilename("tub", "test_2006-06-06_full_S1_R0-report.xml.ghostryde");
private RdeReportTask createTask() { private RdeReportAction createAction() {
RdeReporter reporter = new RdeReporter(); RdeReporter reporter = new RdeReporter();
reporter.config = config; reporter.config = config;
reporter.reportUrlPrefix = "https://rde-report.example"; reporter.reportUrlPrefix = "https://rde-report.example";
reporter.urlFetchService = urlFetchService; reporter.urlFetchService = urlFetchService;
reporter.password = "foo"; reporter.password = "foo";
RdeReportTask task = new RdeReportTask(); RdeReportAction action = new RdeReportAction();
task.gcsUtils = new GcsUtils(gcsService, 1024); action.gcsUtils = new GcsUtils(gcsService, 1024);
task.ghostryde = new Ghostryde(1024); action.ghostryde = new Ghostryde(1024);
task.response = response; action.response = response;
task.bucket = "tub"; action.bucket = "tub";
task.tld = "test"; action.tld = "test";
task.interval = standardDays(1); action.interval = standardDays(1);
task.reporter = reporter; action.reporter = reporter;
task.timeout = standardSeconds(30); action.timeout = standardSeconds(30);
task.stagingDecryptionKey = new RdeKeyringModule().get().getRdeStagingDecryptionKey(); action.stagingDecryptionKey = new RdeKeyringModule().get().getRdeStagingDecryptionKey();
task.runner = runner; action.runner = runner;
return task; return action;
} }
@Before @Before
@ -131,11 +131,11 @@ public class RdeReportTaskTest {
@Test @Test
public void testRun() throws Exception { public void testRun() throws Exception {
createTld("lol"); createTld("lol");
RdeReportTask task = createTask(); RdeReportAction action = createAction();
task.tld = "lol"; action.tld = "lol";
task.run(); action.run();
verify(runner).lockRunAndRollForward( verify(runner).lockRunAndRollForward(
task, Registry.get("lol"), standardSeconds(30), CursorType.RDE_REPORT, standardDays(1)); action, Registry.get("lol"), standardSeconds(30), CursorType.RDE_REPORT, standardDays(1));
verifyNoMoreInteractions(runner); verifyNoMoreInteractions(runner);
} }
@ -144,7 +144,7 @@ public class RdeReportTaskTest {
when(httpResponse.getResponseCode()).thenReturn(SC_OK); when(httpResponse.getResponseCode()).thenReturn(SC_OK);
when(httpResponse.getContent()).thenReturn(IIRDEA_GOOD_XML.read()); when(httpResponse.getContent()).thenReturn(IIRDEA_GOOD_XML.read());
when(urlFetchService.fetch(request.capture())).thenReturn(httpResponse); when(urlFetchService.fetch(request.capture())).thenReturn(httpResponse);
createTask().runWithLock(loadRdeReportCursor()); createAction().runWithLock(loadRdeReportCursor());
assertThat(response.getStatus()).isEqualTo(200); assertThat(response.getStatus()).isEqualTo(200);
assertThat(response.getContentType()).isEqualTo(PLAIN_TEXT_UTF_8); assertThat(response.getContentType()).isEqualTo(PLAIN_TEXT_UTF_8);
assertThat(response.getPayload()).isEqualTo("OK test 2006-06-06T00:00:00.000Z\n"); assertThat(response.getPayload()).isEqualTo("OK test 2006-06-06T00:00:00.000Z\n");
@ -171,7 +171,7 @@ public class RdeReportTaskTest {
when(httpResponse.getContent()).thenReturn(IIRDEA_BAD_XML.read()); when(httpResponse.getContent()).thenReturn(IIRDEA_BAD_XML.read());
when(urlFetchService.fetch(request.capture())).thenReturn(httpResponse); when(urlFetchService.fetch(request.capture())).thenReturn(httpResponse);
thrown.expect(InternalServerErrorException.class, "The structure of the report is invalid."); thrown.expect(InternalServerErrorException.class, "The structure of the report is invalid.");
createTask().runWithLock(loadRdeReportCursor()); createAction().runWithLock(loadRdeReportCursor());
} }
@Test @Test
@ -179,7 +179,7 @@ public class RdeReportTaskTest {
class ExpectedException extends RuntimeException {} class ExpectedException extends RuntimeException {}
when(urlFetchService.fetch(any(HTTPRequest.class))).thenThrow(new ExpectedException()); when(urlFetchService.fetch(any(HTTPRequest.class))).thenThrow(new ExpectedException());
thrown.expect(ExpectedException.class); thrown.expect(ExpectedException.class);
createTask().runWithLock(loadRdeReportCursor()); createAction().runWithLock(loadRdeReportCursor());
} }
private DateTime loadRdeReportCursor() { private DateTime loadRdeReportCursor() {

View file

@ -325,11 +325,11 @@ public class RdeStagingActionTest extends MapreduceTestCase<RdeStagingAction> {
executeTasksUntilEmpty("mapreduce", clock); executeTasksUntilEmpty("mapreduce", clock);
assertTasksEnqueued("rde-upload", assertTasksEnqueued("rde-upload",
new TaskMatcher() new TaskMatcher()
.url(RdeUploadTask.PATH) .url(RdeUploadAction.PATH)
.param(RequestParameters.PARAM_TLD, "lol")); .param(RequestParameters.PARAM_TLD, "lol"));
assertTasksEnqueued("brda", assertTasksEnqueued("brda",
new TaskMatcher() new TaskMatcher()
.url(BrdaCopyTask.PATH) .url(BrdaCopyAction.PATH)
.param(RequestParameters.PARAM_TLD, "lol") .param(RequestParameters.PARAM_TLD, "lol")
.param(RdeModule.PARAM_WATERMARK, "2000-01-04T00:00:00.000Z")); .param(RdeModule.PARAM_WATERMARK, "2000-01-04T00:00:00.000Z"));
} }

View file

@ -26,8 +26,8 @@ import org.junit.runners.Suite.SuiteClasses;
GhostrydeTest.class, GhostrydeTest.class,
HostResourceToXjcConverterTest.class, HostResourceToXjcConverterTest.class,
RdeStagingActionTest.class, RdeStagingActionTest.class,
RdeUploadTaskTest.class, RdeUploadActionTest.class,
RdeReportTaskTest.class, RdeReportActionTest.class,
RegistrarToXjcConverterTest.class, RegistrarToXjcConverterTest.class,
RydeGpgIntegrationTest.class, RydeGpgIntegrationTest.class,
}) })

View file

@ -85,9 +85,9 @@ import java.io.OutputStream;
import java.net.Socket; import java.net.Socket;
import java.net.URI; import java.net.URI;
/** Unit tests for {@link RdeUploadTask}. */ /** Unit tests for {@link RdeUploadAction}. */
@RunWith(MockitoJUnitRunner.class) @RunWith(MockitoJUnitRunner.class)
public class RdeUploadTaskTest { public class RdeUploadActionTest {
private static final int BUFFER_SIZE = 64 * 1024; private static final int BUFFER_SIZE = 64 * 1024;
private static final ByteSource REPORT_XML = RdeTestData.get("report.xml"); private static final ByteSource REPORT_XML = RdeTestData.get("report.xml");
@ -176,35 +176,35 @@ public class RdeUploadTaskTest {
return ioSpy.register(super.create(os, signingKey)); return ioSpy.register(super.create(os, signingKey));
}}; }};
private RdeUploadTask createTask(URI uploadUrl) { private RdeUploadAction createAction(URI uploadUrl) {
try (Keyring keyring = new RdeKeyringModule().get()) { try (Keyring keyring = new RdeKeyringModule().get()) {
RdeUploadTask task = new RdeUploadTask(); RdeUploadAction action = new RdeUploadAction();
task.clock = clock; action.clock = clock;
task.gcsUtils = new GcsUtils(gcsService, BUFFER_SIZE); action.gcsUtils = new GcsUtils(gcsService, BUFFER_SIZE);
task.ghostryde = new Ghostryde(BUFFER_SIZE); action.ghostryde = new Ghostryde(BUFFER_SIZE);
task.jsch = action.jsch =
JSchModule.provideJSch( JSchModule.provideJSch(
keyring.getRdeSshClientPrivateKey(), keyring.getRdeSshClientPublicKey()); keyring.getRdeSshClientPrivateKey(), keyring.getRdeSshClientPublicKey());
task.jschSshSessionFactory = new JSchSshSessionFactory(standardSeconds(3)); action.jschSshSessionFactory = new JSchSshSessionFactory(standardSeconds(3));
task.response = response; action.response = response;
task.pgpCompressionFactory = compressFactory; action.pgpCompressionFactory = compressFactory;
task.pgpEncryptionFactory = encryptFactory; action.pgpEncryptionFactory = encryptFactory;
task.pgpFileFactory = literalFactory; action.pgpFileFactory = literalFactory;
task.pgpSigningFactory = signFactory; action.pgpSigningFactory = signFactory;
task.tarFactory = tarFactory; action.tarFactory = tarFactory;
task.bucket = "bucket"; action.bucket = "bucket";
task.interval = standardDays(1); action.interval = standardDays(1);
task.timeout = standardSeconds(23); action.timeout = standardSeconds(23);
task.tld = "tld"; action.tld = "tld";
task.sftpCooldown = standardSeconds(7); action.sftpCooldown = standardSeconds(7);
task.uploadUrl = uploadUrl; action.uploadUrl = uploadUrl;
task.receiverKey = keyring.getRdeReceiverKey(); action.receiverKey = keyring.getRdeReceiverKey();
task.signingKey = keyring.getRdeSigningKey(); action.signingKey = keyring.getRdeSigningKey();
task.stagingDecryptionKey = keyring.getRdeStagingDecryptionKey(); action.stagingDecryptionKey = keyring.getRdeStagingDecryptionKey();
task.reportQueue = QueueFactory.getQueue("rde-report"); action.reportQueue = QueueFactory.getQueue("rde-report");
task.runner = runner; action.runner = runner;
task.taskEnqueuer = new TaskEnqueuer(new Retrier(null, 1)); action.taskEnqueuer = new TaskEnqueuer(new Retrier(null, 1));
return task; return action;
} }
} }
@ -243,13 +243,13 @@ public class RdeUploadTaskTest {
@Test @Test
public void testRun() throws Exception { public void testRun() throws Exception {
createTld("lol"); createTld("lol");
RdeUploadTask task = createTask(null); RdeUploadAction action = createAction(null);
task.tld = "lol"; action.tld = "lol";
task.run(); action.run();
verify(runner).lockRunAndRollForward( verify(runner).lockRunAndRollForward(
task, Registry.get("lol"), standardSeconds(23), CursorType.RDE_UPLOAD, standardDays(1)); action, Registry.get("lol"), standardSeconds(23), CursorType.RDE_UPLOAD, standardDays(1));
assertTasksEnqueued("rde-report", new TaskMatcher() assertTasksEnqueued("rde-report", new TaskMatcher()
.url(RdeReportTask.PATH) .url(RdeReportAction.PATH)
.param(RequestParameters.PARAM_TLD, "lol")); .param(RequestParameters.PARAM_TLD, "lol"));
verifyNoMoreInteractions(runner); verifyNoMoreInteractions(runner);
} }
@ -264,7 +264,7 @@ public class RdeUploadTaskTest {
DateTime uploadCursor = DateTime.parse("2010-10-17TZ"); DateTime uploadCursor = DateTime.parse("2010-10-17TZ");
persistResource( persistResource(
RegistryCursor.create(Registry.get("tld"), CursorType.RDE_STAGING, stagingCursor)); RegistryCursor.create(Registry.get("tld"), CursorType.RDE_STAGING, stagingCursor));
createTask(uploadUrl).runWithLock(uploadCursor); createAction(uploadUrl).runWithLock(uploadCursor);
assertThat(response.getStatus()).isEqualTo(200); assertThat(response.getStatus()).isEqualTo(200);
assertThat(response.getContentType()).isEqualTo(PLAIN_TEXT_UTF_8); assertThat(response.getContentType()).isEqualTo(PLAIN_TEXT_UTF_8);
assertThat(response.getPayload()).isEqualTo("OK tld 2010-10-17T00:00:00.000Z\n"); assertThat(response.getPayload()).isEqualTo("OK tld 2010-10-17T00:00:00.000Z\n");
@ -283,7 +283,7 @@ public class RdeUploadTaskTest {
DateTime uploadCursor = DateTime.parse("2010-10-17TZ"); DateTime uploadCursor = DateTime.parse("2010-10-17TZ");
persistResource( persistResource(
RegistryCursor.create(Registry.get("tld"), CursorType.RDE_STAGING, stagingCursor)); RegistryCursor.create(Registry.get("tld"), CursorType.RDE_STAGING, stagingCursor));
createTask(uploadUrl).runWithLock(uploadCursor); createAction(uploadUrl).runWithLock(uploadCursor);
assertThat(response.getStatus()).isEqualTo(200); assertThat(response.getStatus()).isEqualTo(200);
assertThat(response.getContentType()).isEqualTo(PLAIN_TEXT_UTF_8); assertThat(response.getContentType()).isEqualTo(PLAIN_TEXT_UTF_8);
assertThat(response.getPayload()).isEqualTo("OK tld 2010-10-17T00:00:00.000Z\n"); assertThat(response.getPayload()).isEqualTo("OK tld 2010-10-17T00:00:00.000Z\n");
@ -311,7 +311,7 @@ public class RdeUploadTaskTest {
DateTime uploadCursor = DateTime.parse("2010-10-17TZ"); DateTime uploadCursor = DateTime.parse("2010-10-17TZ");
persistSimpleResource( persistSimpleResource(
RegistryCursor.create(Registry.get("tld"), CursorType.RDE_STAGING, stagingCursor)); RegistryCursor.create(Registry.get("tld"), CursorType.RDE_STAGING, stagingCursor));
createTask(uploadUrl).runWithLock(uploadCursor); createAction(uploadUrl).runWithLock(uploadCursor);
assertThat(response.getStatus()).isEqualTo(200); assertThat(response.getStatus()).isEqualTo(200);
assertThat(response.getContentType()).isEqualTo(PLAIN_TEXT_UTF_8); assertThat(response.getContentType()).isEqualTo(PLAIN_TEXT_UTF_8);
assertThat(response.getPayload()).isEqualTo("OK tld 2010-10-17T00:00:00.000Z\n"); assertThat(response.getPayload()).isEqualTo("OK tld 2010-10-17T00:00:00.000Z\n");
@ -331,7 +331,7 @@ public class RdeUploadTaskTest {
DateTime uploadCursor = DateTime.parse("2010-10-17TZ"); DateTime uploadCursor = DateTime.parse("2010-10-17TZ");
persistResource( persistResource(
RegistryCursor.create(Registry.get("tld"), CursorType.RDE_STAGING, stagingCursor)); RegistryCursor.create(Registry.get("tld"), CursorType.RDE_STAGING, stagingCursor));
createTask(uploadUrl).runWithLock(uploadCursor); createAction(uploadUrl).runWithLock(uploadCursor);
// Only verify signature for SFTP versions, since we check elsewhere that the GCS files are // Only verify signature for SFTP versions, since we check elsewhere that the GCS files are
// identical to the ones sent over SFTP. // identical to the ones sent over SFTP.
Process pid = gpg.exec("gpg", "--verify", Process pid = gpg.exec("gpg", "--verify",
@ -349,8 +349,8 @@ public class RdeUploadTaskTest {
DateTime uploadCursor = DateTime.parse("2010-10-17TZ"); DateTime uploadCursor = DateTime.parse("2010-10-17TZ");
persistResource( persistResource(
RegistryCursor.create(Registry.get("tld"), CursorType.RDE_STAGING, stagingCursor)); RegistryCursor.create(Registry.get("tld"), CursorType.RDE_STAGING, stagingCursor));
thrown.expect(ServiceUnavailableException.class, "Waiting for RdeStagingTask to complete"); thrown.expect(ServiceUnavailableException.class, "Waiting for RdeStagingAction to complete");
createTask(null).runWithLock(uploadCursor); createAction(null).runWithLock(uploadCursor);
} }
private String slurp(InputStream is) throws FileNotFoundException, IOException { private String slurp(InputStream is) throws FileNotFoundException, IOException {

View file

@ -38,7 +38,7 @@ import org.mockito.runners.MockitoJUnitRunner;
/** Common code for unit tests of classes that extend {@link Marksdb}. */ /** Common code for unit tests of classes that extend {@link Marksdb}. */
@RunWith(MockitoJUnitRunner.class) @RunWith(MockitoJUnitRunner.class)
public class TmchTaskTestCase { public class TmchActionTestCase {
static final String MARKSDB_LOGIN = "lolcat:attack"; static final String MARKSDB_LOGIN = "lolcat:attack";
static final String MARKSDB_LOGIN_BASE64 = "bG9sY2F0OmF0dGFjaw=="; static final String MARKSDB_LOGIN_BASE64 = "bG9sY2F0OmF0dGFjaw==";

View file

@ -28,14 +28,14 @@ import java.security.SignatureException;
import java.security.cert.CRLException; import java.security.cert.CRLException;
import java.security.cert.CertificateNotYetValidException; import java.security.cert.CertificateNotYetValidException;
/** Unit tests for {@link TmchCrlTask}. */ /** Unit tests for {@link TmchCrlAction}. */
public class TmchCrlTaskTest extends TmchTaskTestCase { public class TmchCrlActionTest extends TmchActionTestCase {
private TmchCrlTask newTmchCrlTask() throws MalformedURLException { private TmchCrlAction newTmchCrlAction() throws MalformedURLException {
TmchCrlTask result = new TmchCrlTask(); TmchCrlAction action = new TmchCrlAction();
result.marksdb = marksdb; action.marksdb = marksdb;
result.tmchCrlUrl = new URL("http://sloth.lol/tmch.crl"); action.tmchCrlUrl = new URL("http://sloth.lol/tmch.crl");
return result; return action;
} }
@Test @Test
@ -44,7 +44,7 @@ public class TmchCrlTaskTest extends TmchTaskTestCase {
configRule.useTmchProdCert(); configRule.useTmchProdCert();
when(httpResponse.getContent()).thenReturn( when(httpResponse.getContent()).thenReturn(
readResourceBytes(TmchCertificateAuthority.class, "icann-tmch.crl").read()); readResourceBytes(TmchCertificateAuthority.class, "icann-tmch.crl").read());
newTmchCrlTask().run(); newTmchCrlAction().run();
verify(httpResponse).getContent(); verify(httpResponse).getContent();
verify(fetchService).fetch(httpRequest.capture()); verify(fetchService).fetch(httpRequest.capture());
assertThat(httpRequest.getValue().getURL().toString()).isEqualTo("http://sloth.lol/tmch.crl"); assertThat(httpRequest.getValue().getURL().toString()).isEqualTo("http://sloth.lol/tmch.crl");
@ -57,7 +57,7 @@ public class TmchCrlTaskTest extends TmchTaskTestCase {
when(httpResponse.getContent()).thenReturn( when(httpResponse.getContent()).thenReturn(
readResourceBytes(TmchCertificateAuthority.class, "icann-tmch-test.crl").read()); readResourceBytes(TmchCertificateAuthority.class, "icann-tmch-test.crl").read());
thrown.expectRootCause(CRLException.class, "New CRL is more out of date than our current CRL."); thrown.expectRootCause(CRLException.class, "New CRL is more out of date than our current CRL.");
newTmchCrlTask().run(); newTmchCrlAction().run();
} }
@Test @Test
@ -66,7 +66,7 @@ public class TmchCrlTaskTest extends TmchTaskTestCase {
when(httpResponse.getContent()).thenReturn( when(httpResponse.getContent()).thenReturn(
readResourceBytes(TmchCertificateAuthority.class, "icann-tmch.crl").read()); readResourceBytes(TmchCertificateAuthority.class, "icann-tmch.crl").read());
thrown.expectRootCause(SignatureException.class, "Signature does not match."); thrown.expectRootCause(SignatureException.class, "Signature does not match.");
newTmchCrlTask().run(); newTmchCrlAction().run();
} }
@Test @Test
@ -75,6 +75,6 @@ public class TmchCrlTaskTest extends TmchTaskTestCase {
when(httpResponse.getContent()).thenReturn( when(httpResponse.getContent()).thenReturn(
readResourceBytes(TmchCertificateAuthority.class, "icann-tmch-test.crl").read()); readResourceBytes(TmchCertificateAuthority.class, "icann-tmch-test.crl").read());
thrown.expectRootCause(CertificateNotYetValidException.class); thrown.expectRootCause(CertificateNotYetValidException.class);
newTmchCrlTask().run(); newTmchCrlAction().run();
} }
} }

View file

@ -25,14 +25,14 @@ import com.google.domain.registry.model.tmch.ClaimsListShard;
import org.joda.time.DateTime; import org.joda.time.DateTime;
import org.junit.Test; import org.junit.Test;
/** Unit tests for {@link TmchDnlTask}. */ /** Unit tests for {@link TmchDnlAction}. */
public class TmchDnlTaskTest extends TmchTaskTestCase { public class TmchDnlActionTest extends TmchActionTestCase {
private TmchDnlTask newTmchDnlTask() { private TmchDnlAction newTmchDnlAction() {
TmchDnlTask result = new TmchDnlTask(); TmchDnlAction action = new TmchDnlAction();
result.marksdb = marksdb; action.marksdb = marksdb;
result.marksdbDnlLogin = Optional.of(MARKSDB_LOGIN); action.marksdbDnlLogin = Optional.of(MARKSDB_LOGIN);
return result; return action;
} }
@Test @Test
@ -41,7 +41,7 @@ public class TmchDnlTaskTest extends TmchTaskTestCase {
when(httpResponse.getContent()) when(httpResponse.getContent())
.thenReturn(TmchTestData.loadBytes("dnl-latest.csv").read()) .thenReturn(TmchTestData.loadBytes("dnl-latest.csv").read())
.thenReturn(TmchTestData.loadBytes("dnl-latest.sig").read()); .thenReturn(TmchTestData.loadBytes("dnl-latest.sig").read());
newTmchDnlTask().run(); newTmchDnlAction().run();
verify(fetchService, times(2)).fetch(httpRequest.capture()); verify(fetchService, times(2)).fetch(httpRequest.capture());
assertThat(httpRequest.getAllValues().get(0).getURL().toString()) assertThat(httpRequest.getAllValues().get(0).getURL().toString())
.isEqualTo(MARKSDB_URL + "/dnl/dnl-latest.csv"); .isEqualTo(MARKSDB_URL + "/dnl/dnl-latest.csv");

View file

@ -26,16 +26,16 @@ import com.google.domain.registry.model.smd.SignedMarkRevocationList;
import org.joda.time.DateTime; import org.joda.time.DateTime;
import org.junit.Test; import org.junit.Test;
/** Unit tests for {@link TmchSmdrlTask}. */ /** Unit tests for {@link TmchSmdrlAction}. */
public class TmchSmdrlTaskTest extends TmchTaskTestCase { public class TmchSmdrlActionTest extends TmchActionTestCase {
private static final DateTime now = DateTime.parse("2014-01-01T00:00:00Z"); private static final DateTime now = DateTime.parse("2014-01-01T00:00:00Z");
private TmchSmdrlTask newTmchSmdrlTask() { private TmchSmdrlAction newTmchSmdrlAction() {
TmchSmdrlTask result = new TmchSmdrlTask(); TmchSmdrlAction action = new TmchSmdrlAction();
result.marksdb = marksdb; action.marksdb = marksdb;
result.marksdbSmdrlLogin = Optional.absent(); action.marksdbSmdrlLogin = Optional.absent();
return result; return action;
} }
@Test @Test
@ -46,7 +46,7 @@ public class TmchSmdrlTaskTest extends TmchTaskTestCase {
when(httpResponse.getContent()) when(httpResponse.getContent())
.thenReturn(loadBytes("smdrl-latest.csv").read()) .thenReturn(loadBytes("smdrl-latest.csv").read())
.thenReturn(loadBytes("smdrl-latest.sig").read()); .thenReturn(loadBytes("smdrl-latest.sig").read());
newTmchSmdrlTask().run(); newTmchSmdrlAction().run();
verify(fetchService, times(2)).fetch(httpRequest.capture()); verify(fetchService, times(2)).fetch(httpRequest.capture());
assertThat(httpRequest.getAllValues().get(0).getURL().toString()) assertThat(httpRequest.getAllValues().get(0).getURL().toString())
.isEqualTo(MARKSDB_URL + "/smdrl/smdrl-latest.csv"); .isEqualTo(MARKSDB_URL + "/smdrl/smdrl-latest.csv");

View file

@ -26,9 +26,9 @@ import org.junit.runners.Suite.SuiteClasses;
NordnVerifyAction.class, NordnVerifyAction.class,
SmdrlCsvParserTest.class, SmdrlCsvParserTest.class,
TmchCertificateAuthorityTest.class, TmchCertificateAuthorityTest.class,
TmchCrlTaskTest.class, TmchCrlActionTest.class,
TmchDnlTaskTest.class, TmchDnlActionTest.class,
TmchSmdrlTaskTest.class, TmchSmdrlActionTest.class,
TmchXmlSignatureTest.class, TmchXmlSignatureTest.class,
}) })
class TmchTestSuite {} class TmchTestSuite {}

View file

@ -38,10 +38,10 @@ import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner; import org.mockito.runners.MockitoJUnitRunner;
/** /**
* Unit tests for {@link CreateGroupsTask}. * Unit tests for {@link CreateGroupsAction}.
*/ */
@RunWith(MockitoJUnitRunner.class) @RunWith(MockitoJUnitRunner.class)
public class CreateGroupsTaskTest { public class CreateGroupsActionTest {
@Rule @Rule
public final AppEngineRule appEngine = AppEngineRule.builder() public final AppEngineRule appEngine = AppEngineRule.builder()
@ -60,32 +60,32 @@ public class CreateGroupsTaskTest {
@Mock @Mock
private Response response; private Response response;
private void runTask(String clientId) { private void runAction(String clientId) {
CreateGroupsTask task = new CreateGroupsTask(); CreateGroupsAction action = new CreateGroupsAction();
task.response = response; action.response = response;
task.groupsConnection = connection; action.groupsConnection = connection;
task.publicDomainName = "domain-registry.example"; action.publicDomainName = "domain-registry.example";
task.clientId = Optional.fromNullable(clientId); action.clientId = Optional.fromNullable(clientId);
task.run(); action.run();
} }
@Test @Test
public void test_invalidRequest_missingClientId() throws Exception { public void test_invalidRequest_missingClientId() throws Exception {
thrown.expect(BadRequestException.class, thrown.expect(BadRequestException.class,
"Error creating Google Groups, missing parameter: clientId"); "Error creating Google Groups, missing parameter: clientId");
runTask(null); runAction(null);
} }
@Test @Test
public void test_invalidRequest_invalidClientId() throws Exception { public void test_invalidRequest_invalidClientId() throws Exception {
thrown.expect(BadRequestException.class, thrown.expect(BadRequestException.class,
"Error creating Google Groups; could not find registrar with id completelyMadeUpClientId"); "Error creating Google Groups; could not find registrar with id completelyMadeUpClientId");
runTask("completelyMadeUpClientId"); runAction("completelyMadeUpClientId");
} }
@Test @Test
public void test_createsAllGroupsSuccessfully() throws Exception { public void test_createsAllGroupsSuccessfully() throws Exception {
runTask("NewRegistrar"); runAction("NewRegistrar");
verify(response).setStatus(SC_OK); verify(response).setStatus(SC_OK);
verify(response).setPayload("Success!"); verify(response).setPayload("Success!");
verifyGroupCreationCallsForNewRegistrar(); verifyGroupCreationCallsForNewRegistrar();
@ -103,7 +103,7 @@ public class CreateGroupsTaskTest {
"newregistrar-technical-contacts@domain-registry.example", "newregistrar-technical-contacts@domain-registry.example",
Role.MEMBER); Role.MEMBER);
try { try {
runTask("NewRegistrar"); runAction("NewRegistrar");
} catch (InternalServerErrorException e) { } catch (InternalServerErrorException e) {
String responseString = e.toString(); String responseString = e.toString();
assertThat(responseString).contains("abuse => Success"); assertThat(responseString).contains("abuse => Success");

View file

@ -26,7 +26,7 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.domain.registry.export.sheet.SyncRegistrarsSheetTask; import com.google.domain.registry.export.sheet.SyncRegistrarsSheetAction;
import com.google.domain.registry.model.registrar.Registrar; import com.google.domain.registry.model.registrar.Registrar;
import com.google.domain.registry.testing.TaskQueueHelper.TaskMatcher; import com.google.domain.registry.testing.TaskQueueHelper.TaskMatcher;
@ -54,7 +54,7 @@ public class RegistrarServletTest extends RegistrarServletTestCase {
new InternetAddress("notification2@test.example")); new InternetAddress("notification2@test.example"));
assertThat(message.getContent()).isEqualTo(expectedEmailBody); assertThat(message.getContent()).isEqualTo(expectedEmailBody);
assertTasksEnqueued("sheet", new TaskMatcher() assertTasksEnqueued("sheet", new TaskMatcher()
.url(SyncRegistrarsSheetTask.PATH) .url(SyncRegistrarsSheetAction.PATH)
.method("GET") .method("GET")
.header("Host", "backend.hostname")); .header("Host", "backend.hostname"));
} }

View file

@ -23,7 +23,7 @@ import static org.mockito.Mockito.when;
import com.google.appengine.api.modules.ModulesService; import com.google.appengine.api.modules.ModulesService;
import com.google.common.base.Supplier; import com.google.common.base.Supplier;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.domain.registry.export.sheet.SyncRegistrarsSheetTask; import com.google.domain.registry.export.sheet.SyncRegistrarsSheetAction;
import com.google.domain.registry.model.ofy.Ofy; import com.google.domain.registry.model.ofy.Ofy;
import com.google.domain.registry.testing.AppEngineRule; import com.google.domain.registry.testing.AppEngineRule;
import com.google.domain.registry.testing.ExceptionRule; import com.google.domain.registry.testing.ExceptionRule;
@ -95,7 +95,7 @@ public class RegistrarServletTestCase {
inject.setStaticField(Ofy.class, "clock", clock); inject.setStaticField(Ofy.class, "clock", clock);
inject.setStaticField(ResourceServlet.class, "sessionUtils", sessionUtils); inject.setStaticField(ResourceServlet.class, "sessionUtils", sessionUtils);
inject.setStaticField(SendEmailUtils.class, "emailService", emailService); inject.setStaticField(SendEmailUtils.class, "emailService", emailService);
inject.setStaticField(SyncRegistrarsSheetTask.class, "modulesService", modulesService); inject.setStaticField(SyncRegistrarsSheetAction.class, "modulesService", modulesService);
message = new MimeMessage(Session.getDefaultInstance(new Properties(), null)); message = new MimeMessage(Session.getDefaultInstance(new Properties(), null));
when(emailService.createMessage()).thenReturn(message); when(emailService.createMessage()).thenReturn(message);
when(req.getMethod()).thenReturn("POST"); when(req.getMethod()).thenReturn("POST");