mirror of
https://github.com/google/nomulus.git
synced 2025-06-11 15:04:46 +02:00
Upgrade all remaining flows tests to JUnit 5 (#704)
This commit is contained in:
parent
0a65e05f9d
commit
0385d968db
26 changed files with 323 additions and 384 deletions
|
@ -39,35 +39,31 @@ import google.registry.testing.FakeResponse;
|
|||
import java.util.Map;
|
||||
import org.joda.time.DateTime;
|
||||
import org.json.simple.JSONValue;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.Captor;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnit;
|
||||
import org.mockito.junit.MockitoRule;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
|
||||
/** Tests for {@link CheckApiAction}. */
|
||||
@RunWith(JUnit4.class)
|
||||
public class CheckApiActionTest {
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
class CheckApiActionTest {
|
||||
|
||||
private static final DateTime START_TIME = DateTime.parse("2000-01-01T00:00:00.0Z");
|
||||
|
||||
@Rule
|
||||
public final AppEngineRule appEngine = AppEngineRule.builder().withDatastoreAndCloudSql().build();
|
||||
|
||||
@Rule public final MockitoRule mocks = MockitoJUnit.rule();
|
||||
@RegisterExtension
|
||||
final AppEngineRule appEngine = AppEngineRule.builder().withDatastoreAndCloudSql().build();
|
||||
|
||||
@Mock private CheckApiMetrics checkApiMetrics;
|
||||
@Captor private ArgumentCaptor<CheckApiMetric> metricCaptor;
|
||||
|
||||
private DateTime endTime;
|
||||
|
||||
@Before
|
||||
public void init() {
|
||||
@BeforeEach
|
||||
void beforeEach() {
|
||||
createTld("example");
|
||||
persistResource(
|
||||
Registry.get("example")
|
||||
|
@ -98,7 +94,7 @@ public class CheckApiActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_nullDomain() {
|
||||
void testFailure_nullDomain() {
|
||||
assertThat(getCheckResponse(null))
|
||||
.containsExactly(
|
||||
"status", "error",
|
||||
|
@ -108,7 +104,7 @@ public class CheckApiActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_emptyDomain() {
|
||||
void testFailure_emptyDomain() {
|
||||
assertThat(getCheckResponse(""))
|
||||
.containsExactly(
|
||||
"status", "error",
|
||||
|
@ -118,7 +114,7 @@ public class CheckApiActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_invalidDomain() {
|
||||
void testFailure_invalidDomain() {
|
||||
assertThat(getCheckResponse("@#$%^"))
|
||||
.containsExactly(
|
||||
"status", "error",
|
||||
|
@ -128,7 +124,7 @@ public class CheckApiActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_singlePartDomain() {
|
||||
void testFailure_singlePartDomain() {
|
||||
assertThat(getCheckResponse("foo"))
|
||||
.containsExactly(
|
||||
"status", "error",
|
||||
|
@ -138,7 +134,7 @@ public class CheckApiActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_nonExistentTld() {
|
||||
void testFailure_nonExistentTld() {
|
||||
assertThat(getCheckResponse("foo.bar"))
|
||||
.containsExactly(
|
||||
"status", "error",
|
||||
|
@ -148,7 +144,7 @@ public class CheckApiActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_invalidIdnTable() {
|
||||
void testFailure_invalidIdnTable() {
|
||||
assertThat(getCheckResponse("ΑΒΓ.example"))
|
||||
.containsExactly(
|
||||
"status", "error",
|
||||
|
@ -158,7 +154,7 @@ public class CheckApiActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_tldInPredelegation() {
|
||||
void testFailure_tldInPredelegation() {
|
||||
createTld("predelegated", PREDELEGATION);
|
||||
assertThat(getCheckResponse("foo.predelegated"))
|
||||
.containsExactly(
|
||||
|
@ -169,7 +165,7 @@ public class CheckApiActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_availableStandard() {
|
||||
void testSuccess_availableStandard() {
|
||||
assertThat(getCheckResponse("somedomain.example"))
|
||||
.containsExactly(
|
||||
"status", "success",
|
||||
|
@ -180,7 +176,7 @@ public class CheckApiActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_availableCapital() {
|
||||
void testSuccess_availableCapital() {
|
||||
assertThat(getCheckResponse("SOMEDOMAIN.EXAMPLE"))
|
||||
.containsExactly(
|
||||
"status", "success",
|
||||
|
@ -191,7 +187,7 @@ public class CheckApiActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_availableUnicode() {
|
||||
void testSuccess_availableUnicode() {
|
||||
assertThat(getCheckResponse("ééé.example"))
|
||||
.containsExactly(
|
||||
"status", "success",
|
||||
|
@ -202,7 +198,7 @@ public class CheckApiActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_availablePunycode() {
|
||||
void testSuccess_availablePunycode() {
|
||||
assertThat(getCheckResponse("xn--9caaa.example"))
|
||||
.containsExactly(
|
||||
"status", "success",
|
||||
|
@ -213,7 +209,7 @@ public class CheckApiActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_availablePremium() {
|
||||
void testSuccess_availablePremium() {
|
||||
assertThat(getCheckResponse("rich.example"))
|
||||
.containsExactly(
|
||||
"status", "success",
|
||||
|
@ -224,7 +220,7 @@ public class CheckApiActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_registered_standard() {
|
||||
void testSuccess_registered_standard() {
|
||||
persistActiveDomain("somedomain.example");
|
||||
assertThat(getCheckResponse("somedomain.example"))
|
||||
.containsExactly(
|
||||
|
@ -237,7 +233,7 @@ public class CheckApiActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_reserved_standard() {
|
||||
void testSuccess_reserved_standard() {
|
||||
assertThat(getCheckResponse("foo.example"))
|
||||
.containsExactly(
|
||||
"tier", "standard",
|
||||
|
@ -249,7 +245,7 @@ public class CheckApiActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_registered_premium() {
|
||||
void testSuccess_registered_premium() {
|
||||
persistActiveDomain("rich.example");
|
||||
assertThat(getCheckResponse("rich.example"))
|
||||
.containsExactly(
|
||||
|
@ -262,7 +258,7 @@ public class CheckApiActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_reserved_premium() {
|
||||
void testSuccess_reserved_premium() {
|
||||
assertThat(getCheckResponse("platinum.example"))
|
||||
.containsExactly(
|
||||
"tier", "premium",
|
||||
|
@ -274,7 +270,7 @@ public class CheckApiActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_reservedForSpecificUse_premium() {
|
||||
void testSuccess_reservedForSpecificUse_premium() {
|
||||
assertThat(getCheckResponse("gold.example"))
|
||||
.containsExactly(
|
||||
"tier", "premium",
|
||||
|
|
|
@ -36,28 +36,24 @@ import google.registry.testing.FakeClock;
|
|||
import google.registry.testing.FakeHttpSession;
|
||||
import google.registry.testing.InjectRule;
|
||||
import org.joda.time.DateTime;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
/** Test that domain flows create the commit logs needed to reload at points in the past. */
|
||||
@RunWith(JUnit4.class)
|
||||
public class EppCommitLogsTest {
|
||||
class EppCommitLogsTest {
|
||||
|
||||
@Rule
|
||||
public final AppEngineRule appEngine =
|
||||
@RegisterExtension
|
||||
final AppEngineRule appEngine =
|
||||
AppEngineRule.builder().withDatastoreAndCloudSql().withTaskQueue().build();
|
||||
|
||||
@Rule
|
||||
public final InjectRule inject = new InjectRule();
|
||||
@RegisterExtension final InjectRule inject = new InjectRule();
|
||||
|
||||
private final FakeClock clock = new FakeClock(DateTime.now(UTC));
|
||||
private EppLoader eppLoader;
|
||||
|
||||
@Before
|
||||
public void init() {
|
||||
@BeforeEach
|
||||
void beforeEach() {
|
||||
createTld("tld");
|
||||
inject.setStaticField(Ofy.class, "clock", clock);
|
||||
}
|
||||
|
@ -66,8 +62,7 @@ public class EppCommitLogsTest {
|
|||
SessionMetadata sessionMetadata = new HttpSessionMetadata(new FakeHttpSession());
|
||||
sessionMetadata.setClientId("TheRegistrar");
|
||||
DaggerEppTestComponent.builder()
|
||||
.fakesAndMocksModule(
|
||||
FakesAndMocksModule.create(clock, EppMetric.builderForRequest(clock)))
|
||||
.fakesAndMocksModule(FakesAndMocksModule.create(clock, EppMetric.builderForRequest(clock)))
|
||||
.build()
|
||||
.startRequest()
|
||||
.flowComponentBuilder()
|
||||
|
@ -87,8 +82,8 @@ public class EppCommitLogsTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testLoadAtPointInTime() throws Exception {
|
||||
clock.setTo(DateTime.parse("1984-12-18T12:30Z")); // not midnight
|
||||
void testLoadAtPointInTime() throws Exception {
|
||||
clock.setTo(DateTime.parse("1984-12-18T12:30Z")); // not midnight
|
||||
|
||||
persistActiveHost("ns1.example.net");
|
||||
persistActiveHost("ns2.example.net");
|
||||
|
@ -114,7 +109,7 @@ public class EppCommitLogsTest {
|
|||
DomainBase domainAfterFirstUpdate = ofy().load().key(key).now();
|
||||
assertThat(domainAfterCreate).isNotEqualTo(domainAfterFirstUpdate);
|
||||
|
||||
clock.advanceOneMilli(); // same day as first update
|
||||
clock.advanceOneMilli(); // same day as first update
|
||||
DateTime timeAtSecondUpdate = clock.nowUtc();
|
||||
eppLoader = new EppLoader(this, "domain_update_dsdata_rem.xml");
|
||||
runFlow();
|
||||
|
@ -146,8 +141,7 @@ public class EppCommitLogsTest {
|
|||
// key to the first update should have been overwritten by the second, and its timestamp rolled
|
||||
// forward. So we have to fall back to the last revision before midnight.
|
||||
ofy().clearSessionCache();
|
||||
assertThat(loadAtPointInTime(latest, timeAtFirstUpdate).now())
|
||||
.isEqualTo(domainAfterCreate);
|
||||
assertThat(loadAtPointInTime(latest, timeAtFirstUpdate).now()).isEqualTo(domainAfterCreate);
|
||||
|
||||
ofy().clearSessionCache();
|
||||
assertThat(loadAtPointInTime(latest, timeAtSecondUpdate).now())
|
||||
|
|
|
@ -50,26 +50,24 @@ import java.util.logging.LogRecord;
|
|||
import java.util.logging.Logger;
|
||||
import org.joda.time.DateTime;
|
||||
import org.json.simple.JSONValue;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
import org.mockito.ArgumentMatchers;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnit;
|
||||
import org.mockito.junit.MockitoRule;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import org.mockito.junit.jupiter.MockitoSettings;
|
||||
import org.mockito.quality.Strictness;
|
||||
|
||||
/** Unit tests for {@link EppController}. */
|
||||
@RunWith(JUnit4.class)
|
||||
public class EppControllerTest {
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
@MockitoSettings(strictness = Strictness.LENIENT)
|
||||
class EppControllerTest {
|
||||
|
||||
@Rule
|
||||
public AppEngineRule appEngineRule =
|
||||
new AppEngineRule.Builder().withDatastoreAndCloudSql().build();
|
||||
|
||||
@Rule public final MockitoRule mocks = MockitoJUnit.rule();
|
||||
@RegisterExtension
|
||||
AppEngineRule appEngineRule = new AppEngineRule.Builder().withDatastoreAndCloudSql().build();
|
||||
|
||||
@Mock SessionMetadata sessionMetadata;
|
||||
@Mock TransportCredentials transportCredentials;
|
||||
|
@ -96,8 +94,8 @@ public class EppControllerTest {
|
|||
|
||||
private EppController eppController;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
@BeforeEach
|
||||
void beforeEach() throws Exception {
|
||||
loggerToIntercept.addHandler(logHandler);
|
||||
|
||||
when(sessionMetadata.getClientId()).thenReturn("some-client");
|
||||
|
@ -117,13 +115,13 @@ public class EppControllerTest {
|
|||
eppController.serverTridProvider = new FakeServerTridProvider();
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
@AfterEach
|
||||
void afterEach() {
|
||||
loggerToIntercept.removeHandler(logHandler);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMarshallingUnknownError() throws Exception {
|
||||
void testMarshallingUnknownError() throws Exception {
|
||||
marshal(
|
||||
EppController.getErrorResponse(
|
||||
Result.create(Code.COMMAND_FAILED), Trid.create(null, "server-trid")),
|
||||
|
@ -131,7 +129,7 @@ public class EppControllerTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testHandleEppCommand_regularEppCommand_exportsEppMetrics() {
|
||||
void testHandleEppCommand_regularEppCommand_exportsEppMetrics() {
|
||||
createTld("tld");
|
||||
// Note that some of the EPP metric fields, like # of attempts and command name, are set in
|
||||
// FlowRunner, not EppController, and since FlowRunner is mocked out for these tests they won't
|
||||
|
@ -155,7 +153,7 @@ public class EppControllerTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testHandleEppCommand_dryRunEppCommand_doesNotExportMetric() {
|
||||
void testHandleEppCommand_dryRunEppCommand_doesNotExportMetric() {
|
||||
eppController.handleEppCommand(
|
||||
sessionMetadata,
|
||||
transportCredentials,
|
||||
|
@ -167,7 +165,7 @@ public class EppControllerTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testHandleEppCommand_unmarshallableData_loggedAtInfo_withJsonData() throws Exception {
|
||||
void testHandleEppCommand_unmarshallableData_loggedAtInfo_withJsonData() throws Exception {
|
||||
eppController.handleEppCommand(
|
||||
sessionMetadata,
|
||||
transportCredentials,
|
||||
|
@ -176,7 +174,8 @@ public class EppControllerTest {
|
|||
false,
|
||||
"GET / HTTP/1.1\n\n".getBytes(UTF_8));
|
||||
|
||||
assertAboutLogs().that(logHandler)
|
||||
assertAboutLogs()
|
||||
.that(logHandler)
|
||||
.hasLogAtLevelWithMessage(INFO, "EPP request XML unmarshalling failed");
|
||||
LogRecord logRecord =
|
||||
findFirstLogRecordWithMessagePrefix(logHandler, "EPP request XML unmarshalling failed");
|
||||
|
@ -184,14 +183,14 @@ public class EppControllerTest {
|
|||
assertThat(messageParts.size()).isAtLeast(2);
|
||||
Map<String, Object> json = parseJsonMap(messageParts.get(1));
|
||||
assertThat(json).containsEntry("clientId", "some-client");
|
||||
assertThat(json).containsEntry("resultCode", 2001L); // Must be Long to compare equal.
|
||||
assertThat(json).containsEntry("resultCode", 2001L); // Must be Long to compare equal.
|
||||
assertThat(json).containsEntry("resultMessage", "Command syntax error");
|
||||
assertThat(json)
|
||||
.containsEntry("xmlBytes", base64().encode("GET / HTTP/1.1\n\n".getBytes(UTF_8)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHandleEppCommand_throwsEppException_loggedAtInfo() throws Exception {
|
||||
void testHandleEppCommand_throwsEppException_loggedAtInfo() throws Exception {
|
||||
when(flowRunner.run(eppController.eppMetricBuilder))
|
||||
.thenThrow(new UnimplementedExtensionException());
|
||||
eppController.handleEppCommand(
|
||||
|
@ -201,7 +200,8 @@ public class EppControllerTest {
|
|||
false,
|
||||
true,
|
||||
domainCreateXml.getBytes(UTF_8));
|
||||
assertAboutLogs().that(logHandler)
|
||||
assertAboutLogs()
|
||||
.that(logHandler)
|
||||
.hasLogAtLevelWithMessage(INFO, "Flow returned failure response");
|
||||
LogRecord logRecord =
|
||||
findFirstLogRecordWithMessagePrefix(logHandler, "Flow returned failure response");
|
||||
|
@ -209,8 +209,7 @@ public class EppControllerTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testHandleEppCommand_throwsEppExceptionInProviderException_loggedAtInfo()
|
||||
throws Exception {
|
||||
void testHandleEppCommand_throwsEppExceptionInProviderException_loggedAtInfo() throws Exception {
|
||||
when(flowRunner.run(eppController.eppMetricBuilder))
|
||||
.thenThrow(new EppExceptionInProviderException(new UnimplementedExtensionException()));
|
||||
eppController.handleEppCommand(
|
||||
|
@ -220,7 +219,8 @@ public class EppControllerTest {
|
|||
false,
|
||||
true,
|
||||
domainCreateXml.getBytes(UTF_8));
|
||||
assertAboutLogs().that(logHandler)
|
||||
assertAboutLogs()
|
||||
.that(logHandler)
|
||||
.hasLogAtLevelWithMessage(INFO, "Flow returned failure response");
|
||||
LogRecord logRecord =
|
||||
findFirstLogRecordWithMessagePrefix(logHandler, "Flow returned failure response");
|
||||
|
@ -228,7 +228,7 @@ public class EppControllerTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testHandleEppCommand_throwsRuntimeException_loggedAtSevere() throws Exception {
|
||||
void testHandleEppCommand_throwsRuntimeException_loggedAtSevere() throws Exception {
|
||||
when(flowRunner.run(eppController.eppMetricBuilder)).thenThrow(new IllegalStateException());
|
||||
eppController.handleEppCommand(
|
||||
sessionMetadata,
|
||||
|
@ -237,7 +237,8 @@ public class EppControllerTest {
|
|||
false,
|
||||
true,
|
||||
domainCreateXml.getBytes(UTF_8));
|
||||
assertAboutLogs().that(logHandler)
|
||||
assertAboutLogs()
|
||||
.that(logHandler)
|
||||
.hasLogAtLevelWithMessage(SEVERE, "Unexpected failure in flow execution");
|
||||
LogRecord logRecord =
|
||||
findFirstLogRecordWithMessagePrefix(logHandler, "Unexpected failure in flow execution");
|
||||
|
|
|
@ -22,21 +22,18 @@ import static google.registry.testing.EppMetricSubject.assertThat;
|
|||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import google.registry.testing.AppEngineRule;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
/** Tests for contact lifecycle. */
|
||||
@RunWith(JUnit4.class)
|
||||
public class EppLifecycleContactTest extends EppTestCase {
|
||||
class EppLifecycleContactTest extends EppTestCase {
|
||||
|
||||
@Rule
|
||||
public final AppEngineRule appEngine =
|
||||
@RegisterExtension
|
||||
final AppEngineRule appEngine =
|
||||
AppEngineRule.builder().withDatastoreAndCloudSql().withTaskQueue().build();
|
||||
|
||||
@Test
|
||||
public void testContactLifecycle() throws Exception {
|
||||
void testContactLifecycle() throws Exception {
|
||||
assertThatLoginSucceeds("NewRegistrar", "foo-BAR2");
|
||||
assertThatCommand("contact_create_sh8013.xml")
|
||||
.atTime("2000-06-01T00:00:00Z")
|
||||
|
@ -72,7 +69,7 @@ public class EppLifecycleContactTest extends EppTestCase {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testContactTransferPollMessage() throws Exception {
|
||||
void testContactTransferPollMessage() throws Exception {
|
||||
assertThatLoginSucceeds("NewRegistrar", "foo-BAR2");
|
||||
assertThatCommand("contact_create_sh8013.xml")
|
||||
.atTime("2000-06-01T00:00:00Z")
|
||||
|
|
|
@ -48,15 +48,12 @@ import google.registry.model.reporting.HistoryEntry.Type;
|
|||
import google.registry.testing.AppEngineRule;
|
||||
import org.joda.money.Money;
|
||||
import org.joda.time.DateTime;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
/** Tests for domain lifecycle. */
|
||||
@RunWith(JUnit4.class)
|
||||
public class EppLifecycleDomainTest extends EppTestCase {
|
||||
class EppLifecycleDomainTest extends EppTestCase {
|
||||
|
||||
private static final ImmutableMap<String, String> DEFAULT_TRANSFER_RESPONSE_PARMS =
|
||||
ImmutableMap.of(
|
||||
|
@ -64,17 +61,17 @@ public class EppLifecycleDomainTest extends EppTestCase {
|
|||
"ACDATE", "2002-06-04T00:00:00Z",
|
||||
"EXDATE", "2003-06-01T00:04:00Z");
|
||||
|
||||
@Rule
|
||||
public final AppEngineRule appEngine =
|
||||
@RegisterExtension
|
||||
final AppEngineRule appEngine =
|
||||
AppEngineRule.builder().withDatastoreAndCloudSql().withTaskQueue().build();
|
||||
|
||||
@Before
|
||||
public void initTld() {
|
||||
@BeforeEach
|
||||
void beforeEach() {
|
||||
createTlds("example", "tld");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDomainDeleteRestore() throws Exception {
|
||||
void testDomainDeleteRestore() throws Exception {
|
||||
assertThatLoginSucceeds("NewRegistrar", "foo-BAR2");
|
||||
createContacts(DateTime.parse("2000-06-01T00:00:00Z"));
|
||||
|
||||
|
@ -134,7 +131,7 @@ public class EppLifecycleDomainTest extends EppTestCase {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testDomainDeleteRestore_duringAutorenewGracePeriod() throws Exception {
|
||||
void testDomainDeleteRestore_duringAutorenewGracePeriod() throws Exception {
|
||||
assertThatLoginSucceeds("NewRegistrar", "foo-BAR2");
|
||||
createContacts(DateTime.parse("2000-06-01T00:00:00Z"));
|
||||
|
||||
|
@ -208,7 +205,7 @@ public class EppLifecycleDomainTest extends EppTestCase {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testDomainDeleteRestore_duringRenewalGracePeriod() throws Exception {
|
||||
void testDomainDeleteRestore_duringRenewalGracePeriod() throws Exception {
|
||||
assertThatLoginSucceeds("NewRegistrar", "foo-BAR2");
|
||||
createContacts(DateTime.parse("2000-06-01T00:00:00Z"));
|
||||
|
||||
|
@ -290,8 +287,7 @@ public class EppLifecycleDomainTest extends EppTestCase {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testDomainDelete_duringAddAndRenewalGracePeriod_deletesImmediately()
|
||||
throws Exception {
|
||||
void testDomainDelete_duringAddAndRenewalGracePeriod_deletesImmediately() throws Exception {
|
||||
assertThatLoginSucceeds("NewRegistrar", "foo-BAR2");
|
||||
createContacts(DateTime.parse("2000-06-01T00:00:00Z"));
|
||||
|
||||
|
@ -386,7 +382,7 @@ public class EppLifecycleDomainTest extends EppTestCase {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testDomainDeletion_withinAddGracePeriod_deletesImmediately() throws Exception {
|
||||
void testDomainDeletion_withinAddGracePeriod_deletesImmediately() throws Exception {
|
||||
assertThatLoginSucceeds("NewRegistrar", "foo-BAR2");
|
||||
createContacts(DateTime.parse("2000-06-01T00:00:00Z"));
|
||||
|
||||
|
@ -442,7 +438,7 @@ public class EppLifecycleDomainTest extends EppTestCase {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testDomainDeletion_outsideAddGracePeriod_showsRedemptionPeriod() throws Exception {
|
||||
void testDomainDeletion_outsideAddGracePeriod_showsRedemptionPeriod() throws Exception {
|
||||
assertThatLoginSucceeds("NewRegistrar", "foo-BAR2");
|
||||
createContacts(DateTime.parse("2000-06-01T00:00:00Z"));
|
||||
|
||||
|
@ -504,7 +500,7 @@ public class EppLifecycleDomainTest extends EppTestCase {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testEapDomainDeletion_withinAddGracePeriod_eapFeeIsNotRefunded() throws Exception {
|
||||
void testEapDomainDeletion_withinAddGracePeriod_eapFeeIsNotRefunded() throws Exception {
|
||||
assertThatCommand("login_valid_fee_extension.xml").hasResponse("generic_success_response.xml");
|
||||
createContacts(DateTime.parse("2000-06-01T00:00:00Z"));
|
||||
|
||||
|
@ -569,7 +565,7 @@ public class EppLifecycleDomainTest extends EppTestCase {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testDomainDeletionWithSubordinateHost_fails() throws Exception {
|
||||
void testDomainDeletionWithSubordinateHost_fails() throws Exception {
|
||||
assertThatLoginSucceeds("NewRegistrar", "foo-BAR2");
|
||||
createFakesite();
|
||||
createSubordinateHost();
|
||||
|
@ -582,7 +578,7 @@ public class EppLifecycleDomainTest extends EppTestCase {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testDeletionOfDomain_afterRenameOfSubordinateHost_succeeds() throws Exception {
|
||||
void testDeletionOfDomain_afterRenameOfSubordinateHost_succeeds() throws Exception {
|
||||
assertThatLoginSucceeds("NewRegistrar", "foo-BAR2");
|
||||
assertThat(getRecordedEppMetric())
|
||||
.hasClientId("NewRegistrar")
|
||||
|
@ -637,7 +633,7 @@ public class EppLifecycleDomainTest extends EppTestCase {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testDeletionOfDomain_afterUpdateThatCreatesSubordinateHost_fails() throws Exception {
|
||||
void testDeletionOfDomain_afterUpdateThatCreatesSubordinateHost_fails() throws Exception {
|
||||
assertThatLoginSucceeds("NewRegistrar", "foo-BAR2");
|
||||
createFakesite();
|
||||
|
||||
|
@ -680,7 +676,7 @@ public class EppLifecycleDomainTest extends EppTestCase {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testDomainCreation_failsBeforeSunrise() throws Exception {
|
||||
void testDomainCreation_failsBeforeSunrise() throws Exception {
|
||||
DateTime sunriseDate = DateTime.parse("2000-05-30T00:00:00Z");
|
||||
createTld(
|
||||
"example",
|
||||
|
@ -714,7 +710,7 @@ public class EppLifecycleDomainTest extends EppTestCase {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testDomainCheckFee_succeeds() throws Exception {
|
||||
void testDomainCheckFee_succeeds() throws Exception {
|
||||
DateTime gaDate = DateTime.parse("2000-05-30T00:00:00Z");
|
||||
createTld(
|
||||
"example",
|
||||
|
@ -740,7 +736,7 @@ public class EppLifecycleDomainTest extends EppTestCase {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testDomainCreate_annualAutoRenewPollMessages_haveUniqueIds() throws Exception {
|
||||
void testDomainCreate_annualAutoRenewPollMessages_haveUniqueIds() throws Exception {
|
||||
assertThatLoginSucceeds("NewRegistrar", "foo-BAR2");
|
||||
// Create the domain.
|
||||
createFakesite();
|
||||
|
@ -790,7 +786,7 @@ public class EppLifecycleDomainTest extends EppTestCase {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testDomainTransferPollMessage_serverApproved() throws Exception {
|
||||
void testDomainTransferPollMessage_serverApproved() throws Exception {
|
||||
// As the losing registrar, create the domain.
|
||||
assertThatLoginSucceeds("NewRegistrar", "foo-BAR2");
|
||||
createFakesite();
|
||||
|
@ -839,7 +835,7 @@ public class EppLifecycleDomainTest extends EppTestCase {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testTransfer_autoRenewGraceActive_onlyAtAutomaticTransferTime_getsSubsumed()
|
||||
void testTransfer_autoRenewGraceActive_onlyAtAutomaticTransferTime_getsSubsumed()
|
||||
throws Exception {
|
||||
// Register the domain as the first registrar.
|
||||
assertThatLoginSucceeds("NewRegistrar", "foo-BAR2");
|
||||
|
@ -877,7 +873,7 @@ public class EppLifecycleDomainTest extends EppTestCase {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testNameserversTransferWithDomain_successfully() throws Exception {
|
||||
void testNameserversTransferWithDomain_successfully() throws Exception {
|
||||
// Log in as the first registrar and set up domains with hosts.
|
||||
assertThatLoginSucceeds("NewRegistrar", "foo-BAR2");
|
||||
createFakesite();
|
||||
|
@ -914,7 +910,7 @@ public class EppLifecycleDomainTest extends EppTestCase {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testRenewalFails_whenTotalTermExceeds10Years() throws Exception {
|
||||
void testRenewalFails_whenTotalTermExceeds10Years() throws Exception {
|
||||
assertThatLoginSucceeds("NewRegistrar", "foo-BAR2");
|
||||
// Creates domain with 2 year expiration.
|
||||
createFakesite();
|
||||
|
@ -928,7 +924,7 @@ public class EppLifecycleDomainTest extends EppTestCase {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testDomainDeletionCancelsPendingTransfer() throws Exception {
|
||||
void testDomainDeletionCancelsPendingTransfer() throws Exception {
|
||||
// Register the domain as the first registrar.
|
||||
assertThatLoginSucceeds("NewRegistrar", "foo-BAR2");
|
||||
createFakesite();
|
||||
|
@ -966,7 +962,7 @@ public class EppLifecycleDomainTest extends EppTestCase {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testDomainTransfer_subordinateHost_showsChangeInTransferQuery() throws Exception {
|
||||
void testDomainTransfer_subordinateHost_showsChangeInTransferQuery() throws Exception {
|
||||
assertThatLoginSucceeds("NewRegistrar", "foo-BAR2");
|
||||
createFakesite();
|
||||
createSubordinateHost();
|
||||
|
@ -1002,7 +998,7 @@ public class EppLifecycleDomainTest extends EppTestCase {
|
|||
* superordinate domain, not whatever the transfer time from the second domain is.
|
||||
*/
|
||||
@Test
|
||||
public void testSuccess_lastTransferTime_superordinateDomainTransferFollowedByHostUpdate()
|
||||
void testSuccess_lastTransferTime_superordinateDomainTransferFollowedByHostUpdate()
|
||||
throws Exception {
|
||||
assertThatLoginSucceeds("NewRegistrar", "foo-BAR2");
|
||||
// Create fakesite.example with subordinate host ns3.fakesite.example
|
||||
|
@ -1056,7 +1052,7 @@ public class EppLifecycleDomainTest extends EppTestCase {
|
|||
* to be external, that the host retains the transfer time of the first superordinate domain.
|
||||
*/
|
||||
@Test
|
||||
public void testSuccess_lastTransferTime_superordinateDomainTransferThenHostUpdateToExternal()
|
||||
void testSuccess_lastTransferTime_superordinateDomainTransferThenHostUpdateToExternal()
|
||||
throws Exception {
|
||||
assertThatLoginSucceeds("NewRegistrar", "foo-BAR2");
|
||||
// Create fakesite.example with subordinate host ns3.fakesite.example
|
||||
|
@ -1099,7 +1095,7 @@ public class EppLifecycleDomainTest extends EppTestCase {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_multipartTldsWithSharedSuffixes() throws Exception {
|
||||
void testSuccess_multipartTldsWithSharedSuffixes() throws Exception {
|
||||
createTlds("bar.foo.tld", "foo.tld");
|
||||
|
||||
assertThatLoginSucceeds("NewRegistrar", "foo-BAR2");
|
||||
|
@ -1143,7 +1139,7 @@ public class EppLifecycleDomainTest extends EppTestCase {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_multipartTldsWithSharedPrefixes() throws Exception {
|
||||
void testSuccess_multipartTldsWithSharedPrefixes() throws Exception {
|
||||
createTld("tld.foo");
|
||||
|
||||
assertThatLoginSucceeds("NewRegistrar", "foo-BAR2");
|
||||
|
@ -1177,12 +1173,12 @@ public class EppLifecycleDomainTest extends EppTestCase {
|
|||
/**
|
||||
* Test a full launch of start-date sunrise.
|
||||
*
|
||||
* We show that we can't create during pre-delegation, can only create with an encoded mark during
|
||||
* start-date sunrise - which we can then delete "as normal" (no need for a signed mark or
|
||||
* <p>We show that we can't create during pre-delegation, can only create with an encoded mark
|
||||
* during start-date sunrise - which we can then delete "as normal" (no need for a signed mark or
|
||||
* anything for delete), and then use "regular" create during general-availability.
|
||||
*/
|
||||
@Test
|
||||
public void testDomainCreation_startDateSunriseFull() throws Exception {
|
||||
void testDomainCreation_startDateSunriseFull() throws Exception {
|
||||
// The signed mark is valid between 2013 and 2017
|
||||
DateTime sunriseDate = DateTime.parse("2014-09-08T09:09:09Z");
|
||||
DateTime gaDate = sunriseDate.plusDays(30);
|
||||
|
@ -1278,7 +1274,7 @@ public class EppLifecycleDomainTest extends EppTestCase {
|
|||
|
||||
/** Test that missing type= argument on launch create works in start-date sunrise. */
|
||||
@Test
|
||||
public void testDomainCreation_startDateSunrise_noType() throws Exception {
|
||||
void testDomainCreation_startDateSunrise_noType() throws Exception {
|
||||
// The signed mark is valid between 2013 and 2017
|
||||
DateTime sunriseDate = DateTime.parse("2014-09-08T09:09:09Z");
|
||||
DateTime gaDate = sunriseDate.plusDays(30);
|
||||
|
@ -1327,7 +1323,7 @@ public class EppLifecycleDomainTest extends EppTestCase {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testDomainTransfer_duringAutorenewGrace() throws Exception {
|
||||
void testDomainTransfer_duringAutorenewGrace() throws Exception {
|
||||
// Creation date of fakesite: 2000-06-01T00:04:00.0Z
|
||||
// Expiration date: 2002-06-01T00:04:00.0Z
|
||||
assertThatLoginSucceeds("NewRegistrar", "foo-BAR2");
|
||||
|
@ -1413,7 +1409,7 @@ public class EppLifecycleDomainTest extends EppTestCase {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testDomainTransfer_queryForServerApproved() throws Exception {
|
||||
void testDomainTransfer_queryForServerApproved() throws Exception {
|
||||
// Creation date of fakesite: 2000-06-01T00:04:00.0Z
|
||||
// Expiration date: 2002-06-01T00:04:00.0Z
|
||||
assertThatLoginSucceeds("NewRegistrar", "foo-BAR2");
|
||||
|
|
|
@ -28,21 +28,18 @@ import google.registry.model.domain.DomainBase;
|
|||
import google.registry.model.host.HostResource;
|
||||
import google.registry.testing.AppEngineRule;
|
||||
import org.joda.time.DateTime;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
/** Tests for host lifecycle. */
|
||||
@RunWith(JUnit4.class)
|
||||
public class EppLifecycleHostTest extends EppTestCase {
|
||||
class EppLifecycleHostTest extends EppTestCase {
|
||||
|
||||
@Rule
|
||||
public final AppEngineRule appEngine =
|
||||
@RegisterExtension
|
||||
final AppEngineRule appEngine =
|
||||
AppEngineRule.builder().withDatastoreAndCloudSql().withTaskQueue().build();
|
||||
|
||||
@Test
|
||||
public void testLifecycle() throws Exception {
|
||||
void testLifecycle() throws Exception {
|
||||
assertThatLoginSucceeds("NewRegistrar", "foo-BAR2");
|
||||
assertThatCommand("hello.xml")
|
||||
.atTime("2000-06-02T00:00:00Z")
|
||||
|
@ -90,7 +87,7 @@ public class EppLifecycleHostTest extends EppTestCase {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testRenamingHostToExistingHost_fails() throws Exception {
|
||||
void testRenamingHostToExistingHost_fails() throws Exception {
|
||||
createTld("example");
|
||||
assertThatLoginSucceeds("NewRegistrar", "foo-BAR2");
|
||||
// Create the fakesite domain.
|
||||
|
@ -140,7 +137,7 @@ public class EppLifecycleHostTest extends EppTestCase {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_multipartTldsWithSharedSuffixes() throws Exception {
|
||||
void testSuccess_multipartTldsWithSharedSuffixes() throws Exception {
|
||||
createTlds("bar.foo.tld", "foo.tld", "tld");
|
||||
|
||||
assertThatLoginSucceeds("NewRegistrar", "foo-BAR2");
|
||||
|
|
|
@ -19,21 +19,18 @@ import static google.registry.model.eppoutput.Result.Code.SUCCESS_AND_CLOSE;
|
|||
import static google.registry.testing.EppMetricSubject.assertThat;
|
||||
|
||||
import google.registry.testing.AppEngineRule;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
/** Tests for login lifecycle. */
|
||||
@RunWith(JUnit4.class)
|
||||
public class EppLifecycleLoginTest extends EppTestCase {
|
||||
class EppLifecycleLoginTest extends EppTestCase {
|
||||
|
||||
@Rule
|
||||
public final AppEngineRule appEngine =
|
||||
@RegisterExtension
|
||||
final AppEngineRule appEngine =
|
||||
AppEngineRule.builder().withDatastoreAndCloudSql().withTaskQueue().build();
|
||||
|
||||
@Test
|
||||
public void testLoginAndLogout_recordsEppMetric() throws Exception {
|
||||
void testLoginAndLogout_recordsEppMetric() throws Exception {
|
||||
assertThatLoginSucceeds("NewRegistrar", "foo-BAR2");
|
||||
assertThat(getRecordedEppMetric())
|
||||
.hasClientId("NewRegistrar")
|
||||
|
|
|
@ -20,20 +20,17 @@ import static org.joda.time.format.ISODateTimeFormat.dateTimeNoMillis;
|
|||
import com.google.common.collect.ImmutableMap;
|
||||
import google.registry.testing.AppEngineRule;
|
||||
import org.joda.time.DateTime;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
/** Test flows without login. */
|
||||
@RunWith(JUnit4.class)
|
||||
public class EppLoggedOutTest extends EppTestCase {
|
||||
class EppLoggedOutTest extends EppTestCase {
|
||||
|
||||
@Rule
|
||||
public final AppEngineRule appEngine = AppEngineRule.builder().withDatastoreAndCloudSql().build();
|
||||
@RegisterExtension
|
||||
final AppEngineRule appEngine = AppEngineRule.builder().withDatastoreAndCloudSql().build();
|
||||
|
||||
@Test
|
||||
public void testHello() throws Exception {
|
||||
void testHello() throws Exception {
|
||||
DateTime now = DateTime.now(UTC);
|
||||
assertThatCommand("hello.xml", null)
|
||||
.atTime(now)
|
||||
|
@ -41,7 +38,7 @@ public class EppLoggedOutTest extends EppTestCase {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSyntaxError() throws Exception {
|
||||
void testSyntaxError() throws Exception {
|
||||
assertThatCommand("syntax_error.xml")
|
||||
.hasResponse(
|
||||
"response_error_no_cltrid.xml",
|
||||
|
|
|
@ -23,26 +23,23 @@ import google.registry.testing.AppEngineRule;
|
|||
import google.registry.testing.CertificateSamples;
|
||||
import java.util.Optional;
|
||||
import org.joda.time.DateTime;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
/** Test logging in with TLS credentials. */
|
||||
@RunWith(JUnit4.class)
|
||||
public class EppLoginTlsTest extends EppTestCase {
|
||||
class EppLoginTlsTest extends EppTestCase {
|
||||
|
||||
@Rule
|
||||
public final AppEngineRule appEngine = AppEngineRule.builder().withDatastoreAndCloudSql().build();
|
||||
@RegisterExtension
|
||||
final AppEngineRule appEngine = AppEngineRule.builder().withDatastoreAndCloudSql().build();
|
||||
|
||||
void setClientCertificateHash(String clientCertificateHash) {
|
||||
setTransportCredentials(
|
||||
new TlsCredentials(true, clientCertificateHash, Optional.of("192.168.1.100:54321")));
|
||||
}
|
||||
|
||||
@Before
|
||||
public void initTest() {
|
||||
@BeforeEach
|
||||
void beforeEach() {
|
||||
persistResource(
|
||||
loadRegistrar("NewRegistrar")
|
||||
.asBuilder()
|
||||
|
@ -57,14 +54,14 @@ public class EppLoginTlsTest extends EppTestCase {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testLoginLogout() throws Exception {
|
||||
void testLoginLogout() throws Exception {
|
||||
setClientCertificateHash(CertificateSamples.SAMPLE_CERT_HASH);
|
||||
assertThatLoginSucceeds("NewRegistrar", "foo-BAR2");
|
||||
assertThatLogoutSucceeds();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLogin_wrongPasswordFails() throws Exception {
|
||||
void testLogin_wrongPasswordFails() throws Exception {
|
||||
setClientCertificateHash(CertificateSamples.SAMPLE_CERT_HASH);
|
||||
// For TLS login, we also check the epp xml password.
|
||||
assertThatLogin("NewRegistrar", "incorrect")
|
||||
|
@ -74,7 +71,7 @@ public class EppLoginTlsTest extends EppTestCase {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testMultiLogin() throws Exception {
|
||||
void testMultiLogin() throws Exception {
|
||||
setClientCertificateHash(CertificateSamples.SAMPLE_CERT_HASH);
|
||||
assertThatLoginSucceeds("NewRegistrar", "foo-BAR2");
|
||||
assertThatLogoutSucceeds();
|
||||
|
@ -88,7 +85,7 @@ public class EppLoginTlsTest extends EppTestCase {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testNonAuthedLogin_fails() throws Exception {
|
||||
void testNonAuthedLogin_fails() throws Exception {
|
||||
setClientCertificateHash(CertificateSamples.SAMPLE_CERT_HASH);
|
||||
assertThatLogin("TheRegistrar", "password2")
|
||||
.hasResponse(
|
||||
|
@ -97,9 +94,8 @@ public class EppLoginTlsTest extends EppTestCase {
|
|||
"CODE", "2200", "MSG", "Registrar certificate does not match stored certificate"));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testBadCertificate_failsBadCertificate2200() throws Exception {
|
||||
void testBadCertificate_failsBadCertificate2200() throws Exception {
|
||||
setClientCertificateHash("laffo");
|
||||
assertThatLogin("NewRegistrar", "foo-BAR2")
|
||||
.hasResponse(
|
||||
|
@ -109,7 +105,7 @@ public class EppLoginTlsTest extends EppTestCase {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testGfeDidntProvideClientCertificate_failsMissingCertificate2200() throws Exception {
|
||||
void testGfeDidntProvideClientCertificate_failsMissingCertificate2200() throws Exception {
|
||||
setClientCertificateHash("");
|
||||
assertThatLogin("NewRegistrar", "foo-BAR2")
|
||||
.hasResponse(
|
||||
|
@ -118,7 +114,7 @@ public class EppLoginTlsTest extends EppTestCase {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testGoodPrimaryCertificate() throws Exception {
|
||||
void testGoodPrimaryCertificate() throws Exception {
|
||||
setClientCertificateHash(CertificateSamples.SAMPLE_CERT_HASH);
|
||||
DateTime now = DateTime.now(UTC);
|
||||
persistResource(
|
||||
|
@ -131,7 +127,7 @@ public class EppLoginTlsTest extends EppTestCase {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testGoodFailoverCertificate() throws Exception {
|
||||
void testGoodFailoverCertificate() throws Exception {
|
||||
setClientCertificateHash(CertificateSamples.SAMPLE_CERT2_HASH);
|
||||
DateTime now = DateTime.now(UTC);
|
||||
persistResource(
|
||||
|
@ -144,7 +140,7 @@ public class EppLoginTlsTest extends EppTestCase {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testMissingPrimaryCertificateButHasFailover_usesFailover() throws Exception {
|
||||
void testMissingPrimaryCertificateButHasFailover_usesFailover() throws Exception {
|
||||
setClientCertificateHash(CertificateSamples.SAMPLE_CERT2_HASH);
|
||||
DateTime now = DateTime.now(UTC);
|
||||
persistResource(
|
||||
|
@ -157,7 +153,7 @@ public class EppLoginTlsTest extends EppTestCase {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testRegistrarHasNoCertificatesOnFile_fails() throws Exception {
|
||||
void testRegistrarHasNoCertificatesOnFile_fails() throws Exception {
|
||||
setClientCertificateHash("laffo");
|
||||
DateTime now = DateTime.now(UTC);
|
||||
persistResource(
|
||||
|
|
|
@ -52,16 +52,15 @@ import java.util.Optional;
|
|||
import javax.annotation.Nullable;
|
||||
import org.joda.money.Money;
|
||||
import org.joda.time.DateTime;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
public class EppTestCase {
|
||||
|
||||
private static final MediaType APPLICATION_EPP_XML_UTF8 =
|
||||
MediaType.create("application", "epp+xml").withCharset(UTF_8);
|
||||
|
||||
@Rule
|
||||
public final InjectRule inject = new InjectRule();
|
||||
@RegisterExtension public final InjectRule inject = new InjectRule();
|
||||
|
||||
protected final FakeClock clock = new FakeClock();
|
||||
|
||||
|
@ -70,8 +69,8 @@ public class EppTestCase {
|
|||
private EppMetric.Builder eppMetricBuilder;
|
||||
private boolean isSuperuser;
|
||||
|
||||
@Before
|
||||
public void initTestCase() {
|
||||
@BeforeEach
|
||||
public void beforeEachEppTestCase() {
|
||||
// For transactional flows
|
||||
inject.setStaticField(Ofy.class, "clock", clock);
|
||||
}
|
||||
|
@ -84,7 +83,7 @@ public class EppTestCase {
|
|||
* such as {@link EppLoginUserTest}, {@link EppLoginAdminUserTest} and {@link EppLoginTlsTest}.
|
||||
* Therefore, only those tests should call this method.
|
||||
*/
|
||||
protected void setTransportCredentials(TransportCredentials credentials) {
|
||||
void setTransportCredentials(TransportCredentials credentials) {
|
||||
this.credentials = credentials;
|
||||
}
|
||||
|
||||
|
@ -133,7 +132,7 @@ public class EppTestCase {
|
|||
return new CommandAsserter(inputFilename, inputSubstitutions);
|
||||
}
|
||||
|
||||
protected CommandAsserter assertThatLogin(String clientId, String password) {
|
||||
CommandAsserter assertThatLogin(String clientId, String password) {
|
||||
return assertThatCommand("login.xml", ImmutableMap.of("CLID", clientId, "PW", password));
|
||||
}
|
||||
|
||||
|
@ -202,12 +201,12 @@ public class EppTestCase {
|
|||
return result;
|
||||
}
|
||||
|
||||
protected EppMetric getRecordedEppMetric() {
|
||||
EppMetric getRecordedEppMetric() {
|
||||
return eppMetricBuilder.build();
|
||||
}
|
||||
|
||||
/** Create the two administrative contacts and two hosts. */
|
||||
protected void createContactsAndHosts() throws Exception {
|
||||
void createContactsAndHosts() throws Exception {
|
||||
DateTime createTime = DateTime.parse("2000-06-01T00:00:00Z");
|
||||
createContacts(createTime);
|
||||
assertThatCommand("host_create.xml", ImmutableMap.of("HOSTNAME", "ns1.example.external"))
|
||||
|
@ -239,7 +238,7 @@ public class EppTestCase {
|
|||
}
|
||||
|
||||
/** Creates the domain fakesite.example with two nameservers on it. */
|
||||
protected void createFakesite() throws Exception {
|
||||
void createFakesite() throws Exception {
|
||||
createContactsAndHosts();
|
||||
assertThatCommand("domain_create_fakesite.xml")
|
||||
.atTime("2000-06-01T00:04:00Z")
|
||||
|
@ -255,7 +254,7 @@ public class EppTestCase {
|
|||
}
|
||||
|
||||
/** Creates ns3.fakesite.example as a host, then adds it to fakesite. */
|
||||
protected void createSubordinateHost() throws Exception {
|
||||
void createSubordinateHost() throws Exception {
|
||||
// Add the fakesite nameserver (requires that domain is already created).
|
||||
assertThatCommand("host_create_fakesite.xml")
|
||||
.atTime("2000-06-06T00:01:00Z")
|
||||
|
@ -290,8 +289,7 @@ public class EppTestCase {
|
|||
}
|
||||
|
||||
/** Makes a one-time billing event corresponding to the given domain's renewal. */
|
||||
protected static BillingEvent.OneTime makeOneTimeRenewBillingEvent(
|
||||
DomainBase domain, DateTime renewTime) {
|
||||
static BillingEvent.OneTime makeOneTimeRenewBillingEvent(DomainBase domain, DateTime renewTime) {
|
||||
return new BillingEvent.OneTime.Builder()
|
||||
.setReason(Reason.RENEW)
|
||||
.setTargetId(domain.getDomainName())
|
||||
|
@ -305,14 +303,14 @@ public class EppTestCase {
|
|||
}
|
||||
|
||||
/** Makes a recurring billing event corresponding to the given domain's creation. */
|
||||
protected static BillingEvent.Recurring makeRecurringCreateBillingEvent(
|
||||
static BillingEvent.Recurring makeRecurringCreateBillingEvent(
|
||||
DomainBase domain, DateTime eventTime, DateTime endTime) {
|
||||
return makeRecurringBillingEvent(
|
||||
domain, getOnlyHistoryEntryOfType(domain, Type.DOMAIN_CREATE), eventTime, endTime);
|
||||
}
|
||||
|
||||
/** Makes a recurring billing event corresponding to the given domain's renewal. */
|
||||
protected static BillingEvent.Recurring makeRecurringRenewBillingEvent(
|
||||
static BillingEvent.Recurring makeRecurringRenewBillingEvent(
|
||||
DomainBase domain, DateTime eventTime, DateTime endTime) {
|
||||
return makeRecurringBillingEvent(
|
||||
domain, getOnlyHistoryEntryOfType(domain, Type.DOMAIN_RENEW), eventTime, endTime);
|
||||
|
@ -333,7 +331,7 @@ public class EppTestCase {
|
|||
}
|
||||
|
||||
/** Makes a cancellation billing event cancelling out the given domain create billing event. */
|
||||
protected static BillingEvent.Cancellation makeCancellationBillingEventForCreate(
|
||||
static BillingEvent.Cancellation makeCancellationBillingEventForCreate(
|
||||
DomainBase domain, OneTime billingEventToCancel, DateTime createTime, DateTime deleteTime) {
|
||||
return new BillingEvent.Cancellation.Builder()
|
||||
.setTargetId(domain.getDomainName())
|
||||
|
@ -347,7 +345,7 @@ public class EppTestCase {
|
|||
}
|
||||
|
||||
/** Makes a cancellation billing event cancelling out the given domain renew billing event. */
|
||||
protected static BillingEvent.Cancellation makeCancellationBillingEventForRenew(
|
||||
static BillingEvent.Cancellation makeCancellationBillingEventForRenew(
|
||||
DomainBase domain, OneTime billingEventToCancel, DateTime renewTime, DateTime deleteTime) {
|
||||
return new BillingEvent.Cancellation.Builder()
|
||||
.setTargetId(domain.getDomainName())
|
||||
|
@ -369,7 +367,7 @@ public class EppTestCase {
|
|||
* This is necessary because the ID will be different even though all the rest of the fields are
|
||||
* the same.
|
||||
*/
|
||||
protected static Key<OneTime> findKeyToActualOneTimeBillingEvent(OneTime expectedBillingEvent) {
|
||||
private static Key<OneTime> findKeyToActualOneTimeBillingEvent(OneTime expectedBillingEvent) {
|
||||
Optional<OneTime> actualCreateBillingEvent =
|
||||
ofy()
|
||||
.load()
|
||||
|
|
|
@ -23,19 +23,16 @@ import static org.mockito.Mockito.mock;
|
|||
import static org.mockito.Mockito.verify;
|
||||
|
||||
import google.registry.testing.FakeHttpSession;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
|
||||
/** Tests for {@link EppTlsAction}. */
|
||||
@RunWith(JUnit4.class)
|
||||
public class EppTlsActionTest {
|
||||
class EppTlsActionTest {
|
||||
|
||||
private static final byte[] INPUT_XML_BYTES = "<xml>".getBytes(UTF_8);
|
||||
|
||||
@Test
|
||||
public void testPassesArgumentsThrough() {
|
||||
void testPassesArgumentsThrough() {
|
||||
EppTlsAction action = new EppTlsAction();
|
||||
action.inputXmlBytes = INPUT_XML_BYTES;
|
||||
action.tlsCredentials = mock(TlsCredentials.class);
|
||||
|
|
|
@ -21,14 +21,11 @@ import static org.mockito.Mockito.eq;
|
|||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
|
||||
/** Tests for {@link EppToolAction}. */
|
||||
@RunWith(JUnit4.class)
|
||||
public class EppToolActionTest {
|
||||
class EppToolActionTest {
|
||||
|
||||
private void doTest(boolean isDryRun, boolean isSuperuser) {
|
||||
EppToolAction action = new EppToolAction();
|
||||
|
@ -50,22 +47,22 @@ public class EppToolActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testDryRunAndSuperuser() {
|
||||
void testDryRunAndSuperuser() {
|
||||
doTest(true, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDryRun() {
|
||||
void testDryRun() {
|
||||
doTest(true, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuperuser() {
|
||||
void testSuperuser() {
|
||||
doTest(false, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNeitherDryRunNorSuperuser() {
|
||||
void testNeitherDryRunNorSuperuser() {
|
||||
doTest(false, false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,25 +24,22 @@ import static java.nio.charset.StandardCharsets.UTF_8;
|
|||
import com.google.common.collect.ImmutableMap;
|
||||
import google.registry.testing.EppLoader;
|
||||
import java.util.Base64;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/** Unit tests for {@link EppXmlSanitizer}. */
|
||||
@RunWith(JUnit4.class)
|
||||
public class EppXmlSanitizerTest {
|
||||
class EppXmlSanitizerTest {
|
||||
|
||||
private static final String UTF8_HEADER = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
|
||||
|
||||
@Test
|
||||
public void testSanitize_noSensitiveData_noop() throws Exception {
|
||||
void testSanitize_noSensitiveData_noop() throws Exception {
|
||||
byte[] inputXmlBytes = loadBytes(getClass(), "host_create.xml").read();
|
||||
String expectedXml = UTF8_HEADER + new String(inputXmlBytes, UTF_8);
|
||||
assertXmlEqualsIgnoreHeader(expectedXml, sanitizeEppXml(inputXmlBytes));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSanitize_loginPasswords_sanitized() throws Exception {
|
||||
void testSanitize_loginPasswords_sanitized() throws Exception {
|
||||
String inputXml =
|
||||
new EppLoader(
|
||||
this,
|
||||
|
@ -60,7 +57,7 @@ public class EppXmlSanitizerTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSanitize_loginPasswordTagWrongCase_sanitized() throws Exception {
|
||||
void testSanitize_loginPasswordTagWrongCase_sanitized() throws Exception {
|
||||
String inputXml =
|
||||
new EppLoader(
|
||||
this, "login_wrong_case.xml", ImmutableMap.of("PW", "oldpass", "NEWPW", "newPw"))
|
||||
|
@ -76,7 +73,7 @@ public class EppXmlSanitizerTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSanitize_contactAuthInfo_sanitized() throws Exception {
|
||||
void testSanitize_contactAuthInfo_sanitized() throws Exception {
|
||||
byte[] inputXmlBytes = loadBytes(getClass(), "contact_info.xml").read();
|
||||
String expectedXml =
|
||||
UTF8_HEADER
|
||||
|
@ -85,7 +82,7 @@ public class EppXmlSanitizerTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSanitize_contactCreateResponseAuthInfo_sanitized() throws Exception {
|
||||
void testSanitize_contactCreateResponseAuthInfo_sanitized() throws Exception {
|
||||
byte[] inputXmlBytes = loadBytes(getClass(), "contact_info_from_create_response.xml").read();
|
||||
String expectedXml =
|
||||
UTF8_HEADER
|
||||
|
@ -96,32 +93,32 @@ public class EppXmlSanitizerTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSanitize_emptyElement_transformedToLongForm() throws Exception {
|
||||
void testSanitize_emptyElement_transformedToLongForm() throws Exception {
|
||||
byte[] inputXmlBytes = "<pw/>".getBytes(UTF_8);
|
||||
assertXmlEqualsIgnoreHeader("<pw></pw>", sanitizeEppXml(inputXmlBytes));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSanitize_invalidXML_throws() {
|
||||
void testSanitize_invalidXML_throws() {
|
||||
byte[] inputXmlBytes = "<pw>".getBytes(UTF_8);
|
||||
assertThat(sanitizeEppXml(inputXmlBytes))
|
||||
.isEqualTo(Base64.getMimeEncoder().encodeToString(inputXmlBytes));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSanitize_unicode_hasCorrectCharCount() throws Exception {
|
||||
void testSanitize_unicode_hasCorrectCharCount() throws Exception {
|
||||
byte[] inputXmlBytes = "<pw>\u007F\u4E43x</pw>".getBytes(UTF_8);
|
||||
assertXmlEqualsIgnoreHeader("<pw>C**</pw>", sanitizeEppXml(inputXmlBytes));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSanitize_emptyString_encodedToBase64() {
|
||||
void testSanitize_emptyString_encodedToBase64() {
|
||||
byte[] inputXmlBytes = "".getBytes(UTF_8);
|
||||
assertThat(sanitizeEppXml(inputXmlBytes)).isEqualTo("");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSanitize_utf16_encodingPreserved() {
|
||||
void testSanitize_utf16_encodingPreserved() {
|
||||
// Test data should specify an endian-specific UTF-16 scheme for easy assertion. If 'UTF-16' is
|
||||
// used, the XMLEventReader in sanitizer may resolve it to an endian-specific one.
|
||||
String inputXml = "<?xml version=\"1.0\" encoding=\"UTF-16LE\"?><p>\u03bc</p>\n";
|
||||
|
|
|
@ -16,20 +16,17 @@ package google.registry.flows;
|
|||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import google.registry.testing.AppEngineRule;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
/** Tests for <a href="https://en.wikipedia.org/wiki/XML_external_entity_attack">XXE</a> attacks. */
|
||||
@RunWith(JUnit4.class)
|
||||
public class EppXxeAttackTest extends EppTestCase {
|
||||
class EppXxeAttackTest extends EppTestCase {
|
||||
|
||||
@Rule
|
||||
public final AppEngineRule appEngine = AppEngineRule.builder().withDatastoreAndCloudSql().build();
|
||||
@RegisterExtension
|
||||
final AppEngineRule appEngine = AppEngineRule.builder().withDatastoreAndCloudSql().build();
|
||||
|
||||
@Test
|
||||
public void testRemoteXmlExternalEntity() throws Exception {
|
||||
void testRemoteXmlExternalEntity() throws Exception {
|
||||
assertThatLoginSucceeds("NewRegistrar", "foo-BAR2");
|
||||
assertThatCommand("contact_create_remote_xxe.xml")
|
||||
.hasResponse(
|
||||
|
@ -42,7 +39,7 @@ public class EppXxeAttackTest extends EppTestCase {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testLocalXmlExtrernalEntity() throws Exception {
|
||||
void testLocalXmlExtrernalEntity() throws Exception {
|
||||
assertThatLoginSucceeds("NewRegistrar", "foo-BAR2");
|
||||
assertThatCommand("contact_create_local_xxe.xml")
|
||||
.hasResponse(
|
||||
|
@ -55,7 +52,7 @@ public class EppXxeAttackTest extends EppTestCase {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testBillionLaughsAttack() throws Exception {
|
||||
void testBillionLaughsAttack() throws Exception {
|
||||
assertThatLoginSucceeds("NewRegistrar", "foo-BAR2");
|
||||
assertThatCommand("contact_create_billion_laughs.xml")
|
||||
.hasResponse(
|
||||
|
|
|
@ -38,20 +38,17 @@ import google.registry.model.eppinput.EppInput.CommandExtension;
|
|||
import google.registry.testing.AppEngineRule;
|
||||
import google.registry.util.TypeUtils;
|
||||
import java.util.logging.LogRecord;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
/** Unit tests for {@link ExtensionManager}. */
|
||||
@RunWith(JUnit4.class)
|
||||
public class ExtensionManagerTest {
|
||||
class ExtensionManagerTest {
|
||||
|
||||
@Rule
|
||||
public final AppEngineRule appEngine = AppEngineRule.builder().withDatastoreAndCloudSql().build();
|
||||
@RegisterExtension
|
||||
final AppEngineRule appEngine = AppEngineRule.builder().withDatastoreAndCloudSql().build();
|
||||
|
||||
@Test
|
||||
public void testDuplicateExtensionsForbidden() {
|
||||
void testDuplicateExtensionsForbidden() {
|
||||
ExtensionManager manager =
|
||||
new TestInstanceBuilder()
|
||||
.setEppRequestSource(EppRequestSource.TOOL)
|
||||
|
@ -66,7 +63,7 @@ public class ExtensionManagerTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testUndeclaredExtensionsLogged() throws Exception {
|
||||
void testUndeclaredExtensionsLogged() throws Exception {
|
||||
TestLogHandler handler = new TestLogHandler();
|
||||
LoggerConfig.getConfig(ExtensionManager.class).addHandler(handler);
|
||||
ExtensionManager manager =
|
||||
|
@ -88,7 +85,7 @@ public class ExtensionManagerTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testBlacklistedExtensions_forbiddenWhenUndeclared() {
|
||||
void testBlacklistedExtensions_forbiddenWhenUndeclared() {
|
||||
ExtensionManager manager =
|
||||
new TestInstanceBuilder()
|
||||
.setEppRequestSource(EppRequestSource.TOOL)
|
||||
|
@ -102,7 +99,7 @@ public class ExtensionManagerTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testBlacklistedExtensions_allowedWhenDeclared() throws Exception {
|
||||
void testBlacklistedExtensions_allowedWhenDeclared() throws Exception {
|
||||
ExtensionManager manager =
|
||||
new TestInstanceBuilder()
|
||||
.setEppRequestSource(EppRequestSource.TOOL)
|
||||
|
@ -114,7 +111,7 @@ public class ExtensionManagerTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testMetadataExtension_allowedForToolSource() throws Exception {
|
||||
void testMetadataExtension_allowedForToolSource() throws Exception {
|
||||
ExtensionManager manager =
|
||||
new TestInstanceBuilder()
|
||||
.setEppRequestSource(EppRequestSource.TOOL)
|
||||
|
@ -126,7 +123,7 @@ public class ExtensionManagerTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testMetadataExtension_forbiddenWhenNotToolSource() {
|
||||
void testMetadataExtension_forbiddenWhenNotToolSource() {
|
||||
ExtensionManager manager =
|
||||
new TestInstanceBuilder()
|
||||
.setEppRequestSource(EppRequestSource.CONSOLE)
|
||||
|
@ -139,7 +136,7 @@ public class ExtensionManagerTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuperuserExtension_allowedForToolSource() throws Exception {
|
||||
void testSuperuserExtension_allowedForToolSource() throws Exception {
|
||||
ExtensionManager manager =
|
||||
new TestInstanceBuilder()
|
||||
.setEppRequestSource(EppRequestSource.TOOL)
|
||||
|
@ -152,7 +149,7 @@ public class ExtensionManagerTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuperuserExtension_forbiddenWhenNotSuperuser() {
|
||||
void testSuperuserExtension_forbiddenWhenNotSuperuser() {
|
||||
ExtensionManager manager =
|
||||
new TestInstanceBuilder()
|
||||
.setEppRequestSource(EppRequestSource.TOOL)
|
||||
|
@ -167,7 +164,7 @@ public class ExtensionManagerTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuperuserExtension_forbiddenWhenNotToolSource() {
|
||||
void testSuperuserExtension_forbiddenWhenNotToolSource() {
|
||||
ExtensionManager manager =
|
||||
new TestInstanceBuilder()
|
||||
.setEppRequestSource(EppRequestSource.CONSOLE)
|
||||
|
@ -182,7 +179,7 @@ public class ExtensionManagerTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testUnimplementedExtensionsForbidden() {
|
||||
void testUnimplementedExtensionsForbidden() {
|
||||
ExtensionManager manager =
|
||||
new TestInstanceBuilder()
|
||||
.setEppRequestSource(EppRequestSource.TOOL)
|
||||
|
|
|
@ -32,14 +32,11 @@ import google.registry.model.reporting.IcannReportingTypes.ActivityReportField;
|
|||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import org.json.simple.JSONValue;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/** Unit tests for {@link FlowReporter}. */
|
||||
@RunWith(JUnit4.class)
|
||||
public class FlowReporterTest {
|
||||
class FlowReporterTest {
|
||||
|
||||
static class TestCommandFlow implements Flow {
|
||||
@Override
|
||||
|
@ -59,8 +56,8 @@ public class FlowReporterTest {
|
|||
private final FlowReporter flowReporter = new FlowReporter();
|
||||
private final TestLogHandler handler = new TestLogHandler();
|
||||
|
||||
@Before
|
||||
public void before() {
|
||||
@BeforeEach
|
||||
void beforeEach() {
|
||||
LoggerConfig.getConfig(FlowReporter.class).addHandler(handler);
|
||||
flowReporter.trid = Trid.create("client-123", "server-456");
|
||||
flowReporter.clientId = "TheRegistrar";
|
||||
|
@ -74,7 +71,7 @@ public class FlowReporterTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testRecordToLogs_metadata_basic() throws Exception {
|
||||
void testRecordToLogs_metadata_basic() throws Exception {
|
||||
when(flowReporter.eppInput.isDomainType()).thenReturn(true);
|
||||
when(flowReporter.eppInput.getResourceType()).thenReturn(Optional.of("domain"));
|
||||
flowReporter.recordToLogs();
|
||||
|
@ -93,7 +90,7 @@ public class FlowReporterTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testRecordToLogs_metadata_withReportingSpec() throws Exception {
|
||||
void testRecordToLogs_metadata_withReportingSpec() throws Exception {
|
||||
flowReporter.flowClass = TestReportingSpecCommandFlow.class;
|
||||
flowReporter.recordToLogs();
|
||||
Map<String, Object> json =
|
||||
|
@ -103,7 +100,7 @@ public class FlowReporterTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testRecordToLogs_metadata_noClientId() throws Exception {
|
||||
void testRecordToLogs_metadata_noClientId() throws Exception {
|
||||
flowReporter.clientId = "";
|
||||
flowReporter.recordToLogs();
|
||||
Map<String, Object> json =
|
||||
|
@ -112,7 +109,7 @@ public class FlowReporterTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testRecordToLogs_metadata_notResourceFlow_noResourceTypeOrTld() throws Exception {
|
||||
void testRecordToLogs_metadata_notResourceFlow_noResourceTypeOrTld() throws Exception {
|
||||
when(flowReporter.eppInput.isDomainType()).thenReturn(false);
|
||||
when(flowReporter.eppInput.getResourceType()).thenReturn(Optional.empty());
|
||||
flowReporter.recordToLogs();
|
||||
|
@ -123,9 +120,8 @@ public class FlowReporterTest {
|
|||
assertThat(json).containsEntry("tlds", ImmutableList.of());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testRecordToLogs_metadata_notDomainFlow_noTld() throws Exception {
|
||||
void testRecordToLogs_metadata_notDomainFlow_noTld() throws Exception {
|
||||
when(flowReporter.eppInput.isDomainType()).thenReturn(false);
|
||||
when(flowReporter.eppInput.getResourceType()).thenReturn(Optional.of("contact"));
|
||||
flowReporter.recordToLogs();
|
||||
|
@ -137,7 +133,7 @@ public class FlowReporterTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testRecordToLogs_metadata_multipartDomainName_multipartTld() throws Exception {
|
||||
void testRecordToLogs_metadata_multipartDomainName_multipartTld() throws Exception {
|
||||
when(flowReporter.eppInput.isDomainType()).thenReturn(true);
|
||||
when(flowReporter.eppInput.getResourceType()).thenReturn(Optional.of("domain"));
|
||||
when(flowReporter.eppInput.getSingleTargetId()).thenReturn(Optional.of("target.co.uk"));
|
||||
|
@ -152,7 +148,7 @@ public class FlowReporterTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testRecordToLogs_metadata_multipleTargetIds_uniqueTldSet() throws Exception {
|
||||
void testRecordToLogs_metadata_multipleTargetIds_uniqueTldSet() throws Exception {
|
||||
when(flowReporter.eppInput.isDomainType()).thenReturn(true);
|
||||
when(flowReporter.eppInput.getSingleTargetId()).thenReturn(Optional.empty());
|
||||
when(flowReporter.eppInput.getTargetIds())
|
||||
|
@ -168,7 +164,7 @@ public class FlowReporterTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testRecordToLogs_metadata_uppercaseDomainName_lowercaseTld() throws Exception {
|
||||
void testRecordToLogs_metadata_uppercaseDomainName_lowercaseTld() throws Exception {
|
||||
when(flowReporter.eppInput.isDomainType()).thenReturn(true);
|
||||
when(flowReporter.eppInput.getSingleTargetId()).thenReturn(Optional.of("TARGET.FOO"));
|
||||
when(flowReporter.eppInput.getTargetIds()).thenReturn(ImmutableList.of("TARGET.FOO"));
|
||||
|
@ -182,7 +178,7 @@ public class FlowReporterTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testRecordToLogs_metadata_invalidDomainName_stillGuessesTld() throws Exception {
|
||||
void testRecordToLogs_metadata_invalidDomainName_stillGuessesTld() throws Exception {
|
||||
when(flowReporter.eppInput.isDomainType()).thenReturn(true);
|
||||
when(flowReporter.eppInput.getSingleTargetId()).thenReturn(Optional.of("<foo@bar.com>"));
|
||||
when(flowReporter.eppInput.getTargetIds()).thenReturn(ImmutableList.of("<foo@bar.com>"));
|
||||
|
@ -196,7 +192,7 @@ public class FlowReporterTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testRecordToLogs_metadata_domainWithoutPeriod_noTld() throws Exception {
|
||||
void testRecordToLogs_metadata_domainWithoutPeriod_noTld() throws Exception {
|
||||
when(flowReporter.eppInput.isDomainType()).thenReturn(true);
|
||||
when(flowReporter.eppInput.getSingleTargetId()).thenReturn(Optional.of("target,foo"));
|
||||
when(flowReporter.eppInput.getTargetIds()).thenReturn(ImmutableList.of("target,foo"));
|
||||
|
|
|
@ -38,19 +38,15 @@ import google.registry.testing.FakeClock;
|
|||
import google.registry.testing.FakeHttpSession;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
/** Unit tests for {@link FlowRunner}. */
|
||||
@RunWith(JUnit4.class)
|
||||
public class FlowRunnerTest {
|
||||
class FlowRunnerTest {
|
||||
|
||||
@Rule
|
||||
public final AppEngineRule appEngineRule = new AppEngineRule.Builder().build();
|
||||
@RegisterExtension final AppEngineRule appEngineRule = new AppEngineRule.Builder().build();
|
||||
|
||||
private final FlowRunner flowRunner = new FlowRunner();
|
||||
private final EppMetric.Builder eppMetricBuilder = EppMetric.builderForRequest(new FakeClock());
|
||||
|
@ -64,8 +60,8 @@ public class FlowRunnerTest {
|
|||
}
|
||||
}
|
||||
|
||||
@Before
|
||||
public void before() {
|
||||
@BeforeEach
|
||||
void beforeEach() {
|
||||
LoggerConfig.getConfig(FlowRunner.class).addHandler(handler);
|
||||
flowRunner.clientId = "TheRegistrar";
|
||||
flowRunner.credentials = new PasswordOnlyTransportCredentials();
|
||||
|
@ -83,33 +79,33 @@ public class FlowRunnerTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testRun_nonTransactionalCommand_setsCommandNameOnMetric() throws Exception {
|
||||
void testRun_nonTransactionalCommand_setsCommandNameOnMetric() throws Exception {
|
||||
flowRunner.isTransactional = true;
|
||||
flowRunner.run(eppMetricBuilder);
|
||||
assertThat(eppMetricBuilder.build().getCommandName()).hasValue("TestCommand");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRun_transactionalCommand_setsCommandNameOnMetric() throws Exception {
|
||||
void testRun_transactionalCommand_setsCommandNameOnMetric() throws Exception {
|
||||
flowRunner.run(eppMetricBuilder);
|
||||
assertThat(eppMetricBuilder.build().getCommandName()).hasValue("TestCommand");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRun_callsFlowReporterOnce() throws Exception {
|
||||
void testRun_callsFlowReporterOnce() throws Exception {
|
||||
flowRunner.run(eppMetricBuilder);
|
||||
verify(flowRunner.flowReporter).recordToLogs();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRun_dryRun_doesNotCallFlowReporter() throws Exception {
|
||||
void testRun_dryRun_doesNotCallFlowReporter() throws Exception {
|
||||
flowRunner.isDryRun = true;
|
||||
flowRunner.run(eppMetricBuilder);
|
||||
verify(flowRunner.flowReporter, never()).recordToLogs();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRun_loggingStatement_basic() throws Exception {
|
||||
void testRun_loggingStatement_basic() throws Exception {
|
||||
flowRunner.run(eppMetricBuilder);
|
||||
assertThat(Splitter.on("\n\t").split(findFirstLogMessageByPrefix(handler, "EPP Command\n\t")))
|
||||
.containsExactly(
|
||||
|
@ -128,7 +124,7 @@ public class FlowRunnerTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testRun_loggingStatement_httpSessionMetadata() throws Exception {
|
||||
void testRun_loggingStatement_httpSessionMetadata() throws Exception {
|
||||
flowRunner.sessionMetadata = new HttpSessionMetadata(new FakeHttpSession());
|
||||
flowRunner.sessionMetadata.setClientId("TheRegistrar");
|
||||
flowRunner.run(eppMetricBuilder);
|
||||
|
@ -139,7 +135,7 @@ public class FlowRunnerTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testRun_loggingStatement_tlsCredentials() throws Exception {
|
||||
void testRun_loggingStatement_tlsCredentials() throws Exception {
|
||||
flowRunner.credentials = new TlsCredentials(true, "abc123def", Optional.of("127.0.0.1"));
|
||||
flowRunner.run(eppMetricBuilder);
|
||||
assertThat(Splitter.on("\n\t").split(findFirstLogMessageByPrefix(handler, "EPP Command\n\t")))
|
||||
|
@ -147,7 +143,7 @@ public class FlowRunnerTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testRun_loggingStatement_dryRun() throws Exception {
|
||||
void testRun_loggingStatement_dryRun() throws Exception {
|
||||
flowRunner.isDryRun = true;
|
||||
flowRunner.run(eppMetricBuilder);
|
||||
assertThat(Splitter.on("\n\t").split(findFirstLogMessageByPrefix(handler, "EPP Command\n\t")))
|
||||
|
@ -155,7 +151,7 @@ public class FlowRunnerTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testRun_loggingStatement_superuser() throws Exception {
|
||||
void testRun_loggingStatement_superuser() throws Exception {
|
||||
flowRunner.isSuperuser = true;
|
||||
flowRunner.run(eppMetricBuilder);
|
||||
assertThat(Splitter.on("\n\t").split(findFirstLogMessageByPrefix(handler, "EPP Command\n\t")))
|
||||
|
@ -163,7 +159,7 @@ public class FlowRunnerTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testRun_loggingStatement_complexEppInput() throws Exception {
|
||||
void testRun_loggingStatement_complexEppInput() throws Exception {
|
||||
String domainCreateXml = loadFile(getClass(), "domain_create_prettyprinted.xml");
|
||||
String sanitizedDomainCreateXml = domainCreateXml.replace("2fooBAR", "*******");
|
||||
flowRunner.inputXmlBytes = domainCreateXml.getBytes(UTF_8);
|
||||
|
|
|
@ -73,16 +73,22 @@ import org.junit.jupiter.api.extension.RegisterExtension;
|
|||
public abstract class FlowTestCase<F extends Flow> {
|
||||
|
||||
/** Whether to actually write to Datastore or just simulate. */
|
||||
public enum CommitMode { LIVE, DRY_RUN }
|
||||
public enum CommitMode {
|
||||
LIVE,
|
||||
DRY_RUN
|
||||
}
|
||||
|
||||
/** Whether to run in normal or superuser mode. */
|
||||
public enum UserPrivileges { NORMAL, SUPERUSER }
|
||||
public enum UserPrivileges {
|
||||
NORMAL,
|
||||
SUPERUSER
|
||||
}
|
||||
|
||||
@RegisterExtension
|
||||
public final AppEngineRule appEngine =
|
||||
final AppEngineRule appEngine =
|
||||
AppEngineRule.builder().withDatastoreAndCloudSql().withTaskQueue().build();
|
||||
|
||||
@RegisterExtension public final InjectRule inject = new InjectRule();
|
||||
@RegisterExtension final InjectRule inject = new InjectRule();
|
||||
|
||||
protected EppLoader eppLoader;
|
||||
protected SessionMetadata sessionMetadata;
|
||||
|
@ -94,7 +100,7 @@ public abstract class FlowTestCase<F extends Flow> {
|
|||
private EppMetric.Builder eppMetricBuilder;
|
||||
|
||||
@BeforeEach
|
||||
public void init() {
|
||||
public void beforeEachFlowTestCase() {
|
||||
sessionMetadata = new HttpSessionMetadata(new FakeHttpSession());
|
||||
sessionMetadata.setClientId("TheRegistrar");
|
||||
sessionMetadata.setServiceExtensionUris(ProtocolDefinition.getVisibleServiceExtensionUris());
|
||||
|
|
|
@ -26,7 +26,7 @@ import google.registry.model.eppoutput.CheckData;
|
|||
* @param <F> the flow type
|
||||
* @param <R> the resource type
|
||||
*/
|
||||
public class ResourceCheckFlowTestCase<F extends Flow, R extends EppResource>
|
||||
public abstract class ResourceCheckFlowTestCase<F extends Flow, R extends EppResource>
|
||||
extends ResourceFlowTestCase<F, R> {
|
||||
|
||||
protected void doCheckTest(CheckData.Check... expected) throws Exception {
|
||||
|
|
|
@ -28,27 +28,24 @@ import google.registry.testing.AppEngineRule;
|
|||
import java.util.Optional;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import org.joda.time.DateTime;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
/** Unit tests for {@link TlsCredentials}. */
|
||||
@RunWith(JUnit4.class)
|
||||
public final class TlsCredentialsTest {
|
||||
final class TlsCredentialsTest {
|
||||
|
||||
@Rule
|
||||
public final AppEngineRule appEngine = AppEngineRule.builder().withDatastoreAndCloudSql().build();
|
||||
@RegisterExtension
|
||||
final AppEngineRule appEngine = AppEngineRule.builder().withDatastoreAndCloudSql().build();
|
||||
|
||||
@Test
|
||||
public void testProvideClientCertificateHash() {
|
||||
void testProvideClientCertificateHash() {
|
||||
HttpServletRequest req = mock(HttpServletRequest.class);
|
||||
when(req.getHeader("X-SSL-Certificate")).thenReturn("data");
|
||||
assertThat(TlsCredentials.EppTlsModule.provideClientCertificateHash(req)).isEqualTo("data");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProvideClientCertificateHash_missing() {
|
||||
void testProvideClientCertificateHash_missing() {
|
||||
HttpServletRequest req = mock(HttpServletRequest.class);
|
||||
BadRequestException thrown =
|
||||
assertThrows(
|
||||
|
@ -58,7 +55,7 @@ public final class TlsCredentialsTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void test_validateCertificate_canBeConfiguredToBypassCertHashes() throws Exception {
|
||||
void test_validateCertificate_canBeConfiguredToBypassCertHashes() throws Exception {
|
||||
TlsCredentials tls = new TlsCredentials(false, "certHash", Optional.of("192.168.1.1"));
|
||||
persistResource(
|
||||
loadRegistrar("TheRegistrar")
|
||||
|
|
|
@ -36,8 +36,8 @@ import org.junit.jupiter.api.BeforeEach;
|
|||
* @param <F> the flow type
|
||||
* @param <R> the resource type
|
||||
*/
|
||||
public class ContactTransferFlowTestCase<F extends Flow, R extends EppResource>
|
||||
extends ResourceFlowTestCase<F, R>{
|
||||
abstract class ContactTransferFlowTestCase<F extends Flow, R extends EppResource>
|
||||
extends ResourceFlowTestCase<F, R> {
|
||||
|
||||
// Transfer is requested on the 6th and expires on the 11th.
|
||||
// The "now" of this flow is on the 9th, 3 days in.
|
||||
|
@ -55,7 +55,7 @@ public class ContactTransferFlowTestCase<F extends Flow, R extends EppResource>
|
|||
}
|
||||
|
||||
@BeforeEach
|
||||
void initContactTest() {
|
||||
void beforeEachContactTransferFlowTestCase() {
|
||||
// Registrar ClientZ is used in tests that need another registrar that definitely doesn't own
|
||||
// the resources in question.
|
||||
persistResource(
|
||||
|
|
|
@ -54,8 +54,8 @@ import org.junit.jupiter.api.BeforeEach;
|
|||
* @param <F> the flow type
|
||||
* @param <R> the resource type
|
||||
*/
|
||||
public class DomainTransferFlowTestCase<F extends Flow, R extends EppResource>
|
||||
extends ResourceFlowTestCase<F, R>{
|
||||
abstract class DomainTransferFlowTestCase<F extends Flow, R extends EppResource>
|
||||
extends ResourceFlowTestCase<F, R> {
|
||||
|
||||
// Transfer is requested on the 6th and expires on the 11th.
|
||||
// The "now" of this flow is on the 9th, 3 days in.
|
||||
|
@ -81,7 +81,7 @@ public class DomainTransferFlowTestCase<F extends Flow, R extends EppResource>
|
|||
}
|
||||
|
||||
@BeforeEach
|
||||
void makeClientZ() {
|
||||
void beforeEachDomainTransferFlowTestCase() {
|
||||
// Registrar ClientZ is used in tests that need another registrar that definitely doesn't own
|
||||
// the resources in question.
|
||||
persistResource(
|
||||
|
|
|
@ -49,29 +49,26 @@ import google.registry.model.registry.Registry;
|
|||
import google.registry.model.reporting.HistoryEntry;
|
||||
import google.registry.testing.AppEngineRule;
|
||||
import org.joda.time.DateTime;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
/** Unit tests for {@link AllocationTokenFlowUtils}. */
|
||||
@RunWith(JUnit4.class)
|
||||
public class AllocationTokenFlowUtilsTest {
|
||||
class AllocationTokenFlowUtilsTest {
|
||||
|
||||
private final AllocationTokenFlowUtils flowUtils =
|
||||
new AllocationTokenFlowUtils(new AllocationTokenCustomLogic());
|
||||
|
||||
@Rule
|
||||
public final AppEngineRule appEngine = AppEngineRule.builder().withDatastoreAndCloudSql().build();
|
||||
@RegisterExtension
|
||||
final AppEngineRule appEngine = AppEngineRule.builder().withDatastoreAndCloudSql().build();
|
||||
|
||||
@Before
|
||||
public void initTest() {
|
||||
@BeforeEach
|
||||
void beforeEach() {
|
||||
createTld("tld");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_validateToken_successfullyVerifiesValidToken() throws Exception {
|
||||
void test_validateToken_successfullyVerifiesValidToken() throws Exception {
|
||||
AllocationToken token =
|
||||
persistResource(
|
||||
new AllocationToken.Builder().setToken("tokeN").setTokenType(SINGLE_USE).build());
|
||||
|
@ -86,12 +83,12 @@ public class AllocationTokenFlowUtilsTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void test_validateToken_failsOnNonexistentToken() {
|
||||
void test_validateToken_failsOnNonexistentToken() {
|
||||
assertValidateThrowsEppException(InvalidAllocationTokenException.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_validateToken_failsOnNullToken() {
|
||||
void test_validateToken_failsOnNullToken() {
|
||||
assertAboutEppExceptions()
|
||||
.that(
|
||||
assertThrows(
|
||||
|
@ -107,7 +104,7 @@ public class AllocationTokenFlowUtilsTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void test_validateToken_callsCustomLogic() {
|
||||
void test_validateToken_callsCustomLogic() {
|
||||
AllocationTokenFlowUtils failingFlowUtils =
|
||||
new AllocationTokenFlowUtils(new FailingAllocationTokenCustomLogic());
|
||||
persistResource(
|
||||
|
@ -126,7 +123,7 @@ public class AllocationTokenFlowUtilsTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void test_validateToken_invalidForClientId() {
|
||||
void test_validateToken_invalidForClientId() {
|
||||
persistResource(
|
||||
createOneMonthPromoTokenBuilder(DateTime.now(UTC).minusDays(1))
|
||||
.setAllowedClientIds(ImmutableSet.of("NewRegistrar"))
|
||||
|
@ -135,7 +132,7 @@ public class AllocationTokenFlowUtilsTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void test_validateToken_invalidForTld() {
|
||||
void test_validateToken_invalidForTld() {
|
||||
persistResource(
|
||||
createOneMonthPromoTokenBuilder(DateTime.now(UTC).minusDays(1))
|
||||
.setAllowedTlds(ImmutableSet.of("nottld"))
|
||||
|
@ -144,19 +141,19 @@ public class AllocationTokenFlowUtilsTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void test_validateToken_beforePromoStart() {
|
||||
void test_validateToken_beforePromoStart() {
|
||||
persistResource(createOneMonthPromoTokenBuilder(DateTime.now(UTC).plusDays(1)).build());
|
||||
assertValidateThrowsEppException(AllocationTokenNotInPromotionException.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_validateToken_afterPromoEnd() {
|
||||
void test_validateToken_afterPromoEnd() {
|
||||
persistResource(createOneMonthPromoTokenBuilder(DateTime.now(UTC).minusMonths(2)).build());
|
||||
assertValidateThrowsEppException(AllocationTokenNotInPromotionException.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_validateToken_promoCancelled() {
|
||||
void test_validateToken_promoCancelled() {
|
||||
// the promo would be valid but it was cancelled 12 hours ago
|
||||
persistResource(
|
||||
createOneMonthPromoTokenBuilder(DateTime.now(UTC).minusDays(1))
|
||||
|
@ -171,7 +168,7 @@ public class AllocationTokenFlowUtilsTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void test_checkDomainsWithToken_successfullyVerifiesValidToken() {
|
||||
void test_checkDomainsWithToken_successfullyVerifiesValidToken() {
|
||||
persistResource(
|
||||
new AllocationToken.Builder().setToken("tokeN").setTokenType(SINGLE_USE).build());
|
||||
assertThat(
|
||||
|
@ -190,7 +187,7 @@ public class AllocationTokenFlowUtilsTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void test_checkDomainsWithToken_showsFailureMessageForRedeemedToken() {
|
||||
void test_checkDomainsWithToken_showsFailureMessageForRedeemedToken() {
|
||||
persistResource(
|
||||
new AllocationToken.Builder()
|
||||
.setToken("tokeN")
|
||||
|
@ -216,7 +213,7 @@ public class AllocationTokenFlowUtilsTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void test_checkDomainsWithToken_callsCustomLogic() {
|
||||
void test_checkDomainsWithToken_callsCustomLogic() {
|
||||
persistResource(
|
||||
new AllocationToken.Builder().setToken("tokeN").setTokenType(SINGLE_USE).build());
|
||||
AllocationTokenFlowUtils failingFlowUtils =
|
||||
|
@ -235,7 +232,7 @@ public class AllocationTokenFlowUtilsTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void test_checkDomainsWithToken_resultsFromCustomLogicAreIntegrated() {
|
||||
void test_checkDomainsWithToken_resultsFromCustomLogicAreIntegrated() {
|
||||
persistResource(
|
||||
new AllocationToken.Builder().setToken("tokeN").setTokenType(SINGLE_USE).build());
|
||||
AllocationTokenFlowUtils customResultFlowUtils =
|
||||
|
|
|
@ -26,70 +26,66 @@ import google.registry.flows.host.HostFlowUtils.HostNameTooLongException;
|
|||
import google.registry.flows.host.HostFlowUtils.HostNameTooShallowException;
|
||||
import google.registry.flows.host.HostFlowUtils.InvalidHostNameException;
|
||||
import google.registry.testing.AppEngineRule;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
/** Unit tests for {@link HostFlowUtils}. */
|
||||
@RunWith(JUnit4.class)
|
||||
public class HostFlowUtilsTest {
|
||||
class HostFlowUtilsTest {
|
||||
|
||||
@Rule
|
||||
public final AppEngineRule appEngine = AppEngineRule.builder().withDatastoreAndCloudSql().build();
|
||||
@RegisterExtension
|
||||
final AppEngineRule appEngine = AppEngineRule.builder().withDatastoreAndCloudSql().build();
|
||||
|
||||
@Test
|
||||
public void test_validExternalHostName_validates() throws Exception {
|
||||
void test_validExternalHostName_validates() throws Exception {
|
||||
assertThat(validateHostName("host.example.com").toString()).isEqualTo("host.example.com");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_validExternalHostNameOnRegistrySuffixList_validates() throws Exception {
|
||||
void test_validExternalHostNameOnRegistrySuffixList_validates() throws Exception {
|
||||
assertThat(validateHostName("host.blogspot.com").toString()).isEqualTo("host.blogspot.com");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_validExternalHostNameOnRegistrySuffixList_multipartTLD_validates()
|
||||
throws Exception {
|
||||
void test_validExternalHostNameOnRegistrySuffixList_multipartTLD_validates() throws Exception {
|
||||
assertThat(validateHostName("ns1.host.co.uk").toString()).isEqualTo("ns1.host.co.uk");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_validExternalHostNameOnRegistrySuffixList_multipartTLD_tooShallow() {
|
||||
void test_validExternalHostNameOnRegistrySuffixList_multipartTLD_tooShallow() {
|
||||
assertThrows(
|
||||
HostNameTooShallowException.class, () -> validateHostName("host.co.uk").toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_validateHostName_hostNameTooLong() {
|
||||
void test_validateHostName_hostNameTooLong() {
|
||||
assertThrows(
|
||||
HostNameTooLongException.class,
|
||||
() -> validateHostName(Strings.repeat("na", 200) + ".wat.man"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_validateHostName_hostNameNotLowerCase() {
|
||||
void test_validateHostName_hostNameNotLowerCase() {
|
||||
assertThrows(HostNameNotLowerCaseException.class, () -> validateHostName("NA.CAPS.TLD"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_validateHostName_hostNameNotPunyCoded() {
|
||||
void test_validateHostName_hostNameNotPunyCoded() {
|
||||
assertThrows(
|
||||
HostNameNotPunyCodedException.class, () -> validateHostName("motörhead.death.metal"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_validateHostName_hostNameNotNormalized() {
|
||||
void test_validateHostName_hostNameNotNormalized() {
|
||||
assertThrows(HostNameNotNormalizedException.class, () -> validateHostName("root.node.yeah."));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_validateHostName_hostNameHasLeadingHyphen() {
|
||||
void test_validateHostName_hostNameHasLeadingHyphen() {
|
||||
assertThrows(InvalidHostNameException.class, () -> validateHostName("-giga.mega.tld"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_validateHostName_hostNameTooShallow() {
|
||||
void test_validateHostName_hostNameTooShallow() {
|
||||
assertThrows(HostNameTooShallowException.class, () -> validateHostName("domain.tld"));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ public abstract class LoginFlowTestCase extends FlowTestCase<LoginFlow> {
|
|||
private Registrar.Builder registrarBuilder;
|
||||
|
||||
@BeforeEach
|
||||
void initRegistrar() {
|
||||
void beforeEachLoginFlowTestCase() {
|
||||
sessionMetadata.setClientId(null); // Don't implicitly log in (all other flows need to).
|
||||
registrar = loadRegistrar("NewRegistrar");
|
||||
registrarBuilder = registrar.asBuilder();
|
||||
|
|
|
@ -32,27 +32,24 @@ import google.registry.util.Clock;
|
|||
import java.util.List;
|
||||
import org.joda.money.Money;
|
||||
import org.joda.time.DateTime;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
/** Tests for tools that affect EPP lifecycle. */
|
||||
@RunWith(JUnit4.class)
|
||||
public class EppLifecycleToolsTest extends EppTestCase {
|
||||
class EppLifecycleToolsTest extends EppTestCase {
|
||||
|
||||
@Rule
|
||||
public final AppEngineRule appEngine =
|
||||
@RegisterExtension
|
||||
final AppEngineRule appEngine =
|
||||
AppEngineRule.builder().withDatastoreAndCloudSql().withTaskQueue().build();
|
||||
|
||||
@Before
|
||||
public void initTld() {
|
||||
@BeforeEach
|
||||
void beforeEach() {
|
||||
createTlds("example", "tld");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_renewDomainThenUnrenew() throws Exception {
|
||||
void test_renewDomainThenUnrenew() throws Exception {
|
||||
assertThatLoginSucceeds("NewRegistrar", "foo-BAR2");
|
||||
createContacts(DateTime.parse("2000-06-01T00:00:00Z"));
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue