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