mirror of
https://github.com/google/nomulus.git
synced 2025-08-05 09:21:49 +02:00
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:
parent
5f7bf57cf9
commit
57fa57968d
48 changed files with 320 additions and 318 deletions
|
@ -78,12 +78,12 @@ public final class DnsInjectionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testWriteDnsTask_injectsAndWorks() throws Exception {
|
||||
public void testWriteDnsAction_injectsAndWorks() throws Exception {
|
||||
persistActiveSubordinateHost("ns1.example.lol", persistActiveDomain("example.lol"));
|
||||
clock.advanceOneMilli();
|
||||
dnsQueue.addDomainRefreshTask("example.lol");
|
||||
when(req.getParameter("tld")).thenReturn("lol");
|
||||
component.writeDnsTask().run();
|
||||
component.writeDnsAction().run();
|
||||
assertNoDnsTasksEnqueued();
|
||||
}
|
||||
|
||||
|
|
|
@ -32,6 +32,6 @@ import dagger.Component;
|
|||
})
|
||||
interface DnsTestComponent {
|
||||
DnsQueue dnsQueue();
|
||||
RefreshDns refreshDns();
|
||||
WriteDnsTask writeDnsTask();
|
||||
RefreshDnsAction refreshDns();
|
||||
WriteDnsAction writeDnsAction();
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ import org.mockito.runners.MockitoJUnitRunner;
|
|||
|
||||
import javax.inject.Provider;
|
||||
|
||||
/** Unit tests for {@link WriteDnsTask}. */
|
||||
/** Unit tests for {@link WriteDnsAction}. */
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class PublishDnsUpdatesActionTest {
|
||||
|
||||
|
|
|
@ -36,9 +36,9 @@ import org.junit.Test;
|
|||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
|
||||
/** Unit tests for {@link RefreshDns}. */
|
||||
/** Unit tests for {@link RefreshDnsAction}. */
|
||||
@RunWith(JUnit4.class)
|
||||
public class RefreshDnsTest {
|
||||
public class RefreshDnsActionTest {
|
||||
|
||||
@Rule
|
||||
public final AppEngineRule appEngine = AppEngineRule.builder()
|
||||
|
@ -53,12 +53,12 @@ public class RefreshDnsTest {
|
|||
private final FakeClock clock = new FakeClock();
|
||||
|
||||
private void run(TargetType type, String name) {
|
||||
RefreshDns refreshDns = new RefreshDns();
|
||||
refreshDns.clock = clock;
|
||||
refreshDns.domainOrHostName = name;
|
||||
refreshDns.type = type;
|
||||
refreshDns.dnsQueue = dnsQueue;
|
||||
refreshDns.run();
|
||||
RefreshDnsAction action = new RefreshDnsAction();
|
||||
action.clock = clock;
|
||||
action.domainOrHostName = name;
|
||||
action.type = type;
|
||||
action.dnsQueue = dnsQueue;
|
||||
action.run();
|
||||
}
|
||||
|
||||
@Before
|
|
@ -46,9 +46,9 @@ import org.mockito.runners.MockitoJUnitRunner;
|
|||
|
||||
import javax.inject.Provider;
|
||||
|
||||
/** Unit tests for {@link WriteDnsTask}. */
|
||||
/** Unit tests for {@link WriteDnsAction}. */
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class WriteDnsTaskTest {
|
||||
public class WriteDnsActionTest {
|
||||
|
||||
@Rule
|
||||
public final AppEngineRule appEngine = AppEngineRule.builder()
|
||||
|
@ -77,16 +77,16 @@ public class WriteDnsTaskTest {
|
|||
}
|
||||
|
||||
private void run(String tld) {
|
||||
WriteDnsTask task = new WriteDnsTask();
|
||||
task.dnsQueue = dnsQueue;
|
||||
task.timeout = Duration.standardSeconds(10);
|
||||
task.tld = tld;
|
||||
task.writerProvider = new Provider<DnsWriter>() {
|
||||
WriteDnsAction action = new WriteDnsAction();
|
||||
action.dnsQueue = dnsQueue;
|
||||
action.timeout = Duration.standardSeconds(10);
|
||||
action.tld = tld;
|
||||
action.writerProvider = new Provider<DnsWriter>() {
|
||||
@Override
|
||||
public DnsWriter get() {
|
||||
return dnsWriter;
|
||||
}};
|
||||
task.run();
|
||||
action.run();
|
||||
}
|
||||
|
||||
@After
|
|
@ -14,8 +14,8 @@
|
|||
|
||||
package com.google.domain.registry.export;
|
||||
|
||||
import static com.google.domain.registry.export.ExportReservedTermsTask.EXPORT_MIME_TYPE;
|
||||
import static com.google.domain.registry.export.ExportReservedTermsTask.RESERVED_TERMS_FILENAME;
|
||||
import static com.google.domain.registry.export.ExportReservedTermsAction.EXPORT_MIME_TYPE;
|
||||
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.persistReservedList;
|
||||
import static com.google.domain.registry.testing.DatastoreHelper.persistResource;
|
||||
|
@ -47,9 +47,9 @@ import org.mockito.runners.MockitoJUnitRunner;
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
/** Unit tests for {@link ExportReservedTermsTask}. */
|
||||
/** Unit tests for {@link ExportReservedTermsAction}. */
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class ExportReservedTermsTaskTest {
|
||||
public class ExportReservedTermsActionTest {
|
||||
|
||||
@Rule
|
||||
public final AppEngineRule appEngine = AppEngineRule.builder()
|
||||
|
@ -68,12 +68,12 @@ public class ExportReservedTermsTaskTest {
|
|||
@Mock
|
||||
private Response response;
|
||||
|
||||
private void runTask(String tld) {
|
||||
ExportReservedTermsTask task = new ExportReservedTermsTask();
|
||||
task.response = response;
|
||||
task.driveConnection = driveConnection;
|
||||
task.tld = tld;
|
||||
task.run();
|
||||
private void runAction(String tld) {
|
||||
ExportReservedTermsAction action = new ExportReservedTermsAction();
|
||||
action.response = response;
|
||||
action.driveConnection = driveConnection;
|
||||
action.tld = tld;
|
||||
action.run();
|
||||
}
|
||||
|
||||
@Before
|
||||
|
@ -96,7 +96,7 @@ public class ExportReservedTermsTaskTest {
|
|||
|
||||
@Test
|
||||
public void test_uploadFileToDrive_succeeds() throws Exception {
|
||||
runTask("tld");
|
||||
runAction("tld");
|
||||
byte[] expected =
|
||||
("This is a disclaimer.\ncat\nlol\n")
|
||||
.getBytes(UTF_8);
|
||||
|
@ -112,7 +112,7 @@ public class ExportReservedTermsTaskTest {
|
|||
.setReservedLists(ImmutableSet.<ReservedList>of())
|
||||
.setDriveFolderId(null)
|
||||
.build());
|
||||
runTask("tld");
|
||||
runAction("tld");
|
||||
verify(response).setStatus(SC_OK);
|
||||
verify(response).setPayload("No reserved lists configured");
|
||||
}
|
||||
|
@ -121,7 +121,7 @@ public class ExportReservedTermsTaskTest {
|
|||
public void test_uploadFileToDrive_failsWhenDriveFolderIdIsNull() throws Exception {
|
||||
thrown.expectRootCause(NullPointerException.class, "No drive folder associated with this TLD");
|
||||
persistResource(Registry.get("tld").asBuilder().setDriveFolderId(null).build());
|
||||
runTask("tld");
|
||||
runAction("tld");
|
||||
verify(response).setStatus(SC_INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
|
@ -133,7 +133,7 @@ public class ExportReservedTermsTaskTest {
|
|||
any(MediaType.class),
|
||||
anyString(),
|
||||
any(byte[].class))).thenThrow(new IOException("errorMessage"));
|
||||
runTask("tld");
|
||||
runAction("tld");
|
||||
verify(response).setStatus(SC_INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
|
@ -141,7 +141,7 @@ public class ExportReservedTermsTaskTest {
|
|||
public void test_uploadFileToDrive_failsWhenTldDoesntExist() throws Exception {
|
||||
thrown.expectRootCause(
|
||||
RegistryNotFoundException.class, "No registry object found for fakeTld");
|
||||
runTask("fakeTld");
|
||||
runAction("fakeTld");
|
||||
verify(response).setStatus(SC_INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
|
@ -15,7 +15,7 @@
|
|||
package com.google.domain.registry.export;
|
||||
|
||||
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.registrar.RegistrarContact.Type.ADMIN;
|
||||
import static com.google.domain.registry.model.registrar.RegistrarContact.Type.MARKETING;
|
||||
|
@ -47,13 +47,13 @@ import org.mockito.runners.MockitoJUnitRunner;
|
|||
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
|
||||
* {@link AppEngineRule}.
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class SyncGroupMembersTaskTest {
|
||||
public class SyncGroupMembersActionTest {
|
||||
|
||||
@Rule
|
||||
public final AppEngineRule appEngine = AppEngineRule.builder()
|
||||
|
@ -72,12 +72,12 @@ public class SyncGroupMembersTaskTest {
|
|||
@Mock
|
||||
private Response response;
|
||||
|
||||
private void runTask() {
|
||||
SyncGroupMembersTask task = new SyncGroupMembersTask();
|
||||
task.groupsConnection = connection;
|
||||
task.response = response;
|
||||
task.publicDomainName = "domain-registry.example";
|
||||
task.run();
|
||||
private void runAction() {
|
||||
SyncGroupMembersAction action = new SyncGroupMembersAction();
|
||||
action.groupsConnection = connection;
|
||||
action.response = response;
|
||||
action.publicDomainName = "domain-registry.example";
|
||||
action.run();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -108,7 +108,7 @@ public class SyncGroupMembersTaskTest {
|
|||
.asBuilder()
|
||||
.setContactsRequireSyncing(false)
|
||||
.build());
|
||||
runTask();
|
||||
runAction();
|
||||
verify(response).setStatus(SC_OK);
|
||||
verify(response).setPayload("NOT_MODIFIED No registrar contacts have been updated "
|
||||
+ "since the last time servlet ran.\n");
|
||||
|
@ -117,7 +117,7 @@ public class SyncGroupMembersTaskTest {
|
|||
|
||||
@Test
|
||||
public void test_doPost_syncsNewContact() throws Exception {
|
||||
runTask();
|
||||
runAction();
|
||||
verify(connection).addMemberToGroup(
|
||||
"newregistrar-primary-contacts@domain-registry.example",
|
||||
"janedoe@theregistrar.com",
|
||||
|
@ -131,7 +131,7 @@ public class SyncGroupMembersTaskTest {
|
|||
public void test_doPost_removesOldContact() throws Exception {
|
||||
when(connection.getMembersOfGroup("newregistrar-primary-contacts@domain-registry.example"))
|
||||
.thenReturn(ImmutableSet.of("defunct@example.com", "janedoe@theregistrar.com"));
|
||||
runTask();
|
||||
runAction();
|
||||
verify(connection).removeMemberFromGroup(
|
||||
"newregistrar-primary-contacts@domain-registry.example", "defunct@example.com");
|
||||
verify(response).setStatus(SC_OK);
|
||||
|
@ -145,7 +145,7 @@ public class SyncGroupMembersTaskTest {
|
|||
ofy().deleteWithoutBackup()
|
||||
.entities(Registrar.loadByClientId("NewRegistrar").getContacts())
|
||||
.now();
|
||||
runTask();
|
||||
runAction();
|
||||
verify(connection).removeMemberFromGroup(
|
||||
"newregistrar-primary-contacts@domain-registry.example", "defunct@example.com");
|
||||
verify(connection).removeMemberFromGroup(
|
||||
|
@ -178,7 +178,7 @@ public class SyncGroupMembersTaskTest {
|
|||
.setEmailAddress("hexadecimal@snow.fall")
|
||||
.setTypes(ImmutableSet.of(TECH))
|
||||
.build());
|
||||
runTask();
|
||||
runAction();
|
||||
verify(connection).removeMemberFromGroup(
|
||||
"newregistrar-primary-contacts@domain-registry.example", "defunct@example.com");
|
||||
verify(connection).addMemberToGroup(
|
||||
|
@ -211,7 +211,7 @@ public class SyncGroupMembersTaskTest {
|
|||
.thenReturn(ImmutableSet.<String> of());
|
||||
when(connection.getMembersOfGroup("theregistrar-primary-contacts@domain-registry.example"))
|
||||
.thenThrow(new IOException("Internet was deleted"));
|
||||
runTask();
|
||||
runAction();
|
||||
verify(connection).addMemberToGroup(
|
||||
"newregistrar-primary-contacts@domain-registry.example",
|
||||
"janedoe@theregistrar.com",
|
|
@ -39,9 +39,9 @@ import java.util.concurrent.Callable;
|
|||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/** Unit tests for {@link SyncRegistrarsSheetTask}. */
|
||||
/** Unit tests for {@link SyncRegistrarsSheetAction}. */
|
||||
@RunWith(JUnit4.class)
|
||||
public class SyncRegistrarsSheetTaskTest {
|
||||
public class SyncRegistrarsSheetActionTest {
|
||||
|
||||
@Rule
|
||||
public final AppEngineRule appEngine = AppEngineRule.builder()
|
||||
|
@ -52,20 +52,20 @@ public class SyncRegistrarsSheetTaskTest {
|
|||
private final FakeResponse response = new FakeResponse();
|
||||
private final SyncRegistrarsSheet syncRegistrarsSheet = mock(SyncRegistrarsSheet.class);
|
||||
|
||||
private void runTask(@Nullable String idConfig, @Nullable String idParam) {
|
||||
SyncRegistrarsSheetTask task = new SyncRegistrarsSheetTask();
|
||||
task.response = response;
|
||||
task.syncRegistrarsSheet = syncRegistrarsSheet;
|
||||
task.idConfig = Optional.fromNullable(idConfig);
|
||||
task.idParam = Optional.fromNullable(idParam);
|
||||
task.interval = Duration.standardHours(1);
|
||||
task.timeout = Duration.standardHours(1);
|
||||
task.run();
|
||||
private void runAction(@Nullable String idConfig, @Nullable String idParam) {
|
||||
SyncRegistrarsSheetAction action = new SyncRegistrarsSheetAction();
|
||||
action.response = response;
|
||||
action.syncRegistrarsSheet = syncRegistrarsSheet;
|
||||
action.idConfig = Optional.fromNullable(idConfig);
|
||||
action.idParam = Optional.fromNullable(idParam);
|
||||
action.interval = Duration.standardHours(1);
|
||||
action.timeout = Duration.standardHours(1);
|
||||
action.run();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPost_withoutParamsOrSystemProperty_dropsTask() throws Exception {
|
||||
runTask(null, null);
|
||||
runAction(null, null);
|
||||
assertThat(response.getPayload()).startsWith("MISSINGNO");
|
||||
verifyZeroInteractions(syncRegistrarsSheet);
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ public class SyncRegistrarsSheetTaskTest {
|
|||
@Test
|
||||
public void testPost_withoutParams_runsSyncWithDefaultIdAndChecksIfModified() throws Exception {
|
||||
when(syncRegistrarsSheet.wasRegistrarsModifiedInLast(any(Duration.class))).thenReturn(true);
|
||||
runTask("jazz", null);
|
||||
runAction("jazz", null);
|
||||
assertThat(response.getStatus()).isEqualTo(200);
|
||||
assertThat(response.getContentType()).isEqualTo(PLAIN_TEXT_UTF_8);
|
||||
assertThat(response.getPayload()).startsWith("OK");
|
||||
|
@ -85,7 +85,7 @@ public class SyncRegistrarsSheetTaskTest {
|
|||
@Test
|
||||
public void testPost_noModificationsToRegistrarEntities_doesNothing() throws Exception {
|
||||
when(syncRegistrarsSheet.wasRegistrarsModifiedInLast(any(Duration.class))).thenReturn(false);
|
||||
runTask("NewRegistrar", null);
|
||||
runAction("NewRegistrar", null);
|
||||
assertThat(response.getPayload()).startsWith("NOTMODIFIED");
|
||||
verify(syncRegistrarsSheet).wasRegistrarsModifiedInLast(any(Duration.class));
|
||||
verifyNoMoreInteractions(syncRegistrarsSheet);
|
||||
|
@ -93,7 +93,7 @@ public class SyncRegistrarsSheetTaskTest {
|
|||
|
||||
@Test
|
||||
public void testPost_overrideId_runsSyncWithCustomIdAndDoesNotCheckModified() throws Exception {
|
||||
runTask(null, "foobar");
|
||||
runAction(null, "foobar");
|
||||
assertThat(response.getPayload()).startsWith("OK");
|
||||
verify(syncRegistrarsSheet).run(eq("foobar"));
|
||||
verifyNoMoreInteractions(syncRegistrarsSheet);
|
||||
|
@ -105,10 +105,10 @@ public class SyncRegistrarsSheetTaskTest {
|
|||
Lock.executeWithLocks(new Callable<Void>() {
|
||||
@Override
|
||||
public Void call() throws Exception {
|
||||
runTask(null, "foobar");
|
||||
runAction(null, "foobar");
|
||||
return null;
|
||||
}
|
||||
}, SyncRegistrarsSheetTask.class, "", Duration.standardHours(1), lockName);
|
||||
}, SyncRegistrarsSheetAction.class, "", Duration.standardHours(1), lockName);
|
||||
assertThat(response.getPayload()).startsWith("LOCKED");
|
||||
verifyZeroInteractions(syncRegistrarsSheet);
|
||||
}
|
|
@ -53,9 +53,9 @@ import java.io.IOException;
|
|||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
|
||||
/** Unit tests for {@link BrdaCopyTask}. */
|
||||
/** Unit tests for {@link BrdaCopyAction}. */
|
||||
@RunWith(JUnit4.class)
|
||||
public class BrdaCopyTaskTest {
|
||||
public class BrdaCopyActionTest {
|
||||
|
||||
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 GcsUtils gcsUtils = new GcsUtils(gcsService, 1024);
|
||||
private final BrdaCopyTask task = new BrdaCopyTask();
|
||||
private final BrdaCopyAction action = new BrdaCopyAction();
|
||||
|
||||
@Before
|
||||
public void before() throws Exception {
|
||||
task.gcsUtils = gcsUtils;
|
||||
task.ghostryde = new Ghostryde(23);
|
||||
task.pgpCompressionFactory = new RydePgpCompressionOutputStreamFactory(Providers.of(1024));
|
||||
task.pgpEncryptionFactory = new RydePgpEncryptionOutputStreamFactory(Providers.of(1024));
|
||||
task.pgpFileFactory = new RydePgpFileOutputStreamFactory(Providers.of(1024));
|
||||
task.pgpSigningFactory = new RydePgpSigningOutputStreamFactory();
|
||||
task.tarFactory = new RydeTarOutputStreamFactory();
|
||||
task.tld = "lol";
|
||||
task.watermark = DateTime.parse("2010-10-17TZ");
|
||||
task.brdaBucket = "tub";
|
||||
task.stagingBucket = "keg";
|
||||
task.receiverKey = receiverKey;
|
||||
task.signingKey = signingKey;
|
||||
task.stagingDecryptionKey = decryptKey;
|
||||
action.gcsUtils = gcsUtils;
|
||||
action.ghostryde = new Ghostryde(23);
|
||||
action.pgpCompressionFactory = new RydePgpCompressionOutputStreamFactory(Providers.of(1024));
|
||||
action.pgpEncryptionFactory = new RydePgpEncryptionOutputStreamFactory(Providers.of(1024));
|
||||
action.pgpFileFactory = new RydePgpFileOutputStreamFactory(Providers.of(1024));
|
||||
action.pgpSigningFactory = new RydePgpSigningOutputStreamFactory();
|
||||
action.tarFactory = new RydeTarOutputStreamFactory();
|
||||
action.tld = "lol";
|
||||
action.watermark = DateTime.parse("2010-10-17TZ");
|
||||
action.brdaBucket = "tub";
|
||||
action.stagingBucket = "keg";
|
||||
action.receiverKey = receiverKey;
|
||||
action.signingKey = signingKey;
|
||||
action.stagingDecryptionKey = decryptKey;
|
||||
|
||||
byte[] xml = DEPOSIT_XML.read();
|
||||
GcsTestingUtils.writeGcsFile(gcsService, STAGE_FILE,
|
||||
|
@ -126,7 +126,7 @@ public class BrdaCopyTaskTest {
|
|||
|
||||
@Test
|
||||
public void testRun() throws Exception {
|
||||
task.run();
|
||||
action.run();
|
||||
assertThat(gcsUtils.existsAndNotEmpty(STAGE_FILE)).isTrue();
|
||||
assertThat(gcsUtils.existsAndNotEmpty(RYDE_FILE)).isTrue();
|
||||
assertThat(gcsUtils.existsAndNotEmpty(SIG_FILE)).isTrue();
|
||||
|
@ -135,7 +135,7 @@ public class BrdaCopyTaskTest {
|
|||
@Test
|
||||
public void testRun_rydeFormat() throws Exception {
|
||||
assumeTrue(hasCommand("gpg --version"));
|
||||
task.run();
|
||||
action.run();
|
||||
|
||||
File rydeTmp = new File(gpg.getCwd(), "ryde");
|
||||
Files.write(readGcsFile(gcsService, RYDE_FILE), rydeTmp);
|
||||
|
@ -174,7 +174,7 @@ public class BrdaCopyTaskTest {
|
|||
@Test
|
||||
public void testRun_rydeSignature() throws Exception {
|
||||
assumeTrue(hasCommand("gpg --version"));
|
||||
task.run();
|
||||
action.run();
|
||||
|
||||
File rydeTmp = new File(gpg.getCwd(), "ryde");
|
||||
File sigTmp = new File(gpg.getCwd(), "ryde.sig");
|
|
@ -66,9 +66,9 @@ import org.mockito.ArgumentCaptor;
|
|||
import java.io.ByteArrayInputStream;
|
||||
import java.util.Map;
|
||||
|
||||
/** Unit tests for {@link RdeReportTask}. */
|
||||
/** Unit tests for {@link RdeReportAction}. */
|
||||
@RunWith(JUnit4.class)
|
||||
public class RdeReportTaskTest {
|
||||
public class RdeReportActionTest {
|
||||
|
||||
private static final ByteSource REPORT_XML = RdeTestData.get("report.xml");
|
||||
private static final ByteSource IIRDEA_BAD_XML = RdeTestData.get("iirdea_bad.xml");
|
||||
|
@ -96,24 +96,24 @@ public class RdeReportTaskTest {
|
|||
private final GcsFilename reportFile =
|
||||
new GcsFilename("tub", "test_2006-06-06_full_S1_R0-report.xml.ghostryde");
|
||||
|
||||
private RdeReportTask createTask() {
|
||||
private RdeReportAction createAction() {
|
||||
RdeReporter reporter = new RdeReporter();
|
||||
reporter.config = config;
|
||||
reporter.reportUrlPrefix = "https://rde-report.example";
|
||||
reporter.urlFetchService = urlFetchService;
|
||||
reporter.password = "foo";
|
||||
RdeReportTask task = new RdeReportTask();
|
||||
task.gcsUtils = new GcsUtils(gcsService, 1024);
|
||||
task.ghostryde = new Ghostryde(1024);
|
||||
task.response = response;
|
||||
task.bucket = "tub";
|
||||
task.tld = "test";
|
||||
task.interval = standardDays(1);
|
||||
task.reporter = reporter;
|
||||
task.timeout = standardSeconds(30);
|
||||
task.stagingDecryptionKey = new RdeKeyringModule().get().getRdeStagingDecryptionKey();
|
||||
task.runner = runner;
|
||||
return task;
|
||||
RdeReportAction action = new RdeReportAction();
|
||||
action.gcsUtils = new GcsUtils(gcsService, 1024);
|
||||
action.ghostryde = new Ghostryde(1024);
|
||||
action.response = response;
|
||||
action.bucket = "tub";
|
||||
action.tld = "test";
|
||||
action.interval = standardDays(1);
|
||||
action.reporter = reporter;
|
||||
action.timeout = standardSeconds(30);
|
||||
action.stagingDecryptionKey = new RdeKeyringModule().get().getRdeStagingDecryptionKey();
|
||||
action.runner = runner;
|
||||
return action;
|
||||
}
|
||||
|
||||
@Before
|
||||
|
@ -131,11 +131,11 @@ public class RdeReportTaskTest {
|
|||
@Test
|
||||
public void testRun() throws Exception {
|
||||
createTld("lol");
|
||||
RdeReportTask task = createTask();
|
||||
task.tld = "lol";
|
||||
task.run();
|
||||
RdeReportAction action = createAction();
|
||||
action.tld = "lol";
|
||||
action.run();
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -144,7 +144,7 @@ public class RdeReportTaskTest {
|
|||
when(httpResponse.getResponseCode()).thenReturn(SC_OK);
|
||||
when(httpResponse.getContent()).thenReturn(IIRDEA_GOOD_XML.read());
|
||||
when(urlFetchService.fetch(request.capture())).thenReturn(httpResponse);
|
||||
createTask().runWithLock(loadRdeReportCursor());
|
||||
createAction().runWithLock(loadRdeReportCursor());
|
||||
assertThat(response.getStatus()).isEqualTo(200);
|
||||
assertThat(response.getContentType()).isEqualTo(PLAIN_TEXT_UTF_8);
|
||||
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(urlFetchService.fetch(request.capture())).thenReturn(httpResponse);
|
||||
thrown.expect(InternalServerErrorException.class, "The structure of the report is invalid.");
|
||||
createTask().runWithLock(loadRdeReportCursor());
|
||||
createAction().runWithLock(loadRdeReportCursor());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -179,7 +179,7 @@ public class RdeReportTaskTest {
|
|||
class ExpectedException extends RuntimeException {}
|
||||
when(urlFetchService.fetch(any(HTTPRequest.class))).thenThrow(new ExpectedException());
|
||||
thrown.expect(ExpectedException.class);
|
||||
createTask().runWithLock(loadRdeReportCursor());
|
||||
createAction().runWithLock(loadRdeReportCursor());
|
||||
}
|
||||
|
||||
private DateTime loadRdeReportCursor() {
|
|
@ -325,11 +325,11 @@ public class RdeStagingActionTest extends MapreduceTestCase<RdeStagingAction> {
|
|||
executeTasksUntilEmpty("mapreduce", clock);
|
||||
assertTasksEnqueued("rde-upload",
|
||||
new TaskMatcher()
|
||||
.url(RdeUploadTask.PATH)
|
||||
.url(RdeUploadAction.PATH)
|
||||
.param(RequestParameters.PARAM_TLD, "lol"));
|
||||
assertTasksEnqueued("brda",
|
||||
new TaskMatcher()
|
||||
.url(BrdaCopyTask.PATH)
|
||||
.url(BrdaCopyAction.PATH)
|
||||
.param(RequestParameters.PARAM_TLD, "lol")
|
||||
.param(RdeModule.PARAM_WATERMARK, "2000-01-04T00:00:00.000Z"));
|
||||
}
|
||||
|
|
|
@ -26,8 +26,8 @@ import org.junit.runners.Suite.SuiteClasses;
|
|||
GhostrydeTest.class,
|
||||
HostResourceToXjcConverterTest.class,
|
||||
RdeStagingActionTest.class,
|
||||
RdeUploadTaskTest.class,
|
||||
RdeReportTaskTest.class,
|
||||
RdeUploadActionTest.class,
|
||||
RdeReportActionTest.class,
|
||||
RegistrarToXjcConverterTest.class,
|
||||
RydeGpgIntegrationTest.class,
|
||||
})
|
||||
|
|
|
@ -85,9 +85,9 @@ import java.io.OutputStream;
|
|||
import java.net.Socket;
|
||||
import java.net.URI;
|
||||
|
||||
/** Unit tests for {@link RdeUploadTask}. */
|
||||
/** Unit tests for {@link RdeUploadAction}. */
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class RdeUploadTaskTest {
|
||||
public class RdeUploadActionTest {
|
||||
|
||||
private static final int BUFFER_SIZE = 64 * 1024;
|
||||
private static final ByteSource REPORT_XML = RdeTestData.get("report.xml");
|
||||
|
@ -176,35 +176,35 @@ public class RdeUploadTaskTest {
|
|||
return ioSpy.register(super.create(os, signingKey));
|
||||
}};
|
||||
|
||||
private RdeUploadTask createTask(URI uploadUrl) {
|
||||
private RdeUploadAction createAction(URI uploadUrl) {
|
||||
try (Keyring keyring = new RdeKeyringModule().get()) {
|
||||
RdeUploadTask task = new RdeUploadTask();
|
||||
task.clock = clock;
|
||||
task.gcsUtils = new GcsUtils(gcsService, BUFFER_SIZE);
|
||||
task.ghostryde = new Ghostryde(BUFFER_SIZE);
|
||||
task.jsch =
|
||||
RdeUploadAction action = new RdeUploadAction();
|
||||
action.clock = clock;
|
||||
action.gcsUtils = new GcsUtils(gcsService, BUFFER_SIZE);
|
||||
action.ghostryde = new Ghostryde(BUFFER_SIZE);
|
||||
action.jsch =
|
||||
JSchModule.provideJSch(
|
||||
keyring.getRdeSshClientPrivateKey(), keyring.getRdeSshClientPublicKey());
|
||||
task.jschSshSessionFactory = new JSchSshSessionFactory(standardSeconds(3));
|
||||
task.response = response;
|
||||
task.pgpCompressionFactory = compressFactory;
|
||||
task.pgpEncryptionFactory = encryptFactory;
|
||||
task.pgpFileFactory = literalFactory;
|
||||
task.pgpSigningFactory = signFactory;
|
||||
task.tarFactory = tarFactory;
|
||||
task.bucket = "bucket";
|
||||
task.interval = standardDays(1);
|
||||
task.timeout = standardSeconds(23);
|
||||
task.tld = "tld";
|
||||
task.sftpCooldown = standardSeconds(7);
|
||||
task.uploadUrl = uploadUrl;
|
||||
task.receiverKey = keyring.getRdeReceiverKey();
|
||||
task.signingKey = keyring.getRdeSigningKey();
|
||||
task.stagingDecryptionKey = keyring.getRdeStagingDecryptionKey();
|
||||
task.reportQueue = QueueFactory.getQueue("rde-report");
|
||||
task.runner = runner;
|
||||
task.taskEnqueuer = new TaskEnqueuer(new Retrier(null, 1));
|
||||
return task;
|
||||
action.jschSshSessionFactory = new JSchSshSessionFactory(standardSeconds(3));
|
||||
action.response = response;
|
||||
action.pgpCompressionFactory = compressFactory;
|
||||
action.pgpEncryptionFactory = encryptFactory;
|
||||
action.pgpFileFactory = literalFactory;
|
||||
action.pgpSigningFactory = signFactory;
|
||||
action.tarFactory = tarFactory;
|
||||
action.bucket = "bucket";
|
||||
action.interval = standardDays(1);
|
||||
action.timeout = standardSeconds(23);
|
||||
action.tld = "tld";
|
||||
action.sftpCooldown = standardSeconds(7);
|
||||
action.uploadUrl = uploadUrl;
|
||||
action.receiverKey = keyring.getRdeReceiverKey();
|
||||
action.signingKey = keyring.getRdeSigningKey();
|
||||
action.stagingDecryptionKey = keyring.getRdeStagingDecryptionKey();
|
||||
action.reportQueue = QueueFactory.getQueue("rde-report");
|
||||
action.runner = runner;
|
||||
action.taskEnqueuer = new TaskEnqueuer(new Retrier(null, 1));
|
||||
return action;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -243,13 +243,13 @@ public class RdeUploadTaskTest {
|
|||
@Test
|
||||
public void testRun() throws Exception {
|
||||
createTld("lol");
|
||||
RdeUploadTask task = createTask(null);
|
||||
task.tld = "lol";
|
||||
task.run();
|
||||
RdeUploadAction action = createAction(null);
|
||||
action.tld = "lol";
|
||||
action.run();
|
||||
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()
|
||||
.url(RdeReportTask.PATH)
|
||||
.url(RdeReportAction.PATH)
|
||||
.param(RequestParameters.PARAM_TLD, "lol"));
|
||||
verifyNoMoreInteractions(runner);
|
||||
}
|
||||
|
@ -264,7 +264,7 @@ public class RdeUploadTaskTest {
|
|||
DateTime uploadCursor = DateTime.parse("2010-10-17TZ");
|
||||
persistResource(
|
||||
RegistryCursor.create(Registry.get("tld"), CursorType.RDE_STAGING, stagingCursor));
|
||||
createTask(uploadUrl).runWithLock(uploadCursor);
|
||||
createAction(uploadUrl).runWithLock(uploadCursor);
|
||||
assertThat(response.getStatus()).isEqualTo(200);
|
||||
assertThat(response.getContentType()).isEqualTo(PLAIN_TEXT_UTF_8);
|
||||
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");
|
||||
persistResource(
|
||||
RegistryCursor.create(Registry.get("tld"), CursorType.RDE_STAGING, stagingCursor));
|
||||
createTask(uploadUrl).runWithLock(uploadCursor);
|
||||
createAction(uploadUrl).runWithLock(uploadCursor);
|
||||
assertThat(response.getStatus()).isEqualTo(200);
|
||||
assertThat(response.getContentType()).isEqualTo(PLAIN_TEXT_UTF_8);
|
||||
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");
|
||||
persistSimpleResource(
|
||||
RegistryCursor.create(Registry.get("tld"), CursorType.RDE_STAGING, stagingCursor));
|
||||
createTask(uploadUrl).runWithLock(uploadCursor);
|
||||
createAction(uploadUrl).runWithLock(uploadCursor);
|
||||
assertThat(response.getStatus()).isEqualTo(200);
|
||||
assertThat(response.getContentType()).isEqualTo(PLAIN_TEXT_UTF_8);
|
||||
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");
|
||||
persistResource(
|
||||
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
|
||||
// identical to the ones sent over SFTP.
|
||||
Process pid = gpg.exec("gpg", "--verify",
|
||||
|
@ -349,8 +349,8 @@ public class RdeUploadTaskTest {
|
|||
DateTime uploadCursor = DateTime.parse("2010-10-17TZ");
|
||||
persistResource(
|
||||
RegistryCursor.create(Registry.get("tld"), CursorType.RDE_STAGING, stagingCursor));
|
||||
thrown.expect(ServiceUnavailableException.class, "Waiting for RdeStagingTask to complete");
|
||||
createTask(null).runWithLock(uploadCursor);
|
||||
thrown.expect(ServiceUnavailableException.class, "Waiting for RdeStagingAction to complete");
|
||||
createAction(null).runWithLock(uploadCursor);
|
||||
}
|
||||
|
||||
private String slurp(InputStream is) throws FileNotFoundException, IOException {
|
|
@ -38,7 +38,7 @@ import org.mockito.runners.MockitoJUnitRunner;
|
|||
|
||||
/** Common code for unit tests of classes that extend {@link Marksdb}. */
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class TmchTaskTestCase {
|
||||
public class TmchActionTestCase {
|
||||
|
||||
static final String MARKSDB_LOGIN = "lolcat:attack";
|
||||
static final String MARKSDB_LOGIN_BASE64 = "bG9sY2F0OmF0dGFjaw==";
|
|
@ -28,14 +28,14 @@ import java.security.SignatureException;
|
|||
import java.security.cert.CRLException;
|
||||
import java.security.cert.CertificateNotYetValidException;
|
||||
|
||||
/** Unit tests for {@link TmchCrlTask}. */
|
||||
public class TmchCrlTaskTest extends TmchTaskTestCase {
|
||||
/** Unit tests for {@link TmchCrlAction}. */
|
||||
public class TmchCrlActionTest extends TmchActionTestCase {
|
||||
|
||||
private TmchCrlTask newTmchCrlTask() throws MalformedURLException {
|
||||
TmchCrlTask result = new TmchCrlTask();
|
||||
result.marksdb = marksdb;
|
||||
result.tmchCrlUrl = new URL("http://sloth.lol/tmch.crl");
|
||||
return result;
|
||||
private TmchCrlAction newTmchCrlAction() throws MalformedURLException {
|
||||
TmchCrlAction action = new TmchCrlAction();
|
||||
action.marksdb = marksdb;
|
||||
action.tmchCrlUrl = new URL("http://sloth.lol/tmch.crl");
|
||||
return action;
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -44,7 +44,7 @@ public class TmchCrlTaskTest extends TmchTaskTestCase {
|
|||
configRule.useTmchProdCert();
|
||||
when(httpResponse.getContent()).thenReturn(
|
||||
readResourceBytes(TmchCertificateAuthority.class, "icann-tmch.crl").read());
|
||||
newTmchCrlTask().run();
|
||||
newTmchCrlAction().run();
|
||||
verify(httpResponse).getContent();
|
||||
verify(fetchService).fetch(httpRequest.capture());
|
||||
assertThat(httpRequest.getValue().getURL().toString()).isEqualTo("http://sloth.lol/tmch.crl");
|
||||
|
@ -57,7 +57,7 @@ public class TmchCrlTaskTest extends TmchTaskTestCase {
|
|||
when(httpResponse.getContent()).thenReturn(
|
||||
readResourceBytes(TmchCertificateAuthority.class, "icann-tmch-test.crl").read());
|
||||
thrown.expectRootCause(CRLException.class, "New CRL is more out of date than our current CRL.");
|
||||
newTmchCrlTask().run();
|
||||
newTmchCrlAction().run();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -66,7 +66,7 @@ public class TmchCrlTaskTest extends TmchTaskTestCase {
|
|||
when(httpResponse.getContent()).thenReturn(
|
||||
readResourceBytes(TmchCertificateAuthority.class, "icann-tmch.crl").read());
|
||||
thrown.expectRootCause(SignatureException.class, "Signature does not match.");
|
||||
newTmchCrlTask().run();
|
||||
newTmchCrlAction().run();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -75,6 +75,6 @@ public class TmchCrlTaskTest extends TmchTaskTestCase {
|
|||
when(httpResponse.getContent()).thenReturn(
|
||||
readResourceBytes(TmchCertificateAuthority.class, "icann-tmch-test.crl").read());
|
||||
thrown.expectRootCause(CertificateNotYetValidException.class);
|
||||
newTmchCrlTask().run();
|
||||
newTmchCrlAction().run();
|
||||
}
|
||||
}
|
|
@ -25,14 +25,14 @@ import com.google.domain.registry.model.tmch.ClaimsListShard;
|
|||
import org.joda.time.DateTime;
|
||||
import org.junit.Test;
|
||||
|
||||
/** Unit tests for {@link TmchDnlTask}. */
|
||||
public class TmchDnlTaskTest extends TmchTaskTestCase {
|
||||
/** Unit tests for {@link TmchDnlAction}. */
|
||||
public class TmchDnlActionTest extends TmchActionTestCase {
|
||||
|
||||
private TmchDnlTask newTmchDnlTask() {
|
||||
TmchDnlTask result = new TmchDnlTask();
|
||||
result.marksdb = marksdb;
|
||||
result.marksdbDnlLogin = Optional.of(MARKSDB_LOGIN);
|
||||
return result;
|
||||
private TmchDnlAction newTmchDnlAction() {
|
||||
TmchDnlAction action = new TmchDnlAction();
|
||||
action.marksdb = marksdb;
|
||||
action.marksdbDnlLogin = Optional.of(MARKSDB_LOGIN);
|
||||
return action;
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -41,7 +41,7 @@ public class TmchDnlTaskTest extends TmchTaskTestCase {
|
|||
when(httpResponse.getContent())
|
||||
.thenReturn(TmchTestData.loadBytes("dnl-latest.csv").read())
|
||||
.thenReturn(TmchTestData.loadBytes("dnl-latest.sig").read());
|
||||
newTmchDnlTask().run();
|
||||
newTmchDnlAction().run();
|
||||
verify(fetchService, times(2)).fetch(httpRequest.capture());
|
||||
assertThat(httpRequest.getAllValues().get(0).getURL().toString())
|
||||
.isEqualTo(MARKSDB_URL + "/dnl/dnl-latest.csv");
|
|
@ -26,16 +26,16 @@ import com.google.domain.registry.model.smd.SignedMarkRevocationList;
|
|||
import org.joda.time.DateTime;
|
||||
import org.junit.Test;
|
||||
|
||||
/** Unit tests for {@link TmchSmdrlTask}. */
|
||||
public class TmchSmdrlTaskTest extends TmchTaskTestCase {
|
||||
/** Unit tests for {@link TmchSmdrlAction}. */
|
||||
public class TmchSmdrlActionTest extends TmchActionTestCase {
|
||||
|
||||
private static final DateTime now = DateTime.parse("2014-01-01T00:00:00Z");
|
||||
|
||||
private TmchSmdrlTask newTmchSmdrlTask() {
|
||||
TmchSmdrlTask result = new TmchSmdrlTask();
|
||||
result.marksdb = marksdb;
|
||||
result.marksdbSmdrlLogin = Optional.absent();
|
||||
return result;
|
||||
private TmchSmdrlAction newTmchSmdrlAction() {
|
||||
TmchSmdrlAction action = new TmchSmdrlAction();
|
||||
action.marksdb = marksdb;
|
||||
action.marksdbSmdrlLogin = Optional.absent();
|
||||
return action;
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -46,7 +46,7 @@ public class TmchSmdrlTaskTest extends TmchTaskTestCase {
|
|||
when(httpResponse.getContent())
|
||||
.thenReturn(loadBytes("smdrl-latest.csv").read())
|
||||
.thenReturn(loadBytes("smdrl-latest.sig").read());
|
||||
newTmchSmdrlTask().run();
|
||||
newTmchSmdrlAction().run();
|
||||
verify(fetchService, times(2)).fetch(httpRequest.capture());
|
||||
assertThat(httpRequest.getAllValues().get(0).getURL().toString())
|
||||
.isEqualTo(MARKSDB_URL + "/smdrl/smdrl-latest.csv");
|
|
@ -26,9 +26,9 @@ import org.junit.runners.Suite.SuiteClasses;
|
|||
NordnVerifyAction.class,
|
||||
SmdrlCsvParserTest.class,
|
||||
TmchCertificateAuthorityTest.class,
|
||||
TmchCrlTaskTest.class,
|
||||
TmchDnlTaskTest.class,
|
||||
TmchSmdrlTaskTest.class,
|
||||
TmchCrlActionTest.class,
|
||||
TmchDnlActionTest.class,
|
||||
TmchSmdrlActionTest.class,
|
||||
TmchXmlSignatureTest.class,
|
||||
})
|
||||
class TmchTestSuite {}
|
||||
|
|
|
@ -38,10 +38,10 @@ import org.mockito.Mock;
|
|||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link CreateGroupsTask}.
|
||||
* Unit tests for {@link CreateGroupsAction}.
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class CreateGroupsTaskTest {
|
||||
public class CreateGroupsActionTest {
|
||||
|
||||
@Rule
|
||||
public final AppEngineRule appEngine = AppEngineRule.builder()
|
||||
|
@ -60,32 +60,32 @@ public class CreateGroupsTaskTest {
|
|||
@Mock
|
||||
private Response response;
|
||||
|
||||
private void runTask(String clientId) {
|
||||
CreateGroupsTask task = new CreateGroupsTask();
|
||||
task.response = response;
|
||||
task.groupsConnection = connection;
|
||||
task.publicDomainName = "domain-registry.example";
|
||||
task.clientId = Optional.fromNullable(clientId);
|
||||
task.run();
|
||||
private void runAction(String clientId) {
|
||||
CreateGroupsAction action = new CreateGroupsAction();
|
||||
action.response = response;
|
||||
action.groupsConnection = connection;
|
||||
action.publicDomainName = "domain-registry.example";
|
||||
action.clientId = Optional.fromNullable(clientId);
|
||||
action.run();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_invalidRequest_missingClientId() throws Exception {
|
||||
thrown.expect(BadRequestException.class,
|
||||
"Error creating Google Groups, missing parameter: clientId");
|
||||
runTask(null);
|
||||
runAction(null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_invalidRequest_invalidClientId() throws Exception {
|
||||
thrown.expect(BadRequestException.class,
|
||||
"Error creating Google Groups; could not find registrar with id completelyMadeUpClientId");
|
||||
runTask("completelyMadeUpClientId");
|
||||
runAction("completelyMadeUpClientId");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_createsAllGroupsSuccessfully() throws Exception {
|
||||
runTask("NewRegistrar");
|
||||
runAction("NewRegistrar");
|
||||
verify(response).setStatus(SC_OK);
|
||||
verify(response).setPayload("Success!");
|
||||
verifyGroupCreationCallsForNewRegistrar();
|
||||
|
@ -103,7 +103,7 @@ public class CreateGroupsTaskTest {
|
|||
"newregistrar-technical-contacts@domain-registry.example",
|
||||
Role.MEMBER);
|
||||
try {
|
||||
runTask("NewRegistrar");
|
||||
runAction("NewRegistrar");
|
||||
} catch (InternalServerErrorException e) {
|
||||
String responseString = e.toString();
|
||||
assertThat(responseString).contains("abuse => Success");
|
|
@ -26,7 +26,7 @@ import static org.mockito.Mockito.verify;
|
|||
import static org.mockito.Mockito.when;
|
||||
|
||||
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.testing.TaskQueueHelper.TaskMatcher;
|
||||
|
||||
|
@ -54,7 +54,7 @@ public class RegistrarServletTest extends RegistrarServletTestCase {
|
|||
new InternetAddress("notification2@test.example"));
|
||||
assertThat(message.getContent()).isEqualTo(expectedEmailBody);
|
||||
assertTasksEnqueued("sheet", new TaskMatcher()
|
||||
.url(SyncRegistrarsSheetTask.PATH)
|
||||
.url(SyncRegistrarsSheetAction.PATH)
|
||||
.method("GET")
|
||||
.header("Host", "backend.hostname"));
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ import static org.mockito.Mockito.when;
|
|||
import com.google.appengine.api.modules.ModulesService;
|
||||
import com.google.common.base.Supplier;
|
||||
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.testing.AppEngineRule;
|
||||
import com.google.domain.registry.testing.ExceptionRule;
|
||||
|
@ -95,7 +95,7 @@ public class RegistrarServletTestCase {
|
|||
inject.setStaticField(Ofy.class, "clock", clock);
|
||||
inject.setStaticField(ResourceServlet.class, "sessionUtils", sessionUtils);
|
||||
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));
|
||||
when(emailService.createMessage()).thenReturn(message);
|
||||
when(req.getMethod()).thenReturn("POST");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue