Re-add EppException marshalling assertions in application flow tests

Apologies for the reformatting, but this refactoring is quite rote and it's
definitely a bigger use of total time to perform the reformatting individually
than to simply do it file-wide.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=179221800
This commit is contained in:
mcilwain 2017-12-15 11:53:12 -08:00 committed by Ben McIlwain
parent da08baab92
commit 5e4a6b0235
4 changed files with 773 additions and 509 deletions

View file

@ -26,13 +26,14 @@ import static google.registry.testing.DatastoreHelper.newHostResource;
import static google.registry.testing.DatastoreHelper.persistActiveContact;
import static google.registry.testing.DatastoreHelper.persistActiveDomainApplication;
import static google.registry.testing.DatastoreHelper.persistResource;
import static google.registry.testing.JUnitBackports.assertThrows;
import static google.registry.testing.EppExceptionSubject.assertAboutEppExceptions;
import static google.registry.testing.JUnitBackports.expectThrows;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.googlecode.objectify.Key;
import google.registry.flows.EppException;
import google.registry.flows.EppException.UnimplementedExtensionException;
import google.registry.flows.ResourceFlowTestCase;
import google.registry.flows.ResourceFlowUtils.ResourceDoesNotExistException;
@ -77,8 +78,7 @@ public class DomainApplicationDeleteFlowTest
@Test
public void testDryRun() throws Exception {
persistResource(
newDomainApplication("example.tld").asBuilder().setRepoId("1-TLD").build());
persistResource(newDomainApplication("example.tld").asBuilder().setRepoId("1-TLD").build());
dryRunFlowAssertResponse(loadFile("domain_delete_response.xml"));
}
@ -88,38 +88,45 @@ public class DomainApplicationDeleteFlowTest
persistActiveContact("sh8013");
persistResource(newHostResource("ns1.example.net"));
// Create the DomainApplication to test.
persistResource(newDomainApplication("example.tld").asBuilder()
.setRepoId("1-TLD")
.setRegistrant(
Key.create(
loadByForeignKey(ContactResource.class, "sh8013", clock.nowUtc())))
.setNameservers(ImmutableSet.of(
Key.create(
loadByForeignKey(HostResource.class, "ns1.example.net", clock.nowUtc()))))
.build());
persistResource(
newDomainApplication("example.tld")
.asBuilder()
.setRepoId("1-TLD")
.setRegistrant(
Key.create(loadByForeignKey(ContactResource.class, "sh8013", clock.nowUtc())))
.setNameservers(
ImmutableSet.of(
Key.create(
loadByForeignKey(HostResource.class, "ns1.example.net", clock.nowUtc()))))
.build());
doSuccessfulTest();
for (Key<? extends EppResource> key : ImmutableList.of(
loadAndGetKey(ContactResource.class, "sh8013", clock.nowUtc()),
loadAndGetKey(HostResource.class, "ns1.example.net", clock.nowUtc()))) {
for (Key<? extends EppResource> key :
ImmutableList.of(
loadAndGetKey(ContactResource.class, "sh8013", clock.nowUtc()),
loadAndGetKey(HostResource.class, "ns1.example.net", clock.nowUtc()))) {
assertThat(isLinked(key, clock.nowUtc())).isFalse();
}
}
@Test
public void testSuccess_clientDeleteProhibited() throws Exception {
persistResource(newDomainApplication("example.tld").asBuilder()
.setRepoId("1-TLD")
.addStatusValue(StatusValue.CLIENT_DELETE_PROHIBITED)
.build());
persistResource(
newDomainApplication("example.tld")
.asBuilder()
.setRepoId("1-TLD")
.addStatusValue(StatusValue.CLIENT_DELETE_PROHIBITED)
.build());
doSuccessfulTest();
}
@Test
public void testSuccess_serverDeleteProhibited() throws Exception {
persistResource(newDomainApplication("example.tld").asBuilder()
.setRepoId("1-TLD")
.addStatusValue(StatusValue.SERVER_DELETE_PROHIBITED)
.build());
persistResource(
newDomainApplication("example.tld")
.asBuilder()
.setRepoId("1-TLD")
.addStatusValue(StatusValue.SERVER_DELETE_PROHIBITED)
.build());
doSuccessfulTest();
}
@ -132,10 +139,12 @@ public class DomainApplicationDeleteFlowTest
@Test
public void testFailure_existedButWasDeleted() throws Exception {
persistResource(newDomainApplication("example.tld").asBuilder()
.setRepoId("1-TLD")
.setDeletionTime(clock.nowUtc().minusSeconds(1))
.build());
persistResource(
newDomainApplication("example.tld")
.asBuilder()
.setRepoId("1-TLD")
.setDeletionTime(clock.nowUtc().minusSeconds(1))
.build());
ResourceDoesNotExistException thrown =
expectThrows(ResourceDoesNotExistException.class, this::runFlow);
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
@ -144,16 +153,15 @@ public class DomainApplicationDeleteFlowTest
@Test
public void testFailure_unauthorizedClient() throws Exception {
sessionMetadata.setClientId("NewRegistrar");
persistResource(
newDomainApplication("example.tld").asBuilder().setRepoId("1-TLD").build());
assertThrows(ResourceNotOwnedException.class, this::runFlow);
persistResource(newDomainApplication("example.tld").asBuilder().setRepoId("1-TLD").build());
EppException thrown = expectThrows(ResourceNotOwnedException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml();
}
@Test
public void testSuccess_superuserUnauthorizedClient() throws Exception {
sessionMetadata.setClientId("NewRegistrar");
persistResource(
newDomainApplication("example.tld").asBuilder().setRepoId("1-TLD").build());
persistResource(newDomainApplication("example.tld").asBuilder().setRepoId("1-TLD").build());
clock.advanceOneMilli();
runFlowAssertResponse(
CommitMode.LIVE, UserPrivileges.SUPERUSER, loadFile("domain_delete_response.xml"));
@ -164,9 +172,10 @@ public class DomainApplicationDeleteFlowTest
persistResource(newDomainApplication("example.tld").asBuilder().setRepoId("1-TLD").build());
persistResource(
loadRegistrar("TheRegistrar").asBuilder().setAllowedTlds(ImmutableSet.of()).build());
assertThrows(NotAuthorizedForTldException.class, this::runFlow);
EppException thrown = expectThrows(NotAuthorizedForTldException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml();
}
@Test
public void testSuccess_superuserNotAuthorizedForTld() throws Exception {
persistResource(newDomainApplication("example.tld").asBuilder().setRepoId("1-TLD").build());
@ -181,23 +190,27 @@ public class DomainApplicationDeleteFlowTest
public void testFailure_sunriseDuringLandrush() throws Exception {
createTld("tld", TldState.LANDRUSH);
setEppInput("domain_delete_application_landrush.xml", ImmutableMap.of("DOMAIN", "example.tld"));
persistResource(newDomainApplication("example.tld")
.asBuilder()
.setRepoId("1-TLD")
.setPhase(LaunchPhase.SUNRISE)
.build());
assertThrows(SunriseApplicationCannotBeDeletedInLandrushException.class, this::runFlow);
persistResource(
newDomainApplication("example.tld")
.asBuilder()
.setRepoId("1-TLD")
.setPhase(LaunchPhase.SUNRISE)
.build());
EppException thrown =
expectThrows(SunriseApplicationCannotBeDeletedInLandrushException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml();
}
@Test
public void testSuccess_superuserSunriseDuringLandrush() throws Exception {
createTld("tld", TldState.LANDRUSH);
setEppInput("domain_delete_application_landrush.xml", ImmutableMap.of("DOMAIN", "example.tld"));
persistResource(newDomainApplication("example.tld")
.asBuilder()
.setRepoId("1-TLD")
.setPhase(LaunchPhase.SUNRISE)
.build());
persistResource(
newDomainApplication("example.tld")
.asBuilder()
.setRepoId("1-TLD")
.setPhase(LaunchPhase.SUNRISE)
.build());
clock.advanceOneMilli();
runFlowAssertResponse(
CommitMode.LIVE, UserPrivileges.SUPERUSER, loadFile("domain_delete_response.xml"));
@ -207,11 +220,12 @@ public class DomainApplicationDeleteFlowTest
public void testSuccess_sunrushDuringLandrush() throws Exception {
createTld("tld", TldState.LANDRUSH);
setEppInput("domain_delete_application_landrush.xml", ImmutableMap.of("DOMAIN", "example.tld"));
persistResource(newDomainApplication("example.tld")
.asBuilder()
.setRepoId("1-TLD")
.setPhase(LaunchPhase.SUNRUSH)
.build());
persistResource(
newDomainApplication("example.tld")
.asBuilder()
.setRepoId("1-TLD")
.setPhase(LaunchPhase.SUNRUSH)
.build());
doSuccessfulTest();
}
@ -219,58 +233,59 @@ public class DomainApplicationDeleteFlowTest
public void testSuccess_sunriseDuringSunrush() throws Exception {
createTld("tld", TldState.SUNRUSH);
setEppInput("domain_delete_application_sunrush.xml");
persistResource(newDomainApplication("example.tld")
.asBuilder()
.setRepoId("1-TLD")
.setPhase(LaunchPhase.SUNRISE)
.build());
persistResource(
newDomainApplication("example.tld")
.asBuilder()
.setRepoId("1-TLD")
.setPhase(LaunchPhase.SUNRISE)
.build());
doSuccessfulTest();
}
@Test
public void testFailure_mismatchedPhase() throws Exception {
setEppInput("domain_delete_application_landrush.xml", ImmutableMap.of("DOMAIN", "example.tld"));
persistResource(
newDomainApplication("example.tld").asBuilder().setRepoId("1-TLD").build());
assertThrows(LaunchPhaseMismatchException.class, this::runFlow);
persistResource(newDomainApplication("example.tld").asBuilder().setRepoId("1-TLD").build());
EppException thrown = expectThrows(LaunchPhaseMismatchException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml();
}
@Test
public void testFailure_wrongExtension() throws Exception {
setEppInput("domain_delete_application_wrong_extension.xml");
persistActiveDomainApplication("example.tld");
assertThrows(UnimplementedExtensionException.class, this::runFlow);
EppException thrown = expectThrows(UnimplementedExtensionException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml();
}
@Test
public void testFailure_predelegation() throws Exception {
createTld("tld", TldState.PREDELEGATION);
persistResource(
newDomainApplication("example.tld").asBuilder().setRepoId("1-TLD").build());
assertThrows(BadCommandForRegistryPhaseException.class, this::runFlow);
persistResource(newDomainApplication("example.tld").asBuilder().setRepoId("1-TLD").build());
EppException thrown = expectThrows(BadCommandForRegistryPhaseException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml();
}
@Test
public void testFailure_quietPeriod() throws Exception {
createTld("tld", TldState.QUIET_PERIOD);
persistResource(
newDomainApplication("example.tld").asBuilder().setRepoId("1-TLD").build());
assertThrows(BadCommandForRegistryPhaseException.class, this::runFlow);
persistResource(newDomainApplication("example.tld").asBuilder().setRepoId("1-TLD").build());
EppException thrown = expectThrows(BadCommandForRegistryPhaseException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml();
}
@Test
public void testFailure_generalAvailability() throws Exception {
createTld("tld", TldState.GENERAL_AVAILABILITY);
persistResource(
newDomainApplication("example.tld").asBuilder().setRepoId("1-TLD").build());
assertThrows(BadCommandForRegistryPhaseException.class, this::runFlow);
persistResource(newDomainApplication("example.tld").asBuilder().setRepoId("1-TLD").build());
EppException thrown = expectThrows(BadCommandForRegistryPhaseException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml();
}
@Test
public void testSuccess_superuserQuietPeriod() throws Exception {
createTld("tld", TldState.QUIET_PERIOD);
persistResource(
newDomainApplication("example.tld").asBuilder().setRepoId("1-TLD").build());
persistResource(newDomainApplication("example.tld").asBuilder().setRepoId("1-TLD").build());
clock.advanceOneMilli();
runFlowAssertResponse(
CommitMode.LIVE, UserPrivileges.SUPERUSER, loadFile("domain_delete_response.xml"));
@ -279,8 +294,7 @@ public class DomainApplicationDeleteFlowTest
@Test
public void testSuccess_superuserPredelegation() throws Exception {
createTld("tld", TldState.PREDELEGATION);
persistResource(
newDomainApplication("example.tld").asBuilder().setRepoId("1-TLD").build());
persistResource(newDomainApplication("example.tld").asBuilder().setRepoId("1-TLD").build());
clock.advanceOneMilli();
runFlowAssertResponse(
CommitMode.LIVE, UserPrivileges.SUPERUSER, loadFile("domain_delete_response.xml"));
@ -289,8 +303,7 @@ public class DomainApplicationDeleteFlowTest
@Test
public void testSuccess_superuserGeneralAvailability() throws Exception {
createTld("tld", TldState.GENERAL_AVAILABILITY);
persistResource(
newDomainApplication("example.tld").asBuilder().setRepoId("1-TLD").build());
persistResource(newDomainApplication("example.tld").asBuilder().setRepoId("1-TLD").build());
clock.advanceOneMilli();
runFlowAssertResponse(
CommitMode.LIVE, UserPrivileges.SUPERUSER, loadFile("domain_delete_response.xml"));
@ -298,15 +311,14 @@ public class DomainApplicationDeleteFlowTest
@Test
public void testFailure_applicationIdForDifferentDomain() throws Exception {
persistResource(
newDomainApplication("invalid.tld").asBuilder().setRepoId("1-TLD").build());
assertThrows(ApplicationDomainNameMismatchException.class, this::runFlow);
persistResource(newDomainApplication("invalid.tld").asBuilder().setRepoId("1-TLD").build());
EppException thrown = expectThrows(ApplicationDomainNameMismatchException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml();
}
@Test
public void testIcannActivityReportField_getsLogged() throws Exception {
persistResource(
newDomainApplication("example.tld").asBuilder().setRepoId("1-TLD").build());
persistResource(newDomainApplication("example.tld").asBuilder().setRepoId("1-TLD").build());
clock.advanceOneMilli();
runFlow();
assertIcannReportingActivityFieldLogged("srs-dom-delete");

View file

@ -22,7 +22,7 @@ import static google.registry.testing.DatastoreHelper.createTld;
import static google.registry.testing.DatastoreHelper.persistActiveContact;
import static google.registry.testing.DatastoreHelper.persistActiveHost;
import static google.registry.testing.DatastoreHelper.persistResource;
import static google.registry.testing.JUnitBackports.assertThrows;
import static google.registry.testing.EppExceptionSubject.assertAboutEppExceptions;
import static google.registry.testing.JUnitBackports.expectThrows;
import com.google.common.base.Predicates;
@ -30,6 +30,7 @@ import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.googlecode.objectify.Key;
import google.registry.flows.EppException;
import google.registry.flows.ResourceFlowTestCase;
import google.registry.flows.ResourceFlowUtils.ResourceDoesNotExistException;
import google.registry.flows.ResourceFlowUtils.ResourceNotOwnedException;
@ -67,8 +68,15 @@ public class DomainApplicationInfoFlowTest
private HostResource host2;
private DomainApplication application;
private enum MarksState { MARKS_EXIST, NO_MARKS_EXIST }
private enum HostsState { HOSTS_EXIST, NO_HOSTS_EXIST }
private enum MarksState {
MARKS_EXIST,
NO_MARKS_EXIST
}
private enum HostsState {
HOSTS_EXIST,
NO_HOSTS_EXIST
}
@Before
public void resetClientId() {
@ -82,33 +90,42 @@ public class DomainApplicationInfoFlowTest
contact = persistActiveContact("sh8013");
host1 = persistActiveHost("ns1.example.net");
host2 = persistActiveHost("ns1.example.tld");
application = persistResource(new DomainApplication.Builder()
.setRepoId("123-TLD")
.setFullyQualifiedDomainName("example.tld")
.setPhase(LaunchPhase.SUNRUSH)
.setPersistedCurrentSponsorClientId("NewRegistrar")
.setCreationClientId("TheRegistrar")
.setLastEppUpdateClientId("NewRegistrar")
.setCreationTimeForTest(DateTime.parse("1999-04-03T22:00:00.0Z"))
.setLastEppUpdateTime(DateTime.parse("1999-12-03T09:00:00.0Z"))
.setRegistrant(Key.create(registrant))
.setContacts(ImmutableSet.of(
DesignatedContact.create(Type.ADMIN, Key.create(contact)),
DesignatedContact.create(Type.TECH, Key.create(contact))))
.setNameservers(hostsState.equals(HostsState.HOSTS_EXIST) ? ImmutableSet.of(
Key.create(host1), Key.create(host2)) : null)
.setAuthInfo(DomainAuthInfo.create(PasswordAuth.create("2fooBAR")))
.addStatusValue(StatusValue.PENDING_CREATE)
.setApplicationStatus(ApplicationStatus.PENDING_VALIDATION)
.setEncodedSignedMarks(marksState.equals(MarksState.MARKS_EXIST)
// If we need to include an encoded signed mark, pull it out of the create xml.
? ImmutableList.of((EncodedSignedMark)
new EppLoader(this, "domain_create_sunrise_encoded_signed_mark.xml")
.getEpp()
.getSingleExtension(LaunchCreateExtension.class)
.getSignedMarks().get(0))
: null)
.build());
application =
persistResource(
new DomainApplication.Builder()
.setRepoId("123-TLD")
.setFullyQualifiedDomainName("example.tld")
.setPhase(LaunchPhase.SUNRUSH)
.setPersistedCurrentSponsorClientId("NewRegistrar")
.setCreationClientId("TheRegistrar")
.setLastEppUpdateClientId("NewRegistrar")
.setCreationTimeForTest(DateTime.parse("1999-04-03T22:00:00.0Z"))
.setLastEppUpdateTime(DateTime.parse("1999-12-03T09:00:00.0Z"))
.setRegistrant(Key.create(registrant))
.setContacts(
ImmutableSet.of(
DesignatedContact.create(Type.ADMIN, Key.create(contact)),
DesignatedContact.create(Type.TECH, Key.create(contact))))
.setNameservers(
hostsState.equals(HostsState.HOSTS_EXIST)
? ImmutableSet.of(Key.create(host1), Key.create(host2))
: null)
.setAuthInfo(DomainAuthInfo.create(PasswordAuth.create("2fooBAR")))
.addStatusValue(StatusValue.PENDING_CREATE)
.setApplicationStatus(ApplicationStatus.PENDING_VALIDATION)
.setEncodedSignedMarks(
marksState.equals(MarksState.MARKS_EXIST)
// If we need to include an encoded signed mark, pull it out of the create
// xml.
? ImmutableList.of(
(EncodedSignedMark)
new EppLoader(this, "domain_create_sunrise_encoded_signed_mark.xml")
.getEpp()
.getSingleExtension(LaunchCreateExtension.class)
.getSignedMarks()
.get(0))
: null)
.build());
}
private void doSuccessfulTest(String expectedXmlFilename, HostsState hostsState)
@ -241,12 +258,15 @@ public class DomainApplicationInfoFlowTest
public void testSuccess_secDns() throws Exception {
persistTestEntities(HostsState.NO_HOSTS_EXIST, MarksState.NO_MARKS_EXIST);
// Add the dsData to the saved resource and change the nameservers to match the sample xml.
persistResource(application.asBuilder()
.setDsData(ImmutableSet.of(DelegationSignerData.create(
12345, 3, 1, base16().decode("49FD46E6C4B45C55D4AC"))))
.setNameservers(ImmutableSet.of(
Key.create(host1), Key.create(host2)))
.build());
persistResource(
application
.asBuilder()
.setDsData(
ImmutableSet.of(
DelegationSignerData.create(
12345, 3, 1, base16().decode("49FD46E6C4B45C55D4AC"))))
.setNameservers(ImmutableSet.of(Key.create(host1), Key.create(host2)))
.build());
doSuccessfulTest("domain_info_sunrise_response_dsdata.xml", HostsState.NO_HOSTS_EXIST);
}
@ -254,10 +274,12 @@ public class DomainApplicationInfoFlowTest
public void testSuccess_allocated() throws Exception {
persistTestEntities(HostsState.HOSTS_EXIST, MarksState.NO_MARKS_EXIST);
// Update the application status of the saved resource.
persistResource(application.asBuilder()
.removeStatusValue(StatusValue.PENDING_CREATE)
.setApplicationStatus(ApplicationStatus.ALLOCATED)
.build());
persistResource(
application
.asBuilder()
.removeStatusValue(StatusValue.PENDING_CREATE)
.setApplicationStatus(ApplicationStatus.ALLOCATED)
.build());
doSuccessfulTest("domain_info_sunrise_allocated.xml", HostsState.HOSTS_EXIST);
}
@ -270,12 +292,13 @@ public class DomainApplicationInfoFlowTest
@Test
public void testFailure_existedButWasDeleted() throws Exception {
persistResource(new DomainApplication.Builder()
.setRepoId("123-COM")
.setFullyQualifiedDomainName("timber.com")
.setDeletionTime(clock.nowUtc().minusDays(1))
.setRegistrant(Key.create(persistActiveContact("jd1234")))
.build());
persistResource(
new DomainApplication.Builder()
.setRepoId("123-COM")
.setFullyQualifiedDomainName("timber.com")
.setDeletionTime(clock.nowUtc().minusDays(1))
.setRegistrant(Key.create(persistActiveContact("jd1234")))
.build());
ResourceDoesNotExistException thrown =
expectThrows(ResourceDoesNotExistException.class, this::runFlow);
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
@ -283,37 +306,41 @@ public class DomainApplicationInfoFlowTest
@Test
public void testFailure_unauthorized() throws Exception {
persistResource(
AppEngineRule.makeRegistrar1().asBuilder().setClientId("ClientZ").build());
persistResource(AppEngineRule.makeRegistrar1().asBuilder().setClientId("ClientZ").build());
sessionMetadata.setClientId("ClientZ");
persistTestEntities(HostsState.NO_HOSTS_EXIST, MarksState.NO_MARKS_EXIST);
assertThrows(ResourceNotOwnedException.class, this::runFlow);
EppException thrown = expectThrows(ResourceNotOwnedException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml();
}
@Test
public void testFailure_applicationIdForDifferentDomain() throws Exception {
persistResource(new DomainApplication.Builder()
.setRepoId("123-TLD")
.setFullyQualifiedDomainName("invalid.tld")
.setRegistrant(Key.create(persistActiveContact("jd1234")))
.setPhase(LaunchPhase.SUNRUSH)
.build());
assertThrows(ApplicationDomainNameMismatchException.class, this::runFlow);
persistResource(
new DomainApplication.Builder()
.setRepoId("123-TLD")
.setFullyQualifiedDomainName("invalid.tld")
.setRegistrant(Key.create(persistActiveContact("jd1234")))
.setPhase(LaunchPhase.SUNRUSH)
.build());
EppException thrown = expectThrows(ApplicationDomainNameMismatchException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml();
}
@Test
public void testFailure_noApplicationId() throws Exception {
setEppInput("domain_info_sunrise_no_application_id.xml");
persistTestEntities(HostsState.NO_HOSTS_EXIST, MarksState.NO_MARKS_EXIST);
assertThrows(MissingApplicationIdException.class, this::runFlow);
EppException thrown = expectThrows(MissingApplicationIdException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml();
}
@Test
public void testFailure_mismatchedLaunchPhase() throws Exception {
persistTestEntities(HostsState.NO_HOSTS_EXIST, MarksState.NO_MARKS_EXIST);
application = persistResource(
application.asBuilder().setPhase(LaunchPhase.SUNRISE).build());
assertThrows(ApplicationLaunchPhaseMismatchException.class, this::runFlow);
application = persistResource(application.asBuilder().setPhase(LaunchPhase.SUNRISE).build());
EppException thrown =
expectThrows(ApplicationLaunchPhaseMismatchException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml();
}
/** Test that we load contacts and hosts as a batch rather than individually. */

View file

@ -28,13 +28,14 @@ import static google.registry.testing.DatastoreHelper.persistActiveHost;
import static google.registry.testing.DatastoreHelper.persistReservedList;
import static google.registry.testing.DatastoreHelper.persistResource;
import static google.registry.testing.DomainApplicationSubject.assertAboutApplications;
import static google.registry.testing.JUnitBackports.assertThrows;
import static google.registry.testing.EppExceptionSubject.assertAboutEppExceptions;
import static google.registry.testing.JUnitBackports.expectThrows;
import static google.registry.util.DateTimeUtils.START_OF_TIME;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.googlecode.objectify.Key;
import google.registry.flows.EppException;
import google.registry.flows.EppException.UnimplementedExtensionException;
import google.registry.flows.ResourceFlowTestCase;
import google.registry.flows.ResourceFlowUtils.AddRemoveSameValueException;
@ -83,7 +84,7 @@ public class DomainApplicationUpdateFlowTest
extends ResourceFlowTestCase<DomainApplicationUpdateFlow, DomainApplication> {
private static final DelegationSignerData SOME_DSDATA =
DelegationSignerData.create(1, 2, 3, new byte[]{0, 1, 2});
DelegationSignerData.create(1, 2, 3, new byte[] {0, 1, 2});
ContactResource sh8013Contact;
ContactResource mak21Contact;
@ -111,13 +112,17 @@ public class DomainApplicationUpdateFlowTest
}
private DomainApplication persistApplication() throws Exception {
return persistResource(newApplicationBuilder()
.setContacts(ImmutableSet.of(
DesignatedContact.create(Type.TECH, Key.create(sh8013Contact)),
DesignatedContact.create(Type.ADMIN, Key.create(unusedContact))))
.setNameservers(ImmutableSet.of(Key.create(
loadByForeignKey(HostResource.class, "ns1.example.tld", clock.nowUtc()))))
.build());
return persistResource(
newApplicationBuilder()
.setContacts(
ImmutableSet.of(
DesignatedContact.create(Type.TECH, Key.create(sh8013Contact)),
DesignatedContact.create(Type.ADMIN, Key.create(unusedContact))))
.setNameservers(
ImmutableSet.of(
Key.create(
loadByForeignKey(HostResource.class, "ns1.example.tld", clock.nowUtc()))))
.build());
}
private Builder newApplicationBuilder() throws Exception {
@ -134,8 +139,10 @@ public class DomainApplicationUpdateFlowTest
runFlowAssertResponse(loadFile("domain_update_response.xml"));
// Check that the application was updated. These values came from the xml.
DomainApplication application = reloadDomainApplication();
assertAboutApplications().that(application)
.hasStatusValue(StatusValue.CLIENT_HOLD).and()
assertAboutApplications()
.that(application)
.hasStatusValue(StatusValue.CLIENT_HOLD)
.and()
.hasOnlyOneHistoryEntryWhich()
.hasType(HistoryEntry.Type.DOMAIN_APPLICATION_UPDATE);
assertThat(application.getAuthInfo().getPw().getValue()).isEqualTo("2BARfoo");
@ -178,8 +185,7 @@ public class DomainApplicationUpdateFlowTest
setEppInput("domain_update_sunrise_registrant_to_tech.xml");
persistReferencedEntities();
ContactResource sh8013 = loadByForeignKey(ContactResource.class, "sh8013", clock.nowUtc());
persistResource(
newApplicationBuilder().setRegistrant(Key.create(sh8013)).build());
persistResource(newApplicationBuilder().setRegistrant(Key.create(sh8013)).build());
clock.advanceOneMilli();
runFlowAssertResponse(loadFile("domain_update_response.xml"));
}
@ -190,13 +196,15 @@ public class DomainApplicationUpdateFlowTest
persistReferencedEntities();
ContactResource sh8013 = loadByForeignKey(ContactResource.class, "sh8013", clock.nowUtc());
Key<ContactResource> sh8013Key = Key.create(sh8013);
persistResource(newApplicationBuilder()
.setRegistrant(sh8013Key)
.setContacts(ImmutableSet.of(
DesignatedContact.create(Type.ADMIN, sh8013Key),
DesignatedContact.create(Type.BILLING, sh8013Key),
DesignatedContact.create(Type.TECH, sh8013Key)))
.build());
persistResource(
newApplicationBuilder()
.setRegistrant(sh8013Key)
.setContacts(
ImmutableSet.of(
DesignatedContact.create(Type.ADMIN, sh8013Key),
DesignatedContact.create(Type.BILLING, sh8013Key),
DesignatedContact.create(Type.TECH, sh8013Key)))
.build());
clock.advanceOneMilli();
runFlowAssertResponse(loadFile("domain_update_response.xml"));
}
@ -204,11 +212,15 @@ public class DomainApplicationUpdateFlowTest
@Test
public void testSuccess_removeClientUpdateProhibited() throws Exception {
persistReferencedEntities();
persistResource(persistApplication().asBuilder().setStatusValues(
ImmutableSet.of(StatusValue.CLIENT_UPDATE_PROHIBITED)).build());
persistResource(
persistApplication()
.asBuilder()
.setStatusValues(ImmutableSet.of(StatusValue.CLIENT_UPDATE_PROHIBITED))
.build());
clock.advanceOneMilli();
runFlow();
assertAboutApplications().that(reloadDomainApplication())
assertAboutApplications()
.that(reloadDomainApplication())
.doesNotHaveStatusValue(StatusValue.CLIENT_UPDATE_PROHIBITED);
}
@ -222,8 +234,10 @@ public class DomainApplicationUpdateFlowTest
assertTransactionalFlow(true);
clock.advanceOneMilli();
runFlowAssertResponse(loadFile("domain_update_response.xml"));
assertAboutApplications().that(reloadDomainApplication())
.hasExactlyDsData(expectedDsData).and()
assertAboutApplications()
.that(reloadDomainApplication())
.hasExactlyDsData(expectedDsData)
.and()
.hasOnlyOneHistoryEntryWhich()
.hasType(HistoryEntry.Type.DOMAIN_APPLICATION_UPDATE);
}
@ -233,25 +247,25 @@ public class DomainApplicationUpdateFlowTest
doSecDnsSuccessfulTest(
"domain_update_sunrise_dsdata_add.xml",
null,
ImmutableSet.of(DelegationSignerData.create(
12346, 3, 1, base16().decode("38EC35D5B3A34B44C39B"))));
ImmutableSet.of(
DelegationSignerData.create(12346, 3, 1, base16().decode("38EC35D5B3A34B44C39B"))));
}
@Test
public void testSuccess_secDnsAddPreservesExisting() throws Exception {
doSecDnsSuccessfulTest(
"domain_update_sunrise_dsdata_add.xml",
ImmutableSet.of(SOME_DSDATA),
ImmutableSet.of(SOME_DSDATA, DelegationSignerData.create(
12346, 3, 1, base16().decode("38EC35D5B3A34B44C39B"))));
ImmutableSet.of(
SOME_DSDATA,
DelegationSignerData.create(12346, 3, 1, base16().decode("38EC35D5B3A34B44C39B"))));
}
@Test
public void testSuccess_secDnsAddToMaxRecords() throws Exception {
ImmutableSet.Builder<DelegationSignerData> builder = new ImmutableSet.Builder<>();
for (int i = 0; i < 7; ++i) {
builder.add(DelegationSignerData.create(i, 2, 3, new byte[]{0, 1, 2}));
builder.add(DelegationSignerData.create(i, 2, 3, new byte[] {0, 1, 2}));
}
ImmutableSet<DelegationSignerData> commonDsData = builder.build();
@ -259,16 +273,20 @@ public class DomainApplicationUpdateFlowTest
"domain_update_sunrise_dsdata_add.xml",
commonDsData,
ImmutableSet.copyOf(
union(commonDsData, ImmutableSet.of(DelegationSignerData.create(
12346, 3, 1, base16().decode("38EC35D5B3A34B44C39B"))))));
union(
commonDsData,
ImmutableSet.of(
DelegationSignerData.create(
12346, 3, 1, base16().decode("38EC35D5B3A34B44C39B"))))));
}
@Test
public void testSuccess_secDnsRemove() throws Exception {
doSecDnsSuccessfulTest(
"domain_update_sunrise_dsdata_rem.xml",
ImmutableSet.of(SOME_DSDATA, DelegationSignerData.create(
12346, 3, 1, base16().decode("38EC35D5B3A34B44C39B"))),
ImmutableSet.of(
SOME_DSDATA,
DelegationSignerData.create(12346, 3, 1, base16().decode("38EC35D5B3A34B44C39B"))),
ImmutableSet.of(SOME_DSDATA));
}
@ -277,8 +295,9 @@ public class DomainApplicationUpdateFlowTest
// As an aside, this test also validates that it's ok to set the 'urgent' attribute to false.
doSecDnsSuccessfulTest(
"domain_update_sunrise_dsdata_rem_all.xml",
ImmutableSet.of(SOME_DSDATA, DelegationSignerData.create(
12346, 3, 1, base16().decode("38EC35D5B3A34B44C39B"))),
ImmutableSet.of(
SOME_DSDATA,
DelegationSignerData.create(12346, 3, 1, base16().decode("38EC35D5B3A34B44C39B"))),
ImmutableSet.of());
}
@ -286,28 +305,36 @@ public class DomainApplicationUpdateFlowTest
public void testSuccess_secDnsAddRemove() throws Exception {
doSecDnsSuccessfulTest(
"domain_update_sunrise_dsdata_add_rem.xml",
ImmutableSet.of(SOME_DSDATA, DelegationSignerData.create(
12345, 3, 1, base16().decode("38EC35D5B3A34B33C99B"))),
ImmutableSet.of(SOME_DSDATA, DelegationSignerData.create(
12346, 3, 1, base16().decode("38EC35D5B3A34B44C39B"))));
ImmutableSet.of(
SOME_DSDATA,
DelegationSignerData.create(12345, 3, 1, base16().decode("38EC35D5B3A34B33C99B"))),
ImmutableSet.of(
SOME_DSDATA,
DelegationSignerData.create(12346, 3, 1, base16().decode("38EC35D5B3A34B44C39B"))));
}
@Test
public void testSuccess_secDnsAddRemoveToMaxRecords() throws Exception {
ImmutableSet.Builder<DelegationSignerData> builder = new ImmutableSet.Builder<>();
for (int i = 0; i < 7; ++i) {
builder.add(DelegationSignerData.create(i, 2, 3, new byte[]{0, 1, 2}));
builder.add(DelegationSignerData.create(i, 2, 3, new byte[] {0, 1, 2}));
}
ImmutableSet<DelegationSignerData> commonDsData = builder.build();
doSecDnsSuccessfulTest(
"domain_update_sunrise_dsdata_add_rem.xml",
ImmutableSet.copyOf(
union(commonDsData, ImmutableSet.of(DelegationSignerData.create(
12345, 3, 1, base16().decode("38EC35D5B3A34B33C99B"))))),
union(
commonDsData,
ImmutableSet.of(
DelegationSignerData.create(
12345, 3, 1, base16().decode("38EC35D5B3A34B33C99B"))))),
ImmutableSet.copyOf(
union(commonDsData, ImmutableSet.of(DelegationSignerData.create(
12346, 3, 1, base16().decode("38EC35D5B3A34B44C39B"))))));
union(
commonDsData,
ImmutableSet.of(
DelegationSignerData.create(
12346, 3, 1, base16().decode("38EC35D5B3A34B44C39B"))))));
}
@Test
@ -315,10 +342,12 @@ public class DomainApplicationUpdateFlowTest
// Adding and removing the same dsData is a no-op because removes are processed first.
doSecDnsSuccessfulTest(
"domain_update_sunrise_dsdata_add_rem_same.xml",
ImmutableSet.of(SOME_DSDATA, DelegationSignerData.create(
12345, 3, 1, base16().decode("38EC35D5B3A34B33C99B"))),
ImmutableSet.of(SOME_DSDATA, DelegationSignerData.create(
12345, 3, 1, base16().decode("38EC35D5B3A34B33C99B"))));
ImmutableSet.of(
SOME_DSDATA,
DelegationSignerData.create(12345, 3, 1, base16().decode("38EC35D5B3A34B33C99B"))),
ImmutableSet.of(
SOME_DSDATA,
DelegationSignerData.create(12345, 3, 1, base16().decode("38EC35D5B3A34B33C99B"))));
}
@Test
@ -330,12 +359,13 @@ public class DomainApplicationUpdateFlowTest
ImmutableSet.of(SOME_DSDATA));
}
private void doSecDnsFailingTest(Class<? extends Exception> expectedException, String xmlFilename)
throws Exception {
private void doSecDnsFailingTest(
Class<? extends EppException> expectedException, String xmlFilename) throws Exception {
setEppInput(xmlFilename);
persistReferencedEntities();
persistNewApplication();
assertThrows(expectedException, this::runFlow);
EppException thrown = expectThrows(expectedException, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml();
}
@Test
@ -352,40 +382,40 @@ public class DomainApplicationUpdateFlowTest
@Test
public void testFailure_secDnsUrgentNotSupported() throws Exception {
doSecDnsFailingTest(
UrgentAttributeNotSupportedException.class,
"domain_update_sunrise_dsdata_urgent.xml");
UrgentAttributeNotSupportedException.class, "domain_update_sunrise_dsdata_urgent.xml");
}
@Test
public void testFailure_secDnsChangeNotSupported() throws Exception {
doSecDnsFailingTest(
MaxSigLifeChangeNotSupportedException.class,
"domain_update_sunrise_maxsiglife.xml");
MaxSigLifeChangeNotSupportedException.class, "domain_update_sunrise_maxsiglife.xml");
}
@Test
public void testFailure_secDnsTooManyDsRecords() throws Exception {
ImmutableSet.Builder<DelegationSignerData> builder = new ImmutableSet.Builder<>();
for (int i = 0; i < 8; ++i) {
builder.add(DelegationSignerData.create(i, 2, 3, new byte[]{0, 1, 2}));
builder.add(DelegationSignerData.create(i, 2, 3, new byte[] {0, 1, 2}));
}
setEppInput("domain_update_sunrise_dsdata_add.xml");
persistResource(newApplicationBuilder().setDsData(builder.build()).build());
assertThrows(TooManyDsRecordsException.class, this::runFlow);
EppException thrown = expectThrows(TooManyDsRecordsException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml();
}
private void modifyApplicationToHave13Nameservers() throws Exception {
ImmutableSet.Builder<Key<HostResource>> nameservers = new ImmutableSet.Builder<>();
for (int i = 1; i < 15; i++) {
if (i != 2) { // Skip 2 since that's the one that the tests will add.
nameservers.add(Key.create(loadByForeignKey(
HostResource.class, String.format("ns%d.example.tld", i), clock.nowUtc())));
nameservers.add(
Key.create(
loadByForeignKey(
HostResource.class, String.format("ns%d.example.tld", i), clock.nowUtc())));
}
}
persistResource(reloadDomainApplication().asBuilder()
.setNameservers(nameservers.build())
.build());
persistResource(
reloadDomainApplication().asBuilder().setNameservers(nameservers.build()).build());
}
@Test
@ -395,20 +425,23 @@ public class DomainApplicationUpdateFlowTest
// Modify application to have 13 nameservers. We will then remove one and add one in the test.
modifyApplicationToHave13Nameservers();
setEppInput("domain_update_sunrise_add_nameserver.xml");
assertThrows(TooManyNameserversException.class, this::runFlow);
EppException thrown = expectThrows(TooManyNameserversException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml();
}
@Test
public void testFailure_wrongExtension() throws Exception {
setEppInput("domain_update_sunrise_wrong_extension.xml");
assertThrows(UnimplementedExtensionException.class, this::runFlow);
EppException thrown = expectThrows(UnimplementedExtensionException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml();
}
@Test
public void testFailure_applicationDomainNameMismatch() throws Exception {
persistReferencedEntities();
persistResource(newApplicationBuilder().setFullyQualifiedDomainName("something.tld").build());
assertThrows(ApplicationDomainNameMismatchException.class, this::runFlow);
EppException thrown = expectThrows(ApplicationDomainNameMismatchException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml();
}
@Test
@ -432,16 +465,22 @@ public class DomainApplicationUpdateFlowTest
public void testFailure_clientUpdateProhibited() throws Exception {
setEppInput("domain_update_sunrise_authinfo.xml");
persistReferencedEntities();
persistResource(newApplicationBuilder().setStatusValues(
ImmutableSet.of(StatusValue.CLIENT_UPDATE_PROHIBITED)).build());
assertThrows(ResourceHasClientUpdateProhibitedException.class, this::runFlow);
persistResource(
newApplicationBuilder()
.setStatusValues(ImmutableSet.of(StatusValue.CLIENT_UPDATE_PROHIBITED))
.build());
EppException thrown =
expectThrows(ResourceHasClientUpdateProhibitedException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml();
}
@Test
public void testFailure_serverUpdateProhibited() throws Exception {
persistReferencedEntities();
persistResource(newApplicationBuilder().setStatusValues(
ImmutableSet.of(StatusValue.SERVER_UPDATE_PROHIBITED)).build());
persistResource(
newApplicationBuilder()
.setStatusValues(ImmutableSet.of(StatusValue.SERVER_UPDATE_PROHIBITED))
.build());
ResourceStatusProhibitsOperationException thrown =
expectThrows(ResourceStatusProhibitsOperationException.class, this::runFlow);
assertThat(thrown).hasMessageThat().contains("serverUpdateProhibited");
@ -450,7 +489,9 @@ public class DomainApplicationUpdateFlowTest
private void doIllegalApplicationStatusTest(ApplicationStatus status) throws Exception {
persistReferencedEntities();
persistResource(newApplicationBuilder().setApplicationStatus(status).build());
assertThrows(ApplicationStatusProhibitsUpdateException.class, this::runFlow);
EppException thrown =
expectThrows(ApplicationStatusProhibitsUpdateException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml();
}
@Test
@ -497,10 +538,18 @@ public class DomainApplicationUpdateFlowTest
persistNewApplication();
// Add a tech contact to the persisted entity, which should cause the flow to fail when it tries
// to add "mak21" as a second tech contact.
persistResource(reloadDomainApplication().asBuilder().setContacts(ImmutableSet.of(
DesignatedContact.create(Type.TECH, Key.create(
loadByForeignKey(ContactResource.class, "foo", clock.nowUtc()))))).build());
assertThrows(DuplicateContactForRoleException.class, this::runFlow);
persistResource(
reloadDomainApplication()
.asBuilder()
.setContacts(
ImmutableSet.of(
DesignatedContact.create(
Type.TECH,
Key.create(
loadByForeignKey(ContactResource.class, "foo", clock.nowUtc())))))
.build());
EppException thrown = expectThrows(DuplicateContactForRoleException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml();
}
@Test
@ -508,10 +557,10 @@ public class DomainApplicationUpdateFlowTest
setEppInput("domain_update_sunrise_prohibited_status.xml");
persistReferencedEntities();
persistNewApplication();
assertThrows(StatusNotClientSettableException.class, this::runFlow);
EppException thrown = expectThrows(StatusNotClientSettableException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml();
}
@Test
public void testSuccess_superuserProhibitedStatusValue() throws Exception {
setEppInput("domain_update_sunrise_prohibited_status.xml");
@ -519,9 +568,7 @@ public class DomainApplicationUpdateFlowTest
persistNewApplication();
clock.advanceOneMilli();
runFlowAssertResponse(
CommitMode.LIVE,
UserPrivileges.SUPERUSER,
loadFile("domain_update_response.xml"));
CommitMode.LIVE, UserPrivileges.SUPERUSER, loadFile("domain_update_response.xml"));
}
@Test
@ -529,7 +576,8 @@ public class DomainApplicationUpdateFlowTest
setEppInput("domain_update_sunrise_duplicate_contact.xml");
persistReferencedEntities();
persistNewApplication();
assertThrows(DuplicateContactForRoleException.class, this::runFlow);
EppException thrown = expectThrows(DuplicateContactForRoleException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml();
}
@Test
@ -538,7 +586,8 @@ public class DomainApplicationUpdateFlowTest
persistReferencedEntities();
persistNewApplication();
// We need to test for missing type, but not for invalid - the schema enforces that for us.
assertThrows(MissingContactTypeException.class, this::runFlow);
EppException thrown = expectThrows(MissingContactTypeException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml();
}
@Test
@ -546,7 +595,8 @@ public class DomainApplicationUpdateFlowTest
sessionMetadata.setClientId("NewRegistrar");
persistReferencedEntities();
persistApplication();
assertThrows(ResourceNotOwnedException.class, this::runFlow);
EppException thrown = expectThrows(ResourceNotOwnedException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml();
}
@Test
@ -565,7 +615,8 @@ public class DomainApplicationUpdateFlowTest
loadRegistrar("TheRegistrar").asBuilder().setAllowedTlds(ImmutableSet.of()).build());
persistReferencedEntities();
persistApplication();
assertThrows(NotAuthorizedForTldException.class, this::runFlow);
EppException thrown = expectThrows(NotAuthorizedForTldException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml();
}
@Test
@ -583,48 +634,62 @@ public class DomainApplicationUpdateFlowTest
public void testFailure_sameNameserverAddedAndRemoved() throws Exception {
setEppInput("domain_update_sunrise_add_remove_same_host.xml");
persistReferencedEntities();
persistResource(newApplicationBuilder()
.setNameservers(ImmutableSet.of(Key.create(
loadByForeignKey(HostResource.class, "ns1.example.tld", clock.nowUtc()))))
.build());
assertThrows(AddRemoveSameValueException.class, this::runFlow);
persistResource(
newApplicationBuilder()
.setNameservers(
ImmutableSet.of(
Key.create(
loadByForeignKey(HostResource.class, "ns1.example.tld", clock.nowUtc()))))
.build());
EppException thrown = expectThrows(AddRemoveSameValueException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml();
}
@Test
public void testFailure_sameContactAddedAndRemoved() throws Exception {
setEppInput("domain_update_sunrise_add_remove_same_contact.xml");
persistReferencedEntities();
persistResource(newApplicationBuilder()
.setContacts(ImmutableSet.of(DesignatedContact.create(
Type.TECH,
Key.create(
loadByForeignKey(ContactResource.class, "sh8013", clock.nowUtc())))))
.build());
assertThrows(AddRemoveSameValueException.class, this::runFlow);
persistResource(
newApplicationBuilder()
.setContacts(
ImmutableSet.of(
DesignatedContact.create(
Type.TECH,
Key.create(
loadByForeignKey(ContactResource.class, "sh8013", clock.nowUtc())))))
.build());
EppException thrown = expectThrows(AddRemoveSameValueException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml();
}
@Test
public void testFailure_removeAdmin() throws Exception {
setEppInput("domain_update_sunrise_remove_admin.xml");
persistReferencedEntities();
persistResource(newApplicationBuilder()
.setContacts(ImmutableSet.of(
DesignatedContact.create(Type.ADMIN, Key.create(sh8013Contact)),
DesignatedContact.create(Type.TECH, Key.create(sh8013Contact))))
.build());
assertThrows(MissingAdminContactException.class, this::runFlow);
persistResource(
newApplicationBuilder()
.setContacts(
ImmutableSet.of(
DesignatedContact.create(Type.ADMIN, Key.create(sh8013Contact)),
DesignatedContact.create(Type.TECH, Key.create(sh8013Contact))))
.build());
EppException thrown = expectThrows(MissingAdminContactException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml();
}
@Test
public void testFailure_removeTech() throws Exception {
setEppInput("domain_update_sunrise_remove_tech.xml");
persistReferencedEntities();
persistResource(newApplicationBuilder()
.setContacts(ImmutableSet.of(
DesignatedContact.create(Type.ADMIN, Key.create(sh8013Contact)),
DesignatedContact.create(Type.TECH, Key.create(sh8013Contact))))
.build());
assertThrows(MissingTechnicalContactException.class, this::runFlow);
persistResource(
newApplicationBuilder()
.setContacts(
ImmutableSet.of(
DesignatedContact.create(Type.ADMIN, Key.create(sh8013Contact)),
DesignatedContact.create(Type.TECH, Key.create(sh8013Contact))))
.build());
EppException thrown = expectThrows(MissingTechnicalContactException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml();
}
@Test
@ -632,11 +697,13 @@ public class DomainApplicationUpdateFlowTest
persistReferencedEntities();
persistApplication();
persistResource(
Registry.get("tld").asBuilder()
Registry.get("tld")
.asBuilder()
.setAllowedRegistrantContactIds(ImmutableSet.of("contact1234"))
.build());
clock.advanceOneMilli();
assertThrows(RegistrantNotAllowedException.class, this::runFlow);
EppException thrown = expectThrows(RegistrantNotAllowedException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml();
}
@Test
@ -644,17 +711,20 @@ public class DomainApplicationUpdateFlowTest
persistReferencedEntities();
persistApplication();
persistResource(
Registry.get("tld").asBuilder()
Registry.get("tld")
.asBuilder()
.setAllowedFullyQualifiedHostNames(ImmutableSet.of("ns1.example.foo"))
.build());
clock.advanceOneMilli();
assertThrows(NameserversNotAllowedForTldException.class, this::runFlow);
EppException thrown = expectThrows(NameserversNotAllowedForTldException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml();
}
@Test
public void testSuccess_nameserverAndRegistrantWhitelisted() throws Exception {
persistResource(
Registry.get("tld").asBuilder()
Registry.get("tld")
.asBuilder()
.setAllowedRegistrantContactIds(ImmutableSet.of("sh8013"))
.setAllowedFullyQualifiedHostNames(ImmutableSet.of("ns2.example.tld"))
.build());
@ -675,8 +745,10 @@ public class DomainApplicationUpdateFlowTest
ImmutableSet.of("ns1.example.tld", "ns2.example.tld"))
.build());
clock.advanceOneMilli();
assertThrows(
NameserversNotSpecifiedForTldWithNameserverWhitelistException.class, this::runFlow);
EppException thrown =
expectThrows(
NameserversNotSpecifiedForTldWithNameserverWhitelistException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml();
}
@Test
@ -747,8 +819,10 @@ public class DomainApplicationUpdateFlowTest
"reserved", "example,NAMESERVER_RESTRICTED,ns1.example.tld:ns2.example.tld"))
.build());
clock.advanceOneMilli();
assertThrows(
NameserversNotSpecifiedForNameserverRestrictedDomainException.class, this::runFlow);
EppException thrown =
expectThrows(
NameserversNotSpecifiedForNameserverRestrictedDomainException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml();
}
@Test
@ -842,7 +916,8 @@ public class DomainApplicationUpdateFlowTest
"domain_update_sunrise_fee.xml",
ImmutableMap.of("DOMAIN", "non-free-update.tld", "AMOUNT", "12.00"));
clock.advanceOneMilli();
assertThrows(FeesMismatchException.class, this::runFlow);
EppException thrown = expectThrows(FeesMismatchException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml();
}
@Test