Upgrade flow test classes to JUnit 5 (#666)

Most of the diffs are visibility changes.

Also deletes ShardableTestCase, which was only necessary because of Blaze (and
possible Bazel) limitations.
This commit is contained in:
Ben McIlwain 2020-07-08 14:08:05 -04:00 committed by GitHub
parent 5578464e06
commit a3319e0026
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
67 changed files with 1293 additions and 1401 deletions

View file

@ -70,24 +70,24 @@ public class ContactBase extends EppResource implements ResourceWithTransferData
@IgnoreSave(IfNull.class) @IgnoreSave(IfNull.class)
@Embedded @Embedded
@AttributeOverrides({ @AttributeOverrides({
@AttributeOverride(name = "name", column = @Column(name = "addr_local_name")), @AttributeOverride(name = "name", column = @Column(name = "addr_local_name")),
@AttributeOverride(name = "org", column = @Column(name = "addr_local_org")), @AttributeOverride(name = "org", column = @Column(name = "addr_local_org")),
@AttributeOverride(name = "type", column = @Column(name = "addr_local_type")), @AttributeOverride(name = "type", column = @Column(name = "addr_local_type")),
@AttributeOverride( @AttributeOverride(
name = "address.streetLine1", name = "address.streetLine1",
column = @Column(name = "addr_local_street_line1")), column = @Column(name = "addr_local_street_line1")),
@AttributeOverride( @AttributeOverride(
name = "address.streetLine2", name = "address.streetLine2",
column = @Column(name = "addr_local_street_line2")), column = @Column(name = "addr_local_street_line2")),
@AttributeOverride( @AttributeOverride(
name = "address.streetLine3", name = "address.streetLine3",
column = @Column(name = "addr_local_street_line3")), column = @Column(name = "addr_local_street_line3")),
@AttributeOverride(name = "address.city", column = @Column(name = "addr_local_city")), @AttributeOverride(name = "address.city", column = @Column(name = "addr_local_city")),
@AttributeOverride(name = "address.state", column = @Column(name = "addr_local_state")), @AttributeOverride(name = "address.state", column = @Column(name = "addr_local_state")),
@AttributeOverride(name = "address.zip", column = @Column(name = "addr_local_zip")), @AttributeOverride(name = "address.zip", column = @Column(name = "addr_local_zip")),
@AttributeOverride( @AttributeOverride(
name = "address.countryCode", name = "address.countryCode",
column = @Column(name = "addr_local_country_code")) column = @Column(name = "addr_local_country_code"))
}) })
PostalInfo localizedPostalInfo; PostalInfo localizedPostalInfo;
@ -98,24 +98,24 @@ public class ContactBase extends EppResource implements ResourceWithTransferData
@IgnoreSave(IfNull.class) @IgnoreSave(IfNull.class)
@Embedded @Embedded
@AttributeOverrides({ @AttributeOverrides({
@AttributeOverride(name = "name", column = @Column(name = "addr_i18n_name")), @AttributeOverride(name = "name", column = @Column(name = "addr_i18n_name")),
@AttributeOverride(name = "org", column = @Column(name = "addr_i18n_org")), @AttributeOverride(name = "org", column = @Column(name = "addr_i18n_org")),
@AttributeOverride(name = "type", column = @Column(name = "addr_i18n_type")), @AttributeOverride(name = "type", column = @Column(name = "addr_i18n_type")),
@AttributeOverride( @AttributeOverride(
name = "address.streetLine1", name = "address.streetLine1",
column = @Column(name = "addr_i18n_street_line1")), column = @Column(name = "addr_i18n_street_line1")),
@AttributeOverride( @AttributeOverride(
name = "address.streetLine2", name = "address.streetLine2",
column = @Column(name = "addr_i18n_street_line2")), column = @Column(name = "addr_i18n_street_line2")),
@AttributeOverride( @AttributeOverride(
name = "address.streetLine3", name = "address.streetLine3",
column = @Column(name = "addr_i18n_street_line3")), column = @Column(name = "addr_i18n_street_line3")),
@AttributeOverride(name = "address.city", column = @Column(name = "addr_i18n_city")), @AttributeOverride(name = "address.city", column = @Column(name = "addr_i18n_city")),
@AttributeOverride(name = "address.state", column = @Column(name = "addr_i18n_state")), @AttributeOverride(name = "address.state", column = @Column(name = "addr_i18n_state")),
@AttributeOverride(name = "address.zip", column = @Column(name = "addr_i18n_zip")), @AttributeOverride(name = "address.zip", column = @Column(name = "addr_i18n_zip")),
@AttributeOverride( @AttributeOverride(
name = "address.countryCode", name = "address.countryCode",
column = @Column(name = "addr_i18n_country_code")) column = @Column(name = "addr_i18n_country_code"))
}) })
PostalInfo internationalizedPostalInfo; PostalInfo internationalizedPostalInfo;
@ -130,8 +130,8 @@ public class ContactBase extends EppResource implements ResourceWithTransferData
@IgnoreSave(IfNull.class) @IgnoreSave(IfNull.class)
@Embedded @Embedded
@AttributeOverrides({ @AttributeOverrides({
@AttributeOverride(name = "phoneNumber", column = @Column(name = "voice_phone_number")), @AttributeOverride(name = "phoneNumber", column = @Column(name = "voice_phone_number")),
@AttributeOverride(name = "extension", column = @Column(name = "voice_phone_extension")), @AttributeOverride(name = "extension", column = @Column(name = "voice_phone_extension")),
}) })
ContactPhoneNumber voice; ContactPhoneNumber voice;
@ -139,8 +139,8 @@ public class ContactBase extends EppResource implements ResourceWithTransferData
@IgnoreSave(IfNull.class) @IgnoreSave(IfNull.class)
@Embedded @Embedded
@AttributeOverrides({ @AttributeOverrides({
@AttributeOverride(name = "phoneNumber", column = @Column(name = "fax_phone_number")), @AttributeOverride(name = "phoneNumber", column = @Column(name = "fax_phone_number")),
@AttributeOverride(name = "extension", column = @Column(name = "fax_phone_extension")), @AttributeOverride(name = "extension", column = @Column(name = "fax_phone_extension")),
}) })
ContactPhoneNumber fax; ContactPhoneNumber fax;
@ -151,8 +151,8 @@ public class ContactBase extends EppResource implements ResourceWithTransferData
/** Authorization info (aka transfer secret) of the contact. */ /** Authorization info (aka transfer secret) of the contact. */
@Embedded @Embedded
@AttributeOverrides({ @AttributeOverrides({
@AttributeOverride(name = "pw.value", column = @Column(name = "auth_info_value")), @AttributeOverride(name = "pw.value", column = @Column(name = "auth_info_value")),
@AttributeOverride(name = "pw.repoId", column = @Column(name = "auth_info_repo_id")), @AttributeOverride(name = "pw.repoId", column = @Column(name = "auth_info_repo_id")),
}) })
ContactAuthInfo authInfo; ContactAuthInfo authInfo;
@ -172,13 +172,13 @@ public class ContactBase extends EppResource implements ResourceWithTransferData
/** Disclosure policy. */ /** Disclosure policy. */
@Embedded @Embedded
@AttributeOverrides({ @AttributeOverrides({
@AttributeOverride(name = "name", column = @Column(name = "disclose_types_name")), @AttributeOverride(name = "name", column = @Column(name = "disclose_types_name")),
@AttributeOverride(name = "org", column = @Column(name = "disclose_types_org")), @AttributeOverride(name = "org", column = @Column(name = "disclose_types_org")),
@AttributeOverride(name = "addr", column = @Column(name = "disclose_types_addr")), @AttributeOverride(name = "addr", column = @Column(name = "disclose_types_addr")),
@AttributeOverride(name = "flag", column = @Column(name = "disclose_mode_flag")), @AttributeOverride(name = "flag", column = @Column(name = "disclose_mode_flag")),
@AttributeOverride(name = "voice.marked", column = @Column(name = "disclose_show_voice")), @AttributeOverride(name = "voice.marked", column = @Column(name = "disclose_show_voice")),
@AttributeOverride(name = "fax.marked", column = @Column(name = "disclose_show_fax")), @AttributeOverride(name = "fax.marked", column = @Column(name = "disclose_show_fax")),
@AttributeOverride(name = "email.marked", column = @Column(name = "disclose_show_email")) @AttributeOverride(name = "email.marked", column = @Column(name = "disclose_show_email"))
}) })
Disclose disclose; Disclose disclose;

View file

@ -37,11 +37,11 @@ import org.joda.time.DateTime;
@javax.persistence.Table( @javax.persistence.Table(
name = "Contact", name = "Contact",
indexes = { indexes = {
@javax.persistence.Index(columnList = "creationTime"), @javax.persistence.Index(columnList = "creationTime"),
@javax.persistence.Index(columnList = "currentSponsorRegistrarId"), @javax.persistence.Index(columnList = "currentSponsorRegistrarId"),
@javax.persistence.Index(columnList = "deletionTime"), @javax.persistence.Index(columnList = "deletionTime"),
@javax.persistence.Index(columnList = "contactId", unique = true), @javax.persistence.Index(columnList = "contactId", unique = true),
@javax.persistence.Index(columnList = "searchName") @javax.persistence.Index(columnList = "searchName")
}) })
@ExternalMessagingName("contact") @ExternalMessagingName("contact")
@WithStringVKey @WithStringVKey

View file

@ -43,7 +43,6 @@ import google.registry.testing.AppEngineRule;
import google.registry.testing.FakeClock; import google.registry.testing.FakeClock;
import google.registry.testing.FakeSleeper; import google.registry.testing.FakeSleeper;
import google.registry.testing.InjectRule; import google.registry.testing.InjectRule;
import google.registry.testing.ShardableTestCase;
import google.registry.testing.TaskQueueHelper.TaskMatcher; import google.registry.testing.TaskQueueHelper.TaskMatcher;
import google.registry.util.AppEngineServiceUtils; import google.registry.util.AppEngineServiceUtils;
import google.registry.util.CapturingLogHandler; import google.registry.util.CapturingLogHandler;
@ -62,7 +61,7 @@ import org.mockito.junit.MockitoRule;
/** Unit tests for {@link AsyncTaskEnqueuer}. */ /** Unit tests for {@link AsyncTaskEnqueuer}. */
@RunWith(JUnit4.class) @RunWith(JUnit4.class)
public class AsyncTaskEnqueuerTest extends ShardableTestCase { public class AsyncTaskEnqueuerTest {
@Rule @Rule
public final AppEngineRule appEngine = public final AppEngineRule appEngine =

View file

@ -21,14 +21,13 @@ import static google.registry.batch.AsyncTaskMetrics.OperationType.CONTACT_AND_H
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import google.registry.testing.FakeClock; import google.registry.testing.FakeClock;
import google.registry.testing.ShardableTestCase;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.junit.runners.JUnit4; import org.junit.runners.JUnit4;
/** Unit tests for {@link AsyncTaskMetrics}. */ /** Unit tests for {@link AsyncTaskMetrics}. */
@RunWith(JUnit4.class) @RunWith(JUnit4.class)
public class AsyncTaskMetricsTest extends ShardableTestCase { public class AsyncTaskMetricsTest {
private final FakeClock clock = new FakeClock(); private final FakeClock clock = new FakeClock();
private final AsyncTaskMetrics asyncTaskMetrics = new AsyncTaskMetrics(clock); private final AsyncTaskMetrics asyncTaskMetrics = new AsyncTaskMetrics(clock);

View file

@ -45,7 +45,6 @@ import google.registry.request.Response;
import google.registry.testing.AppEngineRule; import google.registry.testing.AppEngineRule;
import google.registry.testing.FakeClock; import google.registry.testing.FakeClock;
import google.registry.testing.InjectRule; import google.registry.testing.InjectRule;
import google.registry.testing.ShardableTestCase;
import google.registry.testing.TaskQueueHelper.TaskMatcher; import google.registry.testing.TaskQueueHelper.TaskMatcher;
import google.registry.util.AppEngineServiceUtils; import google.registry.util.AppEngineServiceUtils;
import org.joda.time.DateTime; import org.joda.time.DateTime;
@ -61,7 +60,7 @@ import org.mockito.junit.MockitoRule;
/** Unit tests for {@link ResaveEntityAction}. */ /** Unit tests for {@link ResaveEntityAction}. */
@RunWith(JUnit4.class) @RunWith(JUnit4.class)
public class ResaveEntityActionTest extends ShardableTestCase { public class ResaveEntityActionTest {
@Rule @Rule
public final AppEngineRule appEngine = public final AppEngineRule appEngine =

View file

@ -132,8 +132,9 @@ public class BillingEventTest {
public void testConvertBillingEvent_toCsv() { public void testConvertBillingEvent_toCsv() {
BillingEvent event = BillingEvent.parseFromRecord(schemaAndRecord); BillingEvent event = BillingEvent.parseFromRecord(schemaAndRecord);
assertThat(event.toCsv()) assertThat(event.toCsv())
.isEqualTo("1,2017-10-24 09:06:03 UTC,2017-01-19 23:59:43 UTC,myRegistrar," .isEqualTo(
+ "12345-CRRHELLO,,test,RENEW,example.test,123456,5,USD,20.50,AUTO_RENEW"); "1,2017-10-24 09:06:03 UTC,2017-01-19 23:59:43 UTC,myRegistrar,"
+ "12345-CRRHELLO,,test,RENEW,example.test,123456,5,USD,20.50,AUTO_RENEW");
} }
@Test @Test
@ -142,8 +143,9 @@ public class BillingEventTest {
record.put("poNumber", "905610"); record.put("poNumber", "905610");
BillingEvent event = BillingEvent.parseFromRecord(new SchemaAndRecord(record, null)); BillingEvent event = BillingEvent.parseFromRecord(new SchemaAndRecord(record, null));
assertThat(event.toCsv()) assertThat(event.toCsv())
.isEqualTo("1,2017-10-24 09:06:03 UTC,2017-01-19 23:59:43 UTC,myRegistrar," .isEqualTo(
+ "12345-CRRHELLO,905610,test,RENEW,example.test,123456,5,USD,20.50,AUTO_RENEW"); "1,2017-10-24 09:06:03 UTC,2017-01-19 23:59:43 UTC,myRegistrar,"
+ "12345-CRRHELLO,905610,test,RENEW,example.test,123456,5,USD,20.50,AUTO_RENEW");
} }
@Test @Test

View file

@ -35,7 +35,6 @@ import google.registry.testing.EppLoader;
import google.registry.testing.FakeClock; import google.registry.testing.FakeClock;
import google.registry.testing.FakeHttpSession; import google.registry.testing.FakeHttpSession;
import google.registry.testing.InjectRule; import google.registry.testing.InjectRule;
import google.registry.testing.ShardableTestCase;
import org.joda.time.DateTime; import org.joda.time.DateTime;
import org.junit.Before; import org.junit.Before;
import org.junit.Rule; import org.junit.Rule;
@ -45,7 +44,7 @@ import org.junit.runners.JUnit4;
/** Test that domain flows create the commit logs needed to reload at points in the past. */ /** Test that domain flows create the commit logs needed to reload at points in the past. */
@RunWith(JUnit4.class) @RunWith(JUnit4.class)
public class EppCommitLogsTest extends ShardableTestCase { public class EppCommitLogsTest {
@Rule @Rule
public final AppEngineRule appEngine = public final AppEngineRule appEngine =

View file

@ -42,7 +42,6 @@ import google.registry.model.eppoutput.Result.Code;
import google.registry.monitoring.whitebox.EppMetric; import google.registry.monitoring.whitebox.EppMetric;
import google.registry.testing.AppEngineRule; import google.registry.testing.AppEngineRule;
import google.registry.testing.FakeClock; import google.registry.testing.FakeClock;
import google.registry.testing.ShardableTestCase;
import google.registry.util.Clock; import google.registry.util.Clock;
import google.registry.xml.ValidationMode; import google.registry.xml.ValidationMode;
import java.util.List; import java.util.List;
@ -64,7 +63,7 @@ import org.mockito.junit.MockitoRule;
/** Unit tests for {@link EppController}. */ /** Unit tests for {@link EppController}. */
@RunWith(JUnit4.class) @RunWith(JUnit4.class)
public class EppControllerTest extends ShardableTestCase { public class EppControllerTest {
@Rule @Rule
public AppEngineRule appEngineRule = public AppEngineRule appEngineRule =

View file

@ -46,7 +46,6 @@ import google.registry.testing.FakeClock;
import google.registry.testing.FakeHttpSession; import google.registry.testing.FakeHttpSession;
import google.registry.testing.FakeResponse; import google.registry.testing.FakeResponse;
import google.registry.testing.InjectRule; import google.registry.testing.InjectRule;
import google.registry.testing.ShardableTestCase;
import java.util.Map; import java.util.Map;
import java.util.Objects; import java.util.Objects;
import java.util.Optional; import java.util.Optional;
@ -56,7 +55,7 @@ import org.joda.time.DateTime;
import org.junit.Before; import org.junit.Before;
import org.junit.Rule; import org.junit.Rule;
public class EppTestCase extends ShardableTestCase { public class EppTestCase {
private static final MediaType APPLICATION_EPP_XML_UTF8 = private static final MediaType APPLICATION_EPP_XML_UTF8 =
MediaType.create("application", "epp+xml").withCharset(UTF_8); MediaType.create("application", "epp+xml").withCharset(UTF_8);

View file

@ -23,7 +23,6 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
import google.registry.testing.FakeHttpSession; import google.registry.testing.FakeHttpSession;
import google.registry.testing.ShardableTestCase;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.junit.runners.JUnit4; import org.junit.runners.JUnit4;
@ -31,7 +30,7 @@ import org.mockito.ArgumentCaptor;
/** Tests for {@link EppTlsAction}. */ /** Tests for {@link EppTlsAction}. */
@RunWith(JUnit4.class) @RunWith(JUnit4.class)
public class EppTlsActionTest extends ShardableTestCase { public class EppTlsActionTest {
private static final byte[] INPUT_XML_BYTES = "<xml>".getBytes(UTF_8); private static final byte[] INPUT_XML_BYTES = "<xml>".getBytes(UTF_8);

View file

@ -29,7 +29,6 @@ import google.registry.model.eppinput.EppInput;
import google.registry.model.eppoutput.EppOutput.ResponseOrGreeting; import google.registry.model.eppoutput.EppOutput.ResponseOrGreeting;
import google.registry.model.eppoutput.EppResponse; import google.registry.model.eppoutput.EppResponse;
import google.registry.model.reporting.IcannReportingTypes.ActivityReportField; import google.registry.model.reporting.IcannReportingTypes.ActivityReportField;
import google.registry.testing.ShardableTestCase;
import java.util.Map; import java.util.Map;
import java.util.Optional; import java.util.Optional;
import org.json.simple.JSONValue; import org.json.simple.JSONValue;
@ -40,7 +39,7 @@ import org.junit.runners.JUnit4;
/** Unit tests for {@link FlowReporter}. */ /** Unit tests for {@link FlowReporter}. */
@RunWith(JUnit4.class) @RunWith(JUnit4.class)
public class FlowReporterTest extends ShardableTestCase { public class FlowReporterTest {
static class TestCommandFlow implements Flow { static class TestCommandFlow implements Flow {
@Override @Override

View file

@ -36,7 +36,6 @@ import google.registry.monitoring.whitebox.EppMetric;
import google.registry.testing.AppEngineRule; import google.registry.testing.AppEngineRule;
import google.registry.testing.FakeClock; import google.registry.testing.FakeClock;
import google.registry.testing.FakeHttpSession; import google.registry.testing.FakeHttpSession;
import google.registry.testing.ShardableTestCase;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
import org.junit.Before; import org.junit.Before;
@ -48,7 +47,7 @@ import org.mockito.Mockito;
/** Unit tests for {@link FlowRunner}. */ /** Unit tests for {@link FlowRunner}. */
@RunWith(JUnit4.class) @RunWith(JUnit4.class)
public class FlowRunnerTest extends ShardableTestCase { public class FlowRunnerTest {
@Rule @Rule
public final AppEngineRule appEngineRule = new AppEngineRule.Builder().build(); public final AppEngineRule appEngineRule = new AppEngineRule.Builder().build();

View file

@ -52,7 +52,6 @@ import google.registry.testing.EppLoader;
import google.registry.testing.FakeClock; import google.registry.testing.FakeClock;
import google.registry.testing.FakeHttpSession; import google.registry.testing.FakeHttpSession;
import google.registry.testing.InjectRule; import google.registry.testing.InjectRule;
import google.registry.testing.ShardableTestCase;
import google.registry.testing.TestDataHelper; import google.registry.testing.TestDataHelper;
import google.registry.tmch.TmchCertificateAuthority; import google.registry.tmch.TmchCertificateAuthority;
import google.registry.tmch.TmchXmlSignature; import google.registry.tmch.TmchXmlSignature;
@ -63,18 +62,15 @@ import java.util.List;
import java.util.Map; import java.util.Map;
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.Rule; import org.junit.jupiter.api.extension.RegisterExtension;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
/** /**
* Base class for resource flow unit tests. * Base class for resource flow unit tests.
* *
* @param <F> the flow type * @param <F> the flow type
*/ */
@RunWith(JUnit4.class) public abstract class FlowTestCase<F extends Flow> {
public abstract class FlowTestCase<F extends Flow> extends ShardableTestCase {
/** Whether to actually write to Datastore or just simulate. */ /** Whether to actually write to Datastore or just simulate. */
public enum CommitMode { LIVE, DRY_RUN } public enum CommitMode { LIVE, DRY_RUN }
@ -82,23 +78,22 @@ public abstract class FlowTestCase<F extends Flow> extends ShardableTestCase {
/** Whether to run in normal or superuser mode. */ /** Whether to run in normal or superuser mode. */
public enum UserPrivileges { NORMAL, SUPERUSER } public enum UserPrivileges { NORMAL, SUPERUSER }
@Rule @RegisterExtension
public final AppEngineRule appEngine = public final AppEngineRule appEngine =
AppEngineRule.builder().withDatastoreAndCloudSql().withTaskQueue().build(); AppEngineRule.builder().withDatastoreAndCloudSql().withTaskQueue().build();
@Rule @RegisterExtension public final InjectRule inject = new InjectRule();
public final InjectRule inject = new InjectRule();
protected EppLoader eppLoader; protected EppLoader eppLoader;
protected SessionMetadata sessionMetadata; protected SessionMetadata sessionMetadata;
protected FakeClock clock = new FakeClock(DateTime.now(UTC)); protected FakeClock clock = new FakeClock(DateTime.now(UTC));
protected TransportCredentials credentials = new PasswordOnlyTransportCredentials(); protected TransportCredentials credentials = new PasswordOnlyTransportCredentials();
protected EppRequestSource eppRequestSource = EppRequestSource.UNIT_TEST; protected EppRequestSource eppRequestSource = EppRequestSource.UNIT_TEST;
protected TmchXmlSignature testTmchXmlSignature = null; private TmchXmlSignature testTmchXmlSignature = null;
private EppMetric.Builder eppMetricBuilder; private EppMetric.Builder eppMetricBuilder;
@Before @BeforeEach
public void init() { public void init() {
sessionMetadata = new HttpSessionMetadata(new FakeHttpSession()); sessionMetadata = new HttpSessionMetadata(new FakeHttpSession());
sessionMetadata.setClientId("TheRegistrar"); sessionMetadata.setClientId("TheRegistrar");
@ -204,29 +199,26 @@ public abstract class FlowTestCase<F extends Flow> extends ShardableTestCase {
} }
/** /**
* Assert that the actual grace periods and the corresponding billing events referenced from * Assert that the actual grace periods and the corresponding billing events referenced from their
* their keys match the expected map of grace periods to billing events. For the expected map, * keys match the expected map of grace periods to billing events. For the expected map, the keys
* the keys on the grace periods and IDs on the billing events are ignored. * on the grace periods and IDs on the billing events are ignored.
*/ */
public void assertGracePeriods( protected void assertGracePeriods(
Iterable<GracePeriod> actual, Iterable<GracePeriod> actual, ImmutableMap<GracePeriod, ? extends BillingEvent> expected) {
ImmutableMap<GracePeriod, ? extends BillingEvent> expected) {
assertThat(canonicalizeGracePeriods(Maps.toMap(actual, FlowTestCase::expandGracePeriod))) assertThat(canonicalizeGracePeriods(Maps.toMap(actual, FlowTestCase::expandGracePeriod)))
.isEqualTo(canonicalizeGracePeriods(expected)); .isEqualTo(canonicalizeGracePeriods(expected));
} }
public void assertPollMessages( protected void assertPollMessages(String clientId, PollMessage... expected) {
String clientId,
PollMessage... expected) {
assertPollMessagesHelper(getPollMessages(clientId), expected); assertPollMessagesHelper(getPollMessages(clientId), expected);
} }
public void assertPollMessages(PollMessage... expected) { protected void assertPollMessages(PollMessage... expected) {
assertPollMessagesHelper(getPollMessages(), expected); assertPollMessagesHelper(getPollMessages(), expected);
} }
/** Assert that the list matches all the poll messages in the fake Datastore. */ /** Assert that the list matches all the poll messages in the fake Datastore. */
public void assertPollMessagesHelper( private void assertPollMessagesHelper(
Iterable<PollMessage> pollMessages, PollMessage... expected) { Iterable<PollMessage> pollMessages, PollMessage... expected) {
// Ordering is irrelevant but duplicates should be considered independently. // Ordering is irrelevant but duplicates should be considered independently.
assertThat( assertThat(
@ -279,7 +271,7 @@ public abstract class FlowTestCase<F extends Flow> extends ShardableTestCase {
} }
/** Shortcut to call {@link #runFlow(CommitMode, UserPrivileges)} as super user and live run. */ /** Shortcut to call {@link #runFlow(CommitMode, UserPrivileges)} as super user and live run. */
public EppOutput runFlowAsSuperuser() throws Exception { protected EppOutput runFlowAsSuperuser() throws Exception {
return runFlow(CommitMode.LIVE, UserPrivileges.SUPERUSER); return runFlow(CommitMode.LIVE, UserPrivileges.SUPERUSER);
} }

View file

@ -46,8 +46,8 @@ import javax.annotation.Nullable;
import org.joda.time.DateTime; import org.joda.time.DateTime;
import org.joda.time.Duration; import org.joda.time.Duration;
import org.json.simple.JSONValue; import org.json.simple.JSONValue;
import org.junit.Before; import org.junit.jupiter.api.BeforeEach;
import org.junit.Test; import org.junit.jupiter.api.Test;
/** /**
* Base class for resource flow unit tests. * Base class for resource flow unit tests.
@ -60,8 +60,8 @@ public abstract class ResourceFlowTestCase<F extends Flow, R extends EppResource
private final TestLogHandler logHandler = new TestLogHandler(); private final TestLogHandler logHandler = new TestLogHandler();
@Before @BeforeEach
public void beforeResourceFlowTestCase() { void beforeResourceFlowTestCase() {
// Attach TestLogHandler to the root logger so it has access to all log messages. // Attach TestLogHandler to the root logger so it has access to all log messages.
// Note that in theory for assertIcannReportingActivityFieldLogged() below it would suffice to // Note that in theory for assertIcannReportingActivityFieldLogged() below it would suffice to
// attach it only to the FlowRunner logger, but for some reason this doesn't work for all flows. // attach it only to the FlowRunner logger, but for some reason this doesn't work for all flows.
@ -89,7 +89,7 @@ public abstract class ResourceFlowTestCase<F extends Flow, R extends EppResource
return refreshedResource; return refreshedResource;
} }
protected ResourceCommand.SingleResourceCommand getResourceCommand() throws Exception { private ResourceCommand.SingleResourceCommand getResourceCommand() throws Exception {
return (ResourceCommand.SingleResourceCommand) return (ResourceCommand.SingleResourceCommand)
((ResourceCommandWrapper) eppLoader.getEpp().getCommandWrapper().getCommand()) ((ResourceCommandWrapper) eppLoader.getEpp().getCommandWrapper().getCommand())
.getResourceCommand(); .getResourceCommand();
@ -99,7 +99,7 @@ public abstract class ResourceFlowTestCase<F extends Flow, R extends EppResource
return getResourceCommand().getTargetId(); return getResourceCommand().getTargetId();
} }
protected Class<R> getResourceClass() { private Class<R> getResourceClass() {
return new TypeInstantiator<R>(getClass()){}.getExactType(); return new TypeInstantiator<R>(getClass()){}.getExactType();
} }
@ -119,7 +119,7 @@ public abstract class ResourceFlowTestCase<F extends Flow, R extends EppResource
} }
@Test @Test
public void testRequiresLogin() { void testRequiresLogin() {
sessionMetadata.setClientId(null); sessionMetadata.setClientId(null);
EppException thrown = assertThrows(NotLoggedInException.class, this::runFlow); EppException thrown = assertThrows(NotLoggedInException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml(); assertAboutEppExceptions().that(thrown).marshalsToXml();

View file

@ -25,7 +25,6 @@ import static org.mockito.Mockito.when;
import google.registry.model.registrar.Registrar; import google.registry.model.registrar.Registrar;
import google.registry.request.HttpException.BadRequestException; import google.registry.request.HttpException.BadRequestException;
import google.registry.testing.AppEngineRule; import google.registry.testing.AppEngineRule;
import google.registry.testing.ShardableTestCase;
import java.util.Optional; import java.util.Optional;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import org.joda.time.DateTime; import org.joda.time.DateTime;
@ -36,7 +35,7 @@ import org.junit.runners.JUnit4;
/** Unit tests for {@link TlsCredentials}. */ /** Unit tests for {@link TlsCredentials}. */
@RunWith(JUnit4.class) @RunWith(JUnit4.class)
public final class TlsCredentialsTest extends ShardableTestCase { public final class TlsCredentialsTest {
@Rule @Rule
public final AppEngineRule appEngine = AppEngineRule.builder().withDatastoreAndCloudSql().build(); public final AppEngineRule appEngine = AppEngineRule.builder().withDatastoreAndCloudSql().build();

View file

@ -24,18 +24,17 @@ import google.registry.flows.EppException;
import google.registry.flows.ResourceCheckFlowTestCase; import google.registry.flows.ResourceCheckFlowTestCase;
import google.registry.flows.exceptions.TooManyResourceChecksException; import google.registry.flows.exceptions.TooManyResourceChecksException;
import google.registry.model.contact.ContactResource; import google.registry.model.contact.ContactResource;
import org.junit.Test; import org.junit.jupiter.api.Test;
/** Unit tests for {@link ContactCheckFlow}. */ /** Unit tests for {@link ContactCheckFlow}. */
public class ContactCheckFlowTest class ContactCheckFlowTest extends ResourceCheckFlowTestCase<ContactCheckFlow, ContactResource> {
extends ResourceCheckFlowTestCase<ContactCheckFlow, ContactResource> {
public ContactCheckFlowTest() { ContactCheckFlowTest() {
setEppInput("contact_check.xml"); setEppInput("contact_check.xml");
} }
@Test @Test
public void testNothingExists() throws Exception { void testNothingExists() throws Exception {
// These ids come from the check xml. // These ids come from the check xml.
doCheckTest( doCheckTest(
create(true, "sh8013", null), create(true, "sh8013", null),
@ -44,7 +43,7 @@ public class ContactCheckFlowTest
} }
@Test @Test
public void testOneExists() throws Exception { void testOneExists() throws Exception {
persistActiveContact("sh8013"); persistActiveContact("sh8013");
// These ids come from the check xml. // These ids come from the check xml.
doCheckTest( doCheckTest(
@ -54,7 +53,7 @@ public class ContactCheckFlowTest
} }
@Test @Test
public void testOneExistsButWasDeleted() throws Exception { void testOneExistsButWasDeleted() throws Exception {
persistDeletedContact("sh8013", clock.nowUtc().minusDays(1)); persistDeletedContact("sh8013", clock.nowUtc().minusDays(1));
// These ids come from the check xml. // These ids come from the check xml.
doCheckTest( doCheckTest(
@ -64,27 +63,27 @@ public class ContactCheckFlowTest
} }
@Test @Test
public void testXmlMatches() throws Exception { void testXmlMatches() throws Exception {
persistActiveContact("sah8013"); persistActiveContact("sah8013");
runFlowAssertResponse(loadFile("contact_check_response.xml")); runFlowAssertResponse(loadFile("contact_check_response.xml"));
} }
@Test @Test
public void test50IdsAllowed() throws Exception { void test50IdsAllowed() throws Exception {
// Make sure we don't have a regression that reduces the number of allowed checks. // Make sure we don't have a regression that reduces the number of allowed checks.
setEppInput("contact_check_50.xml"); setEppInput("contact_check_50.xml");
runFlow(); runFlow();
} }
@Test @Test
public void testTooManyIds() { void testTooManyIds() {
setEppInput("contact_check_51.xml"); setEppInput("contact_check_51.xml");
EppException thrown = assertThrows(TooManyResourceChecksException.class, this::runFlow); EppException thrown = assertThrows(TooManyResourceChecksException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml(); assertAboutEppExceptions().that(thrown).marshalsToXml();
} }
@Test @Test
public void testIcannActivityReportField_getsLogged() throws Exception { void testIcannActivityReportField_getsLogged() throws Exception {
runFlow(); runFlow();
assertIcannReportingActivityFieldLogged("srs-cont-check"); assertIcannReportingActivityFieldLogged("srs-cont-check");
} }

View file

@ -32,13 +32,12 @@ import google.registry.flows.exceptions.ResourceAlreadyExistsForThisClientExcept
import google.registry.flows.exceptions.ResourceCreateContentionException; import google.registry.flows.exceptions.ResourceCreateContentionException;
import google.registry.model.contact.ContactResource; import google.registry.model.contact.ContactResource;
import org.joda.time.DateTime; import org.joda.time.DateTime;
import org.junit.Test; import org.junit.jupiter.api.Test;
/** Unit tests for {@link ContactCreateFlow}. */ /** Unit tests for {@link ContactCreateFlow}. */
public class ContactCreateFlowTest class ContactCreateFlowTest extends ResourceFlowTestCase<ContactCreateFlow, ContactResource> {
extends ResourceFlowTestCase<ContactCreateFlow, ContactResource> {
public ContactCreateFlowTest() { ContactCreateFlowTest() {
setEppInput("contact_create.xml"); setEppInput("contact_create.xml");
clock.setTo(DateTime.parse("1999-04-03T22:00:00.0Z")); clock.setTo(DateTime.parse("1999-04-03T22:00:00.0Z"));
} }
@ -56,24 +55,24 @@ public class ContactCreateFlowTest
} }
@Test @Test
public void testDryRun() throws Exception { void testDryRun() throws Exception {
dryRunFlowAssertResponse(loadFile("contact_create_response.xml")); dryRunFlowAssertResponse(loadFile("contact_create_response.xml"));
} }
@Test @Test
public void testSuccess_neverExisted() throws Exception { void testSuccess_neverExisted() throws Exception {
doSuccessfulTest(); doSuccessfulTest();
} }
@Test @Test
public void testSuccess_existedButWasDeleted() throws Exception { void testSuccess_existedButWasDeleted() throws Exception {
persistDeletedContact(getUniqueIdFromCommand(), clock.nowUtc().minusDays(1)); persistDeletedContact(getUniqueIdFromCommand(), clock.nowUtc().minusDays(1));
clock.advanceOneMilli(); clock.advanceOneMilli();
doSuccessfulTest(); doSuccessfulTest();
} }
@Test @Test
public void testFailure_alreadyExists() throws Exception { void testFailure_alreadyExists() throws Exception {
persistActiveContact(getUniqueIdFromCommand()); persistActiveContact(getUniqueIdFromCommand());
ResourceAlreadyExistsForThisClientException thrown = ResourceAlreadyExistsForThisClientException thrown =
assertThrows(ResourceAlreadyExistsForThisClientException.class, this::runFlow); assertThrows(ResourceAlreadyExistsForThisClientException.class, this::runFlow);
@ -85,7 +84,7 @@ public class ContactCreateFlowTest
} }
@Test @Test
public void testFailure_resourceContention() throws Exception { void testFailure_resourceContention() throws Exception {
String targetId = getUniqueIdFromCommand(); String targetId = getUniqueIdFromCommand();
persistResource( persistResource(
newContactResource(targetId) newContactResource(targetId)
@ -101,13 +100,13 @@ public class ContactCreateFlowTest
} }
@Test @Test
public void testSuccess_nonAsciiInLocAddress() throws Exception { void testSuccess_nonAsciiInLocAddress() throws Exception {
setEppInput("contact_create_hebrew_loc.xml"); setEppInput("contact_create_hebrew_loc.xml");
doSuccessfulTest(); doSuccessfulTest();
} }
@Test @Test
public void testFailure_nonAsciiInIntAddress() { void testFailure_nonAsciiInIntAddress() {
setEppInput("contact_create_hebrew_int.xml"); setEppInput("contact_create_hebrew_int.xml");
EppException thrown = EppException thrown =
assertThrows(BadInternationalizedPostalInfoException.class, this::runFlow); assertThrows(BadInternationalizedPostalInfoException.class, this::runFlow);
@ -115,7 +114,7 @@ public class ContactCreateFlowTest
} }
@Test @Test
public void testFailure_declineDisclosure() { void testFailure_declineDisclosure() {
setEppInput("contact_create_decline_disclosure.xml"); setEppInput("contact_create_decline_disclosure.xml");
EppException thrown = EppException thrown =
assertThrows(DeclineContactDisclosureFieldDisallowedPolicyException.class, this::runFlow); assertThrows(DeclineContactDisclosureFieldDisallowedPolicyException.class, this::runFlow);
@ -123,7 +122,7 @@ public class ContactCreateFlowTest
} }
@Test @Test
public void testIcannActivityReportField_getsLogged() throws Exception { void testIcannActivityReportField_getsLogged() throws Exception {
runFlow(); runFlow();
assertIcannReportingActivityFieldLogged("srs-cont-create"); assertIcannReportingActivityFieldLogged("srs-cont-create");
} }

View file

@ -37,26 +37,25 @@ import google.registry.model.contact.ContactResource;
import google.registry.model.eppcommon.StatusValue; import google.registry.model.eppcommon.StatusValue;
import google.registry.model.eppcommon.Trid; import google.registry.model.eppcommon.Trid;
import google.registry.model.reporting.HistoryEntry; import google.registry.model.reporting.HistoryEntry;
import org.junit.Before; import org.junit.jupiter.api.BeforeEach;
import org.junit.Test; import org.junit.jupiter.api.Test;
/** Unit tests for {@link ContactDeleteFlow}. */ /** Unit tests for {@link ContactDeleteFlow}. */
public class ContactDeleteFlowTest class ContactDeleteFlowTest extends ResourceFlowTestCase<ContactDeleteFlow, ContactResource> {
extends ResourceFlowTestCase<ContactDeleteFlow, ContactResource> {
@Before @BeforeEach
public void initFlowTest() { void initFlowTest() {
setEppInput("contact_delete.xml"); setEppInput("contact_delete.xml");
} }
@Test @Test
public void testDryRun() throws Exception { void testDryRun() throws Exception {
persistActiveContact(getUniqueIdFromCommand()); persistActiveContact(getUniqueIdFromCommand());
dryRunFlowAssertResponse(loadFile("contact_delete_response.xml")); dryRunFlowAssertResponse(loadFile("contact_delete_response.xml"));
} }
@Test @Test
public void testSuccess() throws Exception { void testSuccess() throws Exception {
persistActiveContact(getUniqueIdFromCommand()); persistActiveContact(getUniqueIdFromCommand());
clock.advanceOneMilli(); clock.advanceOneMilli();
assertTransactionalFlow(true); assertTransactionalFlow(true);
@ -73,7 +72,7 @@ public class ContactDeleteFlowTest
} }
@Test @Test
public void testSuccess_clTridNotSpecified() throws Exception { void testSuccess_clTridNotSpecified() throws Exception {
setEppInput("contact_delete_no_cltrid.xml"); setEppInput("contact_delete_no_cltrid.xml");
persistActiveContact(getUniqueIdFromCommand()); persistActiveContact(getUniqueIdFromCommand());
clock.advanceOneMilli(); clock.advanceOneMilli();
@ -91,7 +90,7 @@ public class ContactDeleteFlowTest
} }
@Test @Test
public void testFailure_neverExisted() throws Exception { void testFailure_neverExisted() throws Exception {
ResourceDoesNotExistException thrown = ResourceDoesNotExistException thrown =
assertThrows(ResourceDoesNotExistException.class, this::runFlow); assertThrows(ResourceDoesNotExistException.class, this::runFlow);
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand())); assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
@ -99,7 +98,7 @@ public class ContactDeleteFlowTest
} }
@Test @Test
public void testFailure_existedButWasDeleted() throws Exception { void testFailure_existedButWasDeleted() throws Exception {
persistDeletedContact(getUniqueIdFromCommand(), clock.nowUtc().minusDays(1)); persistDeletedContact(getUniqueIdFromCommand(), clock.nowUtc().minusDays(1));
ResourceDoesNotExistException thrown = ResourceDoesNotExistException thrown =
assertThrows(ResourceDoesNotExistException.class, this::runFlow); assertThrows(ResourceDoesNotExistException.class, this::runFlow);
@ -108,19 +107,19 @@ public class ContactDeleteFlowTest
} }
@Test @Test
public void testFailure_existedButWasClientDeleteProhibited() throws Exception { void testFailure_existedButWasClientDeleteProhibited() throws Exception {
doFailingStatusTest( doFailingStatusTest(
StatusValue.CLIENT_DELETE_PROHIBITED, ResourceStatusProhibitsOperationException.class); StatusValue.CLIENT_DELETE_PROHIBITED, ResourceStatusProhibitsOperationException.class);
} }
@Test @Test
public void testFailure_existedButWasServerDeleteProhibited() throws Exception { void testFailure_existedButWasServerDeleteProhibited() throws Exception {
doFailingStatusTest( doFailingStatusTest(
StatusValue.SERVER_DELETE_PROHIBITED, ResourceStatusProhibitsOperationException.class); StatusValue.SERVER_DELETE_PROHIBITED, ResourceStatusProhibitsOperationException.class);
} }
@Test @Test
public void testFailure_existedButWasPendingDelete() throws Exception { void testFailure_existedButWasPendingDelete() throws Exception {
doFailingStatusTest( doFailingStatusTest(
StatusValue.PENDING_DELETE, ResourceStatusProhibitsOperationException.class); StatusValue.PENDING_DELETE, ResourceStatusProhibitsOperationException.class);
} }
@ -137,7 +136,7 @@ public class ContactDeleteFlowTest
} }
@Test @Test
public void testFailure_unauthorizedClient() throws Exception { void testFailure_unauthorizedClient() throws Exception {
sessionMetadata.setClientId("NewRegistrar"); sessionMetadata.setClientId("NewRegistrar");
persistActiveContact(getUniqueIdFromCommand()); persistActiveContact(getUniqueIdFromCommand());
EppException thrown = assertThrows(ResourceNotOwnedException.class, this::runFlow); EppException thrown = assertThrows(ResourceNotOwnedException.class, this::runFlow);
@ -145,7 +144,7 @@ public class ContactDeleteFlowTest
} }
@Test @Test
public void testSuccess_superuserUnauthorizedClient() throws Exception { void testSuccess_superuserUnauthorizedClient() throws Exception {
sessionMetadata.setClientId("NewRegistrar"); sessionMetadata.setClientId("NewRegistrar");
persistActiveContact(getUniqueIdFromCommand()); persistActiveContact(getUniqueIdFromCommand());
clock.advanceOneMilli(); clock.advanceOneMilli();
@ -163,7 +162,7 @@ public class ContactDeleteFlowTest
} }
@Test @Test
public void testFailure_failfastWhenLinkedToDomain() throws Exception { void testFailure_failfastWhenLinkedToDomain() throws Exception {
createTld("tld"); createTld("tld");
persistResource( persistResource(
newDomainBase("example.tld", persistActiveContact(getUniqueIdFromCommand()))); newDomainBase("example.tld", persistActiveContact(getUniqueIdFromCommand())));
@ -172,7 +171,7 @@ public class ContactDeleteFlowTest
} }
@Test @Test
public void testFailure_failfastWhenLinkedToApplication() throws Exception { void testFailure_failfastWhenLinkedToApplication() throws Exception {
createTld("tld"); createTld("tld");
persistResource( persistResource(
newDomainBase("example.tld", persistActiveContact(getUniqueIdFromCommand()))); newDomainBase("example.tld", persistActiveContact(getUniqueIdFromCommand())));
@ -181,7 +180,7 @@ public class ContactDeleteFlowTest
} }
@Test @Test
public void testIcannActivityReportField_getsLogged() throws Exception { void testIcannActivityReportField_getsLogged() throws Exception {
persistActiveContact(getUniqueIdFromCommand()); persistActiveContact(getUniqueIdFromCommand());
clock.advanceOneMilli(); clock.advanceOneMilli();
runFlow(); runFlow();

View file

@ -39,12 +39,12 @@ import google.registry.model.eppcommon.AuthInfo.PasswordAuth;
import google.registry.model.eppcommon.PresenceMarker; import google.registry.model.eppcommon.PresenceMarker;
import google.registry.model.eppcommon.StatusValue; import google.registry.model.eppcommon.StatusValue;
import org.joda.time.DateTime; import org.joda.time.DateTime;
import org.junit.Test; import org.junit.jupiter.api.Test;
/** Unit tests for {@link ContactInfoFlow}. */ /** Unit tests for {@link ContactInfoFlow}. */
public class ContactInfoFlowTest extends ResourceFlowTestCase<ContactInfoFlow, ContactResource> { class ContactInfoFlowTest extends ResourceFlowTestCase<ContactInfoFlow, ContactResource> {
public ContactInfoFlowTest() { ContactInfoFlowTest() {
setEppInput("contact_info.xml"); setEppInput("contact_info.xml");
} }
@ -95,7 +95,7 @@ public class ContactInfoFlowTest extends ResourceFlowTestCase<ContactInfoFlow, C
} }
@Test @Test
public void testSuccess() throws Exception { void testSuccess() throws Exception {
persistContactResource(true); persistContactResource(true);
// Check that the persisted contact info was returned. // Check that the persisted contact info was returned.
assertTransactionalFlow(false); assertTransactionalFlow(false);
@ -108,7 +108,7 @@ public class ContactInfoFlowTest extends ResourceFlowTestCase<ContactInfoFlow, C
} }
@Test @Test
public void testSuccess_linked() throws Exception { void testSuccess_linked() throws Exception {
createTld("foobar"); createTld("foobar");
persistResource(newDomainBase("example.foobar", persistContactResource(true))); persistResource(newDomainBase("example.foobar", persistContactResource(true)));
// Check that the persisted contact info was returned. // Check that the persisted contact info was returned.
@ -122,7 +122,7 @@ public class ContactInfoFlowTest extends ResourceFlowTestCase<ContactInfoFlow, C
} }
@Test @Test
public void testSuccess_owningRegistrarWithoutAuthInfo_seesAuthInfo() throws Exception { void testSuccess_owningRegistrarWithoutAuthInfo_seesAuthInfo() throws Exception {
setEppInput("contact_info_no_authinfo.xml"); setEppInput("contact_info_no_authinfo.xml");
persistContactResource(true); persistContactResource(true);
// Check that the persisted contact info was returned. // Check that the persisted contact info was returned.
@ -136,7 +136,7 @@ public class ContactInfoFlowTest extends ResourceFlowTestCase<ContactInfoFlow, C
} }
@Test @Test
public void testFailure_otherRegistrar_notAuthorized() throws Exception { void testFailure_otherRegistrar_notAuthorized() throws Exception {
setClientIdForFlow("NewRegistrar"); setClientIdForFlow("NewRegistrar");
persistContactResource(true); persistContactResource(true);
// Check that the persisted contact info was returned. // Check that the persisted contact info was returned.
@ -146,8 +146,7 @@ public class ContactInfoFlowTest extends ResourceFlowTestCase<ContactInfoFlow, C
} }
@Test @Test
public void testSuccess_otherRegistrarWithoutAuthInfoAsSuperuser_doesNotSeeAuthInfo() void testSuccess_otherRegistrarWithoutAuthInfoAsSuperuser_doesNotSeeAuthInfo() throws Exception {
throws Exception {
setClientIdForFlow("NewRegistrar"); setClientIdForFlow("NewRegistrar");
setEppInput("contact_info_no_authinfo.xml"); setEppInput("contact_info_no_authinfo.xml");
persistContactResource(true); persistContactResource(true);
@ -164,7 +163,7 @@ public class ContactInfoFlowTest extends ResourceFlowTestCase<ContactInfoFlow, C
} }
@Test @Test
public void testSuccess_otherRegistrarWithAuthInfoAsSuperuser_seesAuthInfo() throws Exception { void testSuccess_otherRegistrarWithAuthInfoAsSuperuser_seesAuthInfo() throws Exception {
setClientIdForFlow("NewRegistrar"); setClientIdForFlow("NewRegistrar");
persistContactResource(true); persistContactResource(true);
// Check that the persisted contact info was returned. // Check that the persisted contact info was returned.
@ -180,7 +179,7 @@ public class ContactInfoFlowTest extends ResourceFlowTestCase<ContactInfoFlow, C
} }
@Test @Test
public void testFailure_neverExisted() throws Exception { void testFailure_neverExisted() throws Exception {
ResourceDoesNotExistException thrown = ResourceDoesNotExistException thrown =
assertThrows(ResourceDoesNotExistException.class, this::runFlow); assertThrows(ResourceDoesNotExistException.class, this::runFlow);
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand())); assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
@ -188,7 +187,7 @@ public class ContactInfoFlowTest extends ResourceFlowTestCase<ContactInfoFlow, C
} }
@Test @Test
public void testFailure_existedButWasDeleted() throws Exception { void testFailure_existedButWasDeleted() throws Exception {
persistContactResource(false); persistContactResource(false);
ResourceDoesNotExistException thrown = ResourceDoesNotExistException thrown =
assertThrows(ResourceDoesNotExistException.class, this::runFlow); assertThrows(ResourceDoesNotExistException.class, this::runFlow);
@ -197,7 +196,7 @@ public class ContactInfoFlowTest extends ResourceFlowTestCase<ContactInfoFlow, C
} }
@Test @Test
public void testIcannActivityReportField_getsLogged() throws Exception { void testIcannActivityReportField_getsLogged() throws Exception {
persistContactResource(true); persistContactResource(true);
runFlow(); runFlow();
assertIcannReportingActivityFieldLogged("srs-cont-info"); assertIcannReportingActivityFieldLogged("srs-cont-info");

View file

@ -41,15 +41,15 @@ import google.registry.model.reporting.HistoryEntry;
import google.registry.model.transfer.TransferData; import google.registry.model.transfer.TransferData;
import google.registry.model.transfer.TransferResponse; import google.registry.model.transfer.TransferResponse;
import google.registry.model.transfer.TransferStatus; import google.registry.model.transfer.TransferStatus;
import org.junit.Before; import org.junit.jupiter.api.BeforeEach;
import org.junit.Test; import org.junit.jupiter.api.Test;
/** Unit tests for {@link ContactTransferApproveFlow}. */ /** Unit tests for {@link ContactTransferApproveFlow}. */
public class ContactTransferApproveFlowTest class ContactTransferApproveFlowTest
extends ContactTransferFlowTestCase<ContactTransferApproveFlow, ContactResource> { extends ContactTransferFlowTestCase<ContactTransferApproveFlow, ContactResource> {
@Before @BeforeEach
public void setUp() { void setUp() {
setEppInput("contact_transfer_approve.xml"); setEppInput("contact_transfer_approve.xml");
setClientIdForFlow("TheRegistrar"); setClientIdForFlow("TheRegistrar");
setupContactWithPendingTransfer(); setupContactWithPendingTransfer();
@ -122,24 +122,24 @@ public class ContactTransferApproveFlowTest
} }
@Test @Test
public void testDryRun() throws Exception { void testDryRun() throws Exception {
setEppInput("contact_transfer_approve.xml"); setEppInput("contact_transfer_approve.xml");
dryRunFlowAssertResponse(loadFile("contact_transfer_approve_response.xml")); dryRunFlowAssertResponse(loadFile("contact_transfer_approve_response.xml"));
} }
@Test @Test
public void testSuccess() throws Exception { void testSuccess() throws Exception {
doSuccessfulTest("contact_transfer_approve.xml", "contact_transfer_approve_response.xml"); doSuccessfulTest("contact_transfer_approve.xml", "contact_transfer_approve_response.xml");
} }
@Test @Test
public void testSuccess_withAuthinfo() throws Exception { void testSuccess_withAuthinfo() throws Exception {
doSuccessfulTest("contact_transfer_approve_with_authinfo.xml", doSuccessfulTest("contact_transfer_approve_with_authinfo.xml",
"contact_transfer_approve_response.xml"); "contact_transfer_approve_response.xml");
} }
@Test @Test
public void testFailure_badContactPassword() { void testFailure_badContactPassword() {
// Change the contact's password so it does not match the password in the file. // Change the contact's password so it does not match the password in the file.
contact = persistResource( contact = persistResource(
contact.asBuilder() contact.asBuilder()
@ -153,7 +153,7 @@ public class ContactTransferApproveFlowTest
} }
@Test @Test
public void testFailure_neverBeenTransferred() { void testFailure_neverBeenTransferred() {
changeTransferStatus(null); changeTransferStatus(null);
EppException thrown = EppException thrown =
assertThrows( assertThrows(
@ -162,7 +162,7 @@ public class ContactTransferApproveFlowTest
} }
@Test @Test
public void testFailure_clientApproved() { void testFailure_clientApproved() {
changeTransferStatus(TransferStatus.CLIENT_APPROVED); changeTransferStatus(TransferStatus.CLIENT_APPROVED);
EppException thrown = EppException thrown =
assertThrows( assertThrows(
@ -171,7 +171,7 @@ public class ContactTransferApproveFlowTest
} }
@Test @Test
public void testFailure_clientRejected() { void testFailure_clientRejected() {
changeTransferStatus(TransferStatus.CLIENT_REJECTED); changeTransferStatus(TransferStatus.CLIENT_REJECTED);
EppException thrown = EppException thrown =
assertThrows( assertThrows(
@ -180,7 +180,7 @@ public class ContactTransferApproveFlowTest
} }
@Test @Test
public void testFailure_clientCancelled() { void testFailure_clientCancelled() {
changeTransferStatus(TransferStatus.CLIENT_CANCELLED); changeTransferStatus(TransferStatus.CLIENT_CANCELLED);
EppException thrown = EppException thrown =
assertThrows( assertThrows(
@ -189,7 +189,7 @@ public class ContactTransferApproveFlowTest
} }
@Test @Test
public void testFailure_serverApproved() { void testFailure_serverApproved() {
changeTransferStatus(TransferStatus.SERVER_APPROVED); changeTransferStatus(TransferStatus.SERVER_APPROVED);
EppException thrown = EppException thrown =
assertThrows( assertThrows(
@ -198,7 +198,7 @@ public class ContactTransferApproveFlowTest
} }
@Test @Test
public void testFailure_serverCancelled() { void testFailure_serverCancelled() {
changeTransferStatus(TransferStatus.SERVER_CANCELLED); changeTransferStatus(TransferStatus.SERVER_CANCELLED);
EppException thrown = EppException thrown =
assertThrows( assertThrows(
@ -207,7 +207,7 @@ public class ContactTransferApproveFlowTest
} }
@Test @Test
public void testFailure_gainingClient() { void testFailure_gainingClient() {
setClientIdForFlow("NewRegistrar"); setClientIdForFlow("NewRegistrar");
EppException thrown = EppException thrown =
assertThrows( assertThrows(
@ -216,7 +216,7 @@ public class ContactTransferApproveFlowTest
} }
@Test @Test
public void testFailure_unrelatedClient() { void testFailure_unrelatedClient() {
setClientIdForFlow("ClientZ"); setClientIdForFlow("ClientZ");
EppException thrown = EppException thrown =
assertThrows( assertThrows(
@ -225,7 +225,7 @@ public class ContactTransferApproveFlowTest
} }
@Test @Test
public void testFailure_deletedContact() throws Exception { void testFailure_deletedContact() throws Exception {
contact = persistResource( contact = persistResource(
contact.asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build()); contact.asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build());
ResourceDoesNotExistException thrown = ResourceDoesNotExistException thrown =
@ -237,7 +237,7 @@ public class ContactTransferApproveFlowTest
} }
@Test @Test
public void testFailure_nonexistentContact() throws Exception { void testFailure_nonexistentContact() throws Exception {
deleteResource(contact); deleteResource(contact);
contact = persistResource( contact = persistResource(
contact.asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build()); contact.asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build());
@ -250,7 +250,7 @@ public class ContactTransferApproveFlowTest
} }
@Test @Test
public void testIcannActivityReportField_getsLogged() throws Exception { void testIcannActivityReportField_getsLogged() throws Exception {
runFlow(); runFlow();
assertIcannReportingActivityFieldLogged("srs-cont-transfer-approve"); assertIcannReportingActivityFieldLogged("srs-cont-transfer-approve");
} }

View file

@ -38,15 +38,15 @@ import google.registry.model.reporting.HistoryEntry;
import google.registry.model.transfer.TransferData; import google.registry.model.transfer.TransferData;
import google.registry.model.transfer.TransferResponse; import google.registry.model.transfer.TransferResponse;
import google.registry.model.transfer.TransferStatus; import google.registry.model.transfer.TransferStatus;
import org.junit.Before; import org.junit.jupiter.api.BeforeEach;
import org.junit.Test; import org.junit.jupiter.api.Test;
/** Unit tests for {@link ContactTransferCancelFlow}. */ /** Unit tests for {@link ContactTransferCancelFlow}. */
public class ContactTransferCancelFlowTest class ContactTransferCancelFlowTest
extends ContactTransferFlowTestCase<ContactTransferCancelFlow, ContactResource> { extends ContactTransferFlowTestCase<ContactTransferCancelFlow, ContactResource> {
@Before @BeforeEach
public void setUp() { void setUp() {
this.setEppInput("contact_transfer_cancel.xml"); this.setEppInput("contact_transfer_cancel.xml");
setClientIdForFlow("NewRegistrar"); setClientIdForFlow("NewRegistrar");
setupContactWithPendingTransfer(); setupContactWithPendingTransfer();
@ -106,24 +106,24 @@ public class ContactTransferCancelFlowTest
} }
@Test @Test
public void testDryRun() throws Exception { void testDryRun() throws Exception {
setEppInput("contact_transfer_cancel.xml"); setEppInput("contact_transfer_cancel.xml");
dryRunFlowAssertResponse(loadFile("contact_transfer_cancel_response.xml")); dryRunFlowAssertResponse(loadFile("contact_transfer_cancel_response.xml"));
} }
@Test @Test
public void testSuccess() throws Exception { void testSuccess() throws Exception {
doSuccessfulTest("contact_transfer_cancel.xml", "contact_transfer_cancel_response.xml"); doSuccessfulTest("contact_transfer_cancel.xml", "contact_transfer_cancel_response.xml");
} }
@Test @Test
public void testSuccess_withAuthinfo() throws Exception { void testSuccess_withAuthinfo() throws Exception {
doSuccessfulTest("contact_transfer_cancel_with_authinfo.xml", doSuccessfulTest("contact_transfer_cancel_with_authinfo.xml",
"contact_transfer_cancel_response.xml"); "contact_transfer_cancel_response.xml");
} }
@Test @Test
public void testFailure_badContactPassword() { void testFailure_badContactPassword() {
// Change the contact's password so it does not match the password in the file. // Change the contact's password so it does not match the password in the file.
contact = contact =
persistResource( persistResource(
@ -139,7 +139,7 @@ public class ContactTransferCancelFlowTest
} }
@Test @Test
public void testFailure_neverBeenTransferred() { void testFailure_neverBeenTransferred() {
changeTransferStatus(null); changeTransferStatus(null);
EppException thrown = EppException thrown =
assertThrows( assertThrows(
@ -148,7 +148,7 @@ public class ContactTransferCancelFlowTest
} }
@Test @Test
public void testFailure_clientApproved() { void testFailure_clientApproved() {
changeTransferStatus(TransferStatus.CLIENT_APPROVED); changeTransferStatus(TransferStatus.CLIENT_APPROVED);
EppException thrown = EppException thrown =
assertThrows( assertThrows(
@ -157,7 +157,7 @@ public class ContactTransferCancelFlowTest
} }
@Test @Test
public void testFailure_clientRejected() { void testFailure_clientRejected() {
changeTransferStatus(TransferStatus.CLIENT_REJECTED); changeTransferStatus(TransferStatus.CLIENT_REJECTED);
EppException thrown = EppException thrown =
assertThrows( assertThrows(
@ -166,7 +166,7 @@ public class ContactTransferCancelFlowTest
} }
@Test @Test
public void testFailure_clientCancelled() { void testFailure_clientCancelled() {
changeTransferStatus(TransferStatus.CLIENT_CANCELLED); changeTransferStatus(TransferStatus.CLIENT_CANCELLED);
EppException thrown = EppException thrown =
assertThrows( assertThrows(
@ -175,7 +175,7 @@ public class ContactTransferCancelFlowTest
} }
@Test @Test
public void testFailure_serverApproved() { void testFailure_serverApproved() {
changeTransferStatus(TransferStatus.SERVER_APPROVED); changeTransferStatus(TransferStatus.SERVER_APPROVED);
EppException thrown = EppException thrown =
assertThrows( assertThrows(
@ -184,7 +184,7 @@ public class ContactTransferCancelFlowTest
} }
@Test @Test
public void testFailure_serverCancelled() { void testFailure_serverCancelled() {
changeTransferStatus(TransferStatus.SERVER_CANCELLED); changeTransferStatus(TransferStatus.SERVER_CANCELLED);
EppException thrown = EppException thrown =
assertThrows( assertThrows(
@ -193,7 +193,7 @@ public class ContactTransferCancelFlowTest
} }
@Test @Test
public void testFailure_sponsoringClient() { void testFailure_sponsoringClient() {
setClientIdForFlow("TheRegistrar"); setClientIdForFlow("TheRegistrar");
EppException thrown = EppException thrown =
assertThrows( assertThrows(
@ -203,7 +203,7 @@ public class ContactTransferCancelFlowTest
} }
@Test @Test
public void testFailure_unrelatedClient() { void testFailure_unrelatedClient() {
setClientIdForFlow("ClientZ"); setClientIdForFlow("ClientZ");
EppException thrown = EppException thrown =
assertThrows( assertThrows(
@ -213,7 +213,7 @@ public class ContactTransferCancelFlowTest
} }
@Test @Test
public void testFailure_deletedContact() throws Exception { void testFailure_deletedContact() throws Exception {
contact = contact =
persistResource(contact.asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build()); persistResource(contact.asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build());
ResourceDoesNotExistException thrown = ResourceDoesNotExistException thrown =
@ -225,7 +225,7 @@ public class ContactTransferCancelFlowTest
} }
@Test @Test
public void testFailure_nonexistentContact() throws Exception { void testFailure_nonexistentContact() throws Exception {
deleteResource(contact); deleteResource(contact);
ResourceDoesNotExistException thrown = ResourceDoesNotExistException thrown =
assertThrows( assertThrows(
@ -236,7 +236,7 @@ public class ContactTransferCancelFlowTest
} }
@Test @Test
public void testIcannActivityReportField_getsLogged() throws Exception { void testIcannActivityReportField_getsLogged() throws Exception {
runFlow(); runFlow();
assertIcannReportingActivityFieldLogged("srs-cont-transfer-cancel"); assertIcannReportingActivityFieldLogged("srs-cont-transfer-cancel");
} }

View file

@ -28,7 +28,7 @@ import google.registry.model.transfer.TransferStatus;
import google.registry.testing.AppEngineRule; import google.registry.testing.AppEngineRule;
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;
/** /**
* Base class for contact transfer flow unit tests. * Base class for contact transfer flow unit tests.
@ -49,13 +49,13 @@ public class ContactTransferFlowTestCase<F extends Flow, R extends EppResource>
protected ContactResource contact; protected ContactResource contact;
public ContactTransferFlowTestCase() { ContactTransferFlowTestCase() {
checkState(!Registry.DEFAULT_TRANSFER_GRACE_PERIOD.isShorterThan(TIME_SINCE_REQUEST)); checkState(!Registry.DEFAULT_TRANSFER_GRACE_PERIOD.isShorterThan(TIME_SINCE_REQUEST));
clock.setTo(TRANSFER_REQUEST_TIME.plus(TIME_SINCE_REQUEST)); clock.setTo(TRANSFER_REQUEST_TIME.plus(TIME_SINCE_REQUEST));
} }
@Before @BeforeEach
public void initContactTest() { void initContactTest() {
// Registrar ClientZ is used in tests that need another registrar that definitely doesn't own // Registrar ClientZ is used in tests that need another registrar that definitely doesn't own
// the resources in question. // the resources in question.
persistResource( persistResource(
@ -63,7 +63,7 @@ public class ContactTransferFlowTestCase<F extends Flow, R extends EppResource>
} }
/** Adds a contact that has a pending transfer on it from TheRegistrar to NewRegistrar. */ /** Adds a contact that has a pending transfer on it from TheRegistrar to NewRegistrar. */
protected void setupContactWithPendingTransfer() { void setupContactWithPendingTransfer() {
contact = persistContactWithPendingTransfer( contact = persistContactWithPendingTransfer(
newContactResource("sh8013"), newContactResource("sh8013"),
TRANSFER_REQUEST_TIME, TRANSFER_REQUEST_TIME,

View file

@ -33,15 +33,15 @@ import google.registry.model.eppcommon.AuthInfo.PasswordAuth;
import google.registry.model.reporting.HistoryEntry; import google.registry.model.reporting.HistoryEntry;
import google.registry.model.transfer.TransferStatus; import google.registry.model.transfer.TransferStatus;
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 ContactTransferQueryFlow}. */ /** Unit tests for {@link ContactTransferQueryFlow}. */
public class ContactTransferQueryFlowTest class ContactTransferQueryFlowTest
extends ContactTransferFlowTestCase<ContactTransferQueryFlow, ContactResource> { extends ContactTransferFlowTestCase<ContactTransferQueryFlow, ContactResource> {
@Before @BeforeEach
public void setUp() { void setUp() {
setEppInput("contact_transfer_query.xml"); setEppInput("contact_transfer_query.xml");
clock.setTo(DateTime.parse("2000-06-10T22:00:00.0Z")); clock.setTo(DateTime.parse("2000-06-10T22:00:00.0Z"));
setClientIdForFlow("NewRegistrar"); setClientIdForFlow("NewRegistrar");
@ -69,65 +69,65 @@ public class ContactTransferQueryFlowTest
} }
@Test @Test
public void testSuccess() throws Exception { void testSuccess() throws Exception {
doSuccessfulTest("contact_transfer_query.xml", "contact_transfer_query_response.xml"); doSuccessfulTest("contact_transfer_query.xml", "contact_transfer_query_response.xml");
} }
@Test @Test
public void testSuccess_withContactRoid() throws Exception { void testSuccess_withContactRoid() throws Exception {
doSuccessfulTest("contact_transfer_query_with_roid.xml", "contact_transfer_query_response.xml"); doSuccessfulTest("contact_transfer_query_with_roid.xml", "contact_transfer_query_response.xml");
} }
@Test @Test
public void testSuccess_sponsoringClient() throws Exception { void testSuccess_sponsoringClient() throws Exception {
setClientIdForFlow("TheRegistrar"); setClientIdForFlow("TheRegistrar");
doSuccessfulTest("contact_transfer_query.xml", "contact_transfer_query_response.xml"); doSuccessfulTest("contact_transfer_query.xml", "contact_transfer_query_response.xml");
} }
@Test @Test
public void testSuccess_withAuthinfo() throws Exception { void testSuccess_withAuthinfo() throws Exception {
setClientIdForFlow("ClientZ"); setClientIdForFlow("ClientZ");
doSuccessfulTest("contact_transfer_query_with_authinfo.xml", doSuccessfulTest("contact_transfer_query_with_authinfo.xml",
"contact_transfer_query_response.xml"); "contact_transfer_query_response.xml");
} }
@Test @Test
public void testSuccess_clientApproved() throws Exception { void testSuccess_clientApproved() throws Exception {
changeTransferStatus(TransferStatus.CLIENT_APPROVED); changeTransferStatus(TransferStatus.CLIENT_APPROVED);
doSuccessfulTest("contact_transfer_query.xml", doSuccessfulTest("contact_transfer_query.xml",
"contact_transfer_query_response_client_approved.xml"); "contact_transfer_query_response_client_approved.xml");
} }
@Test @Test
public void testSuccess_clientRejected() throws Exception { void testSuccess_clientRejected() throws Exception {
changeTransferStatus(TransferStatus.CLIENT_REJECTED); changeTransferStatus(TransferStatus.CLIENT_REJECTED);
doSuccessfulTest("contact_transfer_query.xml", doSuccessfulTest("contact_transfer_query.xml",
"contact_transfer_query_response_client_rejected.xml"); "contact_transfer_query_response_client_rejected.xml");
} }
@Test @Test
public void testSuccess_clientCancelled() throws Exception { void testSuccess_clientCancelled() throws Exception {
changeTransferStatus(TransferStatus.CLIENT_CANCELLED); changeTransferStatus(TransferStatus.CLIENT_CANCELLED);
doSuccessfulTest("contact_transfer_query.xml", doSuccessfulTest("contact_transfer_query.xml",
"contact_transfer_query_response_client_cancelled.xml"); "contact_transfer_query_response_client_cancelled.xml");
} }
@Test @Test
public void testSuccess_serverApproved() throws Exception { void testSuccess_serverApproved() throws Exception {
changeTransferStatus(TransferStatus.SERVER_APPROVED); changeTransferStatus(TransferStatus.SERVER_APPROVED);
doSuccessfulTest("contact_transfer_query.xml", doSuccessfulTest("contact_transfer_query.xml",
"contact_transfer_query_response_server_approved.xml"); "contact_transfer_query_response_server_approved.xml");
} }
@Test @Test
public void testSuccess_serverCancelled() throws Exception { void testSuccess_serverCancelled() throws Exception {
changeTransferStatus(TransferStatus.SERVER_CANCELLED); changeTransferStatus(TransferStatus.SERVER_CANCELLED);
doSuccessfulTest("contact_transfer_query.xml", doSuccessfulTest("contact_transfer_query.xml",
"contact_transfer_query_response_server_cancelled.xml"); "contact_transfer_query_response_server_cancelled.xml");
} }
@Test @Test
public void testFailure_pendingDeleteContact() throws Exception { void testFailure_pendingDeleteContact() throws Exception {
changeTransferStatus(TransferStatus.SERVER_CANCELLED); changeTransferStatus(TransferStatus.SERVER_CANCELLED);
contact = persistResource( contact = persistResource(
contact.asBuilder().setDeletionTime(clock.nowUtc().plusDays(1)).build()); contact.asBuilder().setDeletionTime(clock.nowUtc().plusDays(1)).build());
@ -136,7 +136,7 @@ public class ContactTransferQueryFlowTest
} }
@Test @Test
public void testFailure_badContactPassword() { void testFailure_badContactPassword() {
// Change the contact's password so it does not match the password in the file. // Change the contact's password so it does not match the password in the file.
contact = contact =
persistResource( persistResource(
@ -152,7 +152,7 @@ public class ContactTransferQueryFlowTest
} }
@Test @Test
public void testFailure_badContactRoid() { void testFailure_badContactRoid() {
// Set the contact to a different ROID, but don't persist it; this is just so the substitution // Set the contact to a different ROID, but don't persist it; this is just so the substitution
// code above will write the wrong ROID into the file. // code above will write the wrong ROID into the file.
contact = contact.asBuilder().setRepoId("DEADBEEF_TLD-ROID").build(); contact = contact.asBuilder().setRepoId("DEADBEEF_TLD-ROID").build();
@ -164,7 +164,7 @@ public class ContactTransferQueryFlowTest
} }
@Test @Test
public void testFailure_neverBeenTransferred() { void testFailure_neverBeenTransferred() {
changeTransferStatus(null); changeTransferStatus(null);
EppException thrown = EppException thrown =
assertThrows( assertThrows(
@ -174,7 +174,7 @@ public class ContactTransferQueryFlowTest
} }
@Test @Test
public void testFailure_unrelatedClient() { void testFailure_unrelatedClient() {
setClientIdForFlow("ClientZ"); setClientIdForFlow("ClientZ");
EppException thrown = EppException thrown =
assertThrows( assertThrows(
@ -184,7 +184,7 @@ public class ContactTransferQueryFlowTest
} }
@Test @Test
public void testFailure_deletedContact() throws Exception { void testFailure_deletedContact() throws Exception {
contact = contact =
persistResource(contact.asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build()); persistResource(contact.asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build());
ResourceDoesNotExistException thrown = ResourceDoesNotExistException thrown =
@ -195,7 +195,7 @@ public class ContactTransferQueryFlowTest
} }
@Test @Test
public void testFailure_nonexistentContact() throws Exception { void testFailure_nonexistentContact() throws Exception {
deleteResource(contact); deleteResource(contact);
ResourceDoesNotExistException thrown = ResourceDoesNotExistException thrown =
assertThrows( assertThrows(
@ -205,7 +205,7 @@ public class ContactTransferQueryFlowTest
} }
@Test @Test
public void testIcannActivityReportField_getsLogged() throws Exception { void testIcannActivityReportField_getsLogged() throws Exception {
runFlow(); runFlow();
assertIcannReportingActivityFieldLogged("srs-cont-transfer-query"); assertIcannReportingActivityFieldLogged("srs-cont-transfer-query");
} }

View file

@ -40,15 +40,15 @@ import google.registry.model.reporting.HistoryEntry;
import google.registry.model.transfer.TransferData; import google.registry.model.transfer.TransferData;
import google.registry.model.transfer.TransferResponse; import google.registry.model.transfer.TransferResponse;
import google.registry.model.transfer.TransferStatus; import google.registry.model.transfer.TransferStatus;
import org.junit.Before; import org.junit.jupiter.api.BeforeEach;
import org.junit.Test; import org.junit.jupiter.api.Test;
/** Unit tests for {@link ContactTransferRejectFlow}. */ /** Unit tests for {@link ContactTransferRejectFlow}. */
public class ContactTransferRejectFlowTest class ContactTransferRejectFlowTest
extends ContactTransferFlowTestCase<ContactTransferRejectFlow, ContactResource> { extends ContactTransferFlowTestCase<ContactTransferRejectFlow, ContactResource> {
@Before @BeforeEach
public void setUp() { void setUp() {
setEppInput("contact_transfer_reject.xml"); setEppInput("contact_transfer_reject.xml");
setClientIdForFlow("TheRegistrar"); setClientIdForFlow("TheRegistrar");
setupContactWithPendingTransfer(); setupContactWithPendingTransfer();
@ -121,24 +121,24 @@ public class ContactTransferRejectFlowTest
} }
@Test @Test
public void testDryRun() throws Exception { void testDryRun() throws Exception {
setEppInput("contact_transfer_reject.xml"); setEppInput("contact_transfer_reject.xml");
dryRunFlowAssertResponse(loadFile("contact_transfer_reject_response.xml")); dryRunFlowAssertResponse(loadFile("contact_transfer_reject_response.xml"));
} }
@Test @Test
public void testSuccess() throws Exception { void testSuccess() throws Exception {
doSuccessfulTest("contact_transfer_reject.xml", "contact_transfer_reject_response.xml"); doSuccessfulTest("contact_transfer_reject.xml", "contact_transfer_reject_response.xml");
} }
@Test @Test
public void testSuccess_domainAuthInfo() throws Exception { void testSuccess_domainAuthInfo() throws Exception {
doSuccessfulTest("contact_transfer_reject_with_authinfo.xml", doSuccessfulTest("contact_transfer_reject_with_authinfo.xml",
"contact_transfer_reject_response.xml"); "contact_transfer_reject_response.xml");
} }
@Test @Test
public void testFailure_badPassword() { void testFailure_badPassword() {
// Change the contact's password so it does not match the password in the file. // Change the contact's password so it does not match the password in the file.
contact = contact =
persistResource( persistResource(
@ -154,7 +154,7 @@ public class ContactTransferRejectFlowTest
} }
@Test @Test
public void testFailure_neverBeenTransferred() { void testFailure_neverBeenTransferred() {
changeTransferStatus(null); changeTransferStatus(null);
EppException thrown = EppException thrown =
assertThrows( assertThrows(
@ -163,7 +163,7 @@ public class ContactTransferRejectFlowTest
} }
@Test @Test
public void testFailure_clientApproved() { void testFailure_clientApproved() {
changeTransferStatus(TransferStatus.CLIENT_APPROVED); changeTransferStatus(TransferStatus.CLIENT_APPROVED);
EppException thrown = EppException thrown =
assertThrows( assertThrows(
@ -172,7 +172,7 @@ public class ContactTransferRejectFlowTest
} }
@Test @Test
public void testFailure_clientRejected() { void testFailure_clientRejected() {
changeTransferStatus(TransferStatus.CLIENT_REJECTED); changeTransferStatus(TransferStatus.CLIENT_REJECTED);
EppException thrown = EppException thrown =
assertThrows( assertThrows(
@ -181,7 +181,7 @@ public class ContactTransferRejectFlowTest
} }
@Test @Test
public void testFailure_clientCancelled() { void testFailure_clientCancelled() {
changeTransferStatus(TransferStatus.CLIENT_CANCELLED); changeTransferStatus(TransferStatus.CLIENT_CANCELLED);
EppException thrown = EppException thrown =
assertThrows( assertThrows(
@ -190,7 +190,7 @@ public class ContactTransferRejectFlowTest
} }
@Test @Test
public void testFailure_serverApproved() { void testFailure_serverApproved() {
changeTransferStatus(TransferStatus.SERVER_APPROVED); changeTransferStatus(TransferStatus.SERVER_APPROVED);
EppException thrown = EppException thrown =
assertThrows( assertThrows(
@ -199,7 +199,7 @@ public class ContactTransferRejectFlowTest
} }
@Test @Test
public void testFailure_serverCancelled() { void testFailure_serverCancelled() {
changeTransferStatus(TransferStatus.SERVER_CANCELLED); changeTransferStatus(TransferStatus.SERVER_CANCELLED);
EppException thrown = EppException thrown =
assertThrows( assertThrows(
@ -208,7 +208,7 @@ public class ContactTransferRejectFlowTest
} }
@Test @Test
public void testFailure_gainingClient() { void testFailure_gainingClient() {
setClientIdForFlow("NewRegistrar"); setClientIdForFlow("NewRegistrar");
EppException thrown = EppException thrown =
assertThrows( assertThrows(
@ -217,7 +217,7 @@ public class ContactTransferRejectFlowTest
} }
@Test @Test
public void testFailure_unrelatedClient() { void testFailure_unrelatedClient() {
setClientIdForFlow("ClientZ"); setClientIdForFlow("ClientZ");
EppException thrown = EppException thrown =
assertThrows( assertThrows(
@ -226,7 +226,7 @@ public class ContactTransferRejectFlowTest
} }
@Test @Test
public void testFailure_deletedContact() throws Exception { void testFailure_deletedContact() throws Exception {
contact = contact =
persistResource(contact.asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build()); persistResource(contact.asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build());
ResourceDoesNotExistException thrown = ResourceDoesNotExistException thrown =
@ -238,7 +238,7 @@ public class ContactTransferRejectFlowTest
} }
@Test @Test
public void testFailure_nonexistentContact() throws Exception { void testFailure_nonexistentContact() throws Exception {
deleteResource(contact); deleteResource(contact);
ResourceDoesNotExistException thrown = ResourceDoesNotExistException thrown =
assertThrows( assertThrows(
@ -249,7 +249,7 @@ public class ContactTransferRejectFlowTest
} }
@Test @Test
public void testIcannActivityReportField_getsLogged() throws Exception { void testIcannActivityReportField_getsLogged() throws Exception {
runFlow(); runFlow();
assertIcannReportingActivityFieldLogged("srs-cont-transfer-reject"); assertIcannReportingActivityFieldLogged("srs-cont-transfer-reject");
} }

View file

@ -52,20 +52,20 @@ import google.registry.model.transfer.ContactTransferData;
import google.registry.model.transfer.TransferStatus; import google.registry.model.transfer.TransferStatus;
import google.registry.persistence.VKey; import google.registry.persistence.VKey;
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 ContactTransferRequestFlow}. */ /** Unit tests for {@link ContactTransferRequestFlow}. */
public class ContactTransferRequestFlowTest class ContactTransferRequestFlowTest
extends ContactTransferFlowTestCase<ContactTransferRequestFlow, ContactResource> { extends ContactTransferFlowTestCase<ContactTransferRequestFlow, ContactResource> {
public ContactTransferRequestFlowTest() { ContactTransferRequestFlowTest() {
// We need the transfer to happen at exactly this time in order for the response to match up. // We need the transfer to happen at exactly this time in order for the response to match up.
clock.setTo(DateTime.parse("2000-06-08T22:00:00.0Z")); clock.setTo(DateTime.parse("2000-06-08T22:00:00.0Z"));
} }
@Before @BeforeEach
public void setUp() { void setUp() {
setEppInput("contact_transfer_request.xml"); setEppInput("contact_transfer_request.xml");
setClientIdForFlow("NewRegistrar"); setClientIdForFlow("NewRegistrar");
contact = persistActiveContact("sh8013"); contact = persistActiveContact("sh8013");
@ -146,18 +146,18 @@ public class ContactTransferRequestFlowTest
} }
@Test @Test
public void testDryRun() throws Exception { void testDryRun() throws Exception {
setEppInput("contact_transfer_request.xml"); setEppInput("contact_transfer_request.xml");
dryRunFlowAssertResponse(loadFile("contact_transfer_request_response.xml")); dryRunFlowAssertResponse(loadFile("contact_transfer_request_response.xml"));
} }
@Test @Test
public void testSuccess() throws Exception { void testSuccess() throws Exception {
doSuccessfulTest("contact_transfer_request.xml", "contact_transfer_request_response.xml"); doSuccessfulTest("contact_transfer_request.xml", "contact_transfer_request_response.xml");
} }
@Test @Test
public void testFailure_noAuthInfo() { void testFailure_noAuthInfo() {
EppException thrown = EppException thrown =
assertThrows( assertThrows(
MissingTransferRequestAuthInfoException.class, MissingTransferRequestAuthInfoException.class,
@ -166,7 +166,7 @@ public class ContactTransferRequestFlowTest
} }
@Test @Test
public void testFailure_badPassword() { void testFailure_badPassword() {
// Change the contact's password so it does not match the password in the file. // Change the contact's password so it does not match the password in the file.
contact = contact =
persistResource( persistResource(
@ -182,37 +182,37 @@ public class ContactTransferRequestFlowTest
} }
@Test @Test
public void testSuccess_clientApproved() throws Exception { void testSuccess_clientApproved() throws Exception {
changeTransferStatus(TransferStatus.CLIENT_APPROVED); changeTransferStatus(TransferStatus.CLIENT_APPROVED);
doSuccessfulTest("contact_transfer_request.xml", "contact_transfer_request_response.xml"); doSuccessfulTest("contact_transfer_request.xml", "contact_transfer_request_response.xml");
} }
@Test @Test
public void testSuccess_clientRejected() throws Exception { void testSuccess_clientRejected() throws Exception {
changeTransferStatus(TransferStatus.CLIENT_REJECTED); changeTransferStatus(TransferStatus.CLIENT_REJECTED);
doSuccessfulTest("contact_transfer_request.xml", "contact_transfer_request_response.xml"); doSuccessfulTest("contact_transfer_request.xml", "contact_transfer_request_response.xml");
} }
@Test @Test
public void testSuccess_clientCancelled() throws Exception { void testSuccess_clientCancelled() throws Exception {
changeTransferStatus(TransferStatus.CLIENT_CANCELLED); changeTransferStatus(TransferStatus.CLIENT_CANCELLED);
doSuccessfulTest("contact_transfer_request.xml", "contact_transfer_request_response.xml"); doSuccessfulTest("contact_transfer_request.xml", "contact_transfer_request_response.xml");
} }
@Test @Test
public void testSuccess_serverApproved() throws Exception { void testSuccess_serverApproved() throws Exception {
changeTransferStatus(TransferStatus.SERVER_APPROVED); changeTransferStatus(TransferStatus.SERVER_APPROVED);
doSuccessfulTest("contact_transfer_request.xml", "contact_transfer_request_response.xml"); doSuccessfulTest("contact_transfer_request.xml", "contact_transfer_request_response.xml");
} }
@Test @Test
public void testSuccess_serverCancelled() throws Exception { void testSuccess_serverCancelled() throws Exception {
changeTransferStatus(TransferStatus.SERVER_CANCELLED); changeTransferStatus(TransferStatus.SERVER_CANCELLED);
doSuccessfulTest("contact_transfer_request.xml", "contact_transfer_request_response.xml"); doSuccessfulTest("contact_transfer_request.xml", "contact_transfer_request_response.xml");
} }
@Test @Test
public void testFailure_pending() { void testFailure_pending() {
contact = contact =
persistResource( persistResource(
contact contact
@ -233,7 +233,7 @@ public class ContactTransferRequestFlowTest
} }
@Test @Test
public void testFailure_sponsoringClient() { void testFailure_sponsoringClient() {
setClientIdForFlow("TheRegistrar"); setClientIdForFlow("TheRegistrar");
EppException thrown = EppException thrown =
assertThrows( assertThrows(
@ -243,7 +243,7 @@ public class ContactTransferRequestFlowTest
} }
@Test @Test
public void testFailure_deletedContact() throws Exception { void testFailure_deletedContact() throws Exception {
contact = contact =
persistResource(contact.asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build()); persistResource(contact.asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build());
ResourceDoesNotExistException thrown = ResourceDoesNotExistException thrown =
@ -255,7 +255,7 @@ public class ContactTransferRequestFlowTest
} }
@Test @Test
public void testFailure_nonexistentContact() throws Exception { void testFailure_nonexistentContact() throws Exception {
deleteResource(contact); deleteResource(contact);
ResourceDoesNotExistException thrown = ResourceDoesNotExistException thrown =
assertThrows( assertThrows(
@ -266,7 +266,7 @@ public class ContactTransferRequestFlowTest
} }
@Test @Test
public void testFailure_clientTransferProhibited() { void testFailure_clientTransferProhibited() {
contact = contact =
persistResource( persistResource(
contact.asBuilder().addStatusValue(StatusValue.CLIENT_TRANSFER_PROHIBITED).build()); contact.asBuilder().addStatusValue(StatusValue.CLIENT_TRANSFER_PROHIBITED).build());
@ -279,7 +279,7 @@ public class ContactTransferRequestFlowTest
} }
@Test @Test
public void testFailure_serverTransferProhibited() { void testFailure_serverTransferProhibited() {
contact = contact =
persistResource( persistResource(
contact.asBuilder().addStatusValue(StatusValue.SERVER_TRANSFER_PROHIBITED).build()); contact.asBuilder().addStatusValue(StatusValue.SERVER_TRANSFER_PROHIBITED).build());
@ -292,7 +292,7 @@ public class ContactTransferRequestFlowTest
} }
@Test @Test
public void testFailure_pendingDelete() { void testFailure_pendingDelete() {
contact = contact =
persistResource(contact.asBuilder().addStatusValue(StatusValue.PENDING_DELETE).build()); persistResource(contact.asBuilder().addStatusValue(StatusValue.PENDING_DELETE).build());
ResourceStatusProhibitsOperationException thrown = ResourceStatusProhibitsOperationException thrown =
@ -304,7 +304,7 @@ public class ContactTransferRequestFlowTest
} }
@Test @Test
public void testIcannActivityReportField_getsLogged() throws Exception { void testIcannActivityReportField_getsLogged() throws Exception {
runFlow(); runFlow();
assertIcannReportingActivityFieldLogged("srs-cont-transfer-request"); assertIcannReportingActivityFieldLogged("srs-cont-transfer-request");
} }

View file

@ -41,13 +41,12 @@ import google.registry.model.contact.ContactResource;
import google.registry.model.contact.PostalInfo; import google.registry.model.contact.PostalInfo;
import google.registry.model.contact.PostalInfo.Type; import google.registry.model.contact.PostalInfo.Type;
import google.registry.model.eppcommon.StatusValue; import google.registry.model.eppcommon.StatusValue;
import org.junit.Test; import org.junit.jupiter.api.Test;
/** Unit tests for {@link ContactUpdateFlow}. */ /** Unit tests for {@link ContactUpdateFlow}. */
public class ContactUpdateFlowTest class ContactUpdateFlowTest extends ResourceFlowTestCase<ContactUpdateFlow, ContactResource> {
extends ResourceFlowTestCase<ContactUpdateFlow, ContactResource> {
public ContactUpdateFlowTest() { ContactUpdateFlowTest() {
setEppInput("contact_update.xml"); setEppInput("contact_update.xml");
} }
@ -65,18 +64,18 @@ public class ContactUpdateFlowTest
} }
@Test @Test
public void testDryRun() throws Exception { void testDryRun() throws Exception {
persistActiveContact(getUniqueIdFromCommand()); persistActiveContact(getUniqueIdFromCommand());
dryRunFlowAssertResponse(loadFile("generic_success_response.xml")); dryRunFlowAssertResponse(loadFile("generic_success_response.xml"));
} }
@Test @Test
public void testSuccess() throws Exception { void testSuccess() throws Exception {
doSuccessfulTest(); doSuccessfulTest();
} }
@Test @Test
public void testSuccess_updatingInternationalizedPostalInfoDeletesLocalized() throws Exception { void testSuccess_updatingInternationalizedPostalInfoDeletesLocalized() throws Exception {
ContactResource contact = ContactResource contact =
persistResource( persistResource(
newContactResource(getUniqueIdFromCommand()).asBuilder() newContactResource(getUniqueIdFromCommand()).asBuilder()
@ -114,7 +113,7 @@ public class ContactUpdateFlowTest
} }
@Test @Test
public void testSuccess_updatingLocalizedPostalInfoDeletesInternationalized() throws Exception { void testSuccess_updatingLocalizedPostalInfoDeletesInternationalized() throws Exception {
setEppInput("contact_update_localized.xml"); setEppInput("contact_update_localized.xml");
ContactResource contact = ContactResource contact =
persistResource( persistResource(
@ -153,7 +152,7 @@ public class ContactUpdateFlowTest
} }
@Test @Test
public void testSuccess_partialPostalInfoUpdate() throws Exception { void testSuccess_partialPostalInfoUpdate() throws Exception {
setEppInput("contact_update_partial_postalinfo.xml"); setEppInput("contact_update_partial_postalinfo.xml");
persistResource( persistResource(
newContactResource(getUniqueIdFromCommand()).asBuilder() newContactResource(getUniqueIdFromCommand()).asBuilder()
@ -188,9 +187,8 @@ public class ContactUpdateFlowTest
.build()); .build());
} }
@Test @Test
public void testSuccess_updateOnePostalInfo_touchOtherPostalInfoPreservesIt() throws Exception { void testSuccess_updateOnePostalInfo_touchOtherPostalInfoPreservesIt() throws Exception {
setEppInput("contact_update_partial_postalinfo_preserve_int.xml"); setEppInput("contact_update_partial_postalinfo_preserve_int.xml");
persistResource( persistResource(
newContactResource(getUniqueIdFromCommand()).asBuilder() newContactResource(getUniqueIdFromCommand()).asBuilder()
@ -256,7 +254,7 @@ public class ContactUpdateFlowTest
} }
@Test @Test
public void testFailure_neverExisted() throws Exception { void testFailure_neverExisted() throws Exception {
ResourceDoesNotExistException thrown = ResourceDoesNotExistException thrown =
assertThrows(ResourceDoesNotExistException.class, this::runFlow); assertThrows(ResourceDoesNotExistException.class, this::runFlow);
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand())); assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
@ -264,7 +262,7 @@ public class ContactUpdateFlowTest
} }
@Test @Test
public void testFailure_existedButWasDeleted() throws Exception { void testFailure_existedButWasDeleted() throws Exception {
persistDeletedContact(getUniqueIdFromCommand(), clock.nowUtc().minusDays(1)); persistDeletedContact(getUniqueIdFromCommand(), clock.nowUtc().minusDays(1));
ResourceDoesNotExistException thrown = ResourceDoesNotExistException thrown =
assertThrows(ResourceDoesNotExistException.class, this::runFlow); assertThrows(ResourceDoesNotExistException.class, this::runFlow);
@ -273,7 +271,7 @@ public class ContactUpdateFlowTest
} }
@Test @Test
public void testFailure_statusValueNotClientSettable() throws Exception { void testFailure_statusValueNotClientSettable() throws Exception {
setEppInput("contact_update_prohibited_status.xml"); setEppInput("contact_update_prohibited_status.xml");
persistActiveContact(getUniqueIdFromCommand()); persistActiveContact(getUniqueIdFromCommand());
EppException thrown = assertThrows(StatusNotClientSettableException.class, this::runFlow); EppException thrown = assertThrows(StatusNotClientSettableException.class, this::runFlow);
@ -281,7 +279,7 @@ public class ContactUpdateFlowTest
} }
@Test @Test
public void testSuccess_superuserStatusValueNotClientSettable() throws Exception { void testSuccess_superuserStatusValueNotClientSettable() throws Exception {
setEppInput("contact_update_prohibited_status.xml"); setEppInput("contact_update_prohibited_status.xml");
persistActiveContact(getUniqueIdFromCommand()); persistActiveContact(getUniqueIdFromCommand());
clock.advanceOneMilli(); clock.advanceOneMilli();
@ -290,7 +288,7 @@ public class ContactUpdateFlowTest
} }
@Test @Test
public void testFailure_unauthorizedClient() throws Exception { void testFailure_unauthorizedClient() throws Exception {
sessionMetadata.setClientId("NewRegistrar"); sessionMetadata.setClientId("NewRegistrar");
persistActiveContact(getUniqueIdFromCommand()); persistActiveContact(getUniqueIdFromCommand());
EppException thrown = assertThrows(ResourceNotOwnedException.class, this::runFlow); EppException thrown = assertThrows(ResourceNotOwnedException.class, this::runFlow);
@ -298,7 +296,7 @@ public class ContactUpdateFlowTest
} }
@Test @Test
public void testSuccess_superuserUnauthorizedClient() throws Exception { void testSuccess_superuserUnauthorizedClient() throws Exception {
sessionMetadata.setClientId("NewRegistrar"); sessionMetadata.setClientId("NewRegistrar");
persistActiveContact(getUniqueIdFromCommand()); persistActiveContact(getUniqueIdFromCommand());
clock.advanceOneMilli(); clock.advanceOneMilli();
@ -307,7 +305,7 @@ public class ContactUpdateFlowTest
} }
@Test @Test
public void testSuccess_clientUpdateProhibited_removed() throws Exception { void testSuccess_clientUpdateProhibited_removed() throws Exception {
setEppInput("contact_update_remove_client_update_prohibited.xml"); setEppInput("contact_update_remove_client_update_prohibited.xml");
persistResource( persistResource(
newContactResource(getUniqueIdFromCommand()) newContactResource(getUniqueIdFromCommand())
@ -321,7 +319,7 @@ public class ContactUpdateFlowTest
} }
@Test @Test
public void testSuccess_superuserClientUpdateProhibited_notRemoved() throws Exception { void testSuccess_superuserClientUpdateProhibited_notRemoved() throws Exception {
setEppInput("contact_update_prohibited_status.xml"); setEppInput("contact_update_prohibited_status.xml");
persistResource( persistResource(
newContactResource(getUniqueIdFromCommand()) newContactResource(getUniqueIdFromCommand())
@ -339,7 +337,7 @@ public class ContactUpdateFlowTest
} }
@Test @Test
public void testFailure_clientUpdateProhibited_notRemoved() throws Exception { void testFailure_clientUpdateProhibited_notRemoved() throws Exception {
persistResource( persistResource(
newContactResource(getUniqueIdFromCommand()) newContactResource(getUniqueIdFromCommand())
.asBuilder() .asBuilder()
@ -351,7 +349,7 @@ public class ContactUpdateFlowTest
} }
@Test @Test
public void testFailure_serverUpdateProhibited() throws Exception { void testFailure_serverUpdateProhibited() throws Exception {
persistResource( persistResource(
newContactResource(getUniqueIdFromCommand()) newContactResource(getUniqueIdFromCommand())
.asBuilder() .asBuilder()
@ -364,7 +362,7 @@ public class ContactUpdateFlowTest
} }
@Test @Test
public void testFailure_pendingDeleteProhibited() throws Exception { void testFailure_pendingDeleteProhibited() throws Exception {
persistResource( persistResource(
newContactResource(getUniqueIdFromCommand()) newContactResource(getUniqueIdFromCommand())
.asBuilder() .asBuilder()
@ -377,13 +375,13 @@ public class ContactUpdateFlowTest
} }
@Test @Test
public void testSuccess_nonAsciiInLocAddress() throws Exception { void testSuccess_nonAsciiInLocAddress() throws Exception {
setEppInput("contact_update_hebrew_loc.xml"); setEppInput("contact_update_hebrew_loc.xml");
doSuccessfulTest(); doSuccessfulTest();
} }
@Test @Test
public void testFailure_nonAsciiInIntAddress() throws Exception { void testFailure_nonAsciiInIntAddress() throws Exception {
setEppInput("contact_update_hebrew_int.xml"); setEppInput("contact_update_hebrew_int.xml");
persistActiveContact(getUniqueIdFromCommand()); persistActiveContact(getUniqueIdFromCommand());
EppException thrown = EppException thrown =
@ -392,7 +390,7 @@ public class ContactUpdateFlowTest
} }
@Test @Test
public void testFailure_declineDisclosure() throws Exception { void testFailure_declineDisclosure() throws Exception {
setEppInput("contact_update_decline_disclosure.xml"); setEppInput("contact_update_decline_disclosure.xml");
persistActiveContact(getUniqueIdFromCommand()); persistActiveContact(getUniqueIdFromCommand());
EppException thrown = EppException thrown =
@ -401,7 +399,7 @@ public class ContactUpdateFlowTest
} }
@Test @Test
public void testFailure_addRemoveSameValue() throws Exception { void testFailure_addRemoveSameValue() throws Exception {
setEppInput("contact_update_add_remove_same.xml"); setEppInput("contact_update_add_remove_same.xml");
persistActiveContact(getUniqueIdFromCommand()); persistActiveContact(getUniqueIdFromCommand());
EppException thrown = assertThrows(AddRemoveSameValueException.class, this::runFlow); EppException thrown = assertThrows(AddRemoveSameValueException.class, this::runFlow);
@ -409,7 +407,7 @@ public class ContactUpdateFlowTest
} }
@Test @Test
public void testIcannActivityReportField_getsLogged() throws Exception { void testIcannActivityReportField_getsLogged() throws Exception {
persistActiveContact(getUniqueIdFromCommand()); persistActiveContact(getUniqueIdFromCommand());
clock.advanceOneMilli(); clock.advanceOneMilli();
runFlow(); runFlow();

View file

@ -74,14 +74,14 @@ import google.registry.model.reporting.HistoryEntry;
import org.joda.money.CurrencyUnit; 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.junit.Before; import org.junit.jupiter.api.BeforeEach;
import org.junit.Ignore; import org.junit.jupiter.api.Disabled;
import org.junit.Test; import org.junit.jupiter.api.Test;
/** Unit tests for {@link DomainCheckFlow}. */ /** Unit tests for {@link DomainCheckFlow}. */
public class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, DomainBase> { class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, DomainBase> {
public DomainCheckFlowTest() { DomainCheckFlowTest() {
setEppInput("domain_check_one_tld.xml"); setEppInput("domain_check_one_tld.xml");
} }
@ -102,14 +102,14 @@ public class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFl
"specificuse,RESERVED_FOR_SPECIFIC_USE"); "specificuse,RESERVED_FOR_SPECIFIC_USE");
} }
@Before @BeforeEach
public void initCheckTest() { void initCheckTest() {
createTld("tld", TldState.QUIET_PERIOD); createTld("tld", TldState.QUIET_PERIOD);
persistResource(Registry.get("tld").asBuilder().setReservedLists(createReservedList()).build()); persistResource(Registry.get("tld").asBuilder().setReservedLists(createReservedList()).build());
} }
@Test @Test
public void testSuccess_nothingExists() throws Exception { void testSuccess_nothingExists() throws Exception {
doCheckTest( doCheckTest(
create(true, "example1.tld", null), create(true, "example1.tld", null),
create(true, "example2.tld", null), create(true, "example2.tld", null),
@ -117,7 +117,7 @@ public class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFl
} }
@Test @Test
public void testSuccess_oneExists() throws Exception { void testSuccess_oneExists() throws Exception {
persistActiveDomain("example1.tld"); persistActiveDomain("example1.tld");
doCheckTest( doCheckTest(
create(false, "example1.tld", "In use"), create(false, "example1.tld", "In use"),
@ -126,7 +126,7 @@ public class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFl
} }
@Test @Test
public void testSuccess_clTridNotSpecified() throws Exception { void testSuccess_clTridNotSpecified() throws Exception {
setEppInput("domain_check_no_cltrid.xml"); setEppInput("domain_check_no_cltrid.xml");
persistActiveDomain("example1.tld"); persistActiveDomain("example1.tld");
doCheckTest( doCheckTest(
@ -136,7 +136,7 @@ public class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFl
} }
@Test @Test
public void testSuccess_oneExists_allocationTokenIsInvalid() throws Exception { void testSuccess_oneExists_allocationTokenIsInvalid() throws Exception {
setEppInput("domain_check_allocationtoken.xml"); setEppInput("domain_check_allocationtoken.xml");
persistActiveDomain("example1.tld"); persistActiveDomain("example1.tld");
doCheckTest( doCheckTest(
@ -147,7 +147,7 @@ public class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFl
} }
@Test @Test
public void testSuccess_oneExists_allocationTokenIsValid() throws Exception { void testSuccess_oneExists_allocationTokenIsValid() throws Exception {
setEppInput("domain_check_allocationtoken.xml"); setEppInput("domain_check_allocationtoken.xml");
persistActiveDomain("example1.tld"); persistActiveDomain("example1.tld");
persistResource( persistResource(
@ -160,7 +160,7 @@ public class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFl
} }
@Test @Test
public void testSuccess_oneExists_allocationTokenIsRedeemed() throws Exception { void testSuccess_oneExists_allocationTokenIsRedeemed() throws Exception {
setEppInput("domain_check_allocationtoken.xml"); setEppInput("domain_check_allocationtoken.xml");
persistActiveDomain("example1.tld"); persistActiveDomain("example1.tld");
persistResource( persistResource(
@ -177,7 +177,7 @@ public class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFl
} }
@Test @Test
public void testSuccess_oneExists_allocationTokenForReservedDomain() throws Exception { void testSuccess_oneExists_allocationTokenForReservedDomain() throws Exception {
setEppInput("domain_check_allocationtoken.xml"); setEppInput("domain_check_allocationtoken.xml");
persistActiveDomain("example1.tld"); persistActiveDomain("example1.tld");
persistResource( persistResource(
@ -194,7 +194,7 @@ public class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFl
} }
@Test @Test
public void testSuccess_allocationTokenForReservedDomain_showsFee() throws Exception { void testSuccess_allocationTokenForReservedDomain_showsFee() throws Exception {
setEppInput("domain_check_allocationtoken_fee_specificuse.xml"); setEppInput("domain_check_allocationtoken_fee_specificuse.xml");
createTld("example"); createTld("example");
persistResource( persistResource(
@ -209,7 +209,7 @@ public class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFl
} }
@Test @Test
public void testSuccess_oneExists_allocationTokenForWrongDomain() throws Exception { void testSuccess_oneExists_allocationTokenForWrongDomain() throws Exception {
setEppInput("domain_check_allocationtoken.xml"); setEppInput("domain_check_allocationtoken.xml");
persistActiveDomain("example1.tld"); persistActiveDomain("example1.tld");
persistResource( persistResource(
@ -226,7 +226,7 @@ public class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFl
} }
@Test @Test
public void testSuccess_notOutOfDateToken_forSpecificDomain() throws Exception { void testSuccess_notOutOfDateToken_forSpecificDomain() throws Exception {
setEppInput("domain_check_allocationtoken.xml"); setEppInput("domain_check_allocationtoken.xml");
persistResource( persistResource(
new AllocationToken.Builder() new AllocationToken.Builder()
@ -248,7 +248,7 @@ public class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFl
} }
@Test @Test
public void testSuccess_outOfDateToken_forSpecificDomain() throws Exception { void testSuccess_outOfDateToken_forSpecificDomain() throws Exception {
setEppInput("domain_check_allocationtoken.xml"); setEppInput("domain_check_allocationtoken.xml");
persistResource( persistResource(
new AllocationToken.Builder() new AllocationToken.Builder()
@ -270,8 +270,7 @@ public class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFl
} }
@Test @Test
public void testSuccess_nothingExists_reservationsOverrideInvalidAllocationTokens() void testSuccess_nothingExists_reservationsOverrideInvalidAllocationTokens() throws Exception {
throws Exception {
setEppInput("domain_check_reserved_allocationtoken.xml"); setEppInput("domain_check_reserved_allocationtoken.xml");
// Fill out these reasons // Fill out these reasons
doCheckTest( doCheckTest(
@ -283,7 +282,7 @@ public class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFl
} }
@Test @Test
public void testSuccess_allocationTokenPromotion() throws Exception { void testSuccess_allocationTokenPromotion() throws Exception {
createTld("example"); createTld("example");
persistResource( persistResource(
new AllocationToken.Builder() new AllocationToken.Builder()
@ -302,7 +301,7 @@ public class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFl
} }
@Test @Test
public void testSuccess_promotionNotActive() throws Exception { void testSuccess_promotionNotActive() throws Exception {
createTld("example"); createTld("example");
persistResource( persistResource(
new AllocationToken.Builder() new AllocationToken.Builder()
@ -324,7 +323,7 @@ public class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFl
} }
@Test @Test
public void testSuccess_promoTokenNotValidForTld() throws Exception { void testSuccess_promoTokenNotValidForTld() throws Exception {
createTld("example"); createTld("example");
persistResource( persistResource(
new AllocationToken.Builder() new AllocationToken.Builder()
@ -347,7 +346,7 @@ public class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFl
} }
@Test @Test
public void testSuccess_promoTokenNotValidForRegistrar() throws Exception { void testSuccess_promoTokenNotValidForRegistrar() throws Exception {
createTld("example"); createTld("example");
persistResource( persistResource(
new AllocationToken.Builder() new AllocationToken.Builder()
@ -370,7 +369,7 @@ public class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFl
} }
@Test @Test
public void testSuccess_oneReservedInSunrise() throws Exception { void testSuccess_oneReservedInSunrise() throws Exception {
createTld("tld", START_DATE_SUNRISE); createTld("tld", START_DATE_SUNRISE);
persistResource(Registry.get("tld").asBuilder().setReservedLists(createReservedList()).build()); persistResource(Registry.get("tld").asBuilder().setReservedLists(createReservedList()).build());
setEppInput("domain_check_one_tld_reserved.xml"); setEppInput("domain_check_one_tld_reserved.xml");
@ -382,7 +381,7 @@ public class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFl
} }
@Test @Test
public void testSuccess_twoReservedOutsideSunrise() throws Exception { void testSuccess_twoReservedOutsideSunrise() throws Exception {
setEppInput("domain_check_one_tld_reserved.xml"); setEppInput("domain_check_one_tld_reserved.xml");
doCheckTest( doCheckTest(
create(false, "reserved.tld", "Reserved"), create(false, "reserved.tld", "Reserved"),
@ -392,8 +391,7 @@ public class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFl
} }
@Test @Test
public void testSuccess_domainWithMultipleReservationType_useMostSevereMessage() void testSuccess_domainWithMultipleReservationType_useMostSevereMessage() throws Exception {
throws Exception {
persistResource( persistResource(
Registry.get("tld") Registry.get("tld")
.asBuilder() .asBuilder()
@ -410,13 +408,13 @@ public class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFl
} }
@Test @Test
public void testSuccess_anchorTenantReserved() throws Exception { void testSuccess_anchorTenantReserved() throws Exception {
setEppInput("domain_check_anchor.xml"); setEppInput("domain_check_anchor.xml");
doCheckTest(create(false, "anchor.tld", "Allocation token required")); doCheckTest(create(false, "anchor.tld", "Allocation token required"));
} }
@Test @Test
public void testSuccess_anchorTenantWithToken() throws Exception { void testSuccess_anchorTenantWithToken() throws Exception {
setEppInput("domain_check_anchor_allocationtoken.xml"); setEppInput("domain_check_anchor_allocationtoken.xml");
persistResource( persistResource(
new AllocationToken.Builder() new AllocationToken.Builder()
@ -428,7 +426,7 @@ public class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFl
} }
@Test @Test
public void testSuccess_multipartTld_oneReserved() throws Exception { void testSuccess_multipartTld_oneReserved() throws Exception {
createTld("tld.foo"); createTld("tld.foo");
persistResource( persistResource(
Registry.get("tld.foo") Registry.get("tld.foo")
@ -446,7 +444,7 @@ public class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFl
} }
@Test @Test
public void testSuccess_oneExistsButWasDeleted() throws Exception { void testSuccess_oneExistsButWasDeleted() throws Exception {
persistDeletedDomain("example1.tld", clock.nowUtc().minusDays(1)); persistDeletedDomain("example1.tld", clock.nowUtc().minusDays(1));
doCheckTest( doCheckTest(
create(true, "example1.tld", null), create(true, "example1.tld", null),
@ -455,7 +453,7 @@ public class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFl
} }
@Test @Test
public void testSuccess_duplicatesAllowed() throws Exception { void testSuccess_duplicatesAllowed() throws Exception {
setEppInput("domain_check_duplicates.xml"); setEppInput("domain_check_duplicates.xml");
doCheckTest( doCheckTest(
create(true, "example1.tld", null), create(true, "example1.tld", null),
@ -464,40 +462,40 @@ public class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFl
} }
@Test @Test
public void testSuccess_xmlMatches() throws Exception { void testSuccess_xmlMatches() throws Exception {
persistActiveDomain("example2.tld"); persistActiveDomain("example2.tld");
runFlowAssertResponse(loadFile("domain_check_one_tld_response.xml")); runFlowAssertResponse(loadFile("domain_check_one_tld_response.xml"));
} }
@Test @Test
public void testSuccess_50IdsAllowed() throws Exception { void testSuccess_50IdsAllowed() throws Exception {
// Make sure we don't have a regression that reduces the number of allowed checks. // Make sure we don't have a regression that reduces the number of allowed checks.
setEppInput("domain_check_50.xml"); setEppInput("domain_check_50.xml");
runFlow(); runFlow();
} }
@Test @Test
public void testSuccess_50IdsAllowed_withAllocationToken() throws Exception { void testSuccess_50IdsAllowed_withAllocationToken() throws Exception {
setEppInput("domain_check_50_allocationtoken.xml"); setEppInput("domain_check_50_allocationtoken.xml");
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_tooManyIds() { void testFailure_tooManyIds() {
setEppInput("domain_check_51.xml"); setEppInput("domain_check_51.xml");
EppException thrown = assertThrows(TooManyResourceChecksException.class, this::runFlow); EppException thrown = assertThrows(TooManyResourceChecksException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml(); assertAboutEppExceptions().that(thrown).marshalsToXml();
} }
@Test @Test
public void testFailure_wrongTld() { void testFailure_wrongTld() {
setEppInput("domain_check.xml"); setEppInput("domain_check.xml");
EppException thrown = assertThrows(TldDoesNotExistException.class, this::runFlow); EppException thrown = assertThrows(TldDoesNotExistException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml(); assertAboutEppExceptions().that(thrown).marshalsToXml();
} }
@Test @Test
public void testFailure_notAuthorizedForTld() { void testFailure_notAuthorizedForTld() {
persistResource( persistResource(
loadRegistrar("TheRegistrar").asBuilder().setAllowedTlds(ImmutableSet.of()).build()); loadRegistrar("TheRegistrar").asBuilder().setAllowedTlds(ImmutableSet.of()).build());
EppException thrown = assertThrows(NotAuthorizedForTldException.class, this::runFlow); EppException thrown = assertThrows(NotAuthorizedForTldException.class, this::runFlow);
@ -505,7 +503,7 @@ public class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFl
} }
@Test @Test
public void testSuccess_superuserNotAuthorizedForTld() throws Exception { void testSuccess_superuserNotAuthorizedForTld() throws Exception {
persistActiveDomain("example2.tld"); persistActiveDomain("example2.tld");
persistResource( persistResource(
loadRegistrar("TheRegistrar").asBuilder().setAllowedTlds(ImmutableSet.of()).build()); loadRegistrar("TheRegistrar").asBuilder().setAllowedTlds(ImmutableSet.of()).build());
@ -521,92 +519,92 @@ public class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFl
} }
@Test @Test
public void testFailure_uppercase() { void testFailure_uppercase() {
doFailingBadLabelTest("FOO.tld", BadDomainNameCharacterException.class); doFailingBadLabelTest("FOO.tld", BadDomainNameCharacterException.class);
} }
@Test @Test
public void testFailure_badCharacter() { void testFailure_badCharacter() {
doFailingBadLabelTest("test_example.tld", BadDomainNameCharacterException.class); doFailingBadLabelTest("test_example.tld", BadDomainNameCharacterException.class);
} }
@Test @Test
public void testFailure_leadingDash() { void testFailure_leadingDash() {
doFailingBadLabelTest("-example.tld", LeadingDashException.class); doFailingBadLabelTest("-example.tld", LeadingDashException.class);
} }
@Test @Test
public void testFailure_trailingDash() { void testFailure_trailingDash() {
doFailingBadLabelTest("example-.tld", TrailingDashException.class); doFailingBadLabelTest("example-.tld", TrailingDashException.class);
} }
@Test @Test
public void testFailure_tooLong() { void testFailure_tooLong() {
doFailingBadLabelTest(Strings.repeat("a", 64) + ".tld", DomainLabelTooLongException.class); doFailingBadLabelTest(Strings.repeat("a", 64) + ".tld", DomainLabelTooLongException.class);
} }
@Test @Test
public void testFailure_leadingDot() { void testFailure_leadingDot() {
doFailingBadLabelTest(".example.tld", EmptyDomainNamePartException.class); doFailingBadLabelTest(".example.tld", EmptyDomainNamePartException.class);
} }
@Test @Test
public void testFailure_leadingDotTld() { void testFailure_leadingDotTld() {
doFailingBadLabelTest("foo..tld", EmptyDomainNamePartException.class); doFailingBadLabelTest("foo..tld", EmptyDomainNamePartException.class);
} }
@Test @Test
public void testFailure_tooManyParts() { void testFailure_tooManyParts() {
doFailingBadLabelTest("foo.example.tld", BadDomainNamePartsCountException.class); doFailingBadLabelTest("foo.example.tld", BadDomainNamePartsCountException.class);
} }
@Test @Test
public void testFailure_tooFewParts() { void testFailure_tooFewParts() {
doFailingBadLabelTest("tld", BadDomainNamePartsCountException.class); doFailingBadLabelTest("tld", BadDomainNamePartsCountException.class);
} }
@Test @Test
public void testFailure_domainNameExistsAsTld_lowercase() { void testFailure_domainNameExistsAsTld_lowercase() {
createTlds("foo.tld", "tld"); createTlds("foo.tld", "tld");
doFailingBadLabelTest("foo.tld", DomainNameExistsAsTldException.class); doFailingBadLabelTest("foo.tld", DomainNameExistsAsTldException.class);
} }
@Test @Test
public void testFailure_domainNameExistsAsTld_uppercase() { void testFailure_domainNameExistsAsTld_uppercase() {
createTlds("foo.tld", "tld"); createTlds("foo.tld", "tld");
doFailingBadLabelTest("FOO.TLD", BadDomainNameCharacterException.class); doFailingBadLabelTest("FOO.TLD", BadDomainNameCharacterException.class);
} }
@Test @Test
public void testFailure_invalidPunycode() { void testFailure_invalidPunycode() {
doFailingBadLabelTest("xn--abcdefg.tld", InvalidPunycodeException.class); doFailingBadLabelTest("xn--abcdefg.tld", InvalidPunycodeException.class);
} }
@Test @Test
public void testFailure_dashesInThirdAndFourthPosition() { void testFailure_dashesInThirdAndFourthPosition() {
doFailingBadLabelTest("ab--cdefg.tld", DashesInThirdAndFourthException.class); doFailingBadLabelTest("ab--cdefg.tld", DashesInThirdAndFourthException.class);
} }
@Test @Test
public void testFailure_tldDoesNotExist() { void testFailure_tldDoesNotExist() {
doFailingBadLabelTest("foo.nosuchtld", TldDoesNotExistException.class); doFailingBadLabelTest("foo.nosuchtld", TldDoesNotExistException.class);
} }
@Test @Test
public void testFailure_invalidIdnCodePoints() { void testFailure_invalidIdnCodePoints() {
// .tld // .tld
doFailingBadLabelTest("xn--k3hel9n7bxlu1e.tld", InvalidIdnDomainLabelException.class); doFailingBadLabelTest("xn--k3hel9n7bxlu1e.tld", InvalidIdnDomainLabelException.class);
} }
@Test @Test
public void testFailure_predelegation() { void testFailure_predelegation() {
createTld("tld", PREDELEGATION); createTld("tld", PREDELEGATION);
EppException thrown = assertThrows(BadCommandForRegistryPhaseException.class, this::runFlow); EppException thrown = assertThrows(BadCommandForRegistryPhaseException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml(); assertAboutEppExceptions().that(thrown).marshalsToXml();
} }
@Test @Test
public void testAvailExtension() throws Exception { void testAvailExtension() throws Exception {
persistActiveDomain("example1.tld"); persistActiveDomain("example1.tld");
setEppInput("domain_check_avail.xml"); setEppInput("domain_check_avail.xml");
doCheckTest( doCheckTest(
@ -617,7 +615,7 @@ public class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFl
/** Test that premium names are shown as available even if the fee extension is not used. */ /** Test that premium names are shown as available even if the fee extension is not used. */
@Test @Test
public void testAvailExtension_premiumDomainsAreAvailableWithoutExtension() throws Exception { void testAvailExtension_premiumDomainsAreAvailableWithoutExtension() throws Exception {
createTld("example"); createTld("example");
setEppInput("domain_check_premium.xml"); setEppInput("domain_check_premium.xml");
doCheckTest(create(true, "rich.example", null)); doCheckTest(create(true, "rich.example", null));
@ -625,14 +623,14 @@ public class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFl
/** Test multiyear periods and explicitly correct currency and that the avail extension is ok. */ /** Test multiyear periods and explicitly correct currency and that the avail extension is ok. */
@Test @Test
public void testFeeExtension_v06() throws Exception { void testFeeExtension_v06() throws Exception {
persistActiveDomain("example1.tld"); persistActiveDomain("example1.tld");
setEppInput("domain_check_fee_v06.xml", ImmutableMap.of("CURRENCY", "USD")); setEppInput("domain_check_fee_v06.xml", ImmutableMap.of("CURRENCY", "USD"));
runFlowAssertResponse(loadFile("domain_check_fee_response_v06.xml")); runFlowAssertResponse(loadFile("domain_check_fee_response_v06.xml"));
} }
@Test @Test
public void testFeeExtension_multipleReservations() throws Exception { void testFeeExtension_multipleReservations() throws Exception {
persistResource( persistResource(
Registry.get("tld") Registry.get("tld")
.asBuilder() .asBuilder()
@ -645,21 +643,21 @@ public class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFl
} }
@Test @Test
public void testFeeExtension_v11() throws Exception { void testFeeExtension_v11() throws Exception {
persistActiveDomain("example1.tld"); persistActiveDomain("example1.tld");
setEppInput("domain_check_fee_v11.xml"); setEppInput("domain_check_fee_v11.xml");
runFlowAssertResponse(loadFile("domain_check_fee_response_v11.xml")); runFlowAssertResponse(loadFile("domain_check_fee_response_v11.xml"));
} }
@Test @Test
public void testFeeExtension_v12() throws Exception { void testFeeExtension_v12() throws Exception {
persistActiveDomain("example1.tld"); persistActiveDomain("example1.tld");
setEppInput("domain_check_fee_v12.xml"); setEppInput("domain_check_fee_v12.xml");
runFlowAssertResponse(loadFile("domain_check_fee_response_v12.xml")); runFlowAssertResponse(loadFile("domain_check_fee_response_v12.xml"));
} }
@Test @Test
public void testSuccess_thirtyDomains_restoreFees() throws Exception { void testSuccess_thirtyDomains_restoreFees() throws Exception {
// Note that 30 is more than 25, which is the maximum # of entity groups you can enlist in a // Note that 30 is more than 25, which is the maximum # of entity groups you can enlist in a
// single Datastore transaction (each DomainBase entity is in a separate entity group). // single Datastore transaction (each DomainBase entity is in a separate entity group).
// It's also pretty common for registrars to send large domain checks. // It's also pretty common for registrars to send large domain checks.
@ -676,7 +674,7 @@ public class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFl
* currency. * currency.
*/ */
@Test @Test
public void testFeeExtension_multipleCommands_v06() throws Exception { void testFeeExtension_multipleCommands_v06() throws Exception {
setEppInput("domain_check_fee_multiple_commands_v06.xml"); setEppInput("domain_check_fee_multiple_commands_v06.xml");
runFlowAssertResponse(loadFile("domain_check_fee_multiple_commands_response_v06.xml")); runFlowAssertResponse(loadFile("domain_check_fee_multiple_commands_response_v06.xml"));
} }
@ -684,21 +682,21 @@ public class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFl
// Version 11 cannot have multiple commands. // Version 11 cannot have multiple commands.
@Test @Test
public void testFeeExtension_multipleCommands_v12() throws Exception { void testFeeExtension_multipleCommands_v12() throws Exception {
setEppInput("domain_check_fee_multiple_commands_v12.xml"); setEppInput("domain_check_fee_multiple_commands_v12.xml");
runFlowAssertResponse(loadFile("domain_check_fee_multiple_commands_response_v12.xml")); runFlowAssertResponse(loadFile("domain_check_fee_multiple_commands_response_v12.xml"));
} }
/** Test the same as {@link #testFeeExtension_multipleCommands_v06} with premium labels. */ /** Test the same as {@link #testFeeExtension_multipleCommands_v06} with premium labels. */
@Test @Test
public void testFeeExtension_premiumLabels_v06() throws Exception { void testFeeExtension_premiumLabels_v06() throws Exception {
createTld("example"); createTld("example");
setEppInput("domain_check_fee_premium_v06.xml"); setEppInput("domain_check_fee_premium_v06.xml");
runFlowAssertResponse(loadFile("domain_check_fee_premium_response_v06.xml")); runFlowAssertResponse(loadFile("domain_check_fee_premium_response_v06.xml"));
} }
@Test @Test
public void testFeeExtension_premium_eap_v06() throws Exception { void testFeeExtension_premium_eap_v06() throws Exception {
createTld("example"); createTld("example");
setEppInput("domain_check_fee_premium_v06.xml"); setEppInput("domain_check_fee_premium_v06.xml");
clock.setTo(DateTime.parse("2010-01-01T10:00:00Z")); clock.setTo(DateTime.parse("2010-01-01T10:00:00Z"));
@ -718,7 +716,7 @@ public class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFl
} }
@Test @Test
public void testFeeExtension_premium_eap_v06_withRenewalOnRestore() throws Exception { void testFeeExtension_premium_eap_v06_withRenewalOnRestore() throws Exception {
createTld("example"); createTld("example");
setEppInput("domain_check_fee_premium_v06.xml"); setEppInput("domain_check_fee_premium_v06.xml");
clock.setTo(DateTime.parse("2010-01-01T10:00:00Z")); clock.setTo(DateTime.parse("2010-01-01T10:00:00Z"));
@ -739,35 +737,35 @@ public class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFl
} }
@Test @Test
public void testFeeExtension_premiumLabels_v11_create() throws Exception { void testFeeExtension_premiumLabels_v11_create() throws Exception {
createTld("example"); createTld("example");
setEppInput("domain_check_fee_premium_v11_create.xml"); setEppInput("domain_check_fee_premium_v11_create.xml");
runFlowAssertResponse(loadFile("domain_check_fee_premium_response_v11_create.xml")); runFlowAssertResponse(loadFile("domain_check_fee_premium_response_v11_create.xml"));
} }
@Test @Test
public void testFeeExtension_premiumLabels_v11_renew() throws Exception { void testFeeExtension_premiumLabels_v11_renew() throws Exception {
createTld("example"); createTld("example");
setEppInput("domain_check_fee_premium_v11_renew.xml"); setEppInput("domain_check_fee_premium_v11_renew.xml");
runFlowAssertResponse(loadFile("domain_check_fee_premium_response_v11_renew.xml")); runFlowAssertResponse(loadFile("domain_check_fee_premium_response_v11_renew.xml"));
} }
@Test @Test
public void testFeeExtension_premiumLabels_v11_transfer() throws Exception { void testFeeExtension_premiumLabels_v11_transfer() throws Exception {
createTld("example"); createTld("example");
setEppInput("domain_check_fee_premium_v11_transfer.xml"); setEppInput("domain_check_fee_premium_v11_transfer.xml");
runFlowAssertResponse(loadFile("domain_check_fee_premium_response_v11_transfer.xml")); runFlowAssertResponse(loadFile("domain_check_fee_premium_response_v11_transfer.xml"));
} }
@Test @Test
public void testFeeExtension_premiumLabels_v11_restore() throws Exception { void testFeeExtension_premiumLabels_v11_restore() throws Exception {
createTld("example"); createTld("example");
setEppInput("domain_check_fee_premium_v11_restore.xml"); setEppInput("domain_check_fee_premium_v11_restore.xml");
runFlowAssertResponse(loadFile("domain_check_fee_premium_response_v11_restore.xml")); runFlowAssertResponse(loadFile("domain_check_fee_premium_response_v11_restore.xml"));
} }
@Test @Test
public void testFeeExtension_premiumLabels_v11_restore_withRenewal() throws Exception { void testFeeExtension_premiumLabels_v11_restore_withRenewal() throws Exception {
setEppInput("domain_check_fee_premium_v11_restore.xml"); setEppInput("domain_check_fee_premium_v11_restore.xml");
createTld("example"); createTld("example");
persistPendingDeleteDomain("rich.example"); persistPendingDeleteDomain("rich.example");
@ -776,21 +774,21 @@ public class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFl
} }
@Test @Test
public void testFeeExtension_premiumLabels_v11_update() throws Exception { void testFeeExtension_premiumLabels_v11_update() throws Exception {
createTld("example"); createTld("example");
setEppInput("domain_check_fee_premium_v11_update.xml"); setEppInput("domain_check_fee_premium_v11_update.xml");
runFlowAssertResponse(loadFile("domain_check_fee_premium_response_v11_update.xml")); runFlowAssertResponse(loadFile("domain_check_fee_premium_response_v11_update.xml"));
} }
@Test @Test
public void testFeeExtension_premiumLabels_v12() throws Exception { void testFeeExtension_premiumLabels_v12() throws Exception {
createTld("example"); createTld("example");
setEppInput("domain_check_fee_premium_v12.xml"); setEppInput("domain_check_fee_premium_v12.xml");
runFlowAssertResponse(loadFile("domain_check_fee_premium_response_v12.xml")); runFlowAssertResponse(loadFile("domain_check_fee_premium_response_v12.xml"));
} }
@Test @Test
public void testFeeExtension_premiumLabels_v12_withRenewalOnRestore() throws Exception { void testFeeExtension_premiumLabels_v12_withRenewalOnRestore() throws Exception {
createTld("example"); createTld("example");
setEppInput("domain_check_fee_premium_v12.xml"); setEppInput("domain_check_fee_premium_v12.xml");
persistPendingDeleteDomain("rich.example"); persistPendingDeleteDomain("rich.example");
@ -798,7 +796,7 @@ public class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFl
} }
@Test @Test
public void testFeeExtension_fractionalCost() throws Exception { void testFeeExtension_fractionalCost() throws Exception {
// Note that the response xml expects to see "11.10" with two digits after the decimal point. // Note that the response xml expects to see "11.10" with two digits after the decimal point.
// This works because Money.getAmount(), used in the flow, returns a BigDecimal that is set to // This works because Money.getAmount(), used in the flow, returns a BigDecimal that is set to
// display the number of digits that is conventional for the given currency. // display the number of digits that is conventional for the given currency.
@ -813,7 +811,7 @@ public class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFl
/** Test that create fees are properly omitted/classed on names on reserved lists. */ /** Test that create fees are properly omitted/classed on names on reserved lists. */
@Test @Test
public void testFeeExtension_reservedName_v06() throws Exception { void testFeeExtension_reservedName_v06() throws Exception {
persistResource( persistResource(
Registry.get("tld") Registry.get("tld")
.asBuilder() .asBuilder()
@ -826,7 +824,7 @@ public class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFl
/** The tests must be split up for version 11, which allows only one command at a time. */ /** The tests must be split up for version 11, which allows only one command at a time. */
@Test @Test
public void testFeeExtension_reservedName_v11_create() throws Exception { void testFeeExtension_reservedName_v11_create() throws Exception {
persistResource( persistResource(
Registry.get("tld") Registry.get("tld")
.asBuilder() .asBuilder()
@ -838,7 +836,7 @@ public class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFl
} }
@Test @Test
public void testFeeExtension_reservedName_v11_renew() throws Exception { void testFeeExtension_reservedName_v11_renew() throws Exception {
persistResource( persistResource(
Registry.get("tld") Registry.get("tld")
.asBuilder() .asBuilder()
@ -850,7 +848,7 @@ public class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFl
} }
@Test @Test
public void testFeeExtension_reservedName_v11_transfer() throws Exception { void testFeeExtension_reservedName_v11_transfer() throws Exception {
persistResource( persistResource(
Registry.get("tld") Registry.get("tld")
.asBuilder() .asBuilder()
@ -862,7 +860,7 @@ public class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFl
} }
@Test @Test
public void testFeeExtension_reservedName_v11_restore() throws Exception { void testFeeExtension_reservedName_v11_restore() throws Exception {
persistResource( persistResource(
Registry.get("tld") Registry.get("tld")
.asBuilder() .asBuilder()
@ -874,7 +872,7 @@ public class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFl
} }
@Test @Test
public void testFeeExtension_reservedName_v11_restore_withRenewals() throws Exception { void testFeeExtension_reservedName_v11_restore_withRenewals() throws Exception {
persistResource( persistResource(
Registry.get("tld") Registry.get("tld")
.asBuilder() .asBuilder()
@ -891,7 +889,7 @@ public class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFl
} }
@Test @Test
public void testFeeExtension_reservedName_v12() throws Exception { void testFeeExtension_reservedName_v12() throws Exception {
persistResource( persistResource(
Registry.get("tld") Registry.get("tld")
.asBuilder() .asBuilder()
@ -903,7 +901,7 @@ public class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFl
} }
@Test @Test
public void testFeeExtension_feesNotOmittedOnReservedNamesInSunrise_v06() throws Exception { void testFeeExtension_feesNotOmittedOnReservedNamesInSunrise_v06() throws Exception {
createTld("tld", START_DATE_SUNRISE); createTld("tld", START_DATE_SUNRISE);
persistResource( persistResource(
Registry.get("tld") Registry.get("tld")
@ -916,7 +914,7 @@ public class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFl
} }
@Test @Test
public void testFeeExtension_feesNotOmittedOnReservedNamesInSunrise_v06_withRestoreRenewals() void testFeeExtension_feesNotOmittedOnReservedNamesInSunrise_v06_withRestoreRenewals()
throws Exception { throws Exception {
createTld("tld", START_DATE_SUNRISE); createTld("tld", START_DATE_SUNRISE);
persistResource( persistResource(
@ -935,8 +933,7 @@ public class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFl
} }
@Test @Test
public void testFeeExtension_feesNotOmittedOnReservedNamesInSunrise_v11_create() void testFeeExtension_feesNotOmittedOnReservedNamesInSunrise_v11_create() throws Exception {
throws Exception {
createTld("tld", START_DATE_SUNRISE); createTld("tld", START_DATE_SUNRISE);
persistResource( persistResource(
Registry.get("tld") Registry.get("tld")
@ -949,7 +946,7 @@ public class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFl
} }
@Test @Test
public void testFeeExtension_feesNotOmittedOnReservedNamesInSunrise_v11_renew() throws Exception { void testFeeExtension_feesNotOmittedOnReservedNamesInSunrise_v11_renew() throws Exception {
createTld("tld", START_DATE_SUNRISE); createTld("tld", START_DATE_SUNRISE);
persistResource( persistResource(
Registry.get("tld") Registry.get("tld")
@ -962,8 +959,7 @@ public class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFl
} }
@Test @Test
public void testFeeExtension_feesNotOmittedOnReservedNamesInSunrise_v11_transfer() void testFeeExtension_feesNotOmittedOnReservedNamesInSunrise_v11_transfer() throws Exception {
throws Exception {
createTld("tld", START_DATE_SUNRISE); createTld("tld", START_DATE_SUNRISE);
persistResource( persistResource(
Registry.get("tld") Registry.get("tld")
@ -976,8 +972,7 @@ public class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFl
} }
@Test @Test
public void testFeeExtension_feesNotOmittedOnReservedNamesInSunrise_v11_restore() void testFeeExtension_feesNotOmittedOnReservedNamesInSunrise_v11_restore() throws Exception {
throws Exception {
createTld("tld", START_DATE_SUNRISE); createTld("tld", START_DATE_SUNRISE);
persistResource( persistResource(
Registry.get("tld") Registry.get("tld")
@ -990,7 +985,7 @@ public class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFl
} }
@Test @Test
public void testFeeExtension_feesNotOmittedOnReservedNamesInSunrise_v12() throws Exception { void testFeeExtension_feesNotOmittedOnReservedNamesInSunrise_v12() throws Exception {
createTld("tld", START_DATE_SUNRISE); createTld("tld", START_DATE_SUNRISE);
persistResource( persistResource(
Registry.get("tld") Registry.get("tld")
@ -1003,91 +998,91 @@ public class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFl
} }
@Test @Test
public void testFeeExtension_wrongCurrency_v06() { void testFeeExtension_wrongCurrency_v06() {
setEppInput("domain_check_fee_euro_v06.xml"); setEppInput("domain_check_fee_euro_v06.xml");
EppException thrown = assertThrows(CurrencyUnitMismatchException.class, this::runFlow); EppException thrown = assertThrows(CurrencyUnitMismatchException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml(); assertAboutEppExceptions().that(thrown).marshalsToXml();
} }
@Test @Test
public void testFeeExtension_wrongCurrency_v11() { void testFeeExtension_wrongCurrency_v11() {
setEppInput("domain_check_fee_euro_v11.xml"); setEppInput("domain_check_fee_euro_v11.xml");
EppException thrown = assertThrows(CurrencyUnitMismatchException.class, this::runFlow); EppException thrown = assertThrows(CurrencyUnitMismatchException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml(); assertAboutEppExceptions().that(thrown).marshalsToXml();
} }
@Test @Test
public void testFeeExtension_wrongCurrency_v12() { void testFeeExtension_wrongCurrency_v12() {
setEppInput("domain_check_fee_euro_v12.xml"); setEppInput("domain_check_fee_euro_v12.xml");
EppException thrown = assertThrows(CurrencyUnitMismatchException.class, this::runFlow); EppException thrown = assertThrows(CurrencyUnitMismatchException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml(); assertAboutEppExceptions().that(thrown).marshalsToXml();
} }
@Test @Test
public void testFeeExtension_badCurrencyType() { void testFeeExtension_badCurrencyType() {
setEppInput("domain_check_fee_v06.xml", ImmutableMap.of("CURRENCY", "BAD")); setEppInput("domain_check_fee_v06.xml", ImmutableMap.of("CURRENCY", "BAD"));
EppException thrown = assertThrows(UnknownCurrencyEppException.class, this::runFlow); EppException thrown = assertThrows(UnknownCurrencyEppException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml(); assertAboutEppExceptions().that(thrown).marshalsToXml();
} }
@Test @Test
public void testFeeExtension_periodNotInYears_v06() { void testFeeExtension_periodNotInYears_v06() {
setEppInput("domain_check_fee_bad_period_v06.xml"); setEppInput("domain_check_fee_bad_period_v06.xml");
EppException thrown = assertThrows(BadPeriodUnitException.class, this::runFlow); EppException thrown = assertThrows(BadPeriodUnitException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml(); assertAboutEppExceptions().that(thrown).marshalsToXml();
} }
@Test @Test
public void testFeeExtension_periodNotInYears_v11() { void testFeeExtension_periodNotInYears_v11() {
setEppInput("domain_check_fee_bad_period_v11.xml"); setEppInput("domain_check_fee_bad_period_v11.xml");
EppException thrown = assertThrows(BadPeriodUnitException.class, this::runFlow); EppException thrown = assertThrows(BadPeriodUnitException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml(); assertAboutEppExceptions().that(thrown).marshalsToXml();
} }
@Test @Test
public void testFeeExtension_periodNotInYears_v12() { void testFeeExtension_periodNotInYears_v12() {
setEppInput("domain_check_fee_bad_period_v12.xml"); setEppInput("domain_check_fee_bad_period_v12.xml");
EppException thrown = assertThrows(BadPeriodUnitException.class, this::runFlow); EppException thrown = assertThrows(BadPeriodUnitException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml(); assertAboutEppExceptions().that(thrown).marshalsToXml();
} }
@Test @Test
public void testFeeExtension_commandWithPhase_v06() { void testFeeExtension_commandWithPhase_v06() {
setEppInput("domain_check_fee_command_phase_v06.xml"); setEppInput("domain_check_fee_command_phase_v06.xml");
EppException thrown = assertThrows(FeeChecksDontSupportPhasesException.class, this::runFlow); EppException thrown = assertThrows(FeeChecksDontSupportPhasesException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml(); assertAboutEppExceptions().that(thrown).marshalsToXml();
} }
@Test @Test
public void testFeeExtension_commandWithPhase_v11() { void testFeeExtension_commandWithPhase_v11() {
setEppInput("domain_check_fee_command_phase_v11.xml"); setEppInput("domain_check_fee_command_phase_v11.xml");
EppException thrown = assertThrows(FeeChecksDontSupportPhasesException.class, this::runFlow); EppException thrown = assertThrows(FeeChecksDontSupportPhasesException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml(); assertAboutEppExceptions().that(thrown).marshalsToXml();
} }
@Test @Test
public void testFeeExtension_commandWithPhase_v12() { void testFeeExtension_commandWithPhase_v12() {
setEppInput("domain_check_fee_command_phase_v12.xml"); setEppInput("domain_check_fee_command_phase_v12.xml");
EppException thrown = assertThrows(FeeChecksDontSupportPhasesException.class, this::runFlow); EppException thrown = assertThrows(FeeChecksDontSupportPhasesException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml(); assertAboutEppExceptions().that(thrown).marshalsToXml();
} }
@Test @Test
public void testFeeExtension_commandSubphase_v06() { void testFeeExtension_commandSubphase_v06() {
setEppInput("domain_check_fee_command_subphase_v06.xml"); setEppInput("domain_check_fee_command_subphase_v06.xml");
EppException thrown = assertThrows(FeeChecksDontSupportPhasesException.class, this::runFlow); EppException thrown = assertThrows(FeeChecksDontSupportPhasesException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml(); assertAboutEppExceptions().that(thrown).marshalsToXml();
} }
@Test @Test
public void testFeeExtension_commandSubphase_v11() { void testFeeExtension_commandSubphase_v11() {
setEppInput("domain_check_fee_command_subphase_v11.xml"); setEppInput("domain_check_fee_command_subphase_v11.xml");
EppException thrown = assertThrows(FeeChecksDontSupportPhasesException.class, this::runFlow); EppException thrown = assertThrows(FeeChecksDontSupportPhasesException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml(); assertAboutEppExceptions().that(thrown).marshalsToXml();
} }
@Test @Test
public void testFeeExtension_commandSubphase_v12() { void testFeeExtension_commandSubphase_v12() {
setEppInput("domain_check_fee_command_subphase_v12.xml"); setEppInput("domain_check_fee_command_subphase_v12.xml");
EppException thrown = assertThrows(FeeChecksDontSupportPhasesException.class, this::runFlow); EppException thrown = assertThrows(FeeChecksDontSupportPhasesException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml(); assertAboutEppExceptions().that(thrown).marshalsToXml();
@ -1095,7 +1090,7 @@ public class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFl
// This test is only relevant for v06, since domain names are not specified in v11 or v12. // This test is only relevant for v06, since domain names are not specified in v11 or v12.
@Test @Test
public void testFeeExtension_feeCheckNotInAvailabilityCheck() { void testFeeExtension_feeCheckNotInAvailabilityCheck() {
setEppInput("domain_check_fee_not_in_avail.xml"); setEppInput("domain_check_fee_not_in_avail.xml");
EppException thrown = EppException thrown =
assertThrows(OnlyCheckedNamesCanBeFeeCheckedException.class, this::runFlow); assertThrows(OnlyCheckedNamesCanBeFeeCheckedException.class, this::runFlow);
@ -1103,84 +1098,84 @@ public class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFl
} }
@Test @Test
public void testFeeExtension_multiyearRestore_v06() { void testFeeExtension_multiyearRestore_v06() {
setEppInput("domain_check_fee_multiyear_restore_v06.xml"); setEppInput("domain_check_fee_multiyear_restore_v06.xml");
EppException thrown = assertThrows(RestoresAreAlwaysForOneYearException.class, this::runFlow); EppException thrown = assertThrows(RestoresAreAlwaysForOneYearException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml(); assertAboutEppExceptions().that(thrown).marshalsToXml();
} }
@Test @Test
public void testFeeExtension_multiyearRestore_v11() { void testFeeExtension_multiyearRestore_v11() {
setEppInput("domain_check_fee_multiyear_restore_v11.xml"); setEppInput("domain_check_fee_multiyear_restore_v11.xml");
EppException thrown = assertThrows(RestoresAreAlwaysForOneYearException.class, this::runFlow); EppException thrown = assertThrows(RestoresAreAlwaysForOneYearException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml(); assertAboutEppExceptions().that(thrown).marshalsToXml();
} }
@Test @Test
public void testFeeExtension_multiyearRestore_v12() { void testFeeExtension_multiyearRestore_v12() {
setEppInput("domain_check_fee_multiyear_restore_v12.xml"); setEppInput("domain_check_fee_multiyear_restore_v12.xml");
EppException thrown = assertThrows(RestoresAreAlwaysForOneYearException.class, this::runFlow); EppException thrown = assertThrows(RestoresAreAlwaysForOneYearException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml(); assertAboutEppExceptions().that(thrown).marshalsToXml();
} }
@Test @Test
public void testFeeExtension_multiyearTransfer_v06() { void testFeeExtension_multiyearTransfer_v06() {
setEppInput("domain_check_fee_multiyear_transfer_v06.xml"); setEppInput("domain_check_fee_multiyear_transfer_v06.xml");
EppException thrown = assertThrows(TransfersAreAlwaysForOneYearException.class, this::runFlow); EppException thrown = assertThrows(TransfersAreAlwaysForOneYearException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml(); assertAboutEppExceptions().that(thrown).marshalsToXml();
} }
@Test @Test
public void testFeeExtension_multiyearTransfer_v11() { void testFeeExtension_multiyearTransfer_v11() {
setEppInput("domain_check_fee_multiyear_transfer_v11.xml"); setEppInput("domain_check_fee_multiyear_transfer_v11.xml");
EppException thrown = assertThrows(TransfersAreAlwaysForOneYearException.class, this::runFlow); EppException thrown = assertThrows(TransfersAreAlwaysForOneYearException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml(); assertAboutEppExceptions().that(thrown).marshalsToXml();
} }
@Test @Test
public void testFeeExtension_multiyearTransfer_v12() { void testFeeExtension_multiyearTransfer_v12() {
setEppInput("domain_check_fee_multiyear_transfer_v12.xml"); setEppInput("domain_check_fee_multiyear_transfer_v12.xml");
EppException thrown = assertThrows(TransfersAreAlwaysForOneYearException.class, this::runFlow); EppException thrown = assertThrows(TransfersAreAlwaysForOneYearException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml(); assertAboutEppExceptions().that(thrown).marshalsToXml();
} }
@Test @Test
public void testFeeExtension_unknownCommand_v06() { void testFeeExtension_unknownCommand_v06() {
setEppInput("domain_check_fee_unknown_command_v06.xml"); setEppInput("domain_check_fee_unknown_command_v06.xml");
EppException thrown = assertThrows(UnknownFeeCommandException.class, this::runFlow); EppException thrown = assertThrows(UnknownFeeCommandException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml(); assertAboutEppExceptions().that(thrown).marshalsToXml();
} }
@Test @Test
public void testFeeExtension_unknownCommand_v11() { void testFeeExtension_unknownCommand_v11() {
setEppInput("domain_check_fee_unknown_command_v11.xml"); setEppInput("domain_check_fee_unknown_command_v11.xml");
EppException thrown = assertThrows(UnknownFeeCommandException.class, this::runFlow); EppException thrown = assertThrows(UnknownFeeCommandException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml(); assertAboutEppExceptions().that(thrown).marshalsToXml();
} }
@Test @Test
public void testFeeExtension_unknownCommand_v12() { void testFeeExtension_unknownCommand_v12() {
setEppInput("domain_check_fee_unknown_command_v12.xml"); setEppInput("domain_check_fee_unknown_command_v12.xml");
EppException thrown = assertThrows(UnknownFeeCommandException.class, this::runFlow); EppException thrown = assertThrows(UnknownFeeCommandException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml(); assertAboutEppExceptions().that(thrown).marshalsToXml();
} }
@Test @Test
public void testFeeExtension_invalidCommand_v06() { void testFeeExtension_invalidCommand_v06() {
setEppInput("domain_check_fee_invalid_command_v06.xml"); setEppInput("domain_check_fee_invalid_command_v06.xml");
EppException thrown = assertThrows(UnknownFeeCommandException.class, this::runFlow); EppException thrown = assertThrows(UnknownFeeCommandException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml(); assertAboutEppExceptions().that(thrown).marshalsToXml();
} }
@Test @Test
public void testFeeExtension_invalidCommand_v11() { void testFeeExtension_invalidCommand_v11() {
setEppInput("domain_check_fee_invalid_command_v11.xml"); setEppInput("domain_check_fee_invalid_command_v11.xml");
EppException thrown = assertThrows(UnknownFeeCommandException.class, this::runFlow); EppException thrown = assertThrows(UnknownFeeCommandException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml(); assertAboutEppExceptions().that(thrown).marshalsToXml();
} }
@Test @Test
public void testFeeExtension_invalidCommand_v12() { void testFeeExtension_invalidCommand_v12() {
setEppInput("domain_check_fee_invalid_command_v12.xml"); setEppInput("domain_check_fee_invalid_command_v12.xml");
EppException thrown = assertThrows(UnknownFeeCommandException.class, this::runFlow); EppException thrown = assertThrows(UnknownFeeCommandException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml(); assertAboutEppExceptions().that(thrown).marshalsToXml();
@ -1205,35 +1200,35 @@ public class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFl
} }
@Test @Test
public void testSuccess_eapFeeCheck_v06() throws Exception { void testSuccess_eapFeeCheck_v06() throws Exception {
runEapFeeCheckTest("domain_check_fee_v06.xml", "domain_check_eap_fee_response_v06.xml"); runEapFeeCheckTest("domain_check_fee_v06.xml", "domain_check_eap_fee_response_v06.xml");
} }
@Test @Test
public void testSuccess_eapFeeCheck_v11() throws Exception { void testSuccess_eapFeeCheck_v11() throws Exception {
runEapFeeCheckTest("domain_check_fee_v11.xml", "domain_check_eap_fee_response_v11.xml"); runEapFeeCheckTest("domain_check_fee_v11.xml", "domain_check_eap_fee_response_v11.xml");
} }
@Test @Test
public void testSuccess_eapFeeCheck_v12() throws Exception { void testSuccess_eapFeeCheck_v12() throws Exception {
runEapFeeCheckTest("domain_check_fee_v12.xml", "domain_check_eap_fee_response_v12.xml"); runEapFeeCheckTest("domain_check_fee_v12.xml", "domain_check_eap_fee_response_v12.xml");
} }
@Test @Test
public void testSuccess_eapFeeCheck_date_v12() throws Exception { void testSuccess_eapFeeCheck_date_v12() throws Exception {
runEapFeeCheckTest( runEapFeeCheckTest(
"domain_check_fee_date_v12.xml", "domain_check_eap_fee_response_date_v12.xml"); "domain_check_fee_date_v12.xml", "domain_check_eap_fee_response_date_v12.xml");
} }
@Ignore @Disabled
@Test @Test
public void testSuccess_feeCheck_multipleRanges() { void testSuccess_feeCheck_multipleRanges() {
// TODO: If at some point we have more than one type of fees that are time dependent, populate // TODO: If at some point we have more than one type of fees that are time dependent, populate
// this test to test if the notAfter date is the earliest of the end points of the ranges. // this test to test if the notAfter date is the earliest of the end points of the ranges.
} }
@Test @Test
public void testIcannActivityReportField_getsLogged() throws Exception { void testIcannActivityReportField_getsLogged() throws Exception {
createTlds("com", "net", "org"); createTlds("com", "net", "org");
setEppInput("domain_check.xml"); setEppInput("domain_check.xml");
runFlow(); runFlow();

View file

@ -36,19 +36,19 @@ import google.registry.flows.exceptions.TooManyResourceChecksException;
import google.registry.model.domain.DomainBase; import google.registry.model.domain.DomainBase;
import google.registry.model.registry.Registry; import google.registry.model.registry.Registry;
import google.registry.model.registry.Registry.TldState; import google.registry.model.registry.Registry.TldState;
import org.junit.Before; import org.junit.jupiter.api.BeforeEach;
import org.junit.Test; import org.junit.jupiter.api.Test;
/** Unit tests for {@link DomainClaimsCheckFlow}. */ /** Unit tests for {@link DomainClaimsCheckFlow}. */
public class DomainClaimsCheckFlowTest public class DomainClaimsCheckFlowTest
extends ResourceFlowTestCase<DomainClaimsCheckFlow, DomainBase> { extends ResourceFlowTestCase<DomainClaimsCheckFlow, DomainBase> {
public DomainClaimsCheckFlowTest() { DomainClaimsCheckFlowTest() {
setEppInput("domain_check_claims.xml"); setEppInput("domain_check_claims.xml");
} }
@Before @BeforeEach
public void initCheckTest() { void initCheckTest() {
createTld("tld"); createTld("tld");
} }
@ -60,25 +60,25 @@ public class DomainClaimsCheckFlowTest
} }
@Test @Test
public void testSuccess_noClaims() throws Exception { void testSuccess_noClaims() throws Exception {
doSuccessfulTest("domain_check_claims_response_none.xml"); doSuccessfulTest("domain_check_claims_response_none.xml");
} }
@Test @Test
public void testSuccess_quietPeriod() throws Exception { void testSuccess_quietPeriod() throws Exception {
createTld("tld", TldState.QUIET_PERIOD); createTld("tld", TldState.QUIET_PERIOD);
doSuccessfulTest("domain_check_claims_response_none.xml"); doSuccessfulTest("domain_check_claims_response_none.xml");
} }
@Test @Test
public void testSuccess_oneClaim() throws Exception { void testSuccess_oneClaim() throws Exception {
persistClaimsList( persistClaimsList(
ImmutableMap.of("example2", "2013041500/2/6/9/rJ1NrDO92vDsAzf7EQzgjX4R0000000001")); ImmutableMap.of("example2", "2013041500/2/6/9/rJ1NrDO92vDsAzf7EQzgjX4R0000000001"));
doSuccessfulTest("domain_check_claims_response.xml"); doSuccessfulTest("domain_check_claims_response.xml");
} }
@Test @Test
public void testSuccess_multipleTlds() throws Exception { void testSuccess_multipleTlds() throws Exception {
setEppInput("domain_check_claims_multiple_tlds.xml"); setEppInput("domain_check_claims_multiple_tlds.xml");
createTld("tld1"); createTld("tld1");
createTld("tld2"); createTld("tld2");
@ -88,28 +88,28 @@ public class DomainClaimsCheckFlowTest
} }
@Test @Test
public void testSuccess_50IdsAllowed() throws Exception { void testSuccess_50IdsAllowed() throws Exception {
// Make sure we don't have a regression that reduces the number of allowed checks. // Make sure we don't have a regression that reduces the number of allowed checks.
setEppInput("domain_check_claims_50.xml"); setEppInput("domain_check_claims_50.xml");
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_TooManyIds() { void testFailure_TooManyIds() {
setEppInput("domain_check_claims_51.xml"); setEppInput("domain_check_claims_51.xml");
EppException thrown = assertThrows(TooManyResourceChecksException.class, this::runFlow); EppException thrown = assertThrows(TooManyResourceChecksException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml(); assertAboutEppExceptions().that(thrown).marshalsToXml();
} }
@Test @Test
public void testFailure_tldDoesntExist() { void testFailure_tldDoesntExist() {
setEppInput("domain_check_claims_bad_tld.xml"); setEppInput("domain_check_claims_bad_tld.xml");
EppException thrown = assertThrows(TldDoesNotExistException.class, this::runFlow); EppException thrown = assertThrows(TldDoesNotExistException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml(); assertAboutEppExceptions().that(thrown).marshalsToXml();
} }
@Test @Test
public void testFailure_notAuthorizedForTld() { void testFailure_notAuthorizedForTld() {
persistResource( persistResource(
loadRegistrar("TheRegistrar").asBuilder().setAllowedTlds(ImmutableSet.of()).build()); loadRegistrar("TheRegistrar").asBuilder().setAllowedTlds(ImmutableSet.of()).build());
EppException thrown = assertThrows(NotAuthorizedForTldException.class, this::runFlow); EppException thrown = assertThrows(NotAuthorizedForTldException.class, this::runFlow);
@ -117,7 +117,7 @@ public class DomainClaimsCheckFlowTest
} }
@Test @Test
public void testSuccess_superuserNotAuthorizedForTld() throws Exception { void testSuccess_superuserNotAuthorizedForTld() throws Exception {
persistClaimsList( persistClaimsList(
ImmutableMap.of("example2", "2013041500/2/6/9/rJ1NrDO92vDsAzf7EQzgjX4R0000000001")); ImmutableMap.of("example2", "2013041500/2/6/9/rJ1NrDO92vDsAzf7EQzgjX4R0000000001"));
persistResource( persistResource(
@ -130,7 +130,7 @@ public class DomainClaimsCheckFlowTest
} }
@Test @Test
public void testFailure_predelgation() { void testFailure_predelgation() {
createTld("tld", PREDELEGATION); createTld("tld", PREDELEGATION);
setEppInput("domain_check_claims.xml"); setEppInput("domain_check_claims.xml");
EppException thrown = assertThrows(BadCommandForRegistryPhaseException.class, this::runFlow); EppException thrown = assertThrows(BadCommandForRegistryPhaseException.class, this::runFlow);
@ -138,7 +138,7 @@ public class DomainClaimsCheckFlowTest
} }
@Test @Test
public void testFailure_allocationToken() { void testFailure_allocationToken() {
createTld("tld"); createTld("tld");
setEppInput("domain_check_claims_allocationtoken.xml"); setEppInput("domain_check_claims_allocationtoken.xml");
EppException thrown = EppException thrown =
@ -147,7 +147,7 @@ public class DomainClaimsCheckFlowTest
} }
@Test @Test
public void testFailure_multipleTlds_oneHasEndedClaims() { void testFailure_multipleTlds_oneHasEndedClaims() {
createTlds("tld1", "tld2"); createTlds("tld1", "tld2");
persistResource( persistResource(
Registry.get("tld2").asBuilder().setClaimsPeriodEnd(clock.nowUtc().minusMillis(1)).build()); Registry.get("tld2").asBuilder().setClaimsPeriodEnd(clock.nowUtc().minusMillis(1)).build());
@ -157,7 +157,7 @@ public class DomainClaimsCheckFlowTest
} }
@Test @Test
public void testIcannActivityReportField_getsLogged() throws Exception { void testIcannActivityReportField_getsLogged() throws Exception {
runFlow(); runFlow();
assertIcannReportingActivityFieldLogged("srs-dom-check"); assertIcannReportingActivityFieldLogged("srs-dom-check");
assertTldsFieldLogged("tld"); assertTldsFieldLogged("tld");

View file

@ -99,11 +99,11 @@ import java.util.Map;
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 DomainDeleteFlow}. */ /** Unit tests for {@link DomainDeleteFlow}. */
public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, DomainBase> { class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, DomainBase> {
private DomainBase domain; private DomainBase domain;
private HistoryEntry earlierHistoryEntry; private HistoryEntry earlierHistoryEntry;
@ -119,13 +119,13 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
private static final ImmutableMap<String, String> FEE_12_MAP = private static final ImmutableMap<String, String> FEE_12_MAP =
ImmutableMap.of("FEE_VERSION", "0.12", "FEE_NS", "fee12"); ImmutableMap.of("FEE_VERSION", "0.12", "FEE_NS", "fee12");
public DomainDeleteFlowTest() { DomainDeleteFlowTest() {
setEppInput("domain_delete.xml"); setEppInput("domain_delete.xml");
clock.setTo(TIME_BEFORE_FLOW); clock.setTo(TIME_BEFORE_FLOW);
} }
@Before @BeforeEach
public void initDomainTest() { void initDomainTest() {
createTld("tld"); createTld("tld");
} }
@ -261,7 +261,7 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
} }
@Test @Test
public void testSuccess_asyncActionsAreEnqueued() throws Exception { void testSuccess_asyncActionsAreEnqueued() throws Exception {
persistResource( persistResource(
Registry.get("tld") Registry.get("tld")
.asBuilder() .asBuilder()
@ -286,7 +286,7 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
} }
@Test @Test
public void testDryRun() throws Exception { void testDryRun() throws Exception {
setUpSuccessfulTest(); setUpSuccessfulTest();
setUpGracePeriods( setUpGracePeriods(
GracePeriod.create(GracePeriodStatus.ADD, TIME_BEFORE_FLOW.plusDays(1), "foo", null)); GracePeriod.create(GracePeriodStatus.ADD, TIME_BEFORE_FLOW.plusDays(1), "foo", null));
@ -294,7 +294,7 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
} }
@Test @Test
public void testDryRun_noGracePeriods() throws Exception { void testDryRun_noGracePeriods() throws Exception {
setUpSuccessfulTest(); setUpSuccessfulTest();
dryRunFlowAssertResponse(loadFile("domain_delete_response_pending.xml")); dryRunFlowAssertResponse(loadFile("domain_delete_response_pending.xml"));
} }
@ -329,7 +329,7 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
} }
@Test @Test
public void testSuccess_updatedEppUpdateTimeAfterPendingRedemption() throws Exception { void testSuccess_updatedEppUpdateTimeAfterPendingRedemption() throws Exception {
persistResource( persistResource(
Registry.get("tld") Registry.get("tld")
.asBuilder() .asBuilder()
@ -353,26 +353,26 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
} }
@Test @Test
public void testSuccess_addGracePeriodResultsInImmediateDelete() throws Exception { void testSuccess_addGracePeriodResultsInImmediateDelete() throws Exception {
sessionMetadata.setServiceExtensionUris(ImmutableSet.of()); sessionMetadata.setServiceExtensionUris(ImmutableSet.of());
doImmediateDeleteTest(GracePeriodStatus.ADD, "generic_success_response.xml"); doImmediateDeleteTest(GracePeriodStatus.ADD, "generic_success_response.xml");
} }
@Test @Test
public void testSuccess_addGracePeriodCredit_v06() throws Exception { void testSuccess_addGracePeriodCredit_v06() throws Exception {
removeServiceExtensionUri(ServiceExtension.FEE_0_11.getUri()); removeServiceExtensionUri(ServiceExtension.FEE_0_11.getUri());
removeServiceExtensionUri(ServiceExtension.FEE_0_12.getUri()); removeServiceExtensionUri(ServiceExtension.FEE_0_12.getUri());
doImmediateDeleteTest(GracePeriodStatus.ADD, "domain_delete_response_fee.xml", FEE_06_MAP); doImmediateDeleteTest(GracePeriodStatus.ADD, "domain_delete_response_fee.xml", FEE_06_MAP);
} }
@Test @Test
public void testSuccess_addGracePeriodCredit_v11() throws Exception { void testSuccess_addGracePeriodCredit_v11() throws Exception {
removeServiceExtensionUri(ServiceExtension.FEE_0_12.getUri()); removeServiceExtensionUri(ServiceExtension.FEE_0_12.getUri());
doImmediateDeleteTest(GracePeriodStatus.ADD, "domain_delete_response_fee.xml", FEE_11_MAP); doImmediateDeleteTest(GracePeriodStatus.ADD, "domain_delete_response_fee.xml", FEE_11_MAP);
} }
@Test @Test
public void testSuccess_addGracePeriodCredit_v12() throws Exception { void testSuccess_addGracePeriodCredit_v12() throws Exception {
doImmediateDeleteTest(GracePeriodStatus.ADD, "domain_delete_response_fee.xml", FEE_12_MAP); doImmediateDeleteTest(GracePeriodStatus.ADD, "domain_delete_response_fee.xml", FEE_12_MAP);
} }
@ -443,31 +443,31 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
} }
@Test @Test
public void testSuccess_noAddGracePeriodResultsInPendingDelete() throws Exception { void testSuccess_noAddGracePeriodResultsInPendingDelete() throws Exception {
sessionMetadata.setServiceExtensionUris(ImmutableSet.of()); sessionMetadata.setServiceExtensionUris(ImmutableSet.of());
doSuccessfulTest_noAddGracePeriod("domain_delete_response_pending.xml"); doSuccessfulTest_noAddGracePeriod("domain_delete_response_pending.xml");
} }
@Test @Test
public void testSuccess_renewGracePeriodCredit_v06() throws Exception { void testSuccess_renewGracePeriodCredit_v06() throws Exception {
removeServiceExtensionUri(ServiceExtension.FEE_0_11.getUri()); removeServiceExtensionUri(ServiceExtension.FEE_0_11.getUri());
removeServiceExtensionUri(ServiceExtension.FEE_0_12.getUri()); removeServiceExtensionUri(ServiceExtension.FEE_0_12.getUri());
doSuccessfulTest_noAddGracePeriod("domain_delete_response_pending_fee.xml", FEE_06_MAP); doSuccessfulTest_noAddGracePeriod("domain_delete_response_pending_fee.xml", FEE_06_MAP);
} }
@Test @Test
public void testSuccess_renewGracePeriodCredit_v11() throws Exception { void testSuccess_renewGracePeriodCredit_v11() throws Exception {
removeServiceExtensionUri(ServiceExtension.FEE_0_12.getUri()); removeServiceExtensionUri(ServiceExtension.FEE_0_12.getUri());
doSuccessfulTest_noAddGracePeriod("domain_delete_response_pending_fee.xml", FEE_11_MAP); doSuccessfulTest_noAddGracePeriod("domain_delete_response_pending_fee.xml", FEE_11_MAP);
} }
@Test @Test
public void testSuccess_renewGracePeriodCredit_v12() throws Exception { void testSuccess_renewGracePeriodCredit_v12() throws Exception {
doSuccessfulTest_noAddGracePeriod("domain_delete_response_pending_fee.xml", FEE_12_MAP); doSuccessfulTest_noAddGracePeriod("domain_delete_response_pending_fee.xml", FEE_12_MAP);
} }
@Test @Test
public void testSuccess_autorenewPollMessageIsNotDeleted() throws Exception { void testSuccess_autorenewPollMessageIsNotDeleted() throws Exception {
setUpSuccessfulTest(); setUpSuccessfulTest();
// Modify the autorenew poll message so that it has unacked messages in the past. This should // Modify the autorenew poll message so that it has unacked messages in the past. This should
// prevent it from being deleted when the domain is deleted. // prevent it from being deleted when the domain is deleted.
@ -489,7 +489,7 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
} }
@Test @Test
public void testSuccess_nonDefaultRedemptionGracePeriod() throws Exception { void testSuccess_nonDefaultRedemptionGracePeriod() throws Exception {
sessionMetadata.setServiceExtensionUris(ImmutableSet.of()); sessionMetadata.setServiceExtensionUris(ImmutableSet.of());
persistResource( persistResource(
Registry.get("tld") Registry.get("tld")
@ -500,7 +500,7 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
} }
@Test @Test
public void testSuccess_nonDefaultPendingDeleteLength() throws Exception { void testSuccess_nonDefaultPendingDeleteLength() throws Exception {
sessionMetadata.setServiceExtensionUris(ImmutableSet.of()); sessionMetadata.setServiceExtensionUris(ImmutableSet.of());
persistResource( persistResource(
Registry.get("tld") Registry.get("tld")
@ -511,7 +511,7 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
} }
@Test @Test
public void testSuccess_autoRenewGracePeriod_v06() throws Exception { void testSuccess_autoRenewGracePeriod_v06() throws Exception {
removeServiceExtensionUri(ServiceExtension.FEE_0_11.getUri()); removeServiceExtensionUri(ServiceExtension.FEE_0_11.getUri());
removeServiceExtensionUri(ServiceExtension.FEE_0_12.getUri()); removeServiceExtensionUri(ServiceExtension.FEE_0_12.getUri());
setUpAutorenewGracePeriod(); setUpAutorenewGracePeriod();
@ -520,7 +520,7 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
} }
@Test @Test
public void testSuccess_autoRenewGracePeriod_v11() throws Exception { void testSuccess_autoRenewGracePeriod_v11() throws Exception {
removeServiceExtensionUri(ServiceExtension.FEE_0_12.getUri()); removeServiceExtensionUri(ServiceExtension.FEE_0_12.getUri());
setUpAutorenewGracePeriod(); setUpAutorenewGracePeriod();
clock.advanceOneMilli(); clock.advanceOneMilli();
@ -528,14 +528,14 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
} }
@Test @Test
public void testSuccess_autoRenewGracePeriod_v12() throws Exception { void testSuccess_autoRenewGracePeriod_v12() throws Exception {
setUpAutorenewGracePeriod(); setUpAutorenewGracePeriod();
clock.advanceOneMilli(); clock.advanceOneMilli();
runFlowAssertResponse(loadFile("domain_delete_response_autorenew_fee.xml", FEE_12_MAP)); runFlowAssertResponse(loadFile("domain_delete_response_autorenew_fee.xml", FEE_12_MAP));
} }
@Test @Test
public void testSuccess_autoRenewGracePeriod_priceChanges_v06() throws Exception { void testSuccess_autoRenewGracePeriod_priceChanges_v06() throws Exception {
removeServiceExtensionUri(ServiceExtension.FEE_0_11.getUri()); removeServiceExtensionUri(ServiceExtension.FEE_0_11.getUri());
removeServiceExtensionUri(ServiceExtension.FEE_0_12.getUri()); removeServiceExtensionUri(ServiceExtension.FEE_0_12.getUri());
persistResource( persistResource(
@ -554,7 +554,7 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
} }
@Test @Test
public void testSuccess_autoRenewGracePeriod_priceChanges_v11() throws Exception { void testSuccess_autoRenewGracePeriod_priceChanges_v11() throws Exception {
removeServiceExtensionUri(ServiceExtension.FEE_0_12.getUri()); removeServiceExtensionUri(ServiceExtension.FEE_0_12.getUri());
persistResource( persistResource(
Registry.get("tld") Registry.get("tld")
@ -572,7 +572,7 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
} }
@Test @Test
public void testSuccess_autoRenewGracePeriod_priceChanges_v12() throws Exception { void testSuccess_autoRenewGracePeriod_priceChanges_v12() throws Exception {
persistResource( persistResource(
Registry.get("tld") Registry.get("tld")
.asBuilder() .asBuilder()
@ -589,7 +589,7 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
} }
@Test @Test
public void testSuccess_noPendingTransfer_deletedAndHasNoTransferData() throws Exception { void testSuccess_noPendingTransfer_deletedAndHasNoTransferData() throws Exception {
setClientIdForFlow("TheRegistrar"); setClientIdForFlow("TheRegistrar");
setUpSuccessfulTest(); setUpSuccessfulTest();
clock.advanceOneMilli(); clock.advanceOneMilli();
@ -599,7 +599,7 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
} }
@Test @Test
public void testSuccess_pendingTransfer() throws Exception { void testSuccess_pendingTransfer() throws Exception {
setClientIdForFlow("TheRegistrar"); setClientIdForFlow("TheRegistrar");
setUpSuccessfulTest(); setUpSuccessfulTest();
// Modify the domain we are testing to include a pending transfer. // Modify the domain we are testing to include a pending transfer.
@ -691,7 +691,7 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
} }
@Test @Test
public void testUnlinkingOfResources() throws Exception { void testUnlinkingOfResources() throws Exception {
sessionMetadata.setServiceExtensionUris(ImmutableSet.of()); sessionMetadata.setServiceExtensionUris(ImmutableSet.of());
setUpSuccessfulTest(); setUpSuccessfulTest();
// Persist the billing event so it can be retrieved for cancellation generation and checking. // Persist the billing event so it can be retrieved for cancellation generation and checking.
@ -726,7 +726,7 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
} }
@Test @Test
public void testSuccess_deletedSubordinateDomain() throws Exception { void testSuccess_deletedSubordinateDomain() throws Exception {
setUpSuccessfulTest(); setUpSuccessfulTest();
persistResource( persistResource(
newHostResource("ns1." + getUniqueIdFromCommand()) newHostResource("ns1." + getUniqueIdFromCommand())
@ -741,7 +741,7 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
} }
@Test @Test
public void testFailure_predelegation() throws Exception { void testFailure_predelegation() throws Exception {
createTld("tld", PREDELEGATION); createTld("tld", PREDELEGATION);
setUpSuccessfulTest(); setUpSuccessfulTest();
EppException thrown = assertThrows(BadCommandForRegistryPhaseException.class, this::runFlow); EppException thrown = assertThrows(BadCommandForRegistryPhaseException.class, this::runFlow);
@ -749,7 +749,7 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
} }
@Test @Test
public void testSuccess_superuserPredelegation() throws Exception { void testSuccess_superuserPredelegation() throws Exception {
createTld("tld", PREDELEGATION); createTld("tld", PREDELEGATION);
setUpSuccessfulTest(); setUpSuccessfulTest();
clock.advanceOneMilli(); clock.advanceOneMilli();
@ -758,14 +758,14 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
} }
@Test @Test
public void testFailure_neverExisted() throws Exception { void testFailure_neverExisted() throws Exception {
ResourceDoesNotExistException thrown = ResourceDoesNotExistException thrown =
assertThrows(ResourceDoesNotExistException.class, this::runFlow); assertThrows(ResourceDoesNotExistException.class, this::runFlow);
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand())); assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
} }
@Test @Test
public void testFailure_existedButWasDeleted() throws Exception { void testFailure_existedButWasDeleted() throws Exception {
persistDeletedDomain(getUniqueIdFromCommand(), clock.nowUtc().minusDays(1)); persistDeletedDomain(getUniqueIdFromCommand(), clock.nowUtc().minusDays(1));
ResourceDoesNotExistException thrown = ResourceDoesNotExistException thrown =
assertThrows(ResourceDoesNotExistException.class, this::runFlow); assertThrows(ResourceDoesNotExistException.class, this::runFlow);
@ -773,7 +773,7 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
} }
@Test @Test
public void testFailure_hasSubordinateHosts() throws Exception { void testFailure_hasSubordinateHosts() throws Exception {
DomainBase domain = persistActiveDomain(getUniqueIdFromCommand()); DomainBase domain = persistActiveDomain(getUniqueIdFromCommand());
HostResource subordinateHost = HostResource subordinateHost =
persistResource( persistResource(
@ -787,7 +787,7 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
} }
@Test @Test
public void testFailure_unauthorizedClient() throws Exception { void testFailure_unauthorizedClient() throws Exception {
sessionMetadata.setClientId("NewRegistrar"); sessionMetadata.setClientId("NewRegistrar");
persistActiveDomain(getUniqueIdFromCommand()); persistActiveDomain(getUniqueIdFromCommand());
EppException thrown = assertThrows(ResourceNotOwnedException.class, this::runFlow); EppException thrown = assertThrows(ResourceNotOwnedException.class, this::runFlow);
@ -795,7 +795,7 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
} }
@Test @Test
public void testSuccess_superuserUnauthorizedClient() throws Exception { void testSuccess_superuserUnauthorizedClient() throws Exception {
sessionMetadata.setClientId("NewRegistrar"); sessionMetadata.setClientId("NewRegistrar");
setUpSuccessfulTest(); setUpSuccessfulTest();
clock.advanceOneMilli(); clock.advanceOneMilli();
@ -804,7 +804,7 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
} }
@Test @Test
public void testFailure_notAuthorizedForTld() throws Exception { void testFailure_notAuthorizedForTld() throws Exception {
setUpSuccessfulTest(); setUpSuccessfulTest();
persistResource( persistResource(
loadRegistrar("TheRegistrar").asBuilder().setAllowedTlds(ImmutableSet.of()).build()); loadRegistrar("TheRegistrar").asBuilder().setAllowedTlds(ImmutableSet.of()).build());
@ -813,7 +813,7 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
} }
@Test @Test
public void testSuccess_superuserNotAuthorizedForTld() throws Exception { void testSuccess_superuserNotAuthorizedForTld() throws Exception {
setUpSuccessfulTest(); setUpSuccessfulTest();
persistResource( persistResource(
loadRegistrar("TheRegistrar").asBuilder().setAllowedTlds(ImmutableSet.of()).build()); loadRegistrar("TheRegistrar").asBuilder().setAllowedTlds(ImmutableSet.of()).build());
@ -823,7 +823,7 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
} }
@Test @Test
public void testFailure_clientDeleteProhibited() throws Exception { void testFailure_clientDeleteProhibited() throws Exception {
persistResource( persistResource(
newDomainBase(getUniqueIdFromCommand()) newDomainBase(getUniqueIdFromCommand())
.asBuilder() .asBuilder()
@ -835,7 +835,7 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
} }
@Test @Test
public void testFailure_serverDeleteProhibited() throws Exception { void testFailure_serverDeleteProhibited() throws Exception {
persistResource( persistResource(
newDomainBase(getUniqueIdFromCommand()) newDomainBase(getUniqueIdFromCommand())
.asBuilder() .asBuilder()
@ -847,7 +847,7 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
} }
@Test @Test
public void testFailure_pendingDelete() throws Exception { void testFailure_pendingDelete() throws Exception {
persistResource( persistResource(
newDomainBase(getUniqueIdFromCommand()) newDomainBase(getUniqueIdFromCommand())
.asBuilder() .asBuilder()
@ -859,7 +859,7 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
} }
@Test @Test
public void testSuccess_metadata() throws Exception { void testSuccess_metadata() throws Exception {
eppRequestSource = EppRequestSource.TOOL; eppRequestSource = EppRequestSource.TOOL;
setEppInput("domain_delete_metadata.xml"); setEppInput("domain_delete_metadata.xml");
setUpSuccessfulTest(); setUpSuccessfulTest();
@ -882,7 +882,7 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
} }
@Test @Test
public void testFailure_metadataNotFromTool() throws Exception { void testFailure_metadataNotFromTool() throws Exception {
setEppInput("domain_delete_metadata.xml"); setEppInput("domain_delete_metadata.xml");
persistResource(newDomainBase(getUniqueIdFromCommand())); persistResource(newDomainBase(getUniqueIdFromCommand()));
EppException thrown = assertThrows(OnlyToolCanPassMetadataException.class, this::runFlow); EppException thrown = assertThrows(OnlyToolCanPassMetadataException.class, this::runFlow);
@ -890,7 +890,7 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
} }
@Test @Test
public void testIcannActivityReportField_getsLogged() throws Exception { void testIcannActivityReportField_getsLogged() throws Exception {
setUpSuccessfulTest(); setUpSuccessfulTest();
clock.advanceOneMilli(); clock.advanceOneMilli();
runFlow(); runFlow();
@ -899,7 +899,7 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
} }
@Test @Test
public void testIcannTransactionRecord_testTld_notStored() throws Exception { void testIcannTransactionRecord_testTld_notStored() throws Exception {
setUpSuccessfulTest(); setUpSuccessfulTest();
setUpGracePeriodDurations(); setUpGracePeriodDurations();
persistResource(Registry.get("tld").asBuilder().setTldType(TldType.TEST).build()); persistResource(Registry.get("tld").asBuilder().setTldType(TldType.TEST).build());
@ -922,7 +922,7 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
} }
@Test @Test
public void testIcannTransactionRecord_noGrace_entryOutsideMaxGracePeriod() throws Exception { void testIcannTransactionRecord_noGrace_entryOutsideMaxGracePeriod() throws Exception {
setUpSuccessfulTest(); setUpSuccessfulTest();
setUpGracePeriodDurations(); setUpGracePeriodDurations();
clock.advanceOneMilli(); clock.advanceOneMilli();
@ -947,7 +947,7 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
} }
@Test @Test
public void testIcannTransactionRecord_noGrace_noAddOrRenewRecords() throws Exception { void testIcannTransactionRecord_noGrace_noAddOrRenewRecords() throws Exception {
setUpSuccessfulTest(); setUpSuccessfulTest();
setUpGracePeriodDurations(); setUpGracePeriodDurations();
clock.advanceOneMilli(); clock.advanceOneMilli();
@ -974,7 +974,7 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
/** Verifies that if there's no add grace period, we still cancel out valid renew records */ /** Verifies that if there's no add grace period, we still cancel out valid renew records */
@Test @Test
public void testIcannTransactionRecord_noGrace_hasRenewRecord() throws Exception { void testIcannTransactionRecord_noGrace_hasRenewRecord() throws Exception {
setUpSuccessfulTest(); setUpSuccessfulTest();
setUpGracePeriodDurations(); setUpGracePeriodDurations();
clock.advanceOneMilli(); clock.advanceOneMilli();
@ -1002,7 +1002,7 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
} }
@Test @Test
public void testIcannTransactionRecord_inGrace_noRecords() throws Exception { void testIcannTransactionRecord_inGrace_noRecords() throws Exception {
setUpSuccessfulTest(); setUpSuccessfulTest();
setUpGracePeriods( setUpGracePeriods(
GracePeriod.create( GracePeriod.create(
@ -1025,7 +1025,7 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
} }
@Test @Test
public void testIcannTransactionRecord_inGrace_multipleRecords() throws Exception { void testIcannTransactionRecord_inGrace_multipleRecords() throws Exception {
setUpSuccessfulTest(); setUpSuccessfulTest();
setUpGracePeriods( setUpGracePeriods(
GracePeriod.create( GracePeriod.create(
@ -1064,8 +1064,7 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
} }
@Test @Test
public void testSuccess_superuserExtension_nonZeroDayGrace_nonZeroDayPendingDelete() void testSuccess_superuserExtension_nonZeroDayGrace_nonZeroDayPendingDelete() throws Exception {
throws Exception {
eppRequestSource = EppRequestSource.TOOL; eppRequestSource = EppRequestSource.TOOL;
setEppInput( setEppInput(
"domain_delete_superuser_extension.xml", "domain_delete_superuser_extension.xml",
@ -1091,8 +1090,7 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
} }
@Test @Test
public void testSuccess_superuserExtension_zeroDayGrace_nonZeroDayPendingDelete() void testSuccess_superuserExtension_zeroDayGrace_nonZeroDayPendingDelete() throws Exception {
throws Exception {
eppRequestSource = EppRequestSource.TOOL; eppRequestSource = EppRequestSource.TOOL;
setEppInput( setEppInput(
"domain_delete_superuser_extension.xml", "domain_delete_superuser_extension.xml",
@ -1112,8 +1110,7 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
} }
@Test @Test
public void testSuccess_superuserExtension_nonZeroDayGrace_zeroDayPendingDelete() void testSuccess_superuserExtension_nonZeroDayGrace_zeroDayPendingDelete() throws Exception {
throws Exception {
eppRequestSource = EppRequestSource.TOOL; eppRequestSource = EppRequestSource.TOOL;
setEppInput( setEppInput(
"domain_delete_superuser_extension.xml", "domain_delete_superuser_extension.xml",
@ -1139,7 +1136,7 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
} }
@Test @Test
public void testSuccess_superuserExtension_zeroDayGrace_zeroDayPendingDelete() throws Exception { void testSuccess_superuserExtension_zeroDayGrace_zeroDayPendingDelete() throws Exception {
eppRequestSource = EppRequestSource.TOOL; eppRequestSource = EppRequestSource.TOOL;
setEppInput( setEppInput(
"domain_delete_superuser_extension.xml", "domain_delete_superuser_extension.xml",
@ -1154,7 +1151,7 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
} }
@Test @Test
public void testSuccess_immediateDelete_withSuperuserAndMetadataExtension() throws Exception { void testSuccess_immediateDelete_withSuperuserAndMetadataExtension() throws Exception {
eppRequestSource = EppRequestSource.TOOL; eppRequestSource = EppRequestSource.TOOL;
setEppInput( setEppInput(
"domain_delete_superuser_and_metadata_extension.xml", "domain_delete_superuser_and_metadata_extension.xml",
@ -1169,7 +1166,7 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
} }
@Test @Test
public void testFailure_allocationTokenNotSupportedOnDelete() { void testFailure_allocationTokenNotSupportedOnDelete() {
setEppInput("domain_delete_allocationtoken.xml"); setEppInput("domain_delete_allocationtoken.xml");
EppException thrown = assertThrows(UnimplementedExtensionException.class, this::runFlow); EppException thrown = assertThrows(UnimplementedExtensionException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml(); assertAboutEppExceptions().that(thrown).marshalsToXml();

View file

@ -33,25 +33,25 @@ import google.registry.flows.domain.DomainFlowUtils.TldDoesNotExistException;
import google.registry.flows.domain.DomainFlowUtils.TrailingDashException; import google.registry.flows.domain.DomainFlowUtils.TrailingDashException;
import google.registry.model.domain.DomainBase; import google.registry.model.domain.DomainBase;
import google.registry.testing.AppEngineRule; import google.registry.testing.AppEngineRule;
import org.junit.Before; import org.junit.jupiter.api.BeforeEach;
import org.junit.Test; import org.junit.jupiter.api.Test;
public class DomainFlowUtilsTest extends ResourceFlowTestCase<DomainInfoFlow, DomainBase> { class DomainFlowUtilsTest extends ResourceFlowTestCase<DomainInfoFlow, DomainBase> {
@Before @BeforeEach
public void setup() { void setup() {
setEppInput("domain_info.xml"); setEppInput("domain_info.xml");
createTld("tld"); createTld("tld");
persistResource(AppEngineRule.makeRegistrar1().asBuilder().build()); persistResource(AppEngineRule.makeRegistrar1().asBuilder().build());
} }
@Test @Test
public void testValidateDomainNameAcceptsValidName() throws EppException { void testValidateDomainNameAcceptsValidName() throws EppException {
assertThat(DomainFlowUtils.validateDomainName("example.tld")).isNotNull(); assertThat(DomainFlowUtils.validateDomainName("example.tld")).isNotNull();
} }
@Test @Test
public void testValidateDomainName_IllegalCharacters() { void testValidateDomainName_IllegalCharacters() {
BadDomainNameCharacterException thrown = BadDomainNameCharacterException thrown =
assertThrows( assertThrows(
BadDomainNameCharacterException.class, BadDomainNameCharacterException.class,
@ -63,7 +63,7 @@ public class DomainFlowUtilsTest extends ResourceFlowTestCase<DomainInfoFlow, Do
} }
@Test @Test
public void testValidateDomainName_DomainNameWithEmptyParts() { void testValidateDomainName_DomainNameWithEmptyParts() {
EmptyDomainNamePartException thrown = EmptyDomainNamePartException thrown =
assertThrows( assertThrows(
EmptyDomainNamePartException.class, EmptyDomainNamePartException.class,
@ -73,7 +73,7 @@ public class DomainFlowUtilsTest extends ResourceFlowTestCase<DomainInfoFlow, Do
} }
@Test @Test
public void testValidateDomainName_DomainNameWithLessThanTwoParts() { void testValidateDomainName_DomainNameWithLessThanTwoParts() {
BadDomainNamePartsCountException thrown = BadDomainNamePartsCountException thrown =
assertThrows( assertThrows(
BadDomainNamePartsCountException.class, BadDomainNamePartsCountException.class,
@ -85,7 +85,7 @@ public class DomainFlowUtilsTest extends ResourceFlowTestCase<DomainInfoFlow, Do
} }
@Test @Test
public void testValidateDomainName_invalidTLD() { void testValidateDomainName_invalidTLD() {
TldDoesNotExistException thrown = TldDoesNotExistException thrown =
assertThrows( assertThrows(
TldDoesNotExistException.class, TldDoesNotExistException.class,
@ -97,7 +97,7 @@ public class DomainFlowUtilsTest extends ResourceFlowTestCase<DomainInfoFlow, Do
} }
@Test @Test
public void testValidateDomainName_DomainNameIsTooLong() { void testValidateDomainName_DomainNameIsTooLong() {
DomainLabelTooLongException thrown = DomainLabelTooLongException thrown =
assertThrows( assertThrows(
DomainLabelTooLongException.class, DomainLabelTooLongException.class,
@ -111,7 +111,7 @@ public class DomainFlowUtilsTest extends ResourceFlowTestCase<DomainInfoFlow, Do
} }
@Test @Test
public void testValidateDomainName_leadingDash() { void testValidateDomainName_leadingDash() {
LeadingDashException thrown = LeadingDashException thrown =
assertThrows( assertThrows(
LeadingDashException.class, () -> DomainFlowUtils.validateDomainName("-example.foo")); LeadingDashException.class, () -> DomainFlowUtils.validateDomainName("-example.foo"));
@ -120,7 +120,7 @@ public class DomainFlowUtilsTest extends ResourceFlowTestCase<DomainInfoFlow, Do
} }
@Test @Test
public void testValidateDomainName_trailingDash() { void testValidateDomainName_trailingDash() {
TrailingDashException thrown = TrailingDashException thrown =
assertThrows( assertThrows(
TrailingDashException.class, () -> DomainFlowUtils.validateDomainName("example-.foo")); TrailingDashException.class, () -> DomainFlowUtils.validateDomainName("example-.foo"));
@ -129,7 +129,7 @@ public class DomainFlowUtilsTest extends ResourceFlowTestCase<DomainInfoFlow, Do
} }
@Test @Test
public void testValidateDomainName_invalidIDN() { void testValidateDomainName_invalidIDN() {
InvalidPunycodeException thrown = InvalidPunycodeException thrown =
assertThrows( assertThrows(
InvalidPunycodeException.class, InvalidPunycodeException.class,
@ -141,7 +141,7 @@ public class DomainFlowUtilsTest extends ResourceFlowTestCase<DomainInfoFlow, Do
} }
@Test @Test
public void testValidateDomainName_containsInvalidDashes() { void testValidateDomainName_containsInvalidDashes() {
DashesInThirdAndFourthException thrown = DashesInThirdAndFourthException thrown =
assertThrows( assertThrows(
DashesInThirdAndFourthException.class, DashesInThirdAndFourthException.class,

View file

@ -61,11 +61,11 @@ import google.registry.model.ofy.RequestCapturingAsyncDatastoreService;
import google.registry.model.registry.Registry; import google.registry.model.registry.Registry;
import google.registry.testing.AppEngineRule; import google.registry.testing.AppEngineRule;
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 DomainInfoFlow}. */ /** Unit tests for {@link DomainInfoFlow}. */
public class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, DomainBase> { class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, DomainBase> {
/** /**
* The domain_info_fee.xml default substitutions common to most tests. * The domain_info_fee.xml default substitutions common to most tests.
@ -86,8 +86,8 @@ public class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Dom
private HostResource host3; private HostResource host3;
private DomainBase domain; private DomainBase domain;
@Before @BeforeEach
public void setup() { void setup() {
setEppInput("domain_info.xml"); setEppInput("domain_info.xml");
sessionMetadata.setClientId("NewRegistrar"); sessionMetadata.setClientId("NewRegistrar");
clock.setTo(DateTime.parse("2005-03-03T22:00:00.000Z")); clock.setTo(DateTime.parse("2005-03-03T22:00:00.000Z"));
@ -174,87 +174,87 @@ public class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Dom
} }
@Test @Test
public void testSuccess_allHosts() throws Exception { void testSuccess_allHosts() throws Exception {
doSuccessfulTest("domain_info_response.xml"); doSuccessfulTest("domain_info_response.xml");
} }
@Test @Test
public void testSuccess_clTridNotSpecified() throws Exception { void testSuccess_clTridNotSpecified() throws Exception {
setEppInput("domain_info_no_cltrid.xml"); setEppInput("domain_info_no_cltrid.xml");
doSuccessfulTest("domain_info_response_no_cltrid.xml"); doSuccessfulTest("domain_info_response_no_cltrid.xml");
} }
@Test @Test
public void testSuccess_allHosts_noDelegatedHosts() throws Exception { void testSuccess_allHosts_noDelegatedHosts() throws Exception {
// There aren't any delegated hosts. // There aren't any delegated hosts.
doSuccessfulTestNoNameservers("domain_info_response_subordinate_hosts.xml"); doSuccessfulTestNoNameservers("domain_info_response_subordinate_hosts.xml");
} }
@Test @Test
public void testSuccess_defaultHosts() throws Exception { void testSuccess_defaultHosts() throws Exception {
setEppInput("domain_info_default_hosts.xml"); setEppInput("domain_info_default_hosts.xml");
doSuccessfulTest("domain_info_response.xml"); doSuccessfulTest("domain_info_response.xml");
} }
@Test @Test
public void testSuccess_defaultHosts_noDelegatedHosts() throws Exception { void testSuccess_defaultHosts_noDelegatedHosts() throws Exception {
setEppInput("domain_info_default_hosts.xml"); setEppInput("domain_info_default_hosts.xml");
// There aren't any delegated hosts. // There aren't any delegated hosts.
doSuccessfulTestNoNameservers("domain_info_response_subordinate_hosts.xml"); doSuccessfulTestNoNameservers("domain_info_response_subordinate_hosts.xml");
} }
@Test @Test
public void testSuccess_delegatedHosts() throws Exception { void testSuccess_delegatedHosts() throws Exception {
setEppInput("domain_info_delegated_hosts.xml"); setEppInput("domain_info_delegated_hosts.xml");
doSuccessfulTest("domain_info_response_delegated_hosts.xml"); doSuccessfulTest("domain_info_response_delegated_hosts.xml");
} }
@Test @Test
public void testSuccess_delegatedHosts_noDelegatedHosts() throws Exception { void testSuccess_delegatedHosts_noDelegatedHosts() throws Exception {
setEppInput("domain_info_delegated_hosts.xml"); setEppInput("domain_info_delegated_hosts.xml");
// There aren't any delegated hosts. // There aren't any delegated hosts.
doSuccessfulTestNoNameservers("domain_info_response_none_hosts.xml"); doSuccessfulTestNoNameservers("domain_info_response_none_hosts.xml");
} }
@Test @Test
public void testSuccess_subordinateHosts() throws Exception { void testSuccess_subordinateHosts() throws Exception {
setEppInput("domain_info_subordinate_hosts.xml"); setEppInput("domain_info_subordinate_hosts.xml");
doSuccessfulTest("domain_info_response_subordinate_hosts.xml"); doSuccessfulTest("domain_info_response_subordinate_hosts.xml");
} }
@Test @Test
public void testSuccess_subordinateHosts_noDelegatedHosts() throws Exception { void testSuccess_subordinateHosts_noDelegatedHosts() throws Exception {
setEppInput("domain_info_subordinate_hosts.xml"); setEppInput("domain_info_subordinate_hosts.xml");
doSuccessfulTestNoNameservers("domain_info_response_subordinate_hosts.xml"); doSuccessfulTestNoNameservers("domain_info_response_subordinate_hosts.xml");
} }
@Test @Test
public void testSuccess_noneHosts() throws Exception { void testSuccess_noneHosts() throws Exception {
setEppInput("domain_info_none_hosts.xml"); setEppInput("domain_info_none_hosts.xml");
doSuccessfulTest("domain_info_response_none_hosts.xml"); doSuccessfulTest("domain_info_response_none_hosts.xml");
} }
@Test @Test
public void testSuccess_noneHosts_noDelegatedHosts() throws Exception { void testSuccess_noneHosts_noDelegatedHosts() throws Exception {
setEppInput("domain_info_none_hosts.xml"); setEppInput("domain_info_none_hosts.xml");
doSuccessfulTestNoNameservers("domain_info_response_none_hosts.xml"); doSuccessfulTestNoNameservers("domain_info_response_none_hosts.xml");
} }
@Test @Test
public void testSuccess_unauthorized() throws Exception { void testSuccess_unauthorized() throws Exception {
sessionMetadata.setClientId("ClientZ"); sessionMetadata.setClientId("ClientZ");
doSuccessfulTest("domain_info_response_unauthorized.xml"); doSuccessfulTest("domain_info_response_unauthorized.xml");
} }
@Test @Test
public void testSuccess_differentRegistrarWithAuthInfo() throws Exception { void testSuccess_differentRegistrarWithAuthInfo() throws Exception {
setEppInput("domain_info_with_auth.xml"); setEppInput("domain_info_with_auth.xml");
sessionMetadata.setClientId("ClientZ"); sessionMetadata.setClientId("ClientZ");
doSuccessfulTest("domain_info_response.xml"); doSuccessfulTest("domain_info_response.xml");
} }
@Test @Test
public void testSuccess_differentRegistrarWithRegistrantAuthInfo() throws Exception { void testSuccess_differentRegistrarWithRegistrantAuthInfo() throws Exception {
persistTestEntities(false); persistTestEntities(false);
setEppInput("domain_info_with_contact_auth.xml"); setEppInput("domain_info_with_contact_auth.xml");
eppLoader.replaceAll("JD1234-REP", registrant.getRepoId()); eppLoader.replaceAll("JD1234-REP", registrant.getRepoId());
@ -263,7 +263,7 @@ public class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Dom
} }
@Test @Test
public void testSuccess_differentRegistrarWithContactAuthInfo() throws Exception { void testSuccess_differentRegistrarWithContactAuthInfo() throws Exception {
persistTestEntities(false); persistTestEntities(false);
setEppInput("domain_info_with_contact_auth.xml"); setEppInput("domain_info_with_contact_auth.xml");
eppLoader.replaceAll("JD1234-REP", registrant.getRepoId()); eppLoader.replaceAll("JD1234-REP", registrant.getRepoId());
@ -272,7 +272,7 @@ public class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Dom
} }
@Test @Test
public void testSuccess_inQuietPeriod() throws Exception { void testSuccess_inQuietPeriod() throws Exception {
persistResource( persistResource(
Registry.get("tld") Registry.get("tld")
.asBuilder() .asBuilder()
@ -282,7 +282,7 @@ public class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Dom
} }
@Test @Test
public void testSuccess_secDns() throws Exception { void testSuccess_secDns() throws Exception {
persistTestEntities(false); persistTestEntities(false);
// Add the dsData to the saved resource and change the nameservers to match the sample xml. // Add the dsData to the saved resource and change the nameservers to match the sample xml.
persistResource( persistResource(
@ -317,12 +317,12 @@ public class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Dom
} }
@Test @Test
public void testSuccess_addGracePeriod() throws Exception { void testSuccess_addGracePeriod() throws Exception {
doAddPeriodTest(GracePeriodStatus.ADD); doAddPeriodTest(GracePeriodStatus.ADD);
} }
@Test @Test
public void testSuccess_autoRenewGracePeriod() throws Exception { void testSuccess_autoRenewGracePeriod() throws Exception {
persistTestEntities(false); persistTestEntities(false);
// Add an AUTO_RENEW grace period to the saved resource. // Add an AUTO_RENEW grace period to the saved resource.
persistResource( persistResource(
@ -339,7 +339,7 @@ public class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Dom
} }
@Test @Test
public void testSuccess_redemptionGracePeriod() throws Exception { void testSuccess_redemptionGracePeriod() throws Exception {
persistTestEntities(false); persistTestEntities(false);
// Add an REDEMPTION grace period to the saved resource, and change a few other fields to match // Add an REDEMPTION grace period to the saved resource, and change a few other fields to match
// the sample xml. // the sample xml.
@ -355,7 +355,7 @@ public class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Dom
} }
@Test @Test
public void testSuccess_renewGracePeriod() throws Exception { void testSuccess_renewGracePeriod() throws Exception {
persistTestEntities(false); persistTestEntities(false);
// Add an RENEW grace period to the saved resource. // Add an RENEW grace period to the saved resource.
persistResource( persistResource(
@ -369,7 +369,7 @@ public class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Dom
} }
@Test @Test
public void testSuccess_multipleRenewGracePeriods() throws Exception { void testSuccess_multipleRenewGracePeriods() throws Exception {
persistTestEntities(false); persistTestEntities(false);
// Add multiple RENEW grace periods to the saved resource. // Add multiple RENEW grace periods to the saved resource.
persistResource( persistResource(
@ -386,7 +386,7 @@ public class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Dom
} }
@Test @Test
public void testSuccess_transferGracePeriod() throws Exception { void testSuccess_transferGracePeriod() throws Exception {
persistTestEntities(false); persistTestEntities(false);
// Add an TRANSFER grace period to the saved resource. // Add an TRANSFER grace period to the saved resource.
persistResource( persistResource(
@ -400,7 +400,7 @@ public class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Dom
} }
@Test @Test
public void testSuccess_pendingDelete() throws Exception { void testSuccess_pendingDelete() throws Exception {
persistTestEntities(false); persistTestEntities(false);
// Set the domain to be pending delete with no grace period, which will cause an RGP status of // Set the domain to be pending delete with no grace period, which will cause an RGP status of
// pending delete to show up, too. // pending delete to show up, too.
@ -410,7 +410,7 @@ public class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Dom
} }
@Test @Test
public void testSuccess_stackedAddRenewGracePeriods() throws Exception { void testSuccess_stackedAddRenewGracePeriods() throws Exception {
persistTestEntities(false); persistTestEntities(false);
// Add both an ADD and RENEW grace period, both which should show up in the RGP status. // Add both an ADD and RENEW grace period, both which should show up in the RGP status.
persistResource( persistResource(
@ -426,7 +426,7 @@ public class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Dom
} }
@Test @Test
public void testSuccess_secDnsAndAddGracePeriod() throws Exception { void testSuccess_secDnsAndAddGracePeriod() throws Exception {
persistTestEntities(false); persistTestEntities(false);
// Add both an ADD grace period and SecDNS data. // Add both an ADD grace period and SecDNS data.
persistResource( persistResource(
@ -443,14 +443,14 @@ public class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Dom
} }
@Test @Test
public void testFailure_neverExisted() throws Exception { void testFailure_neverExisted() throws Exception {
ResourceDoesNotExistException thrown = ResourceDoesNotExistException thrown =
assertThrows(ResourceDoesNotExistException.class, this::runFlow); assertThrows(ResourceDoesNotExistException.class, this::runFlow);
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand())); assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
} }
@Test @Test
public void testFailure_existedButWasDeleted() throws Exception { void testFailure_existedButWasDeleted() throws Exception {
persistResource( persistResource(
newDomainBase("example.tld") newDomainBase("example.tld")
.asBuilder() .asBuilder()
@ -462,7 +462,7 @@ public class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Dom
} }
@Test @Test
public void testFailure_differentRegistrarWrongAuthInfo() { void testFailure_differentRegistrarWrongAuthInfo() {
persistTestEntities(false); persistTestEntities(false);
// Change the password of the domain so that it does not match the file. // Change the password of the domain so that it does not match the file.
persistResource( persistResource(
@ -477,7 +477,7 @@ public class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Dom
} }
@Test @Test
public void testFailure_wrongAuthInfo() { void testFailure_wrongAuthInfo() {
persistTestEntities(false); persistTestEntities(false);
// Change the password of the domain so that it does not match the file. // Change the password of the domain so that it does not match the file.
persistResource( persistResource(
@ -491,7 +491,7 @@ public class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Dom
} }
@Test @Test
public void testFailure_differentRegistrarWrongRegistrantAuthInfo() { void testFailure_differentRegistrarWrongRegistrantAuthInfo() {
persistTestEntities(false); persistTestEntities(false);
// Change the password of the registrant so that it does not match the file. // Change the password of the registrant so that it does not match the file.
registrant = registrant =
@ -509,7 +509,7 @@ public class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Dom
} }
@Test @Test
public void testFailure_wrongRegistrantAuthInfo() { void testFailure_wrongRegistrantAuthInfo() {
persistTestEntities(false); persistTestEntities(false);
// Change the password of the registrant so that it does not match the file. // Change the password of the registrant so that it does not match the file.
registrant = registrant =
@ -526,7 +526,7 @@ public class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Dom
} }
@Test @Test
public void testFailure_differentRegistrarWrongContactAuthInfo() { void testFailure_differentRegistrarWrongContactAuthInfo() {
persistTestEntities(false); persistTestEntities(false);
// Change the password of the contact so that it does not match the file. // Change the password of the contact so that it does not match the file.
contact = contact =
@ -544,7 +544,7 @@ public class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Dom
} }
@Test @Test
public void testFailure_wrongContactAuthInfo() { void testFailure_wrongContactAuthInfo() {
persistTestEntities(false); persistTestEntities(false);
// Change the password of the contact so that it does not match the file. // Change the password of the contact so that it does not match the file.
contact = contact =
@ -561,7 +561,7 @@ public class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Dom
} }
@Test @Test
public void testFailure_differentRegistrarUnrelatedContactAuthInfo() { void testFailure_differentRegistrarUnrelatedContactAuthInfo() {
persistTestEntities(false); persistTestEntities(false);
ContactResource unrelatedContact = persistActiveContact("foo1234"); ContactResource unrelatedContact = persistActiveContact("foo1234");
sessionMetadata.setClientId("ClientZ"); sessionMetadata.setClientId("ClientZ");
@ -573,7 +573,7 @@ public class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Dom
} }
@Test @Test
public void testFailure_unrelatedContactAuthInfo() { void testFailure_unrelatedContactAuthInfo() {
persistTestEntities(false); persistTestEntities(false);
ContactResource unrelatedContact = persistActiveContact("foo1234"); ContactResource unrelatedContact = persistActiveContact("foo1234");
setEppInput("domain_info_with_contact_auth.xml"); setEppInput("domain_info_with_contact_auth.xml");
@ -588,7 +588,7 @@ public class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Dom
* info commands and responses, so we don't need to test the other versions. * info commands and responses, so we don't need to test the other versions.
*/ */
@Test @Test
public void testFeeExtension_createCommand() throws Exception { void testFeeExtension_createCommand() throws Exception {
setEppInput( setEppInput(
"domain_info_fee.xml", "domain_info_fee.xml",
updateSubstitutions( updateSubstitutions(
@ -608,7 +608,7 @@ public class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Dom
/** Test renew command. */ /** Test renew command. */
@Test @Test
public void testFeeExtension_renewCommand() throws Exception { void testFeeExtension_renewCommand() throws Exception {
setEppInput( setEppInput(
"domain_info_fee.xml", "domain_info_fee.xml",
updateSubstitutions( updateSubstitutions(
@ -628,7 +628,7 @@ public class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Dom
/** Test transfer command. */ /** Test transfer command. */
@Test @Test
public void testFeeExtension_transferCommand() throws Exception { void testFeeExtension_transferCommand() throws Exception {
setEppInput( setEppInput(
"domain_info_fee.xml", "domain_info_fee.xml",
updateSubstitutions( updateSubstitutions(
@ -648,7 +648,7 @@ public class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Dom
/** Test restore command. */ /** Test restore command. */
@Test @Test
public void testFeeExtension_restoreCommand() throws Exception { void testFeeExtension_restoreCommand() throws Exception {
setEppInput( setEppInput(
"domain_info_fee.xml", "domain_info_fee.xml",
updateSubstitutions( updateSubstitutions(
@ -660,7 +660,7 @@ public class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Dom
} }
@Test @Test
public void testFeeExtension_restoreCommand_pendingDelete_noRenewal() throws Exception { void testFeeExtension_restoreCommand_pendingDelete_noRenewal() throws Exception {
setEppInput( setEppInput(
"domain_info_fee.xml", "domain_info_fee.xml",
updateSubstitutions(SUBSTITUTION_BASE, "COMMAND", "restore", "PERIOD", "1")); updateSubstitutions(SUBSTITUTION_BASE, "COMMAND", "restore", "PERIOD", "1"));
@ -675,7 +675,7 @@ public class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Dom
} }
@Test @Test
public void testFeeExtension_restoreCommand_pendingDelete_withRenewal() throws Exception { void testFeeExtension_restoreCommand_pendingDelete_withRenewal() throws Exception {
createTld("example"); createTld("example");
setEppInput( setEppInput(
"domain_info_fee.xml", "domain_info_fee.xml",
@ -694,7 +694,7 @@ public class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Dom
/** Test create command on a premium label. */ /** Test create command on a premium label. */
@Test @Test
public void testFeeExtension_createCommandPremium() throws Exception { void testFeeExtension_createCommandPremium() throws Exception {
createTld("example"); createTld("example");
setEppInput( setEppInput(
"domain_info_fee.xml", "domain_info_fee.xml",
@ -712,7 +712,7 @@ public class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Dom
/** Test renew command on a premium label. */ /** Test renew command on a premium label. */
@Test @Test
public void testFeeExtension_renewCommandPremium() throws Exception { void testFeeExtension_renewCommandPremium() throws Exception {
createTld("example"); createTld("example");
setEppInput( setEppInput(
"domain_info_fee.xml", "domain_info_fee.xml",
@ -730,7 +730,7 @@ public class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Dom
/** Test transfer command on a premium label. */ /** Test transfer command on a premium label. */
@Test @Test
public void testFeeExtension_transferCommandPremium() throws Exception { void testFeeExtension_transferCommandPremium() throws Exception {
createTld("example"); createTld("example");
setEppInput( setEppInput(
"domain_info_fee.xml", "domain_info_fee.xml",
@ -748,7 +748,7 @@ public class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Dom
/** Test restore command on a premium label. */ /** Test restore command on a premium label. */
@Test @Test
public void testFeeExtension_restoreCommandPremium() throws Exception { void testFeeExtension_restoreCommandPremium() throws Exception {
createTld("example"); createTld("example");
setEppInput( setEppInput(
"domain_info_fee.xml", "domain_info_fee.xml",
@ -763,7 +763,7 @@ public class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Dom
/** Test setting the currency explicitly to a wrong value. */ /** Test setting the currency explicitly to a wrong value. */
@Test @Test
public void testFeeExtension_wrongCurrency() { void testFeeExtension_wrongCurrency() {
setEppInput( setEppInput(
"domain_info_fee.xml", "domain_info_fee.xml",
updateSubstitutions( updateSubstitutions(
@ -777,7 +777,7 @@ public class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Dom
} }
@Test @Test
public void testFeeExtension_unknownCurrency() { void testFeeExtension_unknownCurrency() {
setEppInput( setEppInput(
"domain_info_fee.xml", "domain_info_fee.xml",
updateSubstitutions( updateSubstitutions(
@ -791,7 +791,7 @@ public class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Dom
/** Test requesting a period that isn't in years. */ /** Test requesting a period that isn't in years. */
@Test @Test
public void testFeeExtension_periodNotInYears() { void testFeeExtension_periodNotInYears() {
setEppInput( setEppInput(
"domain_info_fee.xml", "domain_info_fee.xml",
updateSubstitutions( updateSubstitutions(
@ -806,7 +806,7 @@ public class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Dom
/** Test a command that specifies a phase. */ /** Test a command that specifies a phase. */
@Test @Test
public void testFeeExtension_commandPhase() { void testFeeExtension_commandPhase() {
setEppInput("domain_info_fee_command_phase.xml"); setEppInput("domain_info_fee_command_phase.xml");
persistTestEntities(false); persistTestEntities(false);
EppException thrown = assertThrows(FeeChecksDontSupportPhasesException.class, this::runFlow); EppException thrown = assertThrows(FeeChecksDontSupportPhasesException.class, this::runFlow);
@ -815,7 +815,7 @@ public class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Dom
/** Test a command that specifies a subphase. */ /** Test a command that specifies a subphase. */
@Test @Test
public void testFeeExtension_commandSubphase() { void testFeeExtension_commandSubphase() {
setEppInput("domain_info_fee_command_subphase.xml"); setEppInput("domain_info_fee_command_subphase.xml");
persistTestEntities(false); persistTestEntities(false);
EppException thrown = assertThrows(FeeChecksDontSupportPhasesException.class, this::runFlow); EppException thrown = assertThrows(FeeChecksDontSupportPhasesException.class, this::runFlow);
@ -824,7 +824,7 @@ public class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Dom
/** Test a restore for more than one year. */ /** Test a restore for more than one year. */
@Test @Test
public void testFeeExtension_multiyearRestore() { void testFeeExtension_multiyearRestore() {
setEppInput( setEppInput(
"domain_info_fee.xml", "domain_info_fee.xml",
updateSubstitutions( updateSubstitutions(
@ -838,7 +838,7 @@ public class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Dom
/** Test a transfer for more than one year. */ /** Test a transfer for more than one year. */
@Test @Test
public void testFeeExtension_multiyearTransfer() { void testFeeExtension_multiyearTransfer() {
setEppInput( setEppInput(
"domain_info_fee.xml", "domain_info_fee.xml",
updateSubstitutions( updateSubstitutions(
@ -852,7 +852,7 @@ public class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Dom
/** Test that we load contacts and hosts as a batch rather than individually. */ /** Test that we load contacts and hosts as a batch rather than individually. */
@Test @Test
public void testBatchLoadingOfReferences() throws Exception { void testBatchLoadingOfReferences() throws Exception {
persistTestEntities(false); persistTestEntities(false);
// Clear out the session cache so that we count actual Datastore calls. // Clear out the session cache so that we count actual Datastore calls.
ofy().clearSessionCache(); ofy().clearSessionCache();
@ -880,7 +880,7 @@ public class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Dom
} }
@Test @Test
public void testIcannActivityReportField_getsLogged() throws Exception { void testIcannActivityReportField_getsLogged() throws Exception {
persistTestEntities(false); persistTestEntities(false);
runFlow(); runFlow();
assertIcannReportingActivityFieldLogged("srs-dom-info"); assertIcannReportingActivityFieldLogged("srs-dom-info");

View file

@ -73,11 +73,11 @@ import java.util.Map;
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 DomainRenewFlow}. */ /** Unit tests for {@link DomainRenewFlow}. */
public class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, DomainBase> { class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, DomainBase> {
private static final ImmutableMap<String, String> FEE_BASE_MAP = private static final ImmutableMap<String, String> FEE_BASE_MAP =
ImmutableMap.of( ImmutableMap.of(
@ -94,10 +94,10 @@ public class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, D
private static final ImmutableMap<String, String> FEE_12_MAP = private static final ImmutableMap<String, String> FEE_12_MAP =
updateSubstitutions(FEE_BASE_MAP, "FEE_VERSION", "0.12", "FEE_NS", "fee12"); updateSubstitutions(FEE_BASE_MAP, "FEE_VERSION", "0.12", "FEE_NS", "fee12");
final DateTime expirationTime = DateTime.parse("2000-04-03T22:00:00.0Z"); private final DateTime expirationTime = DateTime.parse("2000-04-03T22:00:00.0Z");
@Before @BeforeEach
public void initDomainTest() { void initDomainTest() {
createTld("tld"); createTld("tld");
clock.setTo(expirationTime.minusMillis(2)); clock.setTo(expirationTime.minusMillis(2));
setEppInput("domain_renew.xml", ImmutableMap.of("DOMAIN", "example.tld", "YEARS", "5")); setEppInput("domain_renew.xml", ImmutableMap.of("DOMAIN", "example.tld", "YEARS", "5"));
@ -244,7 +244,7 @@ public class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, D
} }
@Test @Test
public void testDryRun() throws Exception { void testDryRun() throws Exception {
persistDomain(); persistDomain();
dryRunFlowAssertResponse( dryRunFlowAssertResponse(
loadFile( loadFile(
@ -253,7 +253,7 @@ public class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, D
} }
@Test @Test
public void testSuccess() throws Exception { void testSuccess() throws Exception {
persistDomain(); persistDomain();
doSuccessfulTest( doSuccessfulTest(
"domain_renew_response.xml", "domain_renew_response.xml",
@ -262,7 +262,7 @@ public class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, D
} }
@Test @Test
public void testSuccess_recurringClientIdIsSame_whenSuperuserOverridesRenewal() throws Exception { void testSuccess_recurringClientIdIsSame_whenSuperuserOverridesRenewal() throws Exception {
persistDomain(); persistDomain();
setClientIdForFlow("NewRegistrar"); setClientIdForFlow("NewRegistrar");
doSuccessfulTest( doSuccessfulTest(
@ -275,7 +275,7 @@ public class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, D
} }
@Test @Test
public void testSuccess_customLogicFee() throws Exception { void testSuccess_customLogicFee() throws Exception {
// The "costly-renew" domain has an additional RENEW fee of 100 from custom logic on top of the // The "costly-renew" domain has an additional RENEW fee of 100 from custom logic on top of the
// normal $11 standard renew price for this TLD. // normal $11 standard renew price for this TLD.
ImmutableMap<String, String> customFeeMap = ImmutableMap<String, String> customFeeMap =
@ -297,56 +297,56 @@ public class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, D
} }
@Test @Test
public void testSuccess_fee_v06() throws Exception { void testSuccess_fee_v06() throws Exception {
setEppInput("domain_renew_fee.xml", FEE_06_MAP); setEppInput("domain_renew_fee.xml", FEE_06_MAP);
persistDomain(); persistDomain();
doSuccessfulTest("domain_renew_response_fee.xml", 5, FEE_06_MAP); doSuccessfulTest("domain_renew_response_fee.xml", 5, FEE_06_MAP);
} }
@Test @Test
public void testSuccess_fee_v11() throws Exception { void testSuccess_fee_v11() throws Exception {
setEppInput("domain_renew_fee.xml", FEE_11_MAP); setEppInput("domain_renew_fee.xml", FEE_11_MAP);
persistDomain(); persistDomain();
doSuccessfulTest("domain_renew_response_fee.xml", 5, FEE_11_MAP); doSuccessfulTest("domain_renew_response_fee.xml", 5, FEE_11_MAP);
} }
@Test @Test
public void testSuccess_fee_v12() throws Exception { void testSuccess_fee_v12() throws Exception {
setEppInput("domain_renew_fee.xml", FEE_12_MAP); setEppInput("domain_renew_fee.xml", FEE_12_MAP);
persistDomain(); persistDomain();
doSuccessfulTest("domain_renew_response_fee.xml", 5, FEE_12_MAP); doSuccessfulTest("domain_renew_response_fee.xml", 5, FEE_12_MAP);
} }
@Test @Test
public void testSuccess_fee_withDefaultAttributes_v06() throws Exception { void testSuccess_fee_withDefaultAttributes_v06() throws Exception {
setEppInput("domain_renew_fee_defaults.xml", FEE_06_MAP); setEppInput("domain_renew_fee_defaults.xml", FEE_06_MAP);
persistDomain(); persistDomain();
doSuccessfulTest("domain_renew_response_fee.xml", 5, FEE_06_MAP); doSuccessfulTest("domain_renew_response_fee.xml", 5, FEE_06_MAP);
} }
@Test @Test
public void testSuccess_fee_withDefaultAttributes_v11() throws Exception { void testSuccess_fee_withDefaultAttributes_v11() throws Exception {
setEppInput("domain_renew_fee_defaults.xml", FEE_11_MAP); setEppInput("domain_renew_fee_defaults.xml", FEE_11_MAP);
persistDomain(); persistDomain();
doSuccessfulTest("domain_renew_response_fee.xml", 5, FEE_11_MAP); doSuccessfulTest("domain_renew_response_fee.xml", 5, FEE_11_MAP);
} }
@Test @Test
public void testSuccess_fee_withDefaultAttributes_v12() throws Exception { void testSuccess_fee_withDefaultAttributes_v12() throws Exception {
setEppInput("domain_renew_fee_defaults.xml", FEE_12_MAP); setEppInput("domain_renew_fee_defaults.xml", FEE_12_MAP);
persistDomain(); persistDomain();
doSuccessfulTest("domain_renew_response_fee.xml", 5, FEE_12_MAP); doSuccessfulTest("domain_renew_response_fee.xml", 5, FEE_12_MAP);
} }
@Test @Test
public void testFailure_fee_unknownCurrency() { void testFailure_fee_unknownCurrency() {
setEppInput("domain_renew_fee.xml", updateSubstitutions(FEE_06_MAP, "CURRENCY", "BAD")); setEppInput("domain_renew_fee.xml", updateSubstitutions(FEE_06_MAP, "CURRENCY", "BAD"));
EppException thrown = assertThrows(UnknownCurrencyEppException.class, this::persistDomain); EppException thrown = assertThrows(UnknownCurrencyEppException.class, this::persistDomain);
assertAboutEppExceptions().that(thrown).marshalsToXml(); assertAboutEppExceptions().that(thrown).marshalsToXml();
} }
@Test @Test
public void testFailure_refundableFee_v06() throws Exception { void testFailure_refundableFee_v06() throws Exception {
setEppInput("domain_renew_fee_refundable.xml", FEE_06_MAP); setEppInput("domain_renew_fee_refundable.xml", FEE_06_MAP);
persistDomain(); persistDomain();
EppException thrown = assertThrows(UnsupportedFeeAttributeException.class, this::runFlow); EppException thrown = assertThrows(UnsupportedFeeAttributeException.class, this::runFlow);
@ -354,7 +354,7 @@ public class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, D
} }
@Test @Test
public void testFailure_refundableFee_v11() throws Exception { void testFailure_refundableFee_v11() throws Exception {
setEppInput("domain_renew_fee_refundable.xml", FEE_11_MAP); setEppInput("domain_renew_fee_refundable.xml", FEE_11_MAP);
persistDomain(); persistDomain();
EppException thrown = assertThrows(UnsupportedFeeAttributeException.class, this::runFlow); EppException thrown = assertThrows(UnsupportedFeeAttributeException.class, this::runFlow);
@ -362,7 +362,7 @@ public class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, D
} }
@Test @Test
public void testFailure_refundableFee_v12() throws Exception { void testFailure_refundableFee_v12() throws Exception {
setEppInput("domain_renew_fee_refundable.xml", FEE_12_MAP); setEppInput("domain_renew_fee_refundable.xml", FEE_12_MAP);
persistDomain(); persistDomain();
EppException thrown = assertThrows(UnsupportedFeeAttributeException.class, this::runFlow); EppException thrown = assertThrows(UnsupportedFeeAttributeException.class, this::runFlow);
@ -370,7 +370,7 @@ public class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, D
} }
@Test @Test
public void testFailure_gracePeriodFee_v06() throws Exception { void testFailure_gracePeriodFee_v06() throws Exception {
setEppInput("domain_renew_fee_grace_period.xml", FEE_06_MAP); setEppInput("domain_renew_fee_grace_period.xml", FEE_06_MAP);
persistDomain(); persistDomain();
EppException thrown = assertThrows(UnsupportedFeeAttributeException.class, this::runFlow); EppException thrown = assertThrows(UnsupportedFeeAttributeException.class, this::runFlow);
@ -378,7 +378,7 @@ public class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, D
} }
@Test @Test
public void testFailure_gracePeriodFee_v11() throws Exception { void testFailure_gracePeriodFee_v11() throws Exception {
setEppInput("domain_renew_fee_grace_period.xml", FEE_11_MAP); setEppInput("domain_renew_fee_grace_period.xml", FEE_11_MAP);
persistDomain(); persistDomain();
EppException thrown = assertThrows(UnsupportedFeeAttributeException.class, this::runFlow); EppException thrown = assertThrows(UnsupportedFeeAttributeException.class, this::runFlow);
@ -386,7 +386,7 @@ public class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, D
} }
@Test @Test
public void testFailure_gracePeriodFee_v12() throws Exception { void testFailure_gracePeriodFee_v12() throws Exception {
setEppInput("domain_renew_fee_grace_period.xml", FEE_12_MAP); setEppInput("domain_renew_fee_grace_period.xml", FEE_12_MAP);
persistDomain(); persistDomain();
EppException thrown = assertThrows(UnsupportedFeeAttributeException.class, this::runFlow); EppException thrown = assertThrows(UnsupportedFeeAttributeException.class, this::runFlow);
@ -394,7 +394,7 @@ public class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, D
} }
@Test @Test
public void testFailure_appliedFee_v06() throws Exception { void testFailure_appliedFee_v06() throws Exception {
setEppInput("domain_renew_fee_applied.xml", FEE_06_MAP); setEppInput("domain_renew_fee_applied.xml", FEE_06_MAP);
persistDomain(); persistDomain();
EppException thrown = assertThrows(UnsupportedFeeAttributeException.class, this::runFlow); EppException thrown = assertThrows(UnsupportedFeeAttributeException.class, this::runFlow);
@ -402,7 +402,7 @@ public class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, D
} }
@Test @Test
public void testFailure_appliedFee_v11() throws Exception { void testFailure_appliedFee_v11() throws Exception {
setEppInput("domain_renew_fee_applied.xml", FEE_11_MAP); setEppInput("domain_renew_fee_applied.xml", FEE_11_MAP);
persistDomain(); persistDomain();
EppException thrown = assertThrows(UnsupportedFeeAttributeException.class, this::runFlow); EppException thrown = assertThrows(UnsupportedFeeAttributeException.class, this::runFlow);
@ -410,7 +410,7 @@ public class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, D
} }
@Test @Test
public void testFailure_appliedFee_v12() throws Exception { void testFailure_appliedFee_v12() throws Exception {
setEppInput("domain_renew_fee_applied.xml", FEE_12_MAP); setEppInput("domain_renew_fee_applied.xml", FEE_12_MAP);
persistDomain(); persistDomain();
EppException thrown = assertThrows(UnsupportedFeeAttributeException.class, this::runFlow); EppException thrown = assertThrows(UnsupportedFeeAttributeException.class, this::runFlow);
@ -418,17 +418,17 @@ public class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, D
} }
@Test @Test
public void testFailure_suspendedRegistrarCantRenewDomain() { void testFailure_suspendedRegistrarCantRenewDomain() {
doFailingTest_invalidRegistrarState(State.SUSPENDED); doFailingTest_invalidRegistrarState(State.SUSPENDED);
} }
@Test @Test
public void testFailure_pendingRegistrarCantRenewDomain() { void testFailure_pendingRegistrarCantRenewDomain() {
doFailingTest_invalidRegistrarState(State.PENDING); doFailingTest_invalidRegistrarState(State.PENDING);
} }
@Test @Test
public void testFailure_disabledRegistrarCantRenewDomain() { void testFailure_disabledRegistrarCantRenewDomain() {
doFailingTest_invalidRegistrarState(State.DISABLED); doFailingTest_invalidRegistrarState(State.DISABLED);
} }
@ -445,7 +445,7 @@ public class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, D
} }
@Test @Test
public void testSuccess_nonDefaultRenewGracePeriod() throws Exception { void testSuccess_nonDefaultRenewGracePeriod() throws Exception {
persistResource( persistResource(
Registry.get("tld") Registry.get("tld")
.asBuilder() .asBuilder()
@ -459,14 +459,14 @@ public class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, D
} }
@Test @Test
public void testSuccess_missingPeriod() throws Exception { void testSuccess_missingPeriod() throws Exception {
setEppInput("domain_renew_missing_period.xml"); setEppInput("domain_renew_missing_period.xml");
persistDomain(); persistDomain();
doSuccessfulTest("domain_renew_response_missing_period.xml", 1); doSuccessfulTest("domain_renew_response_missing_period.xml", 1);
} }
@Test @Test
public void testSuccess_autorenewPollMessageIsNotDeleted() throws Exception { void testSuccess_autorenewPollMessageIsNotDeleted() throws Exception {
persistDomain(); persistDomain();
// Modify the autorenew poll message so that it has an undelivered message in the past. // Modify the autorenew poll message so that it has an undelivered message in the past.
persistResource( persistResource(
@ -505,14 +505,14 @@ public class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, D
} }
@Test @Test
public void testFailure_neverExisted() throws Exception { void testFailure_neverExisted() throws Exception {
ResourceDoesNotExistException thrown = ResourceDoesNotExistException thrown =
assertThrows(ResourceDoesNotExistException.class, this::runFlow); assertThrows(ResourceDoesNotExistException.class, this::runFlow);
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand())); assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
} }
@Test @Test
public void testFailure_existedButWasDeleted() throws Exception { void testFailure_existedButWasDeleted() throws Exception {
persistDeletedDomain(getUniqueIdFromCommand(), clock.nowUtc().minusDays(1)); persistDeletedDomain(getUniqueIdFromCommand(), clock.nowUtc().minusDays(1));
ResourceDoesNotExistException thrown = ResourceDoesNotExistException thrown =
assertThrows(ResourceDoesNotExistException.class, this::runFlow); assertThrows(ResourceDoesNotExistException.class, this::runFlow);
@ -520,7 +520,7 @@ public class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, D
} }
@Test @Test
public void testFailure_clientRenewProhibited() throws Exception { void testFailure_clientRenewProhibited() throws Exception {
persistDomain(StatusValue.CLIENT_RENEW_PROHIBITED); persistDomain(StatusValue.CLIENT_RENEW_PROHIBITED);
ResourceStatusProhibitsOperationException thrown = ResourceStatusProhibitsOperationException thrown =
assertThrows(ResourceStatusProhibitsOperationException.class, this::runFlow); assertThrows(ResourceStatusProhibitsOperationException.class, this::runFlow);
@ -528,7 +528,7 @@ public class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, D
} }
@Test @Test
public void testFailure_serverRenewProhibited() throws Exception { void testFailure_serverRenewProhibited() throws Exception {
persistDomain(StatusValue.SERVER_RENEW_PROHIBITED); persistDomain(StatusValue.SERVER_RENEW_PROHIBITED);
ResourceStatusProhibitsOperationException thrown = ResourceStatusProhibitsOperationException thrown =
assertThrows(ResourceStatusProhibitsOperationException.class, this::runFlow); assertThrows(ResourceStatusProhibitsOperationException.class, this::runFlow);
@ -536,7 +536,7 @@ public class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, D
} }
@Test @Test
public void testFailure_pendingDelete() throws Exception { void testFailure_pendingDelete() throws Exception {
persistResource( persistResource(
newDomainBase(getUniqueIdFromCommand()) newDomainBase(getUniqueIdFromCommand())
.asBuilder() .asBuilder()
@ -550,7 +550,7 @@ public class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, D
} }
@Test @Test
public void testFailure_wrongFeeAmount_v06() throws Exception { void testFailure_wrongFeeAmount_v06() throws Exception {
setEppInput("domain_renew_fee.xml", FEE_06_MAP); setEppInput("domain_renew_fee.xml", FEE_06_MAP);
persistResource( persistResource(
Registry.get("tld") Registry.get("tld")
@ -563,7 +563,7 @@ public class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, D
} }
@Test @Test
public void testFailure_wrongFeeAmount_v11() throws Exception { void testFailure_wrongFeeAmount_v11() throws Exception {
setEppInput("domain_renew_fee.xml", FEE_11_MAP); setEppInput("domain_renew_fee.xml", FEE_11_MAP);
persistResource( persistResource(
Registry.get("tld") Registry.get("tld")
@ -576,7 +576,7 @@ public class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, D
} }
@Test @Test
public void testFailure_wrongFeeAmount_v12() throws Exception { void testFailure_wrongFeeAmount_v12() throws Exception {
setEppInput("domain_renew_fee.xml", FEE_12_MAP); setEppInput("domain_renew_fee.xml", FEE_12_MAP);
persistResource( persistResource(
Registry.get("tld") Registry.get("tld")
@ -589,7 +589,7 @@ public class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, D
} }
@Test @Test
public void testFailure_wrongCurrency_v06() throws Exception { void testFailure_wrongCurrency_v06() throws Exception {
setEppInput("domain_renew_fee.xml", FEE_06_MAP); setEppInput("domain_renew_fee.xml", FEE_06_MAP);
persistResource( persistResource(
Registry.get("tld") Registry.get("tld")
@ -607,7 +607,7 @@ public class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, D
} }
@Test @Test
public void testFailure_wrongCurrency_v11() throws Exception { void testFailure_wrongCurrency_v11() throws Exception {
setEppInput("domain_renew_fee.xml", FEE_11_MAP); setEppInput("domain_renew_fee.xml", FEE_11_MAP);
persistResource( persistResource(
Registry.get("tld") Registry.get("tld")
@ -625,7 +625,7 @@ public class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, D
} }
@Test @Test
public void testFailure_wrongCurrency_v12() throws Exception { void testFailure_wrongCurrency_v12() throws Exception {
setEppInput("domain_renew_fee.xml", FEE_12_MAP); setEppInput("domain_renew_fee.xml", FEE_12_MAP);
persistResource( persistResource(
Registry.get("tld") Registry.get("tld")
@ -643,7 +643,7 @@ public class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, D
} }
@Test @Test
public void testFailure_feeGivenInWrongScale_v06() throws Exception { void testFailure_feeGivenInWrongScale_v06() throws Exception {
setEppInput("domain_renew_fee_bad_scale.xml", FEE_06_MAP); setEppInput("domain_renew_fee_bad_scale.xml", FEE_06_MAP);
persistDomain(); persistDomain();
EppException thrown = assertThrows(CurrencyValueScaleException.class, this::runFlow); EppException thrown = assertThrows(CurrencyValueScaleException.class, this::runFlow);
@ -651,7 +651,7 @@ public class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, D
} }
@Test @Test
public void testFailure_feeGivenInWrongScale_v11() throws Exception { void testFailure_feeGivenInWrongScale_v11() throws Exception {
setEppInput("domain_renew_fee_bad_scale.xml", FEE_11_MAP); setEppInput("domain_renew_fee_bad_scale.xml", FEE_11_MAP);
persistDomain(); persistDomain();
EppException thrown = assertThrows(CurrencyValueScaleException.class, this::runFlow); EppException thrown = assertThrows(CurrencyValueScaleException.class, this::runFlow);
@ -659,7 +659,7 @@ public class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, D
} }
@Test @Test
public void testFailure_feeGivenInWrongScale_v12() throws Exception { void testFailure_feeGivenInWrongScale_v12() throws Exception {
setEppInput("domain_renew_fee_bad_scale.xml", FEE_12_MAP); setEppInput("domain_renew_fee_bad_scale.xml", FEE_12_MAP);
persistDomain(); persistDomain();
EppException thrown = assertThrows(CurrencyValueScaleException.class, this::runFlow); EppException thrown = assertThrows(CurrencyValueScaleException.class, this::runFlow);
@ -667,7 +667,7 @@ public class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, D
} }
@Test @Test
public void testFailure_pendingTransfer() throws Exception { void testFailure_pendingTransfer() throws Exception {
persistDomain(); persistDomain();
persistWithPendingTransfer( persistWithPendingTransfer(
reloadResourceByForeignKey() reloadResourceByForeignKey()
@ -680,7 +680,7 @@ public class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, D
} }
@Test @Test
public void testFailure_periodInMonths() throws Exception { void testFailure_periodInMonths() throws Exception {
setEppInput("domain_renew_months.xml"); setEppInput("domain_renew_months.xml");
persistDomain(); persistDomain();
EppException thrown = assertThrows(BadPeriodUnitException.class, this::runFlow); EppException thrown = assertThrows(BadPeriodUnitException.class, this::runFlow);
@ -688,7 +688,7 @@ public class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, D
} }
@Test @Test
public void testFailure_max10Years() throws Exception { void testFailure_max10Years() throws Exception {
setEppInput("domain_renew_11_years.xml"); setEppInput("domain_renew_11_years.xml");
persistDomain(); persistDomain();
EppException thrown = assertThrows(ExceedsMaxRegistrationYearsException.class, this::runFlow); EppException thrown = assertThrows(ExceedsMaxRegistrationYearsException.class, this::runFlow);
@ -696,7 +696,7 @@ public class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, D
} }
@Test @Test
public void testFailure_curExpDateMustMatch() throws Exception { void testFailure_curExpDateMustMatch() throws Exception {
persistDomain(); persistDomain();
// Note expiration time is off by one day. // Note expiration time is off by one day.
persistResource( persistResource(
@ -710,7 +710,7 @@ public class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, D
} }
@Test @Test
public void testFailure_unauthorizedClient() throws Exception { void testFailure_unauthorizedClient() throws Exception {
setClientIdForFlow("NewRegistrar"); setClientIdForFlow("NewRegistrar");
persistActiveDomain(getUniqueIdFromCommand()); persistActiveDomain(getUniqueIdFromCommand());
EppException thrown = assertThrows(ResourceNotOwnedException.class, this::runFlow); EppException thrown = assertThrows(ResourceNotOwnedException.class, this::runFlow);
@ -718,7 +718,7 @@ public class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, D
} }
@Test @Test
public void testSuccess_superuserUnauthorizedClient() throws Exception { void testSuccess_superuserUnauthorizedClient() throws Exception {
setClientIdForFlow("NewRegistrar"); setClientIdForFlow("NewRegistrar");
persistDomain(); persistDomain();
runFlowAssertResponse( runFlowAssertResponse(
@ -730,7 +730,7 @@ public class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, D
} }
@Test @Test
public void testFailure_notAuthorizedForTld() throws Exception { void testFailure_notAuthorizedForTld() throws Exception {
persistResource( persistResource(
loadRegistrar("TheRegistrar").asBuilder().setAllowedTlds(ImmutableSet.of()).build()); loadRegistrar("TheRegistrar").asBuilder().setAllowedTlds(ImmutableSet.of()).build());
persistDomain(); persistDomain();
@ -739,7 +739,7 @@ public class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, D
} }
@Test @Test
public void testSuccess_superuserNotAuthorizedForTld() throws Exception { void testSuccess_superuserNotAuthorizedForTld() throws Exception {
persistResource( persistResource(
loadRegistrar("TheRegistrar").asBuilder().setAllowedTlds(ImmutableSet.of()).build()); loadRegistrar("TheRegistrar").asBuilder().setAllowedTlds(ImmutableSet.of()).build());
persistDomain(); persistDomain();
@ -752,7 +752,7 @@ public class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, D
} }
@Test @Test
public void testFailure_feeNotProvidedOnPremiumName() throws Exception { void testFailure_feeNotProvidedOnPremiumName() throws Exception {
createTld("example"); createTld("example");
setEppInput("domain_renew_premium.xml"); setEppInput("domain_renew_premium.xml");
persistDomain(); persistDomain();
@ -761,7 +761,7 @@ public class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, D
} }
@Test @Test
public void testIcannActivityReportField_getsLogged() throws Exception { void testIcannActivityReportField_getsLogged() throws Exception {
persistDomain(); persistDomain();
runFlow(); runFlow();
assertIcannReportingActivityFieldLogged("srs-dom-renew"); assertIcannReportingActivityFieldLogged("srs-dom-renew");
@ -769,7 +769,7 @@ public class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, D
} }
@Test @Test
public void testIcannTransactionRecord_getsStored() throws Exception { void testIcannTransactionRecord_getsStored() throws Exception {
persistDomain(); persistDomain();
// Test with a nonstandard Renew period to ensure the reporting time is correct regardless // Test with a nonstandard Renew period to ensure the reporting time is correct regardless
persistResource( persistResource(

View file

@ -73,11 +73,11 @@ import google.registry.model.reporting.HistoryEntry;
import java.util.Map; import java.util.Map;
import org.joda.money.Money; import org.joda.money.Money;
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 DomainRestoreRequestFlow}. */ /** Unit tests for {@link DomainRestoreRequestFlow}. */
public class DomainRestoreRequestFlowTest class DomainRestoreRequestFlowTest
extends ResourceFlowTestCase<DomainRestoreRequestFlow, DomainBase> { extends ResourceFlowTestCase<DomainRestoreRequestFlow, DomainBase> {
private static final ImmutableMap<String, String> FEE_06_MAP = private static final ImmutableMap<String, String> FEE_06_MAP =
@ -87,8 +87,8 @@ public class DomainRestoreRequestFlowTest
private static final ImmutableMap<String, String> FEE_12_MAP = private static final ImmutableMap<String, String> FEE_12_MAP =
ImmutableMap.of("FEE_VERSION", "0.12", "FEE_NS", "fee12", "CURRENCY", "USD"); ImmutableMap.of("FEE_VERSION", "0.12", "FEE_NS", "fee12", "CURRENCY", "USD");
@Before @BeforeEach
public void initDomainTest() { void initDomainTest() {
createTld("tld"); createTld("tld");
setEppInput("domain_update_restore_request.xml", ImmutableMap.of("DOMAIN", "example.tld")); setEppInput("domain_update_restore_request.xml", ImmutableMap.of("DOMAIN", "example.tld"));
} }
@ -128,14 +128,14 @@ public class DomainRestoreRequestFlowTest
} }
@Test @Test
public void testDryRun() throws Exception { void testDryRun() throws Exception {
setEppInput("domain_update_restore_request.xml", ImmutableMap.of("DOMAIN", "example.tld")); setEppInput("domain_update_restore_request.xml", ImmutableMap.of("DOMAIN", "example.tld"));
persistPendingDeleteDomain(); persistPendingDeleteDomain();
dryRunFlowAssertResponse(loadFile("generic_success_response.xml")); dryRunFlowAssertResponse(loadFile("generic_success_response.xml"));
} }
@Test @Test
public void testSuccess_expiryStillInFuture_notExtended() throws Exception { void testSuccess_expiryStillInFuture_notExtended() throws Exception {
setEppInput("domain_update_restore_request.xml", ImmutableMap.of("DOMAIN", "example.tld")); setEppInput("domain_update_restore_request.xml", ImmutableMap.of("DOMAIN", "example.tld"));
DateTime expirationTime = clock.nowUtc().plusYears(5).plusDays(45); DateTime expirationTime = clock.nowUtc().plusYears(5).plusDays(45);
persistPendingDeleteDomain(expirationTime); persistPendingDeleteDomain(expirationTime);
@ -202,7 +202,7 @@ public class DomainRestoreRequestFlowTest
} }
@Test @Test
public void testSuccess_expiryInPast_extendedByOneYear() throws Exception { void testSuccess_expiryInPast_extendedByOneYear() throws Exception {
setEppInput("domain_update_restore_request.xml", ImmutableMap.of("DOMAIN", "example.tld")); setEppInput("domain_update_restore_request.xml", ImmutableMap.of("DOMAIN", "example.tld"));
DateTime expirationTime = clock.nowUtc().minusDays(20); DateTime expirationTime = clock.nowUtc().minusDays(20);
DateTime newExpirationTime = expirationTime.plusYears(1); DateTime newExpirationTime = expirationTime.plusYears(1);
@ -280,14 +280,14 @@ public class DomainRestoreRequestFlowTest
} }
@Test @Test
public void testSuccess_fee_v06() throws Exception { void testSuccess_fee_v06() throws Exception {
setEppInput("domain_update_restore_request_fee.xml", FEE_06_MAP); setEppInput("domain_update_restore_request_fee.xml", FEE_06_MAP);
persistPendingDeleteDomain(); persistPendingDeleteDomain();
runFlowAssertResponse(loadFile("domain_update_restore_request_response_fee.xml", FEE_06_MAP)); runFlowAssertResponse(loadFile("domain_update_restore_request_response_fee.xml", FEE_06_MAP));
} }
@Test @Test
public void testSuccess_fee_v06_noRenewal() throws Exception { void testSuccess_fee_v06_noRenewal() throws Exception {
setEppInput("domain_update_restore_request_fee_no_renewal.xml", FEE_06_MAP); setEppInput("domain_update_restore_request_fee_no_renewal.xml", FEE_06_MAP);
persistPendingDeleteDomain(clock.nowUtc().plusMonths(6)); persistPendingDeleteDomain(clock.nowUtc().plusMonths(6));
runFlowAssertResponse( runFlowAssertResponse(
@ -295,42 +295,42 @@ public class DomainRestoreRequestFlowTest
} }
@Test @Test
public void testSuccess_fee_v11() throws Exception { void testSuccess_fee_v11() throws Exception {
setEppInput("domain_update_restore_request_fee.xml", FEE_11_MAP); setEppInput("domain_update_restore_request_fee.xml", FEE_11_MAP);
persistPendingDeleteDomain(); persistPendingDeleteDomain();
runFlowAssertResponse(loadFile("domain_update_restore_request_response_fee.xml", FEE_11_MAP)); runFlowAssertResponse(loadFile("domain_update_restore_request_response_fee.xml", FEE_11_MAP));
} }
@Test @Test
public void testSuccess_fee_v12() throws Exception { void testSuccess_fee_v12() throws Exception {
setEppInput("domain_update_restore_request_fee.xml", FEE_12_MAP); setEppInput("domain_update_restore_request_fee.xml", FEE_12_MAP);
persistPendingDeleteDomain(); persistPendingDeleteDomain();
runFlowAssertResponse(loadFile("domain_update_restore_request_response_fee.xml", FEE_12_MAP)); runFlowAssertResponse(loadFile("domain_update_restore_request_response_fee.xml", FEE_12_MAP));
} }
@Test @Test
public void testSuccess_fee_withDefaultAttributes_v06() throws Exception { void testSuccess_fee_withDefaultAttributes_v06() throws Exception {
setEppInput("domain_update_restore_request_fee_defaults.xml", FEE_06_MAP); setEppInput("domain_update_restore_request_fee_defaults.xml", FEE_06_MAP);
persistPendingDeleteDomain(); persistPendingDeleteDomain();
runFlowAssertResponse(loadFile("domain_update_restore_request_response_fee.xml", FEE_06_MAP)); runFlowAssertResponse(loadFile("domain_update_restore_request_response_fee.xml", FEE_06_MAP));
} }
@Test @Test
public void testSuccess_fee_withDefaultAttributes_v11() throws Exception { void testSuccess_fee_withDefaultAttributes_v11() throws Exception {
setEppInput("domain_update_restore_request_fee_defaults.xml", FEE_11_MAP); setEppInput("domain_update_restore_request_fee_defaults.xml", FEE_11_MAP);
persistPendingDeleteDomain(); persistPendingDeleteDomain();
runFlowAssertResponse(loadFile("domain_update_restore_request_response_fee.xml", FEE_11_MAP)); runFlowAssertResponse(loadFile("domain_update_restore_request_response_fee.xml", FEE_11_MAP));
} }
@Test @Test
public void testSuccess_fee_withDefaultAttributes_v12() throws Exception { void testSuccess_fee_withDefaultAttributes_v12() throws Exception {
setEppInput("domain_update_restore_request_fee_defaults.xml", FEE_12_MAP); setEppInput("domain_update_restore_request_fee_defaults.xml", FEE_12_MAP);
persistPendingDeleteDomain(); persistPendingDeleteDomain();
runFlowAssertResponse(loadFile("domain_update_restore_request_response_fee.xml", FEE_12_MAP)); runFlowAssertResponse(loadFile("domain_update_restore_request_response_fee.xml", FEE_12_MAP));
} }
@Test @Test
public void testFailure_fee_unknownCurrency() { void testFailure_fee_unknownCurrency() {
ImmutableMap<String, String> substitutions = ImmutableMap<String, String> substitutions =
ImmutableMap.of("FEE_VERSION", "0.12", "FEE_NS", "fee12", "CURRENCY", "BAD"); ImmutableMap.of("FEE_VERSION", "0.12", "FEE_NS", "fee12", "CURRENCY", "BAD");
setEppInput("domain_update_restore_request_fee.xml", substitutions); setEppInput("domain_update_restore_request_fee.xml", substitutions);
@ -340,7 +340,7 @@ public class DomainRestoreRequestFlowTest
} }
@Test @Test
public void testFailure_refundableFee_v06() throws Exception { void testFailure_refundableFee_v06() throws Exception {
setEppInput("domain_update_restore_request_fee_refundable.xml", FEE_06_MAP); setEppInput("domain_update_restore_request_fee_refundable.xml", FEE_06_MAP);
persistPendingDeleteDomain(); persistPendingDeleteDomain();
EppException thrown = assertThrows(UnsupportedFeeAttributeException.class, this::runFlow); EppException thrown = assertThrows(UnsupportedFeeAttributeException.class, this::runFlow);
@ -348,7 +348,7 @@ public class DomainRestoreRequestFlowTest
} }
@Test @Test
public void testFailure_refundableFee_v11() throws Exception { void testFailure_refundableFee_v11() throws Exception {
setEppInput("domain_update_restore_request_fee_refundable.xml", FEE_11_MAP); setEppInput("domain_update_restore_request_fee_refundable.xml", FEE_11_MAP);
persistPendingDeleteDomain(); persistPendingDeleteDomain();
EppException thrown = assertThrows(UnsupportedFeeAttributeException.class, this::runFlow); EppException thrown = assertThrows(UnsupportedFeeAttributeException.class, this::runFlow);
@ -356,7 +356,7 @@ public class DomainRestoreRequestFlowTest
} }
@Test @Test
public void testFailure_refundableFee_v12() throws Exception { void testFailure_refundableFee_v12() throws Exception {
setEppInput("domain_update_restore_request_fee_refundable.xml", FEE_12_MAP); setEppInput("domain_update_restore_request_fee_refundable.xml", FEE_12_MAP);
persistPendingDeleteDomain(); persistPendingDeleteDomain();
EppException thrown = assertThrows(UnsupportedFeeAttributeException.class, this::runFlow); EppException thrown = assertThrows(UnsupportedFeeAttributeException.class, this::runFlow);
@ -364,7 +364,7 @@ public class DomainRestoreRequestFlowTest
} }
@Test @Test
public void testFailure_gracePeriodFee_v06() throws Exception { void testFailure_gracePeriodFee_v06() throws Exception {
setEppInput("domain_update_restore_request_fee_grace_period.xml", FEE_06_MAP); setEppInput("domain_update_restore_request_fee_grace_period.xml", FEE_06_MAP);
persistPendingDeleteDomain(); persistPendingDeleteDomain();
EppException thrown = assertThrows(UnsupportedFeeAttributeException.class, this::runFlow); EppException thrown = assertThrows(UnsupportedFeeAttributeException.class, this::runFlow);
@ -372,7 +372,7 @@ public class DomainRestoreRequestFlowTest
} }
@Test @Test
public void testFailure_gracePeriodFee_v11() throws Exception { void testFailure_gracePeriodFee_v11() throws Exception {
setEppInput("domain_update_restore_request_fee_grace_period.xml", FEE_11_MAP); setEppInput("domain_update_restore_request_fee_grace_period.xml", FEE_11_MAP);
persistPendingDeleteDomain(); persistPendingDeleteDomain();
EppException thrown = assertThrows(UnsupportedFeeAttributeException.class, this::runFlow); EppException thrown = assertThrows(UnsupportedFeeAttributeException.class, this::runFlow);
@ -380,7 +380,7 @@ public class DomainRestoreRequestFlowTest
} }
@Test @Test
public void testFailure_gracePeriodFee_v12() throws Exception { void testFailure_gracePeriodFee_v12() throws Exception {
setEppInput("domain_update_restore_request_fee_grace_period.xml", FEE_12_MAP); setEppInput("domain_update_restore_request_fee_grace_period.xml", FEE_12_MAP);
persistPendingDeleteDomain(); persistPendingDeleteDomain();
EppException thrown = assertThrows(UnsupportedFeeAttributeException.class, this::runFlow); EppException thrown = assertThrows(UnsupportedFeeAttributeException.class, this::runFlow);
@ -388,7 +388,7 @@ public class DomainRestoreRequestFlowTest
} }
@Test @Test
public void testFailure_appliedFee_v06() throws Exception { void testFailure_appliedFee_v06() throws Exception {
setEppInput("domain_update_restore_request_fee_applied.xml", FEE_06_MAP); setEppInput("domain_update_restore_request_fee_applied.xml", FEE_06_MAP);
persistPendingDeleteDomain(); persistPendingDeleteDomain();
EppException thrown = assertThrows(UnsupportedFeeAttributeException.class, this::runFlow); EppException thrown = assertThrows(UnsupportedFeeAttributeException.class, this::runFlow);
@ -396,7 +396,7 @@ public class DomainRestoreRequestFlowTest
} }
@Test @Test
public void testFailure_appliedFee_v11() throws Exception { void testFailure_appliedFee_v11() throws Exception {
setEppInput("domain_update_restore_request_fee_applied.xml", FEE_11_MAP); setEppInput("domain_update_restore_request_fee_applied.xml", FEE_11_MAP);
persistPendingDeleteDomain(); persistPendingDeleteDomain();
EppException thrown = assertThrows(UnsupportedFeeAttributeException.class, this::runFlow); EppException thrown = assertThrows(UnsupportedFeeAttributeException.class, this::runFlow);
@ -404,7 +404,7 @@ public class DomainRestoreRequestFlowTest
} }
@Test @Test
public void testFailure_appliedFee_v12() throws Exception { void testFailure_appliedFee_v12() throws Exception {
setEppInput("domain_update_restore_request_fee_applied.xml", FEE_12_MAP); setEppInput("domain_update_restore_request_fee_applied.xml", FEE_12_MAP);
persistPendingDeleteDomain(); persistPendingDeleteDomain();
EppException thrown = assertThrows(UnsupportedFeeAttributeException.class, this::runFlow); EppException thrown = assertThrows(UnsupportedFeeAttributeException.class, this::runFlow);
@ -412,7 +412,7 @@ public class DomainRestoreRequestFlowTest
} }
@Test @Test
public void testSuccess_premiumNotBlocked() throws Exception { void testSuccess_premiumNotBlocked() throws Exception {
createTld("example"); createTld("example");
setEppInput("domain_update_restore_request_premium.xml"); setEppInput("domain_update_restore_request_premium.xml");
persistPendingDeleteDomain(); persistPendingDeleteDomain();
@ -420,7 +420,7 @@ public class DomainRestoreRequestFlowTest
} }
@Test @Test
public void testSuccess_premiumNotBlocked_andNoRenewal() throws Exception { void testSuccess_premiumNotBlocked_andNoRenewal() throws Exception {
createTld("example"); createTld("example");
setEppInput("domain_update_restore_request_premium_no_renewal.xml"); setEppInput("domain_update_restore_request_premium_no_renewal.xml");
persistPendingDeleteDomain(clock.nowUtc().plusYears(2)); persistPendingDeleteDomain(clock.nowUtc().plusYears(2));
@ -429,7 +429,7 @@ public class DomainRestoreRequestFlowTest
} }
@Test @Test
public void testSuccess_superuserOverridesReservedList() throws Exception { void testSuccess_superuserOverridesReservedList() throws Exception {
persistResource( persistResource(
Registry.get("tld") Registry.get("tld")
.asBuilder() .asBuilder()
@ -441,7 +441,7 @@ public class DomainRestoreRequestFlowTest
} }
@Test @Test
public void testSuccess_superuserOverridesPremiumNameBlock() throws Exception { void testSuccess_superuserOverridesPremiumNameBlock() throws Exception {
createTld("example"); createTld("example");
setEppInput("domain_update_restore_request_premium.xml"); setEppInput("domain_update_restore_request_premium.xml");
persistPendingDeleteDomain(); persistPendingDeleteDomain();
@ -454,7 +454,7 @@ public class DomainRestoreRequestFlowTest
} }
@Test @Test
public void testFailure_doesNotExist() throws Exception { void testFailure_doesNotExist() throws Exception {
ResourceDoesNotExistException thrown = ResourceDoesNotExistException thrown =
assertThrows(ResourceDoesNotExistException.class, this::runFlow); assertThrows(ResourceDoesNotExistException.class, this::runFlow);
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand())); assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
@ -462,7 +462,7 @@ public class DomainRestoreRequestFlowTest
} }
@Test @Test
public void testFailure_suspendedRegistrarCantRestoreDomain() { void testFailure_suspendedRegistrarCantRestoreDomain() {
persistResource( persistResource(
Registrar.loadByClientId("TheRegistrar") Registrar.loadByClientId("TheRegistrar")
.get() .get()
@ -475,7 +475,7 @@ public class DomainRestoreRequestFlowTest
} }
@Test @Test
public void testFailure_pendingRegistrarCantRestoreDomain() { void testFailure_pendingRegistrarCantRestoreDomain() {
persistResource( persistResource(
Registrar.loadByClientId("TheRegistrar") Registrar.loadByClientId("TheRegistrar")
.get() .get()
@ -488,7 +488,7 @@ public class DomainRestoreRequestFlowTest
} }
@Test @Test
public void testFailure_wrongFeeAmount_v06() throws Exception { void testFailure_wrongFeeAmount_v06() throws Exception {
setEppInput("domain_update_restore_request_fee.xml", FEE_06_MAP); setEppInput("domain_update_restore_request_fee.xml", FEE_06_MAP);
persistPendingDeleteDomain(); persistPendingDeleteDomain();
persistResource( persistResource(
@ -498,7 +498,7 @@ public class DomainRestoreRequestFlowTest
} }
@Test @Test
public void testFailure_wrongFeeAmount_v11() throws Exception { void testFailure_wrongFeeAmount_v11() throws Exception {
setEppInput("domain_update_restore_request_fee.xml", FEE_11_MAP); setEppInput("domain_update_restore_request_fee.xml", FEE_11_MAP);
persistPendingDeleteDomain(); persistPendingDeleteDomain();
persistResource( persistResource(
@ -508,7 +508,7 @@ public class DomainRestoreRequestFlowTest
} }
@Test @Test
public void testFailure_wrongFeeAmount_v12() throws Exception { void testFailure_wrongFeeAmount_v12() throws Exception {
setEppInput("domain_update_restore_request_fee.xml", FEE_12_MAP); setEppInput("domain_update_restore_request_fee.xml", FEE_12_MAP);
persistPendingDeleteDomain(); persistPendingDeleteDomain();
persistResource( persistResource(
@ -535,22 +535,22 @@ public class DomainRestoreRequestFlowTest
} }
@Test @Test
public void testFailure_wrongCurrency_v06() throws Exception { void testFailure_wrongCurrency_v06() throws Exception {
runWrongCurrencyTest(FEE_06_MAP); runWrongCurrencyTest(FEE_06_MAP);
} }
@Test @Test
public void testFailure_wrongCurrency_v11() throws Exception { void testFailure_wrongCurrency_v11() throws Exception {
runWrongCurrencyTest(FEE_11_MAP); runWrongCurrencyTest(FEE_11_MAP);
} }
@Test @Test
public void testFailure_wrongCurrency_v12() throws Exception { void testFailure_wrongCurrency_v12() throws Exception {
runWrongCurrencyTest(FEE_12_MAP); runWrongCurrencyTest(FEE_12_MAP);
} }
@Test @Test
public void testFailure_feeGivenInWrongScale_v06() throws Exception { void testFailure_feeGivenInWrongScale_v06() throws Exception {
setEppInput("domain_update_restore_request_fee_bad_scale.xml", FEE_06_MAP); setEppInput("domain_update_restore_request_fee_bad_scale.xml", FEE_06_MAP);
persistPendingDeleteDomain(); persistPendingDeleteDomain();
EppException thrown = assertThrows(CurrencyValueScaleException.class, this::runFlow); EppException thrown = assertThrows(CurrencyValueScaleException.class, this::runFlow);
@ -558,7 +558,7 @@ public class DomainRestoreRequestFlowTest
} }
@Test @Test
public void testFailure_feeGivenInWrongScale_v11() throws Exception { void testFailure_feeGivenInWrongScale_v11() throws Exception {
setEppInput("domain_update_restore_request_fee_bad_scale.xml", FEE_11_MAP); setEppInput("domain_update_restore_request_fee_bad_scale.xml", FEE_11_MAP);
persistPendingDeleteDomain(); persistPendingDeleteDomain();
EppException thrown = assertThrows(CurrencyValueScaleException.class, this::runFlow); EppException thrown = assertThrows(CurrencyValueScaleException.class, this::runFlow);
@ -566,7 +566,7 @@ public class DomainRestoreRequestFlowTest
} }
@Test @Test
public void testFailure_feeGivenInWrongScale_v12() throws Exception { void testFailure_feeGivenInWrongScale_v12() throws Exception {
setEppInput("domain_update_restore_request_fee_bad_scale.xml", FEE_12_MAP); setEppInput("domain_update_restore_request_fee_bad_scale.xml", FEE_12_MAP);
persistPendingDeleteDomain(); persistPendingDeleteDomain();
EppException thrown = assertThrows(CurrencyValueScaleException.class, this::runFlow); EppException thrown = assertThrows(CurrencyValueScaleException.class, this::runFlow);
@ -574,7 +574,7 @@ public class DomainRestoreRequestFlowTest
} }
@Test @Test
public void testFailure_notInRedemptionPeriod() throws Exception { void testFailure_notInRedemptionPeriod() throws Exception {
persistResource( persistResource(
newDomainBase(getUniqueIdFromCommand()) newDomainBase(getUniqueIdFromCommand())
.asBuilder() .asBuilder()
@ -586,21 +586,21 @@ public class DomainRestoreRequestFlowTest
} }
@Test @Test
public void testFailure_notDeleted() throws Exception { void testFailure_notDeleted() throws Exception {
persistActiveDomain(getUniqueIdFromCommand()); persistActiveDomain(getUniqueIdFromCommand());
EppException thrown = assertThrows(DomainNotEligibleForRestoreException.class, this::runFlow); EppException thrown = assertThrows(DomainNotEligibleForRestoreException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml(); assertAboutEppExceptions().that(thrown).marshalsToXml();
} }
@Test @Test
public void testFailure_fullyDeleted() throws Exception { void testFailure_fullyDeleted() throws Exception {
persistDeletedDomain(getUniqueIdFromCommand(), clock.nowUtc().minusDays(1)); persistDeletedDomain(getUniqueIdFromCommand(), clock.nowUtc().minusDays(1));
EppException thrown = assertThrows(ResourceDoesNotExistException.class, this::runFlow); EppException thrown = assertThrows(ResourceDoesNotExistException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml(); assertAboutEppExceptions().that(thrown).marshalsToXml();
} }
@Test @Test
public void testFailure_withChange() throws Exception { void testFailure_withChange() throws Exception {
persistPendingDeleteDomain(); persistPendingDeleteDomain();
setEppInput("domain_update_restore_request_with_change.xml"); setEppInput("domain_update_restore_request_with_change.xml");
EppException thrown = assertThrows(RestoreCommandIncludesChangesException.class, this::runFlow); EppException thrown = assertThrows(RestoreCommandIncludesChangesException.class, this::runFlow);
@ -608,7 +608,7 @@ public class DomainRestoreRequestFlowTest
} }
@Test @Test
public void testFailure_withAdd() throws Exception { void testFailure_withAdd() throws Exception {
persistPendingDeleteDomain(); persistPendingDeleteDomain();
setEppInput("domain_update_restore_request_with_add.xml"); setEppInput("domain_update_restore_request_with_add.xml");
EppException thrown = assertThrows(RestoreCommandIncludesChangesException.class, this::runFlow); EppException thrown = assertThrows(RestoreCommandIncludesChangesException.class, this::runFlow);
@ -616,7 +616,7 @@ public class DomainRestoreRequestFlowTest
} }
@Test @Test
public void testFailure_withRemove() throws Exception { void testFailure_withRemove() throws Exception {
persistPendingDeleteDomain(); persistPendingDeleteDomain();
setEppInput("domain_update_restore_request_with_remove.xml"); setEppInput("domain_update_restore_request_with_remove.xml");
EppException thrown = assertThrows(RestoreCommandIncludesChangesException.class, this::runFlow); EppException thrown = assertThrows(RestoreCommandIncludesChangesException.class, this::runFlow);
@ -624,7 +624,7 @@ public class DomainRestoreRequestFlowTest
} }
@Test @Test
public void testFailure_withSecDnsExtension() throws Exception { void testFailure_withSecDnsExtension() throws Exception {
persistPendingDeleteDomain(); persistPendingDeleteDomain();
setEppInput("domain_update_restore_request_with_secdns.xml"); setEppInput("domain_update_restore_request_with_secdns.xml");
EppException thrown = assertThrows(UnimplementedExtensionException.class, this::runFlow); EppException thrown = assertThrows(UnimplementedExtensionException.class, this::runFlow);
@ -632,7 +632,7 @@ public class DomainRestoreRequestFlowTest
} }
@Test @Test
public void testFailure_unauthorizedClient() throws Exception { void testFailure_unauthorizedClient() throws Exception {
sessionMetadata.setClientId("NewRegistrar"); sessionMetadata.setClientId("NewRegistrar");
persistPendingDeleteDomain(); persistPendingDeleteDomain();
EppException thrown = assertThrows(ResourceNotOwnedException.class, this::runFlow); EppException thrown = assertThrows(ResourceNotOwnedException.class, this::runFlow);
@ -640,7 +640,7 @@ public class DomainRestoreRequestFlowTest
} }
@Test @Test
public void testSuccess_superuserUnauthorizedClient() throws Exception { void testSuccess_superuserUnauthorizedClient() throws Exception {
sessionMetadata.setClientId("NewRegistrar"); sessionMetadata.setClientId("NewRegistrar");
persistPendingDeleteDomain(); persistPendingDeleteDomain();
EppException thrown = EppException thrown =
@ -651,7 +651,7 @@ public class DomainRestoreRequestFlowTest
} }
@Test @Test
public void testFailure_notAuthorizedForTld() throws Exception { void testFailure_notAuthorizedForTld() throws Exception {
persistResource( persistResource(
loadRegistrar("TheRegistrar").asBuilder().setAllowedTlds(ImmutableSet.of()).build()); loadRegistrar("TheRegistrar").asBuilder().setAllowedTlds(ImmutableSet.of()).build());
persistPendingDeleteDomain(); persistPendingDeleteDomain();
@ -660,7 +660,7 @@ public class DomainRestoreRequestFlowTest
} }
@Test @Test
public void testSuccess_superuserNotAuthorizedForTld() throws Exception { void testSuccess_superuserNotAuthorizedForTld() throws Exception {
persistResource( persistResource(
loadRegistrar("TheRegistrar").asBuilder().setAllowedTlds(ImmutableSet.of()).build()); loadRegistrar("TheRegistrar").asBuilder().setAllowedTlds(ImmutableSet.of()).build());
persistPendingDeleteDomain(); persistPendingDeleteDomain();
@ -669,7 +669,7 @@ public class DomainRestoreRequestFlowTest
} }
@Test @Test
public void testFailure_premiumBlocked() throws Exception { void testFailure_premiumBlocked() throws Exception {
createTld("example"); createTld("example");
setEppInput("domain_update_restore_request_premium.xml"); setEppInput("domain_update_restore_request_premium.xml");
persistPendingDeleteDomain(); persistPendingDeleteDomain();
@ -680,7 +680,7 @@ public class DomainRestoreRequestFlowTest
} }
@Test @Test
public void testFailure_reservedBlocked() throws Exception { void testFailure_reservedBlocked() throws Exception {
createTld("tld"); createTld("tld");
persistResource( persistResource(
Registry.get("tld") Registry.get("tld")
@ -693,7 +693,7 @@ public class DomainRestoreRequestFlowTest
} }
@Test @Test
public void testFailure_premiumNotAcked() throws Exception { void testFailure_premiumNotAcked() throws Exception {
createTld("example"); createTld("example");
setEppInput("domain_update_restore_request.xml", ImmutableMap.of("DOMAIN", "rich.example")); setEppInput("domain_update_restore_request.xml", ImmutableMap.of("DOMAIN", "rich.example"));
persistPendingDeleteDomain(); persistPendingDeleteDomain();
@ -702,7 +702,7 @@ public class DomainRestoreRequestFlowTest
} }
@Test @Test
public void testIcannActivityReportField_getsLogged() throws Exception { void testIcannActivityReportField_getsLogged() throws Exception {
persistPendingDeleteDomain(); persistPendingDeleteDomain();
runFlow(); runFlow();
assertIcannReportingActivityFieldLogged("srs-dom-rgp-restore-request"); assertIcannReportingActivityFieldLogged("srs-dom-rgp-restore-request");
@ -710,7 +710,7 @@ public class DomainRestoreRequestFlowTest
} }
@Test @Test
public void testIcannTransactionReportField_getsStored() throws Exception { void testIcannTransactionReportField_getsStored() throws Exception {
persistPendingDeleteDomain(); persistPendingDeleteDomain();
runFlow(); runFlow();
DomainBase domain = reloadResourceByForeignKey(); DomainBase domain = reloadResourceByForeignKey();
@ -726,7 +726,7 @@ public class DomainRestoreRequestFlowTest
} }
@Test @Test
public void testFailure_restoreReportsAreNotSupported() { void testFailure_restoreReportsAreNotSupported() {
setEppInput("domain_update_restore_report.xml"); setEppInput("domain_update_restore_report.xml");
// This exception is referred to by its fully qualified path (rather than being imported) so // This exception is referred to by its fully qualified path (rather than being imported) so
// that it is not included in the list of exceptions thrown by DomainRestoreRequestFlow, as this // that it is not included in the list of exceptions thrown by DomainRestoreRequestFlow, as this

View file

@ -77,15 +77,15 @@ import java.util.stream.Stream;
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 DomainTransferApproveFlow}. */ /** Unit tests for {@link DomainTransferApproveFlow}. */
public class DomainTransferApproveFlowTest class DomainTransferApproveFlowTest
extends DomainTransferFlowTestCase<DomainTransferApproveFlow, DomainBase> { extends DomainTransferFlowTestCase<DomainTransferApproveFlow, DomainBase> {
@Before @BeforeEach
public void setUp() { void setUp() {
setEppInput("domain_transfer_approve.xml"); setEppInput("domain_transfer_approve.xml");
// Change the registry so that the renew price changes a day minus 1 millisecond before the // Change the registry so that the renew price changes a day minus 1 millisecond before the
// transfer (right after there will be an autorenew in the test case that has one) and then // transfer (right after there will be an autorenew in the test case that has one) and then
@ -341,18 +341,18 @@ public class DomainTransferApproveFlowTest
} }
@Test @Test
public void testDryRun() throws Exception { void testDryRun() throws Exception {
setEppLoader("domain_transfer_approve.xml"); setEppLoader("domain_transfer_approve.xml");
dryRunFlowAssertResponse(loadFile("domain_transfer_approve_response.xml")); dryRunFlowAssertResponse(loadFile("domain_transfer_approve_response.xml"));
} }
@Test @Test
public void testSuccess() throws Exception { void testSuccess() throws Exception {
doSuccessfulTest("tld", "domain_transfer_approve.xml", "domain_transfer_approve_response.xml"); doSuccessfulTest("tld", "domain_transfer_approve.xml", "domain_transfer_approve_response.xml");
} }
@Test @Test
public void testSuccess_nonDefaultTransferGracePeriod() throws Exception { void testSuccess_nonDefaultTransferGracePeriod() throws Exception {
// We have to set up a new domain in a different TLD so that the billing event will be persisted // We have to set up a new domain in a different TLD so that the billing event will be persisted
// with the new transfer grace period in mind. // with the new transfer grace period in mind.
createTld("net"); createTld("net");
@ -367,7 +367,7 @@ public class DomainTransferApproveFlowTest
} }
@Test @Test
public void testSuccess_domainAuthInfo() throws Exception { void testSuccess_domainAuthInfo() throws Exception {
doSuccessfulTest( doSuccessfulTest(
"tld", "tld",
"domain_transfer_approve_domain_authinfo.xml", "domain_transfer_approve_domain_authinfo.xml",
@ -375,7 +375,7 @@ public class DomainTransferApproveFlowTest
} }
@Test @Test
public void testSuccess_contactAuthInfo() throws Exception { void testSuccess_contactAuthInfo() throws Exception {
doSuccessfulTest( doSuccessfulTest(
"tld", "tld",
"domain_transfer_approve_contact_authinfo.xml", "domain_transfer_approve_contact_authinfo.xml",
@ -383,7 +383,7 @@ public class DomainTransferApproveFlowTest
} }
@Test @Test
public void testSuccess_autorenewBeforeTransfer() throws Exception { void testSuccess_autorenewBeforeTransfer() throws Exception {
domain = reloadResourceByForeignKey(); domain = reloadResourceByForeignKey();
DateTime oldExpirationTime = clock.nowUtc().minusDays(1); DateTime oldExpirationTime = clock.nowUtc().minusDays(1);
persistResource(domain.asBuilder().setRegistrationExpirationTime(oldExpirationTime).build()); persistResource(domain.asBuilder().setRegistrationExpirationTime(oldExpirationTime).build());
@ -407,7 +407,7 @@ public class DomainTransferApproveFlowTest
} }
@Test @Test
public void testFailure_badContactPassword() { void testFailure_badContactPassword() {
// Change the contact's password so it does not match the password in the file. // Change the contact's password so it does not match the password in the file.
contact = contact =
persistResource( persistResource(
@ -423,7 +423,7 @@ public class DomainTransferApproveFlowTest
} }
@Test @Test
public void testFailure_badDomainPassword() { void testFailure_badDomainPassword() {
// Change the domain's password so it does not match the password in the file. // Change the domain's password so it does not match the password in the file.
persistResource( persistResource(
domain domain
@ -438,7 +438,7 @@ public class DomainTransferApproveFlowTest
} }
@Test @Test
public void testFailure_neverBeenTransferred() { void testFailure_neverBeenTransferred() {
changeTransferStatus(null); changeTransferStatus(null);
EppException thrown = EppException thrown =
assertThrows( assertThrows(
@ -447,7 +447,7 @@ public class DomainTransferApproveFlowTest
} }
@Test @Test
public void testFailure_clientApproved() { void testFailure_clientApproved() {
changeTransferStatus(TransferStatus.CLIENT_APPROVED); changeTransferStatus(TransferStatus.CLIENT_APPROVED);
EppException thrown = EppException thrown =
assertThrows( assertThrows(
@ -456,7 +456,7 @@ public class DomainTransferApproveFlowTest
} }
@Test @Test
public void testFailure_clientRejected() { void testFailure_clientRejected() {
changeTransferStatus(TransferStatus.CLIENT_REJECTED); changeTransferStatus(TransferStatus.CLIENT_REJECTED);
EppException thrown = EppException thrown =
assertThrows( assertThrows(
@ -465,7 +465,7 @@ public class DomainTransferApproveFlowTest
} }
@Test @Test
public void testFailure_clientCancelled() { void testFailure_clientCancelled() {
changeTransferStatus(TransferStatus.CLIENT_CANCELLED); changeTransferStatus(TransferStatus.CLIENT_CANCELLED);
EppException thrown = EppException thrown =
assertThrows( assertThrows(
@ -474,7 +474,7 @@ public class DomainTransferApproveFlowTest
} }
@Test @Test
public void testFailure_serverApproved() { void testFailure_serverApproved() {
changeTransferStatus(TransferStatus.SERVER_APPROVED); changeTransferStatus(TransferStatus.SERVER_APPROVED);
EppException thrown = EppException thrown =
assertThrows( assertThrows(
@ -483,7 +483,7 @@ public class DomainTransferApproveFlowTest
} }
@Test @Test
public void testFailure_serverCancelled() { void testFailure_serverCancelled() {
changeTransferStatus(TransferStatus.SERVER_CANCELLED); changeTransferStatus(TransferStatus.SERVER_CANCELLED);
EppException thrown = EppException thrown =
assertThrows( assertThrows(
@ -492,7 +492,7 @@ public class DomainTransferApproveFlowTest
} }
@Test @Test
public void testFailure_gainingClient() { void testFailure_gainingClient() {
setClientIdForFlow("NewRegistrar"); setClientIdForFlow("NewRegistrar");
EppException thrown = EppException thrown =
assertThrows( assertThrows(
@ -501,7 +501,7 @@ public class DomainTransferApproveFlowTest
} }
@Test @Test
public void testFailure_unrelatedClient() { void testFailure_unrelatedClient() {
setClientIdForFlow("ClientZ"); setClientIdForFlow("ClientZ");
EppException thrown = EppException thrown =
assertThrows( assertThrows(
@ -510,7 +510,7 @@ public class DomainTransferApproveFlowTest
} }
@Test @Test
public void testFailure_deletedDomain() throws Exception { void testFailure_deletedDomain() throws Exception {
persistResource(domain.asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build()); persistResource(domain.asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build());
ResourceDoesNotExistException thrown = ResourceDoesNotExistException thrown =
assertThrows( assertThrows(
@ -520,7 +520,7 @@ public class DomainTransferApproveFlowTest
} }
@Test @Test
public void testFailure_nonexistentDomain() throws Exception { void testFailure_nonexistentDomain() throws Exception {
deleteResource(domain); deleteResource(domain);
ResourceDoesNotExistException thrown = ResourceDoesNotExistException thrown =
assertThrows( assertThrows(
@ -530,7 +530,7 @@ public class DomainTransferApproveFlowTest
} }
@Test @Test
public void testFailure_notAuthorizedForTld() { void testFailure_notAuthorizedForTld() {
persistResource( persistResource(
loadRegistrar("TheRegistrar").asBuilder().setAllowedTlds(ImmutableSet.of()).build()); loadRegistrar("TheRegistrar").asBuilder().setAllowedTlds(ImmutableSet.of()).build());
EppException thrown = EppException thrown =
@ -543,7 +543,7 @@ public class DomainTransferApproveFlowTest
} }
@Test @Test
public void testSuccess_superuserNotAuthorizedForTld() throws Exception { void testSuccess_superuserNotAuthorizedForTld() throws Exception {
persistResource( persistResource(
loadRegistrar("TheRegistrar").asBuilder().setAllowedTlds(ImmutableSet.of()).build()); loadRegistrar("TheRegistrar").asBuilder().setAllowedTlds(ImmutableSet.of()).build());
runFlowAssertResponse( runFlowAssertResponse(
@ -556,7 +556,7 @@ public class DomainTransferApproveFlowTest
// entering pending delete phase. So it's already handled in that test case. // entering pending delete phase. So it's already handled in that test case.
@Test @Test
public void testIcannActivityReportField_getsLogged() throws Exception { void testIcannActivityReportField_getsLogged() throws Exception {
runFlow(); runFlow();
assertIcannReportingActivityFieldLogged("srs-dom-transfer-approve"); assertIcannReportingActivityFieldLogged("srs-dom-transfer-approve");
assertTldsFieldLogged("tld"); assertTldsFieldLogged("tld");
@ -572,7 +572,7 @@ public class DomainTransferApproveFlowTest
} }
@Test @Test
public void testIcannTransactionRecord_noRecordsToCancel() throws Exception { void testIcannTransactionRecord_noRecordsToCancel() throws Exception {
setUpGracePeriodDurations(); setUpGracePeriodDurations();
clock.advanceOneMilli(); clock.advanceOneMilli();
runFlow(); runFlow();
@ -585,7 +585,7 @@ public class DomainTransferApproveFlowTest
} }
@Test @Test
public void testIcannTransactionRecord_cancelsPreviousRecords() throws Exception { void testIcannTransactionRecord_cancelsPreviousRecords() throws Exception {
clock.advanceOneMilli(); clock.advanceOneMilli();
setUpGracePeriodDurations(); setUpGracePeriodDurations();
DomainTransactionRecord previousSuccessRecord = DomainTransactionRecord previousSuccessRecord =
@ -613,7 +613,7 @@ public class DomainTransferApproveFlowTest
} }
@Test @Test
public void testSuccess_superuserExtension_transferPeriodZero() throws Exception { void testSuccess_superuserExtension_transferPeriodZero() throws Exception {
domain = reloadResourceByForeignKey(); domain = reloadResourceByForeignKey();
DomainTransferData.Builder transferDataBuilder = domain.getTransferData().asBuilder(); DomainTransferData.Builder transferDataBuilder = domain.getTransferData().asBuilder();
persistResource( persistResource(
@ -632,8 +632,7 @@ public class DomainTransferApproveFlowTest
} }
@Test @Test
public void testSuccess_superuserExtension_transferPeriodZero_autorenewGraceActive() void testSuccess_superuserExtension_transferPeriodZero_autorenewGraceActive() throws Exception {
throws Exception {
DomainBase domain = reloadResourceByForeignKey(); DomainBase domain = reloadResourceByForeignKey();
Key<Recurring> existingAutorenewEvent = domain.getAutorenewBillingEvent(); Key<Recurring> existingAutorenewEvent = domain.getAutorenewBillingEvent();
// Set domain to have auto-renewed just before the transfer request, so that it will have an // Set domain to have auto-renewed just before the transfer request, so that it will have an

View file

@ -55,15 +55,15 @@ import google.registry.model.transfer.TransferResponse.DomainTransferResponse;
import google.registry.model.transfer.TransferStatus; import google.registry.model.transfer.TransferStatus;
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 DomainTransferCancelFlow}. */ /** Unit tests for {@link DomainTransferCancelFlow}. */
public class DomainTransferCancelFlowTest class DomainTransferCancelFlowTest
extends DomainTransferFlowTestCase<DomainTransferCancelFlow, DomainBase> { extends DomainTransferFlowTestCase<DomainTransferCancelFlow, DomainBase> {
@Before @BeforeEach
public void setUp() { void setUp() {
setEppInput("domain_transfer_cancel.xml"); setEppInput("domain_transfer_cancel.xml");
setClientIdForFlow("NewRegistrar"); setClientIdForFlow("NewRegistrar");
setupDomainWithPendingTransfer("example", "tld"); setupDomainWithPendingTransfer("example", "tld");
@ -192,31 +192,31 @@ public class DomainTransferCancelFlowTest
} }
@Test @Test
public void testDryRun() throws Exception { void testDryRun() throws Exception {
setEppInput("domain_transfer_cancel.xml"); setEppInput("domain_transfer_cancel.xml");
eppLoader.replaceAll("JD1234-REP", contact.getRepoId()); eppLoader.replaceAll("JD1234-REP", contact.getRepoId());
dryRunFlowAssertResponse(loadFile("domain_transfer_cancel_response.xml")); dryRunFlowAssertResponse(loadFile("domain_transfer_cancel_response.xml"));
} }
@Test @Test
public void testSuccess() throws Exception { void testSuccess() throws Exception {
doSuccessfulTest("domain_transfer_cancel.xml", "domain_transfer_cancel_response.xml"); doSuccessfulTest("domain_transfer_cancel.xml", "domain_transfer_cancel_response.xml");
} }
@Test @Test
public void testSuccess_domainAuthInfo() throws Exception { void testSuccess_domainAuthInfo() throws Exception {
doSuccessfulTest( doSuccessfulTest(
"domain_transfer_cancel_domain_authinfo.xml", "domain_transfer_cancel_response.xml"); "domain_transfer_cancel_domain_authinfo.xml", "domain_transfer_cancel_response.xml");
} }
@Test @Test
public void testSuccess_contactAuthInfo() throws Exception { void testSuccess_contactAuthInfo() throws Exception {
doSuccessfulTest( doSuccessfulTest(
"domain_transfer_cancel_contact_authinfo.xml", "domain_transfer_cancel_response.xml"); "domain_transfer_cancel_contact_authinfo.xml", "domain_transfer_cancel_response.xml");
} }
@Test @Test
public void testFailure_badContactPassword() { void testFailure_badContactPassword() {
// Change the contact's password so it does not match the password in the file. // Change the contact's password so it does not match the password in the file.
contact = contact =
persistResource( persistResource(
@ -232,7 +232,7 @@ public class DomainTransferCancelFlowTest
} }
@Test @Test
public void testFailure_badDomainPassword() { void testFailure_badDomainPassword() {
// Change the domain's password so it does not match the password in the file. // Change the domain's password so it does not match the password in the file.
domain = domain =
persistResource( persistResource(
@ -248,7 +248,7 @@ public class DomainTransferCancelFlowTest
} }
@Test @Test
public void testFailure_neverBeenTransferred() { void testFailure_neverBeenTransferred() {
changeTransferStatus(null); changeTransferStatus(null);
EppException thrown = EppException thrown =
assertThrows( assertThrows(
@ -257,7 +257,7 @@ public class DomainTransferCancelFlowTest
} }
@Test @Test
public void testFailure_clientApproved() { void testFailure_clientApproved() {
changeTransferStatus(TransferStatus.CLIENT_APPROVED); changeTransferStatus(TransferStatus.CLIENT_APPROVED);
EppException thrown = EppException thrown =
assertThrows( assertThrows(
@ -266,7 +266,7 @@ public class DomainTransferCancelFlowTest
} }
@Test @Test
public void testFailure_clientRejected() { void testFailure_clientRejected() {
changeTransferStatus(TransferStatus.CLIENT_REJECTED); changeTransferStatus(TransferStatus.CLIENT_REJECTED);
EppException thrown = EppException thrown =
assertThrows( assertThrows(
@ -275,7 +275,7 @@ public class DomainTransferCancelFlowTest
} }
@Test @Test
public void testFailure_clientCancelled() { void testFailure_clientCancelled() {
changeTransferStatus(TransferStatus.CLIENT_CANCELLED); changeTransferStatus(TransferStatus.CLIENT_CANCELLED);
EppException thrown = EppException thrown =
assertThrows( assertThrows(
@ -284,7 +284,7 @@ public class DomainTransferCancelFlowTest
} }
@Test @Test
public void testFailure_serverApproved() { void testFailure_serverApproved() {
changeTransferStatus(TransferStatus.SERVER_APPROVED); changeTransferStatus(TransferStatus.SERVER_APPROVED);
EppException thrown = EppException thrown =
assertThrows( assertThrows(
@ -293,7 +293,7 @@ public class DomainTransferCancelFlowTest
} }
@Test @Test
public void testFailure_serverCancelled() { void testFailure_serverCancelled() {
changeTransferStatus(TransferStatus.SERVER_CANCELLED); changeTransferStatus(TransferStatus.SERVER_CANCELLED);
EppException thrown = EppException thrown =
assertThrows( assertThrows(
@ -302,7 +302,7 @@ public class DomainTransferCancelFlowTest
} }
@Test @Test
public void testFailure_sponsoringClient() { void testFailure_sponsoringClient() {
setClientIdForFlow("TheRegistrar"); setClientIdForFlow("TheRegistrar");
EppException thrown = EppException thrown =
assertThrows( assertThrows(
@ -311,7 +311,7 @@ public class DomainTransferCancelFlowTest
} }
@Test @Test
public void testFailure_unrelatedClient() { void testFailure_unrelatedClient() {
setClientIdForFlow("ClientZ"); setClientIdForFlow("ClientZ");
EppException thrown = EppException thrown =
assertThrows( assertThrows(
@ -320,7 +320,7 @@ public class DomainTransferCancelFlowTest
} }
@Test @Test
public void testFailure_deletedDomain() throws Exception { void testFailure_deletedDomain() throws Exception {
domain = domain =
persistResource(domain.asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build()); persistResource(domain.asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build());
ResourceDoesNotExistException thrown = ResourceDoesNotExistException thrown =
@ -330,7 +330,7 @@ public class DomainTransferCancelFlowTest
} }
@Test @Test
public void testFailure_nonexistentDomain() throws Exception { void testFailure_nonexistentDomain() throws Exception {
deleteResource(domain); deleteResource(domain);
ResourceDoesNotExistException thrown = ResourceDoesNotExistException thrown =
assertThrows( assertThrows(
@ -339,7 +339,7 @@ public class DomainTransferCancelFlowTest
} }
@Test @Test
public void testFailure_notAuthorizedForTld() { void testFailure_notAuthorizedForTld() {
persistResource( persistResource(
loadRegistrar("NewRegistrar").asBuilder().setAllowedTlds(ImmutableSet.of()).build()); loadRegistrar("NewRegistrar").asBuilder().setAllowedTlds(ImmutableSet.of()).build());
EppException thrown = EppException thrown =
@ -352,7 +352,7 @@ public class DomainTransferCancelFlowTest
} }
@Test @Test
public void testSuccess_superuserNotAuthorizedForTld() throws Exception { void testSuccess_superuserNotAuthorizedForTld() throws Exception {
persistResource( persistResource(
loadRegistrar("NewRegistrar").asBuilder().setAllowedTlds(ImmutableSet.of()).build()); loadRegistrar("NewRegistrar").asBuilder().setAllowedTlds(ImmutableSet.of()).build());
clock.advanceOneMilli(); clock.advanceOneMilli();
@ -364,7 +364,7 @@ public class DomainTransferCancelFlowTest
// entering pending delete phase. So it's already handled in that test case. // entering pending delete phase. So it's already handled in that test case.
@Test @Test
public void testIcannActivityReportField_getsLogged() throws Exception { void testIcannActivityReportField_getsLogged() throws Exception {
clock.advanceOneMilli(); clock.advanceOneMilli();
runFlow(); runFlow();
assertIcannReportingActivityFieldLogged("srs-dom-transfer-cancel"); assertIcannReportingActivityFieldLogged("srs-dom-transfer-cancel");
@ -372,7 +372,7 @@ public class DomainTransferCancelFlowTest
} }
@Test @Test
public void testIcannTransactionRecord_noRecordsToCancel() throws Exception { void testIcannTransactionRecord_noRecordsToCancel() throws Exception {
clock.advanceOneMilli(); clock.advanceOneMilli();
runFlow(); runFlow();
HistoryEntry persistedEntry = getOnlyHistoryEntryOfType(domain, DOMAIN_TRANSFER_CANCEL); HistoryEntry persistedEntry = getOnlyHistoryEntryOfType(domain, DOMAIN_TRANSFER_CANCEL);
@ -381,7 +381,7 @@ public class DomainTransferCancelFlowTest
} }
@Test @Test
public void testIcannTransactionRecord_cancelsPreviousRecords() throws Exception { void testIcannTransactionRecord_cancelsPreviousRecords() throws Exception {
clock.advanceOneMilli(); clock.advanceOneMilli();
persistResource( persistResource(
Registry.get("tld") Registry.get("tld")

View file

@ -46,7 +46,7 @@ import google.registry.model.transfer.TransferStatus;
import google.registry.testing.AppEngineRule; import google.registry.testing.AppEngineRule;
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;
/** /**
* Base class for domain transfer flow unit tests. * Base class for domain transfer flow unit tests.
@ -60,28 +60,28 @@ public class DomainTransferFlowTestCase<F extends Flow, R extends EppResource>
// Transfer is requested on the 6th and expires on the 11th. // Transfer is requested on the 6th and expires on the 11th.
// The "now" of this flow is on the 9th, 3 days in. // The "now" of this flow is on the 9th, 3 days in.
protected static final DateTime TRANSFER_REQUEST_TIME = DateTime.parse("2000-06-06T22:00:00.0Z"); static final DateTime TRANSFER_REQUEST_TIME = DateTime.parse("2000-06-06T22:00:00.0Z");
protected static final DateTime TRANSFER_EXPIRATION_TIME = static final DateTime TRANSFER_EXPIRATION_TIME =
TRANSFER_REQUEST_TIME.plus(Registry.DEFAULT_AUTOMATIC_TRANSFER_LENGTH); TRANSFER_REQUEST_TIME.plus(Registry.DEFAULT_AUTOMATIC_TRANSFER_LENGTH);
protected static final Duration TIME_SINCE_REQUEST = Duration.standardDays(3); private static final Duration TIME_SINCE_REQUEST = Duration.standardDays(3);
protected static final int EXTENDED_REGISTRATION_YEARS = 1; private static final int EXTENDED_REGISTRATION_YEARS = 1;
protected static final DateTime REGISTRATION_EXPIRATION_TIME = private static final DateTime REGISTRATION_EXPIRATION_TIME =
DateTime.parse("2001-09-08T22:00:00.0Z"); DateTime.parse("2001-09-08T22:00:00.0Z");
protected static final DateTime EXTENDED_REGISTRATION_EXPIRATION_TIME = static final DateTime EXTENDED_REGISTRATION_EXPIRATION_TIME =
REGISTRATION_EXPIRATION_TIME.plusYears(EXTENDED_REGISTRATION_YEARS); REGISTRATION_EXPIRATION_TIME.plusYears(EXTENDED_REGISTRATION_YEARS);
protected ContactResource contact; protected ContactResource contact;
protected DomainBase domain; protected DomainBase domain;
protected HostResource subordinateHost; HostResource subordinateHost;
protected HistoryEntry historyEntryDomainCreate; private HistoryEntry historyEntryDomainCreate;
public DomainTransferFlowTestCase() { DomainTransferFlowTestCase() {
checkState(!Registry.DEFAULT_TRANSFER_GRACE_PERIOD.isShorterThan(TIME_SINCE_REQUEST)); checkState(!Registry.DEFAULT_TRANSFER_GRACE_PERIOD.isShorterThan(TIME_SINCE_REQUEST));
clock.setTo(TRANSFER_REQUEST_TIME.plus(TIME_SINCE_REQUEST)); clock.setTo(TRANSFER_REQUEST_TIME.plus(TIME_SINCE_REQUEST));
} }
@Before @BeforeEach
public void makeClientZ() { void makeClientZ() {
// Registrar ClientZ is used in tests that need another registrar that definitely doesn't own // Registrar ClientZ is used in tests that need another registrar that definitely doesn't own
// the resources in question. // the resources in question.
persistResource( persistResource(
@ -97,7 +97,7 @@ public class DomainTransferFlowTestCase<F extends Flow, R extends EppResource>
} }
/** Adds a domain with no pending transfer on it. */ /** Adds a domain with no pending transfer on it. */
protected void setupDomain(String label, String tld) { void setupDomain(String label, String tld) {
createTld(tld); createTld(tld);
contact = persistActiveContact("jd1234"); contact = persistActiveContact("jd1234");
domain = domain =
@ -124,7 +124,7 @@ public class DomainTransferFlowTestCase<F extends Flow, R extends EppResource>
historyEntryDomainCreate = getOnlyHistoryEntryOfType(domain, DOMAIN_CREATE); historyEntryDomainCreate = getOnlyHistoryEntryOfType(domain, DOMAIN_CREATE);
} }
protected BillingEvent.OneTime getBillingEventForImplicitTransfer() { BillingEvent.OneTime getBillingEventForImplicitTransfer() {
HistoryEntry historyEntry = HistoryEntry historyEntry =
getOnlyHistoryEntryOfType(domain, HistoryEntry.Type.DOMAIN_TRANSFER_REQUEST); getOnlyHistoryEntryOfType(domain, HistoryEntry.Type.DOMAIN_TRANSFER_REQUEST);
return createBillingEventForTransfer( return createBillingEventForTransfer(
@ -135,7 +135,7 @@ public class DomainTransferFlowTestCase<F extends Flow, R extends EppResource>
} }
/** Get the autorenew event that the losing client will have after a SERVER_APPROVED transfer. */ /** Get the autorenew event that the losing client will have after a SERVER_APPROVED transfer. */
protected BillingEvent.Recurring getLosingClientAutorenewEvent() { BillingEvent.Recurring getLosingClientAutorenewEvent() {
return new BillingEvent.Recurring.Builder() return new BillingEvent.Recurring.Builder()
.setReason(Reason.RENEW) .setReason(Reason.RENEW)
.setFlags(ImmutableSet.of(Flag.AUTO_RENEW)) .setFlags(ImmutableSet.of(Flag.AUTO_RENEW))
@ -148,7 +148,7 @@ public class DomainTransferFlowTestCase<F extends Flow, R extends EppResource>
} }
/** Get the autorenew event that the gaining client will have after a SERVER_APPROVED transfer. */ /** Get the autorenew event that the gaining client will have after a SERVER_APPROVED transfer. */
protected BillingEvent.Recurring getGainingClientAutorenewEvent() { BillingEvent.Recurring getGainingClientAutorenewEvent() {
return new BillingEvent.Recurring.Builder() return new BillingEvent.Recurring.Builder()
.setReason(Reason.RENEW) .setReason(Reason.RENEW)
.setFlags(ImmutableSet.of(Flag.AUTO_RENEW)) .setFlags(ImmutableSet.of(Flag.AUTO_RENEW))
@ -160,7 +160,7 @@ public class DomainTransferFlowTestCase<F extends Flow, R extends EppResource>
.build(); .build();
} }
protected void assertTransferFailed( void assertTransferFailed(
DomainBase domain, TransferStatus status, TransferData oldTransferData) { DomainBase domain, TransferStatus status, TransferData oldTransferData) {
assertAboutDomains().that(domain) assertAboutDomains().that(domain)
.doesNotHaveStatusValue(StatusValue.PENDING_TRANSFER).and() .doesNotHaveStatusValue(StatusValue.PENDING_TRANSFER).and()
@ -176,7 +176,7 @@ public class DomainTransferFlowTestCase<F extends Flow, R extends EppResource>
} }
/** Adds a domain that has a pending transfer on it from TheRegistrar to NewRegistrar. */ /** Adds a domain that has a pending transfer on it from TheRegistrar to NewRegistrar. */
protected void setupDomainWithPendingTransfer(String label, String tld) { void setupDomainWithPendingTransfer(String label, String tld) {
setupDomain(label, tld); setupDomain(label, tld);
domain = persistWithPendingTransfer(domain); domain = persistWithPendingTransfer(domain);
} }

View file

@ -34,15 +34,15 @@ import google.registry.model.domain.DomainBase;
import google.registry.model.eppcommon.AuthInfo.PasswordAuth; import google.registry.model.eppcommon.AuthInfo.PasswordAuth;
import google.registry.model.reporting.HistoryEntry; import google.registry.model.reporting.HistoryEntry;
import google.registry.model.transfer.TransferStatus; import google.registry.model.transfer.TransferStatus;
import org.junit.Before; import org.junit.jupiter.api.BeforeEach;
import org.junit.Test; import org.junit.jupiter.api.Test;
/** Unit tests for {@link DomainTransferQueryFlow}. */ /** Unit tests for {@link DomainTransferQueryFlow}. */
public class DomainTransferQueryFlowTest class DomainTransferQueryFlowTest
extends DomainTransferFlowTestCase<DomainTransferQueryFlow, DomainBase> { extends DomainTransferFlowTestCase<DomainTransferQueryFlow, DomainBase> {
@Before @BeforeEach
public void setUp() { void setUp() {
setEppInput("domain_transfer_query.xml"); setEppInput("domain_transfer_query.xml");
setClientIdForFlow("NewRegistrar"); setClientIdForFlow("NewRegistrar");
setupDomainWithPendingTransfer("example", "tld"); setupDomainWithPendingTransfer("example", "tld");
@ -80,67 +80,67 @@ public class DomainTransferQueryFlowTest
} }
@Test @Test
public void testSuccess() throws Exception { void testSuccess() throws Exception {
doSuccessfulTest("domain_transfer_query.xml", "domain_transfer_query_response.xml", 1); doSuccessfulTest("domain_transfer_query.xml", "domain_transfer_query_response.xml", 1);
} }
@Test @Test
public void testSuccess_sponsoringClient() throws Exception { void testSuccess_sponsoringClient() throws Exception {
setClientIdForFlow("TheRegistrar"); setClientIdForFlow("TheRegistrar");
doSuccessfulTest("domain_transfer_query.xml", "domain_transfer_query_response.xml", 1); doSuccessfulTest("domain_transfer_query.xml", "domain_transfer_query_response.xml", 1);
} }
@Test @Test
public void testSuccess_domainAuthInfo() throws Exception { void testSuccess_domainAuthInfo() throws Exception {
setClientIdForFlow("ClientZ"); setClientIdForFlow("ClientZ");
doSuccessfulTest( doSuccessfulTest(
"domain_transfer_query_domain_authinfo.xml", "domain_transfer_query_response.xml", 1); "domain_transfer_query_domain_authinfo.xml", "domain_transfer_query_response.xml", 1);
} }
@Test @Test
public void testSuccess_contactAuthInfo() throws Exception { void testSuccess_contactAuthInfo() throws Exception {
setClientIdForFlow("ClientZ"); setClientIdForFlow("ClientZ");
doSuccessfulTest( doSuccessfulTest(
"domain_transfer_query_contact_authinfo.xml", "domain_transfer_query_response.xml", 1); "domain_transfer_query_contact_authinfo.xml", "domain_transfer_query_response.xml", 1);
} }
@Test @Test
public void testSuccess_clientApproved() throws Exception { void testSuccess_clientApproved() throws Exception {
changeTransferStatus(TransferStatus.CLIENT_APPROVED); changeTransferStatus(TransferStatus.CLIENT_APPROVED);
doSuccessfulTest( doSuccessfulTest(
"domain_transfer_query.xml", "domain_transfer_query_response_client_approved.xml", 1); "domain_transfer_query.xml", "domain_transfer_query_response_client_approved.xml", 1);
} }
@Test @Test
public void testSuccess_clientRejected() throws Exception { void testSuccess_clientRejected() throws Exception {
changeTransferStatus(TransferStatus.CLIENT_REJECTED); changeTransferStatus(TransferStatus.CLIENT_REJECTED);
doSuccessfulTest( doSuccessfulTest(
"domain_transfer_query.xml", "domain_transfer_query_response_client_rejected.xml", 1); "domain_transfer_query.xml", "domain_transfer_query_response_client_rejected.xml", 1);
} }
@Test @Test
public void testSuccess_clientCancelled() throws Exception { void testSuccess_clientCancelled() throws Exception {
changeTransferStatus(TransferStatus.CLIENT_CANCELLED); changeTransferStatus(TransferStatus.CLIENT_CANCELLED);
doSuccessfulTest( doSuccessfulTest(
"domain_transfer_query.xml", "domain_transfer_query_response_client_cancelled.xml", 1); "domain_transfer_query.xml", "domain_transfer_query_response_client_cancelled.xml", 1);
} }
@Test @Test
public void testSuccess_serverApproved() throws Exception { void testSuccess_serverApproved() throws Exception {
changeTransferStatus(TransferStatus.SERVER_APPROVED); changeTransferStatus(TransferStatus.SERVER_APPROVED);
doSuccessfulTest( doSuccessfulTest(
"domain_transfer_query.xml", "domain_transfer_query_response_server_approved.xml", 1); "domain_transfer_query.xml", "domain_transfer_query_response_server_approved.xml", 1);
} }
@Test @Test
public void testSuccess_serverCancelled() throws Exception { void testSuccess_serverCancelled() throws Exception {
changeTransferStatus(TransferStatus.SERVER_CANCELLED); changeTransferStatus(TransferStatus.SERVER_CANCELLED);
doSuccessfulTest( doSuccessfulTest(
"domain_transfer_query.xml", "domain_transfer_query_response_server_cancelled.xml", 1); "domain_transfer_query.xml", "domain_transfer_query_response_server_cancelled.xml", 1);
} }
@Test @Test
public void testSuccess_tenYears() throws Exception { void testSuccess_tenYears() throws Exception {
// Extend registration by 9 years here; with the extra 1 year from the transfer, we should // Extend registration by 9 years here; with the extra 1 year from the transfer, we should
// hit the 10-year capping. // hit the 10-year capping.
domain = domain =
@ -153,7 +153,7 @@ public class DomainTransferQueryFlowTest
} }
@Test @Test
public void testFailure_pendingDeleteDomain() throws Exception { void testFailure_pendingDeleteDomain() throws Exception {
changeTransferStatus(TransferStatus.SERVER_CANCELLED); changeTransferStatus(TransferStatus.SERVER_CANCELLED);
domain = domain =
persistResource(domain.asBuilder().setDeletionTime(clock.nowUtc().plusDays(1)).build()); persistResource(domain.asBuilder().setDeletionTime(clock.nowUtc().plusDays(1)).build());
@ -162,7 +162,7 @@ public class DomainTransferQueryFlowTest
} }
@Test @Test
public void testFailure_badContactPassword() { void testFailure_badContactPassword() {
// Change the contact's password so it does not match the password in the file. // Change the contact's password so it does not match the password in the file.
contact = contact =
persistResource( persistResource(
@ -178,7 +178,7 @@ public class DomainTransferQueryFlowTest
} }
@Test @Test
public void testFailure_badDomainPassword() { void testFailure_badDomainPassword() {
// Change the domain's password so it does not match the password in the file. // Change the domain's password so it does not match the password in the file.
domain = domain =
persistResource( persistResource(
@ -194,7 +194,7 @@ public class DomainTransferQueryFlowTest
} }
@Test @Test
public void testFailure_neverBeenTransferred() { void testFailure_neverBeenTransferred() {
changeTransferStatus(null); changeTransferStatus(null);
EppException thrown = EppException thrown =
assertThrows( assertThrows(
@ -204,7 +204,7 @@ public class DomainTransferQueryFlowTest
} }
@Test @Test
public void testFailure_unrelatedClient() { void testFailure_unrelatedClient() {
setClientIdForFlow("ClientZ"); setClientIdForFlow("ClientZ");
EppException thrown = EppException thrown =
assertThrows( assertThrows(
@ -214,7 +214,7 @@ public class DomainTransferQueryFlowTest
} }
@Test @Test
public void testFailure_deletedDomain() throws Exception { void testFailure_deletedDomain() throws Exception {
domain = domain =
persistResource(domain.asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build()); persistResource(domain.asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build());
ResourceDoesNotExistException thrown = ResourceDoesNotExistException thrown =
@ -224,7 +224,7 @@ public class DomainTransferQueryFlowTest
} }
@Test @Test
public void testFailure_nonexistentDomain() throws Exception { void testFailure_nonexistentDomain() throws Exception {
deleteResource(domain); deleteResource(domain);
ResourceDoesNotExistException thrown = ResourceDoesNotExistException thrown =
assertThrows( assertThrows(
@ -233,14 +233,14 @@ public class DomainTransferQueryFlowTest
} }
@Test @Test
public void testIcannActivityReportField_getsLogged() throws Exception { void testIcannActivityReportField_getsLogged() throws Exception {
runFlow(); runFlow();
assertIcannReportingActivityFieldLogged("srs-dom-transfer-query"); assertIcannReportingActivityFieldLogged("srs-dom-transfer-query");
assertTldsFieldLogged("tld"); assertTldsFieldLogged("tld");
} }
@Test @Test
public void testSuccess_serverApproved_afterAutorenews() throws Exception { void testSuccess_serverApproved_afterAutorenews() throws Exception {
// Set the clock to just past the extended registration time. We'd expect the domain to have // Set the clock to just past the extended registration time. We'd expect the domain to have
// auto-renewed once, but the transfer query response should be the same. // auto-renewed once, but the transfer query response should be the same.
clock.setTo(EXTENDED_REGISTRATION_EXPIRATION_TIME.plusMillis(1)); clock.setTo(EXTENDED_REGISTRATION_EXPIRATION_TIME.plusMillis(1));

View file

@ -58,15 +58,15 @@ import google.registry.model.transfer.TransferResponse;
import google.registry.model.transfer.TransferStatus; import google.registry.model.transfer.TransferStatus;
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 DomainTransferRejectFlow}. */ /** Unit tests for {@link DomainTransferRejectFlow}. */
public class DomainTransferRejectFlowTest class DomainTransferRejectFlowTest
extends DomainTransferFlowTestCase<DomainTransferRejectFlow, DomainBase> { extends DomainTransferFlowTestCase<DomainTransferRejectFlow, DomainBase> {
@Before @BeforeEach
public void setUp() { void setUp() {
setEppInput("domain_transfer_reject.xml"); setEppInput("domain_transfer_reject.xml");
setClientIdForFlow("TheRegistrar"); setClientIdForFlow("TheRegistrar");
setupDomainWithPendingTransfer("example", "tld"); setupDomainWithPendingTransfer("example", "tld");
@ -152,31 +152,31 @@ public class DomainTransferRejectFlowTest
} }
@Test @Test
public void testSuccess() throws Exception { void testSuccess() throws Exception {
doSuccessfulTest("domain_transfer_reject.xml", "domain_transfer_reject_response.xml"); doSuccessfulTest("domain_transfer_reject.xml", "domain_transfer_reject_response.xml");
} }
@Test @Test
public void testDryRun() throws Exception { void testDryRun() throws Exception {
setEppInput("domain_transfer_reject.xml"); setEppInput("domain_transfer_reject.xml");
eppLoader.replaceAll("JD1234-REP", contact.getRepoId()); eppLoader.replaceAll("JD1234-REP", contact.getRepoId());
dryRunFlowAssertResponse(loadFile("domain_transfer_reject_response.xml")); dryRunFlowAssertResponse(loadFile("domain_transfer_reject_response.xml"));
} }
@Test @Test
public void testSuccess_domainAuthInfo() throws Exception { void testSuccess_domainAuthInfo() throws Exception {
doSuccessfulTest( doSuccessfulTest(
"domain_transfer_reject_domain_authinfo.xml", "domain_transfer_reject_response.xml"); "domain_transfer_reject_domain_authinfo.xml", "domain_transfer_reject_response.xml");
} }
@Test @Test
public void testSuccess_contactAuthInfo() throws Exception { void testSuccess_contactAuthInfo() throws Exception {
doSuccessfulTest( doSuccessfulTest(
"domain_transfer_reject_contact_authinfo.xml", "domain_transfer_reject_response.xml"); "domain_transfer_reject_contact_authinfo.xml", "domain_transfer_reject_response.xml");
} }
@Test @Test
public void testFailure_notAuthorizedForTld() { void testFailure_notAuthorizedForTld() {
persistResource( persistResource(
loadRegistrar("TheRegistrar").asBuilder().setAllowedTlds(ImmutableSet.of()).build()); loadRegistrar("TheRegistrar").asBuilder().setAllowedTlds(ImmutableSet.of()).build());
EppException thrown = EppException thrown =
@ -189,7 +189,7 @@ public class DomainTransferRejectFlowTest
} }
@Test @Test
public void testSuccess_superuserNotAuthorizedForTld() throws Exception { void testSuccess_superuserNotAuthorizedForTld() throws Exception {
persistResource( persistResource(
loadRegistrar("TheRegistrar").asBuilder().setAllowedTlds(ImmutableSet.of()).build()); loadRegistrar("TheRegistrar").asBuilder().setAllowedTlds(ImmutableSet.of()).build());
runFlowAssertResponse( runFlowAssertResponse(
@ -197,7 +197,7 @@ public class DomainTransferRejectFlowTest
} }
@Test @Test
public void testFailure_badContactPassword() { void testFailure_badContactPassword() {
// Change the contact's password so it does not match the password in the file. // Change the contact's password so it does not match the password in the file.
contact = contact =
persistResource( persistResource(
@ -213,7 +213,7 @@ public class DomainTransferRejectFlowTest
} }
@Test @Test
public void testFailure_badDomainPassword() { void testFailure_badDomainPassword() {
// Change the domain's password so it does not match the password in the file. // Change the domain's password so it does not match the password in the file.
domain = domain =
persistResource( persistResource(
@ -229,7 +229,7 @@ public class DomainTransferRejectFlowTest
} }
@Test @Test
public void testFailure_neverBeenTransferred() { void testFailure_neverBeenTransferred() {
changeTransferStatus(null); changeTransferStatus(null);
EppException thrown = EppException thrown =
assertThrows( assertThrows(
@ -238,7 +238,7 @@ public class DomainTransferRejectFlowTest
} }
@Test @Test
public void testFailure_clientApproved() { void testFailure_clientApproved() {
changeTransferStatus(TransferStatus.CLIENT_APPROVED); changeTransferStatus(TransferStatus.CLIENT_APPROVED);
EppException thrown = EppException thrown =
assertThrows( assertThrows(
@ -247,7 +247,7 @@ public class DomainTransferRejectFlowTest
} }
@Test @Test
public void testFailure_clientRejected() { void testFailure_clientRejected() {
changeTransferStatus(TransferStatus.CLIENT_REJECTED); changeTransferStatus(TransferStatus.CLIENT_REJECTED);
EppException thrown = EppException thrown =
assertThrows( assertThrows(
@ -256,7 +256,7 @@ public class DomainTransferRejectFlowTest
} }
@Test @Test
public void testFailure_clientCancelled() { void testFailure_clientCancelled() {
changeTransferStatus(TransferStatus.CLIENT_CANCELLED); changeTransferStatus(TransferStatus.CLIENT_CANCELLED);
EppException thrown = EppException thrown =
assertThrows( assertThrows(
@ -265,7 +265,7 @@ public class DomainTransferRejectFlowTest
} }
@Test @Test
public void testFailure_serverApproved() { void testFailure_serverApproved() {
changeTransferStatus(TransferStatus.SERVER_APPROVED); changeTransferStatus(TransferStatus.SERVER_APPROVED);
EppException thrown = EppException thrown =
assertThrows( assertThrows(
@ -274,7 +274,7 @@ public class DomainTransferRejectFlowTest
} }
@Test @Test
public void testFailure_serverCancelled() { void testFailure_serverCancelled() {
changeTransferStatus(TransferStatus.SERVER_CANCELLED); changeTransferStatus(TransferStatus.SERVER_CANCELLED);
EppException thrown = EppException thrown =
assertThrows( assertThrows(
@ -283,7 +283,7 @@ public class DomainTransferRejectFlowTest
} }
@Test @Test
public void testFailure_gainingClient() { void testFailure_gainingClient() {
setClientIdForFlow("NewRegistrar"); setClientIdForFlow("NewRegistrar");
EppException thrown = EppException thrown =
assertThrows( assertThrows(
@ -292,7 +292,7 @@ public class DomainTransferRejectFlowTest
} }
@Test @Test
public void testFailure_unrelatedClient() { void testFailure_unrelatedClient() {
setClientIdForFlow("ClientZ"); setClientIdForFlow("ClientZ");
EppException thrown = EppException thrown =
assertThrows( assertThrows(
@ -301,7 +301,7 @@ public class DomainTransferRejectFlowTest
} }
@Test @Test
public void testFailure_deletedDomain() throws Exception { void testFailure_deletedDomain() throws Exception {
domain = domain =
persistResource(domain.asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build()); persistResource(domain.asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build());
ResourceDoesNotExistException thrown = ResourceDoesNotExistException thrown =
@ -311,7 +311,7 @@ public class DomainTransferRejectFlowTest
} }
@Test @Test
public void testFailure_nonexistentDomain() throws Exception { void testFailure_nonexistentDomain() throws Exception {
deleteResource(domain); deleteResource(domain);
ResourceDoesNotExistException thrown = ResourceDoesNotExistException thrown =
assertThrows( assertThrows(
@ -323,7 +323,7 @@ public class DomainTransferRejectFlowTest
// entering pending delete phase. So it's already handled in that test case. // entering pending delete phase. So it's already handled in that test case.
@Test @Test
public void testIcannActivityReportField_getsLogged() throws Exception { void testIcannActivityReportField_getsLogged() throws Exception {
runFlow(); runFlow();
assertIcannReportingActivityFieldLogged("srs-dom-transfer-reject"); assertIcannReportingActivityFieldLogged("srs-dom-transfer-reject");
assertTldsFieldLogged("tld"); assertTldsFieldLogged("tld");
@ -339,7 +339,7 @@ public class DomainTransferRejectFlowTest
} }
@Test @Test
public void testIcannTransactionRecord_noRecordsToCancel() throws Exception { void testIcannTransactionRecord_noRecordsToCancel() throws Exception {
setUpGracePeriodDurations(); setUpGracePeriodDurations();
runFlow(); runFlow();
HistoryEntry persistedEntry = getOnlyHistoryEntryOfType(domain, DOMAIN_TRANSFER_REJECT); HistoryEntry persistedEntry = getOnlyHistoryEntryOfType(domain, DOMAIN_TRANSFER_REJECT);
@ -349,7 +349,7 @@ public class DomainTransferRejectFlowTest
} }
@Test @Test
public void testIcannTransactionRecord_cancelsPreviousRecords() throws Exception { void testIcannTransactionRecord_cancelsPreviousRecords() throws Exception {
setUpGracePeriodDurations(); setUpGracePeriodDurations();
DomainTransactionRecord previousSuccessRecord = DomainTransactionRecord previousSuccessRecord =
DomainTransactionRecord.create("tld", clock.nowUtc().plusDays(1), TRANSFER_SUCCESSFUL, 1); DomainTransactionRecord.create("tld", clock.nowUtc().plusDays(1), TRANSFER_SUCCESSFUL, 1);

View file

@ -109,11 +109,11 @@ import java.util.stream.Stream;
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 DomainTransferRequestFlow}. */ /** Unit tests for {@link DomainTransferRequestFlow}. */
public class DomainTransferRequestFlowTest class DomainTransferRequestFlowTest
extends DomainTransferFlowTestCase<DomainTransferRequestFlow, DomainBase> { extends DomainTransferFlowTestCase<DomainTransferRequestFlow, DomainBase> {
private static final ImmutableMap<String, String> BASE_FEE_MAP = private static final ImmutableMap<String, String> BASE_FEE_MAP =
@ -151,8 +151,8 @@ public class DomainTransferRequestFlowTest
.put("FEE_NS", "fee12") .put("FEE_NS", "fee12")
.build(); .build();
@Before @BeforeEach
public void setUp() { void setUp() {
setEppInput("domain_transfer_request.xml"); setEppInput("domain_transfer_request.xml");
setClientIdForFlow("NewRegistrar"); setClientIdForFlow("NewRegistrar");
} }
@ -655,7 +655,7 @@ public class DomainTransferRequestFlowTest
} }
@Test @Test
public void testDryRun() throws Exception { void testDryRun() throws Exception {
setupDomain("example", "tld"); setupDomain("example", "tld");
setEppInput("domain_transfer_request.xml"); setEppInput("domain_transfer_request.xml");
eppLoader.replaceAll("JD1234-REP", contact.getRepoId()); eppLoader.replaceAll("JD1234-REP", contact.getRepoId());
@ -663,34 +663,34 @@ public class DomainTransferRequestFlowTest
} }
@Test @Test
public void testSuccess() throws Exception { void testSuccess() throws Exception {
setupDomain("example", "tld"); setupDomain("example", "tld");
doSuccessfulTest("domain_transfer_request.xml", "domain_transfer_request_response.xml"); doSuccessfulTest("domain_transfer_request.xml", "domain_transfer_request_response.xml");
} }
@Test @Test
public void testSuccess_fee_v06() throws Exception { void testSuccess_fee_v06() throws Exception {
setupDomain("example", "tld"); setupDomain("example", "tld");
doSuccessfulTest( doSuccessfulTest(
"domain_transfer_request_fee.xml", "domain_transfer_request_response_fee.xml", FEE_06_MAP); "domain_transfer_request_fee.xml", "domain_transfer_request_response_fee.xml", FEE_06_MAP);
} }
@Test @Test
public void testSuccess_fee_v11() throws Exception { void testSuccess_fee_v11() throws Exception {
setupDomain("example", "tld"); setupDomain("example", "tld");
doSuccessfulTest( doSuccessfulTest(
"domain_transfer_request_fee.xml", "domain_transfer_request_response_fee.xml", FEE_11_MAP); "domain_transfer_request_fee.xml", "domain_transfer_request_response_fee.xml", FEE_11_MAP);
} }
@Test @Test
public void testSuccess_fee_v12() throws Exception { void testSuccess_fee_v12() throws Exception {
setupDomain("example", "tld"); setupDomain("example", "tld");
doSuccessfulTest( doSuccessfulTest(
"domain_transfer_request_fee.xml", "domain_transfer_request_response_fee.xml", FEE_12_MAP); "domain_transfer_request_fee.xml", "domain_transfer_request_response_fee.xml", FEE_12_MAP);
} }
@Test @Test
public void testSuccess_fee_withDefaultAttributes_v06() throws Exception { void testSuccess_fee_withDefaultAttributes_v06() throws Exception {
setupDomain("example", "tld"); setupDomain("example", "tld");
doSuccessfulTest( doSuccessfulTest(
"domain_transfer_request_fee_defaults.xml", "domain_transfer_request_fee_defaults.xml",
@ -699,7 +699,7 @@ public class DomainTransferRequestFlowTest
} }
@Test @Test
public void testSuccess_fee_withDefaultAttributes_v11() throws Exception { void testSuccess_fee_withDefaultAttributes_v11() throws Exception {
setupDomain("example", "tld"); setupDomain("example", "tld");
doSuccessfulTest( doSuccessfulTest(
"domain_transfer_request_fee_defaults.xml", "domain_transfer_request_fee_defaults.xml",
@ -708,7 +708,7 @@ public class DomainTransferRequestFlowTest
} }
@Test @Test
public void testSuccess_fee_withDefaultAttributes_v12() throws Exception { void testSuccess_fee_withDefaultAttributes_v12() throws Exception {
setupDomain("example", "tld"); setupDomain("example", "tld");
doSuccessfulTest( doSuccessfulTest(
"domain_transfer_request_fee_defaults.xml", "domain_transfer_request_fee_defaults.xml",
@ -717,7 +717,7 @@ public class DomainTransferRequestFlowTest
} }
@Test @Test
public void testFailure_refundableFee_v06() { void testFailure_refundableFee_v06() {
setupDomain("example", "tld"); setupDomain("example", "tld");
EppException thrown = EppException thrown =
assertThrows( assertThrows(
@ -727,7 +727,7 @@ public class DomainTransferRequestFlowTest
} }
@Test @Test
public void testFailure_refundableFee_v11() { void testFailure_refundableFee_v11() {
setupDomain("example", "tld"); setupDomain("example", "tld");
EppException thrown = EppException thrown =
assertThrows( assertThrows(
@ -737,7 +737,7 @@ public class DomainTransferRequestFlowTest
} }
@Test @Test
public void testFailure_refundableFee_v12() { void testFailure_refundableFee_v12() {
setupDomain("example", "tld"); setupDomain("example", "tld");
EppException thrown = EppException thrown =
assertThrows( assertThrows(
@ -747,7 +747,7 @@ public class DomainTransferRequestFlowTest
} }
@Test @Test
public void testFailure_gracePeriodFee_v06() { void testFailure_gracePeriodFee_v06() {
setupDomain("example", "tld"); setupDomain("example", "tld");
EppException thrown = EppException thrown =
assertThrows( assertThrows(
@ -757,7 +757,7 @@ public class DomainTransferRequestFlowTest
} }
@Test @Test
public void testFailure_gracePeriodFee_v11() { void testFailure_gracePeriodFee_v11() {
setupDomain("example", "tld"); setupDomain("example", "tld");
EppException thrown = EppException thrown =
assertThrows( assertThrows(
@ -767,7 +767,7 @@ public class DomainTransferRequestFlowTest
} }
@Test @Test
public void testFailure_gracePeriodFee_v12() { void testFailure_gracePeriodFee_v12() {
setupDomain("example", "tld"); setupDomain("example", "tld");
EppException thrown = EppException thrown =
assertThrows( assertThrows(
@ -777,7 +777,7 @@ public class DomainTransferRequestFlowTest
} }
@Test @Test
public void testFailure_appliedFee_v06() { void testFailure_appliedFee_v06() {
setupDomain("example", "tld"); setupDomain("example", "tld");
EppException thrown = EppException thrown =
assertThrows( assertThrows(
@ -787,7 +787,7 @@ public class DomainTransferRequestFlowTest
} }
@Test @Test
public void testFailure_appliedFee_v11() { void testFailure_appliedFee_v11() {
setupDomain("example", "tld"); setupDomain("example", "tld");
EppException thrown = EppException thrown =
assertThrows( assertThrows(
@ -797,7 +797,7 @@ public class DomainTransferRequestFlowTest
} }
@Test @Test
public void testFailure_appliedFee_v12() { void testFailure_appliedFee_v12() {
setupDomain("example", "tld"); setupDomain("example", "tld");
EppException thrown = EppException thrown =
assertThrows( assertThrows(
@ -807,7 +807,7 @@ public class DomainTransferRequestFlowTest
} }
@Test @Test
public void testFailure_suspendedRegistrarCantTransferDomain() { void testFailure_suspendedRegistrarCantTransferDomain() {
setupDomain("example", "tld"); setupDomain("example", "tld");
clock.advanceOneMilli(); clock.advanceOneMilli();
persistResource( persistResource(
@ -824,7 +824,7 @@ public class DomainTransferRequestFlowTest
} }
@Test @Test
public void testFailure_pendingRegistrarCantTransferDomain() { void testFailure_pendingRegistrarCantTransferDomain() {
setupDomain("example", "tld"); setupDomain("example", "tld");
clock.advanceOneMilli(); clock.advanceOneMilli();
persistResource( persistResource(
@ -841,7 +841,7 @@ public class DomainTransferRequestFlowTest
} }
@Test @Test
public void testSuccess_nonDefaultAutomaticTransferLength() throws Exception { void testSuccess_nonDefaultAutomaticTransferLength() throws Exception {
setupDomain("example", "tld"); setupDomain("example", "tld");
persistResource( persistResource(
Registry.get("tld") Registry.get("tld")
@ -853,7 +853,7 @@ public class DomainTransferRequestFlowTest
} }
@Test @Test
public void testSuccess_nonDefaultTransferGracePeriod() throws Exception { void testSuccess_nonDefaultTransferGracePeriod() throws Exception {
setupDomain("example", "tld"); setupDomain("example", "tld");
persistResource( persistResource(
Registry.get("tld") Registry.get("tld")
@ -864,14 +864,14 @@ public class DomainTransferRequestFlowTest
} }
@Test @Test
public void testSuccess_missingPeriod_defaultsToOneYear() throws Exception { void testSuccess_missingPeriod_defaultsToOneYear() throws Exception {
setupDomain("example", "tld"); setupDomain("example", "tld");
doSuccessfulTest( doSuccessfulTest(
"domain_transfer_request_missing_period.xml", "domain_transfer_request_response.xml"); "domain_transfer_request_missing_period.xml", "domain_transfer_request_response.xml");
} }
@Test @Test
public void testSuccess_canTransferAwayFromSuspendedRegistrar() throws Exception { void testSuccess_canTransferAwayFromSuspendedRegistrar() throws Exception {
setupDomain("example", "tld"); setupDomain("example", "tld");
clock.advanceOneMilli(); clock.advanceOneMilli();
persistResource( persistResource(
@ -884,7 +884,7 @@ public class DomainTransferRequestFlowTest
} }
@Test @Test
public void testSuccess_inQuietPeriod() throws Exception { void testSuccess_inQuietPeriod() throws Exception {
setupDomain("example", "tld"); setupDomain("example", "tld");
persistResource( persistResource(
Registry.get("tld") Registry.get("tld")
@ -895,7 +895,7 @@ public class DomainTransferRequestFlowTest
} }
@Test @Test
public void testFailure_multiYearPeriod() { void testFailure_multiYearPeriod() {
setupDomain("example", "tld"); setupDomain("example", "tld");
clock.advanceOneMilli(); clock.advanceOneMilli();
EppException thrown = EppException thrown =
@ -906,8 +906,7 @@ public class DomainTransferRequestFlowTest
} }
@Test @Test
public void testSuccess_superuserExtension_zeroPeriod_nonZeroAutomaticTransferLength() void testSuccess_superuserExtension_zeroPeriod_nonZeroAutomaticTransferLength() throws Exception {
throws Exception {
setupDomain("example", "tld"); setupDomain("example", "tld");
eppRequestSource = EppRequestSource.TOOL; eppRequestSource = EppRequestSource.TOOL;
clock.advanceOneMilli(); clock.advanceOneMilli();
@ -922,8 +921,7 @@ public class DomainTransferRequestFlowTest
} }
@Test @Test
public void testSuccess_superuserExtension_zeroPeriod_zeroAutomaticTransferLength() void testSuccess_superuserExtension_zeroPeriod_zeroAutomaticTransferLength() throws Exception {
throws Exception {
setupDomain("example", "tld"); setupDomain("example", "tld");
eppRequestSource = EppRequestSource.TOOL; eppRequestSource = EppRequestSource.TOOL;
clock.advanceOneMilli(); clock.advanceOneMilli();
@ -938,7 +936,7 @@ public class DomainTransferRequestFlowTest
} }
@Test @Test
public void testSuccess_superuserExtension_nonZeroPeriod_nonZeroAutomaticTransferLength() void testSuccess_superuserExtension_nonZeroPeriod_nonZeroAutomaticTransferLength()
throws Exception { throws Exception {
setupDomain("example", "tld"); setupDomain("example", "tld");
eppRequestSource = EppRequestSource.TOOL; eppRequestSource = EppRequestSource.TOOL;
@ -954,7 +952,7 @@ public class DomainTransferRequestFlowTest
} }
@Test @Test
public void testSuccess_superuserExtension_zeroPeriod_autorenewGraceActive() throws Exception { void testSuccess_superuserExtension_zeroPeriod_autorenewGraceActive() throws Exception {
eppRequestSource = EppRequestSource.TOOL; eppRequestSource = EppRequestSource.TOOL;
setupDomain("example", "tld"); setupDomain("example", "tld");
Key<BillingEvent.Recurring> existingAutorenewEvent = domain.getAutorenewBillingEvent(); Key<BillingEvent.Recurring> existingAutorenewEvent = domain.getAutorenewBillingEvent();
@ -986,7 +984,7 @@ public class DomainTransferRequestFlowTest
} }
@Test @Test
public void testFailure_superuserExtension_twoYearPeriod() { void testFailure_superuserExtension_twoYearPeriod() {
setupDomain("example", "tld"); setupDomain("example", "tld");
eppRequestSource = EppRequestSource.TOOL; eppRequestSource = EppRequestSource.TOOL;
clock.advanceOneMilli(); clock.advanceOneMilli();
@ -1000,7 +998,7 @@ public class DomainTransferRequestFlowTest
} }
@Test @Test
public void testFailure_superuserExtension_zeroPeriod_feeTransferExtension() { void testFailure_superuserExtension_zeroPeriod_feeTransferExtension() {
setupDomain("example", "tld"); setupDomain("example", "tld");
eppRequestSource = EppRequestSource.TOOL; eppRequestSource = EppRequestSource.TOOL;
clock.advanceOneMilli(); clock.advanceOneMilli();
@ -1014,7 +1012,7 @@ public class DomainTransferRequestFlowTest
} }
@Test @Test
public void testSuccess_cappedExpiration() throws Exception { void testSuccess_cappedExpiration() throws Exception {
setupDomain("example", "tld"); setupDomain("example", "tld");
// Set the domain to expire 10 years from now (as if it were just created with a 10-year term). // Set the domain to expire 10 years from now (as if it were just created with a 10-year term).
domain = domain =
@ -1031,14 +1029,14 @@ public class DomainTransferRequestFlowTest
} }
@Test @Test
public void testSuccess_domainAuthInfo() throws Exception { void testSuccess_domainAuthInfo() throws Exception {
setupDomain("example", "tld"); setupDomain("example", "tld");
doSuccessfulTest( doSuccessfulTest(
"domain_transfer_request_domain_authinfo.xml", "domain_transfer_request_response.xml"); "domain_transfer_request_domain_authinfo.xml", "domain_transfer_request_response.xml");
} }
@Test @Test
public void testSuccess_customLogicFee() throws Exception { void testSuccess_customLogicFee() throws Exception {
setupDomain("expensive-domain", "foo"); setupDomain("expensive-domain", "foo");
clock.advanceOneMilli(); clock.advanceOneMilli();
doSuccessfulTest( doSuccessfulTest(
@ -1057,7 +1055,7 @@ public class DomainTransferRequestFlowTest
} }
@Test @Test
public void testFailure_notAuthorizedForTld() { void testFailure_notAuthorizedForTld() {
setupDomain("example", "tld"); setupDomain("example", "tld");
persistResource( persistResource(
loadRegistrar("NewRegistrar").asBuilder().setAllowedTlds(ImmutableSet.of()).build()); loadRegistrar("NewRegistrar").asBuilder().setAllowedTlds(ImmutableSet.of()).build());
@ -1071,7 +1069,7 @@ public class DomainTransferRequestFlowTest
} }
@Test @Test
public void testSuccess_superuserNotAuthorizedForTld() throws Exception { void testSuccess_superuserNotAuthorizedForTld() throws Exception {
setupDomain("example", "tld"); setupDomain("example", "tld");
persistResource( persistResource(
loadRegistrar("NewRegistrar").asBuilder().setAllowedTlds(ImmutableSet.of()).build()); loadRegistrar("NewRegistrar").asBuilder().setAllowedTlds(ImmutableSet.of()).build());
@ -1081,7 +1079,7 @@ public class DomainTransferRequestFlowTest
} }
@Test @Test
public void testSuccess_autorenewGraceActive_onlyAtTransferRequestTime() throws Exception { void testSuccess_autorenewGraceActive_onlyAtTransferRequestTime() throws Exception {
setupDomain("example", "tld"); setupDomain("example", "tld");
// Set the domain to have auto-renewed long enough ago that it is still in the autorenew grace // Set the domain to have auto-renewed long enough ago that it is still in the autorenew grace
// period at the transfer request time, but will have exited it by the automatic transfer time. // period at the transfer request time, but will have exited it by the automatic transfer time.
@ -1110,7 +1108,7 @@ public class DomainTransferRequestFlowTest
} }
@Test @Test
public void testSuccess_autorenewGraceActive_throughoutTransferWindow() throws Exception { void testSuccess_autorenewGraceActive_throughoutTransferWindow() throws Exception {
setupDomain("example", "tld"); setupDomain("example", "tld");
Key<BillingEvent.Recurring> existingAutorenewEvent = domain.getAutorenewBillingEvent(); Key<BillingEvent.Recurring> existingAutorenewEvent = domain.getAutorenewBillingEvent();
// Set domain to have auto-renewed just before the transfer request, so that it will have an // Set domain to have auto-renewed just before the transfer request, so that it will have an
@ -1148,7 +1146,7 @@ public class DomainTransferRequestFlowTest
} }
@Test @Test
public void testSuccess_autorenewGraceActive_onlyAtAutomaticTransferTime() throws Exception { void testSuccess_autorenewGraceActive_onlyAtAutomaticTransferTime() throws Exception {
setupDomain("example", "tld"); setupDomain("example", "tld");
Key<BillingEvent.Recurring> existingAutorenewEvent = domain.getAutorenewBillingEvent(); Key<BillingEvent.Recurring> existingAutorenewEvent = domain.getAutorenewBillingEvent();
// Set domain to expire in 1 day, so that it will be in the autorenew grace period by the // Set domain to expire in 1 day, so that it will be in the autorenew grace period by the
@ -1176,7 +1174,7 @@ public class DomainTransferRequestFlowTest
} }
@Test @Test
public void testSuccess_premiumNotBlocked() throws Exception { void testSuccess_premiumNotBlocked() throws Exception {
setupDomain("rich", "example"); setupDomain("rich", "example");
clock.advanceOneMilli(); clock.advanceOneMilli();
// We don't verify the results; just check that the flow doesn't fail. // We don't verify the results; just check that the flow doesn't fail.
@ -1184,7 +1182,7 @@ public class DomainTransferRequestFlowTest
} }
@Test @Test
public void testSuccess_premiumNotBlockedInSuperuserMode() throws Exception { void testSuccess_premiumNotBlockedInSuperuserMode() throws Exception {
setupDomain("rich", "example"); setupDomain("rich", "example");
clock.advanceOneMilli(); clock.advanceOneMilli();
// Modify the Registrar to block premium names. // Modify the Registrar to block premium names.
@ -1206,22 +1204,22 @@ public class DomainTransferRequestFlowTest
} }
@Test @Test
public void testFailure_wrongCurrency_v06() { void testFailure_wrongCurrency_v06() {
runWrongCurrencyTest(FEE_06_MAP); runWrongCurrencyTest(FEE_06_MAP);
} }
@Test @Test
public void testFailure_wrongCurrency_v11() { void testFailure_wrongCurrency_v11() {
runWrongCurrencyTest(FEE_11_MAP); runWrongCurrencyTest(FEE_11_MAP);
} }
@Test @Test
public void testFailure_wrongCurrency_v12() { void testFailure_wrongCurrency_v12() {
runWrongCurrencyTest(FEE_12_MAP); runWrongCurrencyTest(FEE_12_MAP);
} }
@Test @Test
public void testFailure_unknownCurrency() { void testFailure_unknownCurrency() {
Map<String, String> substitutions = Maps.newHashMap(); Map<String, String> substitutions = Maps.newHashMap();
substitutions.putAll(FEE_06_MAP); substitutions.putAll(FEE_06_MAP);
substitutions.put("CURRENCY", "BAD"); substitutions.put("CURRENCY", "BAD");
@ -1232,7 +1230,7 @@ public class DomainTransferRequestFlowTest
} }
@Test @Test
public void testFailure_feeGivenInWrongScale_v06() { void testFailure_feeGivenInWrongScale_v06() {
setupDomain("example", "tld"); setupDomain("example", "tld");
EppException thrown = EppException thrown =
assertThrows( assertThrows(
@ -1242,7 +1240,7 @@ public class DomainTransferRequestFlowTest
} }
@Test @Test
public void testFailure_feeGivenInWrongScale_v11() { void testFailure_feeGivenInWrongScale_v11() {
setupDomain("example", "tld"); setupDomain("example", "tld");
EppException thrown = EppException thrown =
assertThrows( assertThrows(
@ -1252,7 +1250,7 @@ public class DomainTransferRequestFlowTest
} }
@Test @Test
public void testFailure_feeGivenInWrongScale_v12() { void testFailure_feeGivenInWrongScale_v12() {
setupDomain("example", "tld"); setupDomain("example", "tld");
EppException thrown = EppException thrown =
assertThrows( assertThrows(
@ -1275,25 +1273,25 @@ public class DomainTransferRequestFlowTest
} }
@Test @Test
public void testFailure_wrongFeeAmount_v06() { void testFailure_wrongFeeAmount_v06() {
setupDomain("example", "tld"); setupDomain("example", "tld");
runWrongFeeAmountTest(FEE_06_MAP); runWrongFeeAmountTest(FEE_06_MAP);
} }
@Test @Test
public void testFailure_wrongFeeAmount_v11() { void testFailure_wrongFeeAmount_v11() {
setupDomain("example", "tld"); setupDomain("example", "tld");
runWrongFeeAmountTest(FEE_11_MAP); runWrongFeeAmountTest(FEE_11_MAP);
} }
@Test @Test
public void testFailure_wrongFeeAmount_v12() { void testFailure_wrongFeeAmount_v12() {
setupDomain("example", "tld"); setupDomain("example", "tld");
runWrongFeeAmountTest(FEE_12_MAP); runWrongFeeAmountTest(FEE_12_MAP);
} }
@Test @Test
public void testFailure_premiumBlocked() { void testFailure_premiumBlocked() {
setupDomain("rich", "example"); setupDomain("rich", "example");
// Modify the Registrar to block premium names. // Modify the Registrar to block premium names.
persistResource(loadRegistrar("NewRegistrar").asBuilder().setBlockPremiumNames(true).build()); persistResource(loadRegistrar("NewRegistrar").asBuilder().setBlockPremiumNames(true).build());
@ -1305,7 +1303,7 @@ public class DomainTransferRequestFlowTest
} }
@Test @Test
public void testFailure_feeNotProvidedOnPremiumName() { void testFailure_feeNotProvidedOnPremiumName() {
setupDomain("rich", "example"); setupDomain("rich", "example");
EppException thrown = EppException thrown =
assertThrows( assertThrows(
@ -1315,7 +1313,7 @@ public class DomainTransferRequestFlowTest
} }
@Test @Test
public void testFailure_noAuthInfo() { void testFailure_noAuthInfo() {
setupDomain("example", "tld"); setupDomain("example", "tld");
EppException thrown = EppException thrown =
assertThrows( assertThrows(
@ -1325,7 +1323,7 @@ public class DomainTransferRequestFlowTest
} }
@Test @Test
public void testFailure_badContactPassword() { void testFailure_badContactPassword() {
setupDomain("example", "tld"); setupDomain("example", "tld");
// Change the contact's password so it does not match the password in the file. // Change the contact's password so it does not match the password in the file.
contact = contact =
@ -1342,7 +1340,7 @@ public class DomainTransferRequestFlowTest
} }
@Test @Test
public void testFailure_badContactRepoId() { void testFailure_badContactRepoId() {
setupDomain("example", "tld"); setupDomain("example", "tld");
// Set the contact to a different ROID, but don't persist it; this is just so the substitution // Set the contact to a different ROID, but don't persist it; this is just so the substitution
// code above will write the wrong ROID into the file. // code above will write the wrong ROID into the file.
@ -1355,42 +1353,42 @@ public class DomainTransferRequestFlowTest
} }
@Test @Test
public void testSuccess_clientApproved() throws Exception { void testSuccess_clientApproved() throws Exception {
setupDomain("example", "tld"); setupDomain("example", "tld");
changeTransferStatus(TransferStatus.CLIENT_APPROVED); changeTransferStatus(TransferStatus.CLIENT_APPROVED);
doSuccessfulTest("domain_transfer_request.xml", "domain_transfer_request_response.xml"); doSuccessfulTest("domain_transfer_request.xml", "domain_transfer_request_response.xml");
} }
@Test @Test
public void testSuccess_clientRejected() throws Exception { void testSuccess_clientRejected() throws Exception {
setupDomain("example", "tld"); setupDomain("example", "tld");
changeTransferStatus(TransferStatus.CLIENT_REJECTED); changeTransferStatus(TransferStatus.CLIENT_REJECTED);
doSuccessfulTest("domain_transfer_request.xml", "domain_transfer_request_response.xml"); doSuccessfulTest("domain_transfer_request.xml", "domain_transfer_request_response.xml");
} }
@Test @Test
public void testSuccess_clientCancelled() throws Exception { void testSuccess_clientCancelled() throws Exception {
setupDomain("example", "tld"); setupDomain("example", "tld");
changeTransferStatus(TransferStatus.CLIENT_CANCELLED); changeTransferStatus(TransferStatus.CLIENT_CANCELLED);
doSuccessfulTest("domain_transfer_request.xml", "domain_transfer_request_response.xml"); doSuccessfulTest("domain_transfer_request.xml", "domain_transfer_request_response.xml");
} }
@Test @Test
public void testSuccess_serverApproved() throws Exception { void testSuccess_serverApproved() throws Exception {
setupDomain("example", "tld"); setupDomain("example", "tld");
changeTransferStatus(TransferStatus.SERVER_APPROVED); changeTransferStatus(TransferStatus.SERVER_APPROVED);
doSuccessfulTest("domain_transfer_request.xml", "domain_transfer_request_response.xml"); doSuccessfulTest("domain_transfer_request.xml", "domain_transfer_request_response.xml");
} }
@Test @Test
public void testSuccess_serverCancelled() throws Exception { void testSuccess_serverCancelled() throws Exception {
setupDomain("example", "tld"); setupDomain("example", "tld");
changeTransferStatus(TransferStatus.SERVER_CANCELLED); changeTransferStatus(TransferStatus.SERVER_CANCELLED);
doSuccessfulTest("domain_transfer_request.xml", "domain_transfer_request_response.xml"); doSuccessfulTest("domain_transfer_request.xml", "domain_transfer_request_response.xml");
} }
@Test @Test
public void testFailure_pending() { void testFailure_pending() {
setupDomain("example", "tld"); setupDomain("example", "tld");
domain = domain =
persistResource( persistResource(
@ -1412,7 +1410,7 @@ public class DomainTransferRequestFlowTest
} }
@Test @Test
public void testFailure_badDomainPassword() { void testFailure_badDomainPassword() {
setupDomain("example", "tld"); setupDomain("example", "tld");
// Change the domain's password so it does not match the password in the file. // Change the domain's password so it does not match the password in the file.
domain = domain =
@ -1429,7 +1427,7 @@ public class DomainTransferRequestFlowTest
} }
@Test @Test
public void testFailure_sponsoringClient() { void testFailure_sponsoringClient() {
setupDomain("example", "tld"); setupDomain("example", "tld");
setClientIdForFlow("TheRegistrar"); setClientIdForFlow("TheRegistrar");
EppException thrown = EppException thrown =
@ -1440,7 +1438,7 @@ public class DomainTransferRequestFlowTest
} }
@Test @Test
public void testFailure_deletedDomain() throws Exception { void testFailure_deletedDomain() throws Exception {
setupDomain("example", "tld"); setupDomain("example", "tld");
domain = domain =
persistResource(domain.asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build()); persistResource(domain.asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build());
@ -1452,7 +1450,7 @@ public class DomainTransferRequestFlowTest
} }
@Test @Test
public void testFailure_invalidDomain() throws Exception { void testFailure_invalidDomain() throws Exception {
setupDomain("example", "tld"); setupDomain("example", "tld");
setEppInput( setEppInput(
"domain_transfer_request_wildcard.xml", "domain_transfer_request_wildcard.xml",
@ -1467,7 +1465,7 @@ public class DomainTransferRequestFlowTest
} }
@Test @Test
public void testFailure_nonexistentDomain() { void testFailure_nonexistentDomain() {
createTld("tld"); createTld("tld");
contact = persistActiveContact("jd1234"); contact = persistActiveContact("jd1234");
ResourceDoesNotExistException thrown = ResourceDoesNotExistException thrown =
@ -1478,7 +1476,7 @@ public class DomainTransferRequestFlowTest
} }
@Test @Test
public void testFailure_periodInMonths() { void testFailure_periodInMonths() {
setupDomain("example", "tld"); setupDomain("example", "tld");
EppException thrown = EppException thrown =
assertThrows( assertThrows(
@ -1488,7 +1486,7 @@ public class DomainTransferRequestFlowTest
} }
@Test @Test
public void testFailure_clientTransferProhibited() { void testFailure_clientTransferProhibited() {
setupDomain("example", "tld"); setupDomain("example", "tld");
domain = domain =
persistResource( persistResource(
@ -1501,7 +1499,7 @@ public class DomainTransferRequestFlowTest
} }
@Test @Test
public void testFailure_serverTransferProhibited() { void testFailure_serverTransferProhibited() {
setupDomain("example", "tld"); setupDomain("example", "tld");
domain = domain =
persistResource( persistResource(
@ -1514,7 +1512,7 @@ public class DomainTransferRequestFlowTest
} }
@Test @Test
public void testFailure_pendingDelete() { void testFailure_pendingDelete() {
setupDomain("example", "tld"); setupDomain("example", "tld");
domain = persistResource(domain.asBuilder().addStatusValue(StatusValue.PENDING_DELETE).build()); domain = persistResource(domain.asBuilder().addStatusValue(StatusValue.PENDING_DELETE).build());
ResourceStatusProhibitsOperationException thrown = ResourceStatusProhibitsOperationException thrown =
@ -1525,7 +1523,7 @@ public class DomainTransferRequestFlowTest
} }
@Test @Test
public void testIcannActivityReportField_getsLogged() throws Exception { void testIcannActivityReportField_getsLogged() throws Exception {
setupDomain("example", "tld"); setupDomain("example", "tld");
clock.advanceOneMilli(); clock.advanceOneMilli();
runTest("domain_transfer_request.xml", UserPrivileges.NORMAL); runTest("domain_transfer_request.xml", UserPrivileges.NORMAL);
@ -1534,7 +1532,7 @@ public class DomainTransferRequestFlowTest
} }
@Test @Test
public void testIcannTransactionRecord_getsStored() throws Exception { void testIcannTransactionRecord_getsStored() throws Exception {
setupDomain("example", "tld"); setupDomain("example", "tld");
persistResource( persistResource(
Registry.get("tld") Registry.get("tld")

View file

@ -90,8 +90,8 @@ import google.registry.model.registry.Registry;
import google.registry.model.reporting.HistoryEntry; import google.registry.model.reporting.HistoryEntry;
import google.registry.persistence.VKey; import google.registry.persistence.VKey;
import org.joda.money.Money; import org.joda.money.Money;
import org.junit.Before; import org.junit.jupiter.api.BeforeEach;
import org.junit.Test; import org.junit.jupiter.api.Test;
/** Unit tests for {@link DomainUpdateFlow}. */ /** Unit tests for {@link DomainUpdateFlow}. */
public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, DomainBase> { public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, DomainBase> {
@ -110,7 +110,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
ContactResource unusedContact; ContactResource unusedContact;
HistoryEntry historyEntryDomainCreate; HistoryEntry historyEntryDomainCreate;
@Before @BeforeEach
public void initDomainTest() { public void initDomainTest() {
createTld("tld"); createTld("tld");
// Note that "domain_update.xml" tests adding and removing the same contact type. // Note that "domain_update.xml" tests adding and removing the same contact type.

View file

@ -48,7 +48,6 @@ import google.registry.model.domain.token.AllocationToken.TokenStatus;
import google.registry.model.registry.Registry; import google.registry.model.registry.Registry;
import google.registry.model.reporting.HistoryEntry; import google.registry.model.reporting.HistoryEntry;
import google.registry.testing.AppEngineRule; import google.registry.testing.AppEngineRule;
import google.registry.testing.ShardableTestCase;
import org.joda.time.DateTime; import org.joda.time.DateTime;
import org.junit.Before; import org.junit.Before;
import org.junit.Rule; import org.junit.Rule;
@ -58,7 +57,7 @@ import org.junit.runners.JUnit4;
/** Unit tests for {@link AllocationTokenFlowUtils}. */ /** Unit tests for {@link AllocationTokenFlowUtils}. */
@RunWith(JUnit4.class) @RunWith(JUnit4.class)
public class AllocationTokenFlowUtilsTest extends ShardableTestCase { public class AllocationTokenFlowUtilsTest {
private final AllocationTokenFlowUtils flowUtils = private final AllocationTokenFlowUtils flowUtils =
new AllocationTokenFlowUtils(new AllocationTokenCustomLogic()); new AllocationTokenFlowUtils(new AllocationTokenCustomLogic());

View file

@ -24,17 +24,17 @@ import google.registry.flows.EppException;
import google.registry.flows.ResourceCheckFlowTestCase; import google.registry.flows.ResourceCheckFlowTestCase;
import google.registry.flows.exceptions.TooManyResourceChecksException; import google.registry.flows.exceptions.TooManyResourceChecksException;
import google.registry.model.host.HostResource; import google.registry.model.host.HostResource;
import org.junit.Test; import org.junit.jupiter.api.Test;
/** Unit tests for {@link HostCheckFlow}. */ /** Unit tests for {@link HostCheckFlow}. */
public class HostCheckFlowTest extends ResourceCheckFlowTestCase<HostCheckFlow, HostResource> { class HostCheckFlowTest extends ResourceCheckFlowTestCase<HostCheckFlow, HostResource> {
public HostCheckFlowTest() { HostCheckFlowTest() {
setEppInput("host_check.xml"); setEppInput("host_check.xml");
} }
@Test @Test
public void testNothingExists() throws Exception { void testNothingExists() throws Exception {
// These ids come from the check xml. // These ids come from the check xml.
doCheckTest( doCheckTest(
create(true, "ns1.example.tld", null), create(true, "ns1.example.tld", null),
@ -43,7 +43,7 @@ public class HostCheckFlowTest extends ResourceCheckFlowTestCase<HostCheckFlow,
} }
@Test @Test
public void testOneExists() throws Exception { void testOneExists() throws Exception {
persistActiveHost("ns1.example.tld"); persistActiveHost("ns1.example.tld");
// These ids come from the check xml. // These ids come from the check xml.
doCheckTest( doCheckTest(
@ -53,7 +53,7 @@ public class HostCheckFlowTest extends ResourceCheckFlowTestCase<HostCheckFlow,
} }
@Test @Test
public void testOneExistsButWasDeleted() throws Exception { void testOneExistsButWasDeleted() throws Exception {
persistDeletedHost("ns1.example.tld", clock.nowUtc().minusDays(1)); persistDeletedHost("ns1.example.tld", clock.nowUtc().minusDays(1));
// These ids come from the check xml. // These ids come from the check xml.
doCheckTest( doCheckTest(
@ -63,27 +63,27 @@ public class HostCheckFlowTest extends ResourceCheckFlowTestCase<HostCheckFlow,
} }
@Test @Test
public void testXmlMatches() throws Exception { void testXmlMatches() throws Exception {
persistActiveHost("ns2.example.tld"); persistActiveHost("ns2.example.tld");
runFlowAssertResponse(loadFile("host_check_response.xml")); runFlowAssertResponse(loadFile("host_check_response.xml"));
} }
@Test @Test
public void test50IdsAllowed() throws Exception { void test50IdsAllowed() throws Exception {
// Make sure we don't have a regression that reduces the number of allowed checks. // Make sure we don't have a regression that reduces the number of allowed checks.
setEppInput("host_check_50.xml"); setEppInput("host_check_50.xml");
runFlow(); runFlow();
} }
@Test @Test
public void testTooManyIds() { void testTooManyIds() {
setEppInput("host_check_51.xml"); setEppInput("host_check_51.xml");
EppException thrown = assertThrows(TooManyResourceChecksException.class, this::runFlow); EppException thrown = assertThrows(TooManyResourceChecksException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml(); assertAboutEppExceptions().that(thrown).marshalsToXml();
} }
@Test @Test
public void testIcannActivityReportField_getsLogged() throws Exception { void testIcannActivityReportField_getsLogged() throws Exception {
runFlow(); runFlow();
assertIcannReportingActivityFieldLogged("srs-host-check"); assertIcannReportingActivityFieldLogged("srs-host-check");
} }

View file

@ -54,10 +54,10 @@ import google.registry.model.eppcommon.StatusValue;
import google.registry.model.host.HostResource; import google.registry.model.host.HostResource;
import google.registry.model.reporting.HistoryEntry; import google.registry.model.reporting.HistoryEntry;
import org.joda.time.DateTime; import org.joda.time.DateTime;
import org.junit.Test; import org.junit.jupiter.api.Test;
/** Unit tests for {@link HostCreateFlow}. */ /** Unit tests for {@link HostCreateFlow}. */
public class HostCreateFlowTest extends ResourceFlowTestCase<HostCreateFlow, HostResource> { class HostCreateFlowTest extends ResourceFlowTestCase<HostCreateFlow, HostResource> {
private void setEppHostCreateInput(String hostName, String hostAddrs) { private void setEppHostCreateInput(String hostName, String hostAddrs) {
setEppInput( setEppInput(
@ -73,7 +73,7 @@ public class HostCreateFlowTest extends ResourceFlowTestCase<HostCreateFlow, Hos
+ "<host:addr ip=\"v6\">1080:0:0:0:8:800:200C:417A</host:addr>"); + "<host:addr ip=\"v6\">1080:0:0:0:8:800:200C:417A</host:addr>");
} }
public HostCreateFlowTest() { HostCreateFlowTest() {
setEppHostCreateInput("ns1.example.tld", null); setEppHostCreateInput("ns1.example.tld", null);
clock.setTo(DateTime.parse("1999-04-03T22:00:00.0Z")); clock.setTo(DateTime.parse("1999-04-03T22:00:00.0Z"));
} }
@ -101,19 +101,19 @@ public class HostCreateFlowTest extends ResourceFlowTestCase<HostCreateFlow, Hos
} }
@Test @Test
public void testDryRun() throws Exception { void testDryRun() throws Exception {
dryRunFlowAssertResponse(loadFile("host_create_response.xml")); dryRunFlowAssertResponse(loadFile("host_create_response.xml"));
} }
@Test @Test
public void testSuccess_externalNeverExisted() throws Exception { void testSuccess_externalNeverExisted() throws Exception {
doSuccessfulTest(); doSuccessfulTest();
assertAboutHosts().that(reloadResourceByForeignKey()).hasSuperordinateDomain(null); assertAboutHosts().that(reloadResourceByForeignKey()).hasSuperordinateDomain(null);
assertNoDnsTasksEnqueued(); assertNoDnsTasksEnqueued();
} }
@Test @Test
public void testSuccess_internalNeverExisted() throws Exception { void testSuccess_internalNeverExisted() throws Exception {
doSuccessfulInternalTest("tld"); doSuccessfulInternalTest("tld");
HostResource host = reloadResourceByForeignKey(); HostResource host = reloadResourceByForeignKey();
DomainBase superordinateDomain = DomainBase superordinateDomain =
@ -124,7 +124,7 @@ public class HostCreateFlowTest extends ResourceFlowTestCase<HostCreateFlow, Hos
} }
@Test @Test
public void testFailure_multipartTLDsAndInvalidHost() { void testFailure_multipartTLDsAndInvalidHost() {
createTlds("bar.tld", "tld"); createTlds("bar.tld", "tld");
setEppHostCreateInputWithIps("ns1.bar.tld"); setEppHostCreateInputWithIps("ns1.bar.tld");
@ -133,7 +133,7 @@ public class HostCreateFlowTest extends ResourceFlowTestCase<HostCreateFlow, Hos
} }
@Test @Test
public void testSuccess_externalExistedButWasDeleted() throws Exception { void testSuccess_externalExistedButWasDeleted() throws Exception {
persistDeletedHost(getUniqueIdFromCommand(), clock.nowUtc().minusDays(1)); persistDeletedHost(getUniqueIdFromCommand(), clock.nowUtc().minusDays(1));
doSuccessfulTest(); doSuccessfulTest();
assertAboutHosts().that(reloadResourceByForeignKey()).hasSuperordinateDomain(null); assertAboutHosts().that(reloadResourceByForeignKey()).hasSuperordinateDomain(null);
@ -141,7 +141,7 @@ public class HostCreateFlowTest extends ResourceFlowTestCase<HostCreateFlow, Hos
} }
@Test @Test
public void testSuccess_internalExistedButWasDeleted() throws Exception { void testSuccess_internalExistedButWasDeleted() throws Exception {
persistDeletedHost(getUniqueIdFromCommand(), clock.nowUtc().minusDays(1)); persistDeletedHost(getUniqueIdFromCommand(), clock.nowUtc().minusDays(1));
doSuccessfulInternalTest("tld"); doSuccessfulInternalTest("tld");
HostResource host = reloadResourceByForeignKey(); HostResource host = reloadResourceByForeignKey();
@ -153,7 +153,7 @@ public class HostCreateFlowTest extends ResourceFlowTestCase<HostCreateFlow, Hos
} }
@Test @Test
public void testFailure_subordinateNeedsIps() { void testFailure_subordinateNeedsIps() {
setEppHostCreateInput("ns1.example.tld", null); setEppHostCreateInput("ns1.example.tld", null);
createTld("tld"); createTld("tld");
persistActiveDomain("example.tld"); persistActiveDomain("example.tld");
@ -162,7 +162,7 @@ public class HostCreateFlowTest extends ResourceFlowTestCase<HostCreateFlow, Hos
} }
@Test @Test
public void testFailure_externalMustNotHaveIps() { void testFailure_externalMustNotHaveIps() {
setEppHostCreateInputWithIps("ns1.example.external"); setEppHostCreateInputWithIps("ns1.example.external");
createTld("tld"); createTld("tld");
persistActiveDomain("example.tld"); persistActiveDomain("example.tld");
@ -171,7 +171,7 @@ public class HostCreateFlowTest extends ResourceFlowTestCase<HostCreateFlow, Hos
} }
@Test @Test
public void testFailure_superordinateMissing() { void testFailure_superordinateMissing() {
setEppHostCreateInput("ns1.example.tld", null); setEppHostCreateInput("ns1.example.tld", null);
createTld("tld"); createTld("tld");
SuperordinateDomainDoesNotExistException thrown = SuperordinateDomainDoesNotExistException thrown =
@ -180,7 +180,7 @@ public class HostCreateFlowTest extends ResourceFlowTestCase<HostCreateFlow, Hos
} }
@Test @Test
public void testFailure_superordinateInPendingDelete() { void testFailure_superordinateInPendingDelete() {
setEppHostCreateInputWithIps("ns1.example.tld"); setEppHostCreateInputWithIps("ns1.example.tld");
createTld("tld"); createTld("tld");
persistResource( persistResource(
@ -198,7 +198,7 @@ public class HostCreateFlowTest extends ResourceFlowTestCase<HostCreateFlow, Hos
} }
@Test @Test
public void testFailure_alreadyExists() throws Exception { void testFailure_alreadyExists() throws Exception {
setEppHostCreateInput("ns1.example.tld", null); setEppHostCreateInput("ns1.example.tld", null);
persistActiveHost(getUniqueIdFromCommand()); persistActiveHost(getUniqueIdFromCommand());
ResourceAlreadyExistsForThisClientException thrown = ResourceAlreadyExistsForThisClientException thrown =
@ -210,7 +210,7 @@ public class HostCreateFlowTest extends ResourceFlowTestCase<HostCreateFlow, Hos
} }
@Test @Test
public void testFailure_resourceContention() throws Exception { void testFailure_resourceContention() throws Exception {
setEppHostCreateInput("ns1.example.tld", null); setEppHostCreateInput("ns1.example.tld", null);
String targetId = getUniqueIdFromCommand(); String targetId = getUniqueIdFromCommand();
persistResource( persistResource(
@ -227,14 +227,14 @@ public class HostCreateFlowTest extends ResourceFlowTestCase<HostCreateFlow, Hos
} }
@Test @Test
public void testFailure_nonLowerCaseHostname() { void testFailure_nonLowerCaseHostname() {
setEppHostCreateInput("ns1.EXAMPLE.tld", null); setEppHostCreateInput("ns1.EXAMPLE.tld", null);
EppException thrown = assertThrows(HostNameNotLowerCaseException.class, this::runFlow); EppException thrown = assertThrows(HostNameNotLowerCaseException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml(); assertAboutEppExceptions().that(thrown).marshalsToXml();
} }
@Test @Test
public void testFailure_nonPunyCodedHostname() { void testFailure_nonPunyCodedHostname() {
setEppHostCreateInput("ns1.çauçalito.みんな", null); setEppHostCreateInput("ns1.çauçalito.みんな", null);
HostNameNotPunyCodedException thrown = HostNameNotPunyCodedException thrown =
assertThrows(HostNameNotPunyCodedException.class, this::runFlow); assertThrows(HostNameNotPunyCodedException.class, this::runFlow);
@ -242,21 +242,21 @@ public class HostCreateFlowTest extends ResourceFlowTestCase<HostCreateFlow, Hos
} }
@Test @Test
public void testFailure_nonCanonicalHostname() { void testFailure_nonCanonicalHostname() {
setEppHostCreateInput("ns1.example.tld.", null); setEppHostCreateInput("ns1.example.tld.", null);
EppException thrown = assertThrows(HostNameNotNormalizedException.class, this::runFlow); EppException thrown = assertThrows(HostNameNotNormalizedException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml(); assertAboutEppExceptions().that(thrown).marshalsToXml();
} }
@Test @Test
public void testFailure_longHostName() { void testFailure_longHostName() {
setEppHostCreateInputWithIps("a" + Strings.repeat(".labelpart", 25) + ".tld"); setEppHostCreateInputWithIps("a" + Strings.repeat(".labelpart", 25) + ".tld");
EppException thrown = assertThrows(HostNameTooLongException.class, this::runFlow); EppException thrown = assertThrows(HostNameTooLongException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml(); assertAboutEppExceptions().that(thrown).marshalsToXml();
} }
@Test @Test
public void testFailure_ip4AddressWithIp6Declaration() { void testFailure_ip4AddressWithIp6Declaration() {
setEppHostCreateInput( setEppHostCreateInput(
"ns1.example.tld", "ns1.example.tld",
"<host:addr ip=\"v4\">192.0.2.2</host:addr>\n" "<host:addr ip=\"v4\">192.0.2.2</host:addr>\n"
@ -273,37 +273,37 @@ public class HostCreateFlowTest extends ResourceFlowTestCase<HostCreateFlow, Hos
} }
@Test @Test
public void testFailure_badCharacter() { void testFailure_badCharacter() {
doFailingHostNameTest("foo bar", InvalidHostNameException.class); doFailingHostNameTest("foo bar", InvalidHostNameException.class);
} }
@Test @Test
public void testFailure_tooShallowPublicSuffix() { void testFailure_tooShallowPublicSuffix() {
doFailingHostNameTest("example.tld", HostNameTooShallowException.class); doFailingHostNameTest("example.tld", HostNameTooShallowException.class);
} }
@Test @Test
public void testFailure_tooShallowCcTld() { void testFailure_tooShallowCcTld() {
doFailingHostNameTest("foo.co.uk", HostNameTooShallowException.class); doFailingHostNameTest("foo.co.uk", HostNameTooShallowException.class);
} }
@Test @Test
public void testFailure_barePublicSuffix() { void testFailure_barePublicSuffix() {
doFailingHostNameTest("com", HostNameTooShallowException.class); doFailingHostNameTest("com", HostNameTooShallowException.class);
} }
@Test @Test
public void testFailure_bareCcTld() { void testFailure_bareCcTld() {
doFailingHostNameTest("co.uk", HostNameTooShallowException.class); doFailingHostNameTest("co.uk", HostNameTooShallowException.class);
} }
@Test @Test
public void testFailure_tooShallowNewTld() { void testFailure_tooShallowNewTld() {
doFailingHostNameTest("example.lol", HostNameTooShallowException.class); doFailingHostNameTest("example.lol", HostNameTooShallowException.class);
} }
@Test @Test
public void testFailure_ccTldInBailiwick() { void testFailure_ccTldInBailiwick() {
createTld("co.uk"); createTld("co.uk");
setEppHostCreateInputWithIps("foo.co.uk"); setEppHostCreateInputWithIps("foo.co.uk");
EppException thrown = assertThrows(HostNameTooShallowException.class, this::runFlow); EppException thrown = assertThrows(HostNameTooShallowException.class, this::runFlow);
@ -311,7 +311,7 @@ public class HostCreateFlowTest extends ResourceFlowTestCase<HostCreateFlow, Hos
} }
@Test @Test
public void testIcannActivityReportField_getsLogged() throws Exception { void testIcannActivityReportField_getsLogged() throws Exception {
runFlow(); runFlow();
assertIcannReportingActivityFieldLogged("srs-host-create"); assertIcannReportingActivityFieldLogged("srs-host-create");
} }

View file

@ -47,25 +47,25 @@ import google.registry.model.reporting.HistoryEntry;
import google.registry.model.transfer.DomainTransferData; import google.registry.model.transfer.DomainTransferData;
import google.registry.model.transfer.TransferStatus; import google.registry.model.transfer.TransferStatus;
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 HostDeleteFlow}. */ /** Unit tests for {@link HostDeleteFlow}. */
public class HostDeleteFlowTest extends ResourceFlowTestCase<HostDeleteFlow, HostResource> { class HostDeleteFlowTest extends ResourceFlowTestCase<HostDeleteFlow, HostResource> {
@Before @BeforeEach
public void initFlowTest() { void initFlowTest() {
setEppInput("host_delete.xml", ImmutableMap.of("HOSTNAME", "ns1.example.tld")); setEppInput("host_delete.xml", ImmutableMap.of("HOSTNAME", "ns1.example.tld"));
} }
@Test @Test
public void testDryRun() throws Exception { void testDryRun() throws Exception {
persistActiveHost("ns1.example.tld"); persistActiveHost("ns1.example.tld");
dryRunFlowAssertResponse(loadFile("host_delete_response.xml")); dryRunFlowAssertResponse(loadFile("host_delete_response.xml"));
} }
@Test @Test
public void testSuccess() throws Exception { void testSuccess() throws Exception {
persistActiveHost("ns1.example.tld"); persistActiveHost("ns1.example.tld");
clock.advanceOneMilli(); clock.advanceOneMilli();
assertTransactionalFlow(true); assertTransactionalFlow(true);
@ -83,7 +83,7 @@ public class HostDeleteFlowTest extends ResourceFlowTestCase<HostDeleteFlow, Hos
} }
@Test @Test
public void testSuccess_clTridNotSpecified() throws Exception { void testSuccess_clTridNotSpecified() throws Exception {
setEppInput("host_delete_no_cltrid.xml", ImmutableMap.of("HOSTNAME", "ns1.example.tld")); setEppInput("host_delete_no_cltrid.xml", ImmutableMap.of("HOSTNAME", "ns1.example.tld"));
persistActiveHost("ns1.example.tld"); persistActiveHost("ns1.example.tld");
clock.advanceOneMilli(); clock.advanceOneMilli();
@ -102,14 +102,14 @@ public class HostDeleteFlowTest extends ResourceFlowTestCase<HostDeleteFlow, Hos
} }
@Test @Test
public void testFailure_neverExisted() { void testFailure_neverExisted() {
ResourceDoesNotExistException thrown = ResourceDoesNotExistException thrown =
assertThrows(ResourceDoesNotExistException.class, this::runFlow); assertThrows(ResourceDoesNotExistException.class, this::runFlow);
assertThat(thrown).hasMessageThat().contains("(ns1.example.tld)"); assertThat(thrown).hasMessageThat().contains("(ns1.example.tld)");
} }
@Test @Test
public void testFailure_existedButWasDeleted() { void testFailure_existedButWasDeleted() {
persistDeletedHost("ns1.example.tld", clock.nowUtc().minusDays(1)); persistDeletedHost("ns1.example.tld", clock.nowUtc().minusDays(1));
ResourceDoesNotExistException thrown = ResourceDoesNotExistException thrown =
assertThrows(ResourceDoesNotExistException.class, this::runFlow); assertThrows(ResourceDoesNotExistException.class, this::runFlow);
@ -127,25 +127,25 @@ public class HostDeleteFlowTest extends ResourceFlowTestCase<HostDeleteFlow, Hos
} }
@Test @Test
public void testFailure_existedButWasClientDeleteProhibited() { void testFailure_existedButWasClientDeleteProhibited() {
doFailingStatusTest( doFailingStatusTest(
StatusValue.CLIENT_DELETE_PROHIBITED, ResourceStatusProhibitsOperationException.class); StatusValue.CLIENT_DELETE_PROHIBITED, ResourceStatusProhibitsOperationException.class);
} }
@Test @Test
public void testFailure_existedButWasServerDeleteProhibited() { void testFailure_existedButWasServerDeleteProhibited() {
doFailingStatusTest( doFailingStatusTest(
StatusValue.SERVER_DELETE_PROHIBITED, ResourceStatusProhibitsOperationException.class); StatusValue.SERVER_DELETE_PROHIBITED, ResourceStatusProhibitsOperationException.class);
} }
@Test @Test
public void testFailure_existedButWasPendingDelete() { void testFailure_existedButWasPendingDelete() {
doFailingStatusTest( doFailingStatusTest(
StatusValue.PENDING_DELETE, ResourceStatusProhibitsOperationException.class); StatusValue.PENDING_DELETE, ResourceStatusProhibitsOperationException.class);
} }
@Test @Test
public void testFailure_unauthorizedClient() { void testFailure_unauthorizedClient() {
sessionMetadata.setClientId("NewRegistrar"); sessionMetadata.setClientId("NewRegistrar");
persistActiveHost("ns1.example.tld"); persistActiveHost("ns1.example.tld");
EppException thrown = assertThrows(ResourceNotOwnedException.class, this::runFlow); EppException thrown = assertThrows(ResourceNotOwnedException.class, this::runFlow);
@ -153,7 +153,7 @@ public class HostDeleteFlowTest extends ResourceFlowTestCase<HostDeleteFlow, Hos
} }
@Test @Test
public void testSuccess_superuserUnauthorizedClient() throws Exception { void testSuccess_superuserUnauthorizedClient() throws Exception {
sessionMetadata.setClientId("NewRegistrar"); sessionMetadata.setClientId("NewRegistrar");
persistActiveHost("ns1.example.tld"); persistActiveHost("ns1.example.tld");
clock.advanceOneMilli(); clock.advanceOneMilli();
@ -172,7 +172,7 @@ public class HostDeleteFlowTest extends ResourceFlowTestCase<HostDeleteFlow, Hos
} }
@Test @Test
public void testSuccess_authorizedClientReadFromSuperordinate() throws Exception { void testSuccess_authorizedClientReadFromSuperordinate() throws Exception {
sessionMetadata.setClientId("TheRegistrar"); sessionMetadata.setClientId("TheRegistrar");
createTld("tld"); createTld("tld");
DomainBase domain = DomainBase domain =
@ -192,7 +192,7 @@ public class HostDeleteFlowTest extends ResourceFlowTestCase<HostDeleteFlow, Hos
} }
@Test @Test
public void testFailure_unauthorizedClientReadFromSuperordinate() { void testFailure_unauthorizedClientReadFromSuperordinate() {
sessionMetadata.setClientId("TheRegistrar"); sessionMetadata.setClientId("TheRegistrar");
createTld("tld"); createTld("tld");
DomainBase domain = DomainBase domain =
@ -212,7 +212,7 @@ public class HostDeleteFlowTest extends ResourceFlowTestCase<HostDeleteFlow, Hos
} }
@Test @Test
public void testSuccess_authorizedClientReadFromTransferredSuperordinate() throws Exception { void testSuccess_authorizedClientReadFromTransferredSuperordinate() throws Exception {
sessionMetadata.setClientId("NewRegistrar"); sessionMetadata.setClientId("NewRegistrar");
createTld("tld"); createTld("tld");
// Setup a transfer that should have been server approved a day ago. // Setup a transfer that should have been server approved a day ago.
@ -245,7 +245,7 @@ public class HostDeleteFlowTest extends ResourceFlowTestCase<HostDeleteFlow, Hos
} }
@Test @Test
public void testFailure_unauthorizedClientReadFromTransferredSuperordinate() { void testFailure_unauthorizedClientReadFromTransferredSuperordinate() {
sessionMetadata.setClientId("NewRegistrar"); sessionMetadata.setClientId("NewRegistrar");
createTld("tld"); createTld("tld");
// Setup a transfer that should have been server approved a day ago. // Setup a transfer that should have been server approved a day ago.
@ -278,7 +278,7 @@ public class HostDeleteFlowTest extends ResourceFlowTestCase<HostDeleteFlow, Hos
} }
@Test @Test
public void testFailure_failfastWhenLinkedToDomain() { void testFailure_failfastWhenLinkedToDomain() {
createTld("tld"); createTld("tld");
persistResource( persistResource(
newDomainBase("example.tld") newDomainBase("example.tld")
@ -290,14 +290,14 @@ public class HostDeleteFlowTest extends ResourceFlowTestCase<HostDeleteFlow, Hos
} }
@Test @Test
public void testFailure_nonLowerCaseHostname() { void testFailure_nonLowerCaseHostname() {
setEppInput("host_delete.xml", ImmutableMap.of("HOSTNAME", "NS1.EXAMPLE.NET")); setEppInput("host_delete.xml", ImmutableMap.of("HOSTNAME", "NS1.EXAMPLE.NET"));
EppException thrown = assertThrows(HostNameNotLowerCaseException.class, this::runFlow); EppException thrown = assertThrows(HostNameNotLowerCaseException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml(); assertAboutEppExceptions().that(thrown).marshalsToXml();
} }
@Test @Test
public void testFailure_nonPunyCodedHostname() { void testFailure_nonPunyCodedHostname() {
setEppInput("host_delete.xml", ImmutableMap.of("HOSTNAME", "ns1.çauçalito.tld")); setEppInput("host_delete.xml", ImmutableMap.of("HOSTNAME", "ns1.çauçalito.tld"));
HostNameNotPunyCodedException thrown = HostNameNotPunyCodedException thrown =
assertThrows(HostNameNotPunyCodedException.class, this::runFlow); assertThrows(HostNameNotPunyCodedException.class, this::runFlow);
@ -305,14 +305,14 @@ public class HostDeleteFlowTest extends ResourceFlowTestCase<HostDeleteFlow, Hos
} }
@Test @Test
public void testFailure_nonCanonicalHostname() { void testFailure_nonCanonicalHostname() {
setEppInput("host_delete.xml", ImmutableMap.of("HOSTNAME", "ns1.example.tld.")); setEppInput("host_delete.xml", ImmutableMap.of("HOSTNAME", "ns1.example.tld."));
EppException thrown = assertThrows(HostNameNotNormalizedException.class, this::runFlow); EppException thrown = assertThrows(HostNameNotNormalizedException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml(); assertAboutEppExceptions().that(thrown).marshalsToXml();
} }
@Test @Test
public void testIcannActivityReportField_getsLogged() throws Exception { void testIcannActivityReportField_getsLogged() throws Exception {
persistActiveHost("ns1.example.tld"); persistActiveHost("ns1.example.tld");
clock.advanceOneMilli(); clock.advanceOneMilli();
runFlow(); runFlow();

View file

@ -36,18 +36,18 @@ import google.registry.model.eppcommon.StatusValue;
import google.registry.model.host.HostResource; import google.registry.model.host.HostResource;
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;
/** Unit tests for {@link HostInfoFlow}. */ /** Unit tests for {@link HostInfoFlow}. */
public class HostInfoFlowTest extends ResourceFlowTestCase<HostInfoFlow, HostResource> { class HostInfoFlowTest extends ResourceFlowTestCase<HostInfoFlow, HostResource> {
public HostInfoFlowTest() { HostInfoFlowTest() {
setEppInput("host_info.xml", ImmutableMap.of("HOSTNAME", "ns1.example.tld")); setEppInput("host_info.xml", ImmutableMap.of("HOSTNAME", "ns1.example.tld"));
} }
@Before @BeforeEach
public void initHostTest() { void initHostTest() {
createTld("foobar"); createTld("foobar");
} }
@ -73,7 +73,7 @@ public class HostInfoFlowTest extends ResourceFlowTestCase<HostInfoFlow, HostRes
} }
@Test @Test
public void testSuccess() throws Exception { void testSuccess() throws Exception {
persistHostResource(); persistHostResource();
assertTransactionalFlow(false); assertTransactionalFlow(false);
// Check that the persisted host info was returned. // Check that the persisted host info was returned.
@ -86,7 +86,7 @@ public class HostInfoFlowTest extends ResourceFlowTestCase<HostInfoFlow, HostRes
} }
@Test @Test
public void testSuccess_linked() throws Exception { void testSuccess_linked() throws Exception {
persistHostResource(); persistHostResource();
persistResource( persistResource(
newDomainBase("example.foobar") newDomainBase("example.foobar")
@ -130,31 +130,31 @@ public class HostInfoFlowTest extends ResourceFlowTestCase<HostInfoFlow, HostRes
} }
@Test @Test
public void testSuccess_withSuperordinateDomain_hostMovedAfterDomainTransfer() throws Exception { void testSuccess_withSuperordinateDomain_hostMovedAfterDomainTransfer() throws Exception {
runTest_superordinateDomain( runTest_superordinateDomain(
DateTime.parse("2000-01-08T09:00:00.0Z"), DateTime.parse("2000-03-01T01:00:00.0Z")); DateTime.parse("2000-01-08T09:00:00.0Z"), DateTime.parse("2000-03-01T01:00:00.0Z"));
} }
@Test @Test
public void testSuccess_withSuperordinateDomain_hostMovedBeforeDomainTransfer() throws Exception { void testSuccess_withSuperordinateDomain_hostMovedBeforeDomainTransfer() throws Exception {
runTest_superordinateDomain( runTest_superordinateDomain(
DateTime.parse("2000-04-08T09:00:00.0Z"), DateTime.parse("2000-02-08T09:00:00.0Z")); DateTime.parse("2000-04-08T09:00:00.0Z"), DateTime.parse("2000-02-08T09:00:00.0Z"));
} }
@Test @Test
public void testSuccess_withSuperordinateDomain() throws Exception { void testSuccess_withSuperordinateDomain() throws Exception {
runTest_superordinateDomain(DateTime.parse("2000-04-08T09:00:00.0Z"), null); runTest_superordinateDomain(DateTime.parse("2000-04-08T09:00:00.0Z"), null);
} }
@Test @Test
public void testFailure_neverExisted() throws Exception { void testFailure_neverExisted() throws Exception {
ResourceDoesNotExistException thrown = ResourceDoesNotExistException thrown =
assertThrows(ResourceDoesNotExistException.class, this::runFlow); assertThrows(ResourceDoesNotExistException.class, this::runFlow);
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand())); assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
} }
@Test @Test
public void testFailure_existedButWasDeleted() throws Exception { void testFailure_existedButWasDeleted() throws Exception {
persistResource( persistResource(
persistHostResource().asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build()); persistHostResource().asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build());
ResourceDoesNotExistException thrown = ResourceDoesNotExistException thrown =
@ -163,14 +163,14 @@ public class HostInfoFlowTest extends ResourceFlowTestCase<HostInfoFlow, HostRes
} }
@Test @Test
public void testFailure_nonLowerCaseHostname() { void testFailure_nonLowerCaseHostname() {
setEppInput("host_info.xml", ImmutableMap.of("HOSTNAME", "NS1.EXAMPLE.NET")); setEppInput("host_info.xml", ImmutableMap.of("HOSTNAME", "NS1.EXAMPLE.NET"));
EppException thrown = assertThrows(HostNameNotLowerCaseException.class, this::runFlow); EppException thrown = assertThrows(HostNameNotLowerCaseException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml(); assertAboutEppExceptions().that(thrown).marshalsToXml();
} }
@Test @Test
public void testFailure_nonPunyCodedHostname() { void testFailure_nonPunyCodedHostname() {
setEppInput("host_info.xml", ImmutableMap.of("HOSTNAME", "ns1.çauçalito.tld")); setEppInput("host_info.xml", ImmutableMap.of("HOSTNAME", "ns1.çauçalito.tld"));
HostNameNotPunyCodedException thrown = HostNameNotPunyCodedException thrown =
assertThrows(HostNameNotPunyCodedException.class, this::runFlow); assertThrows(HostNameNotPunyCodedException.class, this::runFlow);
@ -178,14 +178,14 @@ public class HostInfoFlowTest extends ResourceFlowTestCase<HostInfoFlow, HostRes
} }
@Test @Test
public void testFailure_nonCanonicalHostname() { void testFailure_nonCanonicalHostname() {
setEppInput("host_info.xml", ImmutableMap.of("HOSTNAME", "ns1.example.tld.")); setEppInput("host_info.xml", ImmutableMap.of("HOSTNAME", "ns1.example.tld."));
EppException thrown = assertThrows(HostNameNotNormalizedException.class, this::runFlow); EppException thrown = assertThrows(HostNameNotNormalizedException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml(); assertAboutEppExceptions().that(thrown).marshalsToXml();
} }
@Test @Test
public void testIcannActivityReportField_getsLogged() throws Exception { void testIcannActivityReportField_getsLogged() throws Exception {
persistHostResource(); persistHostResource();
runFlow(); runFlow();
assertIcannReportingActivityFieldLogged("srs-host-info"); assertIcannReportingActivityFieldLogged("srs-host-info");

View file

@ -79,10 +79,10 @@ import google.registry.model.transfer.TransferStatus;
import google.registry.testing.TaskQueueHelper.TaskMatcher; import google.registry.testing.TaskQueueHelper.TaskMatcher;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import org.joda.time.DateTime; import org.joda.time.DateTime;
import org.junit.Test; import org.junit.jupiter.api.Test;
/** Unit tests for {@link HostUpdateFlow}. */ /** Unit tests for {@link HostUpdateFlow}. */
public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResource> { class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResource> {
private void setEppHostUpdateInput( private void setEppHostUpdateInput(
String oldHostName, String newHostName, String ipOrStatusToAdd, String ipOrStatusToRem) { String oldHostName, String newHostName, String ipOrStatusToAdd, String ipOrStatusToRem) {
@ -99,7 +99,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
nullToEmpty(ipOrStatusToRem))); nullToEmpty(ipOrStatusToRem)));
} }
public HostUpdateFlowTest() { HostUpdateFlowTest() {
setEppHostUpdateInput("ns1.example.tld", "ns2.example.tld", null, null); setEppHostUpdateInput("ns1.example.tld", "ns2.example.tld", null, null);
} }
@ -133,7 +133,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
} }
@Test @Test
public void testDryRun() throws Exception { void testDryRun() throws Exception {
createTld("tld"); createTld("tld");
persistActiveSubordinateHost(oldHostName(), persistActiveDomain("example.tld")); persistActiveSubordinateHost(oldHostName(), persistActiveDomain("example.tld"));
dryRunFlowAssertResponse(loadFile("generic_success_response.xml")); dryRunFlowAssertResponse(loadFile("generic_success_response.xml"));
@ -169,7 +169,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
} }
@Test @Test
public void testSuccess_rename_noOtherHostEverUsedTheOldName() throws Exception { void testSuccess_rename_noOtherHostEverUsedTheOldName() throws Exception {
createTld("tld"); createTld("tld");
persistActiveSubordinateHost(oldHostName(), persistActiveDomain("example.tld")); persistActiveSubordinateHost(oldHostName(), persistActiveDomain("example.tld"));
HostResource renamedHost = doSuccessfulTest(); HostResource renamedHost = doSuccessfulTest();
@ -186,7 +186,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
} }
@Test @Test
public void testSuccess_withReferencingDomain() throws Exception { void testSuccess_withReferencingDomain() throws Exception {
createTld("tld"); createTld("tld");
createTld("xn--q9jyb4c"); createTld("xn--q9jyb4c");
HostResource host = HostResource host =
@ -208,7 +208,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
} }
@Test @Test
public void testSuccess_nameUnchanged_superordinateDomainNeverTransferred() throws Exception { void testSuccess_nameUnchanged_superordinateDomainNeverTransferred() throws Exception {
setEppInput("host_update_name_unchanged.xml"); setEppInput("host_update_name_unchanged.xml");
createTld("tld"); createTld("tld");
DomainBase domain = persistActiveDomain("example.tld"); DomainBase domain = persistActiveDomain("example.tld");
@ -232,7 +232,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
} }
@Test @Test
public void testSuccess_nameUnchanged_superordinateDomainWasTransferred() throws Exception { void testSuccess_nameUnchanged_superordinateDomainWasTransferred() throws Exception {
sessionMetadata.setClientId("NewRegistrar"); sessionMetadata.setClientId("NewRegistrar");
setEppInput("host_update_name_unchanged.xml"); setEppInput("host_update_name_unchanged.xml");
createTld("tld"); createTld("tld");
@ -258,7 +258,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
} }
@Test @Test
public void testSuccess_internalToInternalOnSameDomain() throws Exception { void testSuccess_internalToInternalOnSameDomain() throws Exception {
setEppHostUpdateInput( setEppHostUpdateInput(
"ns1.example.tld", "ns1.example.tld",
"ns2.example.tld", "ns2.example.tld",
@ -292,7 +292,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
} }
@Test @Test
public void testSuccess_internalToInternalOnSameTld() throws Exception { void testSuccess_internalToInternalOnSameTld() throws Exception {
setEppHostUpdateInput( setEppHostUpdateInput(
"ns2.foo.tld", "ns2.foo.tld",
"ns2.example.tld", "ns2.example.tld",
@ -328,7 +328,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
} }
@Test @Test
public void testSuccess_internalToInternalOnDifferentTld() throws Exception { void testSuccess_internalToInternalOnDifferentTld() throws Exception {
setEppHostUpdateInput( setEppHostUpdateInput(
"ns1.example.foo", "ns1.example.foo",
"ns2.example.tld", "ns2.example.tld",
@ -367,7 +367,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
} }
@Test @Test
public void testSuccess_internalToExternal() throws Exception { void testSuccess_internalToExternal() throws Exception {
setEppHostUpdateInput( setEppHostUpdateInput(
"ns1.example.foo", "ns1.example.foo",
"ns2.example.tld", "ns2.example.tld",
@ -409,7 +409,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
} }
@Test @Test
public void testFailure_externalToInternal() throws Exception { void testFailure_externalToInternal() throws Exception {
setEppHostUpdateInput( setEppHostUpdateInput(
"ns1.example.foo", "ns2.example.tld", "<host:addr ip=\"v4\">192.0.2.22</host:addr>", null); "ns1.example.foo", "ns2.example.tld", "<host:addr ip=\"v4\">192.0.2.22</host:addr>", null);
createTld("tld"); createTld("tld");
@ -421,7 +421,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
} }
@Test @Test
public void testSuccess_superuserExternalToInternal() throws Exception { void testSuccess_superuserExternalToInternal() throws Exception {
setEppHostUpdateInput( setEppHostUpdateInput(
"ns1.example.foo", "ns2.example.tld", "<host:addr ip=\"v4\">192.0.2.22</host:addr>", null); "ns1.example.foo", "ns2.example.tld", "<host:addr ip=\"v4\">192.0.2.22</host:addr>", null);
createTld("tld"); createTld("tld");
@ -445,7 +445,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
} }
@Test @Test
public void testFailure_externalToExternal() throws Exception { void testFailure_externalToExternal() throws Exception {
setEppHostUpdateInput("ns1.example.foo", "ns2.example.tld", null, null); setEppHostUpdateInput("ns1.example.foo", "ns2.example.tld", null, null);
persistActiveHost(oldHostName()); persistActiveHost(oldHostName());
EppException thrown = assertThrows(CannotRenameExternalHostException.class, this::runFlow); EppException thrown = assertThrows(CannotRenameExternalHostException.class, this::runFlow);
@ -453,7 +453,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
} }
@Test @Test
public void testSuccess_superuserExternalToExternal() throws Exception { void testSuccess_superuserExternalToExternal() throws Exception {
setEppHostUpdateInput("ns1.example.foo", "ns2.example.tld", null, null); setEppHostUpdateInput("ns1.example.foo", "ns2.example.tld", null, null);
persistActiveHost(oldHostName()); persistActiveHost(oldHostName());
HostResource renamedHost = doSuccessfulTestAsSuperuser(); HostResource renamedHost = doSuccessfulTestAsSuperuser();
@ -470,7 +470,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
} }
@Test @Test
public void testSuccess_superuserClientUpdateProhibited() throws Exception { void testSuccess_superuserClientUpdateProhibited() throws Exception {
setEppInput("host_update_add_status.xml"); setEppInput("host_update_add_status.xml");
persistResource( persistResource(
newHostResource(oldHostName()) newHostResource(oldHostName())
@ -492,7 +492,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
} }
@Test @Test
public void testSuccess_subordToSubord_lastTransferTimeFromPreviousSuperordinateWinsOut() void testSuccess_subordToSubord_lastTransferTimeFromPreviousSuperordinateWinsOut()
throws Exception { throws Exception {
setEppHostUpdateInput( setEppHostUpdateInput(
"ns2.foo.tld", "ns2.foo.tld",
@ -528,7 +528,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
} }
@Test @Test
public void testSuccess_subordToSubord_lastTransferTimeOnExistingHostWinsOut() throws Exception { void testSuccess_subordToSubord_lastTransferTimeOnExistingHostWinsOut() throws Exception {
setEppHostUpdateInput( setEppHostUpdateInput(
"ns2.foo.tld", "ns2.foo.tld",
"ns2.example.tld", "ns2.example.tld",
@ -566,7 +566,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
} }
@Test @Test
public void testSuccess_subordToSubord_lastTransferTimeOnExistingHostWinsOut_whenNullOnNewDomain() void testSuccess_subordToSubord_lastTransferTimeOnExistingHostWinsOut_whenNullOnNewDomain()
throws Exception { throws Exception {
setEppHostUpdateInput( setEppHostUpdateInput(
"ns2.foo.tld", "ns2.foo.tld",
@ -601,7 +601,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
} }
@Test @Test
public void testSuccess_subordToSubord_lastTransferTimeOnExistingHostWins_whenNullOnBothDomains() void testSuccess_subordToSubord_lastTransferTimeOnExistingHostWins_whenNullOnBothDomains()
throws Exception { throws Exception {
setEppHostUpdateInput( setEppHostUpdateInput(
"ns2.foo.tld", "ns2.foo.tld",
@ -632,7 +632,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
} }
@Test @Test
public void testSuccess_subordToSubord_lastTransferTimeIsNull_whenNullOnBoth() throws Exception { void testSuccess_subordToSubord_lastTransferTimeIsNull_whenNullOnBoth() throws Exception {
setEppHostUpdateInput( setEppHostUpdateInput(
"ns2.foo.tld", "ns2.foo.tld",
"ns2.example.tld", "ns2.example.tld",
@ -663,7 +663,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
} }
@Test @Test
public void testSuccess_internalToExternal_lastTransferTimeFrozenWhenComingFromSuperordinate() void testSuccess_internalToExternal_lastTransferTimeFrozenWhenComingFromSuperordinate()
throws Exception { throws Exception {
setEppHostUpdateInput( setEppHostUpdateInput(
"ns1.example.foo", "ns1.example.foo",
@ -699,8 +699,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
} }
@Test @Test
public void testSuccess_internalToExternal_lastTransferTimeFrozenWhenComingFromHost() void testSuccess_internalToExternal_lastTransferTimeFrozenWhenComingFromHost() throws Exception {
throws Exception {
setEppHostUpdateInput( setEppHostUpdateInput(
"ns1.example.foo", "ns1.example.foo",
"ns2.example.tld", "ns2.example.tld",
@ -735,7 +734,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
} }
@Test @Test
public void testSuccess_internalToExternal_lastTransferTimeFrozenWhenDomainOverridesHost() void testSuccess_internalToExternal_lastTransferTimeFrozenWhenDomainOverridesHost()
throws Exception { throws Exception {
setEppHostUpdateInput( setEppHostUpdateInput(
"ns1.example.foo", "ns1.example.foo",
@ -789,14 +788,14 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
} }
@Test @Test
public void testSuccess_externalToSubord_lastTransferTimeNotOverridden_whenLessRecent() void testSuccess_externalToSubord_lastTransferTimeNotOverridden_whenLessRecent()
throws Exception { throws Exception {
doExternalToInternalLastTransferTimeTest( doExternalToInternalLastTransferTimeTest(
clock.nowUtc().minusDays(2), clock.nowUtc().minusDays(1)); clock.nowUtc().minusDays(2), clock.nowUtc().minusDays(1));
} }
@Test @Test
public void testSuccess_externalToSubord_lastTransferTimeNotOverridden_whenMoreRecent() void testSuccess_externalToSubord_lastTransferTimeNotOverridden_whenMoreRecent()
throws Exception { throws Exception {
doExternalToInternalLastTransferTimeTest( doExternalToInternalLastTransferTimeTest(
clock.nowUtc().minusDays(2), clock.nowUtc().minusDays(3)); clock.nowUtc().minusDays(2), clock.nowUtc().minusDays(3));
@ -804,13 +803,12 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
/** Test when the new superdordinate domain has never been transferred before. */ /** Test when the new superdordinate domain has never been transferred before. */
@Test @Test
public void testSuccess_externalToSubord_lastTransferTimeNotOverridden_whenNull() void testSuccess_externalToSubord_lastTransferTimeNotOverridden_whenNull() throws Exception {
throws Exception {
doExternalToInternalLastTransferTimeTest(clock.nowUtc().minusDays(2), null); doExternalToInternalLastTransferTimeTest(clock.nowUtc().minusDays(2), null);
} }
@Test @Test
public void testFailure_superordinateMissing() throws Exception { void testFailure_superordinateMissing() throws Exception {
createTld("tld"); createTld("tld");
persistActiveHost(oldHostName()); persistActiveHost(oldHostName());
SuperordinateDomainDoesNotExistException thrown = SuperordinateDomainDoesNotExistException thrown =
@ -819,7 +817,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
} }
@Test @Test
public void testFailure_superordinateInPendingDelete() throws Exception { void testFailure_superordinateInPendingDelete() throws Exception {
setEppHostUpdateInput( setEppHostUpdateInput(
"ns1.example.tld", "ns1.example.tld",
"ns2.example.tld", "ns2.example.tld",
@ -844,14 +842,14 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
} }
@Test @Test
public void testFailure_neverExisted() throws Exception { void testFailure_neverExisted() throws Exception {
ResourceDoesNotExistException thrown = ResourceDoesNotExistException thrown =
assertThrows(ResourceDoesNotExistException.class, this::runFlow); assertThrows(ResourceDoesNotExistException.class, this::runFlow);
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand())); assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
} }
@Test @Test
public void testFailure_neverExisted_updateWithoutNameChange() throws Exception { void testFailure_neverExisted_updateWithoutNameChange() throws Exception {
setEppInput("host_update_name_unchanged.xml"); setEppInput("host_update_name_unchanged.xml");
ResourceDoesNotExistException thrown = ResourceDoesNotExistException thrown =
assertThrows(ResourceDoesNotExistException.class, this::runFlow); assertThrows(ResourceDoesNotExistException.class, this::runFlow);
@ -859,7 +857,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
} }
@Test @Test
public void testFailure_existedButWasDeleted() throws Exception { void testFailure_existedButWasDeleted() throws Exception {
persistDeletedHost(oldHostName(), clock.nowUtc().minusDays(1)); persistDeletedHost(oldHostName(), clock.nowUtc().minusDays(1));
ResourceDoesNotExistException thrown = ResourceDoesNotExistException thrown =
assertThrows(ResourceDoesNotExistException.class, this::runFlow); assertThrows(ResourceDoesNotExistException.class, this::runFlow);
@ -867,7 +865,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
} }
@Test @Test
public void testFailure_renameToCurrentName() throws Exception { void testFailure_renameToCurrentName() throws Exception {
createTld("tld"); createTld("tld");
persistActiveSubordinateHost(oldHostName(), persistActiveDomain("example.tld")); persistActiveSubordinateHost(oldHostName(), persistActiveDomain("example.tld"));
clock.advanceOneMilli(); clock.advanceOneMilli();
@ -878,7 +876,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
} }
@Test @Test
public void testFailure_renameToNameOfExistingOtherHost() throws Exception { void testFailure_renameToNameOfExistingOtherHost() throws Exception {
createTld("tld"); createTld("tld");
persistActiveSubordinateHost(oldHostName(), persistActiveDomain("example.tld")); persistActiveSubordinateHost(oldHostName(), persistActiveDomain("example.tld"));
persistActiveHost("ns2.example.tld"); persistActiveHost("ns2.example.tld");
@ -888,14 +886,14 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
} }
@Test @Test
public void testFailure_referToNonLowerCaseHostname() { void testFailure_referToNonLowerCaseHostname() {
setEppHostUpdateInput("ns1.EXAMPLE.tld", "ns2.example.tld", null, null); setEppHostUpdateInput("ns1.EXAMPLE.tld", "ns2.example.tld", null, null);
EppException thrown = assertThrows(HostNameNotLowerCaseException.class, this::runFlow); EppException thrown = assertThrows(HostNameNotLowerCaseException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml(); assertAboutEppExceptions().that(thrown).marshalsToXml();
} }
@Test @Test
public void testFailure_renameToNonLowerCaseHostname() { void testFailure_renameToNonLowerCaseHostname() {
persistActiveHost("ns1.example.tld"); persistActiveHost("ns1.example.tld");
setEppHostUpdateInput("ns1.example.tld", "ns2.EXAMPLE.tld", null, null); setEppHostUpdateInput("ns1.example.tld", "ns2.EXAMPLE.tld", null, null);
EppException thrown = assertThrows(HostNameNotLowerCaseException.class, this::runFlow); EppException thrown = assertThrows(HostNameNotLowerCaseException.class, this::runFlow);
@ -903,7 +901,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
} }
@Test @Test
public void testFailure_referToNonPunyCodedHostname() { void testFailure_referToNonPunyCodedHostname() {
setEppHostUpdateInput("ns1.çauçalito.tld", "ns1.sausalito.tld", null, null); setEppHostUpdateInput("ns1.çauçalito.tld", "ns1.sausalito.tld", null, null);
HostNameNotPunyCodedException thrown = HostNameNotPunyCodedException thrown =
assertThrows(HostNameNotPunyCodedException.class, this::runFlow); assertThrows(HostNameNotPunyCodedException.class, this::runFlow);
@ -911,7 +909,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
} }
@Test @Test
public void testFailure_renameToNonPunyCodedHostname() { void testFailure_renameToNonPunyCodedHostname() {
persistActiveHost("ns1.sausalito.tld"); persistActiveHost("ns1.sausalito.tld");
setEppHostUpdateInput("ns1.sausalito.tld", "ns1.çauçalito.tld", null, null); setEppHostUpdateInput("ns1.sausalito.tld", "ns1.çauçalito.tld", null, null);
HostNameNotPunyCodedException thrown = HostNameNotPunyCodedException thrown =
@ -920,7 +918,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
} }
@Test @Test
public void testFailure_referToNonCanonicalHostname() { void testFailure_referToNonCanonicalHostname() {
persistActiveHost("ns1.example.tld."); persistActiveHost("ns1.example.tld.");
setEppHostUpdateInput("ns1.example.tld.", "ns2.example.tld", null, null); setEppHostUpdateInput("ns1.example.tld.", "ns2.example.tld", null, null);
EppException thrown = assertThrows(HostNameNotNormalizedException.class, this::runFlow); EppException thrown = assertThrows(HostNameNotNormalizedException.class, this::runFlow);
@ -928,7 +926,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
} }
@Test @Test
public void testFailure_renameToNonCanonicalHostname() { void testFailure_renameToNonCanonicalHostname() {
persistActiveHost("ns1.example.tld"); persistActiveHost("ns1.example.tld");
setEppHostUpdateInput("ns1.example.tld", "ns2.example.tld.", null, null); setEppHostUpdateInput("ns1.example.tld", "ns2.example.tld.", null, null);
EppException thrown = assertThrows(HostNameNotNormalizedException.class, this::runFlow); EppException thrown = assertThrows(HostNameNotNormalizedException.class, this::runFlow);
@ -936,7 +934,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
} }
@Test @Test
public void testFailure_subordinateNeedsIps() throws Exception { void testFailure_subordinateNeedsIps() throws Exception {
setEppHostUpdateInput( setEppHostUpdateInput(
"ns1.example.tld", "ns1.example.tld",
"ns2.example.tld", "ns2.example.tld",
@ -950,7 +948,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
} }
@Test @Test
public void testFailure_subordinateToExternal_mustRemoveAllIps() throws Exception { void testFailure_subordinateToExternal_mustRemoveAllIps() throws Exception {
setEppHostUpdateInput("ns1.example.tld", "ns2.example.com", null, null); setEppHostUpdateInput("ns1.example.tld", "ns2.example.com", null, null);
createTld("tld"); createTld("tld");
persistActiveSubordinateHost(oldHostName(), persistActiveDomain("example.tld")); persistActiveSubordinateHost(oldHostName(), persistActiveDomain("example.tld"));
@ -959,7 +957,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
} }
@Test @Test
public void testFailure_subordinateToExternal_cantAddAnIp() throws Exception { void testFailure_subordinateToExternal_cantAddAnIp() throws Exception {
setEppHostUpdateInput( setEppHostUpdateInput(
"ns1.example.tld", "ns2.example.com", "<host:addr ip=\"v4\">192.0.2.22</host:addr>", null); "ns1.example.tld", "ns2.example.com", "<host:addr ip=\"v4\">192.0.2.22</host:addr>", null);
createTld("tld"); createTld("tld");
@ -969,7 +967,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
} }
@Test @Test
public void testFailure_addRemoveSameStatusValues() throws Exception { void testFailure_addRemoveSameStatusValues() throws Exception {
createTld("tld"); createTld("tld");
persistActiveDomain("example.tld"); persistActiveDomain("example.tld");
setEppHostUpdateInput( setEppHostUpdateInput(
@ -983,7 +981,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
} }
@Test @Test
public void testFailure_addRemoveSameInetAddresses() throws Exception { void testFailure_addRemoveSameInetAddresses() throws Exception {
createTld("tld"); createTld("tld");
persistActiveSubordinateHost(oldHostName(), persistActiveDomain("example.tld")); persistActiveSubordinateHost(oldHostName(), persistActiveDomain("example.tld"));
setEppHostUpdateInput( setEppHostUpdateInput(
@ -996,7 +994,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
} }
@Test @Test
public void testSuccess_clientUpdateProhibited_removed() throws Exception { void testSuccess_clientUpdateProhibited_removed() throws Exception {
setEppInput("host_update_remove_client_update_prohibited.xml"); setEppInput("host_update_remove_client_update_prohibited.xml");
persistResource( persistResource(
newHostResource(oldHostName()) newHostResource(oldHostName())
@ -1011,7 +1009,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
} }
@Test @Test
public void testFailure_clientUpdateProhibited() throws Exception { void testFailure_clientUpdateProhibited() throws Exception {
createTld("tld"); createTld("tld");
persistResource( persistResource(
newHostResource(oldHostName()) newHostResource(oldHostName())
@ -1025,7 +1023,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
} }
@Test @Test
public void testFailure_serverUpdateProhibited() throws Exception { void testFailure_serverUpdateProhibited() throws Exception {
createTld("tld"); createTld("tld");
persistResource( persistResource(
newHostResource(oldHostName()) newHostResource(oldHostName())
@ -1039,7 +1037,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
} }
@Test @Test
public void testFailure_pendingDelete() throws Exception { void testFailure_pendingDelete() throws Exception {
createTld("tld"); createTld("tld");
persistResource( persistResource(
newHostResource(oldHostName()) newHostResource(oldHostName())
@ -1053,7 +1051,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
} }
@Test @Test
public void testFailure_statusValueNotClientSettable() throws Exception { void testFailure_statusValueNotClientSettable() throws Exception {
createTld("tld"); createTld("tld");
persistActiveSubordinateHost(oldHostName(), persistActiveDomain("example.tld")); persistActiveSubordinateHost(oldHostName(), persistActiveDomain("example.tld"));
setEppInput("host_update_prohibited_status.xml"); setEppInput("host_update_prohibited_status.xml");
@ -1062,7 +1060,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
} }
@Test @Test
public void testSuccess_superuserStatusValueNotClientSettable() throws Exception { void testSuccess_superuserStatusValueNotClientSettable() throws Exception {
setEppInput("host_update_prohibited_status.xml"); setEppInput("host_update_prohibited_status.xml");
createTld("tld"); createTld("tld");
persistActiveDomain("example.tld"); persistActiveDomain("example.tld");
@ -1074,7 +1072,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
} }
@Test @Test
public void testFailure_unauthorizedClient() { void testFailure_unauthorizedClient() {
sessionMetadata.setClientId("NewRegistrar"); sessionMetadata.setClientId("NewRegistrar");
persistActiveHost("ns1.example.tld"); persistActiveHost("ns1.example.tld");
EppException thrown = assertThrows(ResourceNotOwnedException.class, this::runFlow); EppException thrown = assertThrows(ResourceNotOwnedException.class, this::runFlow);
@ -1082,7 +1080,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
} }
@Test @Test
public void testSuccess_superuserUnauthorizedClient() throws Exception { void testSuccess_superuserUnauthorizedClient() throws Exception {
sessionMetadata.setClientId("NewRegistrar"); sessionMetadata.setClientId("NewRegistrar");
persistActiveHost(oldHostName()); persistActiveHost(oldHostName());
@ -1092,7 +1090,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
} }
@Test @Test
public void testSuccess_authorizedClientReadFromSuperordinate() throws Exception { void testSuccess_authorizedClientReadFromSuperordinate() throws Exception {
sessionMetadata.setClientId("NewRegistrar"); sessionMetadata.setClientId("NewRegistrar");
createTld("tld"); createTld("tld");
DomainBase domain = DomainBase domain =
@ -1114,7 +1112,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
} }
@Test @Test
public void testFailure_unauthorizedClientReadFromSuperordinate() { void testFailure_unauthorizedClientReadFromSuperordinate() {
sessionMetadata.setClientId("NewRegistrar"); sessionMetadata.setClientId("NewRegistrar");
createTld("tld"); createTld("tld");
DomainBase domain = DomainBase domain =
@ -1136,7 +1134,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
} }
@Test @Test
public void testSuccess_authorizedClientReadFromTransferredSuperordinate() throws Exception { void testSuccess_authorizedClientReadFromTransferredSuperordinate() throws Exception {
sessionMetadata.setClientId("NewRegistrar"); sessionMetadata.setClientId("NewRegistrar");
createTld("tld"); createTld("tld");
// Create a domain that will belong to NewRegistrar after cloneProjectedAtTime is called. // Create a domain that will belong to NewRegistrar after cloneProjectedAtTime is called.
@ -1154,7 +1152,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
} }
@Test @Test
public void testFailure_unauthorizedClientReadFromTransferredSuperordinate() { void testFailure_unauthorizedClientReadFromTransferredSuperordinate() {
sessionMetadata.setClientId("TheRegistrar"); sessionMetadata.setClientId("TheRegistrar");
createTld("tld"); createTld("tld");
// Create a domain that will belong to NewRegistrar after cloneProjectedAtTime is called. // Create a domain that will belong to NewRegistrar after cloneProjectedAtTime is called.
@ -1172,7 +1170,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
} }
@Test @Test
public void testFailure_newSuperordinateOwnedByDifferentRegistrar() throws Exception { void testFailure_newSuperordinateOwnedByDifferentRegistrar() throws Exception {
setEppHostUpdateInput( setEppHostUpdateInput(
"ns1.example.foo", "ns2.example.tld", "<host:addr ip=\"v4\">192.0.2.22</host:addr>", null); "ns1.example.foo", "ns2.example.tld", "<host:addr ip=\"v4\">192.0.2.22</host:addr>", null);
sessionMetadata.setClientId("TheRegistrar"); sessionMetadata.setClientId("TheRegistrar");
@ -1192,7 +1190,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
} }
@Test @Test
public void testFailure_newSuperordinateWasTransferredToDifferentRegistrar() throws Exception { void testFailure_newSuperordinateWasTransferredToDifferentRegistrar() throws Exception {
setEppHostUpdateInput( setEppHostUpdateInput(
"ns1.example.foo", "ns2.example.tld", "<host:addr ip=\"v4\">192.0.2.22</host:addr>", null); "ns1.example.foo", "ns2.example.tld", "<host:addr ip=\"v4\">192.0.2.22</host:addr>", null);
sessionMetadata.setClientId("TheRegistrar"); sessionMetadata.setClientId("TheRegistrar");
@ -1210,7 +1208,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
} }
@Test @Test
public void testSuccess_newSuperordinateWasTransferredToCorrectRegistrar() throws Exception { void testSuccess_newSuperordinateWasTransferredToCorrectRegistrar() throws Exception {
setEppHostUpdateInput( setEppHostUpdateInput(
"ns1.example.foo", "ns2.example.tld", "<host:addr ip=\"v4\">192.0.2.22</host:addr>", null); "ns1.example.foo", "ns2.example.tld", "<host:addr ip=\"v4\">192.0.2.22</host:addr>", null);
sessionMetadata.setClientId("NewRegistrar"); sessionMetadata.setClientId("NewRegistrar");
@ -1249,17 +1247,17 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
} }
@Test @Test
public void testFailure_renameToBadCharacter() throws Exception { void testFailure_renameToBadCharacter() throws Exception {
doFailingHostNameTest("foo bar", InvalidHostNameException.class); doFailingHostNameTest("foo bar", InvalidHostNameException.class);
} }
@Test @Test
public void testFailure_renameToNotPunyCoded() throws Exception { void testFailure_renameToNotPunyCoded() throws Exception {
doFailingHostNameTest("みんな", HostNameNotPunyCodedException.class); doFailingHostNameTest("みんな", HostNameNotPunyCodedException.class);
} }
@Test @Test
public void testFailure_renameToTooLong() throws Exception { void testFailure_renameToTooLong() throws Exception {
// Host names can be max 253 chars. // Host names can be max 253 chars.
String suffix = ".example.tld"; String suffix = ".example.tld";
String tooLong = Strings.repeat("a", 254 - suffix.length()) + suffix; String tooLong = Strings.repeat("a", 254 - suffix.length()) + suffix;
@ -1267,38 +1265,38 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
} }
@Test @Test
public void testFailure_renameToTooShallowPublicSuffix() throws Exception { void testFailure_renameToTooShallowPublicSuffix() throws Exception {
doFailingHostNameTest("example.com", HostNameTooShallowException.class); doFailingHostNameTest("example.com", HostNameTooShallowException.class);
} }
@Test @Test
public void testFailure_renameToTooShallowCcTld() throws Exception { void testFailure_renameToTooShallowCcTld() throws Exception {
doFailingHostNameTest("foo.co.uk", HostNameTooShallowException.class); doFailingHostNameTest("foo.co.uk", HostNameTooShallowException.class);
} }
@Test @Test
public void testFailure_renameToBarePublicSuffix() throws Exception { void testFailure_renameToBarePublicSuffix() throws Exception {
doFailingHostNameTest("com", HostNameTooShallowException.class); doFailingHostNameTest("com", HostNameTooShallowException.class);
} }
@Test @Test
public void testFailure_renameToBareCcTld() throws Exception { void testFailure_renameToBareCcTld() throws Exception {
doFailingHostNameTest("co.uk", HostNameTooShallowException.class); doFailingHostNameTest("co.uk", HostNameTooShallowException.class);
} }
@Test @Test
public void testFailure_renameToTooShallowNewTld() throws Exception { void testFailure_renameToTooShallowNewTld() throws Exception {
doFailingHostNameTest("example.lol", HostNameTooShallowException.class); doFailingHostNameTest("example.lol", HostNameTooShallowException.class);
} }
@Test @Test
public void testFailure_ccTldInBailiwick() throws Exception { void testFailure_ccTldInBailiwick() throws Exception {
createTld("co.uk"); createTld("co.uk");
doFailingHostNameTest("foo.co.uk", HostNameTooShallowException.class); doFailingHostNameTest("foo.co.uk", HostNameTooShallowException.class);
} }
@Test @Test
public void testSuccess_metadata() throws Exception { void testSuccess_metadata() throws Exception {
createTld("tld"); createTld("tld");
persistActiveSubordinateHost(oldHostName(), persistActiveDomain("example.tld")); persistActiveSubordinateHost(oldHostName(), persistActiveDomain("example.tld"));
clock.advanceOneMilli(); clock.advanceOneMilli();
@ -1314,7 +1312,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
} }
@Test @Test
public void testIcannActivityReportField_getsLogged() throws Exception { void testIcannActivityReportField_getsLogged() throws Exception {
createTld("tld"); createTld("tld");
persistActiveSubordinateHost(oldHostName(), persistActiveDomain("example.tld")); persistActiveSubordinateHost(oldHostName(), persistActiveDomain("example.tld"));
clock.advanceOneMilli(); clock.advanceOneMilli();

View file

@ -33,11 +33,11 @@ import google.registry.model.contact.ContactResource;
import google.registry.model.domain.DomainBase; import google.registry.model.domain.DomainBase;
import google.registry.model.poll.PollMessage; import google.registry.model.poll.PollMessage;
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 PollAckFlow}. */ /** Unit tests for {@link PollAckFlow}. */
public class PollAckFlowTest extends FlowTestCase<PollAckFlow> { class PollAckFlowTest extends FlowTestCase<PollAckFlow> {
/** This is the message id being sent in the ACK request. */ /** This is the message id being sent in the ACK request. */
private static final long MESSAGE_ID = 3; private static final long MESSAGE_ID = 3;
@ -45,8 +45,8 @@ public class PollAckFlowTest extends FlowTestCase<PollAckFlow> {
private DomainBase domain; private DomainBase domain;
private ContactResource contact; private ContactResource contact;
@Before @BeforeEach
public void setUp() { void setUp() {
setEppInput("poll_ack.xml", ImmutableMap.of("MSGID", "1-3-EXAMPLE-4-3-2011")); setEppInput("poll_ack.xml", ImmutableMap.of("MSGID", "1-3-EXAMPLE-4-3-2011"));
setClientIdForFlow("NewRegistrar"); setClientIdForFlow("NewRegistrar");
clock.setTo(DateTime.parse("2011-01-02T01:01:01Z")); clock.setTo(DateTime.parse("2011-01-02T01:01:01Z"));
@ -83,13 +83,13 @@ public class PollAckFlowTest extends FlowTestCase<PollAckFlow> {
} }
@Test @Test
public void testDryRun() throws Exception { void testDryRun() throws Exception {
persistOneTimePollMessage(MESSAGE_ID); persistOneTimePollMessage(MESSAGE_ID);
dryRunFlowAssertResponse(loadFile("poll_ack_response_empty.xml")); dryRunFlowAssertResponse(loadFile("poll_ack_response_empty.xml"));
} }
@Test @Test
public void testSuccess_contactPollMessage() throws Exception { void testSuccess_contactPollMessage() throws Exception {
setEppInput("poll_ack.xml", ImmutableMap.of("MSGID", "2-2-ROID-4-3-2011")); setEppInput("poll_ack.xml", ImmutableMap.of("MSGID", "2-2-ROID-4-3-2011"));
persistResource( persistResource(
new PollMessage.OneTime.Builder() new PollMessage.OneTime.Builder()
@ -104,7 +104,7 @@ public class PollAckFlowTest extends FlowTestCase<PollAckFlow> {
} }
@Test @Test
public void testFailure_contactPollMessage_withIncorrectYearField() throws Exception { void testFailure_contactPollMessage_withIncorrectYearField() throws Exception {
setEppInput("poll_ack.xml", ImmutableMap.of("MSGID", "2-2-ROID-4-3-1999")); setEppInput("poll_ack.xml", ImmutableMap.of("MSGID", "2-2-ROID-4-3-1999"));
persistResource( persistResource(
new PollMessage.OneTime.Builder() new PollMessage.OneTime.Builder()
@ -119,14 +119,14 @@ public class PollAckFlowTest extends FlowTestCase<PollAckFlow> {
} }
@Test @Test
public void testSuccess_messageOnContactResource() throws Exception { void testSuccess_messageOnContactResource() throws Exception {
persistOneTimePollMessage(MESSAGE_ID); persistOneTimePollMessage(MESSAGE_ID);
assertTransactionalFlow(true); assertTransactionalFlow(true);
runFlowAssertResponse(loadFile("poll_ack_response_empty.xml")); runFlowAssertResponse(loadFile("poll_ack_response_empty.xml"));
} }
@Test @Test
public void testSuccess_recentActiveAutorenew() throws Exception { void testSuccess_recentActiveAutorenew() throws Exception {
setEppInput("poll_ack.xml", ImmutableMap.of("MSGID", "1-3-EXAMPLE-4-3-2010")); setEppInput("poll_ack.xml", ImmutableMap.of("MSGID", "1-3-EXAMPLE-4-3-2010"));
persistAutorenewPollMessage(clock.nowUtc().minusMonths(6), END_OF_TIME); persistAutorenewPollMessage(clock.nowUtc().minusMonths(6), END_OF_TIME);
assertTransactionalFlow(true); assertTransactionalFlow(true);
@ -134,7 +134,7 @@ public class PollAckFlowTest extends FlowTestCase<PollAckFlow> {
} }
@Test @Test
public void testSuccess_oldActiveAutorenew() throws Exception { void testSuccess_oldActiveAutorenew() throws Exception {
setEppInput("poll_ack.xml", ImmutableMap.of("MSGID", "1-3-EXAMPLE-4-3-2009")); setEppInput("poll_ack.xml", ImmutableMap.of("MSGID", "1-3-EXAMPLE-4-3-2009"));
persistAutorenewPollMessage(clock.nowUtc().minusYears(2), END_OF_TIME); persistAutorenewPollMessage(clock.nowUtc().minusYears(2), END_OF_TIME);
// Create three other messages to be queued for retrieval to get our count right, since the poll // Create three other messages to be queued for retrieval to get our count right, since the poll
@ -150,7 +150,7 @@ public class PollAckFlowTest extends FlowTestCase<PollAckFlow> {
} }
@Test @Test
public void testSuccess_oldInactiveAutorenew() throws Exception { void testSuccess_oldInactiveAutorenew() throws Exception {
setEppInput("poll_ack.xml", ImmutableMap.of("MSGID", "1-3-EXAMPLE-4-3-2010")); setEppInput("poll_ack.xml", ImmutableMap.of("MSGID", "1-3-EXAMPLE-4-3-2010"));
persistAutorenewPollMessage(clock.nowUtc().minusMonths(6), clock.nowUtc()); persistAutorenewPollMessage(clock.nowUtc().minusMonths(6), clock.nowUtc());
assertTransactionalFlow(true); assertTransactionalFlow(true);
@ -158,7 +158,7 @@ public class PollAckFlowTest extends FlowTestCase<PollAckFlow> {
} }
@Test @Test
public void testSuccess_moreMessages() throws Exception { void testSuccess_moreMessages() throws Exception {
// Create five messages to be queued for retrieval, one of which will be acked. // Create five messages to be queued for retrieval, one of which will be acked.
for (int i = 0; i < 5; i++) { for (int i = 0; i < 5; i++) {
persistOneTimePollMessage(MESSAGE_ID + i); persistOneTimePollMessage(MESSAGE_ID + i);
@ -171,7 +171,7 @@ public class PollAckFlowTest extends FlowTestCase<PollAckFlow> {
} }
@Test @Test
public void testFailure_noSuchMessage() throws Exception { void testFailure_noSuchMessage() throws Exception {
assertTransactionalFlow(true); assertTransactionalFlow(true);
Exception e = assertThrows(MessageDoesNotExistException.class, this::runFlow); Exception e = assertThrows(MessageDoesNotExistException.class, this::runFlow);
assertThat(e) assertThat(e)
@ -180,21 +180,21 @@ public class PollAckFlowTest extends FlowTestCase<PollAckFlow> {
} }
@Test @Test
public void testFailure_invalidId_tooFewComponents() throws Exception { void testFailure_invalidId_tooFewComponents() throws Exception {
setEppInput("poll_ack.xml", ImmutableMap.of("MSGID", "1-2-3")); setEppInput("poll_ack.xml", ImmutableMap.of("MSGID", "1-2-3"));
assertTransactionalFlow(true); assertTransactionalFlow(true);
assertThrows(InvalidMessageIdException.class, this::runFlow); assertThrows(InvalidMessageIdException.class, this::runFlow);
} }
@Test @Test
public void testFailure_invalidId_tooManyComponents() throws Exception { void testFailure_invalidId_tooManyComponents() throws Exception {
setEppInput("poll_ack.xml", ImmutableMap.of("MSGID", "2-2-ROID-4-3-1999-2007")); setEppInput("poll_ack.xml", ImmutableMap.of("MSGID", "2-2-ROID-4-3-1999-2007"));
assertTransactionalFlow(true); assertTransactionalFlow(true);
assertThrows(InvalidMessageIdException.class, this::runFlow); assertThrows(InvalidMessageIdException.class, this::runFlow);
} }
@Test @Test
public void testFailure_contactPollMessage_withMissingYearField() throws Exception { void testFailure_contactPollMessage_withMissingYearField() throws Exception {
setEppInput("poll_ack.xml", ImmutableMap.of("MSGID", "2-2-ROID-4-3")); setEppInput("poll_ack.xml", ImmutableMap.of("MSGID", "2-2-ROID-4-3"));
persistResource( persistResource(
new PollMessage.OneTime.Builder() new PollMessage.OneTime.Builder()
@ -209,28 +209,28 @@ public class PollAckFlowTest extends FlowTestCase<PollAckFlow> {
} }
@Test @Test
public void testFailure_invalidId_stringInsteadOfNumeric() throws Exception { void testFailure_invalidId_stringInsteadOfNumeric() throws Exception {
setEppInput("poll_ack.xml", ImmutableMap.of("MSGID", "ABC-12345")); setEppInput("poll_ack.xml", ImmutableMap.of("MSGID", "ABC-12345"));
assertTransactionalFlow(true); assertTransactionalFlow(true);
assertThrows(InvalidMessageIdException.class, this::runFlow); assertThrows(InvalidMessageIdException.class, this::runFlow);
} }
@Test @Test
public void testFailure_invalidEppResourceClassId() throws Exception { void testFailure_invalidEppResourceClassId() throws Exception {
setEppInput("poll_ack.xml", ImmutableMap.of("MSGID", "999-1-1-1")); setEppInput("poll_ack.xml", ImmutableMap.of("MSGID", "999-1-1-1"));
assertTransactionalFlow(true); assertTransactionalFlow(true);
assertThrows(InvalidMessageIdException.class, this::runFlow); assertThrows(InvalidMessageIdException.class, this::runFlow);
} }
@Test @Test
public void testFailure_missingId() throws Exception { void testFailure_missingId() throws Exception {
setEppInput("poll_ack_missing_id.xml"); setEppInput("poll_ack_missing_id.xml");
assertTransactionalFlow(true); assertTransactionalFlow(true);
assertThrows(MissingMessageIdException.class, this::runFlow); assertThrows(MissingMessageIdException.class, this::runFlow);
} }
@Test @Test
public void testFailure_differentRegistrar() throws Exception { void testFailure_differentRegistrar() throws Exception {
persistResource( persistResource(
new PollMessage.OneTime.Builder() new PollMessage.OneTime.Builder()
.setId(MESSAGE_ID) .setId(MESSAGE_ID)
@ -244,7 +244,7 @@ public class PollAckFlowTest extends FlowTestCase<PollAckFlow> {
} }
@Test @Test
public void testFailure_messageInFuture() throws Exception { void testFailure_messageInFuture() throws Exception {
persistResource( persistResource(
new PollMessage.OneTime.Builder() new PollMessage.OneTime.Builder()
.setId(MESSAGE_ID) .setId(MESSAGE_ID)

View file

@ -38,18 +38,18 @@ import google.registry.model.transfer.TransferResponse.ContactTransferResponse;
import google.registry.model.transfer.TransferResponse.DomainTransferResponse; import google.registry.model.transfer.TransferResponse.DomainTransferResponse;
import google.registry.model.transfer.TransferStatus; import google.registry.model.transfer.TransferStatus;
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 PollRequestFlow}. */ /** Unit tests for {@link PollRequestFlow}. */
public class PollRequestFlowTest extends FlowTestCase<PollRequestFlow> { class PollRequestFlowTest extends FlowTestCase<PollRequestFlow> {
private DomainBase domain; private DomainBase domain;
private ContactResource contact; private ContactResource contact;
private HostResource host; private HostResource host;
@Before @BeforeEach
public void setUp() { void setUp() {
setEppInput("poll.xml"); setEppInput("poll.xml");
setClientIdForFlow("NewRegistrar"); setClientIdForFlow("NewRegistrar");
clock.setTo(DateTime.parse("2011-01-02T01:01:01Z")); clock.setTo(DateTime.parse("2011-01-02T01:01:01Z"));
@ -81,14 +81,14 @@ public class PollRequestFlowTest extends FlowTestCase<PollRequestFlow> {
} }
@Test @Test
public void testSuccess_domainTransferApproved() throws Exception { void testSuccess_domainTransferApproved() throws Exception {
persistPendingTransferPollMessage(); persistPendingTransferPollMessage();
assertTransactionalFlow(false); assertTransactionalFlow(false);
runFlowAssertResponse(loadFile("poll_response_domain_transfer.xml")); runFlowAssertResponse(loadFile("poll_response_domain_transfer.xml"));
} }
@Test @Test
public void testSuccess_clTridNotSpecified() throws Exception { void testSuccess_clTridNotSpecified() throws Exception {
setEppInput("poll_no_cltrid.xml"); setEppInput("poll_no_cltrid.xml");
persistPendingTransferPollMessage(); persistPendingTransferPollMessage();
assertTransactionalFlow(false); assertTransactionalFlow(false);
@ -96,7 +96,7 @@ public class PollRequestFlowTest extends FlowTestCase<PollRequestFlow> {
} }
@Test @Test
public void testSuccess_contactTransferPending() throws Exception { void testSuccess_contactTransferPending() throws Exception {
clock.setTo(DateTime.parse("2000-06-13T22:00:00.0Z")); clock.setTo(DateTime.parse("2000-06-13T22:00:00.0Z"));
setClientIdForFlow("TheRegistrar"); setClientIdForFlow("TheRegistrar");
persistResource( persistResource(
@ -120,7 +120,7 @@ public class PollRequestFlowTest extends FlowTestCase<PollRequestFlow> {
} }
@Test @Test
public void testSuccess_domainPendingActionComplete() throws Exception { void testSuccess_domainPendingActionComplete() throws Exception {
persistResource( persistResource(
new PollMessage.OneTime.Builder() new PollMessage.OneTime.Builder()
.setClientId(getClientIdForFlow()) .setClientId(getClientIdForFlow())
@ -135,7 +135,7 @@ public class PollRequestFlowTest extends FlowTestCase<PollRequestFlow> {
} }
@Test @Test
public void testSuccess_domainAutorenewMessage() throws Exception { void testSuccess_domainAutorenewMessage() throws Exception {
persistResource( persistResource(
new PollMessage.Autorenew.Builder() new PollMessage.Autorenew.Builder()
.setClientId(getClientIdForFlow()) .setClientId(getClientIdForFlow())
@ -149,12 +149,12 @@ public class PollRequestFlowTest extends FlowTestCase<PollRequestFlow> {
} }
@Test @Test
public void testSuccess_empty() throws Exception { void testSuccess_empty() throws Exception {
runFlowAssertResponse(loadFile("poll_response_empty.xml")); runFlowAssertResponse(loadFile("poll_response_empty.xml"));
} }
@Test @Test
public void testSuccess_wrongRegistrar() throws Exception { void testSuccess_wrongRegistrar() throws Exception {
persistResource( persistResource(
new PollMessage.OneTime.Builder() new PollMessage.OneTime.Builder()
.setClientId("different client id") .setClientId("different client id")
@ -166,7 +166,7 @@ public class PollRequestFlowTest extends FlowTestCase<PollRequestFlow> {
} }
@Test @Test
public void testSuccess_futurePollMessage() throws Exception { void testSuccess_futurePollMessage() throws Exception {
persistResource( persistResource(
new PollMessage.OneTime.Builder() new PollMessage.OneTime.Builder()
.setClientId(getClientIdForFlow()) .setClientId(getClientIdForFlow())
@ -178,7 +178,7 @@ public class PollRequestFlowTest extends FlowTestCase<PollRequestFlow> {
} }
@Test @Test
public void testSuccess_futureAutorenew() throws Exception { void testSuccess_futureAutorenew() throws Exception {
persistResource( persistResource(
new PollMessage.Autorenew.Builder() new PollMessage.Autorenew.Builder()
.setClientId(getClientIdForFlow()) .setClientId(getClientIdForFlow())
@ -192,7 +192,7 @@ public class PollRequestFlowTest extends FlowTestCase<PollRequestFlow> {
} }
@Test @Test
public void testSuccess_contactDelete() throws Exception { void testSuccess_contactDelete() throws Exception {
// Contact delete poll messages do not have any response data, so ensure that no // Contact delete poll messages do not have any response data, so ensure that no
// response data block is produced in the poll message. // response data block is produced in the poll message.
HistoryEntry historyEntry = persistResource(new HistoryEntry.Builder() HistoryEntry historyEntry = persistResource(new HistoryEntry.Builder()
@ -213,7 +213,7 @@ public class PollRequestFlowTest extends FlowTestCase<PollRequestFlow> {
} }
@Test @Test
public void testSuccess_hostDelete() throws Exception { void testSuccess_hostDelete() throws Exception {
// Host delete poll messages do not have any response data, so ensure that no // Host delete poll messages do not have any response data, so ensure that no
// response data block is produced in the poll message. // response data block is produced in the poll message.
HistoryEntry historyEntry = persistResource(new HistoryEntry.Builder() HistoryEntry historyEntry = persistResource(new HistoryEntry.Builder()
@ -234,7 +234,7 @@ public class PollRequestFlowTest extends FlowTestCase<PollRequestFlow> {
} }
@Test @Test
public void testFailure_messageIdProvided() throws Exception { void testFailure_messageIdProvided() throws Exception {
setEppInput("poll_with_id.xml"); setEppInput("poll_with_id.xml");
assertTransactionalFlow(false); assertTransactionalFlow(false);
EppException thrown = assertThrows(UnexpectedMessageIdException.class, this::runFlow); EppException thrown = assertThrows(UnexpectedMessageIdException.class, this::runFlow);

View file

@ -22,13 +22,13 @@ import com.google.common.collect.ImmutableMap;
import google.registry.flows.EppException; import google.registry.flows.EppException;
import google.registry.flows.FlowTestCase; import google.registry.flows.FlowTestCase;
import google.registry.flows.FlowUtils.GenericXmlSyntaxErrorException; import google.registry.flows.FlowUtils.GenericXmlSyntaxErrorException;
import org.junit.Test; import org.junit.jupiter.api.Test;
/** Unit tests for {@link HelloFlow}. */ /** Unit tests for {@link HelloFlow}. */
public class HelloFlowTest extends FlowTestCase<HelloFlow> { class HelloFlowTest extends FlowTestCase<HelloFlow> {
@Test @Test
public void testHello() throws Exception { void testHello() throws Exception {
setEppInput("hello.xml"); setEppInput("hello.xml");
assertTransactionalFlow(false); assertTransactionalFlow(false);
runFlowAssertResponse( runFlowAssertResponse(
@ -37,7 +37,7 @@ public class HelloFlowTest extends FlowTestCase<HelloFlow> {
} }
@Test @Test
public void testGenericSyntaxException() { void testGenericSyntaxException() {
// This is a generic syntax test--we don't have a generic flow test case so this simple // This is a generic syntax test--we don't have a generic flow test case so this simple
// test class will do. Note: the logic this tests is common to all flows. // test class will do. Note: the logic this tests is common to all flows.
setEppInput("generic_syntax_exception.xml"); setEppInput("generic_syntax_exception.xml");

View file

@ -34,17 +34,17 @@ import google.registry.flows.session.LoginFlow.TooManyFailedLoginsException;
import google.registry.flows.session.LoginFlow.UnsupportedLanguageException; import google.registry.flows.session.LoginFlow.UnsupportedLanguageException;
import google.registry.model.registrar.Registrar; import google.registry.model.registrar.Registrar;
import google.registry.model.registrar.Registrar.State; import google.registry.model.registrar.Registrar.State;
import org.junit.Before; import org.junit.jupiter.api.BeforeEach;
import org.junit.Test; import org.junit.jupiter.api.Test;
/** Unit tests for {@link LoginFlow}. */ /** Unit tests for {@link LoginFlow}. */
public abstract class LoginFlowTestCase extends FlowTestCase<LoginFlow> { public abstract class LoginFlowTestCase extends FlowTestCase<LoginFlow> {
Registrar registrar; private Registrar registrar;
Registrar.Builder registrarBuilder; private Registrar.Builder registrarBuilder;
@Before @BeforeEach
public void initRegistrar() { void initRegistrar() {
sessionMetadata.setClientId(null); // Don't implicitly log in (all other flows need to). sessionMetadata.setClientId(null); // Don't implicitly log in (all other flows need to).
registrar = loadRegistrar("NewRegistrar"); registrar = loadRegistrar("NewRegistrar");
registrarBuilder = registrar.asBuilder(); registrarBuilder = registrar.asBuilder();
@ -70,73 +70,73 @@ public abstract class LoginFlowTestCase extends FlowTestCase<LoginFlow> {
} }
@Test @Test
public void testSuccess() throws Exception { void testSuccess() throws Exception {
doSuccessfulTest("login_valid.xml"); doSuccessfulTest("login_valid.xml");
} }
@Test @Test
public void testSuccess_suspendedRegistrar() throws Exception { void testSuccess_suspendedRegistrar() throws Exception {
persistResource(getRegistrarBuilder().setState(State.SUSPENDED).build()); persistResource(getRegistrarBuilder().setState(State.SUSPENDED).build());
doSuccessfulTest("login_valid.xml"); doSuccessfulTest("login_valid.xml");
} }
@Test @Test
public void testSuccess_missingTypes() throws Exception { void testSuccess_missingTypes() throws Exception {
// We don't actually care if you list all the right types, as long as you don't add wrong ones. // We don't actually care if you list all the right types, as long as you don't add wrong ones.
doSuccessfulTest("login_valid_missing_types.xml"); doSuccessfulTest("login_valid_missing_types.xml");
} }
@Test @Test
public void testFailure_invalidVersion() { void testFailure_invalidVersion() {
doFailingTest("login_invalid_version.xml", UnimplementedProtocolVersionException.class); doFailingTest("login_invalid_version.xml", UnimplementedProtocolVersionException.class);
} }
@Test @Test
public void testFailure_invalidLanguage() { void testFailure_invalidLanguage() {
doFailingTest("login_invalid_language.xml", UnsupportedLanguageException.class); doFailingTest("login_invalid_language.xml", UnsupportedLanguageException.class);
} }
@Test @Test
public void testFailure_invalidExtension() { void testFailure_invalidExtension() {
doFailingTest("login_invalid_extension.xml", UnimplementedExtensionException.class); doFailingTest("login_invalid_extension.xml", UnimplementedExtensionException.class);
} }
@Test @Test
public void testFailure_invalidTypes() { void testFailure_invalidTypes() {
doFailingTest("login_invalid_types.xml", UnimplementedObjectServiceException.class); doFailingTest("login_invalid_types.xml", UnimplementedObjectServiceException.class);
} }
@Test @Test
public void testFailure_newPassword() { void testFailure_newPassword() {
doFailingTest("login_invalid_newpw.xml", PasswordChangesNotSupportedException.class); doFailingTest("login_invalid_newpw.xml", PasswordChangesNotSupportedException.class);
} }
@Test @Test
public void testFailure_unknownRegistrar() { void testFailure_unknownRegistrar() {
deleteResource(getRegistrarBuilder().build()); deleteResource(getRegistrarBuilder().build());
doFailingTest("login_valid.xml", BadRegistrarClientIdException.class); doFailingTest("login_valid.xml", BadRegistrarClientIdException.class);
} }
@Test @Test
public void testFailure_pendingRegistrar() { void testFailure_pendingRegistrar() {
persistResource(getRegistrarBuilder().setState(State.PENDING).build()); persistResource(getRegistrarBuilder().setState(State.PENDING).build());
doFailingTest("login_valid.xml", RegistrarAccountNotActiveException.class); doFailingTest("login_valid.xml", RegistrarAccountNotActiveException.class);
} }
@Test @Test
public void testFailure_disabledRegistrar() { void testFailure_disabledRegistrar() {
persistResource(getRegistrarBuilder().setState(State.DISABLED).build()); persistResource(getRegistrarBuilder().setState(State.DISABLED).build());
doFailingTest("login_valid.xml", RegistrarAccountNotActiveException.class); doFailingTest("login_valid.xml", RegistrarAccountNotActiveException.class);
} }
@Test @Test
public void testFailure_incorrectPassword() { void testFailure_incorrectPassword() {
persistResource(getRegistrarBuilder().setPassword("diff password").build()); persistResource(getRegistrarBuilder().setPassword("diff password").build());
doFailingTest("login_valid.xml", BadRegistrarPasswordException.class); doFailingTest("login_valid.xml", BadRegistrarPasswordException.class);
} }
@Test @Test
public void testFailure_tooManyFailedLogins() { void testFailure_tooManyFailedLogins() {
persistResource(getRegistrarBuilder().setPassword("diff password").build()); persistResource(getRegistrarBuilder().setPassword("diff password").build());
doFailingTest("login_valid.xml", BadRegistrarPasswordException.class); doFailingTest("login_valid.xml", BadRegistrarPasswordException.class);
doFailingTest("login_valid.xml", BadRegistrarPasswordException.class); doFailingTest("login_valid.xml", BadRegistrarPasswordException.class);
@ -145,7 +145,7 @@ public abstract class LoginFlowTestCase extends FlowTestCase<LoginFlow> {
} }
@Test @Test
public void testFailure_alreadyLoggedIn() { void testFailure_alreadyLoggedIn() {
sessionMetadata.setClientId("something"); sessionMetadata.setClientId("something");
doFailingTest("login_valid.xml", AlreadyLoggedInException.class); doFailingTest("login_valid.xml", AlreadyLoggedInException.class);
} }

View file

@ -26,7 +26,7 @@ import google.registry.model.registrar.Registrar;
import google.registry.testing.CertificateSamples; import google.registry.testing.CertificateSamples;
import google.registry.util.CidrAddressBlock; import google.registry.util.CidrAddressBlock;
import java.util.Optional; import java.util.Optional;
import org.junit.Test; import org.junit.jupiter.api.Test;
/** Unit tests for {@link LoginFlow} when accessed via a TLS transport. */ /** Unit tests for {@link LoginFlow} when accessed via a TLS transport. */
public class LoginFlowViaTlsTest extends LoginFlowTestCase { public class LoginFlowViaTlsTest extends LoginFlowTestCase {
@ -47,14 +47,14 @@ public class LoginFlowViaTlsTest extends LoginFlowTestCase {
} }
@Test @Test
public void testSuccess_withGoodCredentials() throws Exception { void testSuccess_withGoodCredentials() throws Exception {
persistResource(getRegistrarBuilder().build()); persistResource(getRegistrarBuilder().build());
credentials = new TlsCredentials(true, GOOD_CERT, GOOD_IP); credentials = new TlsCredentials(true, GOOD_CERT, GOOD_IP);
doSuccessfulTest("login_valid.xml"); doSuccessfulTest("login_valid.xml");
} }
@Test @Test
public void testSuccess_withGoodCredentialsIpv6() throws Exception { void testSuccess_withGoodCredentialsIpv6() throws Exception {
persistResource( persistResource(
getRegistrarBuilder() getRegistrarBuilder()
.setIpAddressAllowList( .setIpAddressAllowList(
@ -65,7 +65,7 @@ public class LoginFlowViaTlsTest extends LoginFlowTestCase {
} }
@Test @Test
public void testSuccess_withIpv6AddressInSubnet() throws Exception { void testSuccess_withIpv6AddressInSubnet() throws Exception {
persistResource( persistResource(
getRegistrarBuilder() getRegistrarBuilder()
.setIpAddressAllowList( .setIpAddressAllowList(
@ -76,7 +76,7 @@ public class LoginFlowViaTlsTest extends LoginFlowTestCase {
} }
@Test @Test
public void testSuccess_withIpv4AddressInSubnet() throws Exception { void testSuccess_withIpv4AddressInSubnet() throws Exception {
persistResource( persistResource(
getRegistrarBuilder() getRegistrarBuilder()
.setIpAddressAllowList(ImmutableList.of(CidrAddressBlock.create("192.168.1.255/24"))) .setIpAddressAllowList(ImmutableList.of(CidrAddressBlock.create("192.168.1.255/24")))
@ -86,21 +86,21 @@ public class LoginFlowViaTlsTest extends LoginFlowTestCase {
} }
@Test @Test
public void testFailure_incorrectClientCertificateHash() { void testFailure_incorrectClientCertificateHash() {
persistResource(getRegistrarBuilder().build()); persistResource(getRegistrarBuilder().build());
credentials = new TlsCredentials(true, BAD_CERT, GOOD_IP); credentials = new TlsCredentials(true, BAD_CERT, GOOD_IP);
doFailingTest("login_valid.xml", BadRegistrarCertificateException.class); doFailingTest("login_valid.xml", BadRegistrarCertificateException.class);
} }
@Test @Test
public void testFailure_missingClientCertificateHash() { void testFailure_missingClientCertificateHash() {
persistResource(getRegistrarBuilder().build()); persistResource(getRegistrarBuilder().build());
credentials = new TlsCredentials(true, null, GOOD_IP); credentials = new TlsCredentials(true, null, GOOD_IP);
doFailingTest("login_valid.xml", MissingRegistrarCertificateException.class); doFailingTest("login_valid.xml", MissingRegistrarCertificateException.class);
} }
@Test @Test
public void testFailure_missingClientIpAddress() { void testFailure_missingClientIpAddress() {
persistResource( persistResource(
getRegistrarBuilder() getRegistrarBuilder()
.setIpAddressAllowList( .setIpAddressAllowList(
@ -113,7 +113,7 @@ public class LoginFlowViaTlsTest extends LoginFlowTestCase {
} }
@Test @Test
public void testFailure_incorrectClientIpv4Address() { void testFailure_incorrectClientIpv4Address() {
persistResource( persistResource(
getRegistrarBuilder() getRegistrarBuilder()
.setIpAddressAllowList( .setIpAddressAllowList(
@ -126,7 +126,7 @@ public class LoginFlowViaTlsTest extends LoginFlowTestCase {
} }
@Test @Test
public void testFailure_incorrectClientIpv6Address() { void testFailure_incorrectClientIpv6Address() {
persistResource( persistResource(
getRegistrarBuilder() getRegistrarBuilder()
.setIpAddressAllowList( .setIpAddressAllowList(

View file

@ -21,30 +21,30 @@ import static org.junit.Assert.assertThrows;
import google.registry.flows.EppException; import google.registry.flows.EppException;
import google.registry.flows.FlowTestCase; import google.registry.flows.FlowTestCase;
import google.registry.flows.FlowUtils.NotLoggedInException; import google.registry.flows.FlowUtils.NotLoggedInException;
import org.junit.Before; import org.junit.jupiter.api.BeforeEach;
import org.junit.Test; import org.junit.jupiter.api.Test;
/** Unit tests for {@link LogoutFlow}. */ /** Unit tests for {@link LogoutFlow}. */
public class LogoutFlowTest extends FlowTestCase<LogoutFlow> { class LogoutFlowTest extends FlowTestCase<LogoutFlow> {
public LogoutFlowTest() { LogoutFlowTest() {
setEppInput("logout.xml"); setEppInput("logout.xml");
} }
@Before @BeforeEach
public void setupTld() { void setupTld() {
createTld("example"); createTld("example");
} }
@Test @Test
public void testSuccess() throws Exception { void testSuccess() throws Exception {
assertTransactionalFlow(false); assertTransactionalFlow(false);
// All flow tests are implicitly logged in, so logout should work. // All flow tests are implicitly logged in, so logout should work.
runFlowAssertResponse(loadFile("logout_response.xml")); runFlowAssertResponse(loadFile("logout_response.xml"));
} }
@Test @Test
public void testFailure() { void testFailure() {
sessionMetadata.setClientId(null); // Turn off the implicit login sessionMetadata.setClientId(null); // Turn off the implicit login
EppException thrown = assertThrows(NotLoggedInException.class, this::runFlow); EppException thrown = assertThrows(NotLoggedInException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml(); assertAboutEppExceptions().that(thrown).marshalsToXml();

View file

@ -21,14 +21,13 @@ import static org.junit.Assert.assertThrows;
import google.registry.model.eppinput.EppInput; import google.registry.model.eppinput.EppInput;
import google.registry.model.eppoutput.EppOutput; import google.registry.model.eppoutput.EppOutput;
import google.registry.testing.ShardableTestCase;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.junit.runners.JUnit4; import org.junit.runners.JUnit4;
/** Tests for {@link EppXmlTransformer}. */ /** Tests for {@link EppXmlTransformer}. */
@RunWith(JUnit4.class) @RunWith(JUnit4.class)
public class EppXmlTransformerTest extends ShardableTestCase { public class EppXmlTransformerTest {
@Test @Test
public void testUnmarshalingEppInput() throws Exception { public void testUnmarshalingEppInput() throws Exception {

View file

@ -35,7 +35,6 @@ import google.registry.model.registrar.RegistrarAddress;
import google.registry.model.registry.Registry; import google.registry.model.registry.Registry;
import google.registry.model.registry.Registry.TldType; import google.registry.model.registry.Registry.TldType;
import google.registry.testing.AppEngineRule; import google.registry.testing.AppEngineRule;
import google.registry.testing.ShardableTestCase;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.junit.Before; import org.junit.Before;
@ -46,7 +45,7 @@ import org.junit.runners.JUnit4;
/** Unit tests for {@link UpdateRegistrarRdapBaseUrlsAction}. */ /** Unit tests for {@link UpdateRegistrarRdapBaseUrlsAction}. */
@RunWith(JUnit4.class) @RunWith(JUnit4.class)
public final class UpdateRegistrarRdapBaseUrlsActionTest extends ShardableTestCase { public final class UpdateRegistrarRdapBaseUrlsActionTest {
/** /**
* Example reply from the MoSAPI server. * Example reply from the MoSAPI server.

View file

@ -34,7 +34,6 @@ import google.registry.testing.BouncyCastleProviderRule;
import google.registry.testing.FakeKeyringModule; import google.registry.testing.FakeKeyringModule;
import google.registry.testing.GcsTestingUtils; import google.registry.testing.GcsTestingUtils;
import google.registry.testing.GpgSystemCommandRule; import google.registry.testing.GpgSystemCommandRule;
import google.registry.testing.ShardableTestCase;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
@ -52,7 +51,7 @@ import org.junit.runners.JUnit4;
/** Unit tests for {@link BrdaCopyAction}. */ /** Unit tests for {@link BrdaCopyAction}. */
@RunWith(JUnit4.class) @RunWith(JUnit4.class)
public class BrdaCopyActionTest extends ShardableTestCase { public class BrdaCopyActionTest {
private static final ByteSource DEPOSIT_XML = RdeTestData.loadBytes("deposit_full.xml"); private static final ByteSource DEPOSIT_XML = RdeTestData.loadBytes("deposit_full.xml");

View file

@ -26,7 +26,6 @@ import google.registry.keyring.api.Keyring;
import google.registry.testing.BouncyCastleProviderRule; import google.registry.testing.BouncyCastleProviderRule;
import google.registry.testing.FakeKeyringModule; import google.registry.testing.FakeKeyringModule;
import google.registry.testing.GpgSystemCommandRule; import google.registry.testing.GpgSystemCommandRule;
import google.registry.testing.ShardableTestCase;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileOutputStream; import java.io.FileOutputStream;
@ -43,7 +42,7 @@ import org.junit.runner.RunWith;
/** GnuPG integration tests for {@link Ghostryde}. */ /** GnuPG integration tests for {@link Ghostryde}. */
@RunWith(Theories.class) @RunWith(Theories.class)
@SuppressWarnings("resource") @SuppressWarnings("resource")
public class GhostrydeGpgIntegrationTest extends ShardableTestCase { public class GhostrydeGpgIntegrationTest {
@Rule @Rule
public final BouncyCastleProviderRule bouncy = new BouncyCastleProviderRule(); public final BouncyCastleProviderRule bouncy = new BouncyCastleProviderRule();

View file

@ -19,7 +19,6 @@ import static google.registry.testing.DatastoreHelper.loadRegistrar;
import static google.registry.xml.ValidationMode.STRICT; import static google.registry.xml.ValidationMode.STRICT;
import google.registry.testing.AppEngineRule; import google.registry.testing.AppEngineRule;
import google.registry.testing.ShardableTestCase;
import google.registry.xml.XmlTestUtils; import google.registry.xml.XmlTestUtils;
import org.junit.Rule; import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
@ -28,7 +27,7 @@ import org.junit.runners.JUnit4;
/** Unit tests for {@link RdeMarshaller}. */ /** Unit tests for {@link RdeMarshaller}. */
@RunWith(JUnit4.class) @RunWith(JUnit4.class)
public class RdeMarshallerTest extends ShardableTestCase { public class RdeMarshallerTest {
private static final String DECLARATION = private static final String DECLARATION =
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n"; "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n";

View file

@ -28,7 +28,6 @@ import google.registry.model.registrar.RegistrarAddress;
import google.registry.testing.AppEngineRule; import google.registry.testing.AppEngineRule;
import google.registry.testing.FakeClock; import google.registry.testing.FakeClock;
import google.registry.testing.InjectRule; import google.registry.testing.InjectRule;
import google.registry.testing.ShardableTestCase;
import google.registry.xjc.rderegistrar.XjcRdeRegistrar; import google.registry.xjc.rderegistrar.XjcRdeRegistrar;
import google.registry.xjc.rderegistrar.XjcRdeRegistrarAddrType; import google.registry.xjc.rderegistrar.XjcRdeRegistrarAddrType;
import google.registry.xjc.rderegistrar.XjcRdeRegistrarPostalInfoEnumType; import google.registry.xjc.rderegistrar.XjcRdeRegistrarPostalInfoEnumType;
@ -45,11 +44,11 @@ import org.junit.runners.JUnit4;
/** /**
* Unit tests for {@link RegistrarToXjcConverter}. * Unit tests for {@link RegistrarToXjcConverter}.
* *
* <p>This tests the mapping between {@link Registrar} and {@link XjcRdeRegistrar} as well as * <p>This tests the mapping between {@link Registrar} and {@link XjcRdeRegistrar} as well as some
* some exceptional conditions. * exceptional conditions.
*/ */
@RunWith(JUnit4.class) @RunWith(JUnit4.class)
public class RegistrarToXjcConverterTest extends ShardableTestCase { public class RegistrarToXjcConverterTest {
@Rule @Rule
public final AppEngineRule appEngine = AppEngineRule.builder().withDatastoreAndCloudSql().build(); public final AppEngineRule appEngine = AppEngineRule.builder().withDatastoreAndCloudSql().build();

View file

@ -18,7 +18,6 @@ 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 com.google.common.io.ByteStreams; import com.google.common.io.ByteStreams;
import google.registry.testing.ShardableTestCase;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.InputStream; import java.io.InputStream;
@ -28,7 +27,7 @@ import org.junit.runner.RunWith;
import org.junit.runners.JUnit4; import org.junit.runners.JUnit4;
@RunWith(JUnit4.class) @RunWith(JUnit4.class)
public final class RydeCompressionTest extends ShardableTestCase { public final class RydeCompressionTest {
@Test @Test
public void testCompression_decompression() throws Exception { public void testCompression_decompression() throws Exception {

View file

@ -23,7 +23,6 @@ import com.google.common.collect.ImmutableList;
import com.google.common.io.ByteStreams; import com.google.common.io.ByteStreams;
import google.registry.testing.BouncyCastleProviderRule; import google.registry.testing.BouncyCastleProviderRule;
import google.registry.testing.FakeKeyringModule; import google.registry.testing.FakeKeyringModule;
import google.registry.testing.ShardableTestCase;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.InputStream; import java.io.InputStream;
@ -37,7 +36,7 @@ import org.junit.runner.RunWith;
import org.junit.runners.JUnit4; import org.junit.runners.JUnit4;
@RunWith(JUnit4.class) @RunWith(JUnit4.class)
public final class RydeEncryptionTest extends ShardableTestCase { public final class RydeEncryptionTest {
@Rule public final BouncyCastleProviderRule bouncy = new BouncyCastleProviderRule(); @Rule public final BouncyCastleProviderRule bouncy = new BouncyCastleProviderRule();

View file

@ -18,7 +18,6 @@ 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 com.google.common.io.ByteStreams; import com.google.common.io.ByteStreams;
import google.registry.testing.ShardableTestCase;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.OutputStream; import java.io.OutputStream;
@ -28,7 +27,7 @@ import org.junit.runner.RunWith;
import org.junit.runners.JUnit4; import org.junit.runners.JUnit4;
@RunWith(JUnit4.class) @RunWith(JUnit4.class)
public final class RydeFileEncodingTest extends ShardableTestCase { public final class RydeFileEncodingTest {
@Test @Test
public void testEncodeDecode() throws Exception { public void testEncodeDecode() throws Exception {

View file

@ -27,7 +27,6 @@ import google.registry.keyring.api.Keyring;
import google.registry.testing.BouncyCastleProviderRule; import google.registry.testing.BouncyCastleProviderRule;
import google.registry.testing.FakeKeyringModule; import google.registry.testing.FakeKeyringModule;
import google.registry.testing.GpgSystemCommandRule; import google.registry.testing.GpgSystemCommandRule;
import google.registry.testing.ShardableTestCase;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileOutputStream; import java.io.FileOutputStream;
@ -47,7 +46,7 @@ import org.junit.runner.RunWith;
/** GPG combinatorial integration tests for the Ryde classes. */ /** GPG combinatorial integration tests for the Ryde classes. */
@RunWith(Theories.class) @RunWith(Theories.class)
@SuppressWarnings("resource") @SuppressWarnings("resource")
public class RydeGpgIntegrationTest extends ShardableTestCase { public class RydeGpgIntegrationTest {
private static final FluentLogger logger = FluentLogger.forEnclosingClass(); private static final FluentLogger logger = FluentLogger.forEnclosingClass();

View file

@ -18,7 +18,6 @@ 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 com.google.common.io.ByteStreams; import com.google.common.io.ByteStreams;
import google.registry.testing.ShardableTestCase;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.OutputStream; import java.io.OutputStream;
@ -28,7 +27,7 @@ import org.junit.runner.RunWith;
import org.junit.runners.JUnit4; import org.junit.runners.JUnit4;
@RunWith(JUnit4.class) @RunWith(JUnit4.class)
public final class RydeTarTest extends ShardableTestCase { public final class RydeTarTest {
@Test @Test
public void testWriteRead() throws Exception { public void testWriteRead() throws Exception {

View file

@ -1,55 +0,0 @@
// Copyright 2017 The Nomulus Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package google.registry.testing;
import com.google.common.flogger.FluentLogger;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TestName;
/**
* Test case with 3 empty methods.
*
* <p>The sharding test runner fails if it produces an empty shard, and we shard 4 ways. This makes
* sure that we never produces empty shards.
*/
public abstract class ShardableTestCase {
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
@Rule
public final TestName testName = new TestName();
@Before
public void beforeShardable() {
logger.atInfo().log("Starting test %s", testName.getMethodName());
}
@After
public void afterShardable() {
logger.atInfo().log("Finishing test %s", testName.getMethodName());
}
@Test
public void testNothing1() {}
@Test
public void testNothing2() {}
@Test
public void testNothing3() {}
}

View file

@ -36,7 +36,6 @@ import com.google.common.flogger.FluentLogger;
import google.registry.mapreduce.MapreduceRunner; import google.registry.mapreduce.MapreduceRunner;
import google.registry.testing.AppEngineRule; import google.registry.testing.AppEngineRule;
import google.registry.testing.FakeClock; import google.registry.testing.FakeClock;
import google.registry.testing.ShardableTestCase;
import google.registry.util.AppEngineServiceUtils; import google.registry.util.AppEngineServiceUtils;
import google.registry.util.AppEngineServiceUtilsImpl; import google.registry.util.AppEngineServiceUtilsImpl;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
@ -68,7 +67,7 @@ import org.mockito.junit.MockitoRule;
* *
* @param <T> The type of the Action class that implements the mapreduce. * @param <T> The type of the Action class that implements the mapreduce.
*/ */
public abstract class MapreduceTestCase<T> extends ShardableTestCase { public abstract class MapreduceTestCase<T> {
private static final FluentLogger logger = FluentLogger.forEnclosingClass(); private static final FluentLogger logger = FluentLogger.forEnclosingClass();

View file

@ -269,8 +269,7 @@ public final class RegistryLockPostActionTest {
public void testFailure_incorrectRegistrarIdForDomain() { public void testFailure_incorrectRegistrarIdForDomain() {
persistResource(domain.asBuilder().setPersistedCurrentSponsorClientId("NewRegistrar").build()); persistResource(domain.asBuilder().setPersistedCurrentSponsorClientId("NewRegistrar").build());
Map<String, ?> response = action.handleJsonRequest(lockRequest()); Map<String, ?> response = action.handleJsonRequest(lockRequest());
assertFailureWithMessage( assertFailureWithMessage(response, "Domain example.tld is not owned by registrar TheRegistrar");
response, "Domain example.tld is not owned by registrar TheRegistrar");
} }
@Test @Test