mirror of
https://github.com/google/nomulus.git
synced 2025-05-19 18:59:35 +02:00
Upgrade command test classes from JUnit 4 to JUnit 5 (#700)
* Convert first batch of command tests to JUnit 5 * Upgrade rest of command tests to JUnit 5 * Migrate the last few test classes
This commit is contained in:
parent
b721533759
commit
9edb43f3e4
108 changed files with 1626 additions and 1669 deletions
|
@ -29,7 +29,7 @@ import static google.registry.testing.DatastoreHelper.persistResource;
|
||||||
import static org.junit.Assert.assertThrows;
|
import static org.junit.Assert.assertThrows;
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.verifyZeroInteractions;
|
import static org.mockito.Mockito.verifyNoInteractions;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import com.google.common.base.VerifyException;
|
import com.google.common.base.VerifyException;
|
||||||
|
@ -141,7 +141,7 @@ public class DnsUpdateWriterTest {
|
||||||
writer.publishDomain("example1.tld");
|
writer.publishDomain("example1.tld");
|
||||||
writer.publishDomain("example2.tld");
|
writer.publishDomain("example2.tld");
|
||||||
|
|
||||||
verifyZeroInteractions(mockResolver);
|
verifyNoInteractions(mockResolver);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -31,8 +31,8 @@ import static org.mockito.ArgumentMatchers.anyString;
|
||||||
import static org.mockito.ArgumentMatchers.eq;
|
import static org.mockito.ArgumentMatchers.eq;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
|
import static org.mockito.Mockito.verifyNoInteractions;
|
||||||
import static org.mockito.Mockito.verifyNoMoreInteractions;
|
import static org.mockito.Mockito.verifyNoMoreInteractions;
|
||||||
import static org.mockito.Mockito.verifyZeroInteractions;
|
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
|
@ -132,7 +132,7 @@ public class ExportPremiumTermsActionTest {
|
||||||
persistResource(Registry.get("tld").asBuilder().setPremiumList(null).build());
|
persistResource(Registry.get("tld").asBuilder().setPremiumList(null).build());
|
||||||
runAction("tld");
|
runAction("tld");
|
||||||
|
|
||||||
verifyZeroInteractions(driveConnection);
|
verifyNoInteractions(driveConnection);
|
||||||
verify(response).setStatus(SC_OK);
|
verify(response).setStatus(SC_OK);
|
||||||
verify(response).setPayload("No premium lists configured");
|
verify(response).setPayload("No premium lists configured");
|
||||||
verify(response).setContentType(PLAIN_TEXT_UTF_8);
|
verify(response).setContentType(PLAIN_TEXT_UTF_8);
|
||||||
|
@ -144,7 +144,7 @@ public class ExportPremiumTermsActionTest {
|
||||||
persistResource(Registry.get("tld").asBuilder().setDriveFolderId(null).build());
|
persistResource(Registry.get("tld").asBuilder().setDriveFolderId(null).build());
|
||||||
runAction("tld");
|
runAction("tld");
|
||||||
|
|
||||||
verifyZeroInteractions(driveConnection);
|
verifyNoInteractions(driveConnection);
|
||||||
verify(response).setStatus(SC_OK);
|
verify(response).setStatus(SC_OK);
|
||||||
verify(response)
|
verify(response)
|
||||||
.setPayload("Skipping export because no Drive folder is associated with this TLD");
|
.setPayload("Skipping export because no Drive folder is associated with this TLD");
|
||||||
|
@ -157,7 +157,7 @@ public class ExportPremiumTermsActionTest {
|
||||||
deleteTld("tld");
|
deleteTld("tld");
|
||||||
assertThrows(RuntimeException.class, () -> runAction("tld"));
|
assertThrows(RuntimeException.class, () -> runAction("tld"));
|
||||||
|
|
||||||
verifyZeroInteractions(driveConnection);
|
verifyNoInteractions(driveConnection);
|
||||||
verify(response).setStatus(SC_INTERNAL_SERVER_ERROR);
|
verify(response).setStatus(SC_INTERNAL_SERVER_ERROR);
|
||||||
verify(response).setPayload(anyString());
|
verify(response).setPayload(anyString());
|
||||||
verify(response).setContentType(PLAIN_TEXT_UTF_8);
|
verify(response).setContentType(PLAIN_TEXT_UTF_8);
|
||||||
|
@ -169,7 +169,7 @@ public class ExportPremiumTermsActionTest {
|
||||||
deletePremiumList(new PremiumList.Builder().setName("pl-name").build());
|
deletePremiumList(new PremiumList.Builder().setName("pl-name").build());
|
||||||
assertThrows(RuntimeException.class, () -> runAction("tld"));
|
assertThrows(RuntimeException.class, () -> runAction("tld"));
|
||||||
|
|
||||||
verifyZeroInteractions(driveConnection);
|
verifyNoInteractions(driveConnection);
|
||||||
verify(response).setStatus(SC_INTERNAL_SERVER_ERROR);
|
verify(response).setStatus(SC_INTERNAL_SERVER_ERROR);
|
||||||
verify(response).setPayload("Could not load premium list for " + "tld");
|
verify(response).setPayload("Could not load premium list for " + "tld");
|
||||||
verify(response).setContentType(PLAIN_TEXT_UTF_8);
|
verify(response).setContentType(PLAIN_TEXT_UTF_8);
|
||||||
|
|
|
@ -18,7 +18,7 @@ import static com.google.common.collect.Lists.newArrayList;
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.verifyZeroInteractions;
|
import static org.mockito.Mockito.verifyNoInteractions;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import com.google.api.services.sheets.v4.Sheets;
|
import com.google.api.services.sheets.v4.Sheets;
|
||||||
|
@ -91,9 +91,9 @@ public class SheetSynchronizerTest {
|
||||||
public void testSynchronize_dataAndSheetEmpty_doNothing() throws Exception {
|
public void testSynchronize_dataAndSheetEmpty_doNothing() throws Exception {
|
||||||
existingSheet.add(createRow("a", "b"));
|
existingSheet.add(createRow("a", "b"));
|
||||||
sheetSynchronizer.synchronize("aSheetId", data);
|
sheetSynchronizer.synchronize("aSheetId", data);
|
||||||
verifyZeroInteractions(appendReq);
|
verifyNoInteractions(appendReq);
|
||||||
verifyZeroInteractions(clearReq);
|
verifyNoInteractions(clearReq);
|
||||||
verifyZeroInteractions(updateReq);
|
verifyNoInteractions(updateReq);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -103,8 +103,8 @@ public class SheetSynchronizerTest {
|
||||||
data = ImmutableList.of(ImmutableMap.of("a", "val1", "b", "val2"));
|
data = ImmutableList.of(ImmutableMap.of("a", "val1", "b", "val2"));
|
||||||
sheetSynchronizer.synchronize("aSheetId", data);
|
sheetSynchronizer.synchronize("aSheetId", data);
|
||||||
|
|
||||||
verifyZeroInteractions(appendReq);
|
verifyNoInteractions(appendReq);
|
||||||
verifyZeroInteractions(clearReq);
|
verifyNoInteractions(clearReq);
|
||||||
|
|
||||||
BatchUpdateValuesRequest expectedRequest = new BatchUpdateValuesRequest();
|
BatchUpdateValuesRequest expectedRequest = new BatchUpdateValuesRequest();
|
||||||
List<List<Object>> expectedVals = newArrayList();
|
List<List<Object>> expectedVals = newArrayList();
|
||||||
|
@ -122,8 +122,8 @@ public class SheetSynchronizerTest {
|
||||||
data = ImmutableList.of(ImmutableMap.of("a", "val1", "b", "val2", "d", "val3"));
|
data = ImmutableList.of(ImmutableMap.of("a", "val1", "b", "val2", "d", "val3"));
|
||||||
sheetSynchronizer.synchronize("aSheetId", data);
|
sheetSynchronizer.synchronize("aSheetId", data);
|
||||||
|
|
||||||
verifyZeroInteractions(appendReq);
|
verifyNoInteractions(appendReq);
|
||||||
verifyZeroInteractions(clearReq);
|
verifyNoInteractions(clearReq);
|
||||||
|
|
||||||
BatchUpdateValuesRequest expectedRequest = new BatchUpdateValuesRequest();
|
BatchUpdateValuesRequest expectedRequest = new BatchUpdateValuesRequest();
|
||||||
List<List<Object>> expectedVals = newArrayList();
|
List<List<Object>> expectedVals = newArrayList();
|
||||||
|
@ -141,8 +141,8 @@ public class SheetSynchronizerTest {
|
||||||
data = ImmutableList.of(ImmutableMap.of("a", "val1", "b", "paddedVal", "d", "val3"));
|
data = ImmutableList.of(ImmutableMap.of("a", "val1", "b", "paddedVal", "d", "val3"));
|
||||||
sheetSynchronizer.synchronize("aSheetId", data);
|
sheetSynchronizer.synchronize("aSheetId", data);
|
||||||
|
|
||||||
verifyZeroInteractions(appendReq);
|
verifyNoInteractions(appendReq);
|
||||||
verifyZeroInteractions(clearReq);
|
verifyNoInteractions(clearReq);
|
||||||
|
|
||||||
BatchUpdateValuesRequest expectedRequest = new BatchUpdateValuesRequest();
|
BatchUpdateValuesRequest expectedRequest = new BatchUpdateValuesRequest();
|
||||||
List<List<Object>> expectedVals = newArrayList();
|
List<List<Object>> expectedVals = newArrayList();
|
||||||
|
@ -162,7 +162,7 @@ public class SheetSynchronizerTest {
|
||||||
ImmutableMap.of("a", "val3", "b", "val4"));
|
ImmutableMap.of("a", "val3", "b", "val4"));
|
||||||
sheetSynchronizer.synchronize("aSheetId", data);
|
sheetSynchronizer.synchronize("aSheetId", data);
|
||||||
|
|
||||||
verifyZeroInteractions(clearReq);
|
verifyNoInteractions(clearReq);
|
||||||
|
|
||||||
BatchUpdateValuesRequest expectedRequest = new BatchUpdateValuesRequest();
|
BatchUpdateValuesRequest expectedRequest = new BatchUpdateValuesRequest();
|
||||||
List<List<Object>> updatedVals = newArrayList();
|
List<List<Object>> updatedVals = newArrayList();
|
||||||
|
@ -188,6 +188,6 @@ public class SheetSynchronizerTest {
|
||||||
sheetSynchronizer.synchronize("aSheetId", data);
|
sheetSynchronizer.synchronize("aSheetId", data);
|
||||||
|
|
||||||
verify(values).clear("aSheetId", "Registrars!3:4", new ClearValuesRequest());
|
verify(values).clear("aSheetId", "Registrars!3:4", new ClearValuesRequest());
|
||||||
verifyZeroInteractions(updateReq);
|
verifyNoInteractions(updateReq);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,8 +19,8 @@ import static com.google.common.truth.Truth.assertThat;
|
||||||
import static org.mockito.ArgumentMatchers.eq;
|
import static org.mockito.ArgumentMatchers.eq;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
|
import static org.mockito.Mockito.verifyNoInteractions;
|
||||||
import static org.mockito.Mockito.verifyNoMoreInteractions;
|
import static org.mockito.Mockito.verifyNoMoreInteractions;
|
||||||
import static org.mockito.Mockito.verifyZeroInteractions;
|
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import google.registry.testing.AppEngineRule;
|
import google.registry.testing.AppEngineRule;
|
||||||
|
@ -67,7 +67,7 @@ public class SyncRegistrarsSheetActionTest {
|
||||||
public void testPost_withoutParamsOrSystemProperty_dropsTask() {
|
public void testPost_withoutParamsOrSystemProperty_dropsTask() {
|
||||||
runAction(null, null);
|
runAction(null, null);
|
||||||
assertThat(response.getPayload()).startsWith("MISSINGNO");
|
assertThat(response.getPayload()).startsWith("MISSINGNO");
|
||||||
verifyZeroInteractions(syncRegistrarsSheet);
|
verifyNoInteractions(syncRegistrarsSheet);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -104,6 +104,6 @@ public class SyncRegistrarsSheetActionTest {
|
||||||
action.lockHandler = new FakeLockHandler(false);
|
action.lockHandler = new FakeLockHandler(false);
|
||||||
runAction(null, "foobar");
|
runAction(null, "foobar");
|
||||||
assertThat(response.getPayload()).startsWith("LOCKED");
|
assertThat(response.getPayload()).startsWith("LOCKED");
|
||||||
verifyZeroInteractions(syncRegistrarsSheet);
|
verifyNoInteractions(syncRegistrarsSheet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ import static java.util.logging.Level.INFO;
|
||||||
import static java.util.logging.Level.SEVERE;
|
import static java.util.logging.Level.SEVERE;
|
||||||
import static org.mockito.ArgumentMatchers.eq;
|
import static org.mockito.ArgumentMatchers.eq;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.verifyZeroInteractions;
|
import static org.mockito.Mockito.verifyNoInteractions;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import com.google.common.base.Splitter;
|
import com.google.common.base.Splitter;
|
||||||
|
@ -163,7 +163,7 @@ public class EppControllerTest {
|
||||||
true,
|
true,
|
||||||
true,
|
true,
|
||||||
domainCreateXml.getBytes(UTF_8));
|
domainCreateXml.getBytes(UTF_8));
|
||||||
verifyZeroInteractions(eppMetrics);
|
verifyNoInteractions(eppMetrics);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -25,8 +25,8 @@ import static org.mockito.ArgumentMatchers.eq;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.times;
|
import static org.mockito.Mockito.times;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
|
import static org.mockito.Mockito.verifyNoInteractions;
|
||||||
import static org.mockito.Mockito.verifyNoMoreInteractions;
|
import static org.mockito.Mockito.verifyNoMoreInteractions;
|
||||||
import static org.mockito.Mockito.verifyZeroInteractions;
|
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import com.google.appengine.tools.cloudstorage.GcsFilename;
|
import com.google.appengine.tools.cloudstorage.GcsFilename;
|
||||||
|
@ -208,7 +208,7 @@ public class CopyDetailReportsActionTest {
|
||||||
new GcsFilename("test-bucket", "results/invoice_details_2017-10_notExistent_hello.csv"),
|
new GcsFilename("test-bucket", "results/invoice_details_2017-10_notExistent_hello.csv"),
|
||||||
"hola,mundo\n3,4".getBytes(UTF_8));
|
"hola,mundo\n3,4".getBytes(UTF_8));
|
||||||
action.run();
|
action.run();
|
||||||
verifyZeroInteractions(driveConnection);
|
verifyNoInteractions(driveConnection);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -220,6 +220,6 @@ public class CopyDetailReportsActionTest {
|
||||||
"test-bucket", "results/invoice_details_2017-10_TheRegistrar_hello.csv"),
|
"test-bucket", "results/invoice_details_2017-10_TheRegistrar_hello.csv"),
|
||||||
"hola,mundo\n3,4".getBytes(UTF_8));
|
"hola,mundo\n3,4".getBytes(UTF_8));
|
||||||
action.run();
|
action.run();
|
||||||
verifyZeroInteractions(driveConnection);
|
verifyNoInteractions(driveConnection);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,8 +24,8 @@ import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.ArgumentMatchers.eq;
|
import static org.mockito.ArgumentMatchers.eq;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
|
import static org.mockito.Mockito.verifyNoInteractions;
|
||||||
import static org.mockito.Mockito.verifyNoMoreInteractions;
|
import static org.mockito.Mockito.verifyNoMoreInteractions;
|
||||||
import static org.mockito.Mockito.verifyZeroInteractions;
|
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import com.google.appengine.api.users.User;
|
import com.google.appengine.api.users.User;
|
||||||
|
@ -245,7 +245,7 @@ public final class RequestHandlerTest {
|
||||||
|
|
||||||
handler.handleRequest(req, rsp);
|
handler.handleRequest(req, rsp);
|
||||||
|
|
||||||
verifyZeroInteractions(rsp);
|
verifyNoInteractions(rsp);
|
||||||
verify(bumblebeeTask).run();
|
verify(bumblebeeTask).run();
|
||||||
assertMetric("/bumblebee", GET, AuthLevel.NONE, true);
|
assertMetric("/bumblebee", GET, AuthLevel.NONE, true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ import static google.registry.testing.LogsSubject.assertAboutLogs;
|
||||||
import static org.junit.Assert.assertThrows;
|
import static org.junit.Assert.assertThrows;
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.verifyZeroInteractions;
|
import static org.mockito.Mockito.verifyNoInteractions;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import com.google.appengine.api.users.User;
|
import com.google.appengine.api.users.User;
|
||||||
|
@ -150,7 +150,7 @@ public class AuthenticatedRegistrarAccessorTest {
|
||||||
NO_USER, ADMIN_CLIENT_ID, SUPPORT_GROUP, lazyGroupsConnection);
|
NO_USER, ADMIN_CLIENT_ID, SUPPORT_GROUP, lazyGroupsConnection);
|
||||||
|
|
||||||
assertThat(registrarAccessor.getAllClientIdWithRoles()).isEmpty();
|
assertThat(registrarAccessor.getAllClientIdWithRoles()).isEmpty();
|
||||||
verifyZeroInteractions(lazyGroupsConnection);
|
verifyNoInteractions(lazyGroupsConnection);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -182,7 +182,7 @@ public class AuthenticatedRegistrarAccessorTest {
|
||||||
|
|
||||||
ADMIN_CLIENT_ID, ADMIN,
|
ADMIN_CLIENT_ID, ADMIN,
|
||||||
ADMIN_CLIENT_ID, OWNER);
|
ADMIN_CLIENT_ID, OWNER);
|
||||||
verifyZeroInteractions(lazyGroupsConnection);
|
verifyNoInteractions(lazyGroupsConnection);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -228,7 +228,7 @@ public class AuthenticatedRegistrarAccessorTest {
|
||||||
assertThat(registrarAccessor.getAllClientIdWithRoles())
|
assertThat(registrarAccessor.getAllClientIdWithRoles())
|
||||||
.containsExactly(CLIENT_ID_WITH_CONTACT, OWNER);
|
.containsExactly(CLIENT_ID_WITH_CONTACT, OWNER);
|
||||||
// Make sure we didn't instantiate the lazyGroupsConnection
|
// Make sure we didn't instantiate the lazyGroupsConnection
|
||||||
verifyZeroInteractions(lazyGroupsConnection);
|
verifyNoInteractions(lazyGroupsConnection);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Support group check throws - continue anyway. */
|
/** Support group check throws - continue anyway. */
|
||||||
|
@ -287,7 +287,7 @@ public class AuthenticatedRegistrarAccessorTest {
|
||||||
CLIENT_ID_WITH_CONTACT,
|
CLIENT_ID_WITH_CONTACT,
|
||||||
NO_USER,
|
NO_USER,
|
||||||
"<logged-out user> doesn't have access to registrar TheRegistrar");
|
"<logged-out user> doesn't have access to registrar TheRegistrar");
|
||||||
verifyZeroInteractions(lazyGroupsConnection);
|
verifyNoInteractions(lazyGroupsConnection);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Succeed loading registrar if user has access to it. */
|
/** Succeed loading registrar if user has access to it. */
|
||||||
|
@ -307,7 +307,7 @@ public class AuthenticatedRegistrarAccessorTest {
|
||||||
CLIENT_ID_WITH_CONTACT,
|
CLIENT_ID_WITH_CONTACT,
|
||||||
GAE_ADMIN,
|
GAE_ADMIN,
|
||||||
"admin admin@gmail.com has [OWNER, ADMIN] access to registrar TheRegistrar");
|
"admin admin@gmail.com has [OWNER, ADMIN] access to registrar TheRegistrar");
|
||||||
verifyZeroInteractions(lazyGroupsConnection);
|
verifyNoInteractions(lazyGroupsConnection);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Succeed loading registrar for admin even if they aren't on the approved contacts list. */
|
/** Succeed loading registrar for admin even if they aren't on the approved contacts list. */
|
||||||
|
@ -317,7 +317,7 @@ public class AuthenticatedRegistrarAccessorTest {
|
||||||
REAL_CLIENT_ID_WITHOUT_CONTACT,
|
REAL_CLIENT_ID_WITHOUT_CONTACT,
|
||||||
GAE_ADMIN,
|
GAE_ADMIN,
|
||||||
"admin admin@gmail.com has [ADMIN] access to registrar NewRegistrar.");
|
"admin admin@gmail.com has [ADMIN] access to registrar NewRegistrar.");
|
||||||
verifyZeroInteractions(lazyGroupsConnection);
|
verifyNoInteractions(lazyGroupsConnection);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -332,7 +332,7 @@ public class AuthenticatedRegistrarAccessorTest {
|
||||||
REAL_CLIENT_ID_WITHOUT_CONTACT,
|
REAL_CLIENT_ID_WITHOUT_CONTACT,
|
||||||
GAE_ADMIN,
|
GAE_ADMIN,
|
||||||
"admin admin@gmail.com has [OWNER, ADMIN] access to registrar NewRegistrar.");
|
"admin admin@gmail.com has [OWNER, ADMIN] access to registrar NewRegistrar.");
|
||||||
verifyZeroInteractions(lazyGroupsConnection);
|
verifyNoInteractions(lazyGroupsConnection);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Succeed loading non-REAL registrar for admin. */
|
/** Succeed loading non-REAL registrar for admin. */
|
||||||
|
@ -342,7 +342,7 @@ public class AuthenticatedRegistrarAccessorTest {
|
||||||
OTE_CLIENT_ID_WITHOUT_CONTACT,
|
OTE_CLIENT_ID_WITHOUT_CONTACT,
|
||||||
GAE_ADMIN,
|
GAE_ADMIN,
|
||||||
"admin admin@gmail.com has [OWNER, ADMIN] access to registrar OteRegistrar.");
|
"admin admin@gmail.com has [OWNER, ADMIN] access to registrar OteRegistrar.");
|
||||||
verifyZeroInteractions(lazyGroupsConnection);
|
verifyNoInteractions(lazyGroupsConnection);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Fail loading registrar even if admin, if registrar doesn't exist. */
|
/** Fail loading registrar even if admin, if registrar doesn't exist. */
|
||||||
|
@ -352,7 +352,7 @@ public class AuthenticatedRegistrarAccessorTest {
|
||||||
"BadClientId",
|
"BadClientId",
|
||||||
GAE_ADMIN,
|
GAE_ADMIN,
|
||||||
"Registrar BadClientId does not exist");
|
"Registrar BadClientId does not exist");
|
||||||
verifyZeroInteractions(lazyGroupsConnection);
|
verifyNoInteractions(lazyGroupsConnection);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void expectGetRegistrarSuccess(String clientId, AuthResult authResult, String message)
|
private void expectGetRegistrarSuccess(String clientId, AuthResult authResult, String message)
|
||||||
|
|
|
@ -19,7 +19,7 @@ import static com.google.common.truth.Truth.assertThat;
|
||||||
import static com.google.common.truth.Truth8.assertThat;
|
import static com.google.common.truth.Truth8.assertThat;
|
||||||
import static org.junit.Assert.assertThrows;
|
import static org.junit.Assert.assertThrows;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.verifyZeroInteractions;
|
import static org.mockito.Mockito.verifyNoInteractions;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import com.google.appengine.api.users.User;
|
import com.google.appengine.api.users.User;
|
||||||
|
@ -138,7 +138,7 @@ public class RequestAuthenticatorTest {
|
||||||
public void testNoAuthNeeded_noneFound() {
|
public void testNoAuthNeeded_noneFound() {
|
||||||
Optional<AuthResult> authResult = runTest(mockUserService, AUTH_NONE);
|
Optional<AuthResult> authResult = runTest(mockUserService, AUTH_NONE);
|
||||||
|
|
||||||
verifyZeroInteractions(mockUserService);
|
verifyNoInteractions(mockUserService);
|
||||||
assertThat(authResult).isPresent();
|
assertThat(authResult).isPresent();
|
||||||
assertThat(authResult.get().authLevel()).isEqualTo(AuthLevel.NONE);
|
assertThat(authResult.get().authLevel()).isEqualTo(AuthLevel.NONE);
|
||||||
}
|
}
|
||||||
|
@ -149,7 +149,7 @@ public class RequestAuthenticatorTest {
|
||||||
|
|
||||||
Optional<AuthResult> authResult = runTest(mockUserService, AUTH_NONE);
|
Optional<AuthResult> authResult = runTest(mockUserService, AUTH_NONE);
|
||||||
|
|
||||||
verifyZeroInteractions(mockUserService);
|
verifyNoInteractions(mockUserService);
|
||||||
assertThat(authResult).isPresent();
|
assertThat(authResult).isPresent();
|
||||||
assertThat(authResult.get().authLevel()).isEqualTo(AuthLevel.APP);
|
assertThat(authResult.get().authLevel()).isEqualTo(AuthLevel.APP);
|
||||||
assertThat(authResult.get().userAuthInfo()).isEmpty();
|
assertThat(authResult.get().userAuthInfo()).isEmpty();
|
||||||
|
@ -159,7 +159,7 @@ public class RequestAuthenticatorTest {
|
||||||
public void testInternalAuth_notInvokedInternally() {
|
public void testInternalAuth_notInvokedInternally() {
|
||||||
Optional<AuthResult> authResult = runTest(mockUserService, AUTH_INTERNAL_OR_ADMIN);
|
Optional<AuthResult> authResult = runTest(mockUserService, AUTH_INTERNAL_OR_ADMIN);
|
||||||
|
|
||||||
verifyZeroInteractions(mockUserService);
|
verifyNoInteractions(mockUserService);
|
||||||
assertThat(authResult).isEmpty();
|
assertThat(authResult).isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -169,7 +169,7 @@ public class RequestAuthenticatorTest {
|
||||||
|
|
||||||
Optional<AuthResult> authResult = runTest(mockUserService, AUTH_INTERNAL_OR_ADMIN);
|
Optional<AuthResult> authResult = runTest(mockUserService, AUTH_INTERNAL_OR_ADMIN);
|
||||||
|
|
||||||
verifyZeroInteractions(mockUserService);
|
verifyNoInteractions(mockUserService);
|
||||||
assertThat(authResult).isPresent();
|
assertThat(authResult).isPresent();
|
||||||
assertThat(authResult.get().authLevel()).isEqualTo(AuthLevel.APP);
|
assertThat(authResult.get().authLevel()).isEqualTo(AuthLevel.APP);
|
||||||
assertThat(authResult.get().userAuthInfo()).isEmpty();
|
assertThat(authResult.get().userAuthInfo()).isEmpty();
|
||||||
|
|
|
@ -31,25 +31,25 @@ import google.registry.persistence.VKey;
|
||||||
import google.registry.testing.FakeClock;
|
import google.registry.testing.FakeClock;
|
||||||
import google.registry.testing.InjectRule;
|
import google.registry.testing.InjectRule;
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Rule;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||||
|
|
||||||
/** Unit tests for {@link AckPollMessagesCommand}. */
|
/** Unit tests for {@link AckPollMessagesCommand}. */
|
||||||
public class AckPollMessagesCommandTest extends CommandTestCase<AckPollMessagesCommand> {
|
public class AckPollMessagesCommandTest extends CommandTestCase<AckPollMessagesCommand> {
|
||||||
|
|
||||||
private FakeClock clock = new FakeClock(DateTime.parse("2015-02-04T08:16:32.064Z"));
|
private FakeClock clock = new FakeClock(DateTime.parse("2015-02-04T08:16:32.064Z"));
|
||||||
|
|
||||||
@Rule public final InjectRule inject = new InjectRule();
|
@RegisterExtension public final InjectRule inject = new InjectRule();
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public final void before() {
|
final void beforeEach() {
|
||||||
inject.setStaticField(Ofy.class, "clock", clock);
|
inject.setStaticField(Ofy.class, "clock", clock);
|
||||||
command.clock = clock;
|
command.clock = clock;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_doesntDeletePollMessagesInFuture() throws Exception {
|
void testSuccess_doesntDeletePollMessagesInFuture() throws Exception {
|
||||||
VKey<OneTime> pm1 =
|
VKey<OneTime> pm1 =
|
||||||
persistPollMessage(316L, DateTime.parse("2014-01-01T22:33:44Z"), "foobar").createVKey();
|
persistPollMessage(316L, DateTime.parse("2014-01-01T22:33:44Z"), "foobar").createVKey();
|
||||||
VKey<OneTime> pm2 =
|
VKey<OneTime> pm2 =
|
||||||
|
@ -70,7 +70,7 @@ public class AckPollMessagesCommandTest extends CommandTestCase<AckPollMessagesC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_resavesAutorenewPollMessages() throws Exception {
|
void testSuccess_resavesAutorenewPollMessages() throws Exception {
|
||||||
VKey<OneTime> pm1 =
|
VKey<OneTime> pm1 =
|
||||||
persistPollMessage(316L, DateTime.parse("2014-01-01T22:33:44Z"), "foobar").createVKey();
|
persistPollMessage(316L, DateTime.parse("2014-01-01T22:33:44Z"), "foobar").createVKey();
|
||||||
VKey<OneTime> pm2 =
|
VKey<OneTime> pm2 =
|
||||||
|
@ -98,7 +98,7 @@ public class AckPollMessagesCommandTest extends CommandTestCase<AckPollMessagesC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_deletesExpiredAutorenewPollMessages() throws Exception {
|
void testSuccess_deletesExpiredAutorenewPollMessages() throws Exception {
|
||||||
VKey<OneTime> pm1 =
|
VKey<OneTime> pm1 =
|
||||||
persistPollMessage(316L, DateTime.parse("2014-01-01T22:33:44Z"), "foobar").createVKey();
|
persistPollMessage(316L, DateTime.parse("2014-01-01T22:33:44Z"), "foobar").createVKey();
|
||||||
VKey<OneTime> pm2 =
|
VKey<OneTime> pm2 =
|
||||||
|
@ -125,7 +125,7 @@ public class AckPollMessagesCommandTest extends CommandTestCase<AckPollMessagesC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_onlyDeletesPollMessagesMatchingMessage() throws Exception {
|
void testSuccess_onlyDeletesPollMessagesMatchingMessage() throws Exception {
|
||||||
VKey<OneTime> pm1 =
|
VKey<OneTime> pm1 =
|
||||||
persistPollMessage(316L, DateTime.parse("2014-01-01T22:33:44Z"), "food is good")
|
persistPollMessage(316L, DateTime.parse("2014-01-01T22:33:44Z"), "food is good")
|
||||||
.createVKey();
|
.createVKey();
|
||||||
|
@ -143,7 +143,7 @@ public class AckPollMessagesCommandTest extends CommandTestCase<AckPollMessagesC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_onlyDeletesPollMessagesMatchingClientId() throws Exception {
|
void testSuccess_onlyDeletesPollMessagesMatchingClientId() throws Exception {
|
||||||
VKey<OneTime> pm1 =
|
VKey<OneTime> pm1 =
|
||||||
persistPollMessage(316L, DateTime.parse("2014-01-01T22:33:44Z"), "food is good")
|
persistPollMessage(316L, DateTime.parse("2014-01-01T22:33:44Z"), "food is good")
|
||||||
.createVKey();
|
.createVKey();
|
||||||
|
@ -167,7 +167,7 @@ public class AckPollMessagesCommandTest extends CommandTestCase<AckPollMessagesC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_dryRunDoesntDeleteAnything() throws Exception {
|
void testSuccess_dryRunDoesntDeleteAnything() throws Exception {
|
||||||
OneTime pm1 = persistPollMessage(316L, DateTime.parse("2014-01-01T22:33:44Z"), "foobar");
|
OneTime pm1 = persistPollMessage(316L, DateTime.parse("2014-01-01T22:33:44Z"), "foobar");
|
||||||
OneTime pm2 = persistPollMessage(624L, DateTime.parse("2013-05-01T22:33:44Z"), "ninelives");
|
OneTime pm2 = persistPollMessage(624L, DateTime.parse("2013-05-01T22:33:44Z"), "ninelives");
|
||||||
OneTime pm3 = persistPollMessage(791L, DateTime.parse("2015-01-08T22:33:44Z"), "ginger");
|
OneTime pm3 = persistPollMessage(791L, DateTime.parse("2015-01-08T22:33:44Z"), "ginger");
|
||||||
|
|
|
@ -27,23 +27,19 @@ import com.google.common.net.MediaType;
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Rule;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.extension.ExtendWith;
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
import org.junit.runners.JUnit4;
|
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
import org.mockito.junit.MockitoJUnit;
|
import org.mockito.junit.jupiter.MockitoExtension;
|
||||||
import org.mockito.junit.MockitoRule;
|
|
||||||
|
|
||||||
@RunWith(JUnit4.class)
|
/** Unit tests for {@link google.registry.tools.AppEngineConnection}. */
|
||||||
public final class AppEngineConnectionTest {
|
@ExtendWith(MockitoExtension.class)
|
||||||
|
final class AppEngineConnectionTest {
|
||||||
|
|
||||||
@Rule public final MockitoRule mocks = MockitoJUnit.rule();
|
private AppEngineConnection connection;
|
||||||
|
private TestHttpTransport httpTransport;
|
||||||
AppEngineConnection connection;
|
private TestLowLevelHttpRequest lowLevelHttpRequest;
|
||||||
TestHttpTransport httpTransport;
|
|
||||||
TestLowLevelHttpRequest lowLevelHttpRequest;
|
|
||||||
@Mock LowLevelHttpResponse lowLevelHttpResponse;
|
@Mock LowLevelHttpResponse lowLevelHttpResponse;
|
||||||
|
|
||||||
private final class TestHttpTransport extends HttpTransport {
|
private final class TestHttpTransport extends HttpTransport {
|
||||||
|
@ -81,8 +77,8 @@ public final class AppEngineConnectionTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setUp() throws Exception {
|
void beforeEach() throws Exception {
|
||||||
lowLevelHttpRequest = new TestLowLevelHttpRequest();
|
lowLevelHttpRequest = new TestLowLevelHttpRequest();
|
||||||
when(lowLevelHttpResponse.getContent())
|
when(lowLevelHttpResponse.getContent())
|
||||||
.thenReturn(new ByteArrayInputStream("MyContent".getBytes(UTF_8)));
|
.thenReturn(new ByteArrayInputStream("MyContent".getBytes(UTF_8)));
|
||||||
|
@ -94,7 +90,7 @@ public final class AppEngineConnectionTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSendGetRequest() throws Exception {
|
void testSendGetRequest() throws Exception {
|
||||||
assertThat(
|
assertThat(
|
||||||
connection.sendGetRequest(
|
connection.sendGetRequest(
|
||||||
"/my/path?query", ImmutableMap.of("key1", "value1", "key2", "value2")))
|
"/my/path?query", ImmutableMap.of("key1", "value1", "key2", "value2")))
|
||||||
|
@ -107,7 +103,7 @@ public final class AppEngineConnectionTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSendPostRequest() throws Exception {
|
void testSendPostRequest() throws Exception {
|
||||||
assertThat(
|
assertThat(
|
||||||
connection.sendPostRequest(
|
connection.sendPostRequest(
|
||||||
"/my/path?query",
|
"/my/path?query",
|
||||||
|
@ -125,7 +121,7 @@ public final class AppEngineConnectionTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSendJsonRequest() throws Exception {
|
void testSendJsonRequest() throws Exception {
|
||||||
when(lowLevelHttpResponse.getContent())
|
when(lowLevelHttpResponse.getContent())
|
||||||
.thenReturn(
|
.thenReturn(
|
||||||
new ByteArrayInputStream((JSON_SAFETY_PREFIX + "{\"key\":\"value\"}").getBytes(UTF_8)));
|
new ByteArrayInputStream((JSON_SAFETY_PREFIX + "{\"key\":\"value\"}").getBytes(UTF_8)));
|
||||||
|
|
|
@ -17,7 +17,6 @@ package google.registry.tools;
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||||
import static org.junit.Assert.assertThrows;
|
import static org.junit.Assert.assertThrows;
|
||||||
import static org.mockito.Mockito.mock;
|
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import com.google.api.client.auth.oauth2.ClientParametersAuthentication;
|
import com.google.api.client.auth.oauth2.ClientParametersAuthentication;
|
||||||
|
@ -37,25 +36,29 @@ import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Rule;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.extension.ExtendWith;
|
||||||
import org.junit.rules.TemporaryFolder;
|
import org.junit.jupiter.api.io.TempDir;
|
||||||
import org.junit.runner.RunWith;
|
import org.mockito.Mock;
|
||||||
import org.junit.runners.JUnit4;
|
import org.mockito.junit.jupiter.MockitoExtension;
|
||||||
|
import org.mockito.junit.jupiter.MockitoSettings;
|
||||||
|
import org.mockito.quality.Strictness;
|
||||||
|
|
||||||
/** Unit tests for {@link AuthModule}. */
|
/** Unit tests for {@link AuthModule}. */
|
||||||
@RunWith(JUnit4.class)
|
@ExtendWith(MockitoExtension.class)
|
||||||
public class AuthModuleTest {
|
class AuthModuleTest {
|
||||||
|
|
||||||
private static final String CLIENT_ID = "UNITTEST-CLIENT-ID";
|
private static final String CLIENT_ID = "UNITTEST-CLIENT-ID";
|
||||||
private static final String CLIENT_SECRET = "UNITTEST-CLIENT-SECRET";
|
private static final String CLIENT_SECRET = "UNITTEST-CLIENT-SECRET";
|
||||||
private static final String ACCESS_TOKEN = "FakeAccessToken";
|
private static final String ACCESS_TOKEN = "FakeAccessToken";
|
||||||
private static final String REFRESH_TOKEN = "FakeReFreshToken";
|
private static final String REFRESH_TOKEN = "FakeReFreshToken";
|
||||||
|
|
||||||
@Rule
|
@SuppressWarnings("WeakerAccess")
|
||||||
public final TemporaryFolder folder = new TemporaryFolder();
|
@TempDir
|
||||||
|
Path folder;
|
||||||
|
|
||||||
private final Credential fakeCredential =
|
private final Credential fakeCredential =
|
||||||
new Credential.Builder(
|
new Credential.Builder(
|
||||||
|
@ -77,8 +80,7 @@ public class AuthModuleTest {
|
||||||
.setClientAuthentication(new ClientParametersAuthentication(CLIENT_ID, CLIENT_SECRET))
|
.setClientAuthentication(new ClientParametersAuthentication(CLIENT_ID, CLIENT_SECRET))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@Mock DataStore<StoredCredential> dataStore;
|
||||||
DataStore<StoredCredential> dataStore = mock(DataStore.class);
|
|
||||||
|
|
||||||
class FakeDataStoreFactory extends AbstractDataStoreFactory {
|
class FakeDataStoreFactory extends AbstractDataStoreFactory {
|
||||||
@Override
|
@Override
|
||||||
|
@ -89,14 +91,15 @@ public class AuthModuleTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setUp() throws Exception {
|
void beforeEach() throws Exception {
|
||||||
fakeCredential.setRefreshToken(REFRESH_TOKEN);
|
fakeCredential.setRefreshToken(REFRESH_TOKEN);
|
||||||
when(dataStore.get(CLIENT_ID + " scope1")).thenReturn(new StoredCredential(fakeCredential));
|
when(dataStore.get(CLIENT_ID + " scope1")).thenReturn(new StoredCredential(fakeCredential));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_clientScopeQualifier() {
|
@MockitoSettings(strictness = Strictness.LENIENT)
|
||||||
|
void test_clientScopeQualifier() {
|
||||||
String simpleQualifier =
|
String simpleQualifier =
|
||||||
AuthModule.provideClientScopeQualifier("client-id", ImmutableList.of("foo", "bar"));
|
AuthModule.provideClientScopeQualifier("client-id", ImmutableList.of("foo", "bar"));
|
||||||
|
|
||||||
|
@ -161,7 +164,7 @@ public class AuthModuleTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_provideLocalCredentialJson() {
|
void test_provideLocalCredentialJson() {
|
||||||
String credentialJson =
|
String credentialJson =
|
||||||
AuthModule.provideLocalCredentialJson(this::getSecrets, this::getCredential, null);
|
AuthModule.provideLocalCredentialJson(this::getSecrets, this::getCredential, null);
|
||||||
Map<String, String> jsonMap =
|
Map<String, String> jsonMap =
|
||||||
|
@ -173,8 +176,9 @@ public class AuthModuleTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_provideExternalCredentialJson() throws Exception {
|
@MockitoSettings(strictness = Strictness.LENIENT)
|
||||||
File credentialFile = folder.newFile("credential.json");
|
void test_provideExternalCredentialJson() throws Exception {
|
||||||
|
File credentialFile = folder.resolve("credential.json").toFile();
|
||||||
Files.write(credentialFile.toPath(), "{some_field: some_value}".getBytes(UTF_8));
|
Files.write(credentialFile.toPath(), "{some_field: some_value}".getBytes(UTF_8));
|
||||||
String credentialJson =
|
String credentialJson =
|
||||||
AuthModule.provideLocalCredentialJson(
|
AuthModule.provideLocalCredentialJson(
|
||||||
|
@ -183,7 +187,7 @@ public class AuthModuleTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_provideCredential() {
|
void test_provideCredential() {
|
||||||
Credential cred = getCredential();
|
Credential cred = getCredential();
|
||||||
assertThat(cred.getAccessToken()).isEqualTo(fakeCredential.getAccessToken());
|
assertThat(cred.getAccessToken()).isEqualTo(fakeCredential.getAccessToken());
|
||||||
assertThat(cred.getRefreshToken()).isEqualTo(fakeCredential.getRefreshToken());
|
assertThat(cred.getRefreshToken()).isEqualTo(fakeCredential.getRefreshToken());
|
||||||
|
@ -192,7 +196,7 @@ public class AuthModuleTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_provideCredential_notStored() throws IOException {
|
void test_provideCredential_notStored() throws IOException {
|
||||||
when(dataStore.get(CLIENT_ID + " scope1")).thenReturn(null);
|
when(dataStore.get(CLIENT_ID + " scope1")).thenReturn(null);
|
||||||
assertThrows(AuthModule.LoginRequiredException.class, this::getCredential);
|
assertThrows(AuthModule.LoginRequiredException.class, this::getCredential);
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,26 +19,26 @@ import static org.junit.Assert.assertThrows;
|
||||||
|
|
||||||
import com.beust.jcommander.ParameterException;
|
import com.beust.jcommander.ParameterException;
|
||||||
import google.registry.model.registrar.Registrar.Type;
|
import google.registry.model.registrar.Registrar.Type;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
/** Unit tests for {@link CheckDomainClaimsCommand}. */
|
/** Unit tests for {@link CheckDomainClaimsCommand}. */
|
||||||
public class CheckDomainClaimsCommandTest extends EppToolCommandTestCase<CheckDomainClaimsCommand> {
|
class CheckDomainClaimsCommandTest extends EppToolCommandTestCase<CheckDomainClaimsCommand> {
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void before() {
|
void beforeEach() {
|
||||||
persistNewRegistrar("adminreg", "Admin Registrar", Type.REAL, 693L);
|
persistNewRegistrar("adminreg", "Admin Registrar", Type.REAL, 693L);
|
||||||
command.registryAdminClientId = "adminreg";
|
command.registryAdminClientId = "adminreg";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess() throws Exception {
|
void testSuccess() throws Exception {
|
||||||
runCommand("--client=NewRegistrar", "example.tld");
|
runCommand("--client=NewRegistrar", "example.tld");
|
||||||
eppVerifier.expectDryRun().verifySent("domain_check_claims.xml");
|
eppVerifier.expectDryRun().verifySent("domain_check_claims.xml");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_multipleTlds() throws Exception {
|
void testSuccess_multipleTlds() throws Exception {
|
||||||
runCommand("--client=NewRegistrar", "example.tld", "example.tld2");
|
runCommand("--client=NewRegistrar", "example.tld", "example.tld2");
|
||||||
eppVerifier
|
eppVerifier
|
||||||
.expectDryRun()
|
.expectDryRun()
|
||||||
|
@ -47,7 +47,7 @@ public class CheckDomainClaimsCommandTest extends EppToolCommandTestCase<CheckDo
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_multipleDomains() throws Exception {
|
void testSuccess_multipleDomains() throws Exception {
|
||||||
runCommand(
|
runCommand(
|
||||||
"--client=NewRegistrar",
|
"--client=NewRegistrar",
|
||||||
"example.tld",
|
"example.tld",
|
||||||
|
@ -57,7 +57,7 @@ public class CheckDomainClaimsCommandTest extends EppToolCommandTestCase<CheckDo
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_multipleDomainsAndTlds() throws Exception {
|
void testSuccess_multipleDomainsAndTlds() throws Exception {
|
||||||
runCommand(
|
runCommand(
|
||||||
"--client=NewRegistrar",
|
"--client=NewRegistrar",
|
||||||
"example.tld",
|
"example.tld",
|
||||||
|
@ -71,18 +71,18 @@ public class CheckDomainClaimsCommandTest extends EppToolCommandTestCase<CheckDo
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_unspecifiedClientId_defaultsToRegistryRegistrar() throws Exception {
|
void testSuccess_unspecifiedClientId_defaultsToRegistryRegistrar() throws Exception {
|
||||||
runCommand("example.tld");
|
runCommand("example.tld");
|
||||||
eppVerifier.expectDryRun().expectClientId("adminreg").verifySent("domain_check_claims.xml");
|
eppVerifier.expectDryRun().expectClientId("adminreg").verifySent("domain_check_claims.xml");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_NoMainParameter() {
|
void testFailure_NoMainParameter() {
|
||||||
assertThrows(ParameterException.class, () -> runCommand("--client=NewRegistrar"));
|
assertThrows(ParameterException.class, () -> runCommand("--client=NewRegistrar"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_unknownFlag() {
|
void testFailure_unknownFlag() {
|
||||||
assertThrows(
|
assertThrows(
|
||||||
ParameterException.class,
|
ParameterException.class,
|
||||||
() -> runCommand("--client=NewRegistrar", "--unrecognized=foo", "example.tld"));
|
() -> runCommand("--client=NewRegistrar", "--unrecognized=foo", "example.tld"));
|
||||||
|
|
|
@ -19,26 +19,26 @@ import static org.junit.Assert.assertThrows;
|
||||||
|
|
||||||
import com.beust.jcommander.ParameterException;
|
import com.beust.jcommander.ParameterException;
|
||||||
import google.registry.model.registrar.Registrar.Type;
|
import google.registry.model.registrar.Registrar.Type;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
/** Unit tests for {@link CheckDomainCommand}. */
|
/** Unit tests for {@link CheckDomainCommand}. */
|
||||||
public class CheckDomainCommandTest extends EppToolCommandTestCase<CheckDomainCommand> {
|
class CheckDomainCommandTest extends EppToolCommandTestCase<CheckDomainCommand> {
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void before() {
|
void beforeEach() {
|
||||||
persistNewRegistrar("adminreg", "Admin Registrar", Type.REAL, 693L);
|
persistNewRegistrar("adminreg", "Admin Registrar", Type.REAL, 693L);
|
||||||
command.registryAdminClientId = "adminreg";
|
command.registryAdminClientId = "adminreg";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess() throws Exception {
|
void testSuccess() throws Exception {
|
||||||
runCommand("--client=NewRegistrar", "example.tld");
|
runCommand("--client=NewRegistrar", "example.tld");
|
||||||
eppVerifier.expectDryRun().verifySent("domain_check_fee.xml");
|
eppVerifier.expectDryRun().verifySent("domain_check_fee.xml");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_multipleTlds() throws Exception {
|
void testSuccess_multipleTlds() throws Exception {
|
||||||
runCommand("--client=NewRegistrar", "example.tld", "example.tld2");
|
runCommand("--client=NewRegistrar", "example.tld", "example.tld2");
|
||||||
eppVerifier
|
eppVerifier
|
||||||
.expectDryRun()
|
.expectDryRun()
|
||||||
|
@ -47,7 +47,7 @@ public class CheckDomainCommandTest extends EppToolCommandTestCase<CheckDomainCo
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_multipleDomains() throws Exception {
|
void testSuccess_multipleDomains() throws Exception {
|
||||||
runCommand(
|
runCommand(
|
||||||
"--client=NewRegistrar",
|
"--client=NewRegistrar",
|
||||||
"example.tld",
|
"example.tld",
|
||||||
|
@ -57,7 +57,7 @@ public class CheckDomainCommandTest extends EppToolCommandTestCase<CheckDomainCo
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_multipleDomainsAndTlds() throws Exception {
|
void testSuccess_multipleDomainsAndTlds() throws Exception {
|
||||||
runCommand(
|
runCommand(
|
||||||
"--client=NewRegistrar",
|
"--client=NewRegistrar",
|
||||||
"example.tld",
|
"example.tld",
|
||||||
|
@ -71,24 +71,24 @@ public class CheckDomainCommandTest extends EppToolCommandTestCase<CheckDomainCo
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_unspecifiedClientId_defaultsToRegistryRegistrar() throws Exception {
|
void testSuccess_unspecifiedClientId_defaultsToRegistryRegistrar() throws Exception {
|
||||||
runCommand("example.tld");
|
runCommand("example.tld");
|
||||||
eppVerifier.expectDryRun().expectClientId("adminreg").verifySent("domain_check_fee.xml");
|
eppVerifier.expectDryRun().expectClientId("adminreg").verifySent("domain_check_fee.xml");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_allocationToken_reserved() throws Exception {
|
void testSuccess_allocationToken_reserved() throws Exception {
|
||||||
runCommand("--client=NewRegistrar", "--token=abc123", "example.tld");
|
runCommand("--client=NewRegistrar", "--token=abc123", "example.tld");
|
||||||
eppVerifier.expectDryRun().verifySent("domain_check_fee_allocationtoken.xml");
|
eppVerifier.expectDryRun().verifySent("domain_check_fee_allocationtoken.xml");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_NoMainParameter() {
|
void testFailure_NoMainParameter() {
|
||||||
assertThrows(ParameterException.class, () -> runCommand("--client=NewRegistrar"));
|
assertThrows(ParameterException.class, () -> runCommand("--client=NewRegistrar"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_unknownFlag() {
|
void testFailure_unknownFlag() {
|
||||||
assertThrows(
|
assertThrows(
|
||||||
ParameterException.class,
|
ParameterException.class,
|
||||||
() -> runCommand("--client=NewRegistrar", "--unrecognized=foo", "example.tld"));
|
() -> runCommand("--client=NewRegistrar", "--unrecognized=foo", "example.tld"));
|
||||||
|
|
|
@ -35,27 +35,25 @@ import google.registry.testing.FakeClock;
|
||||||
import google.registry.testing.SystemPropertyRule;
|
import google.registry.testing.SystemPropertyRule;
|
||||||
import google.registry.tools.params.ParameterFactory;
|
import google.registry.tools.params.ParameterFactory;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
|
import java.nio.file.Path;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.locks.ReentrantLock;
|
import java.util.concurrent.locks.ReentrantLock;
|
||||||
import org.junit.After;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Rule;
|
import org.junit.jupiter.api.extension.ExtendWith;
|
||||||
import org.junit.rules.TemporaryFolder;
|
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.jupiter.api.io.TempDir;
|
||||||
import org.junit.runners.JUnit4;
|
import org.mockito.junit.jupiter.MockitoExtension;
|
||||||
import org.mockito.junit.MockitoJUnit;
|
|
||||||
import org.mockito.junit.MockitoRule;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base class for all command tests.
|
* Base class for all command tests.
|
||||||
*
|
*
|
||||||
* @param <C> the command type
|
* @param <C> the command type
|
||||||
*/
|
*/
|
||||||
@RunWith(JUnit4.class)
|
@ExtendWith(MockitoExtension.class)
|
||||||
public abstract class CommandTestCase<C extends Command> {
|
public abstract class CommandTestCase<C extends Command> {
|
||||||
|
|
||||||
// Lock for stdout/stderr. Note that this is static: since we're dealing with globals, we need
|
// Lock for stdout/stderr. Note that this is static: since we're dealing with globals, we need
|
||||||
|
@ -70,7 +68,7 @@ public abstract class CommandTestCase<C extends Command> {
|
||||||
|
|
||||||
public final FakeClock fakeClock = new FakeClock();
|
public final FakeClock fakeClock = new FakeClock();
|
||||||
|
|
||||||
@Rule
|
@RegisterExtension
|
||||||
public final AppEngineRule appEngine =
|
public final AppEngineRule appEngine =
|
||||||
AppEngineRule.builder()
|
AppEngineRule.builder()
|
||||||
.withDatastoreAndCloudSql()
|
.withDatastoreAndCloudSql()
|
||||||
|
@ -78,15 +76,12 @@ public abstract class CommandTestCase<C extends Command> {
|
||||||
.withTaskQueue()
|
.withTaskQueue()
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
@Rule public final SystemPropertyRule systemPropertyRule = new SystemPropertyRule();
|
@RegisterExtension final SystemPropertyRule systemPropertyRule = new SystemPropertyRule();
|
||||||
|
|
||||||
@Rule public final MockitoRule mocks = MockitoJUnit.rule();
|
@TempDir public Path tmpDir;
|
||||||
|
|
||||||
@Rule
|
@BeforeEach
|
||||||
public TemporaryFolder tmpDir = new TemporaryFolder();
|
public final void beforeEachCommandTestCase() throws Exception {
|
||||||
|
|
||||||
@Before
|
|
||||||
public final void beforeCommandTestCase() throws Exception {
|
|
||||||
// Ensure the UNITTEST environment has been set before constructing a new command instance.
|
// Ensure the UNITTEST environment has been set before constructing a new command instance.
|
||||||
RegistryToolEnvironment.UNITTEST.setup(systemPropertyRule);
|
RegistryToolEnvironment.UNITTEST.setup(systemPropertyRule);
|
||||||
command = newCommandInstance();
|
command = newCommandInstance();
|
||||||
|
@ -101,8 +96,8 @@ public abstract class CommandTestCase<C extends Command> {
|
||||||
System.setErr(new PrintStream(new OutputSplitter(System.err, stderr)));
|
System.setErr(new PrintStream(new OutputSplitter(System.err, stderr)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@AfterEach
|
||||||
public final void afterCommandTestCase() throws Exception {
|
public final void afterEachCommandTestCase() {
|
||||||
System.setOut(oldStdout);
|
System.setOut(oldStdout);
|
||||||
System.setErr(oldStderr);
|
System.setErr(oldStderr);
|
||||||
streamsLock.unlock();
|
streamsLock.unlock();
|
||||||
|
@ -144,10 +139,10 @@ public abstract class CommandTestCase<C extends Command> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Writes the data to a named temporary file and then returns a path to the file. */
|
/** Writes the data to a named temporary file and then returns a path to the file. */
|
||||||
String writeToNamedTmpFile(String filename, byte[] data) throws IOException {
|
private String writeToNamedTmpFile(String filename, byte[] data) throws IOException {
|
||||||
File tmpFile = tmpDir.newFile(filename);
|
Path tmpFile = tmpDir.resolve(filename);
|
||||||
Files.write(data, tmpFile);
|
Files.write(data, tmpFile.toFile());
|
||||||
return tmpFile.getPath();
|
return tmpFile.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Writes the data to a named temporary file and then returns a path to the file. */
|
/** Writes the data to a named temporary file and then returns a path to the file. */
|
||||||
|
@ -199,7 +194,7 @@ public abstract class CommandTestCase<C extends Command> {
|
||||||
.isEqualTo(stripImmutableObjectHashCodes(expected).trim());
|
.isEqualTo(stripImmutableObjectHashCodes(expected).trim());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void assertStdoutIs(String expected) {
|
void assertStdoutIs(String expected) {
|
||||||
assertThat(getStdoutAsString()).isEqualTo(expected);
|
assertThat(getStdoutAsString()).isEqualTo(expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -210,34 +205,34 @@ public abstract class CommandTestCase<C extends Command> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void assertInStderr(String... expected) {
|
void assertInStderr(String... expected) {
|
||||||
String stderror = new String(stderr.toByteArray(), UTF_8);
|
String stderror = new String(stderr.toByteArray(), UTF_8);
|
||||||
for (String line : expected) {
|
for (String line : expected) {
|
||||||
assertThat(stderror).contains(line);
|
assertThat(stderror).contains(line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void assertNotInStdout(String expected) {
|
void assertNotInStdout(String expected) {
|
||||||
assertThat(getStdoutAsString()).doesNotContain(expected);
|
assertThat(getStdoutAsString()).doesNotContain(expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void assertNotInStderr(String expected) {
|
void assertNotInStderr(String expected) {
|
||||||
assertThat(getStderrAsString()).doesNotContain(expected);
|
assertThat(getStderrAsString()).doesNotContain(expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String getStdoutAsString() {
|
String getStdoutAsString() {
|
||||||
return new String(stdout.toByteArray(), UTF_8);
|
return new String(stdout.toByteArray(), UTF_8);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String getStderrAsString() {
|
String getStderrAsString() {
|
||||||
return new String(stderr.toByteArray(), UTF_8);
|
return new String(stderr.toByteArray(), UTF_8);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected List<String> getStdoutAsLines() {
|
List<String> getStdoutAsLines() {
|
||||||
return Splitter.on('\n').omitEmptyStrings().trimResults().splitToList(getStdoutAsString());
|
return Splitter.on('\n').omitEmptyStrings().trimResults().splitToList(getStdoutAsString());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String stripImmutableObjectHashCodes(String string) {
|
private String stripImmutableObjectHashCodes(String string) {
|
||||||
return string.replaceAll("\\(@\\d+\\)", "(@)");
|
return string.replaceAll("\\(@\\d+\\)", "(@)");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,14 +22,15 @@ import google.registry.testing.DatastoreEntityExtension;
|
||||||
import google.registry.tools.EntityWrapper.Property;
|
import google.registry.tools.EntityWrapper.Property;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
import org.junit.jupiter.api.AfterEach;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||||
import org.junit.rules.TemporaryFolder;
|
import org.junit.jupiter.api.io.TempDir;
|
||||||
|
|
||||||
public class CompareDbBackupsTest {
|
public class CompareDbBackupsTest {
|
||||||
|
|
||||||
|
@ -39,26 +40,24 @@ public class CompareDbBackupsTest {
|
||||||
private final ByteArrayOutputStream stdout = new ByteArrayOutputStream();
|
private final ByteArrayOutputStream stdout = new ByteArrayOutputStream();
|
||||||
private PrintStream orgStdout;
|
private PrintStream orgStdout;
|
||||||
|
|
||||||
public final TemporaryFolder tempFs = new TemporaryFolder();
|
@TempDir Path tmpDir;
|
||||||
|
|
||||||
@RegisterExtension
|
@RegisterExtension
|
||||||
public DatastoreEntityExtension datastoreEntityExtension = new DatastoreEntityExtension();
|
public DatastoreEntityExtension datastoreEntityExtension = new DatastoreEntityExtension();
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
public void before() throws IOException {
|
void beforeEach() {
|
||||||
orgStdout = System.out;
|
orgStdout = System.out;
|
||||||
System.setOut(new PrintStream(stdout));
|
System.setOut(new PrintStream(stdout));
|
||||||
tempFs.create();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterEach
|
@AfterEach
|
||||||
public void after() {
|
void afterEach() {
|
||||||
System.setOut(orgStdout);
|
System.setOut(orgStdout);
|
||||||
tempFs.delete();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testLoadBackup() {
|
void testLoadBackup() {
|
||||||
URL backupRootFolder = Resources.getResource("google/registry/tools/datastore-export");
|
URL backupRootFolder = Resources.getResource("google/registry/tools/datastore-export");
|
||||||
CompareDbBackups.main(new String[] {backupRootFolder.getPath(), backupRootFolder.getPath()});
|
CompareDbBackups.main(new String[] {backupRootFolder.getPath(), backupRootFolder.getPath()});
|
||||||
String output = new String(stdout.toByteArray(), UTF_8);
|
String output = new String(stdout.toByteArray(), UTF_8);
|
||||||
|
@ -66,11 +65,12 @@ public class CompareDbBackupsTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCompareBackups() throws Exception {
|
void testCompareBackups() throws Exception {
|
||||||
|
|
||||||
// Create two directories corresponding to data dumps.
|
// Create two directories corresponding to data dumps.
|
||||||
File dump1 = tempFs.newFolder("dump1");
|
Path dump1 = Files.createDirectory(tmpDir.resolve("dump1"));
|
||||||
LevelDbFileBuilder builder = new LevelDbFileBuilder(new File(dump1, "output-data1"));
|
Path dump2 = Files.createDirectory(tmpDir.resolve("dump2"));
|
||||||
|
|
||||||
|
LevelDbFileBuilder builder = new LevelDbFileBuilder(new File(dump1.toFile(), "output-data1"));
|
||||||
builder.addEntity(
|
builder.addEntity(
|
||||||
EntityWrapper.from(
|
EntityWrapper.from(
|
||||||
BASE_ID,
|
BASE_ID,
|
||||||
|
@ -87,8 +87,7 @@ public class CompareDbBackupsTest {
|
||||||
.getEntity());
|
.getEntity());
|
||||||
builder.build();
|
builder.build();
|
||||||
|
|
||||||
File dump2 = tempFs.newFolder("dump2");
|
builder = new LevelDbFileBuilder(new File(dump2.toFile(), "output-data2"));
|
||||||
builder = new LevelDbFileBuilder(new File(dump2, "output-data2"));
|
|
||||||
builder.addEntity(
|
builder.addEntity(
|
||||||
EntityWrapper.from(
|
EntityWrapper.from(
|
||||||
BASE_ID + 1,
|
BASE_ID + 1,
|
||||||
|
@ -105,7 +104,7 @@ public class CompareDbBackupsTest {
|
||||||
.getEntity());
|
.getEntity());
|
||||||
builder.build();
|
builder.build();
|
||||||
|
|
||||||
CompareDbBackups.main(new String[] {dump1.getCanonicalPath(), dump2.getCanonicalPath()});
|
CompareDbBackups.main(new String[] {dump1.toString(), dump2.toString()});
|
||||||
String output = new String(stdout.toByteArray(), UTF_8);
|
String output = new String(stdout.toByteArray(), UTF_8);
|
||||||
assertThat(output)
|
assertThat(output)
|
||||||
.containsMatch("(?s)1 records were removed.*eeny.*1 records were added.*blutzy");
|
.containsMatch("(?s)1 records were removed.*eeny.*1 records were added.*blutzy");
|
||||||
|
|
|
@ -23,26 +23,26 @@ import google.registry.model.ofy.Ofy;
|
||||||
import google.registry.testing.FakeClock;
|
import google.registry.testing.FakeClock;
|
||||||
import google.registry.testing.InjectRule;
|
import google.registry.testing.InjectRule;
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Rule;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||||
|
|
||||||
/** Unit tests for {@link CountDomainsCommand}. */
|
/** Unit tests for {@link CountDomainsCommand}. */
|
||||||
public class CountDomainsCommandTest extends CommandTestCase<CountDomainsCommand> {
|
public class CountDomainsCommandTest extends CommandTestCase<CountDomainsCommand> {
|
||||||
|
|
||||||
protected FakeClock clock = new FakeClock(DateTime.now(UTC));
|
protected FakeClock clock = new FakeClock(DateTime.now(UTC));
|
||||||
|
|
||||||
@Rule public final InjectRule inject = new InjectRule();
|
@RegisterExtension public final InjectRule inject = new InjectRule();
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public final void before() {
|
final void beforeEach() {
|
||||||
inject.setStaticField(Ofy.class, "clock", clock);
|
inject.setStaticField(Ofy.class, "clock", clock);
|
||||||
command.clock = clock;
|
command.clock = clock;
|
||||||
createTlds("foo", "bar", "baz", "qux");
|
createTlds("foo", "bar", "baz", "qux");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_singleTld() throws Exception {
|
void testSuccess_singleTld() throws Exception {
|
||||||
for (int i = 0; i < 51; i++) {
|
for (int i = 0; i < 51; i++) {
|
||||||
persistActiveDomain(String.format("test-%d.foo", i));
|
persistActiveDomain(String.format("test-%d.foo", i));
|
||||||
if (i > 31) {
|
if (i > 31) {
|
||||||
|
@ -54,7 +54,7 @@ public class CountDomainsCommandTest extends CommandTestCase<CountDomainsCommand
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_multipleTlds() throws Exception {
|
void testSuccess_multipleTlds() throws Exception {
|
||||||
command.clock = clock;
|
command.clock = clock;
|
||||||
for (int i = 0; i < 29; i++) {
|
for (int i = 0; i < 29; i++) {
|
||||||
persistActiveDomain(String.format("test-%d.foo", i));
|
persistActiveDomain(String.format("test-%d.foo", i));
|
||||||
|
|
|
@ -22,34 +22,33 @@ import static org.junit.Assert.assertThrows;
|
||||||
import com.beust.jcommander.ParameterException;
|
import com.beust.jcommander.ParameterException;
|
||||||
import google.registry.model.registry.Registry;
|
import google.registry.model.registry.Registry;
|
||||||
import google.registry.testing.DeterministicStringGenerator;
|
import google.registry.testing.DeterministicStringGenerator;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
/** Unit tests for {@link CreateAnchorTenantCommand}. */
|
/** Unit tests for {@link CreateAnchorTenantCommand}. */
|
||||||
public class CreateAnchorTenantCommandTest
|
class CreateAnchorTenantCommandTest extends EppToolCommandTestCase<CreateAnchorTenantCommand> {
|
||||||
extends EppToolCommandTestCase<CreateAnchorTenantCommand> {
|
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void initCommand() {
|
void beforeEach() {
|
||||||
command.passwordGenerator = new DeterministicStringGenerator("abcdefghijklmnopqrstuvwxyz");
|
command.passwordGenerator = new DeterministicStringGenerator("abcdefghijklmnopqrstuvwxyz");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess() throws Exception {
|
void testSuccess() throws Exception {
|
||||||
runCommandForced("--client=NewRegistrar", "--superuser",
|
runCommandForced("--client=NewRegistrar", "--superuser",
|
||||||
"--reason=anchor-tenant-test", "--contact=jd1234", "--domain_name=example.tld");
|
"--reason=anchor-tenant-test", "--contact=jd1234", "--domain_name=example.tld");
|
||||||
eppVerifier.expectSuperuser().verifySent("domain_create_anchor_tenant.xml");
|
eppVerifier.expectSuperuser().verifySent("domain_create_anchor_tenant.xml");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_suppliedPassword() throws Exception {
|
void testSuccess_suppliedPassword() throws Exception {
|
||||||
runCommandForced("--client=NewRegistrar", "--superuser", "--password=foo",
|
runCommandForced("--client=NewRegistrar", "--superuser", "--password=foo",
|
||||||
"--reason=anchor-tenant-test", "--contact=jd1234", "--domain_name=example.tld");
|
"--reason=anchor-tenant-test", "--contact=jd1234", "--domain_name=example.tld");
|
||||||
eppVerifier.expectSuperuser().verifySent("domain_create_anchor_tenant_password.xml");
|
eppVerifier.expectSuperuser().verifySent("domain_create_anchor_tenant_password.xml");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_multipleWordReason() throws Exception {
|
void testSuccess_multipleWordReason() throws Exception {
|
||||||
runCommandForced("--client=NewRegistrar", "--superuser",
|
runCommandForced("--client=NewRegistrar", "--superuser",
|
||||||
"--reason=\"anchor tenant test\"", "--contact=jd1234", "--domain_name=example.tld");
|
"--reason=\"anchor tenant test\"", "--contact=jd1234", "--domain_name=example.tld");
|
||||||
eppVerifier
|
eppVerifier
|
||||||
|
@ -58,21 +57,21 @@ public class CreateAnchorTenantCommandTest
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_noReason() throws Exception {
|
void testSuccess_noReason() throws Exception {
|
||||||
runCommandForced("--client=NewRegistrar", "--superuser",
|
runCommandForced("--client=NewRegistrar", "--superuser",
|
||||||
"--contact=jd1234", "--domain_name=example.tld");
|
"--contact=jd1234", "--domain_name=example.tld");
|
||||||
eppVerifier.expectSuperuser().verifySent("domain_create_anchor_tenant_no_reason.xml");
|
eppVerifier.expectSuperuser().verifySent("domain_create_anchor_tenant_no_reason.xml");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_feeStandard() throws Exception {
|
void testSuccess_feeStandard() throws Exception {
|
||||||
runCommandForced("--client=NewRegistrar", "--superuser", "--fee",
|
runCommandForced("--client=NewRegistrar", "--superuser", "--fee",
|
||||||
"--reason=anchor-tenant-test", "--contact=jd1234", "--domain_name=example.tld");
|
"--reason=anchor-tenant-test", "--contact=jd1234", "--domain_name=example.tld");
|
||||||
eppVerifier.expectSuperuser().verifySent("domain_create_anchor_tenant_fee_standard.xml");
|
eppVerifier.expectSuperuser().verifySent("domain_create_anchor_tenant_fee_standard.xml");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_feePremium() throws Exception {
|
void testSuccess_feePremium() throws Exception {
|
||||||
createTld("tld");
|
createTld("tld");
|
||||||
persistResource(
|
persistResource(
|
||||||
Registry.get("tld")
|
Registry.get("tld")
|
||||||
|
@ -85,7 +84,7 @@ public class CreateAnchorTenantCommandTest
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_mainParameter() {
|
void testFailure_mainParameter() {
|
||||||
assertThrows(
|
assertThrows(
|
||||||
ParameterException.class,
|
ParameterException.class,
|
||||||
() ->
|
() ->
|
||||||
|
@ -100,7 +99,7 @@ public class CreateAnchorTenantCommandTest
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_missingClientId() {
|
void testFailure_missingClientId() {
|
||||||
assertThrows(
|
assertThrows(
|
||||||
ParameterException.class,
|
ParameterException.class,
|
||||||
() ->
|
() ->
|
||||||
|
@ -112,7 +111,7 @@ public class CreateAnchorTenantCommandTest
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_unknownFlag() {
|
void testFailure_unknownFlag() {
|
||||||
assertThrows(
|
assertThrows(
|
||||||
ParameterException.class,
|
ParameterException.class,
|
||||||
() ->
|
() ->
|
||||||
|
@ -126,7 +125,7 @@ public class CreateAnchorTenantCommandTest
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_missingDomainName() {
|
void testFailure_missingDomainName() {
|
||||||
assertThrows(
|
assertThrows(
|
||||||
ParameterException.class,
|
ParameterException.class,
|
||||||
() ->
|
() ->
|
||||||
|
@ -139,7 +138,7 @@ public class CreateAnchorTenantCommandTest
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_missingContact() {
|
void testFailure_missingContact() {
|
||||||
assertThrows(
|
assertThrows(
|
||||||
ParameterException.class,
|
ParameterException.class,
|
||||||
() ->
|
() ->
|
||||||
|
@ -152,7 +151,7 @@ public class CreateAnchorTenantCommandTest
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_notAsSuperuser() {
|
void testFailure_notAsSuperuser() {
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
() ->
|
() ->
|
||||||
|
|
|
@ -22,14 +22,16 @@ import static org.mockito.Mockito.when;
|
||||||
import com.google.api.services.dns.Dns;
|
import com.google.api.services.dns.Dns;
|
||||||
import com.google.api.services.dns.model.ManagedZone;
|
import com.google.api.services.dns.model.ManagedZone;
|
||||||
import com.google.api.services.dns.model.ManagedZoneDnsSecConfig;
|
import com.google.api.services.dns.model.ManagedZoneDnsSecConfig;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.mockito.ArgumentCaptor;
|
import org.mockito.ArgumentCaptor;
|
||||||
import org.mockito.Captor;
|
import org.mockito.Captor;
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
|
import org.mockito.junit.jupiter.MockitoSettings;
|
||||||
|
import org.mockito.quality.Strictness;
|
||||||
|
|
||||||
/** Unit tests for {@link CreateCdnsTld}. */
|
/** Unit tests for {@link CreateCdnsTld}. */
|
||||||
public class CreateCdnsTldTest extends CommandTestCase<CreateCdnsTld> {
|
class CreateCdnsTldTest extends CommandTestCase<CreateCdnsTld> {
|
||||||
|
|
||||||
@Mock Dns dnsService;
|
@Mock Dns dnsService;
|
||||||
@Mock Dns.ManagedZones managedZones;
|
@Mock Dns.ManagedZones managedZones;
|
||||||
|
@ -37,8 +39,8 @@ public class CreateCdnsTldTest extends CommandTestCase<CreateCdnsTld> {
|
||||||
@Captor ArgumentCaptor<String> projectId;
|
@Captor ArgumentCaptor<String> projectId;
|
||||||
@Captor ArgumentCaptor<ManagedZone> requestBody;
|
@Captor ArgumentCaptor<ManagedZone> requestBody;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setUp() throws Exception {
|
void beforeEach() throws Exception {
|
||||||
when(dnsService.managedZones()).thenReturn(managedZones);
|
when(dnsService.managedZones()).thenReturn(managedZones);
|
||||||
when(managedZones.create(projectId.capture(), requestBody.capture())).thenReturn(request);
|
when(managedZones.create(projectId.capture(), requestBody.capture())).thenReturn(request);
|
||||||
command = new CreateCdnsTld();
|
command = new CreateCdnsTld();
|
||||||
|
@ -57,7 +59,7 @@ public class CreateCdnsTldTest extends CommandTestCase<CreateCdnsTld> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testBasicFunctionality() throws Exception {
|
void testBasicFunctionality() throws Exception {
|
||||||
runCommand("--dns_name=tld.", "--name=tld", "--description=test run", "--force");
|
runCommand("--dns_name=tld.", "--name=tld", "--description=test run", "--force");
|
||||||
verify(request).execute();
|
verify(request).execute();
|
||||||
assertThat(projectId.getValue()).isEqualTo("test-project");
|
assertThat(projectId.getValue()).isEqualTo("test-project");
|
||||||
|
@ -66,14 +68,15 @@ public class CreateCdnsTldTest extends CommandTestCase<CreateCdnsTld> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNameDefault() throws Exception {
|
void testNameDefault() throws Exception {
|
||||||
runCommand("--dns_name=tld.", "--description=test run", "--force");
|
runCommand("--dns_name=tld.", "--description=test run", "--force");
|
||||||
ManagedZone zone = requestBody.getValue();
|
ManagedZone zone = requestBody.getValue();
|
||||||
assertThat(zone).isEqualTo(createZone("cloud-dns-registry-test", "test run", "tld.", "tld."));
|
assertThat(zone).isEqualTo(createZone("cloud-dns-registry-test", "test run", "tld.", "tld."));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSandboxTldRestrictions() throws Exception {
|
@MockitoSettings(strictness = Strictness.LENIENT)
|
||||||
|
void testSandboxTldRestrictions() throws Exception {
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
|
|
|
@ -18,19 +18,19 @@ import static org.junit.Assert.assertThrows;
|
||||||
|
|
||||||
import com.beust.jcommander.ParameterException;
|
import com.beust.jcommander.ParameterException;
|
||||||
import google.registry.testing.DeterministicStringGenerator;
|
import google.registry.testing.DeterministicStringGenerator;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
/** Unit tests for {@link CreateContactCommand}. */
|
/** Unit tests for {@link CreateContactCommand}. */
|
||||||
public class CreateContactCommandTest extends EppToolCommandTestCase<CreateContactCommand> {
|
class CreateContactCommandTest extends EppToolCommandTestCase<CreateContactCommand> {
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void initCommand() {
|
void beforeEach() {
|
||||||
command.passwordGenerator = new DeterministicStringGenerator("abcdefghijklmnopqrstuvwxyz");
|
command.passwordGenerator = new DeterministicStringGenerator("abcdefghijklmnopqrstuvwxyz");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_complete() throws Exception {
|
void testSuccess_complete() throws Exception {
|
||||||
runCommandForced(
|
runCommandForced(
|
||||||
"--client=NewRegistrar",
|
"--client=NewRegistrar",
|
||||||
"--id=sh8013",
|
"--id=sh8013",
|
||||||
|
@ -51,7 +51,7 @@ public class CreateContactCommandTest extends EppToolCommandTestCase<CreateConta
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_minimal() throws Exception {
|
void testSuccess_minimal() throws Exception {
|
||||||
// Will never be the case, but tests that each field can be omitted.
|
// Will never be the case, but tests that each field can be omitted.
|
||||||
// Also tests the auto-gen password.
|
// Also tests the auto-gen password.
|
||||||
runCommandForced("--client=NewRegistrar");
|
runCommandForced("--client=NewRegistrar");
|
||||||
|
@ -59,12 +59,12 @@ public class CreateContactCommandTest extends EppToolCommandTestCase<CreateConta
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_missingClientId() {
|
void testFailure_missingClientId() {
|
||||||
assertThrows(ParameterException.class, this::runCommandForced);
|
assertThrows(ParameterException.class, this::runCommandForced);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_tooManyStreetLines() {
|
void testFailure_tooManyStreetLines() {
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
() ->
|
() ->
|
||||||
|
@ -77,13 +77,13 @@ public class CreateContactCommandTest extends EppToolCommandTestCase<CreateConta
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_badPhone() {
|
void testFailure_badPhone() {
|
||||||
assertThrows(
|
assertThrows(
|
||||||
ParameterException.class, () -> runCommandForced("--client=NewRegistrar", "--phone=3"));
|
ParameterException.class, () -> runCommandForced("--client=NewRegistrar", "--phone=3"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_badFax() {
|
void testFailure_badFax() {
|
||||||
assertThrows(
|
assertThrows(
|
||||||
ParameterException.class, () -> runCommandForced("--client=NewRegistrar", "--fax=3"));
|
ParameterException.class, () -> runCommandForced("--client=NewRegistrar", "--fax=3"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,19 +24,19 @@ import com.beust.jcommander.ParameterException;
|
||||||
import google.registry.model.registry.Registry;
|
import google.registry.model.registry.Registry;
|
||||||
import google.registry.model.registry.label.PremiumList;
|
import google.registry.model.registry.label.PremiumList;
|
||||||
import google.registry.testing.DeterministicStringGenerator;
|
import google.registry.testing.DeterministicStringGenerator;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
/** Unit tests for {@link CreateDomainCommand}. */
|
/** Unit tests for {@link CreateDomainCommand}. */
|
||||||
public class CreateDomainCommandTest extends EppToolCommandTestCase<CreateDomainCommand> {
|
class CreateDomainCommandTest extends EppToolCommandTestCase<CreateDomainCommand> {
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void initCommand() {
|
void beforeEach() {
|
||||||
command.passwordGenerator = new DeterministicStringGenerator("abcdefghijklmnopqrstuvwxyz");
|
command.passwordGenerator = new DeterministicStringGenerator("abcdefghijklmnopqrstuvwxyz");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_complete() throws Exception {
|
void testSuccess_complete() throws Exception {
|
||||||
runCommandForced(
|
runCommandForced(
|
||||||
"--client=NewRegistrar",
|
"--client=NewRegistrar",
|
||||||
"--period=1",
|
"--period=1",
|
||||||
|
@ -52,7 +52,7 @@ public class CreateDomainCommandTest extends EppToolCommandTestCase<CreateDomain
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_completeWithSquareBrackets() throws Exception {
|
void testSuccess_completeWithSquareBrackets() throws Exception {
|
||||||
runCommandForced(
|
runCommandForced(
|
||||||
"--client=NewRegistrar",
|
"--client=NewRegistrar",
|
||||||
"--period=1",
|
"--period=1",
|
||||||
|
@ -68,7 +68,7 @@ public class CreateDomainCommandTest extends EppToolCommandTestCase<CreateDomain
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_minimal() throws Exception {
|
void testSuccess_minimal() throws Exception {
|
||||||
// Test that each optional field can be omitted. Also tests the auto-gen password.
|
// Test that each optional field can be omitted. Also tests the auto-gen password.
|
||||||
runCommandForced(
|
runCommandForced(
|
||||||
"--client=NewRegistrar",
|
"--client=NewRegistrar",
|
||||||
|
@ -80,7 +80,7 @@ public class CreateDomainCommandTest extends EppToolCommandTestCase<CreateDomain
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_multipleDomains() throws Exception {
|
void testSuccess_multipleDomains() throws Exception {
|
||||||
createTld("abc");
|
createTld("abc");
|
||||||
runCommandForced(
|
runCommandForced(
|
||||||
"--client=NewRegistrar",
|
"--client=NewRegistrar",
|
||||||
|
@ -95,7 +95,7 @@ public class CreateDomainCommandTest extends EppToolCommandTestCase<CreateDomain
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_premiumJpyDomain() throws Exception {
|
void testSuccess_premiumJpyDomain() throws Exception {
|
||||||
createTld("baar");
|
createTld("baar");
|
||||||
persistPremiumList("baar", "parajiumu,JPY 96083");
|
persistPremiumList("baar", "parajiumu,JPY 96083");
|
||||||
persistResource(
|
persistResource(
|
||||||
|
@ -118,7 +118,7 @@ public class CreateDomainCommandTest extends EppToolCommandTestCase<CreateDomain
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_multipleDomainsWithPremium() throws Exception {
|
void testSuccess_multipleDomainsWithPremium() throws Exception {
|
||||||
createTld("abc");
|
createTld("abc");
|
||||||
runCommandForced(
|
runCommandForced(
|
||||||
"--client=NewRegistrar",
|
"--client=NewRegistrar",
|
||||||
|
@ -139,7 +139,7 @@ public class CreateDomainCommandTest extends EppToolCommandTestCase<CreateDomain
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_duplicateDomains() {
|
void testFailure_duplicateDomains() {
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
|
@ -155,7 +155,7 @@ public class CreateDomainCommandTest extends EppToolCommandTestCase<CreateDomain
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_missingDomain() {
|
void testFailure_missingDomain() {
|
||||||
ParameterException thrown =
|
ParameterException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
ParameterException.class,
|
ParameterException.class,
|
||||||
|
@ -169,7 +169,7 @@ public class CreateDomainCommandTest extends EppToolCommandTestCase<CreateDomain
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_missingClientId() {
|
void testFailure_missingClientId() {
|
||||||
ParameterException thrown =
|
ParameterException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
ParameterException.class,
|
ParameterException.class,
|
||||||
|
@ -183,7 +183,7 @@ public class CreateDomainCommandTest extends EppToolCommandTestCase<CreateDomain
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_missingRegistrant() {
|
void testFailure_missingRegistrant() {
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
|
@ -197,7 +197,7 @@ public class CreateDomainCommandTest extends EppToolCommandTestCase<CreateDomain
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_missingAdmins() {
|
void testFailure_missingAdmins() {
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
|
@ -211,7 +211,7 @@ public class CreateDomainCommandTest extends EppToolCommandTestCase<CreateDomain
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_missingTechs() {
|
void testFailure_missingTechs() {
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
|
@ -225,7 +225,7 @@ public class CreateDomainCommandTest extends EppToolCommandTestCase<CreateDomain
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_tooManyNameServers() {
|
void testFailure_tooManyNameServers() {
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
|
@ -244,7 +244,7 @@ public class CreateDomainCommandTest extends EppToolCommandTestCase<CreateDomain
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_tooManyNameServers_usingSquareBracketRange() {
|
void testFailure_tooManyNameServers_usingSquareBracketRange() {
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
|
@ -260,7 +260,7 @@ public class CreateDomainCommandTest extends EppToolCommandTestCase<CreateDomain
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_badPeriod() {
|
void testFailure_badPeriod() {
|
||||||
ParameterException thrown =
|
ParameterException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
ParameterException.class,
|
ParameterException.class,
|
||||||
|
@ -276,7 +276,7 @@ public class CreateDomainCommandTest extends EppToolCommandTestCase<CreateDomain
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_dsRecordsNot4Parts() {
|
void testFailure_dsRecordsNot4Parts() {
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
|
@ -292,7 +292,7 @@ public class CreateDomainCommandTest extends EppToolCommandTestCase<CreateDomain
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_keyTagNotNumber() {
|
void testFailure_keyTagNotNumber() {
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
|
@ -308,7 +308,7 @@ public class CreateDomainCommandTest extends EppToolCommandTestCase<CreateDomain
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_algNotNumber() {
|
void testFailure_algNotNumber() {
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
|
@ -324,7 +324,7 @@ public class CreateDomainCommandTest extends EppToolCommandTestCase<CreateDomain
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_digestTypeNotNumber() {
|
void testFailure_digestTypeNotNumber() {
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
|
@ -340,7 +340,7 @@ public class CreateDomainCommandTest extends EppToolCommandTestCase<CreateDomain
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_digestNotHex() {
|
void testFailure_digestNotHex() {
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
|
@ -356,7 +356,7 @@ public class CreateDomainCommandTest extends EppToolCommandTestCase<CreateDomain
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_digestNotEvenLengthed() {
|
void testFailure_digestNotEvenLengthed() {
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
|
@ -372,7 +372,7 @@ public class CreateDomainCommandTest extends EppToolCommandTestCase<CreateDomain
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_cantForceCreatePremiumDomain_withoutForcePremiums() {
|
void testFailure_cantForceCreatePremiumDomain_withoutForcePremiums() {
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
|
|
|
@ -19,13 +19,13 @@ import static google.registry.testing.DatastoreHelper.createTld;
|
||||||
import static org.junit.Assert.assertThrows;
|
import static org.junit.Assert.assertThrows;
|
||||||
|
|
||||||
import com.beust.jcommander.ParameterException;
|
import com.beust.jcommander.ParameterException;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
/** Unit tests for {@link CreateHostCommand}. */
|
/** Unit tests for {@link CreateHostCommand}. */
|
||||||
public class CreateHostCommandTest extends EppToolCommandTestCase<CreateHostCommand> {
|
class CreateHostCommandTest extends EppToolCommandTestCase<CreateHostCommand> {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_complete() throws Exception {
|
void testSuccess_complete() throws Exception {
|
||||||
createTld("tld");
|
createTld("tld");
|
||||||
runCommandForced(
|
runCommandForced(
|
||||||
"--client=NewRegistrar",
|
"--client=NewRegistrar",
|
||||||
|
@ -35,7 +35,7 @@ public class CreateHostCommandTest extends EppToolCommandTestCase<CreateHostComm
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_minimal() throws Exception {
|
void testSuccess_minimal() throws Exception {
|
||||||
// Test that each optional field can be omitted.
|
// Test that each optional field can be omitted.
|
||||||
runCommandForced(
|
runCommandForced(
|
||||||
"--client=NewRegistrar",
|
"--client=NewRegistrar",
|
||||||
|
@ -44,12 +44,12 @@ public class CreateHostCommandTest extends EppToolCommandTestCase<CreateHostComm
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_missingHost() {
|
void testFailure_missingHost() {
|
||||||
assertThrows(ParameterException.class, () -> runCommandForced("--client=NewRegistrar"));
|
assertThrows(ParameterException.class, () -> runCommandForced("--client=NewRegistrar"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_invalidIpAddress() {
|
void testFailure_invalidIpAddress() {
|
||||||
createTld("tld");
|
createTld("tld");
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
|
|
|
@ -28,11 +28,9 @@ import java.nio.charset.StandardCharsets;
|
||||||
import org.mockito.ArgumentCaptor;
|
import org.mockito.ArgumentCaptor;
|
||||||
import org.mockito.Captor;
|
import org.mockito.Captor;
|
||||||
|
|
||||||
/**
|
/** Base class for common testing setup for create and update commands for Premium Lists. */
|
||||||
* Base class for common testing setup for create and update commands for Premium Lists.
|
abstract class CreateOrUpdatePremiumListCommandTestCase<T extends CreateOrUpdatePremiumListCommand>
|
||||||
*/
|
extends CommandTestCase<T> {
|
||||||
public abstract class CreateOrUpdatePremiumListCommandTestCase<
|
|
||||||
T extends CreateOrUpdatePremiumListCommand> extends CommandTestCase<T> {
|
|
||||||
|
|
||||||
@Captor
|
@Captor
|
||||||
ArgumentCaptor<ImmutableMap<String, String>> urlParamCaptor;
|
ArgumentCaptor<ImmutableMap<String, String>> urlParamCaptor;
|
||||||
|
|
|
@ -32,25 +32,25 @@ import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import javax.persistence.EntityManager;
|
import javax.persistence.EntityManager;
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base class for common testing setup for create and update commands for Reserved Lists.
|
* Base class for common testing setup for create and update commands for Reserved Lists.
|
||||||
*
|
*
|
||||||
* @param <T> command type
|
* @param <T> command type
|
||||||
*/
|
*/
|
||||||
public abstract class CreateOrUpdateReservedListCommandTestCase<
|
abstract class CreateOrUpdateReservedListCommandTestCase<
|
||||||
T extends CreateOrUpdateReservedListCommand>
|
T extends CreateOrUpdateReservedListCommand>
|
||||||
extends CommandTestCase<T> {
|
extends CommandTestCase<T> {
|
||||||
|
|
||||||
String reservedTermsPath;
|
String reservedTermsPath;
|
||||||
String invalidReservedTermsPath;
|
private String invalidReservedTermsPath;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void init() throws IOException {
|
void beforeEachCreateOrUpdateReservedListCommandTestCase() throws IOException {
|
||||||
File reservedTermsFile = tmpDir.newFile("xn--q9jyb4c_common-reserved.txt");
|
File reservedTermsFile = tmpDir.resolve("xn--q9jyb4c_common-reserved.txt").toFile();
|
||||||
File invalidReservedTermsFile = tmpDir.newFile("reserved-terms-wontparse.csv");
|
File invalidReservedTermsFile = tmpDir.resolve("reserved-terms-wontparse.csv").toFile();
|
||||||
String reservedTermsCsv =
|
String reservedTermsCsv =
|
||||||
loadFile(CreateOrUpdateReservedListCommandTestCase.class, "example_reserved_terms.csv");
|
loadFile(CreateOrUpdateReservedListCommandTestCase.class, "example_reserved_terms.csv");
|
||||||
Files.asCharSink(reservedTermsFile, UTF_8).write(reservedTermsCsv);
|
Files.asCharSink(reservedTermsFile, UTF_8).write(reservedTermsCsv);
|
||||||
|
@ -61,7 +61,7 @@ public abstract class CreateOrUpdateReservedListCommandTestCase<
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_fileDoesntExist() {
|
void testFailure_fileDoesntExist() {
|
||||||
assertThat(
|
assertThat(
|
||||||
assertThrows(
|
assertThrows(
|
||||||
ParameterException.class,
|
ParameterException.class,
|
||||||
|
@ -74,7 +74,7 @@ public abstract class CreateOrUpdateReservedListCommandTestCase<
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_fileDoesntParse() {
|
void testFailure_fileDoesntParse() {
|
||||||
assertThat(
|
assertThat(
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
|
@ -87,7 +87,7 @@ public abstract class CreateOrUpdateReservedListCommandTestCase<
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_invalidLabel_includesFullDomainName() throws Exception {
|
void testFailure_invalidLabel_includesFullDomainName() throws Exception {
|
||||||
Files.asCharSink(new File(invalidReservedTermsPath), UTF_8)
|
Files.asCharSink(new File(invalidReservedTermsPath), UTF_8)
|
||||||
.write("example.tld,FULLY_BLOCKED\n\n");
|
.write("example.tld,FULLY_BLOCKED\n\n");
|
||||||
assertThat(
|
assertThat(
|
||||||
|
|
|
@ -29,23 +29,25 @@ import com.google.common.base.VerifyException;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.net.MediaType;
|
import com.google.common.net.MediaType;
|
||||||
import google.registry.tools.server.CreatePremiumListAction;
|
import google.registry.tools.server.CreatePremiumListAction;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.mockito.ArgumentMatchers;
|
import org.mockito.ArgumentMatchers;
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
|
import org.mockito.junit.jupiter.MockitoSettings;
|
||||||
|
import org.mockito.quality.Strictness;
|
||||||
|
|
||||||
/** Unit tests for {@link CreatePremiumListCommand}. */
|
/** Unit tests for {@link CreatePremiumListCommand}. */
|
||||||
public class CreatePremiumListCommandTest<C extends CreatePremiumListCommand>
|
class CreatePremiumListCommandTest<C extends CreatePremiumListCommand>
|
||||||
extends CreateOrUpdatePremiumListCommandTestCase<C> {
|
extends CreateOrUpdatePremiumListCommandTestCase<C> {
|
||||||
|
|
||||||
@Mock AppEngineConnection connection;
|
@Mock AppEngineConnection connection;
|
||||||
|
|
||||||
String premiumTermsPath;
|
private String premiumTermsPath;
|
||||||
String premiumTermsCsv;
|
String premiumTermsCsv;
|
||||||
String servletPath;
|
private String servletPath;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void init() throws Exception {
|
void beforeEach() throws Exception {
|
||||||
command.setConnection(connection);
|
command.setConnection(connection);
|
||||||
premiumTermsPath =
|
premiumTermsPath =
|
||||||
writeToNamedTmpFile(
|
writeToNamedTmpFile(
|
||||||
|
@ -61,7 +63,7 @@ public class CreatePremiumListCommandTest<C extends CreatePremiumListCommand>
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRun() throws Exception {
|
void testRun() throws Exception {
|
||||||
runCommandForced("-i=" + premiumTermsPath, "-n=foo");
|
runCommandForced("-i=" + premiumTermsPath, "-n=foo");
|
||||||
assertInStdout("Successfully");
|
assertInStdout("Successfully");
|
||||||
verifySentParams(
|
verifySentParams(
|
||||||
|
@ -71,7 +73,7 @@ public class CreatePremiumListCommandTest<C extends CreatePremiumListCommand>
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRun_noProvidedName_usesBasenameOfInputFile() throws Exception {
|
void testRun_noProvidedName_usesBasenameOfInputFile() throws Exception {
|
||||||
runCommandForced("-i=" + premiumTermsPath);
|
runCommandForced("-i=" + premiumTermsPath);
|
||||||
assertInStdout("Successfully");
|
assertInStdout("Successfully");
|
||||||
verifySentParams(
|
verifySentParams(
|
||||||
|
@ -82,7 +84,7 @@ public class CreatePremiumListCommandTest<C extends CreatePremiumListCommand>
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRun_errorResponse() throws Exception {
|
void testRun_errorResponse() throws Exception {
|
||||||
reset(connection);
|
reset(connection);
|
||||||
command.setConnection(connection);
|
command.setConnection(connection);
|
||||||
when(connection.sendPostRequest(
|
when(connection.sendPostRequest(
|
||||||
|
@ -95,13 +97,15 @@ public class CreatePremiumListCommandTest<C extends CreatePremiumListCommand>
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRun_noInputFileSpecified_throwsException() {
|
@MockitoSettings(strictness = Strictness.LENIENT)
|
||||||
|
void testRun_noInputFileSpecified_throwsException() {
|
||||||
ParameterException thrown = assertThrows(ParameterException.class, this::runCommand);
|
ParameterException thrown = assertThrows(ParameterException.class, this::runCommand);
|
||||||
assertThat(thrown).hasMessageThat().contains("The following option is required");
|
assertThat(thrown).hasMessageThat().contains("The following option is required");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRun_invalidInputData() throws Exception {
|
@MockitoSettings(strictness = Strictness.LENIENT)
|
||||||
|
void testRun_invalidInputData() throws Exception {
|
||||||
premiumTermsPath =
|
premiumTermsPath =
|
||||||
writeToNamedTmpFile(
|
writeToNamedTmpFile(
|
||||||
"tmp_file2",
|
"tmp_file2",
|
||||||
|
|
|
@ -26,7 +26,7 @@ import static org.joda.time.DateTimeZone.UTC;
|
||||||
import static org.junit.Assert.assertThrows;
|
import static org.junit.Assert.assertThrows;
|
||||||
import static org.mockito.ArgumentMatchers.eq;
|
import static org.mockito.ArgumentMatchers.eq;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.verifyZeroInteractions;
|
import static org.mockito.Mockito.verifyNoInteractions;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import com.beust.jcommander.ParameterException;
|
import com.beust.jcommander.ParameterException;
|
||||||
|
@ -39,23 +39,23 @@ import java.io.IOException;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import org.joda.money.CurrencyUnit;
|
import org.joda.money.CurrencyUnit;
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.mockito.ArgumentMatchers;
|
import org.mockito.ArgumentMatchers;
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
|
|
||||||
/** Unit tests for {@link CreateRegistrarCommand}. */
|
/** Unit tests for {@link CreateRegistrarCommand}. */
|
||||||
public class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarCommand> {
|
class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarCommand> {
|
||||||
|
|
||||||
@Mock private AppEngineConnection connection;
|
@Mock private AppEngineConnection connection;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void init() {
|
void beforeEach() {
|
||||||
command.setConnection(connection);
|
command.setConnection(connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess() throws Exception {
|
void testSuccess() throws Exception {
|
||||||
DateTime before = DateTime.now(UTC);
|
DateTime before = DateTime.now(UTC);
|
||||||
runCommandForced(
|
runCommandForced(
|
||||||
"--name=blobio",
|
"--name=blobio",
|
||||||
|
@ -102,7 +102,7 @@ public class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_alsoSaveToCloudSql() throws Exception {
|
void testSuccess_alsoSaveToCloudSql() throws Exception {
|
||||||
runCommandForced(
|
runCommandForced(
|
||||||
"--name=blobio",
|
"--name=blobio",
|
||||||
"--password=\"some_password\"",
|
"--password=\"some_password\"",
|
||||||
|
@ -124,7 +124,7 @@ public class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_quotedPassword() throws Exception {
|
void testSuccess_quotedPassword() throws Exception {
|
||||||
runCommandForced(
|
runCommandForced(
|
||||||
"--name=blobio",
|
"--name=blobio",
|
||||||
"--password=\"some_password\"",
|
"--password=\"some_password\"",
|
||||||
|
@ -145,7 +145,7 @@ public class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_registrarTypeFlag() throws Exception {
|
void testSuccess_registrarTypeFlag() throws Exception {
|
||||||
runCommandForced(
|
runCommandForced(
|
||||||
"--name=blobio",
|
"--name=blobio",
|
||||||
"--password=some_password",
|
"--password=some_password",
|
||||||
|
@ -165,7 +165,7 @@ public class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_registrarStateFlag() throws Exception {
|
void testSuccess_registrarStateFlag() throws Exception {
|
||||||
runCommandForced(
|
runCommandForced(
|
||||||
"--name=blobio",
|
"--name=blobio",
|
||||||
"--password=some_password",
|
"--password=some_password",
|
||||||
|
@ -187,7 +187,7 @@ public class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_allowedTldsInNonProductionEnvironment() throws Exception {
|
void testSuccess_allowedTldsInNonProductionEnvironment() throws Exception {
|
||||||
createTlds("xn--q9jyb4c", "foobar");
|
createTlds("xn--q9jyb4c", "foobar");
|
||||||
|
|
||||||
runCommandInEnvironment(
|
runCommandInEnvironment(
|
||||||
|
@ -214,7 +214,7 @@ public class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_allowedTldsInPDT() throws Exception {
|
void testSuccess_allowedTldsInPDT() throws Exception {
|
||||||
createTlds("xn--q9jyb4c", "foobar");
|
createTlds("xn--q9jyb4c", "foobar");
|
||||||
|
|
||||||
runCommandInEnvironment(
|
runCommandInEnvironment(
|
||||||
|
@ -241,7 +241,7 @@ public class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_groupCreationCanBeDisabled() throws Exception {
|
void testSuccess_groupCreationCanBeDisabled() throws Exception {
|
||||||
runCommandForced(
|
runCommandForced(
|
||||||
"--name=blobio",
|
"--name=blobio",
|
||||||
"--password=some_password",
|
"--password=some_password",
|
||||||
|
@ -256,11 +256,11 @@ public class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarC
|
||||||
"--cc US",
|
"--cc US",
|
||||||
"clientz");
|
"clientz");
|
||||||
|
|
||||||
verifyZeroInteractions(connection);
|
verifyNoInteractions(connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_groupCreationFails() throws Exception {
|
void testFailure_groupCreationFails() throws Exception {
|
||||||
when(connection.sendPostRequest(
|
when(connection.sendPostRequest(
|
||||||
ArgumentMatchers.anyString(),
|
ArgumentMatchers.anyString(),
|
||||||
ArgumentMatchers.anyMap(),
|
ArgumentMatchers.anyMap(),
|
||||||
|
@ -287,7 +287,7 @@ public class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_groupCreationDoesntOccurOnAlphaEnv() throws Exception {
|
void testSuccess_groupCreationDoesntOccurOnAlphaEnv() throws Exception {
|
||||||
runCommandInEnvironment(
|
runCommandInEnvironment(
|
||||||
RegistryToolEnvironment.ALPHA,
|
RegistryToolEnvironment.ALPHA,
|
||||||
"--name=blobio",
|
"--name=blobio",
|
||||||
|
@ -303,11 +303,11 @@ public class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarC
|
||||||
"--force",
|
"--force",
|
||||||
"clientz");
|
"clientz");
|
||||||
|
|
||||||
verifyZeroInteractions(connection);
|
verifyNoInteractions(connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_ipAllowListFlag() throws Exception {
|
void testSuccess_ipAllowListFlag() throws Exception {
|
||||||
runCommandForced(
|
runCommandForced(
|
||||||
"--name=blobio",
|
"--name=blobio",
|
||||||
"--password=some_password",
|
"--password=some_password",
|
||||||
|
@ -331,7 +331,7 @@ public class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_ipAllowListFlagNull() throws Exception {
|
void testSuccess_ipAllowListFlagNull() throws Exception {
|
||||||
runCommandForced(
|
runCommandForced(
|
||||||
"--name=blobio",
|
"--name=blobio",
|
||||||
"--password=some_password",
|
"--password=some_password",
|
||||||
|
@ -353,7 +353,7 @@ public class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_clientCertFileFlag() throws Exception {
|
void testSuccess_clientCertFileFlag() throws Exception {
|
||||||
runCommandForced(
|
runCommandForced(
|
||||||
"--name=blobio",
|
"--name=blobio",
|
||||||
"--password=some_password",
|
"--password=some_password",
|
||||||
|
@ -376,7 +376,7 @@ public class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_clientCertHashFlag() throws Exception {
|
void testSuccess_clientCertHashFlag() throws Exception {
|
||||||
runCommandForced(
|
runCommandForced(
|
||||||
"--name=blobio",
|
"--name=blobio",
|
||||||
"--password=some_password",
|
"--password=some_password",
|
||||||
|
@ -399,7 +399,7 @@ public class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_failoverClientCertFileFlag() throws Exception {
|
void testSuccess_failoverClientCertFileFlag() throws Exception {
|
||||||
runCommandForced(
|
runCommandForced(
|
||||||
"--name=blobio",
|
"--name=blobio",
|
||||||
"--password=some_password",
|
"--password=some_password",
|
||||||
|
@ -425,7 +425,7 @@ public class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_ianaId() throws Exception {
|
void testSuccess_ianaId() throws Exception {
|
||||||
runCommandForced(
|
runCommandForced(
|
||||||
"--name=blobio",
|
"--name=blobio",
|
||||||
"--password=some_password",
|
"--password=some_password",
|
||||||
|
@ -446,7 +446,7 @@ public class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_billingId() throws Exception {
|
void testSuccess_billingId() throws Exception {
|
||||||
runCommandForced(
|
runCommandForced(
|
||||||
"--name=blobio",
|
"--name=blobio",
|
||||||
"--password=some_password",
|
"--password=some_password",
|
||||||
|
@ -468,7 +468,7 @@ public class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_poNumber() throws Exception {
|
void testSuccess_poNumber() throws Exception {
|
||||||
runCommandForced(
|
runCommandForced(
|
||||||
"--name=blobio",
|
"--name=blobio",
|
||||||
"--password=some_password",
|
"--password=some_password",
|
||||||
|
@ -490,7 +490,7 @@ public class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_billingAccountMap() throws Exception {
|
void testSuccess_billingAccountMap() throws Exception {
|
||||||
runCommandForced(
|
runCommandForced(
|
||||||
"--name=blobio",
|
"--name=blobio",
|
||||||
"--password=some_password",
|
"--password=some_password",
|
||||||
|
@ -513,7 +513,7 @@ public class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_billingAccountMap_doesNotContainEntryForTldAllowed() {
|
void testFailure_billingAccountMap_doesNotContainEntryForTldAllowed() {
|
||||||
createTlds("foo");
|
createTlds("foo");
|
||||||
|
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
|
@ -541,7 +541,7 @@ public class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_billingAccountMap_onlyAppliesToRealRegistrar() throws Exception {
|
void testSuccess_billingAccountMap_onlyAppliesToRealRegistrar() throws Exception {
|
||||||
createTlds("foo");
|
createTlds("foo");
|
||||||
|
|
||||||
runCommandForced(
|
runCommandForced(
|
||||||
|
@ -565,7 +565,7 @@ public class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_streetAddress() throws Exception {
|
void testSuccess_streetAddress() throws Exception {
|
||||||
runCommandForced(
|
runCommandForced(
|
||||||
"--name=blobio",
|
"--name=blobio",
|
||||||
"--password=some_password",
|
"--password=some_password",
|
||||||
|
@ -597,7 +597,7 @@ public class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_email() throws Exception {
|
void testSuccess_email() throws Exception {
|
||||||
runCommandForced(
|
runCommandForced(
|
||||||
"--name=blobio",
|
"--name=blobio",
|
||||||
"--password=some_password",
|
"--password=some_password",
|
||||||
|
@ -619,7 +619,7 @@ public class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_fallBackToIcannReferralEmail() throws Exception {
|
void testSuccess_fallBackToIcannReferralEmail() throws Exception {
|
||||||
runCommandForced(
|
runCommandForced(
|
||||||
"--name=blobio",
|
"--name=blobio",
|
||||||
"--password=some_password",
|
"--password=some_password",
|
||||||
|
@ -640,7 +640,7 @@ public class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_url() throws Exception {
|
void testSuccess_url() throws Exception {
|
||||||
runCommandForced(
|
runCommandForced(
|
||||||
"--name=blobio",
|
"--name=blobio",
|
||||||
"--password=some_password",
|
"--password=some_password",
|
||||||
|
@ -662,7 +662,7 @@ public class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_phone() throws Exception {
|
void testSuccess_phone() throws Exception {
|
||||||
runCommandForced(
|
runCommandForced(
|
||||||
"--name=blobio",
|
"--name=blobio",
|
||||||
"--password=some_password",
|
"--password=some_password",
|
||||||
|
@ -684,7 +684,7 @@ public class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_optionalParamsAsNull() throws Exception {
|
void testSuccess_optionalParamsAsNull() throws Exception {
|
||||||
runCommandForced(
|
runCommandForced(
|
||||||
"--name=blobio",
|
"--name=blobio",
|
||||||
"--password=some_password",
|
"--password=some_password",
|
||||||
|
@ -715,7 +715,7 @@ public class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_optionalParamsAsEmptyString() throws Exception {
|
void testSuccess_optionalParamsAsEmptyString() throws Exception {
|
||||||
runCommandForced(
|
runCommandForced(
|
||||||
"--name=blobio",
|
"--name=blobio",
|
||||||
"--password=some_password",
|
"--password=some_password",
|
||||||
|
@ -746,7 +746,7 @@ public class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_blockPremiumNames() throws Exception {
|
void testSuccess_blockPremiumNames() throws Exception {
|
||||||
runCommandForced(
|
runCommandForced(
|
||||||
"--name=blobio",
|
"--name=blobio",
|
||||||
"--password=some_password",
|
"--password=some_password",
|
||||||
|
@ -768,7 +768,7 @@ public class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_noBlockPremiumNames() throws Exception {
|
void testSuccess_noBlockPremiumNames() throws Exception {
|
||||||
runCommandForced(
|
runCommandForced(
|
||||||
"--name=blobio",
|
"--name=blobio",
|
||||||
"--password=some_password",
|
"--password=some_password",
|
||||||
|
@ -790,7 +790,7 @@ public class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_registryLockAllowed() throws Exception {
|
void testSuccess_registryLockAllowed() throws Exception {
|
||||||
runCommandForced(
|
runCommandForced(
|
||||||
"--name=blobio",
|
"--name=blobio",
|
||||||
"--password=some_password",
|
"--password=some_password",
|
||||||
|
@ -812,7 +812,7 @@ public class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_registryLockDisallowed() throws Exception {
|
void testSuccess_registryLockDisallowed() throws Exception {
|
||||||
runCommandForced(
|
runCommandForced(
|
||||||
"--name=blobio",
|
"--name=blobio",
|
||||||
"--password=some_password",
|
"--password=some_password",
|
||||||
|
@ -834,7 +834,7 @@ public class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_badPhoneNumber() {
|
void testFailure_badPhoneNumber() {
|
||||||
ParameterException thrown =
|
ParameterException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
ParameterException.class,
|
ParameterException.class,
|
||||||
|
@ -857,7 +857,7 @@ public class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_badPhoneNumber2() {
|
void testFailure_badPhoneNumber2() {
|
||||||
ParameterException thrown =
|
ParameterException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
ParameterException.class,
|
ParameterException.class,
|
||||||
|
@ -880,7 +880,7 @@ public class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_fax() throws Exception {
|
void testSuccess_fax() throws Exception {
|
||||||
runCommandForced(
|
runCommandForced(
|
||||||
"--name=blobio",
|
"--name=blobio",
|
||||||
"--password=some_password",
|
"--password=some_password",
|
||||||
|
@ -902,7 +902,7 @@ public class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_missingRegistrarType() {
|
void testFailure_missingRegistrarType() {
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
|
@ -922,7 +922,7 @@ public class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_invalidRegistrarType() {
|
void testFailure_invalidRegistrarType() {
|
||||||
assertThrows(
|
assertThrows(
|
||||||
ParameterException.class,
|
ParameterException.class,
|
||||||
() ->
|
() ->
|
||||||
|
@ -940,7 +940,7 @@ public class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_invalidRegistrarState() {
|
void testFailure_invalidRegistrarState() {
|
||||||
assertThrows(
|
assertThrows(
|
||||||
ParameterException.class,
|
ParameterException.class,
|
||||||
() ->
|
() ->
|
||||||
|
@ -961,7 +961,7 @@ public class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_allowedTldDoesNotExist() {
|
void testFailure_allowedTldDoesNotExist() {
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
() ->
|
() ->
|
||||||
|
@ -982,7 +982,7 @@ public class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_allowedTldsInRealWithoutAbuseContact() {
|
void testFailure_allowedTldsInRealWithoutAbuseContact() {
|
||||||
createTlds("xn--q9jyb4c", "foobar");
|
createTlds("xn--q9jyb4c", "foobar");
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
|
@ -1008,7 +1008,7 @@ public class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_invalidIpAllowListFlag() {
|
void testFailure_invalidIpAllowListFlag() {
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
() ->
|
() ->
|
||||||
|
@ -1029,7 +1029,7 @@ public class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_ipAllowListFlagWithNull() {
|
void testSuccess_ipAllowListFlagWithNull() {
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
() ->
|
() ->
|
||||||
|
@ -1050,7 +1050,7 @@ public class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_invalidCertFileContents() {
|
void testFailure_invalidCertFileContents() {
|
||||||
assertThrows(
|
assertThrows(
|
||||||
Exception.class,
|
Exception.class,
|
||||||
() ->
|
() ->
|
||||||
|
@ -1071,7 +1071,7 @@ public class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_invalidFailoverCertFileContents() {
|
void testFailure_invalidFailoverCertFileContents() {
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
() ->
|
() ->
|
||||||
|
@ -1092,7 +1092,7 @@ public class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_certHashAndCertFile() {
|
void testFailure_certHashAndCertFile() {
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
() ->
|
() ->
|
||||||
|
@ -1114,7 +1114,7 @@ public class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_certHashNotBase64() {
|
void testFailure_certHashNotBase64() {
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
|
@ -1137,7 +1137,7 @@ public class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_certHashNotA256BitValue() {
|
void testFailure_certHashNotA256BitValue() {
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
|
@ -1160,7 +1160,7 @@ public class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_missingName() {
|
void testFailure_missingName() {
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
|
@ -1181,7 +1181,7 @@ public class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_missingPassword() {
|
void testFailure_missingPassword() {
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
|
@ -1202,7 +1202,7 @@ public class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_emptyPassword() {
|
void testFailure_emptyPassword() {
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
|
@ -1224,7 +1224,7 @@ public class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_clientIdTooShort() {
|
void testFailure_clientIdTooShort() {
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
() ->
|
() ->
|
||||||
|
@ -1244,7 +1244,7 @@ public class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_clientIdTooLong() {
|
void testFailure_clientIdTooLong() {
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
() ->
|
() ->
|
||||||
|
@ -1264,7 +1264,7 @@ public class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_missingClientId() {
|
void testFailure_missingClientId() {
|
||||||
assertThrows(
|
assertThrows(
|
||||||
ParameterException.class,
|
ParameterException.class,
|
||||||
() ->
|
() ->
|
||||||
|
@ -1284,7 +1284,7 @@ public class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_missingStreetLines() {
|
void testFailure_missingStreetLines() {
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
() ->
|
() ->
|
||||||
|
@ -1303,7 +1303,7 @@ public class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_missingCity() {
|
void testFailure_missingCity() {
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
() ->
|
() ->
|
||||||
|
@ -1324,7 +1324,7 @@ public class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_missingState() {
|
void testFailure_missingState() {
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
() ->
|
() ->
|
||||||
|
@ -1345,7 +1345,7 @@ public class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_missingZip() {
|
void testFailure_missingZip() {
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
() ->
|
() ->
|
||||||
|
@ -1366,7 +1366,7 @@ public class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_missingCc() {
|
void testFailure_missingCc() {
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
() ->
|
() ->
|
||||||
|
@ -1387,7 +1387,7 @@ public class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_invalidCc() {
|
void testFailure_invalidCc() {
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
() ->
|
() ->
|
||||||
|
@ -1409,7 +1409,7 @@ public class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_tooManyStreetLines() {
|
void testFailure_tooManyStreetLines() {
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
() ->
|
() ->
|
||||||
|
@ -1432,7 +1432,7 @@ public class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_tooFewStreetLines() {
|
void testFailure_tooFewStreetLines() {
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
() ->
|
() ->
|
||||||
|
@ -1452,7 +1452,7 @@ public class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_missingIanaIdForRealRegistrar() {
|
void testFailure_missingIanaIdForRealRegistrar() {
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
() ->
|
() ->
|
||||||
|
@ -1471,7 +1471,7 @@ public class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_negativeIanaId() {
|
void testFailure_negativeIanaId() {
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
() ->
|
() ->
|
||||||
|
@ -1491,7 +1491,7 @@ public class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_nonIntegerIanaId() {
|
void testFailure_nonIntegerIanaId() {
|
||||||
assertThrows(
|
assertThrows(
|
||||||
ParameterException.class,
|
ParameterException.class,
|
||||||
() ->
|
() ->
|
||||||
|
@ -1511,7 +1511,7 @@ public class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_negativeBillingId() {
|
void testFailure_negativeBillingId() {
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
() ->
|
() ->
|
||||||
|
@ -1532,7 +1532,7 @@ public class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_nonIntegerBillingId() {
|
void testFailure_nonIntegerBillingId() {
|
||||||
assertThrows(
|
assertThrows(
|
||||||
ParameterException.class,
|
ParameterException.class,
|
||||||
() ->
|
() ->
|
||||||
|
@ -1553,7 +1553,7 @@ public class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_missingPhonePasscode() {
|
void testFailure_missingPhonePasscode() {
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
() ->
|
() ->
|
||||||
|
@ -1572,7 +1572,7 @@ public class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_missingIcannReferralEmail() {
|
void testFailure_missingIcannReferralEmail() {
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
|
@ -1593,7 +1593,7 @@ public class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_passcodeTooShort() {
|
void testFailure_passcodeTooShort() {
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
() ->
|
() ->
|
||||||
|
@ -1613,7 +1613,7 @@ public class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_passcodeTooLong() {
|
void testFailure_passcodeTooLong() {
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
() ->
|
() ->
|
||||||
|
@ -1633,7 +1633,7 @@ public class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_invalidPasscode() {
|
void testFailure_invalidPasscode() {
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
() ->
|
() ->
|
||||||
|
@ -1653,7 +1653,7 @@ public class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_twoClientsSpecified() {
|
void testFailure_twoClientsSpecified() {
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
() ->
|
() ->
|
||||||
|
@ -1674,7 +1674,7 @@ public class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_unknownFlag() {
|
void testFailure_unknownFlag() {
|
||||||
assertThrows(
|
assertThrows(
|
||||||
ParameterException.class,
|
ParameterException.class,
|
||||||
() ->
|
() ->
|
||||||
|
@ -1695,7 +1695,7 @@ public class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_alreadyExists() {
|
void testFailure_alreadyExists() {
|
||||||
persistNewRegistrar("existing", "Existing Registrar", Registrar.Type.REAL, 1L);
|
persistNewRegistrar("existing", "Existing Registrar", Registrar.Type.REAL, 1L);
|
||||||
IllegalStateException thrown =
|
IllegalStateException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
|
@ -1718,7 +1718,7 @@ public class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_registrarNameSimilarToExisting() {
|
void testFailure_registrarNameSimilarToExisting() {
|
||||||
// Note that "tHeRe GiStRaR" normalizes identically to "The Registrar", which is created by
|
// Note that "tHeRe GiStRaR" normalizes identically to "The Registrar", which is created by
|
||||||
// AppEngineRule.
|
// AppEngineRule.
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
|
@ -1746,7 +1746,7 @@ public class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_clientIdNormalizesToExisting() {
|
void testFailure_clientIdNormalizesToExisting() {
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
|
@ -1772,7 +1772,7 @@ public class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_clientIdIsInvalidFormat() {
|
void testFailure_clientIdIsInvalidFormat() {
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
|
@ -1797,7 +1797,7 @@ public class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_phone() {
|
void testFailure_phone() {
|
||||||
assertThrows(
|
assertThrows(
|
||||||
ParameterException.class,
|
ParameterException.class,
|
||||||
() ->
|
() ->
|
||||||
|
@ -1818,7 +1818,7 @@ public class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_fax() {
|
void testFailure_fax() {
|
||||||
assertThrows(
|
assertThrows(
|
||||||
ParameterException.class,
|
ParameterException.class,
|
||||||
() ->
|
() ->
|
||||||
|
@ -1839,7 +1839,7 @@ public class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_badEmail() {
|
void testFailure_badEmail() {
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
|
|
|
@ -21,23 +21,22 @@ import static org.mockito.Mockito.verify;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.net.MediaType;
|
import com.google.common.net.MediaType;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
|
|
||||||
/** Unit tests for {@link CreateRegistrarGroupsCommand}. */
|
/** Unit tests for {@link CreateRegistrarGroupsCommand}. */
|
||||||
public class CreateRegistrarGroupsCommandTest extends
|
class CreateRegistrarGroupsCommandTest extends CommandTestCase<CreateRegistrarGroupsCommand> {
|
||||||
CommandTestCase<CreateRegistrarGroupsCommand> {
|
|
||||||
|
|
||||||
@Mock private AppEngineConnection connection;
|
@Mock private AppEngineConnection connection;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void init() {
|
void beforeEach() {
|
||||||
command.setConnection(connection);
|
command.setConnection(connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_createGroupsForTwoRegistrars() throws Exception {
|
void test_createGroupsForTwoRegistrars() throws Exception {
|
||||||
runCommandForced("NewRegistrar", "TheRegistrar");
|
runCommandForced("NewRegistrar", "TheRegistrar");
|
||||||
verify(connection)
|
verify(connection)
|
||||||
.sendPostRequest(
|
.sendPostRequest(
|
||||||
|
@ -55,7 +54,7 @@ public class CreateRegistrarGroupsCommandTest extends
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_throwsExceptionForNonExistentRegistrar() {
|
void test_throwsExceptionForNonExistentRegistrar() {
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
|
|
|
@ -30,20 +30,20 @@ import google.registry.model.registry.label.ReservedList;
|
||||||
import google.registry.model.registry.label.ReservedList.ReservedListEntry;
|
import google.registry.model.registry.label.ReservedList.ReservedListEntry;
|
||||||
import google.registry.model.registry.label.ReservedListSqlDao;
|
import google.registry.model.registry.label.ReservedListSqlDao;
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
/** Unit tests for {@link CreateReservedListCommand}. */
|
/** Unit tests for {@link CreateReservedListCommand}. */
|
||||||
public class CreateReservedListCommandTest extends
|
class CreateReservedListCommandTest
|
||||||
CreateOrUpdateReservedListCommandTestCase<CreateReservedListCommand> {
|
extends CreateOrUpdateReservedListCommandTestCase<CreateReservedListCommand> {
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void initTest() {
|
void beforeEach() {
|
||||||
createTlds("xn--q9jyb4c", "soy");
|
createTlds("xn--q9jyb4c", "soy");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess() throws Exception {
|
void testSuccess() throws Exception {
|
||||||
runCommandForced("--name=xn--q9jyb4c_common-reserved", "--input=" + reservedTermsPath);
|
runCommandForced("--name=xn--q9jyb4c_common-reserved", "--input=" + reservedTermsPath);
|
||||||
assertThat(ReservedList.get("xn--q9jyb4c_common-reserved")).isPresent();
|
assertThat(ReservedList.get("xn--q9jyb4c_common-reserved")).isPresent();
|
||||||
ReservedList reservedList = ReservedList.get("xn--q9jyb4c_common-reserved").get();
|
ReservedList reservedList = ReservedList.get("xn--q9jyb4c_common-reserved").get();
|
||||||
|
@ -53,13 +53,13 @@ public class CreateReservedListCommandTest extends
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_unspecifiedNameDefaultsToFileName() throws Exception {
|
void testSuccess_unspecifiedNameDefaultsToFileName() throws Exception {
|
||||||
runCommandForced("--input=" + reservedTermsPath);
|
runCommandForced("--input=" + reservedTermsPath);
|
||||||
assertThat(ReservedList.get("xn--q9jyb4c_common-reserved")).isPresent();
|
assertThat(ReservedList.get("xn--q9jyb4c_common-reserved")).isPresent();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_timestampsSetCorrectly() throws Exception {
|
void testSuccess_timestampsSetCorrectly() throws Exception {
|
||||||
DateTime before = DateTime.now(UTC);
|
DateTime before = DateTime.now(UTC);
|
||||||
runCommandForced("--input=" + reservedTermsPath);
|
runCommandForced("--input=" + reservedTermsPath);
|
||||||
assertThat(ReservedList.get("xn--q9jyb4c_common-reserved")).isPresent();
|
assertThat(ReservedList.get("xn--q9jyb4c_common-reserved")).isPresent();
|
||||||
|
@ -69,28 +69,28 @@ public class CreateReservedListCommandTest extends
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_shouldPublishDefaultsToTrue() throws Exception {
|
void testSuccess_shouldPublishDefaultsToTrue() throws Exception {
|
||||||
runCommandForced("--input=" + reservedTermsPath);
|
runCommandForced("--input=" + reservedTermsPath);
|
||||||
assertThat(ReservedList.get("xn--q9jyb4c_common-reserved")).isPresent();
|
assertThat(ReservedList.get("xn--q9jyb4c_common-reserved")).isPresent();
|
||||||
assertThat(ReservedList.get("xn--q9jyb4c_common-reserved").get().getShouldPublish()).isTrue();
|
assertThat(ReservedList.get("xn--q9jyb4c_common-reserved").get().getShouldPublish()).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_shouldPublishSetToTrue_works() throws Exception {
|
void testSuccess_shouldPublishSetToTrue_works() throws Exception {
|
||||||
runCommandForced("--input=" + reservedTermsPath, "--should_publish=true");
|
runCommandForced("--input=" + reservedTermsPath, "--should_publish=true");
|
||||||
assertThat(ReservedList.get("xn--q9jyb4c_common-reserved")).isPresent();
|
assertThat(ReservedList.get("xn--q9jyb4c_common-reserved")).isPresent();
|
||||||
assertThat(ReservedList.get("xn--q9jyb4c_common-reserved").get().getShouldPublish()).isTrue();
|
assertThat(ReservedList.get("xn--q9jyb4c_common-reserved").get().getShouldPublish()).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_shouldPublishSetToFalse_works() throws Exception {
|
void testSuccess_shouldPublishSetToFalse_works() throws Exception {
|
||||||
runCommandForced("--input=" + reservedTermsPath, "--should_publish=false");
|
runCommandForced("--input=" + reservedTermsPath, "--should_publish=false");
|
||||||
assertThat(ReservedList.get("xn--q9jyb4c_common-reserved")).isPresent();
|
assertThat(ReservedList.get("xn--q9jyb4c_common-reserved")).isPresent();
|
||||||
assertThat(ReservedList.get("xn--q9jyb4c_common-reserved").get().getShouldPublish()).isFalse();
|
assertThat(ReservedList.get("xn--q9jyb4c_common-reserved").get().getShouldPublish()).isFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_reservedListWithThatNameAlreadyExists() {
|
void testFailure_reservedListWithThatNameAlreadyExists() {
|
||||||
ReservedList rl = persistReservedList("xn--q9jyb4c_foo", "jones,FULLY_BLOCKED");
|
ReservedList rl = persistReservedList("xn--q9jyb4c_foo", "jones,FULLY_BLOCKED");
|
||||||
persistResource(Registry.get("xn--q9jyb4c").asBuilder().setReservedLists(rl).build());
|
persistResource(Registry.get("xn--q9jyb4c").asBuilder().setReservedLists(rl).build());
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
|
@ -101,90 +101,90 @@ public class CreateReservedListCommandTest extends
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNamingRules_commonReservedList() throws Exception {
|
void testNamingRules_commonReservedList() throws Exception {
|
||||||
runCommandForced("--name=common_abuse-list", "--input=" + reservedTermsPath);
|
runCommandForced("--name=common_abuse-list", "--input=" + reservedTermsPath);
|
||||||
assertThat(ReservedList.get("common_abuse-list")).isPresent();
|
assertThat(ReservedList.get("common_abuse-list")).isPresent();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNamingRules_tldThatDoesNotExist_succeedsWithOverride() throws Exception {
|
void testNamingRules_tldThatDoesNotExist_succeedsWithOverride() throws Exception {
|
||||||
runNameTestWithOverride("footld_reserved-list");
|
runNameTestWithOverride("footld_reserved-list");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNamingRules_tldThatDoesNotExist_failsWithoutOverride() {
|
void testNamingRules_tldThatDoesNotExist_failsWithoutOverride() {
|
||||||
runNameTestExpectedFailure("footld_reserved-list", "TLD footld does not exist");
|
runNameTestExpectedFailure("footld_reserved-list", "TLD footld does not exist");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNamingRules_underscoreIsMissing_succeedsWithOverride() throws Exception {
|
void testNamingRules_underscoreIsMissing_succeedsWithOverride() throws Exception {
|
||||||
runNameTestWithOverride("random-reserved-list");
|
runNameTestWithOverride("random-reserved-list");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNamingRules_underscoreIsMissing_failsWithoutOverride() {
|
void testNamingRules_underscoreIsMissing_failsWithoutOverride() {
|
||||||
runNameTestExpectedFailure("random-reserved-list", INVALID_FORMAT_ERROR_MESSAGE);
|
runNameTestExpectedFailure("random-reserved-list", INVALID_FORMAT_ERROR_MESSAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNamingRules_secondHalfOfNameIsMissing_succeedsWithOverride() throws Exception {
|
void testNamingRules_secondHalfOfNameIsMissing_succeedsWithOverride() throws Exception {
|
||||||
runNameTestWithOverride("soy_");
|
runNameTestWithOverride("soy_");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNamingRules_secondHalfOfNameIsMissing_failsWithoutOverride() {
|
void testNamingRules_secondHalfOfNameIsMissing_failsWithoutOverride() {
|
||||||
runNameTestExpectedFailure("soy_", INVALID_FORMAT_ERROR_MESSAGE);
|
runNameTestExpectedFailure("soy_", INVALID_FORMAT_ERROR_MESSAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNamingRules_onlyTldIsSpecifiedAsName_succeedsWithOverride() throws Exception {
|
void testNamingRules_onlyTldIsSpecifiedAsName_succeedsWithOverride() throws Exception {
|
||||||
runNameTestWithOverride("soy");
|
runNameTestWithOverride("soy");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNamingRules_onlyTldIsSpecifiedAsName_failsWithoutOverride() {
|
void testNamingRules_onlyTldIsSpecifiedAsName_failsWithoutOverride() {
|
||||||
runNameTestExpectedFailure("soy", INVALID_FORMAT_ERROR_MESSAGE);
|
runNameTestExpectedFailure("soy", INVALID_FORMAT_ERROR_MESSAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNamingRules_commonAsListName_succeedsWithOverride() throws Exception {
|
void testNamingRules_commonAsListName_succeedsWithOverride() throws Exception {
|
||||||
runNameTestWithOverride("invalidtld_common");
|
runNameTestWithOverride("invalidtld_common");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNamingRules_commonAsListName_failsWithoutOverride() {
|
void testNamingRules_commonAsListName_failsWithoutOverride() {
|
||||||
runNameTestExpectedFailure("invalidtld_common", "TLD invalidtld does not exist");
|
runNameTestExpectedFailure("invalidtld_common", "TLD invalidtld does not exist");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNamingRules_too_many_underscores_succeedsWithOverride() throws Exception {
|
void testNamingRules_too_many_underscores_succeedsWithOverride() throws Exception {
|
||||||
runNameTestWithOverride("soy_buffalo_buffalo_buffalo");
|
runNameTestWithOverride("soy_buffalo_buffalo_buffalo");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNamingRules_too_many_underscores_failsWithoutOverride() {
|
void testNamingRules_too_many_underscores_failsWithoutOverride() {
|
||||||
runNameTestExpectedFailure("soy_buffalo_buffalo_buffalo", INVALID_FORMAT_ERROR_MESSAGE);
|
runNameTestExpectedFailure("soy_buffalo_buffalo_buffalo", INVALID_FORMAT_ERROR_MESSAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNamingRules_withWeirdCharacters_succeedsWithOverride() throws Exception {
|
void testNamingRules_withWeirdCharacters_succeedsWithOverride() throws Exception {
|
||||||
runNameTestWithOverride("soy_$oy");
|
runNameTestWithOverride("soy_$oy");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNamingRules_withWeirdCharacters_failsWithoutOverride() {
|
void testNamingRules_withWeirdCharacters_failsWithoutOverride() {
|
||||||
runNameTestExpectedFailure("soy_$oy", INVALID_FORMAT_ERROR_MESSAGE);
|
runNameTestExpectedFailure("soy_$oy", INVALID_FORMAT_ERROR_MESSAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSaveToCloudSql_succeeds() throws Exception {
|
void testSaveToCloudSql_succeeds() throws Exception {
|
||||||
runCommandForced("--name=xn--q9jyb4c_common-reserved", "--input=" + reservedTermsPath);
|
runCommandForced("--name=xn--q9jyb4c_common-reserved", "--input=" + reservedTermsPath);
|
||||||
verifyXnq9jyb4cInDatastore();
|
verifyXnq9jyb4cInDatastore();
|
||||||
verifyXnq9jyb4cInCloudSql();
|
verifyXnq9jyb4cInCloudSql();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSaveToCloudSql_noExceptionThrownWhenSaveFail() throws Exception {
|
void testSaveToCloudSql_noExceptionThrownWhenSaveFail() throws Exception {
|
||||||
// Note that, during the dual-write phase, we want to make sure that no exception will be
|
// Note that, during the dual-write phase, we want to make sure that no exception will be
|
||||||
// thrown if saving reserved list to Cloud SQL fails.
|
// thrown if saving reserved list to Cloud SQL fails.
|
||||||
ReservedListSqlDao.save(
|
ReservedListSqlDao.save(
|
||||||
|
|
|
@ -38,14 +38,14 @@ import java.math.BigDecimal;
|
||||||
import org.joda.money.Money;
|
import org.joda.money.Money;
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
import org.joda.time.Duration;
|
import org.joda.time.Duration;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
/** Unit tests for {@link CreateTldCommand}. */
|
/** Unit tests for {@link CreateTldCommand}. */
|
||||||
public class CreateTldCommandTest extends CommandTestCase<CreateTldCommand> {
|
class CreateTldCommandTest extends CommandTestCase<CreateTldCommand> {
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void init() {
|
void beforeEach() {
|
||||||
persistReservedList("common_abuse", "baa,FULLY_BLOCKED");
|
persistReservedList("common_abuse", "baa,FULLY_BLOCKED");
|
||||||
persistReservedList("xn--q9jyb4c_abuse", "lamb,FULLY_BLOCKED");
|
persistReservedList("xn--q9jyb4c_abuse", "lamb,FULLY_BLOCKED");
|
||||||
persistReservedList("tld_banned", "kilo,FULLY_BLOCKED", "lima,FULLY_BLOCKED");
|
persistReservedList("tld_banned", "kilo,FULLY_BLOCKED", "lima,FULLY_BLOCKED");
|
||||||
|
@ -55,7 +55,7 @@ public class CreateTldCommandTest extends CommandTestCase<CreateTldCommand> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess() throws Exception {
|
void testSuccess() throws Exception {
|
||||||
DateTime before = DateTime.now(UTC);
|
DateTime before = DateTime.now(UTC);
|
||||||
runCommandForced("xn--q9jyb4c", "--roid_suffix=Q9JYB4C", "--dns_writers=FooDnsWriter");
|
runCommandForced("xn--q9jyb4c", "--roid_suffix=Q9JYB4C", "--dns_writers=FooDnsWriter");
|
||||||
DateTime after = DateTime.now(UTC);
|
DateTime after = DateTime.now(UTC);
|
||||||
|
@ -72,7 +72,7 @@ public class CreateTldCommandTest extends CommandTestCase<CreateTldCommand> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_multipleArguments() {
|
void testFailure_multipleArguments() {
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
|
@ -83,7 +83,7 @@ public class CreateTldCommandTest extends CommandTestCase<CreateTldCommand> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_multipleDuplicateArguments() {
|
void testFailure_multipleDuplicateArguments() {
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
|
@ -94,7 +94,7 @@ public class CreateTldCommandTest extends CommandTestCase<CreateTldCommand> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_initialTldStateFlag() throws Exception {
|
void testSuccess_initialTldStateFlag() throws Exception {
|
||||||
runCommandForced(
|
runCommandForced(
|
||||||
"--initial_tld_state=GENERAL_AVAILABILITY",
|
"--initial_tld_state=GENERAL_AVAILABILITY",
|
||||||
"--roid_suffix=Q9JYB4C",
|
"--roid_suffix=Q9JYB4C",
|
||||||
|
@ -105,7 +105,7 @@ public class CreateTldCommandTest extends CommandTestCase<CreateTldCommand> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_initialRenewBillingCostFlag() throws Exception {
|
void testSuccess_initialRenewBillingCostFlag() throws Exception {
|
||||||
runCommandForced(
|
runCommandForced(
|
||||||
"--initial_renew_billing_cost=\"USD 42.42\"",
|
"--initial_renew_billing_cost=\"USD 42.42\"",
|
||||||
"--roid_suffix=Q9JYB4C",
|
"--roid_suffix=Q9JYB4C",
|
||||||
|
@ -116,7 +116,7 @@ public class CreateTldCommandTest extends CommandTestCase<CreateTldCommand> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_eapFeeSchedule() throws Exception {
|
void testSuccess_eapFeeSchedule() throws Exception {
|
||||||
DateTime now = DateTime.now(UTC);
|
DateTime now = DateTime.now(UTC);
|
||||||
DateTime tomorrow = now.plusDays(1);
|
DateTime tomorrow = now.plusDays(1);
|
||||||
runCommandForced(
|
runCommandForced(
|
||||||
|
@ -137,7 +137,7 @@ public class CreateTldCommandTest extends CommandTestCase<CreateTldCommand> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_addGracePeriodFlag() throws Exception {
|
void testSuccess_addGracePeriodFlag() throws Exception {
|
||||||
runCommandForced(
|
runCommandForced(
|
||||||
"--add_grace_period=PT300S",
|
"--add_grace_period=PT300S",
|
||||||
"--roid_suffix=Q9JYB4C",
|
"--roid_suffix=Q9JYB4C",
|
||||||
|
@ -147,27 +147,27 @@ public class CreateTldCommandTest extends CommandTestCase<CreateTldCommand> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_roidSuffixWorks() throws Exception {
|
void testSuccess_roidSuffixWorks() throws Exception {
|
||||||
runCommandForced("--roid_suffix=RSUFFIX", "--dns_writers=VoidDnsWriter", "tld");
|
runCommandForced("--roid_suffix=RSUFFIX", "--dns_writers=VoidDnsWriter", "tld");
|
||||||
assertThat(Registry.get("tld").getRoidSuffix()).isEqualTo("RSUFFIX");
|
assertThat(Registry.get("tld").getRoidSuffix()).isEqualTo("RSUFFIX");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_escrow() throws Exception {
|
void testSuccess_escrow() throws Exception {
|
||||||
runCommandForced(
|
runCommandForced(
|
||||||
"--escrow=true", "--roid_suffix=Q9JYB4C", "--dns_writers=VoidDnsWriter", "xn--q9jyb4c");
|
"--escrow=true", "--roid_suffix=Q9JYB4C", "--dns_writers=VoidDnsWriter", "xn--q9jyb4c");
|
||||||
assertThat(Registry.get("xn--q9jyb4c").getEscrowEnabled()).isTrue();
|
assertThat(Registry.get("xn--q9jyb4c").getEscrowEnabled()).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_noEscrow() throws Exception {
|
void testSuccess_noEscrow() throws Exception {
|
||||||
runCommandForced(
|
runCommandForced(
|
||||||
"--escrow=false", "--roid_suffix=Q9JYB4C", "--dns_writers=VoidDnsWriter", "xn--q9jyb4c");
|
"--escrow=false", "--roid_suffix=Q9JYB4C", "--dns_writers=VoidDnsWriter", "xn--q9jyb4c");
|
||||||
assertThat(Registry.get("xn--q9jyb4c").getEscrowEnabled()).isFalse();
|
assertThat(Registry.get("xn--q9jyb4c").getEscrowEnabled()).isFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_redemptionGracePeriodFlag() throws Exception {
|
void testSuccess_redemptionGracePeriodFlag() throws Exception {
|
||||||
runCommandForced(
|
runCommandForced(
|
||||||
"--redemption_grace_period=PT300S",
|
"--redemption_grace_period=PT300S",
|
||||||
"--roid_suffix=Q9JYB4C",
|
"--roid_suffix=Q9JYB4C",
|
||||||
|
@ -178,7 +178,7 @@ public class CreateTldCommandTest extends CommandTestCase<CreateTldCommand> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_pendingDeleteLengthFlag() throws Exception {
|
void testSuccess_pendingDeleteLengthFlag() throws Exception {
|
||||||
runCommandForced(
|
runCommandForced(
|
||||||
"--pending_delete_length=PT300S",
|
"--pending_delete_length=PT300S",
|
||||||
"--roid_suffix=Q9JYB4C",
|
"--roid_suffix=Q9JYB4C",
|
||||||
|
@ -188,7 +188,7 @@ public class CreateTldCommandTest extends CommandTestCase<CreateTldCommand> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_automaticTransferLengthFlag() throws Exception {
|
void testSuccess_automaticTransferLengthFlag() throws Exception {
|
||||||
runCommandForced(
|
runCommandForced(
|
||||||
"--automatic_transfer_length=PT300S",
|
"--automatic_transfer_length=PT300S",
|
||||||
"--roid_suffix=Q9JYB4C",
|
"--roid_suffix=Q9JYB4C",
|
||||||
|
@ -199,7 +199,7 @@ public class CreateTldCommandTest extends CommandTestCase<CreateTldCommand> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_createBillingCostFlag() throws Exception {
|
void testSuccess_createBillingCostFlag() throws Exception {
|
||||||
runCommandForced(
|
runCommandForced(
|
||||||
"--create_billing_cost=\"USD 42.42\"",
|
"--create_billing_cost=\"USD 42.42\"",
|
||||||
"--roid_suffix=Q9JYB4C",
|
"--roid_suffix=Q9JYB4C",
|
||||||
|
@ -209,7 +209,7 @@ public class CreateTldCommandTest extends CommandTestCase<CreateTldCommand> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_restoreBillingCostFlag() throws Exception {
|
void testSuccess_restoreBillingCostFlag() throws Exception {
|
||||||
runCommandForced(
|
runCommandForced(
|
||||||
"--restore_billing_cost=\"USD 42.42\"",
|
"--restore_billing_cost=\"USD 42.42\"",
|
||||||
"--roid_suffix=Q9JYB4C",
|
"--roid_suffix=Q9JYB4C",
|
||||||
|
@ -220,7 +220,7 @@ public class CreateTldCommandTest extends CommandTestCase<CreateTldCommand> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_serverStatusChangeCostFlag() throws Exception {
|
void testSuccess_serverStatusChangeCostFlag() throws Exception {
|
||||||
runCommandForced(
|
runCommandForced(
|
||||||
"--server_status_change_cost=\"USD 42.42\"",
|
"--server_status_change_cost=\"USD 42.42\"",
|
||||||
"--roid_suffix=Q9JYB4C",
|
"--roid_suffix=Q9JYB4C",
|
||||||
|
@ -231,7 +231,7 @@ public class CreateTldCommandTest extends CommandTestCase<CreateTldCommand> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_nonUsdBillingCostFlag() throws Exception {
|
void testSuccess_nonUsdBillingCostFlag() throws Exception {
|
||||||
runCommandForced(
|
runCommandForced(
|
||||||
"--create_billing_cost=\"JPY 12345\"",
|
"--create_billing_cost=\"JPY 12345\"",
|
||||||
"--restore_billing_cost=\"JPY 67890\"",
|
"--restore_billing_cost=\"JPY 67890\"",
|
||||||
|
@ -247,7 +247,7 @@ public class CreateTldCommandTest extends CommandTestCase<CreateTldCommand> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_multipartTld() throws Exception {
|
void testSuccess_multipartTld() throws Exception {
|
||||||
runCommandForced("co.uk", "--roid_suffix=COUK", "--dns_writers=VoidDnsWriter");
|
runCommandForced("co.uk", "--roid_suffix=COUK", "--dns_writers=VoidDnsWriter");
|
||||||
|
|
||||||
Registry registry = Registry.get("co.uk");
|
Registry registry = Registry.get("co.uk");
|
||||||
|
@ -259,7 +259,7 @@ public class CreateTldCommandTest extends CommandTestCase<CreateTldCommand> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_setReservedLists() throws Exception {
|
void testSuccess_setReservedLists() throws Exception {
|
||||||
runCommandForced(
|
runCommandForced(
|
||||||
"--reserved_lists=xn--q9jyb4c_abuse,common_abuse",
|
"--reserved_lists=xn--q9jyb4c_abuse,common_abuse",
|
||||||
"--roid_suffix=Q9JYB4C",
|
"--roid_suffix=Q9JYB4C",
|
||||||
|
@ -270,7 +270,7 @@ public class CreateTldCommandTest extends CommandTestCase<CreateTldCommand> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_invalidAddGracePeriod() {
|
void testFailure_invalidAddGracePeriod() {
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
|
@ -284,7 +284,7 @@ public class CreateTldCommandTest extends CommandTestCase<CreateTldCommand> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_invalidRedemptionGracePeriod() {
|
void testFailure_invalidRedemptionGracePeriod() {
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
|
@ -298,7 +298,7 @@ public class CreateTldCommandTest extends CommandTestCase<CreateTldCommand> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_invalidPendingDeleteLength() {
|
void testFailure_invalidPendingDeleteLength() {
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
|
@ -312,7 +312,7 @@ public class CreateTldCommandTest extends CommandTestCase<CreateTldCommand> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_invalidTldState() {
|
void testFailure_invalidTldState() {
|
||||||
ParameterException thrown =
|
ParameterException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
ParameterException.class,
|
ParameterException.class,
|
||||||
|
@ -326,7 +326,7 @@ public class CreateTldCommandTest extends CommandTestCase<CreateTldCommand> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_bothTldStateFlags() {
|
void testFailure_bothTldStateFlags() {
|
||||||
DateTime now = DateTime.now(UTC);
|
DateTime now = DateTime.now(UTC);
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
|
@ -345,7 +345,7 @@ public class CreateTldCommandTest extends CommandTestCase<CreateTldCommand> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_negativeInitialRenewBillingCost() {
|
void testFailure_negativeInitialRenewBillingCost() {
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
|
@ -359,7 +359,7 @@ public class CreateTldCommandTest extends CommandTestCase<CreateTldCommand> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_invalidEapCurrency() {
|
void testFailure_invalidEapCurrency() {
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
|
@ -373,7 +373,7 @@ public class CreateTldCommandTest extends CommandTestCase<CreateTldCommand> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_noTldName() {
|
void testFailure_noTldName() {
|
||||||
ParameterException thrown = assertThrows(ParameterException.class, this::runCommandForced);
|
ParameterException thrown = assertThrows(ParameterException.class, this::runCommandForced);
|
||||||
assertThat(thrown)
|
assertThat(thrown)
|
||||||
.hasMessageThat()
|
.hasMessageThat()
|
||||||
|
@ -381,7 +381,7 @@ public class CreateTldCommandTest extends CommandTestCase<CreateTldCommand> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_noDnsWriter() {
|
void testFailure_noDnsWriter() {
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
|
@ -390,7 +390,7 @@ public class CreateTldCommandTest extends CommandTestCase<CreateTldCommand> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_alreadyExists() {
|
void testFailure_alreadyExists() {
|
||||||
createTld("xn--q9jyb4c");
|
createTld("xn--q9jyb4c");
|
||||||
IllegalStateException thrown =
|
IllegalStateException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
|
@ -402,7 +402,7 @@ public class CreateTldCommandTest extends CommandTestCase<CreateTldCommand> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_tldStartsWithDigit() {
|
void testFailure_tldStartsWithDigit() {
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
|
@ -411,7 +411,7 @@ public class CreateTldCommandTest extends CommandTestCase<CreateTldCommand> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_setAllowedRegistrants() throws Exception {
|
void testSuccess_setAllowedRegistrants() throws Exception {
|
||||||
runCommandForced(
|
runCommandForced(
|
||||||
"--allowed_registrants=alice,bob",
|
"--allowed_registrants=alice,bob",
|
||||||
"--roid_suffix=Q9JYB4C",
|
"--roid_suffix=Q9JYB4C",
|
||||||
|
@ -422,7 +422,7 @@ public class CreateTldCommandTest extends CommandTestCase<CreateTldCommand> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_setAllowedNameservers() throws Exception {
|
void testSuccess_setAllowedNameservers() throws Exception {
|
||||||
runCommandForced(
|
runCommandForced(
|
||||||
"--allowed_nameservers=ns1.example.com,ns2.example.com",
|
"--allowed_nameservers=ns1.example.com,ns2.example.com",
|
||||||
"--roid_suffix=Q9JYB4C",
|
"--roid_suffix=Q9JYB4C",
|
||||||
|
@ -433,22 +433,22 @@ public class CreateTldCommandTest extends CommandTestCase<CreateTldCommand> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_setCommonReservedListOnTld() throws Exception {
|
void testSuccess_setCommonReservedListOnTld() throws Exception {
|
||||||
runSuccessfulReservedListsTest("common_abuse");
|
runSuccessfulReservedListsTest("common_abuse");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_setTldSpecificReservedListOnTld() throws Exception {
|
void testSuccess_setTldSpecificReservedListOnTld() throws Exception {
|
||||||
runSuccessfulReservedListsTest("xn--q9jyb4c_abuse");
|
runSuccessfulReservedListsTest("xn--q9jyb4c_abuse");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_setCommonReservedListAndTldSpecificReservedListOnTld() throws Exception {
|
void testSuccess_setCommonReservedListAndTldSpecificReservedListOnTld() throws Exception {
|
||||||
runSuccessfulReservedListsTest("common_abuse,xn--q9jyb4c_abuse");
|
runSuccessfulReservedListsTest("common_abuse,xn--q9jyb4c_abuse");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_setReservedListFromOtherTld() {
|
void testFailure_setReservedListFromOtherTld() {
|
||||||
runFailureReservedListsTest(
|
runFailureReservedListsTest(
|
||||||
"tld_banned",
|
"tld_banned",
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
|
@ -456,12 +456,12 @@ public class CreateTldCommandTest extends CommandTestCase<CreateTldCommand> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_setReservedListFromOtherTld_withOverride() throws Exception {
|
void testSuccess_setReservedListFromOtherTld_withOverride() throws Exception {
|
||||||
runReservedListsTestOverride("tld_banned");
|
runReservedListsTestOverride("tld_banned");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_setCommonAndReservedListFromOtherTld() {
|
void testFailure_setCommonAndReservedListFromOtherTld() {
|
||||||
runFailureReservedListsTest(
|
runFailureReservedListsTest(
|
||||||
"common_abuse,tld_banned",
|
"common_abuse,tld_banned",
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
|
@ -469,7 +469,7 @@ public class CreateTldCommandTest extends CommandTestCase<CreateTldCommand> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_setCommonAndReservedListFromOtherTld_withOverride() throws Exception {
|
void testSuccess_setCommonAndReservedListFromOtherTld_withOverride() throws Exception {
|
||||||
runReservedListsTestOverride("common_abuse,tld_banned");
|
runReservedListsTestOverride("common_abuse,tld_banned");
|
||||||
String errMsg =
|
String errMsg =
|
||||||
"Error overridden: The reserved list(s) tld_banned "
|
"Error overridden: The reserved list(s) tld_banned "
|
||||||
|
@ -478,7 +478,7 @@ public class CreateTldCommandTest extends CommandTestCase<CreateTldCommand> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_setMultipleReservedListsFromOtherTld() {
|
void testFailure_setMultipleReservedListsFromOtherTld() {
|
||||||
runFailureReservedListsTest(
|
runFailureReservedListsTest(
|
||||||
"tld_banned,soy_expurgated",
|
"tld_banned,soy_expurgated",
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
|
@ -486,12 +486,12 @@ public class CreateTldCommandTest extends CommandTestCase<CreateTldCommand> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_setMultipleReservedListsFromOtherTld_withOverride() throws Exception {
|
void testSuccess_setMultipleReservedListsFromOtherTld_withOverride() throws Exception {
|
||||||
runReservedListsTestOverride("tld_banned,soy_expurgated");
|
runReservedListsTestOverride("tld_banned,soy_expurgated");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_setNonExistentReservedLists() {
|
void testFailure_setNonExistentReservedLists() {
|
||||||
runFailureReservedListsTest(
|
runFailureReservedListsTest(
|
||||||
"xn--q9jyb4c_asdf,common_asdsdgh",
|
"xn--q9jyb4c_asdf,common_asdsdgh",
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
|
@ -499,7 +499,7 @@ public class CreateTldCommandTest extends CommandTestCase<CreateTldCommand> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_setPremiumList() throws Exception {
|
void testSuccess_setPremiumList() throws Exception {
|
||||||
runCommandForced(
|
runCommandForced(
|
||||||
"--premium_list=xn--q9jyb4c",
|
"--premium_list=xn--q9jyb4c",
|
||||||
"--roid_suffix=Q9JYB4C",
|
"--roid_suffix=Q9JYB4C",
|
||||||
|
@ -509,7 +509,7 @@ public class CreateTldCommandTest extends CommandTestCase<CreateTldCommand> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_setDriveFolderIdToValue() throws Exception {
|
void testSuccess_setDriveFolderIdToValue() throws Exception {
|
||||||
runCommandForced(
|
runCommandForced(
|
||||||
"--drive_folder_id=madmax2030",
|
"--drive_folder_id=madmax2030",
|
||||||
"--roid_suffix=Q9JYB4C",
|
"--roid_suffix=Q9JYB4C",
|
||||||
|
@ -519,7 +519,7 @@ public class CreateTldCommandTest extends CommandTestCase<CreateTldCommand> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_setDriveFolderIdToNull() throws Exception {
|
void testSuccess_setDriveFolderIdToNull() throws Exception {
|
||||||
runCommandForced(
|
runCommandForced(
|
||||||
"--drive_folder_id=null",
|
"--drive_folder_id=null",
|
||||||
"--roid_suffix=Q9JYB4C",
|
"--roid_suffix=Q9JYB4C",
|
||||||
|
@ -529,7 +529,7 @@ public class CreateTldCommandTest extends CommandTestCase<CreateTldCommand> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_setPremiumListThatDoesntExist() {
|
void testFailure_setPremiumListThatDoesntExist() {
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
|
@ -543,7 +543,7 @@ public class CreateTldCommandTest extends CommandTestCase<CreateTldCommand> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_specifiedDnsWriters_dontExist() {
|
void testFailure_specifiedDnsWriters_dontExist() {
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
|
|
|
@ -29,19 +29,22 @@ import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.net.MediaType;
|
import com.google.common.net.MediaType;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.mockito.ArgumentCaptor;
|
import org.mockito.ArgumentCaptor;
|
||||||
import org.mockito.Captor;
|
import org.mockito.Captor;
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
|
import org.mockito.junit.jupiter.MockitoSettings;
|
||||||
|
import org.mockito.quality.Strictness;
|
||||||
|
|
||||||
/** Unit tests for {@link CurlCommand}. */
|
/** Unit tests for {@link CurlCommand}. */
|
||||||
public class CurlCommandTest extends CommandTestCase<CurlCommand> {
|
class CurlCommandTest extends CommandTestCase<CurlCommand> {
|
||||||
|
|
||||||
@Mock private AppEngineConnection connection;
|
@Mock private AppEngineConnection connection;
|
||||||
@Mock private AppEngineConnection connectionForService;
|
@Mock private AppEngineConnection connectionForService;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void init() {
|
void beforeEach() {
|
||||||
command.setConnection(connection);
|
command.setConnection(connection);
|
||||||
when(connection.withService(any())).thenReturn(connectionForService);
|
when(connection.withService(any())).thenReturn(connectionForService);
|
||||||
}
|
}
|
||||||
|
@ -49,7 +52,7 @@ public class CurlCommandTest extends CommandTestCase<CurlCommand> {
|
||||||
@Captor ArgumentCaptor<ImmutableMap<String, String>> urlParamCaptor;
|
@Captor ArgumentCaptor<ImmutableMap<String, String>> urlParamCaptor;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetInvocation() throws Exception {
|
void testGetInvocation() throws Exception {
|
||||||
runCommand("--path=/foo/bar?a=1&b=2", "--service=TOOLS");
|
runCommand("--path=/foo/bar?a=1&b=2", "--service=TOOLS");
|
||||||
verify(connection).withService(TOOLS);
|
verify(connection).withService(TOOLS);
|
||||||
verifyNoMoreInteractions(connection);
|
verifyNoMoreInteractions(connection);
|
||||||
|
@ -58,7 +61,7 @@ public class CurlCommandTest extends CommandTestCase<CurlCommand> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testExplicitGetInvocation() throws Exception {
|
void testExplicitGetInvocation() throws Exception {
|
||||||
runCommand("--path=/foo/bar?a=1&b=2", "--request=GET", "--service=BACKEND");
|
runCommand("--path=/foo/bar?a=1&b=2", "--request=GET", "--service=BACKEND");
|
||||||
verify(connection).withService(BACKEND);
|
verify(connection).withService(BACKEND);
|
||||||
verifyNoMoreInteractions(connection);
|
verifyNoMoreInteractions(connection);
|
||||||
|
@ -67,7 +70,7 @@ public class CurlCommandTest extends CommandTestCase<CurlCommand> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPostInvocation() throws Exception {
|
void testPostInvocation() throws Exception {
|
||||||
runCommand("--path=/foo/bar?a=1&b=2", "--data=some data", "--service=DEFAULT");
|
runCommand("--path=/foo/bar?a=1&b=2", "--data=some data", "--service=DEFAULT");
|
||||||
verify(connection).withService(DEFAULT);
|
verify(connection).withService(DEFAULT);
|
||||||
verifyNoMoreInteractions(connection);
|
verifyNoMoreInteractions(connection);
|
||||||
|
@ -80,7 +83,7 @@ public class CurlCommandTest extends CommandTestCase<CurlCommand> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPostInvocation_withContentType() throws Exception {
|
void testPostInvocation_withContentType() throws Exception {
|
||||||
runCommand(
|
runCommand(
|
||||||
"--path=/foo/bar?a=1&b=2",
|
"--path=/foo/bar?a=1&b=2",
|
||||||
"--data=some data",
|
"--data=some data",
|
||||||
|
@ -97,7 +100,8 @@ public class CurlCommandTest extends CommandTestCase<CurlCommand> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPostInvocation_badContentType() throws Exception {
|
@MockitoSettings(strictness = Strictness.LENIENT)
|
||||||
|
void testPostInvocation_badContentType() throws Exception {
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
() ->
|
() ->
|
||||||
|
@ -111,7 +115,7 @@ public class CurlCommandTest extends CommandTestCase<CurlCommand> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMultiDataPost() throws Exception {
|
void testMultiDataPost() throws Exception {
|
||||||
runCommand(
|
runCommand(
|
||||||
"--path=/foo/bar?a=1&b=2", "--data=first=100", "-d", "second=200", "--service=PUBAPI");
|
"--path=/foo/bar?a=1&b=2", "--data=first=100", "-d", "second=200", "--service=PUBAPI");
|
||||||
verify(connection).withService(PUBAPI);
|
verify(connection).withService(PUBAPI);
|
||||||
|
@ -125,7 +129,7 @@ public class CurlCommandTest extends CommandTestCase<CurlCommand> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDataDoesntSplit() throws Exception {
|
void testDataDoesntSplit() throws Exception {
|
||||||
runCommand(
|
runCommand(
|
||||||
"--path=/foo/bar?a=1&b=2", "--data=one,two", "--service=PUBAPI");
|
"--path=/foo/bar?a=1&b=2", "--data=one,two", "--service=PUBAPI");
|
||||||
verify(connection).withService(PUBAPI);
|
verify(connection).withService(PUBAPI);
|
||||||
|
@ -139,7 +143,7 @@ public class CurlCommandTest extends CommandTestCase<CurlCommand> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testExplicitPostInvocation() throws Exception {
|
void testExplicitPostInvocation() throws Exception {
|
||||||
runCommand("--path=/foo/bar?a=1&b=2", "--request=POST", "--service=TOOLS");
|
runCommand("--path=/foo/bar?a=1&b=2", "--request=POST", "--service=TOOLS");
|
||||||
verify(connection).withService(TOOLS);
|
verify(connection).withService(TOOLS);
|
||||||
verifyNoMoreInteractions(connection);
|
verifyNoMoreInteractions(connection);
|
||||||
|
@ -152,7 +156,8 @@ public class CurlCommandTest extends CommandTestCase<CurlCommand> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetWithBody() throws Exception {
|
@MockitoSettings(strictness = Strictness.LENIENT)
|
||||||
|
void testGetWithBody() {
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
|
|
|
@ -27,12 +27,11 @@ import google.registry.model.domain.token.AllocationToken.TokenType;
|
||||||
import google.registry.model.reporting.HistoryEntry;
|
import google.registry.model.reporting.HistoryEntry;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
/** Unit tests for {@link DeleteAllocationTokensCommand}. */
|
/** Unit tests for {@link DeleteAllocationTokensCommand}. */
|
||||||
public class DeleteAllocationTokensCommandTest
|
class DeleteAllocationTokensCommandTest extends CommandTestCase<DeleteAllocationTokensCommand> {
|
||||||
extends CommandTestCase<DeleteAllocationTokensCommand> {
|
|
||||||
|
|
||||||
private AllocationToken preRed1;
|
private AllocationToken preRed1;
|
||||||
private AllocationToken preRed2;
|
private AllocationToken preRed2;
|
||||||
|
@ -41,8 +40,8 @@ public class DeleteAllocationTokensCommandTest
|
||||||
private AllocationToken othrRed;
|
private AllocationToken othrRed;
|
||||||
private AllocationToken othrNot;
|
private AllocationToken othrNot;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void init() {
|
void beforeEach() {
|
||||||
createTlds("foo", "bar");
|
createTlds("foo", "bar");
|
||||||
preRed1 = persistToken("prefix12345AA", null, true);
|
preRed1 = persistToken("prefix12345AA", null, true);
|
||||||
preRed2 = persistToken("prefixgh8907a", null, true);
|
preRed2 = persistToken("prefixgh8907a", null, true);
|
||||||
|
@ -53,7 +52,7 @@ public class DeleteAllocationTokensCommandTest
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_deleteOnlyUnredeemedTokensWithPrefix() throws Exception {
|
void test_deleteOnlyUnredeemedTokensWithPrefix() throws Exception {
|
||||||
runCommandForced("--prefix", "prefix");
|
runCommandForced("--prefix", "prefix");
|
||||||
assertThat(reloadTokens(preNot1, preNot2)).isEmpty();
|
assertThat(reloadTokens(preNot1, preNot2)).isEmpty();
|
||||||
assertThat(reloadTokens(preRed1, preRed2, othrRed, othrNot))
|
assertThat(reloadTokens(preRed1, preRed2, othrRed, othrNot))
|
||||||
|
@ -61,7 +60,7 @@ public class DeleteAllocationTokensCommandTest
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_deleteSingleAllocationToken() throws Exception {
|
void test_deleteSingleAllocationToken() throws Exception {
|
||||||
runCommandForced("--prefix", "asdgfho7HASDS");
|
runCommandForced("--prefix", "asdgfho7HASDS");
|
||||||
assertThat(reloadTokens(othrNot)).isEmpty();
|
assertThat(reloadTokens(othrNot)).isEmpty();
|
||||||
assertThat(reloadTokens(preRed1, preRed2, preNot1, preNot2, othrRed))
|
assertThat(reloadTokens(preRed1, preRed2, preNot1, preNot2, othrRed))
|
||||||
|
@ -69,7 +68,7 @@ public class DeleteAllocationTokensCommandTest
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_deleteParticularTokens() throws Exception {
|
void test_deleteParticularTokens() throws Exception {
|
||||||
runCommandForced("--tokens", "prefix2978204,asdgfho7HASDS");
|
runCommandForced("--tokens", "prefix2978204,asdgfho7HASDS");
|
||||||
assertThat(reloadTokens(preNot1, othrNot)).isEmpty();
|
assertThat(reloadTokens(preNot1, othrNot)).isEmpty();
|
||||||
assertThat(reloadTokens(preRed1, preRed2, preNot2, othrRed))
|
assertThat(reloadTokens(preRed1, preRed2, preNot2, othrRed))
|
||||||
|
@ -77,14 +76,14 @@ public class DeleteAllocationTokensCommandTest
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_deleteTokensWithNonExistentPrefix_doesNothing() throws Exception {
|
void test_deleteTokensWithNonExistentPrefix_doesNothing() throws Exception {
|
||||||
runCommandForced("--prefix", "nonexistent");
|
runCommandForced("--prefix", "nonexistent");
|
||||||
assertThat(reloadTokens(preRed1, preRed2, preNot1, preNot2, othrRed, othrNot))
|
assertThat(reloadTokens(preRed1, preRed2, preNot1, preNot2, othrRed, othrNot))
|
||||||
.containsExactly(preRed1, preRed2, preNot1, preNot2, othrRed, othrNot);
|
.containsExactly(preRed1, preRed2, preNot1, preNot2, othrRed, othrNot);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_dryRun_deletesNothing() throws Exception {
|
void test_dryRun_deletesNothing() throws Exception {
|
||||||
runCommandForced("--prefix", "prefix", "--dry_run");
|
runCommandForced("--prefix", "prefix", "--dry_run");
|
||||||
assertThat(reloadTokens(preRed1, preRed2, preNot1, preNot2, othrRed, othrNot))
|
assertThat(reloadTokens(preRed1, preRed2, preNot1, preNot2, othrRed, othrNot))
|
||||||
.containsExactly(preRed1, preRed2, preNot1, preNot2, othrRed, othrNot);
|
.containsExactly(preRed1, preRed2, preNot1, preNot2, othrRed, othrNot);
|
||||||
|
@ -92,7 +91,7 @@ public class DeleteAllocationTokensCommandTest
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_defaultOptions_doesntDeletePerDomainTokens() throws Exception {
|
void test_defaultOptions_doesntDeletePerDomainTokens() throws Exception {
|
||||||
AllocationToken preDom1 = persistToken("prefixasdfg897as", "foo.bar", false);
|
AllocationToken preDom1 = persistToken("prefixasdfg897as", "foo.bar", false);
|
||||||
AllocationToken preDom2 = persistToken("prefix98HAZXadbn", "foo.bar", true);
|
AllocationToken preDom2 = persistToken("prefix98HAZXadbn", "foo.bar", true);
|
||||||
runCommandForced("--prefix", "prefix");
|
runCommandForced("--prefix", "prefix");
|
||||||
|
@ -102,7 +101,7 @@ public class DeleteAllocationTokensCommandTest
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_withDomains_doesDeletePerDomainTokens() throws Exception {
|
void test_withDomains_doesDeletePerDomainTokens() throws Exception {
|
||||||
AllocationToken preDom1 = persistToken("prefixasdfg897as", "foo.bar", false);
|
AllocationToken preDom1 = persistToken("prefixasdfg897as", "foo.bar", false);
|
||||||
AllocationToken preDom2 = persistToken("prefix98HAZXadbn", "foo.bar", true);
|
AllocationToken preDom2 = persistToken("prefix98HAZXadbn", "foo.bar", true);
|
||||||
runCommandForced("--prefix", "prefix", "--with_domains");
|
runCommandForced("--prefix", "prefix", "--with_domains");
|
||||||
|
@ -112,7 +111,7 @@ public class DeleteAllocationTokensCommandTest
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSkipUnlimitedUseTokens() throws Exception {
|
void testSkipUnlimitedUseTokens() throws Exception {
|
||||||
AllocationToken unlimitedUseToken =
|
AllocationToken unlimitedUseToken =
|
||||||
persistResource(
|
persistResource(
|
||||||
new AllocationToken.Builder()
|
new AllocationToken.Builder()
|
||||||
|
@ -124,7 +123,7 @@ public class DeleteAllocationTokensCommandTest
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_batching() throws Exception {
|
void test_batching() throws Exception {
|
||||||
for (int i = 0; i < 50; i++) {
|
for (int i = 0; i < 50; i++) {
|
||||||
persistToken(String.format("batch%2d", i), null, i % 2 == 0);
|
persistToken(String.format("batch%2d", i), null, i % 2 == 0);
|
||||||
}
|
}
|
||||||
|
@ -134,7 +133,7 @@ public class DeleteAllocationTokensCommandTest
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_prefixIsRequired() {
|
void test_prefixIsRequired() {
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(IllegalArgumentException.class, this::runCommandForced);
|
assertThrows(IllegalArgumentException.class, this::runCommandForced);
|
||||||
assertThat(thrown)
|
assertThat(thrown)
|
||||||
|
@ -143,7 +142,7 @@ public class DeleteAllocationTokensCommandTest
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_bothPrefixAndTokens() {
|
void testFailure_bothPrefixAndTokens() {
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
|
@ -154,7 +153,7 @@ public class DeleteAllocationTokensCommandTest
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_emptyPrefix() {
|
void testFailure_emptyPrefix() {
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(IllegalArgumentException.class, () -> runCommandForced("--prefix", ""));
|
assertThrows(IllegalArgumentException.class, () -> runCommandForced("--prefix", ""));
|
||||||
assertThat(thrown).hasMessageThat().isEqualTo("Provided prefix should not be blank");
|
assertThat(thrown).hasMessageThat().isEqualTo("Provided prefix should not be blank");
|
||||||
|
|
|
@ -17,39 +17,39 @@ package google.registry.tools;
|
||||||
import static org.junit.Assert.assertThrows;
|
import static org.junit.Assert.assertThrows;
|
||||||
|
|
||||||
import com.beust.jcommander.ParameterException;
|
import com.beust.jcommander.ParameterException;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
/** Unit tests for {@link DeleteDomainCommand}. */
|
/** Unit tests for {@link DeleteDomainCommand}. */
|
||||||
public class DeleteDomainCommandTest extends EppToolCommandTestCase<DeleteDomainCommand> {
|
class DeleteDomainCommandTest extends EppToolCommandTestCase<DeleteDomainCommand> {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess() throws Exception {
|
void testSuccess() throws Exception {
|
||||||
runCommand("--client=NewRegistrar", "--domain_name=example.tld", "--force", "--reason=Test");
|
runCommand("--client=NewRegistrar", "--domain_name=example.tld", "--force", "--reason=Test");
|
||||||
eppVerifier.verifySent("domain_delete.xml");
|
eppVerifier.verifySent("domain_delete.xml");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_multipleWordReason() throws Exception {
|
void testSuccess_multipleWordReason() throws Exception {
|
||||||
runCommandForced(
|
runCommandForced(
|
||||||
"--client=NewRegistrar", "--domain_name=example.tld", "--reason=\"Test test\"");
|
"--client=NewRegistrar", "--domain_name=example.tld", "--reason=\"Test test\"");
|
||||||
eppVerifier.verifySent("domain_delete_multiple_word_reason.xml");
|
eppVerifier.verifySent("domain_delete_multiple_word_reason.xml");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_immediately() throws Exception {
|
void testSuccess_immediately() throws Exception {
|
||||||
runCommandForced(
|
runCommandForced(
|
||||||
"--client=NewRegistrar", "--domain_name=example.tld", "--immediately", "--reason=Test");
|
"--client=NewRegistrar", "--domain_name=example.tld", "--immediately", "--reason=Test");
|
||||||
eppVerifier.expectSuperuser().verifySent("domain_delete_immediately.xml");
|
eppVerifier.expectSuperuser().verifySent("domain_delete_immediately.xml");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_requestedByRegistrarFalse() throws Exception {
|
void testSuccess_requestedByRegistrarFalse() throws Exception {
|
||||||
runCommandForced("--client=NewRegistrar", "--domain_name=example.tld", "--reason=Test");
|
runCommandForced("--client=NewRegistrar", "--domain_name=example.tld", "--reason=Test");
|
||||||
eppVerifier.verifySent("domain_delete.xml");
|
eppVerifier.verifySent("domain_delete.xml");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_requestedByRegistrarTrue() throws Exception {
|
void testSuccess_requestedByRegistrarTrue() throws Exception {
|
||||||
runCommandForced(
|
runCommandForced(
|
||||||
"--client=NewRegistrar",
|
"--client=NewRegistrar",
|
||||||
"--domain_name=example.tld",
|
"--domain_name=example.tld",
|
||||||
|
@ -59,28 +59,28 @@ public class DeleteDomainCommandTest extends EppToolCommandTestCase<DeleteDomain
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_noReason() {
|
void testFailure_noReason() {
|
||||||
assertThrows(
|
assertThrows(
|
||||||
ParameterException.class,
|
ParameterException.class,
|
||||||
() -> runCommand("--client=NewRegistrar", "--domain_name=example.tld", "--force"));
|
() -> runCommand("--client=NewRegistrar", "--domain_name=example.tld", "--force"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_missingClientId() {
|
void testFailure_missingClientId() {
|
||||||
assertThrows(
|
assertThrows(
|
||||||
ParameterException.class,
|
ParameterException.class,
|
||||||
() -> runCommand("--domain_name=example.tld", "--force", "--reason=Test"));
|
() -> runCommand("--domain_name=example.tld", "--force", "--reason=Test"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_missingDomainName() {
|
void testFailure_missingDomainName() {
|
||||||
assertThrows(
|
assertThrows(
|
||||||
ParameterException.class,
|
ParameterException.class,
|
||||||
() -> runCommand("--client=NewRegistrar", "--force", "--reason=Test"));
|
() -> runCommand("--client=NewRegistrar", "--force", "--reason=Test"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_unknownFlag() {
|
void testFailure_unknownFlag() {
|
||||||
assertThrows(
|
assertThrows(
|
||||||
ParameterException.class,
|
ParameterException.class,
|
||||||
() ->
|
() ->
|
||||||
|
@ -93,7 +93,7 @@ public class DeleteDomainCommandTest extends EppToolCommandTestCase<DeleteDomain
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_mainParameter() {
|
void testFailure_mainParameter() {
|
||||||
assertThrows(
|
assertThrows(
|
||||||
ParameterException.class,
|
ParameterException.class,
|
||||||
() ->
|
() ->
|
||||||
|
|
|
@ -17,26 +17,26 @@ package google.registry.tools;
|
||||||
import static org.junit.Assert.assertThrows;
|
import static org.junit.Assert.assertThrows;
|
||||||
|
|
||||||
import com.beust.jcommander.ParameterException;
|
import com.beust.jcommander.ParameterException;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
/** Unit tests for {@link DeleteHostCommand}. */
|
/** Unit tests for {@link DeleteHostCommand}. */
|
||||||
public class DeleteHostCommandTest extends EppToolCommandTestCase<DeleteHostCommand> {
|
class DeleteHostCommandTest extends EppToolCommandTestCase<DeleteHostCommand> {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess() throws Exception {
|
void testSuccess() throws Exception {
|
||||||
runCommand("--client=NewRegistrar", "--host=ns1.example.tld", "--force", "--reason=Test");
|
runCommand("--client=NewRegistrar", "--host=ns1.example.tld", "--force", "--reason=Test");
|
||||||
eppVerifier.verifySent("host_delete.xml");
|
eppVerifier.verifySent("host_delete.xml");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_multipleWordReason() throws Exception {
|
void testSuccess_multipleWordReason() throws Exception {
|
||||||
runCommand(
|
runCommand(
|
||||||
"--client=NewRegistrar", "--host=ns1.example.tld", "--force", "--reason=\"Test test\"");
|
"--client=NewRegistrar", "--host=ns1.example.tld", "--force", "--reason=\"Test test\"");
|
||||||
eppVerifier.verifySent("host_delete_multiple_word_reason.xml");
|
eppVerifier.verifySent("host_delete_multiple_word_reason.xml");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_requestedByRegistrarFalse() throws Exception {
|
void testSuccess_requestedByRegistrarFalse() throws Exception {
|
||||||
runCommand(
|
runCommand(
|
||||||
"--client=NewRegistrar",
|
"--client=NewRegistrar",
|
||||||
"--host=ns1.example.tld",
|
"--host=ns1.example.tld",
|
||||||
|
@ -47,7 +47,7 @@ public class DeleteHostCommandTest extends EppToolCommandTestCase<DeleteHostComm
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_requestedByRegistrarTrue() throws Exception {
|
void testSuccess_requestedByRegistrarTrue() throws Exception {
|
||||||
runCommand(
|
runCommand(
|
||||||
"--client=NewRegistrar",
|
"--client=NewRegistrar",
|
||||||
"--host=ns1.example.tld",
|
"--host=ns1.example.tld",
|
||||||
|
@ -58,28 +58,28 @@ public class DeleteHostCommandTest extends EppToolCommandTestCase<DeleteHostComm
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_noReason() {
|
void testFailure_noReason() {
|
||||||
assertThrows(
|
assertThrows(
|
||||||
ParameterException.class,
|
ParameterException.class,
|
||||||
() -> runCommand("--client=NewRegistrar", "--host=ns1.example.tld", "--force"));
|
() -> runCommand("--client=NewRegistrar", "--host=ns1.example.tld", "--force"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_missingClientId() {
|
void testFailure_missingClientId() {
|
||||||
assertThrows(
|
assertThrows(
|
||||||
ParameterException.class,
|
ParameterException.class,
|
||||||
() -> runCommand("--host=ns1.example.tld", "--force", "--reason=Test"));
|
() -> runCommand("--host=ns1.example.tld", "--force", "--reason=Test"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_missingHostName() {
|
void testFailure_missingHostName() {
|
||||||
assertThrows(
|
assertThrows(
|
||||||
ParameterException.class,
|
ParameterException.class,
|
||||||
() -> runCommand("--client=NewRegistrar", "--force", "--reason=Test"));
|
() -> runCommand("--client=NewRegistrar", "--force", "--reason=Test"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_unknownFlag() {
|
void testFailure_unknownFlag() {
|
||||||
assertThrows(
|
assertThrows(
|
||||||
ParameterException.class,
|
ParameterException.class,
|
||||||
() ->
|
() ->
|
||||||
|
@ -92,7 +92,7 @@ public class DeleteHostCommandTest extends EppToolCommandTestCase<DeleteHostComm
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_mainParameter() {
|
void testFailure_mainParameter() {
|
||||||
assertThrows(
|
assertThrows(
|
||||||
ParameterException.class,
|
ParameterException.class,
|
||||||
() ->
|
() ->
|
||||||
|
|
|
@ -26,13 +26,13 @@ import static org.junit.Assert.assertThrows;
|
||||||
import google.registry.model.registry.Registry;
|
import google.registry.model.registry.Registry;
|
||||||
import google.registry.model.registry.label.PremiumList;
|
import google.registry.model.registry.label.PremiumList;
|
||||||
import google.registry.model.registry.label.PremiumList.PremiumListEntry;
|
import google.registry.model.registry.label.PremiumList.PremiumListEntry;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
/** Unit tests for {@link DeletePremiumListCommand}. */
|
/** Unit tests for {@link DeletePremiumListCommand}. */
|
||||||
public class DeletePremiumListCommandTest extends CommandTestCase<DeletePremiumListCommand> {
|
class DeletePremiumListCommandTest extends CommandTestCase<DeletePremiumListCommand> {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess() throws Exception {
|
void testSuccess() throws Exception {
|
||||||
PremiumList premiumList = persistPremiumList("xn--q9jyb4c", "blah,USD 100");
|
PremiumList premiumList = persistPremiumList("xn--q9jyb4c", "blah,USD 100");
|
||||||
assertThat(loadPremiumListEntries(premiumList)).hasSize(1);
|
assertThat(loadPremiumListEntries(premiumList)).hasSize(1);
|
||||||
runCommand("--force", "--name=xn--q9jyb4c");
|
runCommand("--force", "--name=xn--q9jyb4c");
|
||||||
|
@ -47,7 +47,7 @@ public class DeletePremiumListCommandTest extends CommandTestCase<DeletePremiumL
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_whenPremiumListDoesNotExist() {
|
void testFailure_whenPremiumListDoesNotExist() {
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(IllegalArgumentException.class, () -> runCommandForced("--name=foo"));
|
assertThrows(IllegalArgumentException.class, () -> runCommandForced("--name=foo"));
|
||||||
assertThat(thrown)
|
assertThat(thrown)
|
||||||
|
@ -56,7 +56,7 @@ public class DeletePremiumListCommandTest extends CommandTestCase<DeletePremiumL
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_whenPremiumListIsInUse() {
|
void testFailure_whenPremiumListIsInUse() {
|
||||||
PremiumList premiumList = persistPremiumList("xn--q9jyb4c", "blah,USD 100");
|
PremiumList premiumList = persistPremiumList("xn--q9jyb4c", "blah,USD 100");
|
||||||
createTld("xn--q9jyb4c");
|
createTld("xn--q9jyb4c");
|
||||||
persistResource(Registry.get("xn--q9jyb4c").asBuilder().setPremiumList(premiumList).build());
|
persistResource(Registry.get("xn--q9jyb4c").asBuilder().setPremiumList(premiumList).build());
|
||||||
|
|
|
@ -23,28 +23,28 @@ import static org.junit.Assert.assertThrows;
|
||||||
|
|
||||||
import google.registry.model.registry.Registry;
|
import google.registry.model.registry.Registry;
|
||||||
import google.registry.model.registry.label.ReservedList;
|
import google.registry.model.registry.label.ReservedList;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
/** Unit tests for {@link DeleteReservedListCommand}. */
|
/** Unit tests for {@link DeleteReservedListCommand}. */
|
||||||
public class DeleteReservedListCommandTest extends CommandTestCase<DeleteReservedListCommand> {
|
class DeleteReservedListCommandTest extends CommandTestCase<DeleteReservedListCommand> {
|
||||||
|
|
||||||
ReservedList reservedList;
|
private ReservedList reservedList;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void init() {
|
void beforeEach() {
|
||||||
reservedList = persistReservedList("common", "blah,FULLY_BLOCKED");
|
reservedList = persistReservedList("common", "blah,FULLY_BLOCKED");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess() throws Exception {
|
void testSuccess() throws Exception {
|
||||||
assertThat(reservedList.getReservedListEntries()).hasSize(1);
|
assertThat(reservedList.getReservedListEntries()).hasSize(1);
|
||||||
runCommandForced("--name=common");
|
runCommandForced("--name=common");
|
||||||
assertThat(ReservedList.get("common")).isEmpty();
|
assertThat(ReservedList.get("common")).isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_whenReservedListDoesNotExist() {
|
void testFailure_whenReservedListDoesNotExist() {
|
||||||
String expectedError =
|
String expectedError =
|
||||||
"Cannot delete the reserved list doesntExistReservedList because it doesn't exist.";
|
"Cannot delete the reserved list doesntExistReservedList because it doesn't exist.";
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
|
@ -55,7 +55,7 @@ public class DeleteReservedListCommandTest extends CommandTestCase<DeleteReserve
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_whenReservedListIsInUse() {
|
void testFailure_whenReservedListIsInUse() {
|
||||||
createTld("xn--q9jyb4c");
|
createTld("xn--q9jyb4c");
|
||||||
persistResource(Registry.get("xn--q9jyb4c").asBuilder().setReservedLists(reservedList).build());
|
persistResource(Registry.get("xn--q9jyb4c").asBuilder().setReservedLists(reservedList).build());
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
|
|
|
@ -28,17 +28,17 @@ import google.registry.model.registry.Registry;
|
||||||
import google.registry.model.registry.Registry.RegistryNotFoundException;
|
import google.registry.model.registry.Registry.RegistryNotFoundException;
|
||||||
import google.registry.model.registry.Registry.TldType;
|
import google.registry.model.registry.Registry.TldType;
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
/** Unit tests for {@link DeleteTldCommand}. */
|
/** Unit tests for {@link DeleteTldCommand}. */
|
||||||
public class DeleteTldCommandTest extends CommandTestCase<DeleteTldCommand> {
|
class DeleteTldCommandTest extends CommandTestCase<DeleteTldCommand> {
|
||||||
|
|
||||||
private static final String TLD_REAL = "tldreal";
|
private static final String TLD_REAL = "tldreal";
|
||||||
private static final String TLD_TEST = "tldtest";
|
private static final String TLD_TEST = "tldtest";
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setUp() {
|
void beforeEach() {
|
||||||
persistResource(
|
persistResource(
|
||||||
newRegistry(
|
newRegistry(
|
||||||
TLD_REAL,
|
TLD_REAL,
|
||||||
|
@ -54,7 +54,7 @@ public class DeleteTldCommandTest extends CommandTestCase<DeleteTldCommand> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_otherTldUnaffected() throws Exception {
|
void testSuccess_otherTldUnaffected() throws Exception {
|
||||||
runCommandForced("--tld=" + TLD_TEST);
|
runCommandForced("--tld=" + TLD_TEST);
|
||||||
|
|
||||||
Registry.get(TLD_REAL);
|
Registry.get(TLD_REAL);
|
||||||
|
@ -62,24 +62,24 @@ public class DeleteTldCommandTest extends CommandTestCase<DeleteTldCommand> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_whenTldDoesNotExist() {
|
void testFailure_whenTldDoesNotExist() {
|
||||||
assertThrows(RegistryNotFoundException.class, () -> runCommandForced("--tld=nonexistenttld"));
|
assertThrows(RegistryNotFoundException.class, () -> runCommandForced("--tld=nonexistenttld"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_whenTldIsReal() {
|
void testFailure_whenTldIsReal() {
|
||||||
assertThrows(IllegalStateException.class, () -> runCommandForced("--tld=" + TLD_REAL));
|
assertThrows(IllegalStateException.class, () -> runCommandForced("--tld=" + TLD_REAL));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_whenDomainsArePresent() {
|
void testFailure_whenDomainsArePresent() {
|
||||||
persistDeletedDomain("domain." + TLD_TEST, DateTime.parse("2000-01-01TZ"));
|
persistDeletedDomain("domain." + TLD_TEST, DateTime.parse("2000-01-01TZ"));
|
||||||
|
|
||||||
assertThrows(IllegalStateException.class, () -> runCommandForced("--tld=" + TLD_TEST));
|
assertThrows(IllegalStateException.class, () -> runCommandForced("--tld=" + TLD_TEST));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_whenRegistrarLinksToTld() {
|
void testFailure_whenRegistrarLinksToTld() {
|
||||||
allowRegistrarAccess("TheRegistrar", TLD_TEST);
|
allowRegistrarAccess("TheRegistrar", TLD_TEST);
|
||||||
|
|
||||||
assertThrows(IllegalStateException.class, () -> runCommandForced("--tld=" + TLD_TEST));
|
assertThrows(IllegalStateException.class, () -> runCommandForced("--tld=" + TLD_TEST));
|
||||||
|
|
|
@ -58,14 +58,11 @@ import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
import org.joda.time.DateTimeZone;
|
import org.joda.time.DateTimeZone;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Rule;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
import org.junit.runners.JUnit4;
|
|
||||||
|
|
||||||
/** Unit tests for {@link google.registry.tools.DomainLockUtils}. */
|
/** Unit tests for {@link google.registry.tools.DomainLockUtils}. */
|
||||||
@RunWith(JUnit4.class)
|
|
||||||
public final class DomainLockUtilsTest {
|
public final class DomainLockUtilsTest {
|
||||||
|
|
||||||
private static final String DOMAIN_NAME = "example.tld";
|
private static final String DOMAIN_NAME = "example.tld";
|
||||||
|
@ -74,7 +71,7 @@ public final class DomainLockUtilsTest {
|
||||||
private final FakeClock clock = new FakeClock(DateTime.now(DateTimeZone.UTC));
|
private final FakeClock clock = new FakeClock(DateTime.now(DateTimeZone.UTC));
|
||||||
private DomainLockUtils domainLockUtils;
|
private DomainLockUtils domainLockUtils;
|
||||||
|
|
||||||
@Rule
|
@RegisterExtension
|
||||||
public final AppEngineRule appEngineRule =
|
public final AppEngineRule appEngineRule =
|
||||||
AppEngineRule.builder()
|
AppEngineRule.builder()
|
||||||
.withDatastoreAndCloudSql()
|
.withDatastoreAndCloudSql()
|
||||||
|
@ -85,15 +82,16 @@ public final class DomainLockUtilsTest {
|
||||||
|
|
||||||
private DomainBase domain;
|
private DomainBase domain;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setup() {
|
void setup() {
|
||||||
createTlds("tld", "net");
|
createTlds("tld", "net");
|
||||||
HostResource host = persistActiveHost("ns1.example.net");
|
HostResource host = persistActiveHost("ns1.example.net");
|
||||||
domain = persistResource(newDomainBase(DOMAIN_NAME, host));
|
domain = persistResource(newDomainBase(DOMAIN_NAME, host));
|
||||||
|
|
||||||
AppEngineServiceUtils appEngineServiceUtils = mock(AppEngineServiceUtils.class);
|
AppEngineServiceUtils appEngineServiceUtils = mock(AppEngineServiceUtils.class);
|
||||||
when(appEngineServiceUtils.getServiceHostname("backend")).thenReturn("backend.hostname.fake");
|
when(appEngineServiceUtils.getServiceHostname("backend")).thenReturn("backend.hostname.fake");
|
||||||
domainLockUtils = new DomainLockUtils(
|
domainLockUtils =
|
||||||
|
new DomainLockUtils(
|
||||||
new DeterministicStringGenerator(Alphabets.BASE_58),
|
new DeterministicStringGenerator(Alphabets.BASE_58),
|
||||||
"adminreg",
|
"adminreg",
|
||||||
AsyncTaskEnqueuerTest.createForTesting(
|
AsyncTaskEnqueuerTest.createForTesting(
|
||||||
|
@ -101,7 +99,7 @@ public final class DomainLockUtilsTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_createLock() {
|
void testSuccess_createLock() {
|
||||||
RegistryLock lock =
|
RegistryLock lock =
|
||||||
domainLockUtils.saveNewRegistryLockRequest(DOMAIN_NAME, "TheRegistrar", POC_ID, false);
|
domainLockUtils.saveNewRegistryLockRequest(DOMAIN_NAME, "TheRegistrar", POC_ID, false);
|
||||||
assertNoDomainChanges();
|
assertNoDomainChanges();
|
||||||
|
@ -109,7 +107,7 @@ public final class DomainLockUtilsTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_createUnlock() {
|
void testSuccess_createUnlock() {
|
||||||
domainLockUtils.administrativelyApplyLock(DOMAIN_NAME, "TheRegistrar", POC_ID, false);
|
domainLockUtils.administrativelyApplyLock(DOMAIN_NAME, "TheRegistrar", POC_ID, false);
|
||||||
RegistryLock lock =
|
RegistryLock lock =
|
||||||
domainLockUtils.saveNewRegistryUnlockRequest(
|
domainLockUtils.saveNewRegistryUnlockRequest(
|
||||||
|
@ -118,7 +116,7 @@ public final class DomainLockUtilsTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_createUnlock_adminUnlockingAdmin() {
|
void testSuccess_createUnlock_adminUnlockingAdmin() {
|
||||||
domainLockUtils.administrativelyApplyLock(DOMAIN_NAME, "TheRegistrar", null, true);
|
domainLockUtils.administrativelyApplyLock(DOMAIN_NAME, "TheRegistrar", null, true);
|
||||||
RegistryLock lock =
|
RegistryLock lock =
|
||||||
domainLockUtils.saveNewRegistryUnlockRequest(
|
domainLockUtils.saveNewRegistryUnlockRequest(
|
||||||
|
@ -127,7 +125,7 @@ public final class DomainLockUtilsTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_createLock_previousLockExpired() {
|
void testSuccess_createLock_previousLockExpired() {
|
||||||
domainLockUtils.saveNewRegistryLockRequest(DOMAIN_NAME, "TheRegistrar", POC_ID, false);
|
domainLockUtils.saveNewRegistryLockRequest(DOMAIN_NAME, "TheRegistrar", POC_ID, false);
|
||||||
clock.advanceBy(standardDays(1));
|
clock.advanceBy(standardDays(1));
|
||||||
RegistryLock lock =
|
RegistryLock lock =
|
||||||
|
@ -137,7 +135,7 @@ public final class DomainLockUtilsTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_createUnlock_previousUnlockRequestExpired() {
|
void testSuccess_createUnlock_previousUnlockRequestExpired() {
|
||||||
domainLockUtils.administrativelyApplyLock(DOMAIN_NAME, "TheRegistrar", POC_ID, false);
|
domainLockUtils.administrativelyApplyLock(DOMAIN_NAME, "TheRegistrar", POC_ID, false);
|
||||||
domainLockUtils.saveNewRegistryUnlockRequest(
|
domainLockUtils.saveNewRegistryUnlockRequest(
|
||||||
DOMAIN_NAME, "TheRegistrar", false, Optional.empty());
|
DOMAIN_NAME, "TheRegistrar", false, Optional.empty());
|
||||||
|
@ -150,7 +148,7 @@ public final class DomainLockUtilsTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_applyLockDomain() {
|
void testSuccess_applyLockDomain() {
|
||||||
RegistryLock lock =
|
RegistryLock lock =
|
||||||
domainLockUtils.saveNewRegistryLockRequest(DOMAIN_NAME, "TheRegistrar", POC_ID, false);
|
domainLockUtils.saveNewRegistryLockRequest(DOMAIN_NAME, "TheRegistrar", POC_ID, false);
|
||||||
domainLockUtils.verifyAndApplyLock(lock.getVerificationCode(), false);
|
domainLockUtils.verifyAndApplyLock(lock.getVerificationCode(), false);
|
||||||
|
@ -158,7 +156,7 @@ public final class DomainLockUtilsTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_applyUnlockDomain() {
|
void testSuccess_applyUnlockDomain() {
|
||||||
domainLockUtils.administrativelyApplyLock(DOMAIN_NAME, "TheRegistrar", POC_ID, false);
|
domainLockUtils.administrativelyApplyLock(DOMAIN_NAME, "TheRegistrar", POC_ID, false);
|
||||||
RegistryLock unlock =
|
RegistryLock unlock =
|
||||||
domainLockUtils.saveNewRegistryUnlockRequest(
|
domainLockUtils.saveNewRegistryUnlockRequest(
|
||||||
|
@ -168,7 +166,7 @@ public final class DomainLockUtilsTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_applyAdminLock_onlyHistoryEntry() {
|
void testSuccess_applyAdminLock_onlyHistoryEntry() {
|
||||||
RegistryLock lock =
|
RegistryLock lock =
|
||||||
domainLockUtils.saveNewRegistryLockRequest(DOMAIN_NAME, "TheRegistrar", null, true);
|
domainLockUtils.saveNewRegistryLockRequest(DOMAIN_NAME, "TheRegistrar", null, true);
|
||||||
domainLockUtils.verifyAndApplyLock(lock.getVerificationCode(), true);
|
domainLockUtils.verifyAndApplyLock(lock.getVerificationCode(), true);
|
||||||
|
@ -176,7 +174,7 @@ public final class DomainLockUtilsTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_applyAdminUnlock_onlyHistoryEntry() {
|
void testSuccess_applyAdminUnlock_onlyHistoryEntry() {
|
||||||
RegistryLock lock =
|
RegistryLock lock =
|
||||||
domainLockUtils.saveNewRegistryLockRequest(DOMAIN_NAME, "TheRegistrar", null, true);
|
domainLockUtils.saveNewRegistryLockRequest(DOMAIN_NAME, "TheRegistrar", null, true);
|
||||||
domainLockUtils.verifyAndApplyLock(lock.getVerificationCode(), true);
|
domainLockUtils.verifyAndApplyLock(lock.getVerificationCode(), true);
|
||||||
|
@ -188,20 +186,20 @@ public final class DomainLockUtilsTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_administrativelyLock_nonAdmin() {
|
void testSuccess_administrativelyLock_nonAdmin() {
|
||||||
domainLockUtils.administrativelyApplyLock(
|
domainLockUtils.administrativelyApplyLock(
|
||||||
DOMAIN_NAME, "TheRegistrar", "Marla.Singer@crr.com", false);
|
DOMAIN_NAME, "TheRegistrar", "Marla.Singer@crr.com", false);
|
||||||
verifyProperlyLockedDomain(false);
|
verifyProperlyLockedDomain(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_administrativelyLock_admin() {
|
void testSuccess_administrativelyLock_admin() {
|
||||||
domainLockUtils.administrativelyApplyLock(DOMAIN_NAME, "TheRegistrar", null, true);
|
domainLockUtils.administrativelyApplyLock(DOMAIN_NAME, "TheRegistrar", null, true);
|
||||||
verifyProperlyLockedDomain(true);
|
verifyProperlyLockedDomain(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_administrativelyUnlock_nonAdmin() {
|
void testSuccess_administrativelyUnlock_nonAdmin() {
|
||||||
RegistryLock lock =
|
RegistryLock lock =
|
||||||
domainLockUtils.saveNewRegistryLockRequest(DOMAIN_NAME, "TheRegistrar", POC_ID, false);
|
domainLockUtils.saveNewRegistryLockRequest(DOMAIN_NAME, "TheRegistrar", POC_ID, false);
|
||||||
domainLockUtils.verifyAndApplyLock(lock.getVerificationCode(), false);
|
domainLockUtils.verifyAndApplyLock(lock.getVerificationCode(), false);
|
||||||
|
@ -211,7 +209,7 @@ public final class DomainLockUtilsTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_administrativelyUnlock_admin() {
|
void testSuccess_administrativelyUnlock_admin() {
|
||||||
RegistryLock lock =
|
RegistryLock lock =
|
||||||
domainLockUtils.saveNewRegistryLockRequest(DOMAIN_NAME, "TheRegistrar", null, true);
|
domainLockUtils.saveNewRegistryLockRequest(DOMAIN_NAME, "TheRegistrar", null, true);
|
||||||
domainLockUtils.verifyAndApplyLock(lock.getVerificationCode(), true);
|
domainLockUtils.verifyAndApplyLock(lock.getVerificationCode(), true);
|
||||||
|
@ -221,7 +219,7 @@ public final class DomainLockUtilsTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_regularLock_relockSet() {
|
void testSuccess_regularLock_relockSet() {
|
||||||
domainLockUtils.administrativelyApplyLock(DOMAIN_NAME, "TheRegistrar", POC_ID, false);
|
domainLockUtils.administrativelyApplyLock(DOMAIN_NAME, "TheRegistrar", POC_ID, false);
|
||||||
RegistryLock oldLock =
|
RegistryLock oldLock =
|
||||||
domainLockUtils.administrativelyApplyUnlock(
|
domainLockUtils.administrativelyApplyUnlock(
|
||||||
|
@ -235,7 +233,7 @@ public final class DomainLockUtilsTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_administrativelyLock_relockSet() {
|
void testSuccess_administrativelyLock_relockSet() {
|
||||||
domainLockUtils.administrativelyApplyLock(DOMAIN_NAME, "TheRegistrar", POC_ID, false);
|
domainLockUtils.administrativelyApplyLock(DOMAIN_NAME, "TheRegistrar", POC_ID, false);
|
||||||
RegistryLock oldLock =
|
RegistryLock oldLock =
|
||||||
domainLockUtils.administrativelyApplyUnlock(
|
domainLockUtils.administrativelyApplyUnlock(
|
||||||
|
@ -248,7 +246,7 @@ public final class DomainLockUtilsTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_createUnlock_relockDuration() {
|
void testSuccess_createUnlock_relockDuration() {
|
||||||
domainLockUtils.administrativelyApplyLock(DOMAIN_NAME, "TheRegistrar", POC_ID, false);
|
domainLockUtils.administrativelyApplyLock(DOMAIN_NAME, "TheRegistrar", POC_ID, false);
|
||||||
RegistryLock lock =
|
RegistryLock lock =
|
||||||
domainLockUtils.saveNewRegistryUnlockRequest(
|
domainLockUtils.saveNewRegistryUnlockRequest(
|
||||||
|
@ -257,7 +255,7 @@ public final class DomainLockUtilsTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_unlock_relockSubmitted() {
|
void testSuccess_unlock_relockSubmitted() {
|
||||||
domainLockUtils.administrativelyApplyLock(DOMAIN_NAME, "TheRegistrar", POC_ID, false);
|
domainLockUtils.administrativelyApplyLock(DOMAIN_NAME, "TheRegistrar", POC_ID, false);
|
||||||
RegistryLock lock =
|
RegistryLock lock =
|
||||||
domainLockUtils.saveNewRegistryUnlockRequest(
|
domainLockUtils.saveNewRegistryUnlockRequest(
|
||||||
|
@ -278,7 +276,7 @@ public final class DomainLockUtilsTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_createUnlock_alreadyPendingUnlock() {
|
void testFailure_createUnlock_alreadyPendingUnlock() {
|
||||||
RegistryLock lock =
|
RegistryLock lock =
|
||||||
domainLockUtils.saveNewRegistryLockRequest(DOMAIN_NAME, "TheRegistrar", POC_ID, false);
|
domainLockUtils.saveNewRegistryLockRequest(DOMAIN_NAME, "TheRegistrar", POC_ID, false);
|
||||||
domainLockUtils.verifyAndApplyLock(lock.getVerificationCode(), false);
|
domainLockUtils.verifyAndApplyLock(lock.getVerificationCode(), false);
|
||||||
|
@ -296,7 +294,7 @@ public final class DomainLockUtilsTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_createUnlock_nonAdminUnlockingAdmin() {
|
void testFailure_createUnlock_nonAdminUnlockingAdmin() {
|
||||||
RegistryLock lock =
|
RegistryLock lock =
|
||||||
domainLockUtils.saveNewRegistryLockRequest(DOMAIN_NAME, "TheRegistrar", null, true);
|
domainLockUtils.saveNewRegistryLockRequest(DOMAIN_NAME, "TheRegistrar", null, true);
|
||||||
domainLockUtils.verifyAndApplyLock(lock.getVerificationCode(), true);
|
domainLockUtils.verifyAndApplyLock(lock.getVerificationCode(), true);
|
||||||
|
@ -311,7 +309,7 @@ public final class DomainLockUtilsTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_createLock_unknownDomain() {
|
void testFailure_createLock_unknownDomain() {
|
||||||
assertThat(
|
assertThat(
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
|
@ -323,7 +321,7 @@ public final class DomainLockUtilsTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_createLock_alreadyPendingLock() {
|
void testFailure_createLock_alreadyPendingLock() {
|
||||||
domainLockUtils.saveNewRegistryLockRequest(DOMAIN_NAME, "TheRegistrar", POC_ID, false);
|
domainLockUtils.saveNewRegistryLockRequest(DOMAIN_NAME, "TheRegistrar", POC_ID, false);
|
||||||
assertThat(
|
assertThat(
|
||||||
assertThrows(
|
assertThrows(
|
||||||
|
@ -336,7 +334,7 @@ public final class DomainLockUtilsTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_createLock_alreadyLocked() {
|
void testFailure_createLock_alreadyLocked() {
|
||||||
persistResource(domain.asBuilder().setStatusValues(REGISTRY_LOCK_STATUSES).build());
|
persistResource(domain.asBuilder().setStatusValues(REGISTRY_LOCK_STATUSES).build());
|
||||||
assertThat(
|
assertThat(
|
||||||
assertThrows(
|
assertThrows(
|
||||||
|
@ -349,7 +347,7 @@ public final class DomainLockUtilsTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_createUnlock_alreadyUnlocked() {
|
void testFailure_createUnlock_alreadyUnlocked() {
|
||||||
assertThat(
|
assertThat(
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
|
@ -361,7 +359,7 @@ public final class DomainLockUtilsTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_applyLock_alreadyApplied() {
|
void testFailure_applyLock_alreadyApplied() {
|
||||||
RegistryLock lock =
|
RegistryLock lock =
|
||||||
domainLockUtils.saveNewRegistryLockRequest(DOMAIN_NAME, "TheRegistrar", POC_ID, false);
|
domainLockUtils.saveNewRegistryLockRequest(DOMAIN_NAME, "TheRegistrar", POC_ID, false);
|
||||||
domainLockUtils.verifyAndApplyLock(lock.getVerificationCode(), false);
|
domainLockUtils.verifyAndApplyLock(lock.getVerificationCode(), false);
|
||||||
|
@ -376,7 +374,7 @@ public final class DomainLockUtilsTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_applyLock_expired() {
|
void testFailure_applyLock_expired() {
|
||||||
RegistryLock lock =
|
RegistryLock lock =
|
||||||
domainLockUtils.saveNewRegistryLockRequest(DOMAIN_NAME, "TheRegistrar", POC_ID, false);
|
domainLockUtils.saveNewRegistryLockRequest(DOMAIN_NAME, "TheRegistrar", POC_ID, false);
|
||||||
clock.advanceBy(standardDays(1));
|
clock.advanceBy(standardDays(1));
|
||||||
|
@ -390,7 +388,7 @@ public final class DomainLockUtilsTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_applyLock_nonAdmin_applyAdminLock() {
|
void testFailure_applyLock_nonAdmin_applyAdminLock() {
|
||||||
RegistryLock lock =
|
RegistryLock lock =
|
||||||
domainLockUtils.saveNewRegistryLockRequest(DOMAIN_NAME, "TheRegistrar", null, true);
|
domainLockUtils.saveNewRegistryLockRequest(DOMAIN_NAME, "TheRegistrar", null, true);
|
||||||
assertThat(
|
assertThat(
|
||||||
|
@ -403,7 +401,7 @@ public final class DomainLockUtilsTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_applyUnlock_alreadyUnlocked() {
|
void testFailure_applyUnlock_alreadyUnlocked() {
|
||||||
RegistryLock lock =
|
RegistryLock lock =
|
||||||
domainLockUtils.saveNewRegistryLockRequest(DOMAIN_NAME, "TheRegistrar", POC_ID, false);
|
domainLockUtils.saveNewRegistryLockRequest(DOMAIN_NAME, "TheRegistrar", POC_ID, false);
|
||||||
domainLockUtils.verifyAndApplyLock(lock.getVerificationCode(), false);
|
domainLockUtils.verifyAndApplyLock(lock.getVerificationCode(), false);
|
||||||
|
@ -422,7 +420,7 @@ public final class DomainLockUtilsTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_applyLock_alreadyLocked() {
|
void testFailure_applyLock_alreadyLocked() {
|
||||||
RegistryLock lock =
|
RegistryLock lock =
|
||||||
domainLockUtils.saveNewRegistryLockRequest(DOMAIN_NAME, "TheRegistrar", POC_ID, false);
|
domainLockUtils.saveNewRegistryLockRequest(DOMAIN_NAME, "TheRegistrar", POC_ID, false);
|
||||||
String verificationCode = lock.getVerificationCode();
|
String verificationCode = lock.getVerificationCode();
|
||||||
|
|
|
@ -17,23 +17,17 @@ package google.registry.tools;
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import org.junit.Rule;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.rules.TemporaryFolder;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
import org.junit.runners.JUnit4;
|
|
||||||
|
|
||||||
@RunWith(JUnit4.class)
|
/** Unit tests for {@link google.registry.tools.DumpGoldenSchemaCommand}. */
|
||||||
public class DumpGoldenSchemaCommandTest extends CommandTestCase<DumpGoldenSchemaCommand> {
|
class DumpGoldenSchemaCommandTest extends CommandTestCase<DumpGoldenSchemaCommand> {
|
||||||
|
|
||||||
@Rule public TemporaryFolder tmp = new TemporaryFolder();
|
DumpGoldenSchemaCommandTest() {}
|
||||||
|
|
||||||
public DumpGoldenSchemaCommandTest() {}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSchemaGeneration() throws Exception {
|
void testSchemaGeneration() throws Exception {
|
||||||
runCommand(
|
File schemaFile = tmpDir.resolve("golden.sql").toFile();
|
||||||
"--output=" + tmp.getRoot() + File.separatorChar + "golden.sql", "--start_postgresql");
|
runCommand("--output=" + schemaFile.toString(), "--start_postgresql");
|
||||||
assertThat(new File(tmp.getRoot(), "golden.sql").length()).isGreaterThan(1);
|
assertThat(schemaFile.length()).isGreaterThan(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,17 +22,16 @@ import com.google.common.io.Files;
|
||||||
import google.registry.rde.RdeTestData;
|
import google.registry.rde.RdeTestData;
|
||||||
import google.registry.testing.BouncyCastleProviderRule;
|
import google.registry.testing.BouncyCastleProviderRule;
|
||||||
import google.registry.testing.FakeKeyringModule;
|
import google.registry.testing.FakeKeyringModule;
|
||||||
import java.io.File;
|
import java.nio.file.Path;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Rule;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||||
|
|
||||||
/** Unit tests for {@link EncryptEscrowDepositCommand}. */
|
/** Unit tests for {@link EncryptEscrowDepositCommand}. */
|
||||||
public class EncryptEscrowDepositCommandTest
|
public class EncryptEscrowDepositCommandTest
|
||||||
extends CommandTestCase<EncryptEscrowDepositCommand> {
|
extends CommandTestCase<EncryptEscrowDepositCommand> {
|
||||||
|
|
||||||
@Rule
|
@RegisterExtension public final BouncyCastleProviderRule bouncy = new BouncyCastleProviderRule();
|
||||||
public final BouncyCastleProviderRule bouncy = new BouncyCastleProviderRule();
|
|
||||||
|
|
||||||
private final ByteSource depositXml = loadBytes(RdeTestData.class, "deposit_full.xml");
|
private final ByteSource depositXml = loadBytes(RdeTestData.class, "deposit_full.xml");
|
||||||
|
|
||||||
|
@ -43,21 +42,20 @@ public class EncryptEscrowDepositCommandTest
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void before() {
|
void beforeEach() {
|
||||||
command.encryptor = createEncryptor();
|
command.encryptor = createEncryptor();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess() throws Exception {
|
void testSuccess() throws Exception {
|
||||||
File outDir = tmpDir.newFolder();
|
Path depositFile = tmpDir.resolve("deposit.xml");
|
||||||
File depositFile = tmpDir.newFile("deposit.xml");
|
Files.write(depositXml.read(), depositFile.toFile());
|
||||||
Files.write(depositXml.read(), depositFile);
|
runCommand("--tld=lol", "--input=" + depositFile, "--outdir=" + tmpDir.toString());
|
||||||
runCommand(
|
assertThat(tmpDir.toFile().list())
|
||||||
"--tld=lol",
|
.asList()
|
||||||
"--input=" + depositFile.getPath(),
|
.containsExactly(
|
||||||
"--outdir=" + outDir.getPath());
|
"deposit.xml",
|
||||||
assertThat(outDir.list()).asList().containsExactly(
|
|
||||||
"lol_2010-10-17_full_S1_R0.ryde",
|
"lol_2010-10-17_full_S1_R0.ryde",
|
||||||
"lol_2010-10-17_full_S1_R0.sig",
|
"lol_2010-10-17_full_S1_R0.sig",
|
||||||
"lol.pub");
|
"lol.pub");
|
||||||
|
|
|
@ -22,22 +22,20 @@ import com.google.common.collect.ImmutableList;
|
||||||
import com.google.storage.onestore.v3.OnestoreEntity.EntityProto;
|
import com.google.storage.onestore.v3.OnestoreEntity.EntityProto;
|
||||||
import com.google.storage.onestore.v3.OnestoreEntity.Property;
|
import com.google.storage.onestore.v3.OnestoreEntity.Property;
|
||||||
import google.registry.testing.AppEngineRule;
|
import google.registry.testing.AppEngineRule;
|
||||||
import org.junit.Rule;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
import org.junit.runners.JUnit4;
|
|
||||||
|
|
||||||
@RunWith(JUnit4.class)
|
/** Unit tests for {@link EntityWrapper}. */
|
||||||
public final class EntityWrapperTest {
|
public final class EntityWrapperTest {
|
||||||
|
|
||||||
private static final String TEST_ENTITY_KIND = "TestEntity";
|
private static final String TEST_ENTITY_KIND = "TestEntity";
|
||||||
private static final int ARBITRARY_KEY_ID = 1001;
|
private static final int ARBITRARY_KEY_ID = 1001;
|
||||||
|
|
||||||
@Rule
|
@RegisterExtension
|
||||||
public final AppEngineRule appEngine = AppEngineRule.builder().withDatastoreAndCloudSql().build();
|
public final AppEngineRule appEngine = AppEngineRule.builder().withDatastoreAndCloudSql().build();
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testEquals() {
|
void testEquals() {
|
||||||
// Create an entity with a key and some properties.
|
// Create an entity with a key and some properties.
|
||||||
Entity entity = new Entity(TEST_ENTITY_KIND, ARBITRARY_KEY_ID);
|
Entity entity = new Entity(TEST_ENTITY_KIND, ARBITRARY_KEY_ID);
|
||||||
// Note that we need to specify these as long for property comparisons to work because that's
|
// Note that we need to specify these as long for property comparisons to work because that's
|
||||||
|
@ -73,7 +71,7 @@ public final class EntityWrapperTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDifferentPropertiesNotEqual() {
|
void testDifferentPropertiesNotEqual() {
|
||||||
Entity entity = new Entity(TEST_ENTITY_KIND, ARBITRARY_KEY_ID);
|
Entity entity = new Entity(TEST_ENTITY_KIND, ARBITRARY_KEY_ID);
|
||||||
// Note that we need to specify these as long for property comparisons to work because that's
|
// Note that we need to specify these as long for property comparisons to work because that's
|
||||||
// how they are deserialized from protos.
|
// how they are deserialized from protos.
|
||||||
|
@ -98,7 +96,7 @@ public final class EntityWrapperTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDifferentKeysNotEqual() {
|
void testDifferentKeysNotEqual() {
|
||||||
EntityProto proto1 =
|
EntityProto proto1 =
|
||||||
EntityTranslator.convertToPb(new Entity(TEST_ENTITY_KIND, ARBITRARY_KEY_ID));
|
EntityTranslator.convertToPb(new Entity(TEST_ENTITY_KIND, ARBITRARY_KEY_ID));
|
||||||
EntityProto proto2 =
|
EntityProto proto2 =
|
||||||
|
@ -115,7 +113,7 @@ public final class EntityWrapperTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testComparisonAgainstNonComparableEntities() {
|
void testComparisonAgainstNonComparableEntities() {
|
||||||
EntityWrapper ce = new EntityWrapper(new Entity(TEST_ENTITY_KIND, ARBITRARY_KEY_ID));
|
EntityWrapper ce = new EntityWrapper(new Entity(TEST_ENTITY_KIND, ARBITRARY_KEY_ID));
|
||||||
// Note: this has to be "isNotEqualTo()" and not isNotNull() because we want to test the
|
// Note: this has to be "isNotEqualTo()" and not isNotNull() because we want to test the
|
||||||
// equals() method and isNotNull() just checks for "ce != null".
|
// equals() method and isNotNull() just checks for "ce != null".
|
||||||
|
|
|
@ -21,7 +21,7 @@ import com.beust.jcommander.Parameter;
|
||||||
import com.beust.jcommander.Parameters;
|
import com.beust.jcommander.Parameters;
|
||||||
import google.registry.tools.server.ToolsTestData;
|
import google.registry.tools.server.ToolsTestData;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
/** Unit tests for {@link EppToolCommand}. */
|
/** Unit tests for {@link EppToolCommand}. */
|
||||||
public class EppToolCommandTest extends EppToolCommandTestCase<EppToolCommand> {
|
public class EppToolCommandTest extends EppToolCommandTestCase<EppToolCommand> {
|
||||||
|
@ -50,7 +50,7 @@ public class EppToolCommandTest extends EppToolCommandTestCase<EppToolCommand> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_singleXmlCommand() throws Exception {
|
void testSuccess_singleXmlCommand() throws Exception {
|
||||||
// The choice of xml file is arbitrary.
|
// The choice of xml file is arbitrary.
|
||||||
runCommandForced(
|
runCommandForced(
|
||||||
"--client=NewRegistrar",
|
"--client=NewRegistrar",
|
||||||
|
@ -59,7 +59,7 @@ public class EppToolCommandTest extends EppToolCommandTestCase<EppToolCommand> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_multipleXmlCommands() throws Exception {
|
void testSuccess_multipleXmlCommands() throws Exception {
|
||||||
// The choice of xml files is arbitrary.
|
// The choice of xml files is arbitrary.
|
||||||
runCommandForced(
|
runCommandForced(
|
||||||
"--client=NewRegistrar",
|
"--client=NewRegistrar",
|
||||||
|
@ -73,7 +73,7 @@ public class EppToolCommandTest extends EppToolCommandTestCase<EppToolCommand> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_nonexistentClientId() {
|
void testFailure_nonexistentClientId() {
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
|
|
|
@ -16,8 +16,8 @@ package google.registry.tools;
|
||||||
|
|
||||||
import static google.registry.testing.DatastoreHelper.createTlds;
|
import static google.registry.testing.DatastoreHelper.createTlds;
|
||||||
|
|
||||||
import org.junit.After;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Abstract class for commands that construct + send EPP commands.
|
* Abstract class for commands that construct + send EPP commands.
|
||||||
|
@ -31,15 +31,15 @@ public abstract class EppToolCommandTestCase<C extends EppToolCommand> extends C
|
||||||
|
|
||||||
EppToolVerifier eppVerifier;
|
EppToolVerifier eppVerifier;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void init() {
|
public void beforeEachEppToolCommandTestCase() {
|
||||||
// Create two TLDs for commands that allow multiple TLDs at once.
|
// Create two TLDs for commands that allow multiple TLDs at once.
|
||||||
createTlds("tld", "tld2");
|
createTlds("tld", "tld2");
|
||||||
eppVerifier = EppToolVerifier.create(command).expectClientId("NewRegistrar");
|
eppVerifier = EppToolVerifier.create(command).expectClientId("NewRegistrar");
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@AfterEach
|
||||||
public void cleanup() throws Exception {
|
public void afterEachEppToolCommandTestCase() throws Exception {
|
||||||
eppVerifier.verifyNoMoreSent();
|
eppVerifier.verifyNoMoreSent();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,7 +71,7 @@ public class EppToolVerifier {
|
||||||
*
|
*
|
||||||
* <p>Must be called at least once before any {@link #verifySent} calls.
|
* <p>Must be called at least once before any {@link #verifySent} calls.
|
||||||
*/
|
*/
|
||||||
public EppToolVerifier expectClientId(String clientId) {
|
EppToolVerifier expectClientId(String clientId) {
|
||||||
this.clientId = clientId;
|
this.clientId = clientId;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -81,7 +81,7 @@ public class EppToolVerifier {
|
||||||
*
|
*
|
||||||
* <p>If not called, {@link #verifySent} will expect the "superuser" flag to be false.
|
* <p>If not called, {@link #verifySent} will expect the "superuser" flag to be false.
|
||||||
*/
|
*/
|
||||||
public EppToolVerifier expectSuperuser() {
|
EppToolVerifier expectSuperuser() {
|
||||||
this.superuser = true;
|
this.superuser = true;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -91,7 +91,7 @@ public class EppToolVerifier {
|
||||||
*
|
*
|
||||||
* <p>If not called, {@link #verifySent} will expect the "dryRun" flag to be false.
|
* <p>If not called, {@link #verifySent} will expect the "dryRun" flag to be false.
|
||||||
*/
|
*/
|
||||||
public EppToolVerifier expectDryRun() {
|
EppToolVerifier expectDryRun() {
|
||||||
this.dryRun = true;
|
this.dryRun = true;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -141,7 +141,7 @@ public class EppToolVerifier {
|
||||||
*
|
*
|
||||||
* <p>If multiple EPPs are expected, the verifySent* call order must match the EPP order.
|
* <p>If multiple EPPs are expected, the verifySent* call order must match the EPP order.
|
||||||
*/
|
*/
|
||||||
public EppToolVerifier verifySentAny() throws Exception {
|
EppToolVerifier verifySentAny() throws Exception {
|
||||||
setArgumentsIfNeeded();
|
setArgumentsIfNeeded();
|
||||||
paramIndex++;
|
paramIndex++;
|
||||||
assertThat(capturedParams.size()).isAtLeast(paramIndex);
|
assertThat(capturedParams.size()).isAtLeast(paramIndex);
|
||||||
|
@ -151,7 +151,7 @@ public class EppToolVerifier {
|
||||||
/**
|
/**
|
||||||
* Test that no more EPPs were sent, after any that were expected in previous "verifySent" calls.
|
* Test that no more EPPs were sent, after any that were expected in previous "verifySent" calls.
|
||||||
*/
|
*/
|
||||||
public void verifyNoMoreSent() throws Exception {
|
void verifyNoMoreSent() throws Exception {
|
||||||
setArgumentsIfNeeded();
|
setArgumentsIfNeeded();
|
||||||
assertThat(
|
assertThat(
|
||||||
capturedParams
|
capturedParams
|
||||||
|
|
|
@ -20,48 +20,48 @@ import static org.junit.Assert.assertThrows;
|
||||||
import com.beust.jcommander.ParameterException;
|
import com.beust.jcommander.ParameterException;
|
||||||
import google.registry.tools.server.ToolsTestData;
|
import google.registry.tools.server.ToolsTestData;
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
/** Unit tests for {@link ExecuteEppCommand}. */
|
/** Unit tests for {@link ExecuteEppCommand}. */
|
||||||
public class ExecuteEppCommandTest extends EppToolCommandTestCase<ExecuteEppCommand> {
|
class ExecuteEppCommandTest extends EppToolCommandTestCase<ExecuteEppCommand> {
|
||||||
|
|
||||||
private String xmlInput;
|
private String xmlInput;
|
||||||
private String eppFile;
|
private String eppFile;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void initCommand() throws Exception {
|
void beforeEach() throws Exception {
|
||||||
xmlInput = ToolsTestData.loadFile("contact_create.xml");
|
xmlInput = ToolsTestData.loadFile("contact_create.xml");
|
||||||
eppFile = writeToNamedTmpFile("eppFile", xmlInput);
|
eppFile = writeToNamedTmpFile("eppFile", xmlInput);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess() throws Exception {
|
void testSuccess() throws Exception {
|
||||||
runCommand("--client=NewRegistrar", "--force", eppFile);
|
runCommand("--client=NewRegistrar", "--force", eppFile);
|
||||||
eppVerifier.verifySent("contact_create.xml");
|
eppVerifier.verifySent("contact_create.xml");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_dryRun() throws Exception {
|
void testSuccess_dryRun() throws Exception {
|
||||||
runCommand("--client=NewRegistrar", "--dry_run", eppFile);
|
runCommand("--client=NewRegistrar", "--dry_run", eppFile);
|
||||||
eppVerifier.expectDryRun().verifySent("contact_create.xml");
|
eppVerifier.expectDryRun().verifySent("contact_create.xml");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_withSuperuser() throws Exception {
|
void testSuccess_withSuperuser() throws Exception {
|
||||||
runCommand("--client=NewRegistrar", "--superuser", "--force", eppFile);
|
runCommand("--client=NewRegistrar", "--superuser", "--force", eppFile);
|
||||||
eppVerifier.expectSuperuser().verifySent("contact_create.xml");
|
eppVerifier.expectSuperuser().verifySent("contact_create.xml");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_fromStdin() throws Exception {
|
void testSuccess_fromStdin() throws Exception {
|
||||||
System.setIn(new ByteArrayInputStream(xmlInput.getBytes(UTF_8)));
|
System.setIn(new ByteArrayInputStream(xmlInput.getBytes(UTF_8)));
|
||||||
runCommand("--client=NewRegistrar", "--force");
|
runCommand("--client=NewRegistrar", "--force");
|
||||||
eppVerifier.verifySent("contact_create.xml");
|
eppVerifier.verifySent("contact_create.xml");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_multipleFiles() throws Exception {
|
void testSuccess_multipleFiles() throws Exception {
|
||||||
String xmlInput2 = ToolsTestData.loadFile("domain_check.xml");
|
String xmlInput2 = ToolsTestData.loadFile("domain_check.xml");
|
||||||
String eppFile2 = writeToNamedTmpFile("eppFile2", xmlInput2);
|
String eppFile2 = writeToNamedTmpFile("eppFile2", xmlInput2);
|
||||||
runCommand("--client=NewRegistrar", "--force", eppFile, eppFile2);
|
runCommand("--client=NewRegistrar", "--force", eppFile, eppFile2);
|
||||||
|
@ -71,19 +71,19 @@ public class ExecuteEppCommandTest extends EppToolCommandTestCase<ExecuteEppComm
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_missingClientId() {
|
void testFailure_missingClientId() {
|
||||||
assertThrows(ParameterException.class, () -> runCommand("--force", "foo.xml"));
|
assertThrows(ParameterException.class, () -> runCommand("--force", "foo.xml"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_forceAndDryRunIncompatible() {
|
void testFailure_forceAndDryRunIncompatible() {
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
() -> runCommand("--client=NewRegistrar", "--force", "--dry_run", eppFile));
|
() -> runCommand("--client=NewRegistrar", "--force", "--dry_run", eppFile));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_unknownFlag() {
|
void testFailure_unknownFlag() {
|
||||||
assertThrows(
|
assertThrows(
|
||||||
ParameterException.class,
|
ParameterException.class,
|
||||||
() -> runCommand("--client=NewRegistrar", "--unrecognized=foo", "--force", "foo.xml"));
|
() -> runCommand("--client=NewRegistrar", "--unrecognized=foo", "--force", "foo.xml"));
|
||||||
|
|
|
@ -26,6 +26,8 @@ import static org.joda.time.DateTimeZone.UTC;
|
||||||
import static org.junit.Assert.assertThrows;
|
import static org.junit.Assert.assertThrows;
|
||||||
import static org.mockito.Mockito.doThrow;
|
import static org.mockito.Mockito.doThrow;
|
||||||
import static org.mockito.Mockito.spy;
|
import static org.mockito.Mockito.spy;
|
||||||
|
import static org.mockito.Mockito.times;
|
||||||
|
import static org.mockito.Mockito.verify;
|
||||||
|
|
||||||
import com.beust.jcommander.ParameterException;
|
import com.beust.jcommander.ParameterException;
|
||||||
import com.google.appengine.tools.remoteapi.RemoteApiException;
|
import com.google.appengine.tools.remoteapi.RemoteApiException;
|
||||||
|
@ -50,30 +52,29 @@ import java.io.File;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.mockito.ArgumentMatchers;
|
import org.mockito.ArgumentMatchers;
|
||||||
|
|
||||||
/** Unit tests for {@link GenerateAllocationTokensCommand}. */
|
/** Unit tests for {@link GenerateAllocationTokensCommand}. */
|
||||||
public class GenerateAllocationTokensCommandTest
|
class GenerateAllocationTokensCommandTest extends CommandTestCase<GenerateAllocationTokensCommand> {
|
||||||
extends CommandTestCase<GenerateAllocationTokensCommand> {
|
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void init() {
|
void beforeEach() {
|
||||||
command.stringGenerator = new DeterministicStringGenerator(Alphabets.BASE_58);
|
command.stringGenerator = new DeterministicStringGenerator(Alphabets.BASE_58);
|
||||||
command.retrier =
|
command.retrier =
|
||||||
new Retrier(new FakeSleeper(new FakeClock(DateTime.parse("2000-01-01TZ"))), 3);
|
new Retrier(new FakeSleeper(new FakeClock(DateTime.parse("2000-01-01TZ"))), 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_oneToken() throws Exception {
|
void testSuccess_oneToken() throws Exception {
|
||||||
runCommand("--prefix", "blah", "--number", "1", "--length", "9");
|
runCommand("--prefix", "blah", "--number", "1", "--length", "9");
|
||||||
assertAllocationTokens(createToken("blah123456789", null, null));
|
assertAllocationTokens(createToken("blah123456789", null, null));
|
||||||
assertInStdout("blah123456789");
|
assertInStdout("blah123456789");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_threeTokens() throws Exception {
|
void testSuccess_threeTokens() throws Exception {
|
||||||
runCommand("--prefix", "foo", "--number", "3", "--length", "10");
|
runCommand("--prefix", "foo", "--number", "3", "--length", "10");
|
||||||
assertAllocationTokens(
|
assertAllocationTokens(
|
||||||
createToken("foo123456789A", null, null),
|
createToken("foo123456789A", null, null),
|
||||||
|
@ -83,28 +84,29 @@ public class GenerateAllocationTokensCommandTest
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_defaults() throws Exception {
|
void testSuccess_defaults() throws Exception {
|
||||||
runCommand("--number", "1");
|
runCommand("--number", "1");
|
||||||
assertAllocationTokens(createToken("123456789ABCDEFG", null, null));
|
assertAllocationTokens(createToken("123456789ABCDEFG", null, null));
|
||||||
assertInStdout("123456789ABCDEFG");
|
assertInStdout("123456789ABCDEFG");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_retry() throws Exception {
|
void testSuccess_retry() throws Exception {
|
||||||
GenerateAllocationTokensCommand spyCommand = spy(command);
|
command = spy(command);
|
||||||
RemoteApiException fakeException = new RemoteApiException("foo", "foo", "foo", new Exception());
|
RemoteApiException fakeException = new RemoteApiException("foo", "foo", "foo", new Exception());
|
||||||
doThrow(fakeException)
|
doThrow(fakeException)
|
||||||
.doThrow(fakeException)
|
.doThrow(fakeException)
|
||||||
.doCallRealMethod()
|
.doCallRealMethod()
|
||||||
.when(spyCommand)
|
.when(command)
|
||||||
.saveTokens(ArgumentMatchers.any());
|
.saveTokens(ArgumentMatchers.any());
|
||||||
runCommand("--number", "1");
|
runCommand("--number", "1");
|
||||||
assertAllocationTokens(createToken("123456789ABCDEFG", null, null));
|
assertAllocationTokens(createToken("123456789ABCDEFG", null, null));
|
||||||
assertInStdout("123456789ABCDEFG");
|
assertInStdout("123456789ABCDEFG");
|
||||||
|
verify(command, times(3)).saveTokens(ArgumentMatchers.any());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_tokenCollision() throws Exception {
|
void testSuccess_tokenCollision() throws Exception {
|
||||||
AllocationToken existingToken =
|
AllocationToken existingToken =
|
||||||
persistResource(
|
persistResource(
|
||||||
new AllocationToken.Builder()
|
new AllocationToken.Builder()
|
||||||
|
@ -117,14 +119,14 @@ public class GenerateAllocationTokensCommandTest
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_dryRun_outputsButDoesntSave() throws Exception {
|
void testSuccess_dryRun_outputsButDoesntSave() throws Exception {
|
||||||
runCommand("--prefix", "foo", "--number", "2", "--length", "10", "--dry_run");
|
runCommand("--prefix", "foo", "--number", "2", "--length", "10", "--dry_run");
|
||||||
assertAllocationTokens();
|
assertAllocationTokens();
|
||||||
assertInStdout("foo123456789A\nfooBCDEFGHJKL");
|
assertInStdout("foo123456789A\nfooBCDEFGHJKL");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_largeNumberOfTokens() throws Exception {
|
void testSuccess_largeNumberOfTokens() throws Exception {
|
||||||
command.stringGenerator =
|
command.stringGenerator =
|
||||||
new DeterministicStringGenerator(Alphabets.BASE_58, Rule.PREPEND_COUNTER);
|
new DeterministicStringGenerator(Alphabets.BASE_58, Rule.PREPEND_COUNTER);
|
||||||
runCommand("--prefix", "ooo", "--number", "100", "--length", "16");
|
runCommand("--prefix", "ooo", "--number", "100", "--length", "16");
|
||||||
|
@ -134,9 +136,9 @@ public class GenerateAllocationTokensCommandTest
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_domainNames() throws Exception {
|
void testSuccess_domainNames() throws Exception {
|
||||||
createTld("tld");
|
createTld("tld");
|
||||||
File domainNamesFile = tmpDir.newFile("domain_names.txt");
|
File domainNamesFile = tmpDir.resolve("domain_names.txt").toFile();
|
||||||
Files.asCharSink(domainNamesFile, UTF_8).write("foo1.tld\nboo2.tld\nbaz9.tld\n");
|
Files.asCharSink(domainNamesFile, UTF_8).write("foo1.tld\nboo2.tld\nbaz9.tld\n");
|
||||||
runCommand("--domain_names_file", domainNamesFile.getPath());
|
runCommand("--domain_names_file", domainNamesFile.getPath());
|
||||||
assertAllocationTokens(
|
assertAllocationTokens(
|
||||||
|
@ -148,7 +150,7 @@ public class GenerateAllocationTokensCommandTest
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_promotionToken() throws Exception {
|
void testSuccess_promotionToken() throws Exception {
|
||||||
DateTime promoStart = DateTime.now(UTC);
|
DateTime promoStart = DateTime.now(UTC);
|
||||||
DateTime promoEnd = promoStart.plusMonths(1);
|
DateTime promoEnd = promoStart.plusMonths(1);
|
||||||
runCommand(
|
runCommand(
|
||||||
|
@ -178,14 +180,14 @@ public class GenerateAllocationTokensCommandTest
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_specifyTokens() throws Exception {
|
void testSuccess_specifyTokens() throws Exception {
|
||||||
runCommand("--tokens", "foobar,foobaz");
|
runCommand("--tokens", "foobar,foobaz");
|
||||||
assertAllocationTokens(createToken("foobar", null, null), createToken("foobaz", null, null));
|
assertAllocationTokens(createToken("foobar", null, null), createToken("foobaz", null, null));
|
||||||
assertInStdout("foobar", "foobaz");
|
assertInStdout("foobar", "foobaz");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_specifyManyTokens() throws Exception {
|
void testSuccess_specifyManyTokens() throws Exception {
|
||||||
command.stringGenerator =
|
command.stringGenerator =
|
||||||
new DeterministicStringGenerator(Alphabets.BASE_58, Rule.PREPEND_COUNTER);
|
new DeterministicStringGenerator(Alphabets.BASE_58, Rule.PREPEND_COUNTER);
|
||||||
Collection<String> sampleTokens = command.stringGenerator.createStrings(13, 100);
|
Collection<String> sampleTokens = command.stringGenerator.createStrings(13, 100);
|
||||||
|
@ -195,7 +197,7 @@ public class GenerateAllocationTokensCommandTest
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_mustSpecifyNumberOfTokensOrDomainsFile() {
|
void testFailure_mustSpecifyNumberOfTokensOrDomainsFile() {
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(IllegalArgumentException.class, () -> runCommand("--prefix", "FEET"));
|
assertThrows(IllegalArgumentException.class, () -> runCommand("--prefix", "FEET"));
|
||||||
assertThat(thrown)
|
assertThat(thrown)
|
||||||
|
@ -204,7 +206,7 @@ public class GenerateAllocationTokensCommandTest
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_mustNotSpecifyBothNumberOfTokensAndDomainsFile() {
|
void testFailure_mustNotSpecifyBothNumberOfTokensAndDomainsFile() {
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
|
@ -219,7 +221,7 @@ public class GenerateAllocationTokensCommandTest
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_mustNotSpecifyBothNumberOfTokensAndTokenStrings() {
|
void testFailure_mustNotSpecifyBothNumberOfTokensAndTokenStrings() {
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
|
@ -234,7 +236,7 @@ public class GenerateAllocationTokensCommandTest
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_mustNotSpecifyBothTokenStringsAndDomainsFile() {
|
void testFailure_mustNotSpecifyBothTokenStringsAndDomainsFile() {
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
|
@ -249,9 +251,9 @@ public class GenerateAllocationTokensCommandTest
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_specifiesAlreadyExistingToken() throws Exception {
|
void testFailure_specifiesAlreadyExistingToken() throws Exception {
|
||||||
runCommand("--tokens", "foobar");
|
runCommand("--tokens", "foobar");
|
||||||
beforeCommandTestCase(); // reset the command variables
|
beforeEachCommandTestCase(); // reset the command variables
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(IllegalArgumentException.class, () -> runCommand("--tokens", "foobar,foobaz"));
|
assertThrows(IllegalArgumentException.class, () -> runCommand("--tokens", "foobar,foobaz"));
|
||||||
assertThat(thrown)
|
assertThat(thrown)
|
||||||
|
@ -260,7 +262,7 @@ public class GenerateAllocationTokensCommandTest
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_invalidTokenType() {
|
void testFailure_invalidTokenType() {
|
||||||
ParameterException thrown =
|
ParameterException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
ParameterException.class,
|
ParameterException.class,
|
||||||
|
@ -271,7 +273,7 @@ public class GenerateAllocationTokensCommandTest
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_invalidTokenStatusTransition() {
|
void testFailure_invalidTokenStatusTransition() {
|
||||||
assertThat(
|
assertThat(
|
||||||
assertThrows(
|
assertThrows(
|
||||||
ParameterException.class,
|
ParameterException.class,
|
||||||
|
@ -286,7 +288,7 @@ public class GenerateAllocationTokensCommandTest
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_lengthOfZero() {
|
void testFailure_lengthOfZero() {
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
|
@ -298,7 +300,7 @@ public class GenerateAllocationTokensCommandTest
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_unlimitedUseMustHaveTransitions() {
|
void testFailure_unlimitedUseMustHaveTransitions() {
|
||||||
assertThat(
|
assertThat(
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
|
|
|
@ -41,21 +41,15 @@ import java.io.IOException;
|
||||||
import java.io.Reader;
|
import java.io.Reader;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
import org.json.simple.JSONValue;
|
import org.json.simple.JSONValue;
|
||||||
import org.json.simple.parser.ParseException;
|
import org.json.simple.parser.ParseException;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Rule;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.rules.TemporaryFolder;
|
|
||||||
|
|
||||||
/** Unit tests for {@link GenerateDnsReportCommand}. */
|
/** Unit tests for {@link GenerateDnsReportCommand}. */
|
||||||
public class GenerateDnsReportCommandTest extends CommandTestCase<GenerateDnsReportCommand> {
|
class GenerateDnsReportCommandTest extends CommandTestCase<GenerateDnsReportCommand> {
|
||||||
|
|
||||||
@Rule
|
|
||||||
public final TemporaryFolder folder = new TemporaryFolder();
|
|
||||||
|
|
||||||
private final DateTime now = DateTime.now(UTC);
|
private final DateTime now = DateTime.now(UTC);
|
||||||
private final FakeClock clock = new FakeClock();
|
private final FakeClock clock = new FakeClock();
|
||||||
|
@ -120,9 +114,9 @@ public class GenerateDnsReportCommandTest extends CommandTestCase<GenerateDnsRep
|
||||||
"192.168.1.1",
|
"192.168.1.1",
|
||||||
"2607:f8b0:400d:c00:0:0:0:c1"));
|
"2607:f8b0:400d:c00:0:0:0:c1"));
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void init() throws Exception {
|
void beforeEach() throws Exception {
|
||||||
output = Paths.get(folder.newFile().toString());
|
output = tmpDir.resolve("out.dat");
|
||||||
command.clock = clock;
|
command.clock = clock;
|
||||||
clock.setTo(now);
|
clock.setTo(now);
|
||||||
|
|
||||||
|
@ -165,7 +159,7 @@ public class GenerateDnsReportCommandTest extends CommandTestCase<GenerateDnsRep
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess() throws Exception {
|
void testSuccess() throws Exception {
|
||||||
runCommand("--output=" + output, "--tld=xn--q9jyb4c");
|
runCommand("--output=" + output, "--tld=xn--q9jyb4c");
|
||||||
Iterable<?> output = (Iterable<?>) getOutputAsJson();
|
Iterable<?> output = (Iterable<?>) getOutputAsJson();
|
||||||
assertThat(output).containsAnyOf(DOMAIN1_OUTPUT, DOMAIN1_OUTPUT_ALT);
|
assertThat(output).containsAnyOf(DOMAIN1_OUTPUT, DOMAIN1_OUTPUT_ALT);
|
||||||
|
@ -173,7 +167,7 @@ public class GenerateDnsReportCommandTest extends CommandTestCase<GenerateDnsRep
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_skipDeletedDomain() throws Exception {
|
void testSuccess_skipDeletedDomain() throws Exception {
|
||||||
persistResource(domain1.asBuilder().setDeletionTime(now).build());
|
persistResource(domain1.asBuilder().setDeletionTime(now).build());
|
||||||
runCommand("--output=" + output, "--tld=xn--q9jyb4c");
|
runCommand("--output=" + output, "--tld=xn--q9jyb4c");
|
||||||
assertThat((Iterable<?>) getOutputAsJson())
|
assertThat((Iterable<?>) getOutputAsJson())
|
||||||
|
@ -181,7 +175,7 @@ public class GenerateDnsReportCommandTest extends CommandTestCase<GenerateDnsRep
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_skipDeletedNameserver() throws Exception {
|
void testSuccess_skipDeletedNameserver() throws Exception {
|
||||||
persistResource(nameserver1.asBuilder().setDeletionTime(now).build());
|
persistResource(nameserver1.asBuilder().setDeletionTime(now).build());
|
||||||
runCommand("--output=" + output, "--tld=xn--q9jyb4c");
|
runCommand("--output=" + output, "--tld=xn--q9jyb4c");
|
||||||
Iterable<?> output = (Iterable<?>) getOutputAsJson();
|
Iterable<?> output = (Iterable<?>) getOutputAsJson();
|
||||||
|
@ -190,7 +184,7 @@ public class GenerateDnsReportCommandTest extends CommandTestCase<GenerateDnsRep
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_skipClientHoldDomain() throws Exception {
|
void testSuccess_skipClientHoldDomain() throws Exception {
|
||||||
persistResource(domain1.asBuilder().addStatusValue(StatusValue.CLIENT_HOLD).build());
|
persistResource(domain1.asBuilder().addStatusValue(StatusValue.CLIENT_HOLD).build());
|
||||||
runCommand("--output=" + output, "--tld=xn--q9jyb4c");
|
runCommand("--output=" + output, "--tld=xn--q9jyb4c");
|
||||||
assertThat((Iterable<?>) getOutputAsJson())
|
assertThat((Iterable<?>) getOutputAsJson())
|
||||||
|
@ -198,7 +192,7 @@ public class GenerateDnsReportCommandTest extends CommandTestCase<GenerateDnsRep
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_skipServerHoldDomain() throws Exception {
|
void testSuccess_skipServerHoldDomain() throws Exception {
|
||||||
persistResource(domain1.asBuilder().addStatusValue(StatusValue.SERVER_HOLD).build());
|
persistResource(domain1.asBuilder().addStatusValue(StatusValue.SERVER_HOLD).build());
|
||||||
runCommand("--output=" + output, "--tld=xn--q9jyb4c");
|
runCommand("--output=" + output, "--tld=xn--q9jyb4c");
|
||||||
assertThat((Iterable<?>) getOutputAsJson())
|
assertThat((Iterable<?>) getOutputAsJson())
|
||||||
|
@ -206,7 +200,7 @@ public class GenerateDnsReportCommandTest extends CommandTestCase<GenerateDnsRep
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_skipPendingDeleteDomain() throws Exception {
|
void testSuccess_skipPendingDeleteDomain() throws Exception {
|
||||||
persistResource(
|
persistResource(
|
||||||
domain1
|
domain1
|
||||||
.asBuilder()
|
.asBuilder()
|
||||||
|
@ -219,7 +213,7 @@ public class GenerateDnsReportCommandTest extends CommandTestCase<GenerateDnsRep
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_skipDomainsWithoutNameservers() throws Exception {
|
void testSuccess_skipDomainsWithoutNameservers() throws Exception {
|
||||||
persistResource(domain1.asBuilder().setNameservers(ImmutableSet.of()).build());
|
persistResource(domain1.asBuilder().setNameservers(ImmutableSet.of()).build());
|
||||||
runCommand("--output=" + output, "--tld=xn--q9jyb4c");
|
runCommand("--output=" + output, "--tld=xn--q9jyb4c");
|
||||||
assertThat((Iterable<?>) getOutputAsJson())
|
assertThat((Iterable<?>) getOutputAsJson())
|
||||||
|
@ -227,12 +221,12 @@ public class GenerateDnsReportCommandTest extends CommandTestCase<GenerateDnsRep
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_tldDoesNotExist() {
|
void testFailure_tldDoesNotExist() {
|
||||||
assertThrows(IllegalArgumentException.class, () -> runCommand("--tld=foobar"));
|
assertThrows(IllegalArgumentException.class, () -> runCommand("--tld=foobar"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_missingTldParameter() {
|
void testFailure_missingTldParameter() {
|
||||||
assertThrows(ParameterException.class, () -> runCommand(""));
|
assertThrows(ParameterException.class, () -> runCommand(""));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,21 +26,24 @@ import google.registry.testing.InjectRule;
|
||||||
import google.registry.testing.TaskQueueHelper.TaskMatcher;
|
import google.registry.testing.TaskQueueHelper.TaskMatcher;
|
||||||
import google.registry.util.AppEngineServiceUtils;
|
import google.registry.util.AppEngineServiceUtils;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Rule;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
|
import org.mockito.junit.jupiter.MockitoSettings;
|
||||||
|
import org.mockito.quality.Strictness;
|
||||||
|
|
||||||
/** Unit tests for {@link GenerateEscrowDepositCommand}. */
|
/** Unit tests for {@link GenerateEscrowDepositCommand}. */
|
||||||
|
@MockitoSettings(strictness = Strictness.LENIENT)
|
||||||
public class GenerateEscrowDepositCommandTest
|
public class GenerateEscrowDepositCommandTest
|
||||||
extends CommandTestCase<GenerateEscrowDepositCommand> {
|
extends CommandTestCase<GenerateEscrowDepositCommand> {
|
||||||
|
|
||||||
@Rule public final InjectRule inject = new InjectRule();
|
@RegisterExtension public final InjectRule inject = new InjectRule();
|
||||||
|
|
||||||
@Mock AppEngineServiceUtils appEngineServiceUtils;
|
@Mock AppEngineServiceUtils appEngineServiceUtils;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void before() {
|
void beforeEach() {
|
||||||
createTld("tld");
|
createTld("tld");
|
||||||
createTld("anothertld");
|
createTld("anothertld");
|
||||||
command = new GenerateEscrowDepositCommand();
|
command = new GenerateEscrowDepositCommand();
|
||||||
|
@ -52,7 +55,7 @@ public class GenerateEscrowDepositCommandTest
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCommand_missingTld() {
|
void testCommand_missingTld() {
|
||||||
ParameterException thrown =
|
ParameterException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
ParameterException.class,
|
ParameterException.class,
|
||||||
|
@ -62,7 +65,7 @@ public class GenerateEscrowDepositCommandTest
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCommand_emptyTld() {
|
void testCommand_emptyTld() {
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
|
@ -77,7 +80,7 @@ public class GenerateEscrowDepositCommandTest
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCommand_invalidTld() {
|
void testCommand_invalidTld() {
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
|
@ -92,7 +95,7 @@ public class GenerateEscrowDepositCommandTest
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCommand_missingWatermark() {
|
void testCommand_missingWatermark() {
|
||||||
ParameterException thrown =
|
ParameterException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
ParameterException.class,
|
ParameterException.class,
|
||||||
|
@ -103,7 +106,7 @@ public class GenerateEscrowDepositCommandTest
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCommand_emptyWatermark() {
|
void testCommand_emptyWatermark() {
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
|
@ -112,7 +115,7 @@ public class GenerateEscrowDepositCommandTest
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCommand_missingOutdir() {
|
void testCommand_missingOutdir() {
|
||||||
ParameterException thrown =
|
ParameterException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
ParameterException.class,
|
ParameterException.class,
|
||||||
|
@ -123,7 +126,7 @@ public class GenerateEscrowDepositCommandTest
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCommand_emptyOutdir() {
|
void testCommand_emptyOutdir() {
|
||||||
ParameterException thrown =
|
ParameterException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
ParameterException.class,
|
ParameterException.class,
|
||||||
|
@ -138,7 +141,7 @@ public class GenerateEscrowDepositCommandTest
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCommand_invalidWatermark() {
|
void testCommand_invalidWatermark() {
|
||||||
ParameterException thrown =
|
ParameterException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
ParameterException.class,
|
ParameterException.class,
|
||||||
|
@ -153,7 +156,7 @@ public class GenerateEscrowDepositCommandTest
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCommand_invalidMode() {
|
void testCommand_invalidMode() {
|
||||||
ParameterException thrown =
|
ParameterException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
ParameterException.class,
|
ParameterException.class,
|
||||||
|
@ -170,7 +173,7 @@ public class GenerateEscrowDepositCommandTest
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCommand_invalidRevision() {
|
void testCommand_invalidRevision() {
|
||||||
ParameterException thrown =
|
ParameterException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
ParameterException.class,
|
ParameterException.class,
|
||||||
|
@ -185,7 +188,7 @@ public class GenerateEscrowDepositCommandTest
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCommand_success() throws Exception {
|
void testCommand_success() throws Exception {
|
||||||
runCommand("--tld=tld", "--watermark=2017-01-01T00:00:00Z", "--mode=thin", "-r 42", "-o test");
|
runCommand("--tld=tld", "--watermark=2017-01-01T00:00:00Z", "--mode=thin", "-r 42", "-o test");
|
||||||
|
|
||||||
assertTasksEnqueued(
|
assertTasksEnqueued(
|
||||||
|
@ -202,7 +205,7 @@ public class GenerateEscrowDepositCommandTest
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCommand_successWithDefaultRevision() throws Exception {
|
void testCommand_successWithDefaultRevision() throws Exception {
|
||||||
runCommand("--tld=tld", "--watermark=2017-01-01T00:00:00Z", "--mode=thin", "-o test");
|
runCommand("--tld=tld", "--watermark=2017-01-01T00:00:00Z", "--mode=thin", "-o test");
|
||||||
|
|
||||||
assertTasksEnqueued(
|
assertTasksEnqueued(
|
||||||
|
@ -218,7 +221,7 @@ public class GenerateEscrowDepositCommandTest
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCommand_successWithDefaultMode() throws Exception {
|
void testCommand_successWithDefaultMode() throws Exception {
|
||||||
runCommand("--tld=tld", "--watermark=2017-01-01T00:00:00Z", "-r=42", "-o test");
|
runCommand("--tld=tld", "--watermark=2017-01-01T00:00:00Z", "-r=42", "-o test");
|
||||||
|
|
||||||
assertTasksEnqueued(
|
assertTasksEnqueued(
|
||||||
|
@ -235,7 +238,7 @@ public class GenerateEscrowDepositCommandTest
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCommand_successWithMultipleArgumentValues() throws Exception {
|
void testCommand_successWithMultipleArgumentValues() throws Exception {
|
||||||
runCommand(
|
runCommand(
|
||||||
"--tld=tld,anothertld",
|
"--tld=tld,anothertld",
|
||||||
"--watermark=2017-01-01T00:00:00Z,2017-01-02T00:00:00Z",
|
"--watermark=2017-01-01T00:00:00Z,2017-01-02T00:00:00Z",
|
||||||
|
|
|
@ -22,60 +22,54 @@ import com.google.common.io.Files;
|
||||||
import com.google.common.io.Resources;
|
import com.google.common.io.Resources;
|
||||||
import google.registry.persistence.NomulusPostgreSql;
|
import google.registry.persistence.NomulusPostgreSql;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import org.junit.Before;
|
import java.nio.file.Path;
|
||||||
import org.junit.ClassRule;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Rule;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.rules.TemporaryFolder;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
import org.junit.runners.JUnit4;
|
|
||||||
import org.testcontainers.containers.PostgreSQLContainer;
|
import org.testcontainers.containers.PostgreSQLContainer;
|
||||||
|
import org.testcontainers.junit.jupiter.Container;
|
||||||
|
import org.testcontainers.junit.jupiter.Testcontainers;
|
||||||
|
|
||||||
/** Unit tests for {@link GenerateSqlSchemaCommand}. */
|
/** Unit tests for {@link GenerateSqlSchemaCommand}. */
|
||||||
@RunWith(JUnit4.class)
|
@Testcontainers
|
||||||
public class GenerateSqlSchemaCommandTest extends CommandTestCase<GenerateSqlSchemaCommand> {
|
class GenerateSqlSchemaCommandTest extends CommandTestCase<GenerateSqlSchemaCommand> {
|
||||||
|
|
||||||
private String containerHostName;
|
private String containerHostName;
|
||||||
private int containerPort;
|
private int containerPort;
|
||||||
|
|
||||||
@Rule public TemporaryFolder tmp = new TemporaryFolder();
|
@Container
|
||||||
|
private static PostgreSQLContainer postgres =
|
||||||
@ClassRule
|
|
||||||
public static PostgreSQLContainer postgres =
|
|
||||||
new PostgreSQLContainer(NomulusPostgreSql.getDockerTag())
|
new PostgreSQLContainer(NomulusPostgreSql.getDockerTag())
|
||||||
.withDatabaseName("postgres")
|
.withDatabaseName("postgres")
|
||||||
.withUsername("postgres")
|
.withUsername("postgres")
|
||||||
.withPassword("domain-registry");
|
.withPassword("domain-registry");
|
||||||
|
|
||||||
public GenerateSqlSchemaCommandTest() {}
|
@BeforeEach
|
||||||
|
void beforeEach() {
|
||||||
@Before
|
|
||||||
public void setUp() {
|
|
||||||
containerHostName = postgres.getContainerIpAddress();
|
containerHostName = postgres.getContainerIpAddress();
|
||||||
containerPort = postgres.getMappedPort(GenerateSqlSchemaCommand.POSTGRESQL_PORT);
|
containerPort = postgres.getMappedPort(GenerateSqlSchemaCommand.POSTGRESQL_PORT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSchemaGeneration() throws Exception {
|
void testSchemaGeneration() throws Exception {
|
||||||
runCommand(
|
runCommand(
|
||||||
"--out_file=" + tmp.getRoot() + File.separatorChar + "schema.sql",
|
"--out_file=" + tmpDir.resolve("schema.sql").toString(),
|
||||||
"--db_host=" + containerHostName,
|
"--db_host=" + containerHostName,
|
||||||
"--db_port=" + containerPort);
|
"--db_port=" + containerPort);
|
||||||
|
|
||||||
// We don't verify the exact contents of the result SQL file because that would be too brittle,
|
// We don't verify the exact contents of the result SQL file because that would be too brittle,
|
||||||
// but we check to make sure that a couple parts of it are named as we expect them to be
|
// but we check to make sure that a couple parts of it are named as we expect them to be
|
||||||
// TODO: try running the schema against the test database.
|
// TODO: try running the schema against the test database.
|
||||||
File sqlFile = new File(tmp.getRoot(), "schema.sql");
|
File schemaFile = tmpDir.resolve("schema.sql").toFile();
|
||||||
assertThat(sqlFile.exists()).isTrue();
|
assertThat(schemaFile.exists()).isTrue();
|
||||||
String fileContent = Files.asCharSource(sqlFile, UTF_8).read();
|
String fileContent = Files.asCharSource(schemaFile, UTF_8).read();
|
||||||
assertThat(fileContent).contains("create table \"Domain\" (");
|
assertThat(fileContent).contains("create table \"Domain\" (");
|
||||||
assertThat(fileContent).contains("repo_id text not null,");
|
assertThat(fileContent).contains("repo_id text not null,");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIncompatibleFlags() throws Exception {
|
void testIncompatibleFlags() throws Exception {
|
||||||
runCommand(
|
runCommand(
|
||||||
"--out_file=" + tmp.getRoot() + File.separatorChar + "schema.sql",
|
"--out_file=" + tmpDir.resolve("schema.sql").toString(),
|
||||||
"--db_host=" + containerHostName,
|
"--db_host=" + containerHostName,
|
||||||
"--db_port=" + containerPort,
|
"--db_port=" + containerPort,
|
||||||
"--start_postgresql");
|
"--start_postgresql");
|
||||||
|
@ -83,17 +77,17 @@ public class GenerateSqlSchemaCommandTest extends CommandTestCase<GenerateSqlSch
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDockerPostgresql() throws Exception {
|
void testDockerPostgresql() throws Exception {
|
||||||
runCommand(
|
Path schemaFile = tmpDir.resolve("schema.sql");
|
||||||
"--start_postgresql", "--out_file=" + tmp.getRoot() + File.separatorChar + "schema.sql");
|
runCommand("--start_postgresql", "--out_file=" + schemaFile.toString());
|
||||||
assertThat(new File(tmp.getRoot(), "schema.sql").exists()).isTrue();
|
assertThat(schemaFile.toFile().exists()).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void validateGeneratedSchemaIsSameAsSchemaInFile() throws Exception {
|
void validateGeneratedSchemaIsSameAsSchemaInFile() throws Exception {
|
||||||
runCommand(
|
Path schemaFile = tmpDir.resolve("schema.sql");
|
||||||
"--start_postgresql", "--out_file=" + tmp.getRoot() + File.separatorChar + "schema.sql");
|
runCommand("--start_postgresql", "--out_file=" + schemaFile.toString());
|
||||||
assertThat(new File(tmp.getRoot(), "schema.sql").toURI().toURL())
|
assertThat(schemaFile.toFile().toURI().toURL())
|
||||||
.hasSameContentAs(Resources.getResource("sql/schema/db-schema.sql.generated"));
|
.hasSameContentAs(Resources.getResource("sql/schema/db-schema.sql.generated"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,13 +29,13 @@ import com.googlecode.objectify.Key;
|
||||||
import google.registry.model.domain.DomainBase;
|
import google.registry.model.domain.DomainBase;
|
||||||
import google.registry.model.domain.token.AllocationToken;
|
import google.registry.model.domain.token.AllocationToken;
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
/** Unit tests for {@link GetAllocationTokenCommand}. */
|
/** Unit tests for {@link GetAllocationTokenCommand}. */
|
||||||
public class GetAllocationTokenCommandTest extends CommandTestCase<GetAllocationTokenCommand> {
|
class GetAllocationTokenCommandTest extends CommandTestCase<GetAllocationTokenCommand> {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_oneToken() throws Exception {
|
void testSuccess_oneToken() throws Exception {
|
||||||
createTlds("bar");
|
createTlds("bar");
|
||||||
AllocationToken token =
|
AllocationToken token =
|
||||||
persistResource(
|
persistResource(
|
||||||
|
@ -49,7 +49,7 @@ public class GetAllocationTokenCommandTest extends CommandTestCase<GetAllocation
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_multipleTokens() throws Exception {
|
void testSuccess_multipleTokens() throws Exception {
|
||||||
createTlds("baz");
|
createTlds("baz");
|
||||||
ImmutableList<AllocationToken> tokens =
|
ImmutableList<AllocationToken> tokens =
|
||||||
persistSimpleResources(
|
persistSimpleResources(
|
||||||
|
@ -73,7 +73,7 @@ public class GetAllocationTokenCommandTest extends CommandTestCase<GetAllocation
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_redeemedToken() throws Exception {
|
void testSuccess_redeemedToken() throws Exception {
|
||||||
createTld("tld");
|
createTld("tld");
|
||||||
DomainBase domain =
|
DomainBase domain =
|
||||||
persistActiveDomain("fqqdn.tld", DateTime.parse("2016-04-07T22:19:17.044Z"));
|
persistActiveDomain("fqqdn.tld", DateTime.parse("2016-04-07T22:19:17.044Z"));
|
||||||
|
@ -92,7 +92,7 @@ public class GetAllocationTokenCommandTest extends CommandTestCase<GetAllocation
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_oneTokenDoesNotExist() throws Exception {
|
void testSuccess_oneTokenDoesNotExist() throws Exception {
|
||||||
createTlds("bar");
|
createTlds("bar");
|
||||||
AllocationToken token =
|
AllocationToken token =
|
||||||
persistResource(
|
persistResource(
|
||||||
|
@ -107,7 +107,7 @@ public class GetAllocationTokenCommandTest extends CommandTestCase<GetAllocation
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_noAllocationTokensSpecified() {
|
void testFailure_noAllocationTokensSpecified() {
|
||||||
assertThrows(ParameterException.class, this::runCommand);
|
assertThrows(ParameterException.class, this::runCommand);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,23 +24,23 @@ import google.registry.model.tmch.ClaimsListShard;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
/** Unit tests for {@link GetClaimsListCommand}. */
|
/** Unit tests for {@link GetClaimsListCommand}. */
|
||||||
public class GetClaimsListCommandTest extends CommandTestCase<GetClaimsListCommand> {
|
class GetClaimsListCommandTest extends CommandTestCase<GetClaimsListCommand> {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_getWorks() throws Exception {
|
void testSuccess_getWorks() throws Exception {
|
||||||
ClaimsListShard.create(DateTime.now(UTC), ImmutableMap.of("a", "1", "b", "2")).save();
|
ClaimsListShard.create(DateTime.now(UTC), ImmutableMap.of("a", "1", "b", "2")).save();
|
||||||
File output = tmpDir.newFile();
|
File output = tmpDir.resolve("claims.txt").toFile();
|
||||||
runCommand("--output=" + output.getAbsolutePath());
|
runCommand("--output=" + output.getAbsolutePath());
|
||||||
assertThat(readAllLines(output.toPath(), UTF_8)).containsExactly("a,1", "b,2");
|
assertThat(readAllLines(output.toPath(), UTF_8)).containsExactly("a,1", "b,2");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_endsWithNewline() throws Exception {
|
void testSuccess_endsWithNewline() throws Exception {
|
||||||
ClaimsListShard.create(DateTime.now(UTC), ImmutableMap.of("a", "1")).save();
|
ClaimsListShard.create(DateTime.now(UTC), ImmutableMap.of("a", "1")).save();
|
||||||
File output = tmpDir.newFile();
|
File output = tmpDir.resolve("claims.txt").toFile();
|
||||||
runCommand("--output=" + output.getAbsolutePath());
|
runCommand("--output=" + output.getAbsolutePath());
|
||||||
assertThat(new String(Files.readAllBytes(output.toPath()), UTF_8)).endsWith("\n");
|
assertThat(new String(Files.readAllBytes(output.toPath()), UTF_8)).endsWith("\n");
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,21 +24,21 @@ import static org.junit.Assert.assertThrows;
|
||||||
|
|
||||||
import com.beust.jcommander.ParameterException;
|
import com.beust.jcommander.ParameterException;
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
/** Unit tests for {@link GetContactCommand}. */
|
/** Unit tests for {@link GetContactCommand}. */
|
||||||
public class GetContactCommandTest extends CommandTestCase<GetContactCommand> {
|
class GetContactCommandTest extends CommandTestCase<GetContactCommand> {
|
||||||
|
|
||||||
DateTime now = DateTime.now(UTC);
|
private DateTime now = DateTime.now(UTC);
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void initialize() {
|
void beforeEach() {
|
||||||
createTld("tld");
|
createTld("tld");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess() throws Exception {
|
void testSuccess() throws Exception {
|
||||||
persistActiveContact("sh8013");
|
persistActiveContact("sh8013");
|
||||||
runCommand("sh8013");
|
runCommand("sh8013");
|
||||||
assertInStdout("contactId=sh8013");
|
assertInStdout("contactId=sh8013");
|
||||||
|
@ -46,7 +46,7 @@ public class GetContactCommandTest extends CommandTestCase<GetContactCommand> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_expand() throws Exception {
|
void testSuccess_expand() throws Exception {
|
||||||
persistActiveContact("sh8013");
|
persistActiveContact("sh8013");
|
||||||
runCommand("sh8013", "--expand");
|
runCommand("sh8013", "--expand");
|
||||||
assertInStdout("contactId=sh8013");
|
assertInStdout("contactId=sh8013");
|
||||||
|
@ -55,7 +55,7 @@ public class GetContactCommandTest extends CommandTestCase<GetContactCommand> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_multipleArguments() throws Exception {
|
void testSuccess_multipleArguments() throws Exception {
|
||||||
persistActiveContact("sh8013");
|
persistActiveContact("sh8013");
|
||||||
persistActiveContact("jd1234");
|
persistActiveContact("jd1234");
|
||||||
runCommand("sh8013", "jd1234");
|
runCommand("sh8013", "jd1234");
|
||||||
|
@ -66,25 +66,25 @@ public class GetContactCommandTest extends CommandTestCase<GetContactCommand> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_deletedContact() throws Exception {
|
void testSuccess_deletedContact() throws Exception {
|
||||||
persistDeletedContact("sh8013", now.minusDays(1));
|
persistDeletedContact("sh8013", now.minusDays(1));
|
||||||
runCommand("sh8013");
|
runCommand("sh8013");
|
||||||
assertInStdout("Contact 'sh8013' does not exist or is deleted");
|
assertInStdout("Contact 'sh8013' does not exist or is deleted");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_contactDoesNotExist() throws Exception {
|
void testSuccess_contactDoesNotExist() throws Exception {
|
||||||
runCommand("nope");
|
runCommand("nope");
|
||||||
assertInStdout("Contact 'nope' does not exist or is deleted");
|
assertInStdout("Contact 'nope' does not exist or is deleted");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_noContact() {
|
void testFailure_noContact() {
|
||||||
assertThrows(ParameterException.class, this::runCommand);
|
assertThrows(ParameterException.class, this::runCommand);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_contactDeletedInFuture() throws Exception {
|
void testSuccess_contactDeletedInFuture() throws Exception {
|
||||||
persistResource(
|
persistResource(
|
||||||
newContactResource("sh8013").asBuilder().setDeletionTime(now.plusDays(1)).build());
|
newContactResource("sh8013").asBuilder().setDeletionTime(now.plusDays(1)).build());
|
||||||
runCommand("sh8013", "--read_timestamp=" + now.plusMonths(1));
|
runCommand("sh8013", "--read_timestamp=" + now.plusMonths(1));
|
||||||
|
|
|
@ -24,21 +24,21 @@ import static org.junit.Assert.assertThrows;
|
||||||
|
|
||||||
import com.beust.jcommander.ParameterException;
|
import com.beust.jcommander.ParameterException;
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
/** Unit tests for {@link GetDomainCommand}. */
|
/** Unit tests for {@link GetDomainCommand}. */
|
||||||
public class GetDomainCommandTest extends CommandTestCase<GetDomainCommand> {
|
class GetDomainCommandTest extends CommandTestCase<GetDomainCommand> {
|
||||||
|
|
||||||
DateTime now = DateTime.now(UTC);
|
private DateTime now = DateTime.now(UTC);
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void initialize() {
|
void beforeEach() {
|
||||||
createTld("tld");
|
createTld("tld");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess() throws Exception {
|
void testSuccess() throws Exception {
|
||||||
persistActiveDomain("example.tld");
|
persistActiveDomain("example.tld");
|
||||||
runCommand("example.tld");
|
runCommand("example.tld");
|
||||||
assertInStdout("fullyQualifiedDomainName=example.tld");
|
assertInStdout("fullyQualifiedDomainName=example.tld");
|
||||||
|
@ -47,7 +47,7 @@ public class GetDomainCommandTest extends CommandTestCase<GetDomainCommand> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_expand() throws Exception {
|
void testSuccess_expand() throws Exception {
|
||||||
persistActiveDomain("example.tld");
|
persistActiveDomain("example.tld");
|
||||||
runCommand("example.tld", "--expand");
|
runCommand("example.tld", "--expand");
|
||||||
assertInStdout("fullyQualifiedDomainName=example.tld");
|
assertInStdout("fullyQualifiedDomainName=example.tld");
|
||||||
|
@ -57,7 +57,7 @@ public class GetDomainCommandTest extends CommandTestCase<GetDomainCommand> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_multipleArguments() throws Exception {
|
void testSuccess_multipleArguments() throws Exception {
|
||||||
persistActiveDomain("example.tld");
|
persistActiveDomain("example.tld");
|
||||||
persistActiveDomain("example2.tld");
|
persistActiveDomain("example2.tld");
|
||||||
runCommand("example.tld", "example2.tld");
|
runCommand("example.tld", "example2.tld");
|
||||||
|
@ -68,7 +68,7 @@ public class GetDomainCommandTest extends CommandTestCase<GetDomainCommand> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_domainDeletedInFuture() throws Exception {
|
void testSuccess_domainDeletedInFuture() throws Exception {
|
||||||
persistResource(newDomainBase("example.tld").asBuilder()
|
persistResource(newDomainBase("example.tld").asBuilder()
|
||||||
.setDeletionTime(now.plusDays(1)).build());
|
.setDeletionTime(now.plusDays(1)).build());
|
||||||
runCommand("example.tld", "--read_timestamp=" + now.plusMonths(1));
|
runCommand("example.tld", "--read_timestamp=" + now.plusMonths(1));
|
||||||
|
@ -76,31 +76,31 @@ public class GetDomainCommandTest extends CommandTestCase<GetDomainCommand> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_deletedDomain() throws Exception {
|
void testSuccess_deletedDomain() throws Exception {
|
||||||
persistDeletedDomain("example.tld", now.minusDays(1));
|
persistDeletedDomain("example.tld", now.minusDays(1));
|
||||||
runCommand("example.tld");
|
runCommand("example.tld");
|
||||||
assertInStdout("Domain 'example.tld' does not exist or is deleted");
|
assertInStdout("Domain 'example.tld' does not exist or is deleted");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_domainDoesNotExist() throws Exception {
|
void testSuccess_domainDoesNotExist() throws Exception {
|
||||||
runCommand("something.tld");
|
runCommand("something.tld");
|
||||||
assertInStdout("Domain 'something.tld' does not exist or is deleted");
|
assertInStdout("Domain 'something.tld' does not exist or is deleted");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_tldDoesNotExist() throws Exception {
|
void testFailure_tldDoesNotExist() throws Exception {
|
||||||
runCommand("example.foo");
|
runCommand("example.foo");
|
||||||
assertInStdout("Domain 'example.foo' does not exist or is deleted");
|
assertInStdout("Domain 'example.foo' does not exist or is deleted");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_noDomainName() {
|
void testFailure_noDomainName() {
|
||||||
assertThrows(ParameterException.class, this::runCommand);
|
assertThrows(ParameterException.class, this::runCommand);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_oneDomainDoesNotExist() throws Exception {
|
void testSuccess_oneDomainDoesNotExist() throws Exception {
|
||||||
persistActiveDomain("example.tld");
|
persistActiveDomain("example.tld");
|
||||||
createTld("com");
|
createTld("com");
|
||||||
runCommand("example.com", "example.tld");
|
runCommand("example.com", "example.tld");
|
||||||
|
|
|
@ -24,24 +24,24 @@ import google.registry.model.domain.Period;
|
||||||
import google.registry.model.reporting.HistoryEntry;
|
import google.registry.model.reporting.HistoryEntry;
|
||||||
import google.registry.testing.FakeClock;
|
import google.registry.testing.FakeClock;
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
/** Unit tests for {@link GetClaimsListCommand}. */
|
/** Unit tests for {@link GetClaimsListCommand}. */
|
||||||
public class GetHistoryEntriesCommandTest extends CommandTestCase<GetHistoryEntriesCommand> {
|
class GetHistoryEntriesCommandTest extends CommandTestCase<GetHistoryEntriesCommand> {
|
||||||
|
|
||||||
private final FakeClock clock = new FakeClock(DateTime.parse("2000-01-01T00:00:00Z"));
|
private final FakeClock clock = new FakeClock(DateTime.parse("2000-01-01T00:00:00Z"));
|
||||||
|
|
||||||
private DomainBase domain;
|
private DomainBase domain;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setup() {
|
void beforeEach() {
|
||||||
createTld("tld");
|
createTld("tld");
|
||||||
domain = persistActiveDomain("example.tld");
|
domain = persistActiveDomain("example.tld");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_works() throws Exception {
|
void testSuccess_works() throws Exception {
|
||||||
persistResource(
|
persistResource(
|
||||||
makeHistoryEntry(
|
makeHistoryEntry(
|
||||||
domain,
|
domain,
|
||||||
|
@ -61,7 +61,7 @@ public class GetHistoryEntriesCommandTest extends CommandTestCase<GetHistoryEntr
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_noTrid() throws Exception {
|
void testSuccess_noTrid() throws Exception {
|
||||||
persistResource(
|
persistResource(
|
||||||
makeHistoryEntry(
|
makeHistoryEntry(
|
||||||
domain,
|
domain,
|
||||||
|
|
|
@ -24,21 +24,21 @@ import static org.junit.Assert.assertThrows;
|
||||||
|
|
||||||
import com.beust.jcommander.ParameterException;
|
import com.beust.jcommander.ParameterException;
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
/** Unit tests for {@link GetHostCommand}. */
|
/** Unit tests for {@link GetHostCommand}. */
|
||||||
public class GetHostCommandTest extends CommandTestCase<GetHostCommand> {
|
class GetHostCommandTest extends CommandTestCase<GetHostCommand> {
|
||||||
|
|
||||||
DateTime now = DateTime.now(UTC);
|
private DateTime now = DateTime.now(UTC);
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void initialize() {
|
void beforeEach() {
|
||||||
createTld("tld");
|
createTld("tld");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess() throws Exception {
|
void testSuccess() throws Exception {
|
||||||
persistActiveHost("ns1.example.tld");
|
persistActiveHost("ns1.example.tld");
|
||||||
runCommand("ns1.example.tld");
|
runCommand("ns1.example.tld");
|
||||||
assertInStdout("fullyQualifiedHostName=ns1.example.tld");
|
assertInStdout("fullyQualifiedHostName=ns1.example.tld");
|
||||||
|
@ -46,7 +46,7 @@ public class GetHostCommandTest extends CommandTestCase<GetHostCommand> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_expand() throws Exception {
|
void testSuccess_expand() throws Exception {
|
||||||
persistActiveHost("ns1.example.tld");
|
persistActiveHost("ns1.example.tld");
|
||||||
runCommand("ns1.example.tld", "--expand");
|
runCommand("ns1.example.tld", "--expand");
|
||||||
assertInStdout("fullyQualifiedHostName=ns1.example.tld");
|
assertInStdout("fullyQualifiedHostName=ns1.example.tld");
|
||||||
|
@ -55,7 +55,7 @@ public class GetHostCommandTest extends CommandTestCase<GetHostCommand> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_multipleArguments() throws Exception {
|
void testSuccess_multipleArguments() throws Exception {
|
||||||
persistActiveHost("ns1.example.tld");
|
persistActiveHost("ns1.example.tld");
|
||||||
persistActiveHost("ns2.example.tld");
|
persistActiveHost("ns2.example.tld");
|
||||||
runCommand("ns1.example.tld", "ns2.example.tld");
|
runCommand("ns1.example.tld", "ns2.example.tld");
|
||||||
|
@ -66,7 +66,7 @@ public class GetHostCommandTest extends CommandTestCase<GetHostCommand> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_multipleTlds() throws Exception {
|
void testSuccess_multipleTlds() throws Exception {
|
||||||
persistActiveHost("ns1.example.tld");
|
persistActiveHost("ns1.example.tld");
|
||||||
createTld("tld2");
|
createTld("tld2");
|
||||||
persistActiveHost("ns1.example.tld2");
|
persistActiveHost("ns1.example.tld2");
|
||||||
|
@ -76,20 +76,20 @@ public class GetHostCommandTest extends CommandTestCase<GetHostCommand> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_deletedHost() throws Exception {
|
void testSuccess_deletedHost() throws Exception {
|
||||||
persistDeletedHost("ns1.example.tld", now.minusDays(1));
|
persistDeletedHost("ns1.example.tld", now.minusDays(1));
|
||||||
runCommand("ns1.example.tld");
|
runCommand("ns1.example.tld");
|
||||||
assertInStdout("Host 'ns1.example.tld' does not exist or is deleted");
|
assertInStdout("Host 'ns1.example.tld' does not exist or is deleted");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_hostDoesNotExist() throws Exception {
|
void testSuccess_hostDoesNotExist() throws Exception {
|
||||||
runCommand("foo.example.tld");
|
runCommand("foo.example.tld");
|
||||||
assertInStdout("Host 'foo.example.tld' does not exist or is deleted");
|
assertInStdout("Host 'foo.example.tld' does not exist or is deleted");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_hostDeletedInFuture() throws Exception {
|
void testSuccess_hostDeletedInFuture() throws Exception {
|
||||||
persistResource(
|
persistResource(
|
||||||
newHostResource("ns1.example.tld").asBuilder()
|
newHostResource("ns1.example.tld").asBuilder()
|
||||||
.setDeletionTime(now.plusDays(1))
|
.setDeletionTime(now.plusDays(1))
|
||||||
|
@ -99,14 +99,14 @@ public class GetHostCommandTest extends CommandTestCase<GetHostCommand> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_externalHost() throws Exception {
|
void testSuccess_externalHost() throws Exception {
|
||||||
persistActiveHost("ns1.example.foo");
|
persistActiveHost("ns1.example.foo");
|
||||||
runCommand("ns1.example.foo");
|
runCommand("ns1.example.foo");
|
||||||
assertInStdout("fullyQualifiedHostName=ns1.example.foo");
|
assertInStdout("fullyQualifiedHostName=ns1.example.foo");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_noHostName() {
|
void testFailure_noHostName() {
|
||||||
assertThrows(ParameterException.class, this::runCommand);
|
assertThrows(ParameterException.class, this::runCommand);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,24 +22,23 @@ import google.registry.export.datastore.DatastoreAdmin;
|
||||||
import google.registry.export.datastore.DatastoreAdmin.Get;
|
import google.registry.export.datastore.DatastoreAdmin.Get;
|
||||||
import google.registry.export.datastore.Operation;
|
import google.registry.export.datastore.Operation;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
import org.junit.runners.JUnit4;
|
|
||||||
import org.mockito.ArgumentCaptor;
|
import org.mockito.ArgumentCaptor;
|
||||||
import org.mockito.Captor;
|
import org.mockito.Captor;
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
|
import org.mockito.junit.jupiter.MockitoSettings;
|
||||||
|
import org.mockito.quality.Strictness;
|
||||||
|
|
||||||
/** Unit tests for {@link GetOperationStatusCommand}. */
|
/** Unit tests for {@link GetOperationStatusCommand}. */
|
||||||
@RunWith(JUnit4.class)
|
class GetOperationStatusCommandTest extends CommandTestCase<GetOperationStatusCommand> {
|
||||||
public class GetOperationStatusCommandTest extends CommandTestCase<GetOperationStatusCommand> {
|
|
||||||
|
|
||||||
@Mock private DatastoreAdmin datastoreAdmin;
|
@Mock private DatastoreAdmin datastoreAdmin;
|
||||||
@Mock private Get getRequest;
|
@Mock private Get getRequest;
|
||||||
@Captor ArgumentCaptor<String> operationName;
|
@Captor ArgumentCaptor<String> operationName;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setup() throws IOException {
|
void beforeEach() throws IOException {
|
||||||
command.datastoreAdmin = datastoreAdmin;
|
command.datastoreAdmin = datastoreAdmin;
|
||||||
|
|
||||||
when(datastoreAdmin.get(operationName.capture())).thenReturn(getRequest);
|
when(datastoreAdmin.get(operationName.capture())).thenReturn(getRequest);
|
||||||
|
@ -47,13 +46,14 @@ public class GetOperationStatusCommandTest extends CommandTestCase<GetOperationS
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_success() throws Exception {
|
void test_success() throws Exception {
|
||||||
runCommand("projects/project-id/operations/HASH");
|
runCommand("projects/project-id/operations/HASH");
|
||||||
assertThat(operationName.getValue()).isEqualTo("projects/project-id/operations/HASH");
|
assertThat(operationName.getValue()).isEqualTo("projects/project-id/operations/HASH");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_failure_tooManyNames() {
|
@MockitoSettings(strictness = Strictness.LENIENT)
|
||||||
|
void test_failure_tooManyNames() {
|
||||||
assertThrows(IllegalArgumentException.class, () -> runCommand("a", "b"));
|
assertThrows(IllegalArgumentException.class, () -> runCommand("a", "b"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,37 +18,37 @@ import static com.google.common.truth.Truth.assertThat;
|
||||||
import static org.junit.Assert.assertThrows;
|
import static org.junit.Assert.assertThrows;
|
||||||
|
|
||||||
import com.beust.jcommander.ParameterException;
|
import com.beust.jcommander.ParameterException;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
/** Unit tests for {@link GetRegistrarCommand}. */
|
/** Unit tests for {@link GetRegistrarCommand}. */
|
||||||
public class GetRegistrarCommandTest extends CommandTestCase<GetRegistrarCommand> {
|
class GetRegistrarCommandTest extends CommandTestCase<GetRegistrarCommand> {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess() throws Exception {
|
void testSuccess() throws Exception {
|
||||||
// This registrar is created by AppEngineRule.
|
// This registrar is created by AppEngineRule.
|
||||||
runCommand("NewRegistrar");
|
runCommand("NewRegistrar");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_multipleArguments() throws Exception {
|
void testSuccess_multipleArguments() throws Exception {
|
||||||
// Registrars are created by AppEngineRule.
|
// Registrars are created by AppEngineRule.
|
||||||
runCommand("NewRegistrar", "TheRegistrar");
|
runCommand("NewRegistrar", "TheRegistrar");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_registrarDoesNotExist() {
|
void testFailure_registrarDoesNotExist() {
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(IllegalArgumentException.class, () -> runCommand("ClientZ"));
|
assertThrows(IllegalArgumentException.class, () -> runCommand("ClientZ"));
|
||||||
assertThat(thrown).hasMessageThat().contains("Registrar with id ClientZ does not exist");
|
assertThat(thrown).hasMessageThat().contains("Registrar with id ClientZ does not exist");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_noRegistrarName() {
|
void testFailure_noRegistrarName() {
|
||||||
assertThrows(ParameterException.class, this::runCommand);
|
assertThrows(ParameterException.class, this::runCommand);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_oneRegistrarDoesNotExist() {
|
void testFailure_oneRegistrarDoesNotExist() {
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(IllegalArgumentException.class, () -> runCommand("NewRegistrar", "ClientZ"));
|
assertThrows(IllegalArgumentException.class, () -> runCommand("NewRegistrar", "ClientZ"));
|
||||||
assertThat(thrown).hasMessageThat().contains("Registrar with id ClientZ does not exist");
|
assertThat(thrown).hasMessageThat().contains("Registrar with id ClientZ does not exist");
|
||||||
|
|
|
@ -27,21 +27,21 @@ import static org.junit.Assert.assertThrows;
|
||||||
|
|
||||||
import com.beust.jcommander.ParameterException;
|
import com.beust.jcommander.ParameterException;
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
/** Unit tests for {@link GetResourceByKeyCommand}. */
|
/** Unit tests for {@link GetResourceByKeyCommand}. */
|
||||||
public class GetResourceByKeyCommandTest extends CommandTestCase<GetResourceByKeyCommand> {
|
class GetResourceByKeyCommandTest extends CommandTestCase<GetResourceByKeyCommand> {
|
||||||
|
|
||||||
DateTime now = DateTime.now(UTC);
|
private DateTime now = DateTime.now(UTC);
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void initialize() {
|
void beforeEach() {
|
||||||
createTld("tld");
|
createTld("tld");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_domain() throws Exception {
|
void testSuccess_domain() throws Exception {
|
||||||
persistActiveDomain("example.tld");
|
persistActiveDomain("example.tld");
|
||||||
runCommand("agR0ZXN0chULEgpEb21haW5CYXNlIgUyLVRMRAw");
|
runCommand("agR0ZXN0chULEgpEb21haW5CYXNlIgUyLVRMRAw");
|
||||||
assertInStdout("fullyQualifiedDomainName=example.tld");
|
assertInStdout("fullyQualifiedDomainName=example.tld");
|
||||||
|
@ -49,7 +49,7 @@ public class GetResourceByKeyCommandTest extends CommandTestCase<GetResourceByKe
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_domain_expand() throws Exception {
|
void testSuccess_domain_expand() throws Exception {
|
||||||
persistActiveDomain("example.tld");
|
persistActiveDomain("example.tld");
|
||||||
runCommand("agR0ZXN0chULEgpEb21haW5CYXNlIgUyLVRMRAw", "--expand");
|
runCommand("agR0ZXN0chULEgpEb21haW5CYXNlIgUyLVRMRAw", "--expand");
|
||||||
assertInStdout("fullyQualifiedDomainName=example.tld");
|
assertInStdout("fullyQualifiedDomainName=example.tld");
|
||||||
|
@ -58,7 +58,7 @@ public class GetResourceByKeyCommandTest extends CommandTestCase<GetResourceByKe
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_domain_multipleArguments() throws Exception {
|
void testSuccess_domain_multipleArguments() throws Exception {
|
||||||
persistActiveDomain("example.tld");
|
persistActiveDomain("example.tld");
|
||||||
persistActiveDomain("example2.tld");
|
persistActiveDomain("example2.tld");
|
||||||
runCommand(
|
runCommand(
|
||||||
|
@ -68,7 +68,7 @@ public class GetResourceByKeyCommandTest extends CommandTestCase<GetResourceByKe
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_domain_oneDoesNotExist() {
|
void testFailure_domain_oneDoesNotExist() {
|
||||||
persistActiveDomain("example.tld");
|
persistActiveDomain("example.tld");
|
||||||
NullPointerException thrown =
|
NullPointerException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
|
@ -83,7 +83,7 @@ public class GetResourceByKeyCommandTest extends CommandTestCase<GetResourceByKe
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_deletedDomain() throws Exception {
|
void testSuccess_deletedDomain() throws Exception {
|
||||||
persistDeletedDomain("example.tld", now.minusDays(1));
|
persistDeletedDomain("example.tld", now.minusDays(1));
|
||||||
runCommand("agR0ZXN0chULEgpEb21haW5CYXNlIgUyLVRMRAw");
|
runCommand("agR0ZXN0chULEgpEb21haW5CYXNlIgUyLVRMRAw");
|
||||||
assertInStdout("fullyQualifiedDomainName=example.tld");
|
assertInStdout("fullyQualifiedDomainName=example.tld");
|
||||||
|
@ -91,14 +91,14 @@ public class GetResourceByKeyCommandTest extends CommandTestCase<GetResourceByKe
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_contact() throws Exception {
|
void testSuccess_contact() throws Exception {
|
||||||
persistActiveContact("sh8013");
|
persistActiveContact("sh8013");
|
||||||
runCommand("agR0ZXN0chsLEg9Db250YWN0UmVzb3VyY2UiBjItUk9JRAw");
|
runCommand("agR0ZXN0chsLEg9Db250YWN0UmVzb3VyY2UiBjItUk9JRAw");
|
||||||
assertInStdout("contactId=sh8013");
|
assertInStdout("contactId=sh8013");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_contact_expand() throws Exception {
|
void testSuccess_contact_expand() throws Exception {
|
||||||
persistActiveContact("sh8013");
|
persistActiveContact("sh8013");
|
||||||
runCommand("agR0ZXN0chsLEg9Db250YWN0UmVzb3VyY2UiBjItUk9JRAw", "--expand");
|
runCommand("agR0ZXN0chsLEg9Db250YWN0UmVzb3VyY2UiBjItUk9JRAw", "--expand");
|
||||||
assertInStdout("contactId=sh8013");
|
assertInStdout("contactId=sh8013");
|
||||||
|
@ -106,7 +106,7 @@ public class GetResourceByKeyCommandTest extends CommandTestCase<GetResourceByKe
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_contact_multipleArguments() throws Exception {
|
void testSuccess_contact_multipleArguments() throws Exception {
|
||||||
persistActiveContact("sh8013");
|
persistActiveContact("sh8013");
|
||||||
persistActiveContact("jd1234");
|
persistActiveContact("jd1234");
|
||||||
runCommand(
|
runCommand(
|
||||||
|
@ -117,7 +117,7 @@ public class GetResourceByKeyCommandTest extends CommandTestCase<GetResourceByKe
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_contact_oneDoesNotExist() {
|
void testFailure_contact_oneDoesNotExist() {
|
||||||
persistActiveContact("sh8013");
|
persistActiveContact("sh8013");
|
||||||
NullPointerException thrown =
|
NullPointerException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
|
@ -132,7 +132,7 @@ public class GetResourceByKeyCommandTest extends CommandTestCase<GetResourceByKe
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_deletedContact() throws Exception {
|
void testSuccess_deletedContact() throws Exception {
|
||||||
persistDeletedContact("sh8013", now.minusDays(1));
|
persistDeletedContact("sh8013", now.minusDays(1));
|
||||||
runCommand("agR0ZXN0chsLEg9Db250YWN0UmVzb3VyY2UiBjItUk9JRAw");
|
runCommand("agR0ZXN0chsLEg9Db250YWN0UmVzb3VyY2UiBjItUk9JRAw");
|
||||||
assertInStdout("contactId=sh8013");
|
assertInStdout("contactId=sh8013");
|
||||||
|
@ -140,14 +140,14 @@ public class GetResourceByKeyCommandTest extends CommandTestCase<GetResourceByKe
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_host() throws Exception {
|
void testSuccess_host() throws Exception {
|
||||||
persistActiveHost("ns1.example.tld");
|
persistActiveHost("ns1.example.tld");
|
||||||
runCommand("agR0ZXN0chgLEgxIb3N0UmVzb3VyY2UiBjItUk9JRAw");
|
runCommand("agR0ZXN0chgLEgxIb3N0UmVzb3VyY2UiBjItUk9JRAw");
|
||||||
assertInStdout("fullyQualifiedHostName=ns1.example.tld");
|
assertInStdout("fullyQualifiedHostName=ns1.example.tld");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_host_expand() throws Exception {
|
void testSuccess_host_expand() throws Exception {
|
||||||
persistActiveHost("ns1.example.tld");
|
persistActiveHost("ns1.example.tld");
|
||||||
runCommand("agR0ZXN0chgLEgxIb3N0UmVzb3VyY2UiBjItUk9JRAw", "--expand");
|
runCommand("agR0ZXN0chgLEgxIb3N0UmVzb3VyY2UiBjItUk9JRAw", "--expand");
|
||||||
assertInStdout("fullyQualifiedHostName=ns1.example.tld");
|
assertInStdout("fullyQualifiedHostName=ns1.example.tld");
|
||||||
|
@ -155,7 +155,7 @@ public class GetResourceByKeyCommandTest extends CommandTestCase<GetResourceByKe
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_host_multipleArguments() throws Exception {
|
void testSuccess_host_multipleArguments() throws Exception {
|
||||||
persistActiveHost("ns1.example.tld");
|
persistActiveHost("ns1.example.tld");
|
||||||
persistActiveHost("ns2.example.tld");
|
persistActiveHost("ns2.example.tld");
|
||||||
runCommand(
|
runCommand(
|
||||||
|
@ -166,7 +166,7 @@ public class GetResourceByKeyCommandTest extends CommandTestCase<GetResourceByKe
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_host_oneDoesNotExist() {
|
void testFailure_host_oneDoesNotExist() {
|
||||||
persistActiveHost("ns1.example.tld");
|
persistActiveHost("ns1.example.tld");
|
||||||
NullPointerException thrown =
|
NullPointerException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
|
@ -181,7 +181,7 @@ public class GetResourceByKeyCommandTest extends CommandTestCase<GetResourceByKe
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_deletedHost() throws Exception {
|
void testSuccess_deletedHost() throws Exception {
|
||||||
persistDeletedHost("ns1.example.tld", now.minusDays(1));
|
persistDeletedHost("ns1.example.tld", now.minusDays(1));
|
||||||
runCommand("agR0ZXN0chgLEgxIb3N0UmVzb3VyY2UiBjItUk9JRAw");
|
runCommand("agR0ZXN0chgLEgxIb3N0UmVzb3VyY2UiBjItUk9JRAw");
|
||||||
assertInStdout("fullyQualifiedHostName=ns1.example.tld");
|
assertInStdout("fullyQualifiedHostName=ns1.example.tld");
|
||||||
|
@ -189,7 +189,7 @@ public class GetResourceByKeyCommandTest extends CommandTestCase<GetResourceByKe
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_mixedTypes() throws Exception {
|
void testSuccess_mixedTypes() throws Exception {
|
||||||
persistActiveDomain("example.tld");
|
persistActiveDomain("example.tld");
|
||||||
persistActiveContact("sh8013");
|
persistActiveContact("sh8013");
|
||||||
persistActiveHost("ns1.example.tld");
|
persistActiveHost("ns1.example.tld");
|
||||||
|
@ -203,7 +203,7 @@ public class GetResourceByKeyCommandTest extends CommandTestCase<GetResourceByKe
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_keyDoesNotExist() {
|
void testFailure_keyDoesNotExist() {
|
||||||
NullPointerException thrown =
|
NullPointerException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
NullPointerException.class,
|
NullPointerException.class,
|
||||||
|
@ -214,7 +214,7 @@ public class GetResourceByKeyCommandTest extends CommandTestCase<GetResourceByKe
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_nonsenseKey() {
|
void testFailure_nonsenseKey() {
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class, () -> runCommand("agR0ZXN0chULEgpEb21haW5CYXN"));
|
IllegalArgumentException.class, () -> runCommand("agR0ZXN0chULEgpEb21haW5CYXN"));
|
||||||
|
@ -222,7 +222,7 @@ public class GetResourceByKeyCommandTest extends CommandTestCase<GetResourceByKe
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_noParameters() {
|
void testFailure_noParameters() {
|
||||||
assertThrows(ParameterException.class, this::runCommand);
|
assertThrows(ParameterException.class, this::runCommand);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,12 +19,13 @@ import static com.google.common.truth.Truth.assertWithMessage;
|
||||||
import com.google.re2j.Matcher;
|
import com.google.re2j.Matcher;
|
||||||
import com.google.re2j.Pattern;
|
import com.google.re2j.Pattern;
|
||||||
import google.registry.model.EntityClasses;
|
import google.registry.model.EntityClasses;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
/** Unit tests for {@link GetSchemaTreeCommand}. */
|
/** Unit tests for {@link GetSchemaTreeCommand}. */
|
||||||
public class GetSchemaTreeCommandTest extends CommandTestCase<GetSchemaTreeCommand> {
|
class GetSchemaTreeCommandTest extends CommandTestCase<GetSchemaTreeCommand> {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAllClassesPrintedExactlyOnce() throws Exception {
|
void testAllClassesPrintedExactlyOnce() throws Exception {
|
||||||
runCommand();
|
runCommand();
|
||||||
String stdout = getStdoutAsString();
|
String stdout = getStdoutAsString();
|
||||||
for (Class<?> clazz : EntityClasses.ALL_CLASSES) {
|
for (Class<?> clazz : EntityClasses.ALL_CLASSES) {
|
||||||
|
|
|
@ -19,36 +19,35 @@ import static google.registry.testing.DatastoreHelper.createTlds;
|
||||||
import static org.junit.Assert.assertThrows;
|
import static org.junit.Assert.assertThrows;
|
||||||
|
|
||||||
import com.beust.jcommander.ParameterException;
|
import com.beust.jcommander.ParameterException;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
/** Unit tests for {@link GetTldCommand}. */
|
/** Unit tests for {@link GetTldCommand}. */
|
||||||
public class GetTldCommandTest extends CommandTestCase<GetTldCommand> {
|
class GetTldCommandTest extends CommandTestCase<GetTldCommand> {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess() throws Exception {
|
void testSuccess() throws Exception {
|
||||||
createTld("xn--q9jyb4c");
|
createTld("xn--q9jyb4c");
|
||||||
runCommand("xn--q9jyb4c");
|
runCommand("xn--q9jyb4c");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_multipleArguments() throws Exception {
|
void testSuccess_multipleArguments() throws Exception {
|
||||||
createTlds("xn--q9jyb4c", "example");
|
createTlds("xn--q9jyb4c", "example");
|
||||||
runCommand("xn--q9jyb4c", "example");
|
runCommand("xn--q9jyb4c", "example");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_tldDoesNotExist() {
|
void testFailure_tldDoesNotExist() {
|
||||||
assertThrows(IllegalArgumentException.class, () -> runCommand("xn--q9jyb4c"));
|
assertThrows(IllegalArgumentException.class, () -> runCommand("xn--q9jyb4c"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_noTldName() {
|
void testFailure_noTldName() {
|
||||||
assertThrows(ParameterException.class, this::runCommand);
|
assertThrows(ParameterException.class, this::runCommand);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_oneTldDoesNotExist() {
|
void testFailure_oneTldDoesNotExist() {
|
||||||
createTld("xn--q9jyb4c");
|
createTld("xn--q9jyb4c");
|
||||||
assertThrows(IllegalArgumentException.class, () -> runCommand("xn--q9jyb4c", "example"));
|
assertThrows(IllegalArgumentException.class, () -> runCommand("xn--q9jyb4c", "example"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,12 +25,12 @@ import google.registry.testing.FakeKeyringModule;
|
||||||
import google.registry.testing.InjectRule;
|
import google.registry.testing.InjectRule;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Rule;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||||
|
|
||||||
/** Unit tests for {@link GhostrydeCommand}. */
|
/** Unit tests for {@link GhostrydeCommand}. */
|
||||||
public class GhostrydeCommandTest extends CommandTestCase<GhostrydeCommand> {
|
class GhostrydeCommandTest extends CommandTestCase<GhostrydeCommand> {
|
||||||
|
|
||||||
private static final byte[] SONG_BY_CHRISTINA_ROSSETTI = (""
|
private static final byte[] SONG_BY_CHRISTINA_ROSSETTI = (""
|
||||||
+ "When I am dead, my dearest, \n"
|
+ "When I am dead, my dearest, \n"
|
||||||
|
@ -51,50 +51,50 @@ public class GhostrydeCommandTest extends CommandTestCase<GhostrydeCommand> {
|
||||||
+ "Haply I may remember, \n"
|
+ "Haply I may remember, \n"
|
||||||
+ " And haply may forget. \n").getBytes(UTF_8);
|
+ " And haply may forget. \n").getBytes(UTF_8);
|
||||||
|
|
||||||
@Rule
|
@RegisterExtension final InjectRule inject = new InjectRule();
|
||||||
public final InjectRule inject = new InjectRule();
|
|
||||||
|
|
||||||
@Rule
|
@RegisterExtension final BouncyCastleProviderRule bouncy = new BouncyCastleProviderRule();
|
||||||
public final BouncyCastleProviderRule bouncy = new BouncyCastleProviderRule();
|
|
||||||
|
|
||||||
private Keyring keyring;
|
private Keyring keyring;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void before() {
|
void beforeEach() {
|
||||||
keyring = new FakeKeyringModule().get();
|
keyring = new FakeKeyringModule().get();
|
||||||
command.rdeStagingDecryptionKey = keyring::getRdeStagingDecryptionKey;
|
command.rdeStagingDecryptionKey = keyring::getRdeStagingDecryptionKey;
|
||||||
command.rdeStagingEncryptionKey = keyring::getRdeStagingEncryptionKey;
|
command.rdeStagingEncryptionKey = keyring::getRdeStagingEncryptionKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testParameters_cantSpecifyBothEncryptAndDecrypt() {
|
void testParameters_cantSpecifyBothEncryptAndDecrypt() {
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(IllegalArgumentException.class, () -> runCommand("--encrypt", "--decrypt"));
|
assertThrows(IllegalArgumentException.class, () -> runCommand("--encrypt", "--decrypt"));
|
||||||
assertThat(thrown).hasMessageThat().isEqualTo("Please specify either --encrypt or --decrypt");
|
assertThat(thrown).hasMessageThat().isEqualTo("Please specify either --encrypt or --decrypt");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testParameters_mustSpecifyOneOfEncryptOrDecrypt() {
|
void testParameters_mustSpecifyOneOfEncryptOrDecrypt() throws Exception {
|
||||||
|
Path inputFile = Files.createFile(tmpDir.resolve("foo.dat"));
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
() -> runCommand("--input=" + tmpDir.newFile(), "--output=" + tmpDir.newFile()));
|
() -> runCommand("--input=" + inputFile.toString(), "--output=bar.dat"));
|
||||||
assertThat(thrown).hasMessageThat().isEqualTo("Please specify either --encrypt or --decrypt");
|
assertThat(thrown).hasMessageThat().isEqualTo("Please specify either --encrypt or --decrypt");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testEncrypt_outputPathIsRequired() {
|
void testEncrypt_outputPathIsRequired() throws Exception {
|
||||||
|
Path inputFile = Files.createFile(tmpDir.resolve("foo.dat"));
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
() -> runCommand("--encrypt", "--input=" + tmpDir.newFile()));
|
() -> runCommand("--encrypt", "--input=" + inputFile.toString()));
|
||||||
assertThat(thrown).hasMessageThat().isEqualTo("--output path is required in --encrypt mode");
|
assertThat(thrown).hasMessageThat().isEqualTo("--output path is required in --encrypt mode");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testEncrypt_outputIsAFile_writesToFile() throws Exception {
|
void testEncrypt_outputIsAFile_writesToFile() throws Exception {
|
||||||
Path inFile = tmpDir.newFile("atrain.txt").toPath();
|
Path inFile = tmpDir.resolve("atrain.txt");
|
||||||
Path outFile = tmpDir.newFile().toPath();
|
Path outFile = tmpDir.resolve("out.dat");
|
||||||
Files.write(inFile, SONG_BY_CHRISTINA_ROSSETTI);
|
Files.write(inFile, SONG_BY_CHRISTINA_ROSSETTI);
|
||||||
runCommand("--encrypt", "--input=" + inFile, "--output=" + outFile);
|
runCommand("--encrypt", "--input=" + inFile, "--output=" + outFile);
|
||||||
byte[] decoded =
|
byte[] decoded =
|
||||||
|
@ -103,24 +103,23 @@ public class GhostrydeCommandTest extends CommandTestCase<GhostrydeCommand> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testEncrypt_outputIsADirectory_appendsGhostrydeExtension() throws Exception {
|
void testEncrypt_outputIsADirectory_appendsGhostrydeExtension() throws Exception {
|
||||||
Path inFile = tmpDir.newFile("atrain.txt").toPath();
|
Path inFile = tmpDir.resolve("atrain.txt");
|
||||||
Path outDir = tmpDir.newFolder().toPath();
|
|
||||||
Files.write(inFile, SONG_BY_CHRISTINA_ROSSETTI);
|
Files.write(inFile, SONG_BY_CHRISTINA_ROSSETTI);
|
||||||
runCommand("--encrypt", "--input=" + inFile, "--output=" + outDir);
|
runCommand("--encrypt", "--input=" + inFile, "--output=" + tmpDir.toString());
|
||||||
Path lenOutFile = outDir.resolve("atrain.txt.length");
|
Path lenOutFile = tmpDir.resolve("atrain.txt.length");
|
||||||
assertThat(Ghostryde.readLength(Files.newInputStream(lenOutFile)))
|
assertThat(Ghostryde.readLength(Files.newInputStream(lenOutFile)))
|
||||||
.isEqualTo(SONG_BY_CHRISTINA_ROSSETTI.length);
|
.isEqualTo(SONG_BY_CHRISTINA_ROSSETTI.length);
|
||||||
Path outFile = outDir.resolve("atrain.txt.ghostryde");
|
Path outFile = tmpDir.resolve("atrain.txt.ghostryde");
|
||||||
byte[] decoded =
|
byte[] decoded =
|
||||||
Ghostryde.decode(Files.readAllBytes(outFile), keyring.getRdeStagingDecryptionKey());
|
Ghostryde.decode(Files.readAllBytes(outFile), keyring.getRdeStagingDecryptionKey());
|
||||||
assertThat(decoded).isEqualTo(SONG_BY_CHRISTINA_ROSSETTI);
|
assertThat(decoded).isEqualTo(SONG_BY_CHRISTINA_ROSSETTI);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDecrypt_outputIsAFile_writesToFile() throws Exception {
|
void testDecrypt_outputIsAFile_writesToFile() throws Exception {
|
||||||
Path inFile = tmpDir.newFile().toPath();
|
Path inFile = tmpDir.resolve("atrain.txt");
|
||||||
Path outFile = tmpDir.newFile().toPath();
|
Path outFile = tmpDir.resolve("out.dat");
|
||||||
Files.write(
|
Files.write(
|
||||||
inFile, Ghostryde.encode(SONG_BY_CHRISTINA_ROSSETTI, keyring.getRdeStagingEncryptionKey()));
|
inFile, Ghostryde.encode(SONG_BY_CHRISTINA_ROSSETTI, keyring.getRdeStagingEncryptionKey()));
|
||||||
runCommand("--decrypt", "--input=" + inFile, "--output=" + outFile);
|
runCommand("--decrypt", "--input=" + inFile, "--output=" + outFile);
|
||||||
|
@ -128,19 +127,18 @@ public class GhostrydeCommandTest extends CommandTestCase<GhostrydeCommand> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDecrypt_outputIsADirectory_AppendsDecryptExtension() throws Exception {
|
void testDecrypt_outputIsADirectory_AppendsDecryptExtension() throws Exception {
|
||||||
Path inFile = tmpDir.newFolder().toPath().resolve("atrain.ghostryde");
|
Path inFile = tmpDir.resolve("atrain.ghostryde");
|
||||||
Path outDir = tmpDir.newFolder().toPath();
|
|
||||||
Files.write(
|
Files.write(
|
||||||
inFile, Ghostryde.encode(SONG_BY_CHRISTINA_ROSSETTI, keyring.getRdeStagingEncryptionKey()));
|
inFile, Ghostryde.encode(SONG_BY_CHRISTINA_ROSSETTI, keyring.getRdeStagingEncryptionKey()));
|
||||||
runCommand("--decrypt", "--input=" + inFile, "--output=" + outDir);
|
runCommand("--decrypt", "--input=" + inFile, "--output=" + tmpDir.toString());
|
||||||
Path outFile = outDir.resolve("atrain.ghostryde.decrypt");
|
Path outFile = tmpDir.resolve("atrain.ghostryde.decrypt");
|
||||||
assertThat(Files.readAllBytes(outFile)).isEqualTo(SONG_BY_CHRISTINA_ROSSETTI);
|
assertThat(Files.readAllBytes(outFile)).isEqualTo(SONG_BY_CHRISTINA_ROSSETTI);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDecrypt_outputIsStdOut() throws Exception {
|
void testDecrypt_outputIsStdOut() throws Exception {
|
||||||
Path inFile = tmpDir.newFolder().toPath().resolve("atrain.ghostryde");
|
Path inFile = tmpDir.resolve("atrain.ghostryde");
|
||||||
Files.write(
|
Files.write(
|
||||||
inFile, Ghostryde.encode(SONG_BY_CHRISTINA_ROSSETTI, keyring.getRdeStagingEncryptionKey()));
|
inFile, Ghostryde.encode(SONG_BY_CHRISTINA_ROSSETTI, keyring.getRdeStagingEncryptionKey()));
|
||||||
runCommand("--decrypt", "--input=" + inFile);
|
runCommand("--decrypt", "--input=" + inFile);
|
||||||
|
|
|
@ -27,17 +27,17 @@ import google.registry.export.datastore.DatastoreAdmin.Get;
|
||||||
import google.registry.export.datastore.DatastoreAdmin.Import;
|
import google.registry.export.datastore.DatastoreAdmin.Import;
|
||||||
import google.registry.export.datastore.Operation;
|
import google.registry.export.datastore.Operation;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
import org.junit.runners.JUnit4;
|
|
||||||
import org.mockito.ArgumentCaptor;
|
import org.mockito.ArgumentCaptor;
|
||||||
import org.mockito.Captor;
|
import org.mockito.Captor;
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
|
import org.mockito.junit.jupiter.MockitoSettings;
|
||||||
|
import org.mockito.quality.Strictness;
|
||||||
|
|
||||||
/** Unit tests for {@link ImportDatastoreCommand}. */
|
/** Unit tests for {@link ImportDatastoreCommand}. */
|
||||||
@RunWith(JUnit4.class)
|
@MockitoSettings(strictness = Strictness.LENIENT)
|
||||||
public class ImportDatastoreCommandTest extends CommandTestCase<ImportDatastoreCommand> {
|
class ImportDatastoreCommandTest extends CommandTestCase<ImportDatastoreCommand> {
|
||||||
|
|
||||||
@Captor ArgumentCaptor<String> backupUrl;
|
@Captor ArgumentCaptor<String> backupUrl;
|
||||||
@Captor ArgumentCaptor<Collection<String>> kinds;
|
@Captor ArgumentCaptor<Collection<String>> kinds;
|
||||||
|
@ -49,8 +49,8 @@ public class ImportDatastoreCommandTest extends CommandTestCase<ImportDatastoreC
|
||||||
@Mock private Operation importOperation;
|
@Mock private Operation importOperation;
|
||||||
@Mock private Operation getOperation;
|
@Mock private Operation getOperation;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setup() throws Exception {
|
void beforeEach() throws Exception {
|
||||||
command.datastoreAdmin = datastoreAdmin;
|
command.datastoreAdmin = datastoreAdmin;
|
||||||
|
|
||||||
when(datastoreAdmin.importBackup(backupUrl.capture(), kinds.capture()))
|
when(datastoreAdmin.importBackup(backupUrl.capture(), kinds.capture()))
|
||||||
|
@ -63,7 +63,7 @@ public class ImportDatastoreCommandTest extends CommandTestCase<ImportDatastoreC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_importAllKinds_immediateSuccess() throws Exception {
|
void test_importAllKinds_immediateSuccess() throws Exception {
|
||||||
runCommandForced(
|
runCommandForced(
|
||||||
"--poll_interval", "PT0.001S",
|
"--poll_interval", "PT0.001S",
|
||||||
"--backup_url", "gs://bucket/export-id/export-id.overall_export_metadata");
|
"--backup_url", "gs://bucket/export-id/export-id.overall_export_metadata");
|
||||||
|
@ -74,7 +74,7 @@ public class ImportDatastoreCommandTest extends CommandTestCase<ImportDatastoreC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_importSomeKinds_immediateSuccess() throws Exception {
|
void test_importSomeKinds_immediateSuccess() throws Exception {
|
||||||
runCommandForced(
|
runCommandForced(
|
||||||
"--poll_interval",
|
"--poll_interval",
|
||||||
"PT0.001S",
|
"PT0.001S",
|
||||||
|
@ -91,7 +91,7 @@ public class ImportDatastoreCommandTest extends CommandTestCase<ImportDatastoreC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_delayedSuccess_sync() throws Exception {
|
void test_delayedSuccess_sync() throws Exception {
|
||||||
when(importOperation.isProcessing()).thenReturn(true);
|
when(importOperation.isProcessing()).thenReturn(true);
|
||||||
when(getOperation.isProcessing()).thenReturn(true).thenReturn(false);
|
when(getOperation.isProcessing()).thenReturn(true).thenReturn(false);
|
||||||
when(getOperation.isSuccessful()).thenReturn(true);
|
when(getOperation.isSuccessful()).thenReturn(true);
|
||||||
|
@ -103,7 +103,7 @@ public class ImportDatastoreCommandTest extends CommandTestCase<ImportDatastoreC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_delayedSuccess_async() throws Exception {
|
void test_delayedSuccess_async() throws Exception {
|
||||||
when(importOperation.isProcessing()).thenReturn(false);
|
when(importOperation.isProcessing()).thenReturn(false);
|
||||||
when(getOperation.isProcessing()).thenReturn(true).thenReturn(false);
|
when(getOperation.isProcessing()).thenReturn(true).thenReturn(false);
|
||||||
when(getOperation.isSuccessful()).thenReturn(true);
|
when(getOperation.isSuccessful()).thenReturn(true);
|
||||||
|
@ -118,7 +118,7 @@ public class ImportDatastoreCommandTest extends CommandTestCase<ImportDatastoreC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_failure_notAllowedInProduction() {
|
void test_failure_notAllowedInProduction() {
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
() ->
|
() ->
|
||||||
|
@ -132,7 +132,7 @@ public class ImportDatastoreCommandTest extends CommandTestCase<ImportDatastoreC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_success_runInProduction() throws Exception {
|
void test_success_runInProduction() throws Exception {
|
||||||
runCommandInEnvironment(
|
runCommandInEnvironment(
|
||||||
RegistryToolEnvironment.PRODUCTION,
|
RegistryToolEnvironment.PRODUCTION,
|
||||||
"--force",
|
"--force",
|
||||||
|
|
|
@ -28,6 +28,7 @@ import java.io.IOException;
|
||||||
|
|
||||||
/** Utility class for building a leveldb logfile. */
|
/** Utility class for building a leveldb logfile. */
|
||||||
public final class LevelDbFileBuilder {
|
public final class LevelDbFileBuilder {
|
||||||
|
|
||||||
private final FileOutputStream out;
|
private final FileOutputStream out;
|
||||||
private byte[] currentBlock = new byte[BLOCK_SIZE];
|
private byte[] currentBlock = new byte[BLOCK_SIZE];
|
||||||
|
|
||||||
|
|
|
@ -28,26 +28,24 @@ import google.registry.testing.DatastoreHelper;
|
||||||
import google.registry.tools.EntityWrapper.Property;
|
import google.registry.tools.EntityWrapper.Property;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import org.junit.Rule;
|
import java.nio.file.Path;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.rules.TemporaryFolder;
|
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.jupiter.api.io.TempDir;
|
||||||
import org.junit.runners.JUnit4;
|
|
||||||
|
|
||||||
@RunWith(JUnit4.class)
|
/** Unit tests for {@link LevelDbFileBuilder}. */
|
||||||
public class LevelDbFileBuilderTest {
|
public class LevelDbFileBuilderTest {
|
||||||
|
|
||||||
public static final int BASE_ID = 1001;
|
private static final int BASE_ID = 1001;
|
||||||
|
|
||||||
@Rule public final TemporaryFolder tempFs = new TemporaryFolder();
|
@TempDir Path tmpDir;
|
||||||
|
|
||||||
@Rule
|
@RegisterExtension
|
||||||
public final AppEngineRule appEngine = AppEngineRule.builder().withDatastoreAndCloudSql().build();
|
public final AppEngineRule appEngine = AppEngineRule.builder().withDatastoreAndCloudSql().build();
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSingleRecordWrites() throws IOException {
|
void testSingleRecordWrites() throws IOException {
|
||||||
File subdir = tempFs.newFolder("folder");
|
File logFile = tmpDir.resolve("testfile").toFile();
|
||||||
File logFile = new File(subdir, "testfile");
|
|
||||||
LevelDbFileBuilder builder = new LevelDbFileBuilder(logFile);
|
LevelDbFileBuilder builder = new LevelDbFileBuilder(logFile);
|
||||||
EntityWrapper entity =
|
EntityWrapper entity =
|
||||||
EntityWrapper.from(
|
EntityWrapper.from(
|
||||||
|
@ -64,9 +62,8 @@ public class LevelDbFileBuilderTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMultipleRecordWrites() throws IOException {
|
void testMultipleRecordWrites() throws IOException {
|
||||||
File subdir = tempFs.newFolder("folder");
|
File logFile = tmpDir.resolve("testfile").toFile();
|
||||||
File logFile = new File(subdir, "testfile");
|
|
||||||
LevelDbFileBuilder builder = new LevelDbFileBuilder(logFile);
|
LevelDbFileBuilder builder = new LevelDbFileBuilder(logFile);
|
||||||
|
|
||||||
// Generate enough records to cross a block boundary. These records end up being around 80
|
// Generate enough records to cross a block boundary. These records end up being around 80
|
||||||
|
@ -93,9 +90,8 @@ public class LevelDbFileBuilderTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testOfyEntityWrite() throws Exception {
|
void testOfyEntityWrite() throws Exception {
|
||||||
File subdir = tempFs.newFolder("folder");
|
File logFile = tmpDir.resolve("testfile").toFile();
|
||||||
File logFile = new File(subdir, "testfile");
|
|
||||||
LevelDbFileBuilder builder = new LevelDbFileBuilder(logFile);
|
LevelDbFileBuilder builder = new LevelDbFileBuilder(logFile);
|
||||||
|
|
||||||
ContactResource contact = DatastoreHelper.newContactResource("contact");
|
ContactResource contact = DatastoreHelper.newContactResource("contact");
|
||||||
|
|
|
@ -31,7 +31,7 @@ import java.util.List;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
/** Unit tests of {@link LevelDbLogReader}. */
|
/** Unit tests of {@link LevelDbLogReader}. */
|
||||||
public final class LevelDbLogReaderTest {
|
final class LevelDbLogReaderTest {
|
||||||
|
|
||||||
// Size of the test record. Any value < 256 will do.
|
// Size of the test record. Any value < 256 will do.
|
||||||
private static final int TEST_RECORD_SIZE = 231;
|
private static final int TEST_RECORD_SIZE = 231;
|
||||||
|
@ -53,13 +53,13 @@ public final class LevelDbLogReaderTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSimpleBlock() throws IOException {
|
void testSimpleBlock() throws IOException {
|
||||||
TestBlock block = makeBlockOfRepeatingBytes(0);
|
TestBlock block = makeBlockOfRepeatingBytes(0);
|
||||||
assertThat(readIncrementally(block.data)).hasSize(block.recordCount);
|
assertThat(readIncrementally(block.data)).hasSize(block.recordCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testLargeRecord() throws IOException {
|
void testLargeRecord() throws IOException {
|
||||||
byte[] block0 = new byte[LevelDbLogReader.BLOCK_SIZE];
|
byte[] block0 = new byte[LevelDbLogReader.BLOCK_SIZE];
|
||||||
addRecord(block0, 0, ChunkType.FIRST, MAX_RECORD, (byte) 1);
|
addRecord(block0, 0, ChunkType.FIRST, MAX_RECORD, (byte) 1);
|
||||||
assertThat(readIncrementally(block0)).isEmpty();
|
assertThat(readIncrementally(block0)).isEmpty();
|
||||||
|
@ -88,7 +88,7 @@ public final class LevelDbLogReaderTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void readFromMultiBlockStream() throws IOException {
|
void readFromMultiBlockStream() throws IOException {
|
||||||
TestBlock block0 = makeBlockOfRepeatingBytes(0);
|
TestBlock block0 = makeBlockOfRepeatingBytes(0);
|
||||||
TestBlock block1 = makeBlockOfRepeatingBytes(138);
|
TestBlock block1 = makeBlockOfRepeatingBytes(138);
|
||||||
assertThat(readIncrementally(block0.data, block1.data))
|
assertThat(readIncrementally(block0.data, block1.data))
|
||||||
|
@ -112,7 +112,7 @@ public final class LevelDbLogReaderTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testChunkTypesToCode() {
|
void testChunkTypesToCode() {
|
||||||
// Verify that we're translating chunk types to code values correctly.z
|
// Verify that we're translating chunk types to code values correctly.z
|
||||||
assertThat(ChunkType.fromCode(ChunkType.END.getCode())).isEqualTo(ChunkType.END);
|
assertThat(ChunkType.fromCode(ChunkType.END.getCode())).isEqualTo(ChunkType.END);
|
||||||
assertThat(ChunkType.fromCode(ChunkType.FULL.getCode())).isEqualTo(ChunkType.FULL);
|
assertThat(ChunkType.fromCode(ChunkType.FULL.getCode())).isEqualTo(ChunkType.FULL);
|
||||||
|
|
|
@ -20,7 +20,7 @@ import google.registry.tools.LevelDbLogReader.ChunkType;
|
||||||
|
|
||||||
class LevelDbUtil {
|
class LevelDbUtil {
|
||||||
|
|
||||||
public static final int MAX_RECORD = LevelDbLogReader.BLOCK_SIZE - LevelDbLogReader.HEADER_SIZE;
|
static final int MAX_RECORD = LevelDbLogReader.BLOCK_SIZE - LevelDbLogReader.HEADER_SIZE;
|
||||||
|
|
||||||
/** Adds a new record header to "bytes" at "pos", returns the new position. */
|
/** Adds a new record header to "bytes" at "pos", returns the new position. */
|
||||||
private static int addRecordHeader(byte[] bytes, int pos, ChunkType type, int size) {
|
private static int addRecordHeader(byte[] bytes, int pos, ChunkType type, int size) {
|
||||||
|
|
|
@ -27,9 +27,9 @@ import google.registry.model.registry.Registry;
|
||||||
import google.registry.testing.FakeClock;
|
import google.registry.testing.FakeClock;
|
||||||
import google.registry.testing.InjectRule;
|
import google.registry.testing.InjectRule;
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Rule;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||||
|
|
||||||
/** Unit tests for {@link ListCursorsCommand}. */
|
/** Unit tests for {@link ListCursorsCommand}. */
|
||||||
public class ListCursorsCommandTest extends CommandTestCase<ListCursorsCommand> {
|
public class ListCursorsCommandTest extends CommandTestCase<ListCursorsCommand> {
|
||||||
|
@ -40,22 +40,22 @@ public class ListCursorsCommandTest extends CommandTestCase<ListCursorsCommand>
|
||||||
private static final String HEADER_TWO =
|
private static final String HEADER_TWO =
|
||||||
"--------------------------------------------------------------------------";
|
"--------------------------------------------------------------------------";
|
||||||
|
|
||||||
@Rule public final InjectRule inject = new InjectRule();
|
@RegisterExtension public final InjectRule inject = new InjectRule();
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void before() {
|
void beforeEach() {
|
||||||
inject.setStaticField(
|
inject.setStaticField(
|
||||||
Ofy.class, "clock", new FakeClock(DateTime.parse("1984-12-21T06:07:08.789Z")));
|
Ofy.class, "clock", new FakeClock(DateTime.parse("1984-12-21T06:07:08.789Z")));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testListCursors_noTlds_printsNothing() throws Exception {
|
void testListCursors_noTlds_printsNothing() throws Exception {
|
||||||
runCommand("--type=BRDA");
|
runCommand("--type=BRDA");
|
||||||
assertThat(getStdoutAsString()).isEmpty();
|
assertThat(getStdoutAsString()).isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testListCursors_twoTldsOneAbsent_printsAbsentAndTimestampSorted() throws Exception {
|
void testListCursors_twoTldsOneAbsent_printsAbsentAndTimestampSorted() throws Exception {
|
||||||
createTlds("foo", "bar");
|
createTlds("foo", "bar");
|
||||||
persistResource(
|
persistResource(
|
||||||
Cursor.create(CursorType.BRDA, DateTime.parse("1984-12-18TZ"), Registry.get("bar")));
|
Cursor.create(CursorType.BRDA, DateTime.parse("1984-12-18TZ"), Registry.get("bar")));
|
||||||
|
@ -70,19 +70,19 @@ public class ListCursorsCommandTest extends CommandTestCase<ListCursorsCommand>
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testListCursors_badCursor_throwsIae() {
|
void testListCursors_badCursor_throwsIae() {
|
||||||
ParameterException thrown =
|
ParameterException thrown =
|
||||||
assertThrows(ParameterException.class, () -> runCommand("--type=love"));
|
assertThrows(ParameterException.class, () -> runCommand("--type=love"));
|
||||||
assertThat(thrown).hasMessageThat().contains("Invalid value for --type parameter.");
|
assertThat(thrown).hasMessageThat().contains("Invalid value for --type parameter.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testListCursors_lowercaseCursor_isAllowed() throws Exception {
|
void testListCursors_lowercaseCursor_isAllowed() throws Exception {
|
||||||
runCommand("--type=brda");
|
runCommand("--type=brda");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testListCursors_filterEscrowEnabled_doesWhatItSays() throws Exception {
|
void testListCursors_filterEscrowEnabled_doesWhatItSays() throws Exception {
|
||||||
createTlds("foo", "bar");
|
createTlds("foo", "bar");
|
||||||
persistResource(Registry.get("bar").asBuilder().setEscrowEnabled(true).build());
|
persistResource(Registry.get("bar").asBuilder().setEscrowEnabled(true).build());
|
||||||
runCommand("--type=BRDA", "--escrow_enabled");
|
runCommand("--type=BRDA", "--escrow_enabled");
|
||||||
|
|
|
@ -27,18 +27,14 @@ import google.registry.testing.FakeClock;
|
||||||
import google.registry.util.Clock;
|
import google.registry.util.Clock;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
import org.junit.runners.JUnit4;
|
|
||||||
import org.mockito.ArgumentCaptor;
|
import org.mockito.ArgumentCaptor;
|
||||||
import org.mockito.Captor;
|
import org.mockito.Captor;
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
|
|
||||||
/** Unit tests for {@link google.registry.tools.ListDatastoreOperationsCommand}. */
|
/** Unit tests for {@link google.registry.tools.ListDatastoreOperationsCommand}. */
|
||||||
@RunWith(JUnit4.class)
|
class ListDatastoreOperationsCommandTest extends CommandTestCase<ListDatastoreOperationsCommand> {
|
||||||
public class ListDatastoreOperationsCommandTest
|
|
||||||
extends CommandTestCase<ListDatastoreOperationsCommand> {
|
|
||||||
|
|
||||||
@Mock private DatastoreAdmin datastoreAdmin;
|
@Mock private DatastoreAdmin datastoreAdmin;
|
||||||
@Mock private ListOperations listOperationsRequest;
|
@Mock private ListOperations listOperationsRequest;
|
||||||
|
@ -46,25 +42,24 @@ public class ListDatastoreOperationsCommandTest
|
||||||
|
|
||||||
private final Clock clock = new FakeClock(new DateTime("2019-01-01T00:00:30Z"));
|
private final Clock clock = new FakeClock(new DateTime("2019-01-01T00:00:30Z"));
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setup() throws IOException {
|
void beforeEach() throws IOException {
|
||||||
command.datastoreAdmin = datastoreAdmin;
|
command.datastoreAdmin = datastoreAdmin;
|
||||||
command.clock = clock;
|
command.clock = clock;
|
||||||
|
|
||||||
when(datastoreAdmin.list(filterClause.capture())).thenReturn(listOperationsRequest);
|
|
||||||
when(datastoreAdmin.listAll()).thenReturn(listOperationsRequest);
|
|
||||||
when(listOperationsRequest.execute()).thenReturn(new OperationList());
|
when(listOperationsRequest.execute()).thenReturn(new OperationList());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testListAll() throws Exception {
|
void testListAll() throws Exception {
|
||||||
|
when(datastoreAdmin.listAll()).thenReturn(listOperationsRequest);
|
||||||
runCommand();
|
runCommand();
|
||||||
verify(datastoreAdmin, times(1)).listAll();
|
verify(datastoreAdmin, times(1)).listAll();
|
||||||
verifyNoMoreInteractions(datastoreAdmin);
|
verifyNoMoreInteractions(datastoreAdmin);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testListWithFilter() throws Exception {
|
void testListWithFilter() throws Exception {
|
||||||
|
when(datastoreAdmin.list(filterClause.capture())).thenReturn(listOperationsRequest);
|
||||||
runCommand("--start_time_filter=PT30S");
|
runCommand("--start_time_filter=PT30S");
|
||||||
verify(datastoreAdmin, times(1)).list(filterClause.capture());
|
verify(datastoreAdmin, times(1)).list(filterClause.capture());
|
||||||
assertThat(filterClause.getValue())
|
assertThat(filterClause.getValue())
|
||||||
|
|
|
@ -27,7 +27,9 @@ import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.net.MediaType;
|
import com.google.common.net.MediaType;
|
||||||
import google.registry.model.registry.Registry.TldType;
|
import google.registry.model.registry.Registry.TldType;
|
||||||
import google.registry.tools.server.ListDomainsAction;
|
import google.registry.tools.server.ListDomainsAction;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.mockito.junit.jupiter.MockitoSettings;
|
||||||
|
import org.mockito.quality.Strictness;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unit tests for {@link ListDomainsCommand}.
|
* Unit tests for {@link ListDomainsCommand}.
|
||||||
|
@ -47,7 +49,8 @@ public class ListDomainsCommandTest extends ListObjectsCommandTestCase<ListDomai
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_tldsParamTooLong() {
|
@MockitoSettings(strictness = Strictness.LENIENT)
|
||||||
|
void test_tldsParamTooLong() {
|
||||||
String tldsParam = "--tlds=foo,bar" + Strings.repeat(",baz", 300);
|
String tldsParam = "--tlds=foo,bar" + Strings.repeat(",baz", 300);
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(IllegalArgumentException.class, () -> runCommand(tldsParam));
|
assertThrows(IllegalArgumentException.class, () -> runCommand(tldsParam));
|
||||||
|
@ -57,7 +60,7 @@ public class ListDomainsCommandTest extends ListObjectsCommandTestCase<ListDomai
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_bothParamsSpecified() throws Exception {
|
void test_bothParamsSpecified() throws Exception {
|
||||||
runCommand("--tlds=foo,bar", "--limit=100");
|
runCommand("--tlds=foo,bar", "--limit=100");
|
||||||
verify(connection)
|
verify(connection)
|
||||||
.sendPostRequest(
|
.sendPostRequest(
|
||||||
|
@ -68,7 +71,7 @@ public class ListDomainsCommandTest extends ListObjectsCommandTestCase<ListDomai
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_defaultsToAllRealTlds() throws Exception {
|
void test_defaultsToAllRealTlds() throws Exception {
|
||||||
createTlds("tldone", "tldtwo");
|
createTlds("tldone", "tldtwo");
|
||||||
persistResource(newRegistry("fake", "FAKE").asBuilder().setTldType(TldType.TEST).build());
|
persistResource(newRegistry("fake", "FAKE").asBuilder().setTldType(TldType.TEST).build());
|
||||||
runCommand();
|
runCommand();
|
||||||
|
|
|
@ -21,7 +21,7 @@ import google.registry.tools.server.ListHostsAction;
|
||||||
*
|
*
|
||||||
* @see ListObjectsCommandTestCase
|
* @see ListObjectsCommandTestCase
|
||||||
*/
|
*/
|
||||||
public class ListHostsCommandTest extends ListObjectsCommandTestCase<ListHostsCommand> {
|
class ListHostsCommandTest extends ListObjectsCommandTestCase<ListHostsCommand> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
final String getTaskPath() {
|
final String getTaskPath() {
|
||||||
|
|
|
@ -29,8 +29,8 @@ import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.net.MediaType;
|
import com.google.common.net.MediaType;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
|
|
||||||
/** Abstract base class for unit tests of commands that list object data using a back-end task. */
|
/** Abstract base class for unit tests of commands that list object data using a back-end task. */
|
||||||
|
@ -47,16 +47,14 @@ public abstract class ListObjectsCommandTestCase<C extends ListObjectsCommand>
|
||||||
return ImmutableMap.of();
|
return ImmutableMap.of();
|
||||||
}
|
}
|
||||||
|
|
||||||
ImmutableList<String> otherParams = ImmutableList.of();
|
private ImmutableList<String> otherParams = ImmutableList.of();
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void init() throws Exception {
|
void beforeEachListObjectsCommandTestCase() throws Exception {
|
||||||
ImmutableMap<String, Object> otherParameters = getOtherParameters();
|
ImmutableMap<String, Object> otherParameters = getOtherParameters();
|
||||||
if (!otherParameters.isEmpty()) {
|
if (!otherParameters.isEmpty()) {
|
||||||
otherParams =
|
otherParams =
|
||||||
otherParameters
|
otherParameters.entrySet().stream()
|
||||||
.entrySet()
|
|
||||||
.stream()
|
|
||||||
.map(entry -> String.format("--%s=%s", entry.getKey(), entry.getValue()))
|
.map(entry -> String.format("--%s=%s", entry.getKey(), entry.getValue()))
|
||||||
.collect(toImmutableList());
|
.collect(toImmutableList());
|
||||||
}
|
}
|
||||||
|
@ -83,26 +81,26 @@ public abstract class ListObjectsCommandTestCase<C extends ListObjectsCommand>
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRun_noFields() throws Exception {
|
void testRun_noFields() throws Exception {
|
||||||
runCommand(otherParams);
|
runCommand(otherParams);
|
||||||
verifySent(null, Optional.empty(), Optional.empty());
|
verifySent(null, Optional.empty(), Optional.empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRun_oneField() throws Exception {
|
void testRun_oneField() throws Exception {
|
||||||
runCommand(
|
runCommand(
|
||||||
new ImmutableList.Builder<String>().addAll(otherParams).add("--fields=fieldName").build());
|
new ImmutableList.Builder<String>().addAll(otherParams).add("--fields=fieldName").build());
|
||||||
verifySent("fieldName", Optional.empty(), Optional.empty());
|
verifySent("fieldName", Optional.empty(), Optional.empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRun_wildcardField() throws Exception {
|
void testRun_wildcardField() throws Exception {
|
||||||
runCommand(new ImmutableList.Builder<String>().addAll(otherParams).add("--fields=*").build());
|
runCommand(new ImmutableList.Builder<String>().addAll(otherParams).add("--fields=*").build());
|
||||||
verifySent("*", Optional.empty(), Optional.empty());
|
verifySent("*", Optional.empty(), Optional.empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRun_header() throws Exception {
|
void testRun_header() throws Exception {
|
||||||
runCommand(
|
runCommand(
|
||||||
new ImmutableList.Builder<String>()
|
new ImmutableList.Builder<String>()
|
||||||
.addAll(otherParams)
|
.addAll(otherParams)
|
||||||
|
@ -112,7 +110,7 @@ public abstract class ListObjectsCommandTestCase<C extends ListObjectsCommand>
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRun_noHeader() throws Exception {
|
void testRun_noHeader() throws Exception {
|
||||||
runCommand(
|
runCommand(
|
||||||
new ImmutableList.Builder<String>()
|
new ImmutableList.Builder<String>()
|
||||||
.addAll(otherParams)
|
.addAll(otherParams)
|
||||||
|
@ -122,7 +120,7 @@ public abstract class ListObjectsCommandTestCase<C extends ListObjectsCommand>
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRun_fullFieldNames() throws Exception {
|
void testRun_fullFieldNames() throws Exception {
|
||||||
runCommand(
|
runCommand(
|
||||||
new ImmutableList.Builder<String>()
|
new ImmutableList.Builder<String>()
|
||||||
.addAll(otherParams)
|
.addAll(otherParams)
|
||||||
|
@ -132,7 +130,7 @@ public abstract class ListObjectsCommandTestCase<C extends ListObjectsCommand>
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRun_allParameters() throws Exception {
|
void testRun_allParameters() throws Exception {
|
||||||
runCommand(
|
runCommand(
|
||||||
new ImmutableList.Builder<String>()
|
new ImmutableList.Builder<String>()
|
||||||
.addAll(otherParams)
|
.addAll(otherParams)
|
||||||
|
|
|
@ -21,8 +21,7 @@ import google.registry.tools.server.ListPremiumListsAction;
|
||||||
*
|
*
|
||||||
* @see ListObjectsCommandTestCase
|
* @see ListObjectsCommandTestCase
|
||||||
*/
|
*/
|
||||||
public class ListPremiumListsCommandTest
|
class ListPremiumListsCommandTest extends ListObjectsCommandTestCase<ListPremiumListsCommand> {
|
||||||
extends ListObjectsCommandTestCase<ListPremiumListsCommand> {
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
final String getTaskPath() {
|
final String getTaskPath() {
|
||||||
|
|
|
@ -21,8 +21,7 @@ import google.registry.tools.server.ListRegistrarsAction;
|
||||||
*
|
*
|
||||||
* @see ListObjectsCommandTestCase
|
* @see ListObjectsCommandTestCase
|
||||||
*/
|
*/
|
||||||
public class ListRegistrarsCommandTest
|
class ListRegistrarsCommandTest extends ListObjectsCommandTestCase<ListRegistrarsCommand> {
|
||||||
extends ListObjectsCommandTestCase<ListRegistrarsCommand> {
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
final String getTaskPath() {
|
final String getTaskPath() {
|
||||||
|
|
|
@ -21,8 +21,7 @@ import google.registry.tools.server.ListReservedListsAction;
|
||||||
*
|
*
|
||||||
* @see ListObjectsCommandTestCase
|
* @see ListObjectsCommandTestCase
|
||||||
*/
|
*/
|
||||||
public class ListReservedListsCommandTest
|
class ListReservedListsCommandTest extends ListObjectsCommandTestCase<ListReservedListsCommand> {
|
||||||
extends ListObjectsCommandTestCase<ListReservedListsCommand> {
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
final String getTaskPath() {
|
final String getTaskPath() {
|
||||||
|
|
|
@ -21,7 +21,7 @@ import google.registry.tools.server.ListTldsAction;
|
||||||
*
|
*
|
||||||
* @see ListObjectsCommandTestCase
|
* @see ListObjectsCommandTestCase
|
||||||
*/
|
*/
|
||||||
public class ListTldsCommandTest extends ListObjectsCommandTestCase<ListTldsCommand> {
|
class ListTldsCommandTest extends ListObjectsCommandTestCase<ListTldsCommand> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
final String getTaskPath() {
|
final String getTaskPath() {
|
||||||
|
|
|
@ -17,33 +17,33 @@ package google.registry.tools;
|
||||||
import static google.registry.testing.DatastoreHelper.createTld;
|
import static google.registry.testing.DatastoreHelper.createTld;
|
||||||
import static google.registry.testing.DatastoreHelper.persistNewRegistrar;
|
import static google.registry.testing.DatastoreHelper.persistNewRegistrar;
|
||||||
import static org.mockito.ArgumentMatchers.eq;
|
import static org.mockito.ArgumentMatchers.eq;
|
||||||
import static org.mockito.Mockito.mock;
|
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.verifyZeroInteractions;
|
import static org.mockito.Mockito.verifyNoInteractions;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.net.MediaType;
|
import com.google.common.net.MediaType;
|
||||||
import google.registry.model.registrar.Registrar;
|
import google.registry.model.registrar.Registrar;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.mockito.Mock;
|
||||||
import org.junit.runners.JUnit4;
|
|
||||||
|
|
||||||
@RunWith(JUnit4.class)
|
/** Unit tests for {@link LoadTestCommand}. */
|
||||||
public class LoadTestCommandTest extends CommandTestCase<LoadTestCommand> {
|
class LoadTestCommandTest extends CommandTestCase<LoadTestCommand> {
|
||||||
AppEngineConnection connection = mock(AppEngineConnection.class);
|
|
||||||
|
|
||||||
@Before
|
@Mock private AppEngineConnection connection;
|
||||||
public void setUp() {
|
|
||||||
|
@BeforeEach
|
||||||
|
void beforeEach() {
|
||||||
command.setConnection(connection);
|
command.setConnection(connection);
|
||||||
createTld("example");
|
createTld("example");
|
||||||
persistNewRegistrar("acme", "ACME", Registrar.Type.REAL, 99L);
|
persistNewRegistrar("acme", "ACME", Registrar.Type.REAL, 99L);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_defaults() throws Exception {
|
void test_defaults() throws Exception {
|
||||||
runCommandForced();
|
runCommandForced();
|
||||||
ImmutableMap<String, Object> parms = new ImmutableMap.Builder<String, Object>()
|
ImmutableMap<String, Object> params =
|
||||||
|
new ImmutableMap.Builder<String, Object>()
|
||||||
.put("tld", "example")
|
.put("tld", "example")
|
||||||
.put("clientId", "acme")
|
.put("clientId", "acme")
|
||||||
.put("successfulHostCreates", 1)
|
.put("successfulHostCreates", 1)
|
||||||
|
@ -56,11 +56,11 @@ public class LoadTestCommandTest extends CommandTestCase<LoadTestCommand> {
|
||||||
.build();
|
.build();
|
||||||
verify(connection)
|
verify(connection)
|
||||||
.sendPostRequest(
|
.sendPostRequest(
|
||||||
eq("/_dr/loadtest"), eq(parms), eq(MediaType.PLAIN_TEXT_UTF_8), eq(new byte[0]));
|
eq("/_dr/loadtest"), eq(params), eq(MediaType.PLAIN_TEXT_UTF_8), eq(new byte[0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_overrides() throws Exception {
|
void test_overrides() throws Exception {
|
||||||
createTld("foo");
|
createTld("foo");
|
||||||
runCommandForced(
|
runCommandForced(
|
||||||
"--tld=foo",
|
"--tld=foo",
|
||||||
|
@ -72,7 +72,8 @@ public class LoadTestCommandTest extends CommandTestCase<LoadTestCommand> {
|
||||||
"--domain_infos=14",
|
"--domain_infos=14",
|
||||||
"--contact_infos=15",
|
"--contact_infos=15",
|
||||||
"--run_seconds=16");
|
"--run_seconds=16");
|
||||||
ImmutableMap<String, Object> parms = new ImmutableMap.Builder<String, Object>()
|
ImmutableMap<String, Object> params =
|
||||||
|
new ImmutableMap.Builder<String, Object>()
|
||||||
.put("tld", "foo")
|
.put("tld", "foo")
|
||||||
.put("clientId", "NewRegistrar")
|
.put("clientId", "NewRegistrar")
|
||||||
.put("successfulHostCreates", 10)
|
.put("successfulHostCreates", 10)
|
||||||
|
@ -85,25 +86,25 @@ public class LoadTestCommandTest extends CommandTestCase<LoadTestCommand> {
|
||||||
.build();
|
.build();
|
||||||
verify(connection)
|
verify(connection)
|
||||||
.sendPostRequest(
|
.sendPostRequest(
|
||||||
eq("/_dr/loadtest"), eq(parms), eq(MediaType.PLAIN_TEXT_UTF_8), eq(new byte[0]));
|
eq("/_dr/loadtest"), eq(params), eq(MediaType.PLAIN_TEXT_UTF_8), eq(new byte[0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_badTLD() throws Exception {
|
void test_badTLD() throws Exception {
|
||||||
runCommand("--tld=bogus");
|
runCommand("--tld=bogus");
|
||||||
verifyZeroInteractions(connection);
|
verifyNoInteractions(connection);
|
||||||
assertInStderr("No such TLD: bogus");
|
assertInStderr("No such TLD: bogus");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_badClientId() throws Exception {
|
void test_badClientId() throws Exception {
|
||||||
runCommand("--client_id=badaddry");
|
runCommand("--client_id=badaddry");
|
||||||
verifyZeroInteractions(connection);
|
verifyNoInteractions(connection);
|
||||||
assertInStderr("No such client: badaddry");
|
assertInStderr("No such client: badaddry");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_noProduction() throws Exception {
|
void test_noProduction() throws Exception {
|
||||||
runCommandInEnvironment(RegistryToolEnvironment.PRODUCTION);
|
runCommandInEnvironment(RegistryToolEnvironment.PRODUCTION);
|
||||||
assertInStderr("You may not run a load test against production.");
|
assertInStderr("You may not run a load test against production.");
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,14 +37,14 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import org.joda.time.Duration;
|
import org.joda.time.Duration;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
/** Unit tests for {@link LockDomainCommand}. */
|
/** Unit tests for {@link LockDomainCommand}. */
|
||||||
public class LockDomainCommandTest extends CommandTestCase<LockDomainCommand> {
|
class LockDomainCommandTest extends CommandTestCase<LockDomainCommand> {
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void before() {
|
void beforeEach() {
|
||||||
persistNewRegistrar("adminreg", "Admin Registrar", Type.REAL, 693L);
|
persistNewRegistrar("adminreg", "Admin Registrar", Type.REAL, 693L);
|
||||||
createTld("tld");
|
createTld("tld");
|
||||||
command.registryAdminClientId = "adminreg";
|
command.registryAdminClientId = "adminreg";
|
||||||
|
@ -57,7 +57,7 @@ public class LockDomainCommandTest extends CommandTestCase<LockDomainCommand> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_locksDomain() throws Exception {
|
void testSuccess_locksDomain() throws Exception {
|
||||||
DomainBase domain = persistActiveDomain("example.tld");
|
DomainBase domain = persistActiveDomain("example.tld");
|
||||||
runCommandForced("--client=TheRegistrar", "example.tld");
|
runCommandForced("--client=TheRegistrar", "example.tld");
|
||||||
assertThat(reloadResource(domain).getStatusValues())
|
assertThat(reloadResource(domain).getStatusValues())
|
||||||
|
@ -65,7 +65,7 @@ public class LockDomainCommandTest extends CommandTestCase<LockDomainCommand> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_partiallyUpdatesStatuses() throws Exception {
|
void testSuccess_partiallyUpdatesStatuses() throws Exception {
|
||||||
DomainBase domain =
|
DomainBase domain =
|
||||||
persistResource(
|
persistResource(
|
||||||
newDomainBase("example.tld")
|
newDomainBase("example.tld")
|
||||||
|
@ -78,7 +78,7 @@ public class LockDomainCommandTest extends CommandTestCase<LockDomainCommand> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_manyDomains() throws Exception {
|
void testSuccess_manyDomains() throws Exception {
|
||||||
// Create 26 domains -- one more than the number of entity groups allowed in a transaction (in
|
// Create 26 domains -- one more than the number of entity groups allowed in a transaction (in
|
||||||
// case that was going to be the failure point).
|
// case that was going to be the failure point).
|
||||||
List<DomainBase> domains = new ArrayList<>();
|
List<DomainBase> domains = new ArrayList<>();
|
||||||
|
@ -98,7 +98,7 @@ public class LockDomainCommandTest extends CommandTestCase<LockDomainCommand> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_domainDoesntExist() {
|
void testFailure_domainDoesntExist() {
|
||||||
IllegalArgumentException e =
|
IllegalArgumentException e =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
|
@ -107,7 +107,7 @@ public class LockDomainCommandTest extends CommandTestCase<LockDomainCommand> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_alreadyLockedDomain_performsNoAction() throws Exception {
|
void testSuccess_alreadyLockedDomain_performsNoAction() throws Exception {
|
||||||
DomainBase domain =
|
DomainBase domain =
|
||||||
persistResource(
|
persistResource(
|
||||||
newDomainBase("example.tld")
|
newDomainBase("example.tld")
|
||||||
|
@ -119,7 +119,7 @@ public class LockDomainCommandTest extends CommandTestCase<LockDomainCommand> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_defaultsToAdminRegistrar_ifUnspecified() throws Exception {
|
void testSuccess_defaultsToAdminRegistrar_ifUnspecified() throws Exception {
|
||||||
DomainBase domain = persistActiveDomain("example.tld");
|
DomainBase domain = persistActiveDomain("example.tld");
|
||||||
runCommandForced("example.tld");
|
runCommandForced("example.tld");
|
||||||
assertThat(getMostRecentRegistryLockByRepoId(domain.getRepoId()).get().getRegistrarId())
|
assertThat(getMostRecentRegistryLockByRepoId(domain.getRepoId()).get().getRegistrarId())
|
||||||
|
@ -127,7 +127,7 @@ public class LockDomainCommandTest extends CommandTestCase<LockDomainCommand> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_duplicateDomainsAreSpecified() {
|
void testFailure_duplicateDomainsAreSpecified() {
|
||||||
IllegalArgumentException e =
|
IllegalArgumentException e =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
|
|
|
@ -29,30 +29,27 @@ import google.registry.model.registrar.Registrar;
|
||||||
import google.registry.testing.AppEngineRule;
|
import google.registry.testing.AppEngineRule;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Rule;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
import org.junit.runners.JUnit4;
|
|
||||||
|
|
||||||
/** Unit tests for {@link MutatingCommand}. */
|
/** Unit tests for {@link MutatingCommand}. */
|
||||||
@RunWith(JUnit4.class)
|
|
||||||
public class MutatingCommandTest {
|
public class MutatingCommandTest {
|
||||||
|
|
||||||
@Rule
|
@RegisterExtension
|
||||||
public final AppEngineRule appEngine = AppEngineRule.builder().withDatastoreAndCloudSql().build();
|
public final AppEngineRule appEngine = AppEngineRule.builder().withDatastoreAndCloudSql().build();
|
||||||
|
|
||||||
Registrar registrar1;
|
private Registrar registrar1;
|
||||||
Registrar registrar2;
|
private Registrar registrar2;
|
||||||
Registrar newRegistrar1;
|
private Registrar newRegistrar1;
|
||||||
Registrar newRegistrar2;
|
private Registrar newRegistrar2;
|
||||||
HostResource host1;
|
private HostResource host1;
|
||||||
HostResource host2;
|
private HostResource host2;
|
||||||
HostResource newHost1;
|
private HostResource newHost1;
|
||||||
HostResource newHost2;
|
private HostResource newHost2;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void init() {
|
void beforeEach() {
|
||||||
registrar1 = persistNewRegistrar("Registrar1", "Registrar1", Registrar.Type.REAL, 1L);
|
registrar1 = persistNewRegistrar("Registrar1", "Registrar1", Registrar.Type.REAL, 1L);
|
||||||
registrar2 = persistNewRegistrar("Registrar2", "Registrar2", Registrar.Type.REAL, 2L);
|
registrar2 = persistNewRegistrar("Registrar2", "Registrar2", Registrar.Type.REAL, 2L);
|
||||||
newRegistrar1 = registrar1.asBuilder().setBillingIdentifier(42L).build();
|
newRegistrar1 = registrar1.asBuilder().setBillingIdentifier(42L).build();
|
||||||
|
@ -68,7 +65,7 @@ public class MutatingCommandTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_noChanges() throws Exception {
|
void testSuccess_noChanges() throws Exception {
|
||||||
MutatingCommand command = new MutatingCommand() {
|
MutatingCommand command = new MutatingCommand() {
|
||||||
@Override
|
@Override
|
||||||
protected void init() {}
|
protected void init() {}
|
||||||
|
@ -79,7 +76,7 @@ public class MutatingCommandTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_update() throws Exception {
|
void testSuccess_update() throws Exception {
|
||||||
MutatingCommand command = new MutatingCommand() {
|
MutatingCommand command = new MutatingCommand() {
|
||||||
@Override
|
@Override
|
||||||
public void init() {
|
public void init() {
|
||||||
|
@ -112,7 +109,7 @@ public class MutatingCommandTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_create() throws Exception {
|
void testSuccess_create() throws Exception {
|
||||||
ofy().deleteWithoutBackup().entities(Arrays.asList(host1, host2, registrar1, registrar2)).now();
|
ofy().deleteWithoutBackup().entities(Arrays.asList(host1, host2, registrar1, registrar2)).now();
|
||||||
MutatingCommand command = new MutatingCommand() {
|
MutatingCommand command = new MutatingCommand() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -146,7 +143,7 @@ public class MutatingCommandTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_delete() throws Exception {
|
void testSuccess_delete() throws Exception {
|
||||||
MutatingCommand command = new MutatingCommand() {
|
MutatingCommand command = new MutatingCommand() {
|
||||||
@Override
|
@Override
|
||||||
protected void init() {
|
protected void init() {
|
||||||
|
@ -179,7 +176,7 @@ public class MutatingCommandTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_noopUpdate() throws Exception {
|
void testSuccess_noopUpdate() throws Exception {
|
||||||
MutatingCommand command = new MutatingCommand() {
|
MutatingCommand command = new MutatingCommand() {
|
||||||
@Override
|
@Override
|
||||||
protected void init() {
|
protected void init() {
|
||||||
|
@ -203,7 +200,7 @@ public class MutatingCommandTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_batching() throws Exception {
|
void testSuccess_batching() throws Exception {
|
||||||
MutatingCommand command = new MutatingCommand() {
|
MutatingCommand command = new MutatingCommand() {
|
||||||
@Override
|
@Override
|
||||||
protected void init() {
|
protected void init() {
|
||||||
|
@ -239,7 +236,7 @@ public class MutatingCommandTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_batching_partialExecutionWorks() throws Exception {
|
void testSuccess_batching_partialExecutionWorks() throws Exception {
|
||||||
// The expected behavior here is that the first transaction will work and be committed, and
|
// The expected behavior here is that the first transaction will work and be committed, and
|
||||||
// the second transaction will throw an IllegalStateException and not commit.
|
// the second transaction will throw an IllegalStateException and not commit.
|
||||||
MutatingCommand command = new MutatingCommand() {
|
MutatingCommand command = new MutatingCommand() {
|
||||||
|
@ -281,7 +278,7 @@ public class MutatingCommandTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_nullEntityChange() {
|
void testFailure_nullEntityChange() {
|
||||||
MutatingCommand command = new MutatingCommand() {
|
MutatingCommand command = new MutatingCommand() {
|
||||||
@Override
|
@Override
|
||||||
protected void init() {
|
protected void init() {
|
||||||
|
@ -292,7 +289,7 @@ public class MutatingCommandTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_updateSameEntityTwice() {
|
void testFailure_updateSameEntityTwice() {
|
||||||
MutatingCommand command =
|
MutatingCommand command =
|
||||||
new MutatingCommand() {
|
new MutatingCommand() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -309,7 +306,7 @@ public class MutatingCommandTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_updateDifferentLongId() {
|
void testFailure_updateDifferentLongId() {
|
||||||
MutatingCommand command = new MutatingCommand() {
|
MutatingCommand command = new MutatingCommand() {
|
||||||
@Override
|
@Override
|
||||||
protected void init() {
|
protected void init() {
|
||||||
|
@ -323,7 +320,7 @@ public class MutatingCommandTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_updateDifferentStringId() {
|
void testFailure_updateDifferentStringId() {
|
||||||
MutatingCommand command =
|
MutatingCommand command =
|
||||||
new MutatingCommand() {
|
new MutatingCommand() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -338,7 +335,7 @@ public class MutatingCommandTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_updateDifferentKind() {
|
void testFailure_updateDifferentKind() {
|
||||||
MutatingCommand command =
|
MutatingCommand command =
|
||||||
new MutatingCommand() {
|
new MutatingCommand() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -353,7 +350,7 @@ public class MutatingCommandTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_updateModifiedEntity() throws Exception {
|
void testFailure_updateModifiedEntity() throws Exception {
|
||||||
MutatingCommand command =
|
MutatingCommand command =
|
||||||
new MutatingCommand() {
|
new MutatingCommand() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -368,7 +365,7 @@ public class MutatingCommandTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_createExistingEntity() throws Exception {
|
void testFailure_createExistingEntity() throws Exception {
|
||||||
MutatingCommand command =
|
MutatingCommand command =
|
||||||
new MutatingCommand() {
|
new MutatingCommand() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -383,7 +380,7 @@ public class MutatingCommandTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_deleteChangedEntity() throws Exception {
|
void testFailure_deleteChangedEntity() throws Exception {
|
||||||
MutatingCommand command =
|
MutatingCommand command =
|
||||||
new MutatingCommand() {
|
new MutatingCommand() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -398,7 +395,7 @@ public class MutatingCommandTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_deleteRemovedEntity() throws Exception {
|
void testFailure_deleteRemovedEntity() throws Exception {
|
||||||
MutatingCommand command =
|
MutatingCommand command =
|
||||||
new MutatingCommand() {
|
new MutatingCommand() {
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -21,7 +21,7 @@ import com.beust.jcommander.Parameter;
|
||||||
import com.beust.jcommander.Parameters;
|
import com.beust.jcommander.Parameters;
|
||||||
import google.registry.tools.server.ToolsTestData;
|
import google.registry.tools.server.ToolsTestData;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
/** Unit tests for {@link MutatingEppToolCommand}. */
|
/** Unit tests for {@link MutatingEppToolCommand}. */
|
||||||
public class MutatingEppToolCommandTest extends EppToolCommandTestCase<MutatingEppToolCommand> {
|
public class MutatingEppToolCommandTest extends EppToolCommandTestCase<MutatingEppToolCommand> {
|
||||||
|
@ -50,7 +50,7 @@ public class MutatingEppToolCommandTest extends EppToolCommandTestCase<MutatingE
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_dryrun() throws Exception {
|
void testSuccess_dryrun() throws Exception {
|
||||||
// The choice of xml file is arbitrary.
|
// The choice of xml file is arbitrary.
|
||||||
runCommand(
|
runCommand(
|
||||||
"--client=NewRegistrar",
|
"--client=NewRegistrar",
|
||||||
|
@ -60,7 +60,7 @@ public class MutatingEppToolCommandTest extends EppToolCommandTestCase<MutatingE
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_cantUseForceWithDryRun() {
|
void testFailure_cantUseForceWithDryRun() {
|
||||||
Exception e =
|
Exception e =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
|
|
|
@ -21,7 +21,7 @@ import com.beust.jcommander.Parameter;
|
||||||
import com.beust.jcommander.Parameters;
|
import com.beust.jcommander.Parameters;
|
||||||
import google.registry.tools.server.ToolsTestData;
|
import google.registry.tools.server.ToolsTestData;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
/** Unit tests for {@link NonMutatingEppToolCommand}. */
|
/** Unit tests for {@link NonMutatingEppToolCommand}. */
|
||||||
public class NonMutatingEppToolCommandTest
|
public class NonMutatingEppToolCommandTest
|
||||||
|
@ -34,8 +34,7 @@ public class NonMutatingEppToolCommandTest
|
||||||
@Parameter(names = {"--client"})
|
@Parameter(names = {"--client"})
|
||||||
String clientId;
|
String clientId;
|
||||||
|
|
||||||
@Parameter
|
@Parameter List<String> xmlPayloads;
|
||||||
List<String> xmlPayloads;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void initEppToolCommand() {
|
void initEppToolCommand() {
|
||||||
|
@ -51,14 +50,14 @@ public class NonMutatingEppToolCommandTest
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_doesntPrompt_whenNotForced() throws Exception {
|
void testSuccess_doesntPrompt_whenNotForced() throws Exception {
|
||||||
// The choice of xml file is arbitrary.
|
// The choice of xml file is arbitrary.
|
||||||
runCommand("--client=NewRegistrar", ToolsTestData.loadFile("domain_check.xml"));
|
runCommand("--client=NewRegistrar", ToolsTestData.loadFile("domain_check.xml"));
|
||||||
eppVerifier.expectDryRun().verifySent("domain_check.xml");
|
eppVerifier.expectDryRun().verifySent("domain_check.xml");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_doesntAllowForce() {
|
void testFailure_doesntAllowForce() {
|
||||||
Exception e =
|
Exception e =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
|
|
|
@ -21,26 +21,23 @@ import google.registry.testing.AppEngineRule;
|
||||||
import google.registry.tools.EntityWrapper.Property;
|
import google.registry.tools.EntityWrapper.Property;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import org.junit.Rule;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||||
import org.junit.rules.TemporaryFolder;
|
import org.junit.jupiter.api.io.TempDir;
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
import org.junit.runners.JUnit4;
|
|
||||||
|
|
||||||
@RunWith(JUnit4.class)
|
/** Unit tests for {@link RecordAccumulator}. */
|
||||||
public class RecordAccumulatorTest {
|
public class RecordAccumulatorTest {
|
||||||
|
|
||||||
private static final int BASE_ID = 1001;
|
private static final int BASE_ID = 1001;
|
||||||
|
|
||||||
@Rule public final TemporaryFolder tempFs = new TemporaryFolder();
|
@TempDir public File tmpDir;
|
||||||
|
|
||||||
@Rule
|
@RegisterExtension
|
||||||
public final AppEngineRule appEngine = AppEngineRule.builder().withDatastoreAndCloudSql().build();
|
public final AppEngineRule appEngine = AppEngineRule.builder().withDatastoreAndCloudSql().build();
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testReadDirectory() throws IOException {
|
void testReadDirectory() throws IOException {
|
||||||
File subdir = tempFs.newFolder("folder");
|
LevelDbFileBuilder builder = new LevelDbFileBuilder(new File(tmpDir, "data1"));
|
||||||
LevelDbFileBuilder builder = new LevelDbFileBuilder(new File(subdir, "data1"));
|
|
||||||
|
|
||||||
// Note that we need to specify property values as "Long" for property comparisons to work
|
// Note that we need to specify property values as "Long" for property comparisons to work
|
||||||
// correctly because that's how they are deserialized from protos.
|
// correctly because that's how they are deserialized from protos.
|
||||||
|
@ -60,7 +57,7 @@ public class RecordAccumulatorTest {
|
||||||
builder.addEntity(e2.getEntity());
|
builder.addEntity(e2.getEntity());
|
||||||
builder.build();
|
builder.build();
|
||||||
|
|
||||||
builder = new LevelDbFileBuilder(new File(subdir, "data2"));
|
builder = new LevelDbFileBuilder(new File(tmpDir, "data2"));
|
||||||
|
|
||||||
// Duplicate of the record in the other file.
|
// Duplicate of the record in the other file.
|
||||||
builder.addEntity(
|
builder.addEntity(
|
||||||
|
@ -81,7 +78,7 @@ public class RecordAccumulatorTest {
|
||||||
builder.build();
|
builder.build();
|
||||||
|
|
||||||
ImmutableSet<EntityWrapper> entities =
|
ImmutableSet<EntityWrapper> entities =
|
||||||
RecordAccumulator.readDirectory(subdir, any -> true).getEntityWrapperSet();
|
RecordAccumulator.readDirectory(tmpDir, any -> true).getEntityWrapperSet();
|
||||||
assertThat(entities).containsExactly(e1, e2, e3);
|
assertThat(entities).containsExactly(e1, e2, e3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,21 +32,21 @@ import google.registry.model.registrar.Registrar;
|
||||||
import google.registry.model.registrar.RegistrarContact;
|
import google.registry.model.registrar.RegistrarContact;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
/** Unit tests for {@link RegistrarContactCommand}. */
|
/** Unit tests for {@link RegistrarContactCommand}. */
|
||||||
public class RegistrarContactCommandTest extends CommandTestCase<RegistrarContactCommand> {
|
class RegistrarContactCommandTest extends CommandTestCase<RegistrarContactCommand> {
|
||||||
|
|
||||||
private String output;
|
private String output;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void before() throws Exception {
|
void beforeEach() {
|
||||||
output = tmpDir.newFile().toString();
|
output = tmpDir.resolve("temp.dat").toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testList() throws Exception {
|
void testList() throws Exception {
|
||||||
Registrar registrar = loadRegistrar("NewRegistrar");
|
Registrar registrar = loadRegistrar("NewRegistrar");
|
||||||
RegistrarContact.updateContacts(
|
RegistrarContact.updateContacts(
|
||||||
registrar,
|
registrar,
|
||||||
|
@ -72,7 +72,7 @@ public class RegistrarContactCommandTest extends CommandTestCase<RegistrarContac
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUpdate() throws Exception {
|
void testUpdate() throws Exception {
|
||||||
Registrar registrar = loadRegistrar("NewRegistrar");
|
Registrar registrar = loadRegistrar("NewRegistrar");
|
||||||
ImmutableList<RegistrarContact> contacts = ImmutableList.of(
|
ImmutableList<RegistrarContact> contacts = ImmutableList.of(
|
||||||
new RegistrarContact.Builder()
|
new RegistrarContact.Builder()
|
||||||
|
@ -115,7 +115,7 @@ public class RegistrarContactCommandTest extends CommandTestCase<RegistrarContac
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUpdate_enableConsoleAccess() throws Exception {
|
void testUpdate_enableConsoleAccess() throws Exception {
|
||||||
Registrar registrar = loadRegistrar("NewRegistrar");
|
Registrar registrar = loadRegistrar("NewRegistrar");
|
||||||
persistSimpleResource(
|
persistSimpleResource(
|
||||||
new RegistrarContact.Builder()
|
new RegistrarContact.Builder()
|
||||||
|
@ -137,7 +137,7 @@ public class RegistrarContactCommandTest extends CommandTestCase<RegistrarContac
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUpdate_disableConsoleAccess() throws Exception {
|
void testUpdate_disableConsoleAccess() throws Exception {
|
||||||
Registrar registrar = loadRegistrar("NewRegistrar");
|
Registrar registrar = loadRegistrar("NewRegistrar");
|
||||||
persistSimpleResource(
|
persistSimpleResource(
|
||||||
new RegistrarContact.Builder()
|
new RegistrarContact.Builder()
|
||||||
|
@ -156,7 +156,7 @@ public class RegistrarContactCommandTest extends CommandTestCase<RegistrarContac
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUpdate_unsetOtherWhoisAbuseFlags() throws Exception {
|
void testUpdate_unsetOtherWhoisAbuseFlags() throws Exception {
|
||||||
Registrar registrar = loadRegistrar("NewRegistrar");
|
Registrar registrar = loadRegistrar("NewRegistrar");
|
||||||
persistSimpleResource(
|
persistSimpleResource(
|
||||||
new RegistrarContact.Builder()
|
new RegistrarContact.Builder()
|
||||||
|
@ -190,7 +190,7 @@ public class RegistrarContactCommandTest extends CommandTestCase<RegistrarContac
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUpdate_cannotUnsetOnlyWhoisAbuseContact() {
|
void testUpdate_cannotUnsetOnlyWhoisAbuseContact() {
|
||||||
Registrar registrar = loadRegistrar("NewRegistrar");
|
Registrar registrar = loadRegistrar("NewRegistrar");
|
||||||
persistSimpleResource(
|
persistSimpleResource(
|
||||||
new RegistrarContact.Builder()
|
new RegistrarContact.Builder()
|
||||||
|
@ -217,7 +217,7 @@ public class RegistrarContactCommandTest extends CommandTestCase<RegistrarContac
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUpdate_emptyCommandModifiesNothing() throws Exception {
|
void testUpdate_emptyCommandModifiesNothing() throws Exception {
|
||||||
Registrar registrar = loadRegistrar("NewRegistrar");
|
Registrar registrar = loadRegistrar("NewRegistrar");
|
||||||
RegistrarContact existingContact = persistSimpleResource(
|
RegistrarContact existingContact = persistSimpleResource(
|
||||||
new RegistrarContact.Builder()
|
new RegistrarContact.Builder()
|
||||||
|
@ -249,7 +249,7 @@ public class RegistrarContactCommandTest extends CommandTestCase<RegistrarContac
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUpdate_listOfTypesWorks() throws Exception {
|
void testUpdate_listOfTypesWorks() throws Exception {
|
||||||
Registrar registrar = loadRegistrar("NewRegistrar");
|
Registrar registrar = loadRegistrar("NewRegistrar");
|
||||||
persistSimpleResource(
|
persistSimpleResource(
|
||||||
new RegistrarContact.Builder()
|
new RegistrarContact.Builder()
|
||||||
|
@ -274,7 +274,7 @@ public class RegistrarContactCommandTest extends CommandTestCase<RegistrarContac
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUpdate_clearAllTypes() throws Exception {
|
void testUpdate_clearAllTypes() throws Exception {
|
||||||
Registrar registrar = loadRegistrar("NewRegistrar");
|
Registrar registrar = loadRegistrar("NewRegistrar");
|
||||||
persistSimpleResource(
|
persistSimpleResource(
|
||||||
new RegistrarContact.Builder()
|
new RegistrarContact.Builder()
|
||||||
|
@ -293,7 +293,7 @@ public class RegistrarContactCommandTest extends CommandTestCase<RegistrarContac
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCreate_withAdminType() throws Exception {
|
void testCreate_withAdminType() throws Exception {
|
||||||
Registrar registrar = loadRegistrar("NewRegistrar");
|
Registrar registrar = loadRegistrar("NewRegistrar");
|
||||||
runCommandForced(
|
runCommandForced(
|
||||||
"--mode=CREATE",
|
"--mode=CREATE",
|
||||||
|
@ -322,7 +322,7 @@ public class RegistrarContactCommandTest extends CommandTestCase<RegistrarContac
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDelete() throws Exception {
|
void testDelete() throws Exception {
|
||||||
assertThat(loadRegistrar("NewRegistrar").getContacts()).isNotEmpty();
|
assertThat(loadRegistrar("NewRegistrar").getContacts()).isNotEmpty();
|
||||||
runCommandForced(
|
runCommandForced(
|
||||||
"--mode=DELETE",
|
"--mode=DELETE",
|
||||||
|
@ -332,7 +332,7 @@ public class RegistrarContactCommandTest extends CommandTestCase<RegistrarContac
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDelete_failsOnDomainWhoisAbuseContact() {
|
void testDelete_failsOnDomainWhoisAbuseContact() {
|
||||||
RegistrarContact registrarContact = loadRegistrar("NewRegistrar").getContacts().asList().get(0);
|
RegistrarContact registrarContact = loadRegistrar("NewRegistrar").getContacts().asList().get(0);
|
||||||
persistSimpleResource(
|
persistSimpleResource(
|
||||||
registrarContact.asBuilder().setVisibleInDomainWhoisAsAbuse(true).build());
|
registrarContact.asBuilder().setVisibleInDomainWhoisAsAbuse(true).build());
|
||||||
|
@ -347,7 +347,7 @@ public class RegistrarContactCommandTest extends CommandTestCase<RegistrarContac
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCreate_withConsoleAccessEnabled() throws Exception {
|
void testCreate_withConsoleAccessEnabled() throws Exception {
|
||||||
runCommandForced(
|
runCommandForced(
|
||||||
"--mode=CREATE",
|
"--mode=CREATE",
|
||||||
"--name=Jim Doe",
|
"--name=Jim Doe",
|
||||||
|
@ -360,7 +360,7 @@ public class RegistrarContactCommandTest extends CommandTestCase<RegistrarContac
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCreate_withNoContactTypes() throws Exception {
|
void testCreate_withNoContactTypes() throws Exception {
|
||||||
runCommandForced(
|
runCommandForced(
|
||||||
"--mode=CREATE", "--name=Jim Doe", "--email=jim.doe@example.com", "NewRegistrar");
|
"--mode=CREATE", "--name=Jim Doe", "--email=jim.doe@example.com", "NewRegistrar");
|
||||||
RegistrarContact registrarContact = loadRegistrar("NewRegistrar").getContacts().asList().get(1);
|
RegistrarContact registrarContact = loadRegistrar("NewRegistrar").getContacts().asList().get(1);
|
||||||
|
@ -368,7 +368,7 @@ public class RegistrarContactCommandTest extends CommandTestCase<RegistrarContac
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCreate_syncingRequiredSetToTrue() throws Exception {
|
void testCreate_syncingRequiredSetToTrue() throws Exception {
|
||||||
persistResource(
|
persistResource(
|
||||||
loadRegistrar("NewRegistrar").asBuilder().setContactsRequireSyncing(false).build());
|
loadRegistrar("NewRegistrar").asBuilder().setContactsRequireSyncing(false).build());
|
||||||
|
|
||||||
|
@ -379,7 +379,7 @@ public class RegistrarContactCommandTest extends CommandTestCase<RegistrarContac
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCreate_setAllowedToSetRegistryLockPassword() throws Exception {
|
void testCreate_setAllowedToSetRegistryLockPassword() throws Exception {
|
||||||
runCommandForced(
|
runCommandForced(
|
||||||
"--mode=CREATE",
|
"--mode=CREATE",
|
||||||
"--name=Jim Doe",
|
"--name=Jim Doe",
|
||||||
|
@ -393,7 +393,7 @@ public class RegistrarContactCommandTest extends CommandTestCase<RegistrarContac
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUpdate_setAllowedToSetRegistryLockPassword() throws Exception {
|
void testUpdate_setAllowedToSetRegistryLockPassword() throws Exception {
|
||||||
Registrar registrar = loadRegistrar("NewRegistrar");
|
Registrar registrar = loadRegistrar("NewRegistrar");
|
||||||
RegistrarContact registrarContact =
|
RegistrarContact registrarContact =
|
||||||
persistSimpleResource(
|
persistSimpleResource(
|
||||||
|
@ -436,7 +436,7 @@ public class RegistrarContactCommandTest extends CommandTestCase<RegistrarContac
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUpdate_setAllowedToSetRegistryLockPassword_removesOldPassword() throws Exception {
|
void testUpdate_setAllowedToSetRegistryLockPassword_removesOldPassword() throws Exception {
|
||||||
Registrar registrar = loadRegistrar("NewRegistrar");
|
Registrar registrar = loadRegistrar("NewRegistrar");
|
||||||
RegistrarContact registrarContact =
|
RegistrarContact registrarContact =
|
||||||
persistSimpleResource(
|
persistSimpleResource(
|
||||||
|
@ -460,7 +460,7 @@ public class RegistrarContactCommandTest extends CommandTestCase<RegistrarContac
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCreate_failure_badEmail() {
|
void testCreate_failure_badEmail() {
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
|
@ -473,7 +473,7 @@ public class RegistrarContactCommandTest extends CommandTestCase<RegistrarContac
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCreate_failure_nullEmail() {
|
void testCreate_failure_nullEmail() {
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
|
|
|
@ -18,25 +18,22 @@ import static com.google.common.truth.Truth.assertThat;
|
||||||
import static org.junit.Assert.assertThrows;
|
import static org.junit.Assert.assertThrows;
|
||||||
|
|
||||||
import google.registry.testing.SystemPropertyRule;
|
import google.registry.testing.SystemPropertyRule;
|
||||||
import org.junit.Rule;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
import org.junit.runners.JUnit4;
|
|
||||||
|
|
||||||
/** Unit tests for {@link RegistryToolEnvironment}. */
|
/** Unit tests for {@link RegistryToolEnvironment}. */
|
||||||
@RunWith(JUnit4.class)
|
class RegistryToolEnvironmentTest {
|
||||||
public class RegistryToolEnvironmentTest {
|
|
||||||
|
|
||||||
@Rule public final SystemPropertyRule systemPropertyRule = new SystemPropertyRule();
|
@RegisterExtension final SystemPropertyRule systemPropertyRule = new SystemPropertyRule();
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGet_withoutSetup_throws() {
|
void testGet_withoutSetup_throws() {
|
||||||
RegistryToolEnvironment.reset();
|
RegistryToolEnvironment.reset();
|
||||||
assertThrows(IllegalStateException.class, RegistryToolEnvironment::get);
|
assertThrows(IllegalStateException.class, RegistryToolEnvironment::get);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSetup_changesEnvironmentReturnedByGet() {
|
void testSetup_changesEnvironmentReturnedByGet() {
|
||||||
RegistryToolEnvironment.UNITTEST.setup(systemPropertyRule);
|
RegistryToolEnvironment.UNITTEST.setup(systemPropertyRule);
|
||||||
assertThat(RegistryToolEnvironment.get()).isEqualTo(RegistryToolEnvironment.UNITTEST);
|
assertThat(RegistryToolEnvironment.get()).isEqualTo(RegistryToolEnvironment.UNITTEST);
|
||||||
|
|
||||||
|
@ -45,25 +42,25 @@ public class RegistryToolEnvironmentTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFromArgs_shortNotation_works() {
|
void testFromArgs_shortNotation_works() {
|
||||||
assertThat(RegistryToolEnvironment.parseFromArgs(new String[] {"-e", "alpha"}))
|
assertThat(RegistryToolEnvironment.parseFromArgs(new String[] {"-e", "alpha"}))
|
||||||
.isEqualTo(RegistryToolEnvironment.ALPHA);
|
.isEqualTo(RegistryToolEnvironment.ALPHA);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFromArgs_longNotation_works() {
|
void testFromArgs_longNotation_works() {
|
||||||
assertThat(RegistryToolEnvironment.parseFromArgs(new String[] {"--environment", "alpha"}))
|
assertThat(RegistryToolEnvironment.parseFromArgs(new String[] {"--environment", "alpha"}))
|
||||||
.isEqualTo(RegistryToolEnvironment.ALPHA);
|
.isEqualTo(RegistryToolEnvironment.ALPHA);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFromArgs_uppercase_works() {
|
void testFromArgs_uppercase_works() {
|
||||||
assertThat(RegistryToolEnvironment.parseFromArgs(new String[] {"-e", "QA"}))
|
assertThat(RegistryToolEnvironment.parseFromArgs(new String[] {"-e", "QA"}))
|
||||||
.isEqualTo(RegistryToolEnvironment.QA);
|
.isEqualTo(RegistryToolEnvironment.QA);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFromArgs_equalsNotation_works() {
|
void testFromArgs_equalsNotation_works() {
|
||||||
assertThat(RegistryToolEnvironment.parseFromArgs(new String[] {"-e=sandbox"}))
|
assertThat(RegistryToolEnvironment.parseFromArgs(new String[] {"-e=sandbox"}))
|
||||||
.isEqualTo(RegistryToolEnvironment.SANDBOX);
|
.isEqualTo(RegistryToolEnvironment.SANDBOX);
|
||||||
assertThat(RegistryToolEnvironment.parseFromArgs(new String[] {"--environment=sandbox"}))
|
assertThat(RegistryToolEnvironment.parseFromArgs(new String[] {"--environment=sandbox"}))
|
||||||
|
@ -71,7 +68,7 @@ public class RegistryToolEnvironmentTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFromArgs_envFlagAfterCommandName_getsIgnored() {
|
void testFromArgs_envFlagAfterCommandName_getsIgnored() {
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
() ->
|
() ->
|
||||||
|
@ -80,34 +77,33 @@ public class RegistryToolEnvironmentTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFromArgs_missingEnvironmentFlag_throwsIae() {
|
void testFromArgs_missingEnvironmentFlag_throwsIae() {
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
() -> RegistryToolEnvironment.parseFromArgs(new String[] {}));
|
() -> RegistryToolEnvironment.parseFromArgs(new String[] {}));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFromArgs_extraEnvFlagAfterCommandName_getsIgnored() {
|
void testFromArgs_extraEnvFlagAfterCommandName_getsIgnored() {
|
||||||
String[] args = new String[] {
|
String[] args = new String[] {"-e", "alpha", "registrar_activity_report", "-e", "1406851199"};
|
||||||
"-e", "alpha",
|
|
||||||
"registrar_activity_report",
|
|
||||||
"-e", "1406851199"};
|
|
||||||
assertThat(RegistryToolEnvironment.parseFromArgs(args))
|
assertThat(RegistryToolEnvironment.parseFromArgs(args))
|
||||||
.isEqualTo(RegistryToolEnvironment.ALPHA);
|
.isEqualTo(RegistryToolEnvironment.ALPHA);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFromArgs_loggingFlagWithUnderscores_isntConsideredCommand() {
|
void testFromArgs_loggingFlagWithUnderscores_isntConsideredCommand() {
|
||||||
String[] args = new String[] {
|
String[] args =
|
||||||
|
new String[] {
|
||||||
"--logging_properties_file", "my_file.properties",
|
"--logging_properties_file", "my_file.properties",
|
||||||
"-e", "alpha",
|
"-e", "alpha",
|
||||||
"list_tlds"};
|
"list_tlds"
|
||||||
|
};
|
||||||
assertThat(RegistryToolEnvironment.parseFromArgs(args))
|
assertThat(RegistryToolEnvironment.parseFromArgs(args))
|
||||||
.isEqualTo(RegistryToolEnvironment.ALPHA);
|
.isEqualTo(RegistryToolEnvironment.ALPHA);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFromArgs_badName_throwsIae() {
|
void testFromArgs_badName_throwsIae() {
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
() -> RegistryToolEnvironment.parseFromArgs(new String[] {"-e", "alphaville"}));
|
() -> RegistryToolEnvironment.parseFromArgs(new String[] {"-e", "alphaville"}));
|
||||||
|
|
|
@ -32,26 +32,26 @@ import google.registry.testing.InjectRule;
|
||||||
import google.registry.util.Clock;
|
import google.registry.util.Clock;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Rule;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||||
import org.testcontainers.shaded.com.google.common.collect.ImmutableList;
|
import org.testcontainers.shaded.com.google.common.collect.ImmutableList;
|
||||||
|
|
||||||
/** Unit tests for {@link RenewDomainCommand}. */
|
/** Unit tests for {@link RenewDomainCommand}. */
|
||||||
public class RenewDomainCommandTest extends EppToolCommandTestCase<RenewDomainCommand> {
|
public class RenewDomainCommandTest extends EppToolCommandTestCase<RenewDomainCommand> {
|
||||||
|
|
||||||
@Rule public final InjectRule inject = new InjectRule();
|
@RegisterExtension public final InjectRule inject = new InjectRule();
|
||||||
|
|
||||||
private final Clock clock = new FakeClock(DateTime.parse("2015-04-05T05:05:05Z"));
|
private final Clock clock = new FakeClock(DateTime.parse("2015-04-05T05:05:05Z"));
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void before() {
|
void beforeEach() {
|
||||||
inject.setStaticField(Ofy.class, "clock", clock);
|
inject.setStaticField(Ofy.class, "clock", clock);
|
||||||
command.clock = clock;
|
command.clock = clock;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess() throws Exception {
|
void testSuccess() throws Exception {
|
||||||
persistResource(
|
persistResource(
|
||||||
persistActiveDomain(
|
persistActiveDomain(
|
||||||
"domain.tld",
|
"domain.tld",
|
||||||
|
@ -94,7 +94,7 @@ public class RenewDomainCommandTest extends EppToolCommandTestCase<RenewDomainCo
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_multipleDomains_renewsAndUsesEachDomainsRegistrar() throws Exception {
|
void testSuccess_multipleDomains_renewsAndUsesEachDomainsRegistrar() throws Exception {
|
||||||
persistThreeDomains();
|
persistThreeDomains();
|
||||||
runCommandForced("--period 3", "domain1.tld", "domain2.tld", "domain3.tld");
|
runCommandForced("--period 3", "domain1.tld", "domain2.tld", "domain3.tld");
|
||||||
eppVerifier
|
eppVerifier
|
||||||
|
@ -113,7 +113,7 @@ public class RenewDomainCommandTest extends EppToolCommandTestCase<RenewDomainCo
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_multipleDomains_renewsAndUsesSpecifiedRegistrar() throws Exception {
|
void testSuccess_multipleDomains_renewsAndUsesSpecifiedRegistrar() throws Exception {
|
||||||
persistThreeDomains();
|
persistThreeDomains();
|
||||||
persistNewRegistrar("reg3", "Registrar 3", Registrar.Type.REAL, 9783L);
|
persistNewRegistrar("reg3", "Registrar 3", Registrar.Type.REAL, 9783L);
|
||||||
runCommandForced("--period 3", "domain1.tld", "domain2.tld", "domain3.tld", "-u", "-c reg3");
|
runCommandForced("--period 3", "domain1.tld", "domain2.tld", "domain3.tld", "-u", "-c reg3");
|
||||||
|
@ -133,7 +133,7 @@ public class RenewDomainCommandTest extends EppToolCommandTestCase<RenewDomainCo
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_domainDoesntExist() {
|
void testFailure_domainDoesntExist() {
|
||||||
IllegalArgumentException e =
|
IllegalArgumentException e =
|
||||||
assertThrows(IllegalArgumentException.class, () -> runCommandForced("nonexistent.tld"));
|
assertThrows(IllegalArgumentException.class, () -> runCommandForced("nonexistent.tld"));
|
||||||
assertThat(e)
|
assertThat(e)
|
||||||
|
@ -142,7 +142,7 @@ public class RenewDomainCommandTest extends EppToolCommandTestCase<RenewDomainCo
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_domainIsDeleted() {
|
void testFailure_domainIsDeleted() {
|
||||||
persistDeletedDomain("deleted.tld", DateTime.parse("2012-10-05T05:05:05Z"));
|
persistDeletedDomain("deleted.tld", DateTime.parse("2012-10-05T05:05:05Z"));
|
||||||
IllegalArgumentException e =
|
IllegalArgumentException e =
|
||||||
assertThrows(IllegalArgumentException.class, () -> runCommandForced("deleted.tld"));
|
assertThrows(IllegalArgumentException.class, () -> runCommandForced("deleted.tld"));
|
||||||
|
@ -150,7 +150,7 @@ public class RenewDomainCommandTest extends EppToolCommandTestCase<RenewDomainCo
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_duplicateDomainSpecified() {
|
void testFailure_duplicateDomainSpecified() {
|
||||||
IllegalArgumentException e =
|
IllegalArgumentException e =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class, () -> runCommandForced("dupe.tld", "dupe.tld"));
|
IllegalArgumentException.class, () -> runCommandForced("dupe.tld", "dupe.tld"));
|
||||||
|
@ -158,7 +158,7 @@ public class RenewDomainCommandTest extends EppToolCommandTestCase<RenewDomainCo
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_cantRenewForTenYears() {
|
void testFailure_cantRenewForTenYears() {
|
||||||
persistActiveDomain(
|
persistActiveDomain(
|
||||||
"domain.tld",
|
"domain.tld",
|
||||||
DateTime.parse("2014-09-05T05:05:05Z"),
|
DateTime.parse("2014-09-05T05:05:05Z"),
|
||||||
|
@ -170,7 +170,7 @@ public class RenewDomainCommandTest extends EppToolCommandTestCase<RenewDomainCo
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_missingDomainNames() {
|
void testFailure_missingDomainNames() {
|
||||||
assertThrows(ParameterException.class, () -> runCommand("--period 4"));
|
assertThrows(ParameterException.class, () -> runCommand("--period 4"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,8 +17,8 @@ package google.registry.tools;
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
import static google.registry.tools.RequestFactoryModule.REQUEST_TIMEOUT_MS;
|
import static google.registry.tools.RequestFactoryModule.REQUEST_TIMEOUT_MS;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
|
import static org.mockito.Mockito.verifyNoInteractions;
|
||||||
import static org.mockito.Mockito.verifyNoMoreInteractions;
|
import static org.mockito.Mockito.verifyNoMoreInteractions;
|
||||||
import static org.mockito.Mockito.verifyZeroInteractions;
|
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import com.google.api.client.http.GenericUrl;
|
import com.google.api.client.http.GenericUrl;
|
||||||
|
@ -28,32 +28,29 @@ import com.google.api.client.http.HttpRequestInitializer;
|
||||||
import google.registry.config.RegistryConfig;
|
import google.registry.config.RegistryConfig;
|
||||||
import google.registry.testing.SystemPropertyRule;
|
import google.registry.testing.SystemPropertyRule;
|
||||||
import google.registry.util.GoogleCredentialsBundle;
|
import google.registry.util.GoogleCredentialsBundle;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Rule;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.extension.ExtendWith;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||||
import org.junit.runners.JUnit4;
|
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
import org.mockito.junit.MockitoJUnit;
|
import org.mockito.junit.jupiter.MockitoExtension;
|
||||||
import org.mockito.junit.MockitoRule;
|
|
||||||
|
|
||||||
@RunWith(JUnit4.class)
|
/** Unit tests for {@link RequestFactoryModule}. */
|
||||||
|
@ExtendWith(MockitoExtension.class)
|
||||||
public class RequestFactoryModuleTest {
|
public class RequestFactoryModuleTest {
|
||||||
|
|
||||||
@Rule public final MockitoRule mockitoRule = MockitoJUnit.rule();
|
@RegisterExtension final SystemPropertyRule systemPropertyRule = new SystemPropertyRule();
|
||||||
@Rule public final SystemPropertyRule systemPropertyRule = new SystemPropertyRule();
|
|
||||||
|
|
||||||
@Mock public GoogleCredentialsBundle credentialsBundle;
|
@Mock public GoogleCredentialsBundle credentialsBundle;
|
||||||
@Mock public HttpRequestInitializer httpRequestInitializer;
|
@Mock public HttpRequestInitializer httpRequestInitializer;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setUp() {
|
void beforeEach() {
|
||||||
RegistryToolEnvironment.UNITTEST.setup(systemPropertyRule);
|
RegistryToolEnvironment.UNITTEST.setup(systemPropertyRule);
|
||||||
when(credentialsBundle.getHttpRequestInitializer()).thenReturn(httpRequestInitializer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_provideHttpRequestFactory_localhost() throws Exception {
|
void test_provideHttpRequestFactory_localhost() throws Exception {
|
||||||
// Make sure that localhost creates a request factory with an initializer.
|
// Make sure that localhost creates a request factory with an initializer.
|
||||||
boolean origIsLocal = RegistryConfig.CONFIG_SETTINGS.get().appEngine.isLocal;
|
boolean origIsLocal = RegistryConfig.CONFIG_SETTINGS.get().appEngine.isLocal;
|
||||||
RegistryConfig.CONFIG_SETTINGS.get().appEngine.isLocal = true;
|
RegistryConfig.CONFIG_SETTINGS.get().appEngine.isLocal = true;
|
||||||
|
@ -64,14 +61,15 @@ public class RequestFactoryModuleTest {
|
||||||
assertThat(initializer).isNotNull();
|
assertThat(initializer).isNotNull();
|
||||||
HttpRequest request = factory.buildGetRequest(new GenericUrl("http://localhost"));
|
HttpRequest request = factory.buildGetRequest(new GenericUrl("http://localhost"));
|
||||||
initializer.initialize(request);
|
initializer.initialize(request);
|
||||||
verifyZeroInteractions(httpRequestInitializer);
|
verifyNoInteractions(httpRequestInitializer);
|
||||||
} finally {
|
} finally {
|
||||||
RegistryConfig.CONFIG_SETTINGS.get().appEngine.isLocal = origIsLocal;
|
RegistryConfig.CONFIG_SETTINGS.get().appEngine.isLocal = origIsLocal;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_provideHttpRequestFactory_remote() throws Exception {
|
void test_provideHttpRequestFactory_remote() throws Exception {
|
||||||
|
when(credentialsBundle.getHttpRequestInitializer()).thenReturn(httpRequestInitializer);
|
||||||
// Make sure that example.com creates a request factory with the UNITTEST client id but no
|
// Make sure that example.com creates a request factory with the UNITTEST client id but no
|
||||||
boolean origIsLocal = RegistryConfig.CONFIG_SETTINGS.get().appEngine.isLocal;
|
boolean origIsLocal = RegistryConfig.CONFIG_SETTINGS.get().appEngine.isLocal;
|
||||||
RegistryConfig.CONFIG_SETTINGS.get().appEngine.isLocal = false;
|
RegistryConfig.CONFIG_SETTINGS.get().appEngine.isLocal = false;
|
||||||
|
|
|
@ -25,13 +25,13 @@ import google.registry.model.ImmutableObject;
|
||||||
import google.registry.model.contact.ContactResource;
|
import google.registry.model.contact.ContactResource;
|
||||||
import google.registry.model.ofy.CommitLogManifest;
|
import google.registry.model.ofy.CommitLogManifest;
|
||||||
import google.registry.model.ofy.CommitLogMutation;
|
import google.registry.model.ofy.CommitLogMutation;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
/** Unit tests for {@link ResaveEntitiesCommand}. */
|
/** Unit tests for {@link ResaveEntitiesCommand}. */
|
||||||
public class ResaveEntitiesCommandTest extends CommandTestCase<ResaveEntitiesCommand> {
|
class ResaveEntitiesCommandTest extends CommandTestCase<ResaveEntitiesCommand> {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_createsCommitLogs() throws Exception {
|
void testSuccess_createsCommitLogs() throws Exception {
|
||||||
ContactResource contact1 = persistActiveContact("contact1");
|
ContactResource contact1 = persistActiveContact("contact1");
|
||||||
ContactResource contact2 = persistActiveContact("contact2");
|
ContactResource contact2 = persistActiveContact("contact2");
|
||||||
deleteEntitiesOfTypes(CommitLogManifest.class, CommitLogMutation.class);
|
deleteEntitiesOfTypes(CommitLogManifest.class, CommitLogMutation.class);
|
||||||
|
|
|
@ -28,14 +28,14 @@ import google.registry.model.ofy.CommitLogMutation;
|
||||||
import google.registry.model.registrar.Registrar;
|
import google.registry.model.registrar.Registrar;
|
||||||
import google.registry.model.registrar.RegistrarContact;
|
import google.registry.model.registrar.RegistrarContact;
|
||||||
import google.registry.model.registry.Registry;
|
import google.registry.model.registry.Registry;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
/** Unit tests for {@link ResaveEnvironmentEntitiesCommand}. */
|
/** Unit tests for {@link ResaveEnvironmentEntitiesCommand}. */
|
||||||
public class ResaveEnvironmentEntitiesCommandTest
|
class ResaveEnvironmentEntitiesCommandTest
|
||||||
extends CommandTestCase<ResaveEnvironmentEntitiesCommand> {
|
extends CommandTestCase<ResaveEnvironmentEntitiesCommand> {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_noop() throws Exception {
|
void testSuccess_noop() throws Exception {
|
||||||
// Get rid of all the entities that this command runs on so that it does nothing.
|
// Get rid of all the entities that this command runs on so that it does nothing.
|
||||||
deleteEntitiesOfTypes(
|
deleteEntitiesOfTypes(
|
||||||
Registry.class,
|
Registry.class,
|
||||||
|
@ -49,7 +49,7 @@ public class ResaveEnvironmentEntitiesCommandTest
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_createsCommitLogs() throws Exception {
|
void testSuccess_createsCommitLogs() throws Exception {
|
||||||
createTld("tld");
|
createTld("tld");
|
||||||
deleteEntitiesOfTypes(CommitLogManifest.class, CommitLogMutation.class);
|
deleteEntitiesOfTypes(CommitLogManifest.class, CommitLogMutation.class);
|
||||||
assertThat(ofy().load().type(CommitLogManifest.class).keys()).isEmpty();
|
assertThat(ofy().load().type(CommitLogManifest.class).keys()).isEmpty();
|
||||||
|
|
|
@ -22,13 +22,13 @@ import google.registry.model.ImmutableObject;
|
||||||
import google.registry.model.contact.ContactResource;
|
import google.registry.model.contact.ContactResource;
|
||||||
import google.registry.model.ofy.CommitLogManifest;
|
import google.registry.model.ofy.CommitLogManifest;
|
||||||
import google.registry.model.ofy.CommitLogMutation;
|
import google.registry.model.ofy.CommitLogMutation;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
/** Unit tests for {@link ResaveEppResourceCommand}. */
|
/** Unit tests for {@link ResaveEppResourceCommand}. */
|
||||||
public class ResaveEppResourcesCommandTest extends CommandTestCase<ResaveEppResourceCommand> {
|
class ResaveEppResourcesCommandTest extends CommandTestCase<ResaveEppResourceCommand> {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_createsCommitLogs() throws Exception {
|
void testSuccess_createsCommitLogs() throws Exception {
|
||||||
ContactResource contact = persistActiveContact("contact");
|
ContactResource contact = persistActiveContact("contact");
|
||||||
deleteEntitiesOfTypes(CommitLogManifest.class, CommitLogMutation.class);
|
deleteEntitiesOfTypes(CommitLogManifest.class, CommitLogMutation.class);
|
||||||
assertThat(ofy().load().type(CommitLogManifest.class).keys()).isEmpty();
|
assertThat(ofy().load().type(CommitLogManifest.class).keys()).isEmpty();
|
||||||
|
|
|
@ -24,29 +24,31 @@ import com.google.common.collect.ImmutableMultimap;
|
||||||
import google.registry.testing.AppEngineAdminApiHelper;
|
import google.registry.testing.AppEngineAdminApiHelper;
|
||||||
import google.registry.testing.InjectRule;
|
import google.registry.testing.InjectRule;
|
||||||
import google.registry.util.AppEngineServiceUtils;
|
import google.registry.util.AppEngineServiceUtils;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Rule;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
|
import org.mockito.junit.jupiter.MockitoSettings;
|
||||||
|
import org.mockito.quality.Strictness;
|
||||||
|
|
||||||
/** Unit tests for {@link SetNumInstancesCommand}. */
|
/** Unit tests for {@link SetNumInstancesCommand}. */
|
||||||
public class SetNumInstancesCommandTest extends CommandTestCase<SetNumInstancesCommand> {
|
public class SetNumInstancesCommandTest extends CommandTestCase<SetNumInstancesCommand> {
|
||||||
|
|
||||||
@Rule public final InjectRule inject = new InjectRule();
|
@RegisterExtension public final InjectRule inject = new InjectRule();
|
||||||
|
|
||||||
@Mock AppEngineServiceUtils appEngineServiceUtils;
|
@Mock AppEngineServiceUtils appEngineServiceUtils;
|
||||||
|
|
||||||
private final String projectId = "domain-registry-test";
|
private final String projectId = "domain-registry-test";
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void before() {
|
void beforeEach() {
|
||||||
command = new SetNumInstancesCommand();
|
command = new SetNumInstancesCommand();
|
||||||
command.appEngineServiceUtils = appEngineServiceUtils;
|
command.appEngineServiceUtils = appEngineServiceUtils;
|
||||||
command.projectId = projectId;
|
command.projectId = projectId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_missingService_throwsException() {
|
void test_missingService_throwsException() {
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
|
@ -55,7 +57,7 @@ public class SetNumInstancesCommandTest extends CommandTestCase<SetNumInstancesC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_emptyService_throwsException() {
|
void test_emptyService_throwsException() {
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
|
@ -64,7 +66,7 @@ public class SetNumInstancesCommandTest extends CommandTestCase<SetNumInstancesC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_invalidService_throwsException() {
|
void test_invalidService_throwsException() {
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
|
@ -75,7 +77,7 @@ public class SetNumInstancesCommandTest extends CommandTestCase<SetNumInstancesC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_missingVersion_throwsException() {
|
void test_missingVersion_throwsException() {
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
|
@ -84,7 +86,7 @@ public class SetNumInstancesCommandTest extends CommandTestCase<SetNumInstancesC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_emptyVersion_throwsException() {
|
void test_emptyVersion_throwsException() {
|
||||||
ParameterException thrown =
|
ParameterException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
ParameterException.class,
|
ParameterException.class,
|
||||||
|
@ -93,7 +95,7 @@ public class SetNumInstancesCommandTest extends CommandTestCase<SetNumInstancesC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_missingNumInstances_throwsException() {
|
void test_missingNumInstances_throwsException() {
|
||||||
ParameterException thrown =
|
ParameterException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
ParameterException.class, () -> runCommand("--services=DEFAULT", "--versions=version"));
|
ParameterException.class, () -> runCommand("--services=DEFAULT", "--versions=version"));
|
||||||
|
@ -103,7 +105,7 @@ public class SetNumInstancesCommandTest extends CommandTestCase<SetNumInstancesC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_invalidNumInstances_throwsException() {
|
void test_invalidNumInstances_throwsException() {
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
|
@ -112,7 +114,7 @@ public class SetNumInstancesCommandTest extends CommandTestCase<SetNumInstancesC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_versionNotNullWhenSettingAllNonLiveVersions_throwsException() {
|
void test_versionNotNullWhenSettingAllNonLiveVersions_throwsException() {
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
|
@ -120,8 +122,9 @@ public class SetNumInstancesCommandTest extends CommandTestCase<SetNumInstancesC
|
||||||
assertThat(thrown).hasMessageThat().contains("Number of instances must be greater than zero");
|
assertThat(thrown).hasMessageThat().contains("Number of instances must be greater than zero");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@MockitoSettings(strictness = Strictness.LENIENT)
|
||||||
@Test
|
@Test
|
||||||
public void test_settingNonManualScalingVersions_throwsException() {
|
void test_settingNonManualScalingVersions_throwsException() {
|
||||||
command.appengine =
|
command.appengine =
|
||||||
new AppEngineAdminApiHelper.Builder()
|
new AppEngineAdminApiHelper.Builder()
|
||||||
.setAppId(projectId)
|
.setAppId(projectId)
|
||||||
|
@ -143,8 +146,9 @@ public class SetNumInstancesCommandTest extends CommandTestCase<SetNumInstancesC
|
||||||
.contains("--versions cannot be set if --non_live_versions is set");
|
.contains("--versions cannot be set if --non_live_versions is set");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@MockitoSettings(strictness = Strictness.LENIENT)
|
||||||
@Test
|
@Test
|
||||||
public void test_validParameters_succeeds() throws Exception {
|
void test_validParameters_succeeds() throws Exception {
|
||||||
command.appengine =
|
command.appengine =
|
||||||
new AppEngineAdminApiHelper.Builder()
|
new AppEngineAdminApiHelper.Builder()
|
||||||
.setAppId(projectId)
|
.setAppId(projectId)
|
||||||
|
@ -156,8 +160,9 @@ public class SetNumInstancesCommandTest extends CommandTestCase<SetNumInstancesC
|
||||||
verify(appEngineServiceUtils, times(1)).setNumInstances("default", "version", 10L);
|
verify(appEngineServiceUtils, times(1)).setNumInstances("default", "version", 10L);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@MockitoSettings(strictness = Strictness.LENIENT)
|
||||||
@Test
|
@Test
|
||||||
public void test_validShortParametersAndLowercaseService_succeeds() throws Exception {
|
void test_validShortParametersAndLowercaseService_succeeds() throws Exception {
|
||||||
command.appengine =
|
command.appengine =
|
||||||
new AppEngineAdminApiHelper.Builder()
|
new AppEngineAdminApiHelper.Builder()
|
||||||
.setAppId(projectId)
|
.setAppId(projectId)
|
||||||
|
@ -169,8 +174,9 @@ public class SetNumInstancesCommandTest extends CommandTestCase<SetNumInstancesC
|
||||||
verify(appEngineServiceUtils, times(1)).setNumInstances("default", "version", 10L);
|
verify(appEngineServiceUtils, times(1)).setNumInstances("default", "version", 10L);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@MockitoSettings(strictness = Strictness.LENIENT)
|
||||||
@Test
|
@Test
|
||||||
public void test_settingMultipleServicesAndVersions_succeeds() throws Exception {
|
void test_settingMultipleServicesAndVersions_succeeds() throws Exception {
|
||||||
command.appengine =
|
command.appengine =
|
||||||
new AppEngineAdminApiHelper.Builder()
|
new AppEngineAdminApiHelper.Builder()
|
||||||
.setAppId(projectId)
|
.setAppId(projectId)
|
||||||
|
@ -191,7 +197,7 @@ public class SetNumInstancesCommandTest extends CommandTestCase<SetNumInstancesC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_settingAllNonLiveVersions_succeeds() throws Exception {
|
void test_settingAllNonLiveVersions_succeeds() throws Exception {
|
||||||
command.appengine =
|
command.appengine =
|
||||||
new AppEngineAdminApiHelper.Builder()
|
new AppEngineAdminApiHelper.Builder()
|
||||||
.setAppId(projectId)
|
.setAppId(projectId)
|
||||||
|
@ -209,7 +215,7 @@ public class SetNumInstancesCommandTest extends CommandTestCase<SetNumInstancesC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_noNonLiveVersions_succeeds() throws Exception {
|
void test_noNonLiveVersions_succeeds() throws Exception {
|
||||||
command.appengine =
|
command.appengine =
|
||||||
new AppEngineAdminApiHelper.Builder()
|
new AppEngineAdminApiHelper.Builder()
|
||||||
.setAppId(projectId)
|
.setAppId(projectId)
|
||||||
|
|
|
@ -43,19 +43,19 @@ import org.joda.money.CurrencyUnit;
|
||||||
import org.joda.money.Money;
|
import org.joda.money.Money;
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
import org.joda.time.Duration;
|
import org.joda.time.Duration;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
/** Unit tests for {@link SetupOteCommand}. */
|
/** Unit tests for {@link SetupOteCommand}. */
|
||||||
public class SetupOteCommandTest extends CommandTestCase<SetupOteCommand> {
|
class SetupOteCommandTest extends CommandTestCase<SetupOteCommand> {
|
||||||
|
|
||||||
static final String PASSWORD = "abcdefghijklmnop";
|
private static final String PASSWORD = "abcdefghijklmnop";
|
||||||
|
|
||||||
DeterministicStringGenerator passwordGenerator =
|
private DeterministicStringGenerator passwordGenerator =
|
||||||
new DeterministicStringGenerator("abcdefghijklmnopqrstuvwxyz");
|
new DeterministicStringGenerator("abcdefghijklmnopqrstuvwxyz");
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void init() {
|
void beforeEach() {
|
||||||
command.passwordGenerator = passwordGenerator;
|
command.passwordGenerator = passwordGenerator;
|
||||||
command.clock = new FakeClock(DateTime.parse("2018-07-07TZ"));
|
command.clock = new FakeClock(DateTime.parse("2018-07-07TZ"));
|
||||||
persistPremiumList("default_sandbox_list", "sandbox,USD 1000");
|
persistPremiumList("default_sandbox_list", "sandbox,USD 1000");
|
||||||
|
@ -133,7 +133,7 @@ public class SetupOteCommandTest extends CommandTestCase<SetupOteCommand> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess() throws Exception {
|
void testSuccess() throws Exception {
|
||||||
runCommandForced(
|
runCommandForced(
|
||||||
"--ip_allow_list=1.1.1.1",
|
"--ip_allow_list=1.1.1.1",
|
||||||
"--registrar=blobio",
|
"--registrar=blobio",
|
||||||
|
@ -159,7 +159,7 @@ public class SetupOteCommandTest extends CommandTestCase<SetupOteCommand> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_shortRegistrarName() throws Exception {
|
void testSuccess_shortRegistrarName() throws Exception {
|
||||||
runCommandForced(
|
runCommandForced(
|
||||||
"--ip_allow_list=1.1.1.1",
|
"--ip_allow_list=1.1.1.1",
|
||||||
"--registrar=abc",
|
"--registrar=abc",
|
||||||
|
@ -185,7 +185,7 @@ public class SetupOteCommandTest extends CommandTestCase<SetupOteCommand> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_certificateHash() throws Exception {
|
void testSuccess_certificateHash() throws Exception {
|
||||||
runCommandForced(
|
runCommandForced(
|
||||||
"--ip_allow_list=1.1.1.1",
|
"--ip_allow_list=1.1.1.1",
|
||||||
"--registrar=blobio",
|
"--registrar=blobio",
|
||||||
|
@ -203,7 +203,7 @@ public class SetupOteCommandTest extends CommandTestCase<SetupOteCommand> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_multipleIps() throws Exception {
|
void testSuccess_multipleIps() throws Exception {
|
||||||
runCommandForced(
|
runCommandForced(
|
||||||
"--ip_allow_list=1.1.1.1,2.2.2.2",
|
"--ip_allow_list=1.1.1.1,2.2.2.2",
|
||||||
"--registrar=blobio",
|
"--registrar=blobio",
|
||||||
|
@ -230,7 +230,7 @@ public class SetupOteCommandTest extends CommandTestCase<SetupOteCommand> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_missingIpAllowList() {
|
void testFailure_missingIpAllowList() {
|
||||||
ParameterException thrown =
|
ParameterException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
ParameterException.class,
|
ParameterException.class,
|
||||||
|
@ -243,7 +243,7 @@ public class SetupOteCommandTest extends CommandTestCase<SetupOteCommand> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_missingRegistrar() {
|
void testFailure_missingRegistrar() {
|
||||||
ParameterException thrown =
|
ParameterException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
ParameterException.class,
|
ParameterException.class,
|
||||||
|
@ -256,7 +256,7 @@ public class SetupOteCommandTest extends CommandTestCase<SetupOteCommand> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_missingCertificateFileAndCertificateHash() {
|
void testFailure_missingCertificateFileAndCertificateHash() {
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
|
@ -270,7 +270,7 @@ public class SetupOteCommandTest extends CommandTestCase<SetupOteCommand> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_suppliedCertificateFileAndCertificateHash() {
|
void testFailure_suppliedCertificateFileAndCertificateHash() {
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
|
@ -288,7 +288,7 @@ public class SetupOteCommandTest extends CommandTestCase<SetupOteCommand> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_missingEmail() {
|
void testFailure_missingEmail() {
|
||||||
ParameterException thrown =
|
ParameterException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
ParameterException.class,
|
ParameterException.class,
|
||||||
|
@ -301,7 +301,7 @@ public class SetupOteCommandTest extends CommandTestCase<SetupOteCommand> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_invalidCert() {
|
void testFailure_invalidCert() {
|
||||||
CertificateParsingException thrown =
|
CertificateParsingException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
CertificateParsingException.class,
|
CertificateParsingException.class,
|
||||||
|
@ -315,7 +315,7 @@ public class SetupOteCommandTest extends CommandTestCase<SetupOteCommand> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_invalidRegistrar() {
|
void testFailure_invalidRegistrar() {
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
|
@ -329,7 +329,7 @@ public class SetupOteCommandTest extends CommandTestCase<SetupOteCommand> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_registrarTooShort() {
|
void testFailure_registrarTooShort() {
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
|
@ -343,7 +343,7 @@ public class SetupOteCommandTest extends CommandTestCase<SetupOteCommand> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_registrarTooLong() {
|
void testFailure_registrarTooLong() {
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
|
@ -357,7 +357,7 @@ public class SetupOteCommandTest extends CommandTestCase<SetupOteCommand> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_registrarInvalidCharacter() {
|
void testFailure_registrarInvalidCharacter() {
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
|
@ -371,7 +371,7 @@ public class SetupOteCommandTest extends CommandTestCase<SetupOteCommand> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_tldExists() {
|
void testFailure_tldExists() {
|
||||||
createTld("blobio-sunrise");
|
createTld("blobio-sunrise");
|
||||||
IllegalStateException thrown =
|
IllegalStateException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
|
@ -386,7 +386,7 @@ public class SetupOteCommandTest extends CommandTestCase<SetupOteCommand> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_tldExists_replaceExisting() throws Exception {
|
void testSuccess_tldExists_replaceExisting() throws Exception {
|
||||||
createTld("blobio-sunrise");
|
createTld("blobio-sunrise");
|
||||||
|
|
||||||
runCommandForced(
|
runCommandForced(
|
||||||
|
@ -401,7 +401,7 @@ public class SetupOteCommandTest extends CommandTestCase<SetupOteCommand> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_registrarExists() {
|
void testFailure_registrarExists() {
|
||||||
Registrar registrar = loadRegistrar("TheRegistrar").asBuilder()
|
Registrar registrar = loadRegistrar("TheRegistrar").asBuilder()
|
||||||
.setClientId("blobio-1")
|
.setClientId("blobio-1")
|
||||||
.setRegistrarName("blobio-1")
|
.setRegistrarName("blobio-1")
|
||||||
|
@ -420,7 +420,7 @@ public class SetupOteCommandTest extends CommandTestCase<SetupOteCommand> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_registrarExists_replaceExisting() throws Exception {
|
void testSuccess_registrarExists_replaceExisting() throws Exception {
|
||||||
Registrar registrar = loadRegistrar("TheRegistrar").asBuilder()
|
Registrar registrar = loadRegistrar("TheRegistrar").asBuilder()
|
||||||
.setClientId("blobio-1")
|
.setClientId("blobio-1")
|
||||||
.setRegistrarName("blobio-1")
|
.setRegistrarName("blobio-1")
|
||||||
|
|
|
@ -39,43 +39,39 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
import org.joda.time.Duration;
|
import org.joda.time.Duration;
|
||||||
import org.junit.After;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Rule;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
import org.junit.runners.JUnit4;
|
|
||||||
|
|
||||||
@RunWith(JUnit4.class)
|
/** Unit tests for {@link ShellCommand}. */
|
||||||
public class ShellCommandTest {
|
class ShellCommandTest {
|
||||||
|
|
||||||
@Rule public final SystemPropertyRule systemPropertyRule = new SystemPropertyRule();
|
@RegisterExtension final SystemPropertyRule systemPropertyRule = new SystemPropertyRule();
|
||||||
|
|
||||||
CommandRunner cli = mock(CommandRunner.class);
|
CommandRunner cli = mock(CommandRunner.class);
|
||||||
FakeClock clock = new FakeClock(DateTime.parse("2000-01-01TZ"));
|
private FakeClock clock = new FakeClock(DateTime.parse("2000-01-01TZ"));
|
||||||
|
|
||||||
PrintStream orgStdout;
|
private PrintStream orgStdout;
|
||||||
PrintStream orgStderr;
|
private PrintStream orgStderr;
|
||||||
|
|
||||||
ByteArrayOutputStream stdout;
|
private ByteArrayOutputStream stdout;
|
||||||
ByteArrayOutputStream stderr;
|
private ByteArrayOutputStream stderr;
|
||||||
|
|
||||||
public ShellCommandTest() {}
|
@BeforeEach
|
||||||
|
void beforeEach() {
|
||||||
@Before
|
|
||||||
public void setUp() {
|
|
||||||
orgStdout = System.out;
|
orgStdout = System.out;
|
||||||
orgStderr = System.err;
|
orgStderr = System.err;
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@AfterEach
|
||||||
public void tearDown() {
|
void afterEach() {
|
||||||
System.setOut(orgStdout);
|
System.setOut(orgStdout);
|
||||||
System.setErr(orgStderr);
|
System.setErr(orgStderr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testParsing() {
|
void testParsing() {
|
||||||
assertThat(ShellCommand.parseCommand("foo bar 123 baz+ // comment \"string data\""))
|
assertThat(ShellCommand.parseCommand("foo bar 123 baz+ // comment \"string data\""))
|
||||||
.isEqualTo(new String[] {"foo", "bar", "123", "baz+", "//", "comment", "string data"});
|
.isEqualTo(new String[] {"foo", "bar", "123", "baz+", "//", "comment", "string data"});
|
||||||
assertThat(ShellCommand.parseCommand("\"got \\\" escapes?\""))
|
assertThat(ShellCommand.parseCommand("\"got \\\" escapes?\""))
|
||||||
|
@ -87,7 +83,9 @@ public class ShellCommandTest {
|
||||||
CommandRunner commandRunner, Duration delay, String... commands) throws Exception {
|
CommandRunner commandRunner, Duration delay, String... commands) throws Exception {
|
||||||
ArrayDeque<String> queue = new ArrayDeque<String>(ImmutableList.copyOf(commands));
|
ArrayDeque<String> queue = new ArrayDeque<String>(ImmutableList.copyOf(commands));
|
||||||
BufferedReader bufferedReader = mock(BufferedReader.class);
|
BufferedReader bufferedReader = mock(BufferedReader.class);
|
||||||
when(bufferedReader.readLine()).thenAnswer((x) -> {
|
when(bufferedReader.readLine())
|
||||||
|
.thenAnswer(
|
||||||
|
(x) -> {
|
||||||
clock.advanceBy(delay);
|
clock.advanceBy(delay);
|
||||||
if (queue.isEmpty()) {
|
if (queue.isEmpty()) {
|
||||||
throw new IOException();
|
throw new IOException();
|
||||||
|
@ -98,7 +96,7 @@ public class ShellCommandTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCommandProcessing() throws Exception {
|
void testCommandProcessing() throws Exception {
|
||||||
MockCli cli = new MockCli();
|
MockCli cli = new MockCli();
|
||||||
ShellCommand shellCommand =
|
ShellCommand shellCommand =
|
||||||
createShellCommand(cli, Duration.ZERO, "test1 foo bar", "test2 foo bar");
|
createShellCommand(cli, Duration.ZERO, "test1 foo bar", "test2 foo bar");
|
||||||
|
@ -110,7 +108,7 @@ public class ShellCommandTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNoIdleWhenInAlpha() throws Exception {
|
void testNoIdleWhenInAlpha() throws Exception {
|
||||||
RegistryToolEnvironment.ALPHA.setup(systemPropertyRule);
|
RegistryToolEnvironment.ALPHA.setup(systemPropertyRule);
|
||||||
MockCli cli = new MockCli();
|
MockCli cli = new MockCli();
|
||||||
ShellCommand shellCommand =
|
ShellCommand shellCommand =
|
||||||
|
@ -119,7 +117,7 @@ public class ShellCommandTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNoIdleWhenInSandbox() throws Exception {
|
void testNoIdleWhenInSandbox() throws Exception {
|
||||||
RegistryToolEnvironment.SANDBOX.setup(systemPropertyRule);
|
RegistryToolEnvironment.SANDBOX.setup(systemPropertyRule);
|
||||||
MockCli cli = new MockCli();
|
MockCli cli = new MockCli();
|
||||||
ShellCommand shellCommand =
|
ShellCommand shellCommand =
|
||||||
|
@ -128,7 +126,7 @@ public class ShellCommandTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIdleWhenOverHourInProduction() throws Exception {
|
void testIdleWhenOverHourInProduction() throws Exception {
|
||||||
RegistryToolEnvironment.PRODUCTION.setup(systemPropertyRule);
|
RegistryToolEnvironment.PRODUCTION.setup(systemPropertyRule);
|
||||||
MockCli cli = new MockCli();
|
MockCli cli = new MockCli();
|
||||||
ShellCommand shellCommand =
|
ShellCommand shellCommand =
|
||||||
|
@ -138,7 +136,7 @@ public class ShellCommandTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNoIdleWhenUnderHourInProduction() throws Exception {
|
void testNoIdleWhenUnderHourInProduction() throws Exception {
|
||||||
RegistryToolEnvironment.PRODUCTION.setup(systemPropertyRule);
|
RegistryToolEnvironment.PRODUCTION.setup(systemPropertyRule);
|
||||||
MockCli cli = new MockCli();
|
MockCli cli = new MockCli();
|
||||||
ShellCommand shellCommand =
|
ShellCommand shellCommand =
|
||||||
|
@ -156,7 +154,7 @@ public class ShellCommandTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMultipleCommandInvocations() throws Exception {
|
void testMultipleCommandInvocations() throws Exception {
|
||||||
try (RegistryCli cli =
|
try (RegistryCli cli =
|
||||||
new RegistryCli("unittest", ImmutableMap.of("test_command", TestCommand.class))) {
|
new RegistryCli("unittest", ImmutableMap.of("test_command", TestCommand.class))) {
|
||||||
RegistryToolEnvironment.UNITTEST.setup(systemPropertyRule);
|
RegistryToolEnvironment.UNITTEST.setup(systemPropertyRule);
|
||||||
|
@ -173,7 +171,7 @@ public class ShellCommandTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNonExistentCommand() {
|
void testNonExistentCommand() {
|
||||||
try (RegistryCli cli =
|
try (RegistryCli cli =
|
||||||
new RegistryCli("unittest", ImmutableMap.of("test_command", TestCommand.class))) {
|
new RegistryCli("unittest", ImmutableMap.of("test_command", TestCommand.class))) {
|
||||||
|
|
||||||
|
@ -183,9 +181,7 @@ public class ShellCommandTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void performJCommanderCompletorTest(
|
private void performJCommanderCompletorTest(
|
||||||
String line,
|
String line, int expectedBackMotion, String... expectedCompletions) {
|
||||||
int expectedBackMotion,
|
|
||||||
String... expectedCompletions) {
|
|
||||||
JCommander jcommander = new JCommander();
|
JCommander jcommander = new JCommander();
|
||||||
jcommander.setProgramName("test");
|
jcommander.setProgramName("test");
|
||||||
jcommander.addCommand("help", new HelpCommand(jcommander));
|
jcommander.addCommand("help", new HelpCommand(jcommander));
|
||||||
|
@ -201,7 +197,7 @@ public class ShellCommandTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCompletion_commands() {
|
void testCompletion_commands() {
|
||||||
performJCommanderCompletorTest("", 0, "testCommand ", "testAnotherCommand ", "help ");
|
performJCommanderCompletorTest("", 0, "testCommand ", "testAnotherCommand ", "help ");
|
||||||
performJCommanderCompletorTest("n", 1);
|
performJCommanderCompletorTest("n", 1);
|
||||||
performJCommanderCompletorTest("test", 4, "testCommand ", "testAnotherCommand ");
|
performJCommanderCompletorTest("test", 4, "testCommand ", "testAnotherCommand ");
|
||||||
|
@ -211,7 +207,7 @@ public class ShellCommandTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCompletion_help() {
|
void testCompletion_help() {
|
||||||
performJCommanderCompletorTest("h", 1, "help ");
|
performJCommanderCompletorTest("h", 1, "help ");
|
||||||
performJCommanderCompletorTest("help ", 0, "testCommand ", "testAnotherCommand ", "help ");
|
performJCommanderCompletorTest("help ", 0, "testCommand ", "testAnotherCommand ", "help ");
|
||||||
performJCommanderCompletorTest("help testC", 5, "testCommand ");
|
performJCommanderCompletorTest("help testC", 5, "testCommand ");
|
||||||
|
@ -219,7 +215,7 @@ public class ShellCommandTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCompletion_documentation() {
|
void testCompletion_documentation() {
|
||||||
performJCommanderCompletorTest(
|
performJCommanderCompletorTest(
|
||||||
"testCommand ",
|
"testCommand ",
|
||||||
0,
|
0,
|
||||||
|
@ -239,7 +235,7 @@ public class ShellCommandTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCompletion_arguments() {
|
void testCompletion_arguments() {
|
||||||
performJCommanderCompletorTest("testCommand -", 1, "-x ", "--xparam ", "--xorg ");
|
performJCommanderCompletorTest("testCommand -", 1, "-x ", "--xparam ", "--xorg ");
|
||||||
performJCommanderCompletorTest("testCommand --wrong", 7);
|
performJCommanderCompletorTest("testCommand --wrong", 7);
|
||||||
performJCommanderCompletorTest("testCommand noise --", 2, "--xparam ", "--xorg ");
|
performJCommanderCompletorTest("testCommand noise --", 2, "--xparam ", "--xorg ");
|
||||||
|
@ -247,7 +243,7 @@ public class ShellCommandTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCompletion_enum() {
|
void testCompletion_enum() {
|
||||||
performJCommanderCompletorTest("testCommand --xorg P", 1, "PRIVATE ", "PUBLIC ");
|
performJCommanderCompletorTest("testCommand --xorg P", 1, "PRIVATE ", "PUBLIC ");
|
||||||
performJCommanderCompletorTest("testCommand --xorg PU", 2, "PUBLIC ");
|
performJCommanderCompletorTest("testCommand --xorg PU", 2, "PUBLIC ");
|
||||||
performJCommanderCompletorTest(
|
performJCommanderCompletorTest(
|
||||||
|
@ -255,7 +251,7 @@ public class ShellCommandTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testEncapsulatedOutputStream_basicFuncionality() {
|
void testEncapsulatedOutputStream_basicFuncionality() {
|
||||||
ByteArrayOutputStream backing = new ByteArrayOutputStream();
|
ByteArrayOutputStream backing = new ByteArrayOutputStream();
|
||||||
try (PrintStream out =
|
try (PrintStream out =
|
||||||
new PrintStream(new ShellCommand.EncapsulatingOutputStream(backing, "out: "))) {
|
new PrintStream(new ShellCommand.EncapsulatingOutputStream(backing, "out: "))) {
|
||||||
|
@ -267,7 +263,7 @@ public class ShellCommandTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testEncapsulatedOutputStream_emptyStream() {
|
void testEncapsulatedOutputStream_emptyStream() {
|
||||||
ByteArrayOutputStream backing = new ByteArrayOutputStream();
|
ByteArrayOutputStream backing = new ByteArrayOutputStream();
|
||||||
try (PrintStream out =
|
try (PrintStream out =
|
||||||
new PrintStream(new ShellCommand.EncapsulatingOutputStream(backing, "out: "))) {}
|
new PrintStream(new ShellCommand.EncapsulatingOutputStream(backing, "out: "))) {}
|
||||||
|
@ -275,7 +271,7 @@ public class ShellCommandTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testEncapsulatedOutput_command() throws Exception {
|
void testEncapsulatedOutput_command() throws Exception {
|
||||||
RegistryToolEnvironment.ALPHA.setup(systemPropertyRule);
|
RegistryToolEnvironment.ALPHA.setup(systemPropertyRule);
|
||||||
captureOutput();
|
captureOutput();
|
||||||
ShellCommand shellCommand =
|
ShellCommand shellCommand =
|
||||||
|
@ -299,7 +295,7 @@ public class ShellCommandTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testEncapsulatedOutput_throws() throws Exception {
|
void testEncapsulatedOutput_throws() throws Exception {
|
||||||
RegistryToolEnvironment.ALPHA.setup(systemPropertyRule);
|
RegistryToolEnvironment.ALPHA.setup(systemPropertyRule);
|
||||||
captureOutput();
|
captureOutput();
|
||||||
ShellCommand shellCommand =
|
ShellCommand shellCommand =
|
||||||
|
@ -319,7 +315,7 @@ public class ShellCommandTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testEncapsulatedOutput_noCommand() throws Exception {
|
void testEncapsulatedOutput_noCommand() throws Exception {
|
||||||
captureOutput();
|
captureOutput();
|
||||||
ShellCommand shellCommand =
|
ShellCommand shellCommand =
|
||||||
createShellCommand(
|
createShellCommand(
|
||||||
|
@ -354,14 +350,12 @@ public class ShellCommandTest {
|
||||||
|
|
||||||
@Parameter(
|
@Parameter(
|
||||||
names = {"-x", "--xparam"},
|
names = {"-x", "--xparam"},
|
||||||
description = "test parameter"
|
description = "test parameter")
|
||||||
)
|
|
||||||
String xparam = "default value";
|
String xparam = "default value";
|
||||||
|
|
||||||
@Parameter(
|
@Parameter(
|
||||||
names = {"--xorg"},
|
names = {"--xorg"},
|
||||||
description = "test organization"
|
description = "test organization")
|
||||||
)
|
|
||||||
OrgType orgType = OrgType.PRIVATE;
|
OrgType orgType = OrgType.PRIVATE;
|
||||||
|
|
||||||
// List for recording command invocations by run().
|
// List for recording command invocations by run().
|
||||||
|
@ -373,7 +367,7 @@ public class ShellCommandTest {
|
||||||
@Parameter(description = "normal argument")
|
@Parameter(description = "normal argument")
|
||||||
List<String> args;
|
List<String> args;
|
||||||
|
|
||||||
public TestCommand() {}
|
TestCommand() {}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
|
|
@ -29,20 +29,20 @@ import google.registry.model.eppcommon.StatusValue;
|
||||||
import google.registry.model.host.HostResource;
|
import google.registry.model.host.HostResource;
|
||||||
import google.registry.persistence.VKey;
|
import google.registry.persistence.VKey;
|
||||||
import javax.xml.bind.annotation.adapters.HexBinaryAdapter;
|
import javax.xml.bind.annotation.adapters.HexBinaryAdapter;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
/** Unit tests for {@link UniformRapidSuspensionCommand}. */
|
/** Unit tests for {@link UniformRapidSuspensionCommand}. */
|
||||||
public class UniformRapidSuspensionCommandTest
|
class UniformRapidSuspensionCommandTest
|
||||||
extends EppToolCommandTestCase<UniformRapidSuspensionCommand> {
|
extends EppToolCommandTestCase<UniformRapidSuspensionCommand> {
|
||||||
|
|
||||||
HostResource ns1;
|
private HostResource ns1;
|
||||||
HostResource ns2;
|
private HostResource ns2;
|
||||||
HostResource urs1;
|
private HostResource urs1;
|
||||||
HostResource urs2;
|
private HostResource urs2;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void initResources() {
|
void beforeEach() {
|
||||||
// Since the command's history client ID must be CharlestonRoad, resave TheRegistrar that way.
|
// Since the command's history client ID must be CharlestonRoad, resave TheRegistrar that way.
|
||||||
persistResource(
|
persistResource(
|
||||||
loadRegistrar("TheRegistrar").asBuilder().setClientId("CharlestonRoad").build());
|
loadRegistrar("TheRegistrar").asBuilder().setClientId("CharlestonRoad").build());
|
||||||
|
@ -66,7 +66,7 @@ public class UniformRapidSuspensionCommandTest
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCommand_addsLocksReplacesHostsAndDsDataPrintsUndo() throws Exception {
|
void testCommand_addsLocksReplacesHostsAndDsDataPrintsUndo() throws Exception {
|
||||||
persistDomainWithHosts(ns1, ns2);
|
persistDomainWithHosts(ns1, ns2);
|
||||||
runCommandForced(
|
runCommandForced(
|
||||||
"--domain_name=evil.tld",
|
"--domain_name=evil.tld",
|
||||||
|
@ -86,7 +86,7 @@ public class UniformRapidSuspensionCommandTest
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCommand_respectsExistingHost() throws Exception {
|
void testCommand_respectsExistingHost() throws Exception {
|
||||||
persistDomainWithHosts(urs2, ns1);
|
persistDomainWithHosts(urs2, ns1);
|
||||||
runCommandForced("--domain_name=evil.tld", "--hosts=urs1.example.com,urs2.example.com");
|
runCommandForced("--domain_name=evil.tld", "--hosts=urs1.example.com,urs2.example.com");
|
||||||
eppVerifier
|
eppVerifier
|
||||||
|
@ -100,7 +100,7 @@ public class UniformRapidSuspensionCommandTest
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCommand_generatesUndoForUndelegatedDomain() throws Exception {
|
void testCommand_generatesUndoForUndelegatedDomain() throws Exception {
|
||||||
persistActiveDomain("evil.tld");
|
persistActiveDomain("evil.tld");
|
||||||
runCommandForced("--domain_name=evil.tld", "--hosts=urs1.example.com,urs2.example.com");
|
runCommandForced("--domain_name=evil.tld", "--hosts=urs1.example.com,urs2.example.com");
|
||||||
eppVerifier.verifySentAny();
|
eppVerifier.verifySentAny();
|
||||||
|
@ -110,7 +110,7 @@ public class UniformRapidSuspensionCommandTest
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCommand_generatesUndoWithLocksToPreserve() throws Exception {
|
void testCommand_generatesUndoWithLocksToPreserve() throws Exception {
|
||||||
persistResource(
|
persistResource(
|
||||||
newDomainBase("evil.tld").asBuilder()
|
newDomainBase("evil.tld").asBuilder()
|
||||||
.addStatusValue(StatusValue.SERVER_DELETE_PROHIBITED)
|
.addStatusValue(StatusValue.SERVER_DELETE_PROHIBITED)
|
||||||
|
@ -123,7 +123,7 @@ public class UniformRapidSuspensionCommandTest
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUndo_removesLocksReplacesHostsAndDsData() throws Exception {
|
void testUndo_removesLocksReplacesHostsAndDsData() throws Exception {
|
||||||
persistDomainWithHosts(urs1, urs2);
|
persistDomainWithHosts(urs1, urs2);
|
||||||
runCommandForced(
|
runCommandForced(
|
||||||
"--domain_name=evil.tld", "--undo", "--hosts=ns1.example.com,ns2.example.com");
|
"--domain_name=evil.tld", "--undo", "--hosts=ns1.example.com,ns2.example.com");
|
||||||
|
@ -135,7 +135,7 @@ public class UniformRapidSuspensionCommandTest
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUndo_respectsLocksToPreserveFlag() throws Exception {
|
void testUndo_respectsLocksToPreserveFlag() throws Exception {
|
||||||
persistDomainWithHosts(urs1, urs2);
|
persistDomainWithHosts(urs1, urs2);
|
||||||
runCommandForced(
|
runCommandForced(
|
||||||
"--domain_name=evil.tld",
|
"--domain_name=evil.tld",
|
||||||
|
@ -150,7 +150,7 @@ public class UniformRapidSuspensionCommandTest
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_locksToPreserveWithoutUndo() {
|
void testFailure_locksToPreserveWithoutUndo() {
|
||||||
persistActiveDomain("evil.tld");
|
persistActiveDomain("evil.tld");
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
|
@ -162,7 +162,7 @@ public class UniformRapidSuspensionCommandTest
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_domainNameRequired() {
|
void testFailure_domainNameRequired() {
|
||||||
persistActiveDomain("evil.tld");
|
persistActiveDomain("evil.tld");
|
||||||
ParameterException thrown =
|
ParameterException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
|
@ -172,7 +172,7 @@ public class UniformRapidSuspensionCommandTest
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_extraFieldInDsData() {
|
void testFailure_extraFieldInDsData() {
|
||||||
persistActiveDomain("evil.tld");
|
persistActiveDomain("evil.tld");
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
|
@ -185,7 +185,7 @@ public class UniformRapidSuspensionCommandTest
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_missingFieldInDsData() {
|
void testFailure_missingFieldInDsData() {
|
||||||
persistActiveDomain("evil.tld");
|
persistActiveDomain("evil.tld");
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
|
@ -198,7 +198,7 @@ public class UniformRapidSuspensionCommandTest
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_malformedDsData() {
|
void testFailure_malformedDsData() {
|
||||||
persistActiveDomain("evil.tld");
|
persistActiveDomain("evil.tld");
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
|
|
|
@ -40,14 +40,14 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import org.joda.time.Duration;
|
import org.joda.time.Duration;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
/** Unit tests for {@link UnlockDomainCommand}. */
|
/** Unit tests for {@link UnlockDomainCommand}. */
|
||||||
public class UnlockDomainCommandTest extends CommandTestCase<UnlockDomainCommand> {
|
class UnlockDomainCommandTest extends CommandTestCase<UnlockDomainCommand> {
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void before() {
|
void beforeEach() {
|
||||||
persistNewRegistrar("adminreg", "Admin Registrar", Type.REAL, 693L);
|
persistNewRegistrar("adminreg", "Admin Registrar", Type.REAL, 693L);
|
||||||
createTld("tld");
|
createTld("tld");
|
||||||
command.registryAdminClientId = "adminreg";
|
command.registryAdminClientId = "adminreg";
|
||||||
|
@ -68,14 +68,14 @@ public class UnlockDomainCommandTest extends CommandTestCase<UnlockDomainCommand
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_unlocksDomain() throws Exception {
|
void testSuccess_unlocksDomain() throws Exception {
|
||||||
DomainBase domain = persistLockedDomain("example.tld", "TheRegistrar");
|
DomainBase domain = persistLockedDomain("example.tld", "TheRegistrar");
|
||||||
runCommandForced("--client=TheRegistrar", "example.tld");
|
runCommandForced("--client=TheRegistrar", "example.tld");
|
||||||
assertThat(reloadResource(domain).getStatusValues()).containsNoneIn(REGISTRY_LOCK_STATUSES);
|
assertThat(reloadResource(domain).getStatusValues()).containsNoneIn(REGISTRY_LOCK_STATUSES);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_partiallyUpdatesStatuses() throws Exception {
|
void testSuccess_partiallyUpdatesStatuses() throws Exception {
|
||||||
DomainBase domain = persistLockedDomain("example.tld", "TheRegistrar");
|
DomainBase domain = persistLockedDomain("example.tld", "TheRegistrar");
|
||||||
domain =
|
domain =
|
||||||
persistResource(
|
persistResource(
|
||||||
|
@ -89,7 +89,7 @@ public class UnlockDomainCommandTest extends CommandTestCase<UnlockDomainCommand
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_manyDomains() throws Exception {
|
void testSuccess_manyDomains() throws Exception {
|
||||||
// Create 26 domains -- one more than the number of entity groups allowed in a transaction (in
|
// Create 26 domains -- one more than the number of entity groups allowed in a transaction (in
|
||||||
// case that was going to be the failure point).
|
// case that was going to be the failure point).
|
||||||
List<DomainBase> domains = new ArrayList<>();
|
List<DomainBase> domains = new ArrayList<>();
|
||||||
|
@ -108,7 +108,7 @@ public class UnlockDomainCommandTest extends CommandTestCase<UnlockDomainCommand
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_domainDoesntExist() {
|
void testFailure_domainDoesntExist() {
|
||||||
IllegalArgumentException e =
|
IllegalArgumentException e =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
|
@ -117,14 +117,14 @@ public class UnlockDomainCommandTest extends CommandTestCase<UnlockDomainCommand
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_alreadyUnlockedDomain_performsNoAction() throws Exception {
|
void testSuccess_alreadyUnlockedDomain_performsNoAction() throws Exception {
|
||||||
DomainBase domain = persistActiveDomain("example.tld");
|
DomainBase domain = persistActiveDomain("example.tld");
|
||||||
runCommandForced("--client=TheRegistrar", "example.tld");
|
runCommandForced("--client=TheRegistrar", "example.tld");
|
||||||
assertThat(reloadResource(domain)).isEqualTo(domain);
|
assertThat(reloadResource(domain)).isEqualTo(domain);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_defaultsToAdminRegistrar_ifUnspecified() throws Exception {
|
void testSuccess_defaultsToAdminRegistrar_ifUnspecified() throws Exception {
|
||||||
DomainBase domain = persistLockedDomain("example.tld", "TheRegistrar");
|
DomainBase domain = persistLockedDomain("example.tld", "TheRegistrar");
|
||||||
runCommandForced("example.tld");
|
runCommandForced("example.tld");
|
||||||
assertThat(getMostRecentRegistryLockByRepoId(domain.getRepoId()).get().getRegistrarId())
|
assertThat(getMostRecentRegistryLockByRepoId(domain.getRepoId()).get().getRegistrarId())
|
||||||
|
@ -132,7 +132,7 @@ public class UnlockDomainCommandTest extends CommandTestCase<UnlockDomainCommand
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_duplicateDomainsAreSpecified() {
|
void testFailure_duplicateDomainsAreSpecified() {
|
||||||
IllegalArgumentException e =
|
IllegalArgumentException e =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
|
|
|
@ -47,26 +47,26 @@ import google.registry.model.reporting.HistoryEntry;
|
||||||
import google.registry.testing.FakeClock;
|
import google.registry.testing.FakeClock;
|
||||||
import google.registry.testing.InjectRule;
|
import google.registry.testing.InjectRule;
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Rule;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||||
|
|
||||||
/** Unit tests for {@link UnrenewDomainCommand}. */
|
/** Unit tests for {@link UnrenewDomainCommand}. */
|
||||||
public class UnrenewDomainCommandTest extends CommandTestCase<UnrenewDomainCommand> {
|
public class UnrenewDomainCommandTest extends CommandTestCase<UnrenewDomainCommand> {
|
||||||
|
|
||||||
@Rule public final InjectRule inject = new InjectRule();
|
@RegisterExtension public final InjectRule inject = new InjectRule();
|
||||||
|
|
||||||
private final FakeClock clock = new FakeClock(DateTime.parse("2016-12-06T13:55:01Z"));
|
private final FakeClock clock = new FakeClock(DateTime.parse("2016-12-06T13:55:01Z"));
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void before() {
|
void beforeEach() {
|
||||||
createTld("tld");
|
createTld("tld");
|
||||||
inject.setStaticField(Ofy.class, "clock", clock);
|
inject.setStaticField(Ofy.class, "clock", clock);
|
||||||
command.clock = clock;
|
command.clock = clock;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_unrenewTwoDomains_worksSuccessfully() throws Exception {
|
void test_unrenewTwoDomains_worksSuccessfully() throws Exception {
|
||||||
ContactResource contact = persistActiveContact("jd1234");
|
ContactResource contact = persistActiveContact("jd1234");
|
||||||
clock.advanceOneMilli();
|
clock.advanceOneMilli();
|
||||||
persistDomainWithDependentResources(
|
persistDomainWithDependentResources(
|
||||||
|
@ -91,7 +91,7 @@ public class UnrenewDomainCommandTest extends CommandTestCase<UnrenewDomainComma
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_unrenewDomain_savesDependentEntitiesCorrectly() throws Exception {
|
void test_unrenewDomain_savesDependentEntitiesCorrectly() throws Exception {
|
||||||
ContactResource contact = persistActiveContact("jd1234");
|
ContactResource contact = persistActiveContact("jd1234");
|
||||||
clock.advanceOneMilli();
|
clock.advanceOneMilli();
|
||||||
persistDomainWithDependentResources(
|
persistDomainWithDependentResources(
|
||||||
|
@ -155,7 +155,7 @@ public class UnrenewDomainCommandTest extends CommandTestCase<UnrenewDomainComma
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_periodTooLow_fails() {
|
void test_periodTooLow_fails() {
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class, () -> runCommandForced("--period", "0", "domain.tld"));
|
IllegalArgumentException.class, () -> runCommandForced("--period", "0", "domain.tld"));
|
||||||
|
@ -163,7 +163,7 @@ public class UnrenewDomainCommandTest extends CommandTestCase<UnrenewDomainComma
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_periodTooHigh_fails() {
|
void test_periodTooHigh_fails() {
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class, () -> runCommandForced("--period", "10", "domain.tld"));
|
IllegalArgumentException.class, () -> runCommandForced("--period", "10", "domain.tld"));
|
||||||
|
@ -171,7 +171,7 @@ public class UnrenewDomainCommandTest extends CommandTestCase<UnrenewDomainComma
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_varietyOfInvalidDomains_displaysErrors() {
|
void test_varietyOfInvalidDomains_displaysErrors() {
|
||||||
DateTime now = clock.nowUtc();
|
DateTime now = clock.nowUtc();
|
||||||
persistResource(
|
persistResource(
|
||||||
newDomainBase("deleting.tld")
|
newDomainBase("deleting.tld")
|
||||||
|
|
|
@ -31,13 +31,12 @@ import com.google.common.collect.ImmutableSortedMap;
|
||||||
import google.registry.model.domain.token.AllocationToken;
|
import google.registry.model.domain.token.AllocationToken;
|
||||||
import google.registry.model.domain.token.AllocationToken.TokenStatus;
|
import google.registry.model.domain.token.AllocationToken.TokenStatus;
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
public class UpdateAllocationTokensCommandTest
|
class UpdateAllocationTokensCommandTest extends CommandTestCase<UpdateAllocationTokensCommand> {
|
||||||
extends CommandTestCase<UpdateAllocationTokensCommand> {
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUpdateTlds_setTlds() throws Exception {
|
void testUpdateTlds_setTlds() throws Exception {
|
||||||
AllocationToken token =
|
AllocationToken token =
|
||||||
persistResource(builderWithPromo().setAllowedTlds(ImmutableSet.of("toRemove")).build());
|
persistResource(builderWithPromo().setAllowedTlds(ImmutableSet.of("toRemove")).build());
|
||||||
runCommandForced("--prefix", "token", "--allowed_tlds", "tld,example");
|
runCommandForced("--prefix", "token", "--allowed_tlds", "tld,example");
|
||||||
|
@ -45,7 +44,7 @@ public class UpdateAllocationTokensCommandTest
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUpdateTlds_clearTlds() throws Exception {
|
void testUpdateTlds_clearTlds() throws Exception {
|
||||||
AllocationToken token =
|
AllocationToken token =
|
||||||
persistResource(builderWithPromo().setAllowedTlds(ImmutableSet.of("toRemove")).build());
|
persistResource(builderWithPromo().setAllowedTlds(ImmutableSet.of("toRemove")).build());
|
||||||
runCommandForced("--prefix", "token", "--allowed_tlds", "");
|
runCommandForced("--prefix", "token", "--allowed_tlds", "");
|
||||||
|
@ -53,7 +52,7 @@ public class UpdateAllocationTokensCommandTest
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUpdateClientIds_setClientIds() throws Exception {
|
void testUpdateClientIds_setClientIds() throws Exception {
|
||||||
AllocationToken token =
|
AllocationToken token =
|
||||||
persistResource(
|
persistResource(
|
||||||
builderWithPromo().setAllowedClientIds(ImmutableSet.of("toRemove")).build());
|
builderWithPromo().setAllowedClientIds(ImmutableSet.of("toRemove")).build());
|
||||||
|
@ -63,7 +62,7 @@ public class UpdateAllocationTokensCommandTest
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUpdateClientIds_clearClientIds() throws Exception {
|
void testUpdateClientIds_clearClientIds() throws Exception {
|
||||||
AllocationToken token =
|
AllocationToken token =
|
||||||
persistResource(
|
persistResource(
|
||||||
builderWithPromo().setAllowedClientIds(ImmutableSet.of("toRemove")).build());
|
builderWithPromo().setAllowedClientIds(ImmutableSet.of("toRemove")).build());
|
||||||
|
@ -72,14 +71,14 @@ public class UpdateAllocationTokensCommandTest
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUpdateDiscountFraction() throws Exception {
|
void testUpdateDiscountFraction() throws Exception {
|
||||||
AllocationToken token = persistResource(builderWithPromo().setDiscountFraction(0.5).build());
|
AllocationToken token = persistResource(builderWithPromo().setDiscountFraction(0.5).build());
|
||||||
runCommandForced("--prefix", "token", "--discount_fraction", "0.15");
|
runCommandForced("--prefix", "token", "--discount_fraction", "0.15");
|
||||||
assertThat(reloadResource(token).getDiscountFraction()).isEqualTo(0.15);
|
assertThat(reloadResource(token).getDiscountFraction()).isEqualTo(0.15);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUpdateStatusTransitions() throws Exception {
|
void testUpdateStatusTransitions() throws Exception {
|
||||||
DateTime now = DateTime.now(UTC);
|
DateTime now = DateTime.now(UTC);
|
||||||
AllocationToken token = persistResource(builderWithPromo().build());
|
AllocationToken token = persistResource(builderWithPromo().build());
|
||||||
runCommandForced(
|
runCommandForced(
|
||||||
|
@ -94,7 +93,7 @@ public class UpdateAllocationTokensCommandTest
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUpdateStatusTransitions_badTransitions() {
|
void testUpdateStatusTransitions_badTransitions() {
|
||||||
DateTime now = DateTime.now(UTC);
|
DateTime now = DateTime.now(UTC);
|
||||||
persistResource(builderWithPromo().build());
|
persistResource(builderWithPromo().build());
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
|
@ -114,7 +113,7 @@ public class UpdateAllocationTokensCommandTest
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUpdate_onlyWithPrefix() throws Exception {
|
void testUpdate_onlyWithPrefix() throws Exception {
|
||||||
AllocationToken token =
|
AllocationToken token =
|
||||||
persistResource(builderWithPromo().setAllowedTlds(ImmutableSet.of("tld")).build());
|
persistResource(builderWithPromo().setAllowedTlds(ImmutableSet.of("tld")).build());
|
||||||
AllocationToken otherToken =
|
AllocationToken otherToken =
|
||||||
|
@ -130,7 +129,7 @@ public class UpdateAllocationTokensCommandTest
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUpdate_onlyTokensProvided() throws Exception {
|
void testUpdate_onlyTokensProvided() throws Exception {
|
||||||
AllocationToken firstToken =
|
AllocationToken firstToken =
|
||||||
persistResource(builderWithPromo().setAllowedTlds(ImmutableSet.of("tld")).build());
|
persistResource(builderWithPromo().setAllowedTlds(ImmutableSet.of("tld")).build());
|
||||||
AllocationToken secondToken =
|
AllocationToken secondToken =
|
||||||
|
@ -154,7 +153,7 @@ public class UpdateAllocationTokensCommandTest
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDoNothing() throws Exception {
|
void testDoNothing() throws Exception {
|
||||||
AllocationToken token =
|
AllocationToken token =
|
||||||
persistResource(
|
persistResource(
|
||||||
builderWithPromo()
|
builderWithPromo()
|
||||||
|
@ -170,7 +169,7 @@ public class UpdateAllocationTokensCommandTest
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_bothTokensAndPrefix() {
|
void testFailure_bothTokensAndPrefix() {
|
||||||
assertThat(
|
assertThat(
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
|
@ -180,7 +179,7 @@ public class UpdateAllocationTokensCommandTest
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_neitherTokensNorPrefix() {
|
void testFailure_neitherTokensNorPrefix() {
|
||||||
assertThat(
|
assertThat(
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class, () -> runCommandForced("--allowed_tlds", "tld")))
|
IllegalArgumentException.class, () -> runCommandForced("--allowed_tlds", "tld")))
|
||||||
|
@ -189,7 +188,7 @@ public class UpdateAllocationTokensCommandTest
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_emptyPrefix() {
|
void testFailure_emptyPrefix() {
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(IllegalArgumentException.class, () -> runCommandForced("--prefix", ""));
|
assertThrows(IllegalArgumentException.class, () -> runCommandForced("--prefix", ""));
|
||||||
assertThat(thrown).hasMessageThat().isEqualTo("Provided prefix should not be blank");
|
assertThat(thrown).hasMessageThat().isEqualTo("Provided prefix should not be blank");
|
||||||
|
|
|
@ -26,16 +26,16 @@ import google.registry.model.common.Cursor.CursorType;
|
||||||
import google.registry.model.registry.Registry;
|
import google.registry.model.registry.Registry;
|
||||||
import google.registry.model.registry.Registry.RegistryNotFoundException;
|
import google.registry.model.registry.Registry.RegistryNotFoundException;
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
/** Unit tests for {@link UpdateCursorsCommand}. */
|
/** Unit tests for {@link UpdateCursorsCommand}. */
|
||||||
public class UpdateCursorsCommandTest extends CommandTestCase<UpdateCursorsCommand> {
|
class UpdateCursorsCommandTest extends CommandTestCase<UpdateCursorsCommand> {
|
||||||
|
|
||||||
Registry registry;
|
private Registry registry;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void before() {
|
void beforeEach() {
|
||||||
createTld("foo");
|
createTld("foo");
|
||||||
registry = Registry.get("foo");
|
registry = Registry.get("foo");
|
||||||
}
|
}
|
||||||
|
@ -66,33 +66,33 @@ public class UpdateCursorsCommandTest extends CommandTestCase<UpdateCursorsComma
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_oldValueisEmpty() throws Exception {
|
void testSuccess_oldValueisEmpty() throws Exception {
|
||||||
assertThat(ofy().load().key(Cursor.createKey(CursorType.BRDA, registry)).now()).isNull();
|
assertThat(ofy().load().key(Cursor.createKey(CursorType.BRDA, registry)).now()).isNull();
|
||||||
doUpdateTest();
|
doUpdateTest();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_hasOldValue() throws Exception {
|
void testSuccess_hasOldValue() throws Exception {
|
||||||
persistResource(Cursor.create(CursorType.BRDA, DateTime.parse("1950-12-18TZ"), registry));
|
persistResource(Cursor.create(CursorType.BRDA, DateTime.parse("1950-12-18TZ"), registry));
|
||||||
doUpdateTest();
|
doUpdateTest();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_global_hasOldValue() throws Exception {
|
void testSuccess_global_hasOldValue() throws Exception {
|
||||||
persistResource(
|
persistResource(
|
||||||
Cursor.createGlobal(CursorType.RECURRING_BILLING, DateTime.parse("1950-12-18TZ")));
|
Cursor.createGlobal(CursorType.RECURRING_BILLING, DateTime.parse("1950-12-18TZ")));
|
||||||
doGlobalUpdateTest();
|
doGlobalUpdateTest();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_global_oldValueisEmpty() throws Exception {
|
void testSuccess_global_oldValueisEmpty() throws Exception {
|
||||||
assertThat(ofy().load().key(Cursor.createGlobalKey(CursorType.RECURRING_BILLING)).now())
|
assertThat(ofy().load().key(Cursor.createGlobalKey(CursorType.RECURRING_BILLING)).now())
|
||||||
.isNull();
|
.isNull();
|
||||||
doGlobalUpdateTest();
|
doGlobalUpdateTest();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_multipleTlds_hasOldValue() throws Exception {
|
void testSuccess_multipleTlds_hasOldValue() throws Exception {
|
||||||
createTld("bar");
|
createTld("bar");
|
||||||
Registry registry2 = Registry.get("bar");
|
Registry registry2 = Registry.get("bar");
|
||||||
persistResource(Cursor.create(CursorType.BRDA, DateTime.parse("1950-12-18TZ"), registry));
|
persistResource(Cursor.create(CursorType.BRDA, DateTime.parse("1950-12-18TZ"), registry));
|
||||||
|
@ -110,7 +110,7 @@ public class UpdateCursorsCommandTest extends CommandTestCase<UpdateCursorsComma
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_multipleTlds_oldValueisEmpty() throws Exception {
|
void testSuccess_multipleTlds_oldValueisEmpty() throws Exception {
|
||||||
createTld("bar");
|
createTld("bar");
|
||||||
Registry registry2 = Registry.get("bar");
|
Registry registry2 = Registry.get("bar");
|
||||||
assertThat(ofy().load().key(Cursor.createKey(CursorType.BRDA, registry)).now()).isNull();
|
assertThat(ofy().load().key(Cursor.createKey(CursorType.BRDA, registry)).now()).isNull();
|
||||||
|
@ -128,14 +128,14 @@ public class UpdateCursorsCommandTest extends CommandTestCase<UpdateCursorsComma
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_badTld() {
|
void testFailure_badTld() {
|
||||||
assertThrows(
|
assertThrows(
|
||||||
RegistryNotFoundException.class,
|
RegistryNotFoundException.class,
|
||||||
() -> runCommandForced("--type=brda", "--timestamp=1984-12-18T00:00:00Z", "bar"));
|
() -> runCommandForced("--type=brda", "--timestamp=1984-12-18T00:00:00Z", "bar"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_badCursorType() {
|
void testFailure_badCursorType() {
|
||||||
ParameterException thrown =
|
ParameterException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
ParameterException.class,
|
ParameterException.class,
|
||||||
|
|
|
@ -31,13 +31,13 @@ import google.registry.model.domain.DesignatedContact;
|
||||||
import google.registry.model.eppcommon.StatusValue;
|
import google.registry.model.eppcommon.StatusValue;
|
||||||
import google.registry.model.host.HostResource;
|
import google.registry.model.host.HostResource;
|
||||||
import google.registry.persistence.VKey;
|
import google.registry.persistence.VKey;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
/** Unit tests for {@link UpdateDomainCommand}. */
|
/** Unit tests for {@link UpdateDomainCommand}. */
|
||||||
public class UpdateDomainCommandTest extends EppToolCommandTestCase<UpdateDomainCommand> {
|
class UpdateDomainCommandTest extends EppToolCommandTestCase<UpdateDomainCommand> {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_complete() throws Exception {
|
void testSuccess_complete() throws Exception {
|
||||||
runCommandForced(
|
runCommandForced(
|
||||||
"--client=NewRegistrar",
|
"--client=NewRegistrar",
|
||||||
"--add_nameservers=ns1.zdns.google,ns2.zdns.google",
|
"--add_nameservers=ns1.zdns.google,ns2.zdns.google",
|
||||||
|
@ -57,7 +57,7 @@ public class UpdateDomainCommandTest extends EppToolCommandTestCase<UpdateDomain
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_completeWithSquareBrackets() throws Exception {
|
void testSuccess_completeWithSquareBrackets() throws Exception {
|
||||||
runCommandForced(
|
runCommandForced(
|
||||||
"--client=NewRegistrar",
|
"--client=NewRegistrar",
|
||||||
"--add_nameservers=ns[1-2].zdns.google",
|
"--add_nameservers=ns[1-2].zdns.google",
|
||||||
|
@ -77,7 +77,7 @@ public class UpdateDomainCommandTest extends EppToolCommandTestCase<UpdateDomain
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_multipleDomains() throws Exception {
|
void testSuccess_multipleDomains() throws Exception {
|
||||||
runCommandForced(
|
runCommandForced(
|
||||||
"--client=NewRegistrar",
|
"--client=NewRegistrar",
|
||||||
"--add_nameservers=ns1.zdns.google,ns2.zdns.google",
|
"--add_nameservers=ns1.zdns.google,ns2.zdns.google",
|
||||||
|
@ -100,12 +100,12 @@ public class UpdateDomainCommandTest extends EppToolCommandTestCase<UpdateDomain
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_multipleDomains_setNameservers() throws Exception {
|
void testSuccess_multipleDomains_setNameservers() throws Exception {
|
||||||
runTest_multipleDomains_setNameservers("-n ns1.foo.fake,ns2.foo.fake");
|
runTest_multipleDomains_setNameservers("-n ns1.foo.fake,ns2.foo.fake");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_multipleDomains_setNameserversWithSquareBrackets() throws Exception {
|
void testSuccess_multipleDomains_setNameserversWithSquareBrackets() throws Exception {
|
||||||
runTest_multipleDomains_setNameservers("-n ns[1-2].foo.fake");
|
runTest_multipleDomains_setNameservers("-n ns[1-2].foo.fake");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,7 +135,7 @@ public class UpdateDomainCommandTest extends EppToolCommandTestCase<UpdateDomain
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_add() throws Exception {
|
void testSuccess_add() throws Exception {
|
||||||
runCommandForced(
|
runCommandForced(
|
||||||
"--client=NewRegistrar",
|
"--client=NewRegistrar",
|
||||||
"--add_nameservers=ns2.zdns.google,ns3.zdns.google",
|
"--add_nameservers=ns2.zdns.google,ns3.zdns.google",
|
||||||
|
@ -148,7 +148,7 @@ public class UpdateDomainCommandTest extends EppToolCommandTestCase<UpdateDomain
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_remove() throws Exception {
|
void testSuccess_remove() throws Exception {
|
||||||
runCommandForced(
|
runCommandForced(
|
||||||
"--client=NewRegistrar",
|
"--client=NewRegistrar",
|
||||||
"--remove_nameservers=ns4.zdns.google",
|
"--remove_nameservers=ns4.zdns.google",
|
||||||
|
@ -161,14 +161,14 @@ public class UpdateDomainCommandTest extends EppToolCommandTestCase<UpdateDomain
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_change() throws Exception {
|
void testSuccess_change() throws Exception {
|
||||||
runCommandForced(
|
runCommandForced(
|
||||||
"--client=NewRegistrar", "--registrant=crr-admin", "--password=2fooBAR", "example.tld");
|
"--client=NewRegistrar", "--registrant=crr-admin", "--password=2fooBAR", "example.tld");
|
||||||
eppVerifier.verifySent("domain_update_change.xml");
|
eppVerifier.verifySent("domain_update_change.xml");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_setNameservers() throws Exception {
|
void testSuccess_setNameservers() throws Exception {
|
||||||
HostResource host1 = persistActiveHost("ns1.zdns.google");
|
HostResource host1 = persistActiveHost("ns1.zdns.google");
|
||||||
HostResource host2 = persistActiveHost("ns2.zdns.google");
|
HostResource host2 = persistActiveHost("ns2.zdns.google");
|
||||||
ImmutableSet<VKey<HostResource>> nameservers =
|
ImmutableSet<VKey<HostResource>> nameservers =
|
||||||
|
@ -181,7 +181,7 @@ public class UpdateDomainCommandTest extends EppToolCommandTestCase<UpdateDomain
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_setContacts() throws Exception {
|
void testSuccess_setContacts() throws Exception {
|
||||||
ContactResource adminContact1 = persistResource(newContactResource("crr-admin1"));
|
ContactResource adminContact1 = persistResource(newContactResource("crr-admin1"));
|
||||||
ContactResource adminContact2 = persistResource(newContactResource("crr-admin2"));
|
ContactResource adminContact2 = persistResource(newContactResource("crr-admin2"));
|
||||||
ContactResource techContact1 = persistResource(newContactResource("crr-tech1"));
|
ContactResource techContact1 = persistResource(newContactResource("crr-tech1"));
|
||||||
|
@ -211,7 +211,7 @@ public class UpdateDomainCommandTest extends EppToolCommandTestCase<UpdateDomain
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_setStatuses() throws Exception {
|
void testSuccess_setStatuses() throws Exception {
|
||||||
HostResource host = persistActiveHost("ns1.zdns.google");
|
HostResource host = persistActiveHost("ns1.zdns.google");
|
||||||
ImmutableSet<VKey<HostResource>> nameservers = ImmutableSet.of(host.createVKey());
|
ImmutableSet<VKey<HostResource>> nameservers = ImmutableSet.of(host.createVKey());
|
||||||
persistResource(
|
persistResource(
|
||||||
|
@ -229,14 +229,14 @@ public class UpdateDomainCommandTest extends EppToolCommandTestCase<UpdateDomain
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_setDsRecords() throws Exception {
|
void testSuccess_setDsRecords() throws Exception {
|
||||||
runCommandForced(
|
runCommandForced(
|
||||||
"--client=NewRegistrar", "--ds_records=1 2 3 abcd,4 5 6 EF01", "example.tld");
|
"--client=NewRegistrar", "--ds_records=1 2 3 abcd,4 5 6 EF01", "example.tld");
|
||||||
eppVerifier.verifySent("domain_update_set_ds_records.xml");
|
eppVerifier.verifySent("domain_update_set_ds_records.xml");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_setDsRecords_withUnneededClear() throws Exception {
|
void testSuccess_setDsRecords_withUnneededClear() throws Exception {
|
||||||
runCommandForced(
|
runCommandForced(
|
||||||
"--client=NewRegistrar",
|
"--client=NewRegistrar",
|
||||||
"--ds_records=1 2 3 abcd,4 5 6 EF01",
|
"--ds_records=1 2 3 abcd,4 5 6 EF01",
|
||||||
|
@ -246,7 +246,7 @@ public class UpdateDomainCommandTest extends EppToolCommandTestCase<UpdateDomain
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_clearDsRecords() throws Exception {
|
void testSuccess_clearDsRecords() throws Exception {
|
||||||
runCommandForced(
|
runCommandForced(
|
||||||
"--client=NewRegistrar",
|
"--client=NewRegistrar",
|
||||||
"--clear_ds_records",
|
"--clear_ds_records",
|
||||||
|
@ -255,7 +255,7 @@ public class UpdateDomainCommandTest extends EppToolCommandTestCase<UpdateDomain
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_cantUpdateRegistryLockedDomainEvenAsSuperuser() {
|
void testFailure_cantUpdateRegistryLockedDomainEvenAsSuperuser() {
|
||||||
HostResource host = persistActiveHost("ns1.zdns.google");
|
HostResource host = persistActiveHost("ns1.zdns.google");
|
||||||
ImmutableSet<VKey<HostResource>> nameservers = ImmutableSet.of(host.createVKey());
|
ImmutableSet<VKey<HostResource>> nameservers = ImmutableSet.of(host.createVKey());
|
||||||
persistResource(
|
persistResource(
|
||||||
|
@ -280,7 +280,7 @@ public class UpdateDomainCommandTest extends EppToolCommandTestCase<UpdateDomain
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_duplicateDomains() {
|
void testFailure_duplicateDomains() {
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
|
@ -295,7 +295,7 @@ public class UpdateDomainCommandTest extends EppToolCommandTestCase<UpdateDomain
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_missingDomain() {
|
void testFailure_missingDomain() {
|
||||||
ParameterException thrown =
|
ParameterException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
ParameterException.class,
|
ParameterException.class,
|
||||||
|
@ -306,7 +306,7 @@ public class UpdateDomainCommandTest extends EppToolCommandTestCase<UpdateDomain
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_missingClientId() {
|
void testFailure_missingClientId() {
|
||||||
ParameterException thrown =
|
ParameterException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
ParameterException.class,
|
ParameterException.class,
|
||||||
|
@ -315,7 +315,7 @@ public class UpdateDomainCommandTest extends EppToolCommandTestCase<UpdateDomain
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_addTooManyNameServers() {
|
void testFailure_addTooManyNameServers() {
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
|
@ -334,7 +334,7 @@ public class UpdateDomainCommandTest extends EppToolCommandTestCase<UpdateDomain
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_providedNameserversAndAddNameservers() {
|
void testFailure_providedNameserversAndAddNameservers() {
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
|
@ -352,7 +352,7 @@ public class UpdateDomainCommandTest extends EppToolCommandTestCase<UpdateDomain
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_providedNameserversAndRemoveNameservers() {
|
void testFailure_providedNameserversAndRemoveNameservers() {
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
|
@ -370,7 +370,7 @@ public class UpdateDomainCommandTest extends EppToolCommandTestCase<UpdateDomain
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_providedAdminsAndAddAdmins() {
|
void testFailure_providedAdminsAndAddAdmins() {
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
|
@ -388,7 +388,7 @@ public class UpdateDomainCommandTest extends EppToolCommandTestCase<UpdateDomain
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_providedAdminsAndRemoveAdmins() {
|
void testFailure_providedAdminsAndRemoveAdmins() {
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
|
@ -406,7 +406,7 @@ public class UpdateDomainCommandTest extends EppToolCommandTestCase<UpdateDomain
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_providedTechsAndAddTechs() {
|
void testFailure_providedTechsAndAddTechs() {
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
|
@ -423,7 +423,7 @@ public class UpdateDomainCommandTest extends EppToolCommandTestCase<UpdateDomain
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_providedTechsAndRemoveTechs() {
|
void testFailure_providedTechsAndRemoveTechs() {
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
|
@ -440,7 +440,7 @@ public class UpdateDomainCommandTest extends EppToolCommandTestCase<UpdateDomain
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_providedStatusesAndAddStatuses() {
|
void testFailure_providedStatusesAndAddStatuses() {
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
|
@ -458,7 +458,7 @@ public class UpdateDomainCommandTest extends EppToolCommandTestCase<UpdateDomain
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_providedStatusesAndRemoveStatuses() {
|
void testFailure_providedStatusesAndRemoveStatuses() {
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
|
@ -476,7 +476,7 @@ public class UpdateDomainCommandTest extends EppToolCommandTestCase<UpdateDomain
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_provideDsRecordsAndAddDsRecords() {
|
void testFailure_provideDsRecordsAndAddDsRecords() {
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
|
@ -494,7 +494,7 @@ public class UpdateDomainCommandTest extends EppToolCommandTestCase<UpdateDomain
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_provideDsRecordsAndRemoveDsRecords() {
|
void testFailure_provideDsRecordsAndRemoveDsRecords() {
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
|
@ -512,7 +512,7 @@ public class UpdateDomainCommandTest extends EppToolCommandTestCase<UpdateDomain
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_clearDsRecordsAndAddDsRecords() {
|
void testFailure_clearDsRecordsAndAddDsRecords() {
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
|
@ -530,7 +530,7 @@ public class UpdateDomainCommandTest extends EppToolCommandTestCase<UpdateDomain
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_clearDsRecordsAndRemoveDsRecords() {
|
void testFailure_clearDsRecordsAndRemoveDsRecords() {
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
|
|
|
@ -24,22 +24,22 @@ import static org.mockito.Mockito.when;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.net.MediaType;
|
import com.google.common.net.MediaType;
|
||||||
import google.registry.tools.server.UpdatePremiumListAction;
|
import google.registry.tools.server.UpdatePremiumListAction;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
|
|
||||||
/** Unit tests for {@link UpdatePremiumListCommand}. */
|
/** Unit tests for {@link UpdatePremiumListCommand}. */
|
||||||
public class UpdatePremiumListCommandTest<C extends UpdatePremiumListCommand>
|
class UpdatePremiumListCommandTest<C extends UpdatePremiumListCommand>
|
||||||
extends CreateOrUpdatePremiumListCommandTestCase<C> {
|
extends CreateOrUpdatePremiumListCommandTestCase<C> {
|
||||||
|
|
||||||
@Mock AppEngineConnection connection;
|
@Mock AppEngineConnection connection;
|
||||||
|
|
||||||
String premiumTermsPath;
|
private String premiumTermsPath;
|
||||||
String premiumTermsCsv;
|
String premiumTermsCsv;
|
||||||
String servletPath;
|
private String servletPath;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void init() throws Exception {
|
void beforeEach() throws Exception {
|
||||||
command.setConnection(connection);
|
command.setConnection(connection);
|
||||||
servletPath = "/_dr/admin/updatePremiumList";
|
servletPath = "/_dr/admin/updatePremiumList";
|
||||||
premiumTermsPath =
|
premiumTermsPath =
|
||||||
|
@ -52,7 +52,7 @@ public class UpdatePremiumListCommandTest<C extends UpdatePremiumListCommand>
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRun() throws Exception {
|
void testRun() throws Exception {
|
||||||
runCommandForced("-i=" + premiumTermsPath, "-n=foo");
|
runCommandForced("-i=" + premiumTermsPath, "-n=foo");
|
||||||
verifySentParams(
|
verifySentParams(
|
||||||
connection,
|
connection,
|
||||||
|
@ -61,7 +61,7 @@ public class UpdatePremiumListCommandTest<C extends UpdatePremiumListCommand>
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRun_noProvidedName_usesBasenameOfInputFile() throws Exception {
|
void testRun_noProvidedName_usesBasenameOfInputFile() throws Exception {
|
||||||
runCommandForced("-i=" + premiumTermsPath);
|
runCommandForced("-i=" + premiumTermsPath);
|
||||||
assertInStdout("Successfully");
|
assertInStdout("Successfully");
|
||||||
verifySentParams(
|
verifySentParams(
|
||||||
|
|
|
@ -39,13 +39,13 @@ import google.registry.util.CidrAddressBlock;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import org.joda.money.CurrencyUnit;
|
import org.joda.money.CurrencyUnit;
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
/** Unit tests for {@link UpdateRegistrarCommand}. */
|
/** Unit tests for {@link UpdateRegistrarCommand}. */
|
||||||
public class UpdateRegistrarCommandTest extends CommandTestCase<UpdateRegistrarCommand> {
|
class UpdateRegistrarCommandTest extends CommandTestCase<UpdateRegistrarCommand> {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_alsoUpdateInCloudSql() throws Exception {
|
void testSuccess_alsoUpdateInCloudSql() throws Exception {
|
||||||
assertThat(loadRegistrar("NewRegistrar").verifyPassword("some_password")).isFalse();
|
assertThat(loadRegistrar("NewRegistrar").verifyPassword("some_password")).isFalse();
|
||||||
jpaTm().transact(() -> jpaTm().saveNew(loadRegistrar("NewRegistrar")));
|
jpaTm().transact(() -> jpaTm().saveNew(loadRegistrar("NewRegistrar")));
|
||||||
runCommand("--password=some_password", "--force", "NewRegistrar");
|
runCommand("--password=some_password", "--force", "NewRegistrar");
|
||||||
|
@ -58,14 +58,14 @@ public class UpdateRegistrarCommandTest extends CommandTestCase<UpdateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_password() throws Exception {
|
void testSuccess_password() throws Exception {
|
||||||
assertThat(loadRegistrar("NewRegistrar").verifyPassword("some_password")).isFalse();
|
assertThat(loadRegistrar("NewRegistrar").verifyPassword("some_password")).isFalse();
|
||||||
runCommand("--password=some_password", "--force", "NewRegistrar");
|
runCommand("--password=some_password", "--force", "NewRegistrar");
|
||||||
assertThat(loadRegistrar("NewRegistrar").verifyPassword("some_password")).isTrue();
|
assertThat(loadRegistrar("NewRegistrar").verifyPassword("some_password")).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_registrarType() throws Exception {
|
void testSuccess_registrarType() throws Exception {
|
||||||
persistResource(
|
persistResource(
|
||||||
loadRegistrar("NewRegistrar")
|
loadRegistrar("NewRegistrar")
|
||||||
.asBuilder()
|
.asBuilder()
|
||||||
|
@ -78,7 +78,7 @@ public class UpdateRegistrarCommandTest extends CommandTestCase<UpdateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_noPasscodeOnChangeToReal() {
|
void testFailure_noPasscodeOnChangeToReal() {
|
||||||
persistResource(
|
persistResource(
|
||||||
loadRegistrar("NewRegistrar")
|
loadRegistrar("NewRegistrar")
|
||||||
.asBuilder()
|
.asBuilder()
|
||||||
|
@ -94,14 +94,14 @@ public class UpdateRegistrarCommandTest extends CommandTestCase<UpdateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_registrarState() throws Exception {
|
void testSuccess_registrarState() throws Exception {
|
||||||
assertThat(loadRegistrar("NewRegistrar").getState()).isEqualTo(State.ACTIVE);
|
assertThat(loadRegistrar("NewRegistrar").getState()).isEqualTo(State.ACTIVE);
|
||||||
runCommand("--registrar_state=SUSPENDED", "--force", "NewRegistrar");
|
runCommand("--registrar_state=SUSPENDED", "--force", "NewRegistrar");
|
||||||
assertThat(loadRegistrar("NewRegistrar").getState()).isEqualTo(State.SUSPENDED);
|
assertThat(loadRegistrar("NewRegistrar").getState()).isEqualTo(State.SUSPENDED);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_allowedTlds() throws Exception {
|
void testSuccess_allowedTlds() throws Exception {
|
||||||
persistWhoisAbuseContact();
|
persistWhoisAbuseContact();
|
||||||
createTlds("xn--q9jyb4c", "foobar");
|
createTlds("xn--q9jyb4c", "foobar");
|
||||||
persistResource(
|
persistResource(
|
||||||
|
@ -119,7 +119,7 @@ public class UpdateRegistrarCommandTest extends CommandTestCase<UpdateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_addAllowedTlds() throws Exception {
|
void testSuccess_addAllowedTlds() throws Exception {
|
||||||
persistWhoisAbuseContact();
|
persistWhoisAbuseContact();
|
||||||
createTlds("xn--q9jyb4c", "foo", "bar");
|
createTlds("xn--q9jyb4c", "foo", "bar");
|
||||||
persistResource(
|
persistResource(
|
||||||
|
@ -137,7 +137,7 @@ public class UpdateRegistrarCommandTest extends CommandTestCase<UpdateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_addAllowedTldsWithDupes() throws Exception {
|
void testSuccess_addAllowedTldsWithDupes() throws Exception {
|
||||||
persistWhoisAbuseContact();
|
persistWhoisAbuseContact();
|
||||||
createTlds("xn--q9jyb4c", "foo", "bar");
|
createTlds("xn--q9jyb4c", "foo", "bar");
|
||||||
persistResource(
|
persistResource(
|
||||||
|
@ -155,7 +155,7 @@ public class UpdateRegistrarCommandTest extends CommandTestCase<UpdateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_allowedTldsInNonProductionEnvironment() throws Exception {
|
void testSuccess_allowedTldsInNonProductionEnvironment() throws Exception {
|
||||||
createTlds("xn--q9jyb4c", "foobar");
|
createTlds("xn--q9jyb4c", "foobar");
|
||||||
persistResource(
|
persistResource(
|
||||||
loadRegistrar("NewRegistrar")
|
loadRegistrar("NewRegistrar")
|
||||||
|
@ -172,7 +172,7 @@ public class UpdateRegistrarCommandTest extends CommandTestCase<UpdateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_allowedTldsInPdtRegistrar() throws Exception {
|
void testSuccess_allowedTldsInPdtRegistrar() throws Exception {
|
||||||
createTlds("xn--q9jyb4c", "foobar");
|
createTlds("xn--q9jyb4c", "foobar");
|
||||||
persistResource(
|
persistResource(
|
||||||
loadRegistrar("NewRegistrar")
|
loadRegistrar("NewRegistrar")
|
||||||
|
@ -191,7 +191,7 @@ public class UpdateRegistrarCommandTest extends CommandTestCase<UpdateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_ipAllowList() throws Exception {
|
void testSuccess_ipAllowList() throws Exception {
|
||||||
assertThat(loadRegistrar("NewRegistrar").getIpAddressAllowList()).isEmpty();
|
assertThat(loadRegistrar("NewRegistrar").getIpAddressAllowList()).isEmpty();
|
||||||
runCommand("--ip_allow_list=192.168.1.1,192.168.0.2/16", "--force", "NewRegistrar");
|
runCommand("--ip_allow_list=192.168.1.1,192.168.0.2/16", "--force", "NewRegistrar");
|
||||||
assertThat(loadRegistrar("NewRegistrar").getIpAddressAllowList())
|
assertThat(loadRegistrar("NewRegistrar").getIpAddressAllowList())
|
||||||
|
@ -201,7 +201,7 @@ public class UpdateRegistrarCommandTest extends CommandTestCase<UpdateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_clearIpAllowList_useNull() throws Exception {
|
void testSuccess_clearIpAllowList_useNull() throws Exception {
|
||||||
persistResource(
|
persistResource(
|
||||||
loadRegistrar("NewRegistrar")
|
loadRegistrar("NewRegistrar")
|
||||||
.asBuilder()
|
.asBuilder()
|
||||||
|
@ -216,7 +216,7 @@ public class UpdateRegistrarCommandTest extends CommandTestCase<UpdateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_clearIpAllowList_useEmpty() throws Exception {
|
void testSuccess_clearIpAllowList_useEmpty() throws Exception {
|
||||||
persistResource(
|
persistResource(
|
||||||
loadRegistrar("NewRegistrar")
|
loadRegistrar("NewRegistrar")
|
||||||
.asBuilder()
|
.asBuilder()
|
||||||
|
@ -231,7 +231,7 @@ public class UpdateRegistrarCommandTest extends CommandTestCase<UpdateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_certFile() throws Exception {
|
void testSuccess_certFile() throws Exception {
|
||||||
Registrar registrar = loadRegistrar("NewRegistrar");
|
Registrar registrar = loadRegistrar("NewRegistrar");
|
||||||
assertThat(registrar.getClientCertificate()).isNull();
|
assertThat(registrar.getClientCertificate()).isNull();
|
||||||
assertThat(registrar.getClientCertificateHash()).isNull();
|
assertThat(registrar.getClientCertificateHash()).isNull();
|
||||||
|
@ -244,7 +244,7 @@ public class UpdateRegistrarCommandTest extends CommandTestCase<UpdateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_certHash() throws Exception {
|
void testSuccess_certHash() throws Exception {
|
||||||
assertThat(loadRegistrar("NewRegistrar").getClientCertificateHash()).isNull();
|
assertThat(loadRegistrar("NewRegistrar").getClientCertificateHash()).isNull();
|
||||||
runCommand("--cert_hash=" + SAMPLE_CERT_HASH, "--force", "NewRegistrar");
|
runCommand("--cert_hash=" + SAMPLE_CERT_HASH, "--force", "NewRegistrar");
|
||||||
assertThat(loadRegistrar("NewRegistrar").getClientCertificateHash())
|
assertThat(loadRegistrar("NewRegistrar").getClientCertificateHash())
|
||||||
|
@ -252,7 +252,7 @@ public class UpdateRegistrarCommandTest extends CommandTestCase<UpdateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_clearCert() throws Exception {
|
void testSuccess_clearCert() throws Exception {
|
||||||
persistResource(
|
persistResource(
|
||||||
loadRegistrar("NewRegistrar")
|
loadRegistrar("NewRegistrar")
|
||||||
.asBuilder()
|
.asBuilder()
|
||||||
|
@ -264,7 +264,7 @@ public class UpdateRegistrarCommandTest extends CommandTestCase<UpdateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_clearCertHash() throws Exception {
|
void testSuccess_clearCertHash() throws Exception {
|
||||||
persistResource(
|
persistResource(
|
||||||
loadRegistrar("NewRegistrar")
|
loadRegistrar("NewRegistrar")
|
||||||
.asBuilder()
|
.asBuilder()
|
||||||
|
@ -276,28 +276,28 @@ public class UpdateRegistrarCommandTest extends CommandTestCase<UpdateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_ianaId() throws Exception {
|
void testSuccess_ianaId() throws Exception {
|
||||||
assertThat(loadRegistrar("NewRegistrar").getIanaIdentifier()).isEqualTo(8);
|
assertThat(loadRegistrar("NewRegistrar").getIanaIdentifier()).isEqualTo(8);
|
||||||
runCommand("--iana_id=12345", "--force", "NewRegistrar");
|
runCommand("--iana_id=12345", "--force", "NewRegistrar");
|
||||||
assertThat(loadRegistrar("NewRegistrar").getIanaIdentifier()).isEqualTo(12345);
|
assertThat(loadRegistrar("NewRegistrar").getIanaIdentifier()).isEqualTo(12345);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_billingId() throws Exception {
|
void testSuccess_billingId() throws Exception {
|
||||||
assertThat(loadRegistrar("NewRegistrar").getBillingIdentifier()).isNull();
|
assertThat(loadRegistrar("NewRegistrar").getBillingIdentifier()).isNull();
|
||||||
runCommand("--billing_id=12345", "--force", "NewRegistrar");
|
runCommand("--billing_id=12345", "--force", "NewRegistrar");
|
||||||
assertThat(loadRegistrar("NewRegistrar").getBillingIdentifier()).isEqualTo(12345);
|
assertThat(loadRegistrar("NewRegistrar").getBillingIdentifier()).isEqualTo(12345);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_poNumber() throws Exception {
|
void testSuccess_poNumber() throws Exception {
|
||||||
assertThat(loadRegistrar("NewRegistrar").getPoNumber()).isEmpty();
|
assertThat(loadRegistrar("NewRegistrar").getPoNumber()).isEmpty();
|
||||||
runCommand("--po_number=52345", "--force", "NewRegistrar");
|
runCommand("--po_number=52345", "--force", "NewRegistrar");
|
||||||
assertThat(loadRegistrar("NewRegistrar").getPoNumber()).hasValue("52345");
|
assertThat(loadRegistrar("NewRegistrar").getPoNumber()).hasValue("52345");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_billingAccountMap() throws Exception {
|
void testSuccess_billingAccountMap() throws Exception {
|
||||||
assertThat(loadRegistrar("NewRegistrar").getBillingAccountMap()).isEmpty();
|
assertThat(loadRegistrar("NewRegistrar").getBillingAccountMap()).isEmpty();
|
||||||
runCommand("--billing_account_map=USD=abc123,JPY=789xyz", "--force", "NewRegistrar");
|
runCommand("--billing_account_map=USD=abc123,JPY=789xyz", "--force", "NewRegistrar");
|
||||||
assertThat(loadRegistrar("NewRegistrar").getBillingAccountMap())
|
assertThat(loadRegistrar("NewRegistrar").getBillingAccountMap())
|
||||||
|
@ -305,7 +305,7 @@ public class UpdateRegistrarCommandTest extends CommandTestCase<UpdateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_billingAccountMap_doesNotContainEntryForTldAllowed() {
|
void testFailure_billingAccountMap_doesNotContainEntryForTldAllowed() {
|
||||||
createTlds("foo");
|
createTlds("foo");
|
||||||
assertThat(loadRegistrar("NewRegistrar").getBillingAccountMap()).isEmpty();
|
assertThat(loadRegistrar("NewRegistrar").getBillingAccountMap()).isEmpty();
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
|
@ -322,7 +322,7 @@ public class UpdateRegistrarCommandTest extends CommandTestCase<UpdateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_billingAccountMap_onlyAppliesToRealRegistrar() throws Exception {
|
void testSuccess_billingAccountMap_onlyAppliesToRealRegistrar() throws Exception {
|
||||||
createTlds("foo");
|
createTlds("foo");
|
||||||
assertThat(loadRegistrar("NewRegistrar").getBillingAccountMap()).isEmpty();
|
assertThat(loadRegistrar("NewRegistrar").getBillingAccountMap()).isEmpty();
|
||||||
runCommand("--billing_account_map=JPY=789xyz", "--allowed_tlds=foo", "--force", "NewRegistrar");
|
runCommand("--billing_account_map=JPY=789xyz", "--allowed_tlds=foo", "--force", "NewRegistrar");
|
||||||
|
@ -331,7 +331,7 @@ public class UpdateRegistrarCommandTest extends CommandTestCase<UpdateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_billingAccountMap_partialUpdate() throws Exception {
|
void testSuccess_billingAccountMap_partialUpdate() throws Exception {
|
||||||
createTlds("foo");
|
createTlds("foo");
|
||||||
persistResource(
|
persistResource(
|
||||||
loadRegistrar("NewRegistrar")
|
loadRegistrar("NewRegistrar")
|
||||||
|
@ -345,7 +345,7 @@ public class UpdateRegistrarCommandTest extends CommandTestCase<UpdateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_streetAddress() throws Exception {
|
void testSuccess_streetAddress() throws Exception {
|
||||||
runCommand(
|
runCommand(
|
||||||
"--street=\"1234 Main St\"",
|
"--street=\"1234 Main St\"",
|
||||||
"--street \"4th Floor\"",
|
"--street \"4th Floor\"",
|
||||||
|
@ -370,35 +370,35 @@ public class UpdateRegistrarCommandTest extends CommandTestCase<UpdateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_blockPremiumNames() throws Exception {
|
void testSuccess_blockPremiumNames() throws Exception {
|
||||||
assertThat(loadRegistrar("NewRegistrar").getBlockPremiumNames()).isFalse();
|
assertThat(loadRegistrar("NewRegistrar").getBlockPremiumNames()).isFalse();
|
||||||
runCommandForced("--block_premium=true", "NewRegistrar");
|
runCommandForced("--block_premium=true", "NewRegistrar");
|
||||||
assertThat(loadRegistrar("NewRegistrar").getBlockPremiumNames()).isTrue();
|
assertThat(loadRegistrar("NewRegistrar").getBlockPremiumNames()).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_resetBlockPremiumNames() throws Exception {
|
void testSuccess_resetBlockPremiumNames() throws Exception {
|
||||||
persistResource(loadRegistrar("NewRegistrar").asBuilder().setBlockPremiumNames(true).build());
|
persistResource(loadRegistrar("NewRegistrar").asBuilder().setBlockPremiumNames(true).build());
|
||||||
runCommandForced("--block_premium=false", "NewRegistrar");
|
runCommandForced("--block_premium=false", "NewRegistrar");
|
||||||
assertThat(loadRegistrar("NewRegistrar").getBlockPremiumNames()).isFalse();
|
assertThat(loadRegistrar("NewRegistrar").getBlockPremiumNames()).isFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_allowRegistryLock() throws Exception {
|
void testSuccess_allowRegistryLock() throws Exception {
|
||||||
assertThat(loadRegistrar("NewRegistrar").isRegistryLockAllowed()).isFalse();
|
assertThat(loadRegistrar("NewRegistrar").isRegistryLockAllowed()).isFalse();
|
||||||
runCommandForced("--registry_lock_allowed=true", "NewRegistrar");
|
runCommandForced("--registry_lock_allowed=true", "NewRegistrar");
|
||||||
assertThat(loadRegistrar("NewRegistrar").isRegistryLockAllowed()).isTrue();
|
assertThat(loadRegistrar("NewRegistrar").isRegistryLockAllowed()).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_disallowRegistryLock() throws Exception {
|
void testSuccess_disallowRegistryLock() throws Exception {
|
||||||
persistResource(loadRegistrar("NewRegistrar").asBuilder().setRegistryLockAllowed(true).build());
|
persistResource(loadRegistrar("NewRegistrar").asBuilder().setRegistryLockAllowed(true).build());
|
||||||
runCommandForced("--registry_lock_allowed=false", "NewRegistrar");
|
runCommandForced("--registry_lock_allowed=false", "NewRegistrar");
|
||||||
assertThat(loadRegistrar("NewRegistrar").isRegistryLockAllowed()).isFalse();
|
assertThat(loadRegistrar("NewRegistrar").isRegistryLockAllowed()).isFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_unspecifiedBooleansArentChanged() throws Exception {
|
void testSuccess_unspecifiedBooleansArentChanged() throws Exception {
|
||||||
persistResource(
|
persistResource(
|
||||||
loadRegistrar("NewRegistrar")
|
loadRegistrar("NewRegistrar")
|
||||||
.asBuilder()
|
.asBuilder()
|
||||||
|
@ -414,7 +414,7 @@ public class UpdateRegistrarCommandTest extends CommandTestCase<UpdateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_updateMultiple() throws Exception {
|
void testSuccess_updateMultiple() throws Exception {
|
||||||
assertThat(loadRegistrar("TheRegistrar").getState()).isEqualTo(State.ACTIVE);
|
assertThat(loadRegistrar("TheRegistrar").getState()).isEqualTo(State.ACTIVE);
|
||||||
assertThat(loadRegistrar("NewRegistrar").getState()).isEqualTo(State.ACTIVE);
|
assertThat(loadRegistrar("NewRegistrar").getState()).isEqualTo(State.ACTIVE);
|
||||||
runCommandForced("--registrar_state=SUSPENDED", "TheRegistrar", "NewRegistrar");
|
runCommandForced("--registrar_state=SUSPENDED", "TheRegistrar", "NewRegistrar");
|
||||||
|
@ -423,7 +423,7 @@ public class UpdateRegistrarCommandTest extends CommandTestCase<UpdateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_resetOptionalParamsNullString() throws Exception {
|
void testSuccess_resetOptionalParamsNullString() throws Exception {
|
||||||
Registrar registrar = loadRegistrar("NewRegistrar");
|
Registrar registrar = loadRegistrar("NewRegistrar");
|
||||||
registrar =
|
registrar =
|
||||||
persistResource(
|
persistResource(
|
||||||
|
@ -466,7 +466,7 @@ public class UpdateRegistrarCommandTest extends CommandTestCase<UpdateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_resetOptionalParamsEmptyString() throws Exception {
|
void testSuccess_resetOptionalParamsEmptyString() throws Exception {
|
||||||
Registrar registrar = loadRegistrar("NewRegistrar");
|
Registrar registrar = loadRegistrar("NewRegistrar");
|
||||||
registrar =
|
registrar =
|
||||||
persistResource(
|
persistResource(
|
||||||
|
@ -509,7 +509,7 @@ public class UpdateRegistrarCommandTest extends CommandTestCase<UpdateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_setIcannEmail() throws Exception {
|
void testSuccess_setIcannEmail() throws Exception {
|
||||||
runCommand("--icann_referral_email=foo@bar.test", "--force", "TheRegistrar");
|
runCommand("--icann_referral_email=foo@bar.test", "--force", "TheRegistrar");
|
||||||
Registrar registrar = loadRegistrar("TheRegistrar");
|
Registrar registrar = loadRegistrar("TheRegistrar");
|
||||||
assertThat(registrar.getIcannReferralEmail()).isEqualTo("foo@bar.test");
|
assertThat(registrar.getIcannReferralEmail()).isEqualTo("foo@bar.test");
|
||||||
|
@ -517,20 +517,20 @@ public class UpdateRegistrarCommandTest extends CommandTestCase<UpdateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_setEmail() throws Exception {
|
void testSuccess_setEmail() throws Exception {
|
||||||
runCommand("--email=foo@bar.baz", "--force", "TheRegistrar");
|
runCommand("--email=foo@bar.baz", "--force", "TheRegistrar");
|
||||||
Registrar registrar = loadRegistrar("TheRegistrar");
|
Registrar registrar = loadRegistrar("TheRegistrar");
|
||||||
assertThat(registrar.getEmailAddress()).isEqualTo("foo@bar.baz");
|
assertThat(registrar.getEmailAddress()).isEqualTo("foo@bar.baz");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_setWhoisServer_works() throws Exception {
|
void testSuccess_setWhoisServer_works() throws Exception {
|
||||||
runCommand("--whois=whois.goth.black", "--force", "NewRegistrar");
|
runCommand("--whois=whois.goth.black", "--force", "NewRegistrar");
|
||||||
assertThat(loadRegistrar("NewRegistrar").getWhoisServer()).isEqualTo("whois.goth.black");
|
assertThat(loadRegistrar("NewRegistrar").getWhoisServer()).isEqualTo("whois.goth.black");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_triggerGroupSyncing_works() throws Exception {
|
void testSuccess_triggerGroupSyncing_works() throws Exception {
|
||||||
persistResource(
|
persistResource(
|
||||||
loadRegistrar("NewRegistrar").asBuilder().setContactsRequireSyncing(false).build());
|
loadRegistrar("NewRegistrar").asBuilder().setContactsRequireSyncing(false).build());
|
||||||
assertThat(loadRegistrar("NewRegistrar").getContactsRequireSyncing()).isFalse();
|
assertThat(loadRegistrar("NewRegistrar").getContactsRequireSyncing()).isFalse();
|
||||||
|
@ -539,83 +539,83 @@ public class UpdateRegistrarCommandTest extends CommandTestCase<UpdateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_invalidRegistrarType() {
|
void testFailure_invalidRegistrarType() {
|
||||||
assertThrows(
|
assertThrows(
|
||||||
ParameterException.class,
|
ParameterException.class,
|
||||||
() -> runCommand("--registrar_type=INVALID_TYPE", "--force", "NewRegistrar"));
|
() -> runCommand("--registrar_type=INVALID_TYPE", "--force", "NewRegistrar"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_invalidRegistrarState() {
|
void testFailure_invalidRegistrarState() {
|
||||||
assertThrows(
|
assertThrows(
|
||||||
ParameterException.class,
|
ParameterException.class,
|
||||||
() -> runCommand("--registrar_state=INVALID_STATE", "--force", "NewRegistrar"));
|
() -> runCommand("--registrar_state=INVALID_STATE", "--force", "NewRegistrar"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_negativeIanaId() {
|
void testFailure_negativeIanaId() {
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
() -> runCommand("--iana_id=-1", "--force", "NewRegistrar"));
|
() -> runCommand("--iana_id=-1", "--force", "NewRegistrar"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_nonIntegerIanaId() {
|
void testFailure_nonIntegerIanaId() {
|
||||||
assertThrows(
|
assertThrows(
|
||||||
ParameterException.class, () -> runCommand("--iana_id=ABC123", "--force", "NewRegistrar"));
|
ParameterException.class, () -> runCommand("--iana_id=ABC123", "--force", "NewRegistrar"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_negativeBillingId() {
|
void testFailure_negativeBillingId() {
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
() -> runCommand("--billing_id=-1", "--force", "NewRegistrar"));
|
() -> runCommand("--billing_id=-1", "--force", "NewRegistrar"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_nonIntegerBillingId() {
|
void testFailure_nonIntegerBillingId() {
|
||||||
assertThrows(
|
assertThrows(
|
||||||
ParameterException.class,
|
ParameterException.class,
|
||||||
() -> runCommand("--billing_id=ABC123", "--force", "NewRegistrar"));
|
() -> runCommand("--billing_id=ABC123", "--force", "NewRegistrar"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_passcodeTooShort() {
|
void testFailure_passcodeTooShort() {
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
() -> runCommand("--passcode=0123", "--force", "NewRegistrar"));
|
() -> runCommand("--passcode=0123", "--force", "NewRegistrar"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_passcodeTooLong() {
|
void testFailure_passcodeTooLong() {
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
() -> runCommand("--passcode=012345", "--force", "NewRegistrar"));
|
() -> runCommand("--passcode=012345", "--force", "NewRegistrar"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_invalidPasscode() {
|
void testFailure_invalidPasscode() {
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
() -> runCommand("--passcode=code1", "--force", "NewRegistrar"));
|
() -> runCommand("--passcode=code1", "--force", "NewRegistrar"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_allowedTldDoesNotExist() {
|
void testFailure_allowedTldDoesNotExist() {
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
() -> runCommand("--allowed_tlds=foobar", "--force", "NewRegistrar"));
|
() -> runCommand("--allowed_tlds=foobar", "--force", "NewRegistrar"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_addAllowedTldDoesNotExist() {
|
void testFailure_addAllowedTldDoesNotExist() {
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
() -> runCommand("--add_allowed_tlds=foobar", "--force", "NewRegistrar"));
|
() -> runCommand("--add_allowed_tlds=foobar", "--force", "NewRegistrar"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_allowedTldsAndAddAllowedTlds() {
|
void testFailure_allowedTldsAndAddAllowedTlds() {
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
() ->
|
() ->
|
||||||
|
@ -623,7 +623,7 @@ public class UpdateRegistrarCommandTest extends CommandTestCase<UpdateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_setAllowedTldsWithoutAbuseContact() {
|
void testFailure_setAllowedTldsWithoutAbuseContact() {
|
||||||
createTlds("bar");
|
createTlds("bar");
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
|
@ -638,7 +638,7 @@ public class UpdateRegistrarCommandTest extends CommandTestCase<UpdateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_addAllowedTldsWithoutAbuseContact() {
|
void testFailure_addAllowedTldsWithoutAbuseContact() {
|
||||||
createTlds("bar");
|
createTlds("bar");
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
|
@ -653,21 +653,21 @@ public class UpdateRegistrarCommandTest extends CommandTestCase<UpdateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_invalidIpAllowList() {
|
void testFailure_invalidIpAllowList() {
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
() -> runCommand("--ip_allow_list=foobarbaz", "--force", "NewRegistrar"));
|
() -> runCommand("--ip_allow_list=foobarbaz", "--force", "NewRegistrar"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_invalidCertFileContents() {
|
void testFailure_invalidCertFileContents() {
|
||||||
assertThrows(
|
assertThrows(
|
||||||
Exception.class,
|
Exception.class,
|
||||||
() -> runCommand("--cert_file=" + writeToTmpFile("ABCDEF"), "--force", "NewRegistrar"));
|
() -> runCommand("--cert_file=" + writeToTmpFile("ABCDEF"), "--force", "NewRegistrar"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_certHashAndCertFile() {
|
void testFailure_certHashAndCertFile() {
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
() ->
|
() ->
|
||||||
|
@ -679,12 +679,12 @@ public class UpdateRegistrarCommandTest extends CommandTestCase<UpdateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_missingClientId() {
|
void testFailure_missingClientId() {
|
||||||
assertThrows(ParameterException.class, () -> runCommand("--force"));
|
assertThrows(ParameterException.class, () -> runCommand("--force"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_missingStreetLines() {
|
void testFailure_missingStreetLines() {
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
() ->
|
() ->
|
||||||
|
@ -698,7 +698,7 @@ public class UpdateRegistrarCommandTest extends CommandTestCase<UpdateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_missingCity() {
|
void testFailure_missingCity() {
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
() ->
|
() ->
|
||||||
|
@ -714,7 +714,7 @@ public class UpdateRegistrarCommandTest extends CommandTestCase<UpdateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_missingState() {
|
void testFailure_missingState() {
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
() ->
|
() ->
|
||||||
|
@ -730,7 +730,7 @@ public class UpdateRegistrarCommandTest extends CommandTestCase<UpdateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_missingZip() {
|
void testFailure_missingZip() {
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
() ->
|
() ->
|
||||||
|
@ -746,7 +746,7 @@ public class UpdateRegistrarCommandTest extends CommandTestCase<UpdateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_missingCc() {
|
void testFailure_missingCc() {
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
() ->
|
() ->
|
||||||
|
@ -762,7 +762,7 @@ public class UpdateRegistrarCommandTest extends CommandTestCase<UpdateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_missingInvalidCc() {
|
void testFailure_missingInvalidCc() {
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
() ->
|
() ->
|
||||||
|
@ -779,7 +779,7 @@ public class UpdateRegistrarCommandTest extends CommandTestCase<UpdateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_tooManyStreetLines() {
|
void testFailure_tooManyStreetLines() {
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
() ->
|
() ->
|
||||||
|
@ -797,7 +797,7 @@ public class UpdateRegistrarCommandTest extends CommandTestCase<UpdateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_tooFewStreetLines() {
|
void testFailure_tooFewStreetLines() {
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
() ->
|
() ->
|
||||||
|
@ -812,21 +812,21 @@ public class UpdateRegistrarCommandTest extends CommandTestCase<UpdateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_unknownFlag() {
|
void testFailure_unknownFlag() {
|
||||||
assertThrows(
|
assertThrows(
|
||||||
ParameterException.class,
|
ParameterException.class,
|
||||||
() -> runCommand("--force", "--unrecognized_flag=foo", "NewRegistrar"));
|
() -> runCommand("--force", "--unrecognized_flag=foo", "NewRegistrar"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_doesNotExist() {
|
void testFailure_doesNotExist() {
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(IllegalArgumentException.class, () -> runCommand("--force", "ClientZ"));
|
assertThrows(IllegalArgumentException.class, () -> runCommand("--force", "ClientZ"));
|
||||||
assertThat(thrown).hasMessageThat().contains("Registrar ClientZ not found");
|
assertThat(thrown).hasMessageThat().contains("Registrar ClientZ not found");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_registrarNameSimilarToExisting() {
|
void testFailure_registrarNameSimilarToExisting() {
|
||||||
// Note that "tHeRe GiStRaR" normalizes identically to "The Registrar", which is created by
|
// Note that "tHeRe GiStRaR" normalizes identically to "The Registrar", which is created by
|
||||||
// AppEngineRule.
|
// AppEngineRule.
|
||||||
assertThrows(
|
assertThrows(
|
||||||
|
@ -835,7 +835,7 @@ public class UpdateRegistrarCommandTest extends CommandTestCase<UpdateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_poNumberNotSpecified_doesntWipeOutExisting() throws Exception {
|
void testSuccess_poNumberNotSpecified_doesntWipeOutExisting() throws Exception {
|
||||||
Registrar registrar =
|
Registrar registrar =
|
||||||
persistResource(
|
persistResource(
|
||||||
loadRegistrar("NewRegistrar").asBuilder().setPoNumber(Optional.of("1664")).build());
|
loadRegistrar("NewRegistrar").asBuilder().setPoNumber(Optional.of("1664")).build());
|
||||||
|
@ -847,7 +847,7 @@ public class UpdateRegistrarCommandTest extends CommandTestCase<UpdateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_poNumber_canBeBlanked() throws Exception {
|
void testSuccess_poNumber_canBeBlanked() throws Exception {
|
||||||
persistResource(
|
persistResource(
|
||||||
loadRegistrar("NewRegistrar").asBuilder().setPoNumber(Optional.of("1664")).build());
|
loadRegistrar("NewRegistrar").asBuilder().setPoNumber(Optional.of("1664")).build());
|
||||||
runCommand("--po_number=null", "--force", "NewRegistrar");
|
runCommand("--po_number=null", "--force", "NewRegistrar");
|
||||||
|
@ -855,7 +855,7 @@ public class UpdateRegistrarCommandTest extends CommandTestCase<UpdateRegistrarC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_badEmail() {
|
void testFailure_badEmail() {
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
|
|
|
@ -26,15 +26,15 @@ import com.google.common.collect.ImmutableMap;
|
||||||
import google.registry.model.registry.label.ReservedList;
|
import google.registry.model.registry.label.ReservedList;
|
||||||
import google.registry.model.registry.label.ReservedList.ReservedListEntry;
|
import google.registry.model.registry.label.ReservedList.ReservedListEntry;
|
||||||
import google.registry.model.registry.label.ReservedListSqlDao;
|
import google.registry.model.registry.label.ReservedListSqlDao;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
/** Unit tests for {@link UpdateReservedListCommand}. */
|
/** Unit tests for {@link UpdateReservedListCommand}. */
|
||||||
public class UpdateReservedListCommandTest extends
|
class UpdateReservedListCommandTest
|
||||||
CreateOrUpdateReservedListCommandTestCase<UpdateReservedListCommand> {
|
extends CreateOrUpdateReservedListCommandTestCase<UpdateReservedListCommand> {
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setup() {
|
void beforeEach() {
|
||||||
populateInitialReservedListInDatastore(true);
|
populateInitialReservedListInDatastore(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,17 +60,17 @@ public class UpdateReservedListCommandTest extends
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess() throws Exception {
|
void testSuccess() throws Exception {
|
||||||
runSuccessfulUpdateTest("--name=xn--q9jyb4c_common-reserved", "--input=" + reservedTermsPath);
|
runSuccessfulUpdateTest("--name=xn--q9jyb4c_common-reserved", "--input=" + reservedTermsPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_unspecifiedNameDefaultsToFileName() throws Exception {
|
void testSuccess_unspecifiedNameDefaultsToFileName() throws Exception {
|
||||||
runSuccessfulUpdateTest("--input=" + reservedTermsPath);
|
runSuccessfulUpdateTest("--input=" + reservedTermsPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_lastUpdateTime_updatedCorrectly() throws Exception {
|
void testSuccess_lastUpdateTime_updatedCorrectly() throws Exception {
|
||||||
ReservedList original = ReservedList.get("xn--q9jyb4c_common-reserved").get();
|
ReservedList original = ReservedList.get("xn--q9jyb4c_common-reserved").get();
|
||||||
runCommandForced("--input=" + reservedTermsPath);
|
runCommandForced("--input=" + reservedTermsPath);
|
||||||
ReservedList updated = ReservedList.get("xn--q9jyb4c_common-reserved").get();
|
ReservedList updated = ReservedList.get("xn--q9jyb4c_common-reserved").get();
|
||||||
|
@ -80,7 +80,7 @@ public class UpdateReservedListCommandTest extends
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_shouldPublish_setToFalseCorrectly() throws Exception {
|
void testSuccess_shouldPublish_setToFalseCorrectly() throws Exception {
|
||||||
runSuccessfulUpdateTest("--input=" + reservedTermsPath, "--should_publish=false");
|
runSuccessfulUpdateTest("--input=" + reservedTermsPath, "--should_publish=false");
|
||||||
assertThat(ReservedList.get("xn--q9jyb4c_common-reserved")).isPresent();
|
assertThat(ReservedList.get("xn--q9jyb4c_common-reserved")).isPresent();
|
||||||
ReservedList reservedList = ReservedList.get("xn--q9jyb4c_common-reserved").get();
|
ReservedList reservedList = ReservedList.get("xn--q9jyb4c_common-reserved").get();
|
||||||
|
@ -88,7 +88,7 @@ public class UpdateReservedListCommandTest extends
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_shouldPublish_doesntOverrideFalseIfNotSpecified() throws Exception {
|
void testSuccess_shouldPublish_doesntOverrideFalseIfNotSpecified() throws Exception {
|
||||||
populateInitialReservedListInDatastore(false);
|
populateInitialReservedListInDatastore(false);
|
||||||
runCommandForced("--input=" + reservedTermsPath);
|
runCommandForced("--input=" + reservedTermsPath);
|
||||||
assertThat(ReservedList.get("xn--q9jyb4c_common-reserved")).isPresent();
|
assertThat(ReservedList.get("xn--q9jyb4c_common-reserved")).isPresent();
|
||||||
|
@ -107,7 +107,7 @@ public class UpdateReservedListCommandTest extends
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_reservedListDoesntExist() {
|
void testFailure_reservedListDoesntExist() {
|
||||||
String errorMessage =
|
String errorMessage =
|
||||||
"Could not update reserved list xn--q9jyb4c_poobah because it doesn't exist.";
|
"Could not update reserved list xn--q9jyb4c_poobah because it doesn't exist.";
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
|
@ -119,7 +119,7 @@ public class UpdateReservedListCommandTest extends
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSaveToCloudSql_succeeds() throws Exception {
|
void testSaveToCloudSql_succeeds() throws Exception {
|
||||||
populateInitialReservedListInCloudSql(true);
|
populateInitialReservedListInCloudSql(true);
|
||||||
runCommandForced("--name=xn--q9jyb4c_common-reserved", "--input=" + reservedTermsPath);
|
runCommandForced("--name=xn--q9jyb4c_common-reserved", "--input=" + reservedTermsPath);
|
||||||
verifyXnq9jyb4cInDatastore();
|
verifyXnq9jyb4cInDatastore();
|
||||||
|
@ -127,7 +127,7 @@ public class UpdateReservedListCommandTest extends
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSaveToCloudSql_succeedsEvenPreviousListNotExist() throws Exception {
|
void testSaveToCloudSql_succeedsEvenPreviousListNotExist() throws Exception {
|
||||||
// Note that, during the dual-write phase, we always save the reserved list to Cloud SQL without
|
// Note that, during the dual-write phase, we always save the reserved list to Cloud SQL without
|
||||||
// checking if there is a list with same name. This is to backfill the existing list in Cloud
|
// checking if there is a list with same name. This is to backfill the existing list in Cloud
|
||||||
// Datastore when we update it.
|
// Datastore when we update it.
|
||||||
|
|
|
@ -17,48 +17,48 @@ package google.registry.tools;
|
||||||
import static org.junit.Assert.assertThrows;
|
import static org.junit.Assert.assertThrows;
|
||||||
|
|
||||||
import com.beust.jcommander.ParameterException;
|
import com.beust.jcommander.ParameterException;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
/** Unit tests for {@link UpdateServerLocksCommand}. */
|
/** Unit tests for {@link UpdateServerLocksCommand}. */
|
||||||
public class UpdateServerLocksCommandTest extends EppToolCommandTestCase<UpdateServerLocksCommand> {
|
class UpdateServerLocksCommandTest extends EppToolCommandTestCase<UpdateServerLocksCommand> {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_applyOne() throws Exception {
|
void testSuccess_applyOne() throws Exception {
|
||||||
runCommandForced("--client=NewRegistrar", "--registrar_request=true", "--reason=Test",
|
runCommandForced("--client=NewRegistrar", "--registrar_request=true", "--reason=Test",
|
||||||
"--domain_name=example.tld", "--apply=serverRenewProhibited");
|
"--domain_name=example.tld", "--apply=serverRenewProhibited");
|
||||||
eppVerifier.verifySent("update_server_locks_apply_one.xml");
|
eppVerifier.verifySent("update_server_locks_apply_one.xml");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_multipleWordReason() throws Exception {
|
void testSuccess_multipleWordReason() throws Exception {
|
||||||
runCommandForced("--client=NewRegistrar", "--registrar_request=false",
|
runCommandForced("--client=NewRegistrar", "--registrar_request=false",
|
||||||
"--reason=\"Test this\"", "--domain_name=example.tld", "--apply=serverRenewProhibited");
|
"--reason=\"Test this\"", "--domain_name=example.tld", "--apply=serverRenewProhibited");
|
||||||
eppVerifier.verifySent("update_server_locks_multiple_word_reason.xml");
|
eppVerifier.verifySent("update_server_locks_multiple_word_reason.xml");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_removeOne() throws Exception {
|
void testSuccess_removeOne() throws Exception {
|
||||||
runCommandForced("--client=NewRegistrar", "--registrar_request=true", "--reason=Test",
|
runCommandForced("--client=NewRegistrar", "--registrar_request=true", "--reason=Test",
|
||||||
"--domain_name=example.tld", "--remove=serverRenewProhibited");
|
"--domain_name=example.tld", "--remove=serverRenewProhibited");
|
||||||
eppVerifier.verifySent("update_server_locks_remove_one.xml");
|
eppVerifier.verifySent("update_server_locks_remove_one.xml");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_applyAll() throws Exception {
|
void testSuccess_applyAll() throws Exception {
|
||||||
runCommandForced("--client=NewRegistrar", "--registrar_request=true", "--reason=Test",
|
runCommandForced("--client=NewRegistrar", "--registrar_request=true", "--reason=Test",
|
||||||
"--domain_name=example.tld", "--apply=all");
|
"--domain_name=example.tld", "--apply=all");
|
||||||
eppVerifier.verifySent("update_server_locks_apply_all.xml");
|
eppVerifier.verifySent("update_server_locks_apply_all.xml");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_removeAll() throws Exception {
|
void testSuccess_removeAll() throws Exception {
|
||||||
runCommandForced("--client=NewRegistrar", "--registrar_request=true", "--reason=Test",
|
runCommandForced("--client=NewRegistrar", "--registrar_request=true", "--reason=Test",
|
||||||
"--domain_name=example.tld", "--remove=all");
|
"--domain_name=example.tld", "--remove=all");
|
||||||
eppVerifier.verifySent("update_server_locks_remove_all.xml");
|
eppVerifier.verifySent("update_server_locks_remove_all.xml");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_applyAllRemoveOne_failsDueToOverlap() {
|
void testFailure_applyAllRemoveOne_failsDueToOverlap() {
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
() ->
|
() ->
|
||||||
|
@ -72,7 +72,7 @@ public class UpdateServerLocksCommandTest extends EppToolCommandTestCase<UpdateS
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_illegalStatus() {
|
void testFailure_illegalStatus() {
|
||||||
// The EPP status is a valid one by RFC, but invalid for this command.
|
// The EPP status is a valid one by RFC, but invalid for this command.
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
|
@ -86,7 +86,7 @@ public class UpdateServerLocksCommandTest extends EppToolCommandTestCase<UpdateS
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_unrecognizedStatus() {
|
void testFailure_unrecognizedStatus() {
|
||||||
// Handles a status passed to the command that doesn't correspond to any
|
// Handles a status passed to the command that doesn't correspond to any
|
||||||
// EPP-valid status.
|
// EPP-valid status.
|
||||||
assertThrows(
|
assertThrows(
|
||||||
|
@ -101,7 +101,7 @@ public class UpdateServerLocksCommandTest extends EppToolCommandTestCase<UpdateS
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_mainParameter() {
|
void testFailure_mainParameter() {
|
||||||
assertThrows(
|
assertThrows(
|
||||||
ParameterException.class,
|
ParameterException.class,
|
||||||
() ->
|
() ->
|
||||||
|
@ -115,7 +115,7 @@ public class UpdateServerLocksCommandTest extends EppToolCommandTestCase<UpdateS
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_noOp() {
|
void testFailure_noOp() {
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
() ->
|
() ->
|
||||||
|
@ -130,7 +130,7 @@ public class UpdateServerLocksCommandTest extends EppToolCommandTestCase<UpdateS
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_missingClientId() {
|
void testFailure_missingClientId() {
|
||||||
assertThrows(
|
assertThrows(
|
||||||
ParameterException.class,
|
ParameterException.class,
|
||||||
() ->
|
() ->
|
||||||
|
@ -142,7 +142,7 @@ public class UpdateServerLocksCommandTest extends EppToolCommandTestCase<UpdateS
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_unknownFlag() {
|
void testFailure_unknownFlag() {
|
||||||
assertThrows(
|
assertThrows(
|
||||||
ParameterException.class,
|
ParameterException.class,
|
||||||
() ->
|
() ->
|
||||||
|
@ -156,7 +156,7 @@ public class UpdateServerLocksCommandTest extends EppToolCommandTestCase<UpdateS
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_noReasonWhenNotRegistrarRequested() {
|
void testFailure_noReasonWhenNotRegistrarRequested() {
|
||||||
assertThrows(
|
assertThrows(
|
||||||
IllegalArgumentException.class,
|
IllegalArgumentException.class,
|
||||||
() ->
|
() ->
|
||||||
|
@ -168,7 +168,7 @@ public class UpdateServerLocksCommandTest extends EppToolCommandTestCase<UpdateS
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_missingRegistrarRequest() {
|
void testFailure_missingRegistrarRequest() {
|
||||||
assertThrows(
|
assertThrows(
|
||||||
ParameterException.class,
|
ParameterException.class,
|
||||||
() ->
|
() ->
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue