mirror of
https://github.com/google/nomulus.git
synced 2025-05-13 16:07:15 +02:00
Re-add assertions that EppExceptions marshal correctly
These checks were removed in [] and re-adding them is the last step of the migration to using expectThrows/assertThrows globally. Note that this is roughly half of them. More to come in a follow-up CL. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=179216707
This commit is contained in:
parent
16a1d6d196
commit
da08baab92
17 changed files with 529 additions and 316 deletions
|
@ -15,7 +15,8 @@
|
||||||
package google.registry.flows;
|
package google.registry.flows;
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
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.ImmutableList;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
@ -50,25 +51,28 @@ public class ExtensionManagerTest {
|
||||||
public final AppEngineRule appEngine = AppEngineRule.builder()
|
public final AppEngineRule appEngine = AppEngineRule.builder()
|
||||||
.withDatastore()
|
.withDatastore()
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDuplicateExtensionsForbidden() throws Exception {
|
public void testDuplicateExtensionsForbidden() throws Exception {
|
||||||
ExtensionManager manager = new TestInstanceBuilder()
|
ExtensionManager manager =
|
||||||
|
new TestInstanceBuilder()
|
||||||
.setEppRequestSource(EppRequestSource.TOOL)
|
.setEppRequestSource(EppRequestSource.TOOL)
|
||||||
.setDeclaredUris()
|
.setDeclaredUris()
|
||||||
.setSuppliedExtensions(
|
.setSuppliedExtensions(
|
||||||
MetadataExtension.class,
|
MetadataExtension.class, LaunchCreateExtension.class, MetadataExtension.class)
|
||||||
LaunchCreateExtension.class,
|
|
||||||
MetadataExtension.class)
|
|
||||||
.build();
|
.build();
|
||||||
manager.register(MetadataExtension.class, LaunchCreateExtension.class);
|
manager.register(MetadataExtension.class, LaunchCreateExtension.class);
|
||||||
assertThrows(UnsupportedRepeatedExtensionException.class, () -> manager.validate());
|
EppException thrown =
|
||||||
|
expectThrows(UnsupportedRepeatedExtensionException.class, manager::validate);
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUndeclaredExtensionsLogged() throws Exception {
|
public void testUndeclaredExtensionsLogged() throws Exception {
|
||||||
TestLogHandler handler = new TestLogHandler();
|
TestLogHandler handler = new TestLogHandler();
|
||||||
Logger.getLogger(ExtensionManager.class.getCanonicalName()).addHandler(handler);
|
Logger.getLogger(ExtensionManager.class.getCanonicalName()).addHandler(handler);
|
||||||
ExtensionManager manager = new TestInstanceBuilder()
|
ExtensionManager manager =
|
||||||
|
new TestInstanceBuilder()
|
||||||
.setEppRequestSource(EppRequestSource.TOOL)
|
.setEppRequestSource(EppRequestSource.TOOL)
|
||||||
.setDeclaredUris()
|
.setDeclaredUris()
|
||||||
.setSuppliedExtensions(MetadataExtension.class)
|
.setSuppliedExtensions(MetadataExtension.class)
|
||||||
|
@ -79,25 +83,30 @@ public class ExtensionManagerTest {
|
||||||
for (LogRecord record : handler.getStoredLogRecords()) {
|
for (LogRecord record : handler.getStoredLogRecords()) {
|
||||||
logMessages.add(record.getMessage());
|
logMessages.add(record.getMessage());
|
||||||
}
|
}
|
||||||
assertThat(logMessages.build()).contains(
|
assertThat(logMessages.build())
|
||||||
|
.contains(
|
||||||
"Client clientId is attempting to run HelloFlow without declaring "
|
"Client clientId is attempting to run HelloFlow without declaring "
|
||||||
+ "URIs [urn:google:params:xml:ns:metadata-1.0] on login");
|
+ "URIs [urn:google:params:xml:ns:metadata-1.0] on login");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testBlacklistedExtensions_forbiddenWhenUndeclared() throws Exception {
|
public void testBlacklistedExtensions_forbiddenWhenUndeclared() throws Exception {
|
||||||
ExtensionManager manager = new TestInstanceBuilder()
|
ExtensionManager manager =
|
||||||
|
new TestInstanceBuilder()
|
||||||
.setEppRequestSource(EppRequestSource.TOOL)
|
.setEppRequestSource(EppRequestSource.TOOL)
|
||||||
.setDeclaredUris()
|
.setDeclaredUris()
|
||||||
.setSuppliedExtensions(FeeInfoCommandExtensionV06.class)
|
.setSuppliedExtensions(FeeInfoCommandExtensionV06.class)
|
||||||
.build();
|
.build();
|
||||||
manager.register(FeeInfoCommandExtensionV06.class);
|
manager.register(FeeInfoCommandExtensionV06.class);
|
||||||
assertThrows(UndeclaredServiceExtensionException.class, () -> manager.validate());
|
EppException thrown =
|
||||||
|
expectThrows(UndeclaredServiceExtensionException.class, manager::validate);
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testBlacklistedExtensions_allowedWhenDeclared() throws Exception {
|
public void testBlacklistedExtensions_allowedWhenDeclared() throws Exception {
|
||||||
ExtensionManager manager = new TestInstanceBuilder()
|
ExtensionManager manager =
|
||||||
|
new TestInstanceBuilder()
|
||||||
.setEppRequestSource(EppRequestSource.TOOL)
|
.setEppRequestSource(EppRequestSource.TOOL)
|
||||||
.setDeclaredUris(ServiceExtension.FEE_0_6.getUri())
|
.setDeclaredUris(ServiceExtension.FEE_0_6.getUri())
|
||||||
.setSuppliedExtensions(FeeInfoCommandExtensionV06.class)
|
.setSuppliedExtensions(FeeInfoCommandExtensionV06.class)
|
||||||
|
@ -108,7 +117,8 @@ public class ExtensionManagerTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMetadataExtension_allowedForToolSource() throws Exception {
|
public void testMetadataExtension_allowedForToolSource() throws Exception {
|
||||||
ExtensionManager manager = new TestInstanceBuilder()
|
ExtensionManager manager =
|
||||||
|
new TestInstanceBuilder()
|
||||||
.setEppRequestSource(EppRequestSource.TOOL)
|
.setEppRequestSource(EppRequestSource.TOOL)
|
||||||
.setDeclaredUris()
|
.setDeclaredUris()
|
||||||
.setSuppliedExtensions(MetadataExtension.class)
|
.setSuppliedExtensions(MetadataExtension.class)
|
||||||
|
@ -119,18 +129,21 @@ public class ExtensionManagerTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMetadataExtension_forbiddenWhenNotToolSource() throws Exception {
|
public void testMetadataExtension_forbiddenWhenNotToolSource() throws Exception {
|
||||||
ExtensionManager manager = new TestInstanceBuilder()
|
ExtensionManager manager =
|
||||||
|
new TestInstanceBuilder()
|
||||||
.setEppRequestSource(EppRequestSource.CONSOLE)
|
.setEppRequestSource(EppRequestSource.CONSOLE)
|
||||||
.setDeclaredUris()
|
.setDeclaredUris()
|
||||||
.setSuppliedExtensions(MetadataExtension.class)
|
.setSuppliedExtensions(MetadataExtension.class)
|
||||||
.build();
|
.build();
|
||||||
manager.register(MetadataExtension.class);
|
manager.register(MetadataExtension.class);
|
||||||
assertThrows(OnlyToolCanPassMetadataException.class, () -> manager.validate());
|
EppException thrown = expectThrows(OnlyToolCanPassMetadataException.class, manager::validate);
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuperuserExtension_allowedForToolSource() throws Exception {
|
public void testSuperuserExtension_allowedForToolSource() throws Exception {
|
||||||
ExtensionManager manager = new TestInstanceBuilder()
|
ExtensionManager manager =
|
||||||
|
new TestInstanceBuilder()
|
||||||
.setEppRequestSource(EppRequestSource.TOOL)
|
.setEppRequestSource(EppRequestSource.TOOL)
|
||||||
.setDeclaredUris()
|
.setDeclaredUris()
|
||||||
.setSuppliedExtensions(DomainTransferRequestSuperuserExtension.class)
|
.setSuppliedExtensions(DomainTransferRequestSuperuserExtension.class)
|
||||||
|
@ -142,36 +155,44 @@ public class ExtensionManagerTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuperuserExtension_forbiddenWhenNotSuperuser() throws Exception {
|
public void testSuperuserExtension_forbiddenWhenNotSuperuser() throws Exception {
|
||||||
ExtensionManager manager = new TestInstanceBuilder()
|
ExtensionManager manager =
|
||||||
|
new TestInstanceBuilder()
|
||||||
.setEppRequestSource(EppRequestSource.TOOL)
|
.setEppRequestSource(EppRequestSource.TOOL)
|
||||||
.setDeclaredUris()
|
.setDeclaredUris()
|
||||||
.setSuppliedExtensions(DomainTransferRequestSuperuserExtension.class)
|
.setSuppliedExtensions(DomainTransferRequestSuperuserExtension.class)
|
||||||
.setIsSuperuser(false)
|
.setIsSuperuser(false)
|
||||||
.build();
|
.build();
|
||||||
manager.register(DomainTransferRequestSuperuserExtension.class);
|
manager.register(DomainTransferRequestSuperuserExtension.class);
|
||||||
assertThrows(UnauthorizedForSuperuserExtensionException.class, () -> manager.validate());
|
EppException thrown =
|
||||||
|
expectThrows(UnauthorizedForSuperuserExtensionException.class, manager::validate);
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuperuserExtension_forbiddenWhenNotToolSource() throws Exception {
|
public void testSuperuserExtension_forbiddenWhenNotToolSource() throws Exception {
|
||||||
ExtensionManager manager = new TestInstanceBuilder()
|
ExtensionManager manager =
|
||||||
|
new TestInstanceBuilder()
|
||||||
.setEppRequestSource(EppRequestSource.CONSOLE)
|
.setEppRequestSource(EppRequestSource.CONSOLE)
|
||||||
.setDeclaredUris()
|
.setDeclaredUris()
|
||||||
.setSuppliedExtensions(DomainTransferRequestSuperuserExtension.class)
|
.setSuppliedExtensions(DomainTransferRequestSuperuserExtension.class)
|
||||||
.setIsSuperuser(true)
|
.setIsSuperuser(true)
|
||||||
.build();
|
.build();
|
||||||
manager.register(DomainTransferRequestSuperuserExtension.class);
|
manager.register(DomainTransferRequestSuperuserExtension.class);
|
||||||
assertThrows(UnauthorizedForSuperuserExtensionException.class, () -> manager.validate());
|
EppException thrown =
|
||||||
|
expectThrows(UnauthorizedForSuperuserExtensionException.class, manager::validate);
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUnimplementedExtensionsForbidden() throws Exception {
|
public void testUnimplementedExtensionsForbidden() throws Exception {
|
||||||
ExtensionManager manager = new TestInstanceBuilder()
|
ExtensionManager manager =
|
||||||
|
new TestInstanceBuilder()
|
||||||
.setEppRequestSource(EppRequestSource.TOOL)
|
.setEppRequestSource(EppRequestSource.TOOL)
|
||||||
.setDeclaredUris()
|
.setDeclaredUris()
|
||||||
.setSuppliedExtensions(LaunchCreateExtension.class)
|
.setSuppliedExtensions(LaunchCreateExtension.class)
|
||||||
.build();
|
.build();
|
||||||
assertThrows(UnimplementedExtensionException.class, () -> manager.validate());
|
EppException thrown = expectThrows(UnimplementedExtensionException.class, manager::validate);
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** A builder for a test-ready {@link ExtensionManager} instance. */
|
/** A builder for a test-ready {@link ExtensionManager} instance. */
|
||||||
|
|
|
@ -19,7 +19,8 @@ import static com.google.common.truth.Truth.assertThat;
|
||||||
import static google.registry.model.EppResourceUtils.loadByForeignKey;
|
import static google.registry.model.EppResourceUtils.loadByForeignKey;
|
||||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||||
import static google.registry.model.tmch.ClaimsListShardTest.createTestClaimsListShard;
|
import static google.registry.model.tmch.ClaimsListShardTest.createTestClaimsListShard;
|
||||||
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.testing.LogsSubject.assertAboutLogs;
|
import static google.registry.testing.LogsSubject.assertAboutLogs;
|
||||||
import static google.registry.testing.TaskQueueHelper.assertTasksEnqueued;
|
import static google.registry.testing.TaskQueueHelper.assertTasksEnqueued;
|
||||||
|
|
||||||
|
@ -132,7 +133,8 @@ public abstract class ResourceFlowTestCase<F extends Flow, R extends EppResource
|
||||||
@Test
|
@Test
|
||||||
public void testRequiresLogin() throws Exception {
|
public void testRequiresLogin() throws Exception {
|
||||||
sessionMetadata.setClientId(null);
|
sessionMetadata.setClientId(null);
|
||||||
assertThrows(NotLoggedInException.class, this::runFlow);
|
EppException thrown = expectThrows(NotLoggedInException.class, this::runFlow);
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -17,8 +17,10 @@ package google.registry.flows.contact;
|
||||||
import static google.registry.model.eppoutput.CheckData.ContactCheck.create;
|
import static google.registry.model.eppoutput.CheckData.ContactCheck.create;
|
||||||
import static google.registry.testing.DatastoreHelper.persistActiveContact;
|
import static google.registry.testing.DatastoreHelper.persistActiveContact;
|
||||||
import static google.registry.testing.DatastoreHelper.persistDeletedContact;
|
import static google.registry.testing.DatastoreHelper.persistDeletedContact;
|
||||||
import static google.registry.testing.JUnitBackports.assertThrows;
|
import static google.registry.testing.EppExceptionSubject.assertAboutEppExceptions;
|
||||||
|
import static google.registry.testing.JUnitBackports.expectThrows;
|
||||||
|
|
||||||
|
import google.registry.flows.EppException;
|
||||||
import google.registry.flows.ResourceCheckFlowTestCase;
|
import google.registry.flows.ResourceCheckFlowTestCase;
|
||||||
import google.registry.flows.exceptions.TooManyResourceChecksException;
|
import google.registry.flows.exceptions.TooManyResourceChecksException;
|
||||||
import google.registry.model.contact.ContactResource;
|
import google.registry.model.contact.ContactResource;
|
||||||
|
@ -77,7 +79,8 @@ public class ContactCheckFlowTest
|
||||||
@Test
|
@Test
|
||||||
public void testTooManyIds() throws Exception {
|
public void testTooManyIds() throws Exception {
|
||||||
setEppInput("contact_check_51.xml");
|
setEppInput("contact_check_51.xml");
|
||||||
assertThrows(TooManyResourceChecksException.class, this::runFlow);
|
EppException thrown = expectThrows(TooManyResourceChecksException.class, this::runFlow);
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -19,9 +19,10 @@ import static google.registry.testing.ContactResourceSubject.assertAboutContacts
|
||||||
import static google.registry.testing.DatastoreHelper.assertNoBillingEvents;
|
import static google.registry.testing.DatastoreHelper.assertNoBillingEvents;
|
||||||
import static google.registry.testing.DatastoreHelper.persistActiveContact;
|
import static google.registry.testing.DatastoreHelper.persistActiveContact;
|
||||||
import static google.registry.testing.DatastoreHelper.persistDeletedContact;
|
import static google.registry.testing.DatastoreHelper.persistDeletedContact;
|
||||||
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.testing.JUnitBackports.expectThrows;
|
||||||
|
|
||||||
|
import google.registry.flows.EppException;
|
||||||
import google.registry.flows.ResourceFlowTestCase;
|
import google.registry.flows.ResourceFlowTestCase;
|
||||||
import google.registry.flows.contact.ContactFlowUtils.BadInternationalizedPostalInfoException;
|
import google.registry.flows.contact.ContactFlowUtils.BadInternationalizedPostalInfoException;
|
||||||
import google.registry.flows.contact.ContactFlowUtils.DeclineContactDisclosureFieldDisallowedPolicyException;
|
import google.registry.flows.contact.ContactFlowUtils.DeclineContactDisclosureFieldDisallowedPolicyException;
|
||||||
|
@ -75,6 +76,7 @@ public class ContactCreateFlowTest
|
||||||
.hasMessageThat()
|
.hasMessageThat()
|
||||||
.contains(
|
.contains(
|
||||||
String.format("Object with given ID (%s) already exists", getUniqueIdFromCommand()));
|
String.format("Object with given ID (%s) already exists", getUniqueIdFromCommand()));
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -86,13 +88,17 @@ public class ContactCreateFlowTest
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_nonAsciiInIntAddress() throws Exception {
|
public void testFailure_nonAsciiInIntAddress() throws Exception {
|
||||||
setEppInput("contact_create_hebrew_int.xml");
|
setEppInput("contact_create_hebrew_int.xml");
|
||||||
assertThrows(BadInternationalizedPostalInfoException.class, this::runFlow);
|
EppException thrown =
|
||||||
|
expectThrows(BadInternationalizedPostalInfoException.class, this::runFlow);
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_declineDisclosure() throws Exception {
|
public void testFailure_declineDisclosure() throws Exception {
|
||||||
setEppInput("contact_create_decline_disclosure.xml");
|
setEppInput("contact_create_decline_disclosure.xml");
|
||||||
assertThrows(DeclineContactDisclosureFieldDisallowedPolicyException.class, this::runFlow);
|
EppException thrown =
|
||||||
|
expectThrows(DeclineContactDisclosureFieldDisallowedPolicyException.class, this::runFlow);
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -23,10 +23,11 @@ import static google.registry.testing.DatastoreHelper.newDomainResource;
|
||||||
import static google.registry.testing.DatastoreHelper.persistActiveContact;
|
import static google.registry.testing.DatastoreHelper.persistActiveContact;
|
||||||
import static google.registry.testing.DatastoreHelper.persistDeletedContact;
|
import static google.registry.testing.DatastoreHelper.persistDeletedContact;
|
||||||
import static google.registry.testing.DatastoreHelper.persistResource;
|
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 static google.registry.testing.JUnitBackports.expectThrows;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
import google.registry.flows.EppException;
|
||||||
import google.registry.flows.ResourceFlowTestCase;
|
import google.registry.flows.ResourceFlowTestCase;
|
||||||
import google.registry.flows.ResourceFlowUtils.ResourceDoesNotExistException;
|
import google.registry.flows.ResourceFlowUtils.ResourceDoesNotExistException;
|
||||||
import google.registry.flows.ResourceFlowUtils.ResourceNotOwnedException;
|
import google.registry.flows.ResourceFlowUtils.ResourceNotOwnedException;
|
||||||
|
@ -75,6 +76,7 @@ public class ContactDeleteFlowTest
|
||||||
ResourceDoesNotExistException thrown =
|
ResourceDoesNotExistException thrown =
|
||||||
expectThrows(ResourceDoesNotExistException.class, this::runFlow);
|
expectThrows(ResourceDoesNotExistException.class, this::runFlow);
|
||||||
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
|
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -83,6 +85,7 @@ public class ContactDeleteFlowTest
|
||||||
ResourceDoesNotExistException thrown =
|
ResourceDoesNotExistException thrown =
|
||||||
expectThrows(ResourceDoesNotExistException.class, this::runFlow);
|
expectThrows(ResourceDoesNotExistException.class, this::runFlow);
|
||||||
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
|
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -103,21 +106,23 @@ public class ContactDeleteFlowTest
|
||||||
StatusValue.PENDING_DELETE, ResourceStatusProhibitsOperationException.class);
|
StatusValue.PENDING_DELETE, ResourceStatusProhibitsOperationException.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doFailingStatusTest(StatusValue statusValue, Class<? extends Exception> exception)
|
private void doFailingStatusTest(StatusValue statusValue, Class<? extends EppException> exception)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
persistResource(
|
persistResource(
|
||||||
newContactResource(getUniqueIdFromCommand()).asBuilder()
|
newContactResource(getUniqueIdFromCommand()).asBuilder()
|
||||||
.setStatusValues(ImmutableSet.of(statusValue))
|
.setStatusValues(ImmutableSet.of(statusValue))
|
||||||
.build());
|
.build());
|
||||||
Exception e = expectThrows(exception, this::runFlow);
|
EppException thrown = expectThrows(exception, this::runFlow);
|
||||||
assertThat(e).hasMessageThat().contains(statusValue.getXmlName());
|
assertThat(thrown).hasMessageThat().contains(statusValue.getXmlName());
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_unauthorizedClient() throws Exception {
|
public void testFailure_unauthorizedClient() throws Exception {
|
||||||
sessionMetadata.setClientId("NewRegistrar");
|
sessionMetadata.setClientId("NewRegistrar");
|
||||||
persistActiveContact(getUniqueIdFromCommand());
|
persistActiveContact(getUniqueIdFromCommand());
|
||||||
assertThrows(ResourceNotOwnedException.class, this::runFlow);
|
EppException thrown = expectThrows(ResourceNotOwnedException.class, this::runFlow);
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -131,7 +136,8 @@ public class ContactDeleteFlowTest
|
||||||
assertAboutContacts().that(deletedContact).hasStatusValue(StatusValue.PENDING_DELETE);
|
assertAboutContacts().that(deletedContact).hasStatusValue(StatusValue.PENDING_DELETE);
|
||||||
assertAsyncDeletionTaskEnqueued(
|
assertAsyncDeletionTaskEnqueued(
|
||||||
deletedContact, "NewRegistrar", Trid.create("ABC-12345", "server-trid"), true);
|
deletedContact, "NewRegistrar", Trid.create("ABC-12345", "server-trid"), true);
|
||||||
assertAboutContacts().that(deletedContact)
|
assertAboutContacts()
|
||||||
|
.that(deletedContact)
|
||||||
.hasOnlyOneHistoryEntryWhich()
|
.hasOnlyOneHistoryEntryWhich()
|
||||||
.hasType(HistoryEntry.Type.CONTACT_PENDING_DELETE);
|
.hasType(HistoryEntry.Type.CONTACT_PENDING_DELETE);
|
||||||
assertNoBillingEvents();
|
assertNoBillingEvents();
|
||||||
|
@ -142,7 +148,8 @@ public class ContactDeleteFlowTest
|
||||||
createTld("tld");
|
createTld("tld");
|
||||||
persistResource(
|
persistResource(
|
||||||
newDomainResource("example.tld", persistActiveContact(getUniqueIdFromCommand())));
|
newDomainResource("example.tld", persistActiveContact(getUniqueIdFromCommand())));
|
||||||
assertThrows(ResourceToDeleteIsReferencedException.class, this::runFlow);
|
EppException thrown = expectThrows(ResourceToDeleteIsReferencedException.class, this::runFlow);
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -150,7 +157,8 @@ public class ContactDeleteFlowTest
|
||||||
createTld("tld");
|
createTld("tld");
|
||||||
persistResource(
|
persistResource(
|
||||||
newDomainResource("example.tld", persistActiveContact(getUniqueIdFromCommand())));
|
newDomainResource("example.tld", persistActiveContact(getUniqueIdFromCommand())));
|
||||||
assertThrows(ResourceToDeleteIsReferencedException.class, this::runFlow);
|
EppException thrown = expectThrows(ResourceToDeleteIsReferencedException.class, this::runFlow);
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -20,6 +20,7 @@ import static google.registry.testing.DatastoreHelper.assertNoBillingEvents;
|
||||||
import static google.registry.testing.DatastoreHelper.createTld;
|
import static google.registry.testing.DatastoreHelper.createTld;
|
||||||
import static google.registry.testing.DatastoreHelper.newDomainResource;
|
import static google.registry.testing.DatastoreHelper.newDomainResource;
|
||||||
import static google.registry.testing.DatastoreHelper.persistResource;
|
import static google.registry.testing.DatastoreHelper.persistResource;
|
||||||
|
import static google.registry.testing.EppExceptionSubject.assertAboutEppExceptions;
|
||||||
import static google.registry.testing.JUnitBackports.expectThrows;
|
import static google.registry.testing.JUnitBackports.expectThrows;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
|
@ -167,6 +168,7 @@ public class ContactInfoFlowTest extends ResourceFlowTestCase<ContactInfoFlow, C
|
||||||
ResourceDoesNotExistException thrown =
|
ResourceDoesNotExistException thrown =
|
||||||
expectThrows(ResourceDoesNotExistException.class, this::runFlow);
|
expectThrows(ResourceDoesNotExistException.class, this::runFlow);
|
||||||
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
|
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -175,6 +177,7 @@ public class ContactInfoFlowTest extends ResourceFlowTestCase<ContactInfoFlow, C
|
||||||
ResourceDoesNotExistException thrown =
|
ResourceDoesNotExistException thrown =
|
||||||
expectThrows(ResourceDoesNotExistException.class, this::runFlow);
|
expectThrows(ResourceDoesNotExistException.class, this::runFlow);
|
||||||
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
|
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -23,9 +23,10 @@ import static google.registry.testing.DatastoreHelper.deleteResource;
|
||||||
import static google.registry.testing.DatastoreHelper.getOnlyPollMessage;
|
import static google.registry.testing.DatastoreHelper.getOnlyPollMessage;
|
||||||
import static google.registry.testing.DatastoreHelper.getPollMessages;
|
import static google.registry.testing.DatastoreHelper.getPollMessages;
|
||||||
import static google.registry.testing.DatastoreHelper.persistResource;
|
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 static google.registry.testing.JUnitBackports.expectThrows;
|
||||||
|
|
||||||
|
import google.registry.flows.EppException;
|
||||||
import google.registry.flows.ResourceFlowUtils.BadAuthInfoForResourceException;
|
import google.registry.flows.ResourceFlowUtils.BadAuthInfoForResourceException;
|
||||||
import google.registry.flows.ResourceFlowUtils.ResourceDoesNotExistException;
|
import google.registry.flows.ResourceFlowUtils.ResourceDoesNotExistException;
|
||||||
import google.registry.flows.ResourceFlowUtils.ResourceNotOwnedException;
|
import google.registry.flows.ResourceFlowUtils.ResourceNotOwnedException;
|
||||||
|
@ -144,65 +145,82 @@ public class ContactTransferApproveFlowTest
|
||||||
contact.asBuilder()
|
contact.asBuilder()
|
||||||
.setAuthInfo(ContactAuthInfo.create(PasswordAuth.create("badpassword")))
|
.setAuthInfo(ContactAuthInfo.create(PasswordAuth.create("badpassword")))
|
||||||
.build());
|
.build());
|
||||||
assertThrows(
|
EppException thrown = expectThrows(
|
||||||
BadAuthInfoForResourceException.class,
|
BadAuthInfoForResourceException.class,
|
||||||
() -> doFailingTest("contact_transfer_approve_with_authinfo.xml"));
|
() -> doFailingTest("contact_transfer_approve_with_authinfo.xml"));
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_neverBeenTransferred() throws Exception {
|
public void testFailure_neverBeenTransferred() throws Exception {
|
||||||
changeTransferStatus(null);
|
changeTransferStatus(null);
|
||||||
assertThrows(
|
EppException thrown =
|
||||||
|
expectThrows(
|
||||||
NotPendingTransferException.class, () -> doFailingTest("contact_transfer_approve.xml"));
|
NotPendingTransferException.class, () -> doFailingTest("contact_transfer_approve.xml"));
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_clientApproved() throws Exception {
|
public void testFailure_clientApproved() throws Exception {
|
||||||
changeTransferStatus(TransferStatus.CLIENT_APPROVED);
|
changeTransferStatus(TransferStatus.CLIENT_APPROVED);
|
||||||
assertThrows(
|
EppException thrown =
|
||||||
|
expectThrows(
|
||||||
NotPendingTransferException.class, () -> doFailingTest("contact_transfer_approve.xml"));
|
NotPendingTransferException.class, () -> doFailingTest("contact_transfer_approve.xml"));
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_clientRejected() throws Exception {
|
public void testFailure_clientRejected() throws Exception {
|
||||||
changeTransferStatus(TransferStatus.CLIENT_REJECTED);
|
changeTransferStatus(TransferStatus.CLIENT_REJECTED);
|
||||||
assertThrows(
|
EppException thrown =
|
||||||
|
expectThrows(
|
||||||
NotPendingTransferException.class, () -> doFailingTest("contact_transfer_approve.xml"));
|
NotPendingTransferException.class, () -> doFailingTest("contact_transfer_approve.xml"));
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_clientCancelled() throws Exception {
|
public void testFailure_clientCancelled() throws Exception {
|
||||||
changeTransferStatus(TransferStatus.CLIENT_CANCELLED);
|
changeTransferStatus(TransferStatus.CLIENT_CANCELLED);
|
||||||
assertThrows(
|
EppException thrown =
|
||||||
|
expectThrows(
|
||||||
NotPendingTransferException.class, () -> doFailingTest("contact_transfer_approve.xml"));
|
NotPendingTransferException.class, () -> doFailingTest("contact_transfer_approve.xml"));
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_serverApproved() throws Exception {
|
public void testFailure_serverApproved() throws Exception {
|
||||||
changeTransferStatus(TransferStatus.SERVER_APPROVED);
|
changeTransferStatus(TransferStatus.SERVER_APPROVED);
|
||||||
assertThrows(
|
EppException thrown =
|
||||||
|
expectThrows(
|
||||||
NotPendingTransferException.class, () -> doFailingTest("contact_transfer_approve.xml"));
|
NotPendingTransferException.class, () -> doFailingTest("contact_transfer_approve.xml"));
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_serverCancelled() throws Exception {
|
public void testFailure_serverCancelled() throws Exception {
|
||||||
changeTransferStatus(TransferStatus.SERVER_CANCELLED);
|
changeTransferStatus(TransferStatus.SERVER_CANCELLED);
|
||||||
assertThrows(
|
EppException thrown =
|
||||||
|
expectThrows(
|
||||||
NotPendingTransferException.class, () -> doFailingTest("contact_transfer_approve.xml"));
|
NotPendingTransferException.class, () -> doFailingTest("contact_transfer_approve.xml"));
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_gainingClient() throws Exception {
|
public void testFailure_gainingClient() throws Exception {
|
||||||
setClientIdForFlow("NewRegistrar");
|
setClientIdForFlow("NewRegistrar");
|
||||||
assertThrows(
|
EppException thrown =
|
||||||
|
expectThrows(
|
||||||
ResourceNotOwnedException.class, () -> doFailingTest("contact_transfer_approve.xml"));
|
ResourceNotOwnedException.class, () -> doFailingTest("contact_transfer_approve.xml"));
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_unrelatedClient() throws Exception {
|
public void testFailure_unrelatedClient() throws Exception {
|
||||||
setClientIdForFlow("ClientZ");
|
setClientIdForFlow("ClientZ");
|
||||||
assertThrows(
|
EppException thrown =
|
||||||
|
expectThrows(
|
||||||
ResourceNotOwnedException.class, () -> doFailingTest("contact_transfer_approve.xml"));
|
ResourceNotOwnedException.class, () -> doFailingTest("contact_transfer_approve.xml"));
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -214,6 +232,7 @@ public class ContactTransferApproveFlowTest
|
||||||
ResourceDoesNotExistException.class,
|
ResourceDoesNotExistException.class,
|
||||||
() -> doFailingTest("contact_transfer_approve.xml"));
|
() -> doFailingTest("contact_transfer_approve.xml"));
|
||||||
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
|
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -226,6 +245,7 @@ public class ContactTransferApproveFlowTest
|
||||||
ResourceDoesNotExistException.class,
|
ResourceDoesNotExistException.class,
|
||||||
() -> doFailingTest("contact_transfer_approve.xml"));
|
() -> doFailingTest("contact_transfer_approve.xml"));
|
||||||
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
|
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -22,9 +22,10 @@ import static google.registry.testing.DatastoreHelper.deleteResource;
|
||||||
import static google.registry.testing.DatastoreHelper.getOnlyPollMessage;
|
import static google.registry.testing.DatastoreHelper.getOnlyPollMessage;
|
||||||
import static google.registry.testing.DatastoreHelper.getPollMessages;
|
import static google.registry.testing.DatastoreHelper.getPollMessages;
|
||||||
import static google.registry.testing.DatastoreHelper.persistResource;
|
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 static google.registry.testing.JUnitBackports.expectThrows;
|
||||||
|
|
||||||
|
import google.registry.flows.EppException;
|
||||||
import google.registry.flows.ResourceFlowUtils.BadAuthInfoForResourceException;
|
import google.registry.flows.ResourceFlowUtils.BadAuthInfoForResourceException;
|
||||||
import google.registry.flows.ResourceFlowUtils.ResourceDoesNotExistException;
|
import google.registry.flows.ResourceFlowUtils.ResourceDoesNotExistException;
|
||||||
import google.registry.flows.exceptions.NotPendingTransferException;
|
import google.registry.flows.exceptions.NotPendingTransferException;
|
||||||
|
@ -124,80 +125,103 @@ public class ContactTransferCancelFlowTest
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_badContactPassword() throws Exception {
|
public void testFailure_badContactPassword() throws Exception {
|
||||||
// Change the contact's password so it does not match the password in the file.
|
// Change the contact's password so it does not match the password in the file.
|
||||||
contact = persistResource(
|
contact =
|
||||||
contact.asBuilder()
|
persistResource(
|
||||||
|
contact
|
||||||
|
.asBuilder()
|
||||||
.setAuthInfo(ContactAuthInfo.create(PasswordAuth.create("badpassword")))
|
.setAuthInfo(ContactAuthInfo.create(PasswordAuth.create("badpassword")))
|
||||||
.build());
|
.build());
|
||||||
assertThrows(
|
EppException thrown =
|
||||||
|
expectThrows(
|
||||||
BadAuthInfoForResourceException.class,
|
BadAuthInfoForResourceException.class,
|
||||||
() -> doFailingTest("contact_transfer_cancel_with_authinfo.xml"));
|
() -> doFailingTest("contact_transfer_cancel_with_authinfo.xml"));
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_neverBeenTransferred() throws Exception {
|
public void testFailure_neverBeenTransferred() throws Exception {
|
||||||
changeTransferStatus(null);
|
changeTransferStatus(null);
|
||||||
assertThrows(
|
EppException thrown =
|
||||||
|
expectThrows(
|
||||||
NotPendingTransferException.class, () -> doFailingTest("contact_transfer_cancel.xml"));
|
NotPendingTransferException.class, () -> doFailingTest("contact_transfer_cancel.xml"));
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_clientApproved() throws Exception {
|
public void testFailure_clientApproved() throws Exception {
|
||||||
changeTransferStatus(TransferStatus.CLIENT_APPROVED);
|
changeTransferStatus(TransferStatus.CLIENT_APPROVED);
|
||||||
assertThrows(
|
EppException thrown =
|
||||||
|
expectThrows(
|
||||||
NotPendingTransferException.class, () -> doFailingTest("contact_transfer_cancel.xml"));
|
NotPendingTransferException.class, () -> doFailingTest("contact_transfer_cancel.xml"));
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_clientRejected() throws Exception {
|
public void testFailure_clientRejected() throws Exception {
|
||||||
changeTransferStatus(TransferStatus.CLIENT_REJECTED);
|
changeTransferStatus(TransferStatus.CLIENT_REJECTED);
|
||||||
assertThrows(
|
EppException thrown =
|
||||||
|
expectThrows(
|
||||||
NotPendingTransferException.class, () -> doFailingTest("contact_transfer_cancel.xml"));
|
NotPendingTransferException.class, () -> doFailingTest("contact_transfer_cancel.xml"));
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_clientCancelled() throws Exception {
|
public void testFailure_clientCancelled() throws Exception {
|
||||||
changeTransferStatus(TransferStatus.CLIENT_CANCELLED);
|
changeTransferStatus(TransferStatus.CLIENT_CANCELLED);
|
||||||
assertThrows(
|
EppException thrown =
|
||||||
|
expectThrows(
|
||||||
NotPendingTransferException.class, () -> doFailingTest("contact_transfer_cancel.xml"));
|
NotPendingTransferException.class, () -> doFailingTest("contact_transfer_cancel.xml"));
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_serverApproved() throws Exception {
|
public void testFailure_serverApproved() throws Exception {
|
||||||
changeTransferStatus(TransferStatus.SERVER_APPROVED);
|
changeTransferStatus(TransferStatus.SERVER_APPROVED);
|
||||||
assertThrows(
|
EppException thrown =
|
||||||
|
expectThrows(
|
||||||
NotPendingTransferException.class, () -> doFailingTest("contact_transfer_cancel.xml"));
|
NotPendingTransferException.class, () -> doFailingTest("contact_transfer_cancel.xml"));
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_serverCancelled() throws Exception {
|
public void testFailure_serverCancelled() throws Exception {
|
||||||
changeTransferStatus(TransferStatus.SERVER_CANCELLED);
|
changeTransferStatus(TransferStatus.SERVER_CANCELLED);
|
||||||
assertThrows(
|
EppException thrown =
|
||||||
|
expectThrows(
|
||||||
NotPendingTransferException.class, () -> doFailingTest("contact_transfer_cancel.xml"));
|
NotPendingTransferException.class, () -> doFailingTest("contact_transfer_cancel.xml"));
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_sponsoringClient() throws Exception {
|
public void testFailure_sponsoringClient() throws Exception {
|
||||||
setClientIdForFlow("TheRegistrar");
|
setClientIdForFlow("TheRegistrar");
|
||||||
assertThrows(
|
EppException thrown =
|
||||||
NotTransferInitiatorException.class, () -> doFailingTest("contact_transfer_cancel.xml"));
|
expectThrows(
|
||||||
|
NotTransferInitiatorException.class,
|
||||||
|
() -> doFailingTest("contact_transfer_cancel.xml"));
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_unrelatedClient() throws Exception {
|
public void testFailure_unrelatedClient() throws Exception {
|
||||||
setClientIdForFlow("ClientZ");
|
setClientIdForFlow("ClientZ");
|
||||||
assertThrows(
|
EppException thrown =
|
||||||
NotTransferInitiatorException.class, () -> doFailingTest("contact_transfer_cancel.xml"));
|
expectThrows(
|
||||||
|
NotTransferInitiatorException.class,
|
||||||
|
() -> doFailingTest("contact_transfer_cancel.xml"));
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_deletedContact() throws Exception {
|
public void testFailure_deletedContact() throws Exception {
|
||||||
contact = persistResource(
|
contact =
|
||||||
contact.asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build());
|
persistResource(contact.asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build());
|
||||||
ResourceDoesNotExistException thrown =
|
ResourceDoesNotExistException thrown =
|
||||||
expectThrows(
|
expectThrows(
|
||||||
ResourceDoesNotExistException.class,
|
ResourceDoesNotExistException.class,
|
||||||
() -> doFailingTest("contact_transfer_cancel.xml"));
|
() -> doFailingTest("contact_transfer_cancel.xml"));
|
||||||
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
|
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -208,6 +232,7 @@ public class ContactTransferCancelFlowTest
|
||||||
ResourceDoesNotExistException.class,
|
ResourceDoesNotExistException.class,
|
||||||
() -> doFailingTest("contact_transfer_cancel.xml"));
|
() -> doFailingTest("contact_transfer_cancel.xml"));
|
||||||
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
|
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -19,9 +19,10 @@ import static google.registry.testing.ContactResourceSubject.assertAboutContacts
|
||||||
import static google.registry.testing.DatastoreHelper.assertNoBillingEvents;
|
import static google.registry.testing.DatastoreHelper.assertNoBillingEvents;
|
||||||
import static google.registry.testing.DatastoreHelper.deleteResource;
|
import static google.registry.testing.DatastoreHelper.deleteResource;
|
||||||
import static google.registry.testing.DatastoreHelper.persistResource;
|
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 static google.registry.testing.JUnitBackports.expectThrows;
|
||||||
|
|
||||||
|
import google.registry.flows.EppException;
|
||||||
import google.registry.flows.ResourceFlowUtils.BadAuthInfoForResourceException;
|
import google.registry.flows.ResourceFlowUtils.BadAuthInfoForResourceException;
|
||||||
import google.registry.flows.ResourceFlowUtils.ResourceDoesNotExistException;
|
import google.registry.flows.ResourceFlowUtils.ResourceDoesNotExistException;
|
||||||
import google.registry.flows.exceptions.NoTransferHistoryToQueryException;
|
import google.registry.flows.exceptions.NoTransferHistoryToQueryException;
|
||||||
|
@ -137,13 +138,17 @@ public class ContactTransferQueryFlowTest
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_badContactPassword() throws Exception {
|
public void testFailure_badContactPassword() throws Exception {
|
||||||
// Change the contact's password so it does not match the password in the file.
|
// Change the contact's password so it does not match the password in the file.
|
||||||
contact = persistResource(
|
contact =
|
||||||
contact.asBuilder()
|
persistResource(
|
||||||
|
contact
|
||||||
|
.asBuilder()
|
||||||
.setAuthInfo(ContactAuthInfo.create(PasswordAuth.create("badpassword")))
|
.setAuthInfo(ContactAuthInfo.create(PasswordAuth.create("badpassword")))
|
||||||
.build());
|
.build());
|
||||||
assertThrows(
|
EppException thrown =
|
||||||
|
expectThrows(
|
||||||
BadAuthInfoForResourceException.class,
|
BadAuthInfoForResourceException.class,
|
||||||
() -> doFailingTest("contact_transfer_query_with_authinfo.xml"));
|
() -> doFailingTest("contact_transfer_query_with_authinfo.xml"));
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -151,34 +156,42 @@ public class ContactTransferQueryFlowTest
|
||||||
// Set the contact to a different ROID, but don't persist it; this is just so the substitution
|
// Set the contact to a different ROID, but don't persist it; this is just so the substitution
|
||||||
// code above will write the wrong ROID into the file.
|
// code above will write the wrong ROID into the file.
|
||||||
contact = contact.asBuilder().setRepoId("DEADBEEF_TLD-ROID").build();
|
contact = contact.asBuilder().setRepoId("DEADBEEF_TLD-ROID").build();
|
||||||
assertThrows(
|
EppException thrown =
|
||||||
|
expectThrows(
|
||||||
BadAuthInfoForResourceException.class,
|
BadAuthInfoForResourceException.class,
|
||||||
() -> doFailingTest("contact_transfer_query_with_roid.xml"));
|
() -> doFailingTest("contact_transfer_query_with_roid.xml"));
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_neverBeenTransferred() throws Exception {
|
public void testFailure_neverBeenTransferred() throws Exception {
|
||||||
changeTransferStatus(null);
|
changeTransferStatus(null);
|
||||||
assertThrows(
|
EppException thrown =
|
||||||
NoTransferHistoryToQueryException.class, () -> doFailingTest("contact_transfer_query.xml"));
|
expectThrows(
|
||||||
|
NoTransferHistoryToQueryException.class,
|
||||||
|
() -> doFailingTest("contact_transfer_query.xml"));
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_unrelatedClient() throws Exception {
|
public void testFailure_unrelatedClient() throws Exception {
|
||||||
setClientIdForFlow("ClientZ");
|
setClientIdForFlow("ClientZ");
|
||||||
assertThrows(
|
EppException thrown =
|
||||||
|
expectThrows(
|
||||||
NotAuthorizedToViewTransferException.class,
|
NotAuthorizedToViewTransferException.class,
|
||||||
() -> doFailingTest("contact_transfer_query.xml"));
|
() -> doFailingTest("contact_transfer_query.xml"));
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_deletedContact() throws Exception {
|
public void testFailure_deletedContact() throws Exception {
|
||||||
contact = persistResource(
|
contact =
|
||||||
contact.asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build());
|
persistResource(contact.asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build());
|
||||||
ResourceDoesNotExistException thrown =
|
ResourceDoesNotExistException thrown =
|
||||||
expectThrows(
|
expectThrows(
|
||||||
ResourceDoesNotExistException.class, () -> doFailingTest("contact_transfer_query.xml"));
|
ResourceDoesNotExistException.class, () -> doFailingTest("contact_transfer_query.xml"));
|
||||||
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
|
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -188,6 +201,7 @@ public class ContactTransferQueryFlowTest
|
||||||
expectThrows(
|
expectThrows(
|
||||||
ResourceDoesNotExistException.class, () -> doFailingTest("contact_transfer_query.xml"));
|
ResourceDoesNotExistException.class, () -> doFailingTest("contact_transfer_query.xml"));
|
||||||
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
|
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -22,9 +22,10 @@ import static google.registry.testing.DatastoreHelper.deleteResource;
|
||||||
import static google.registry.testing.DatastoreHelper.getOnlyPollMessage;
|
import static google.registry.testing.DatastoreHelper.getOnlyPollMessage;
|
||||||
import static google.registry.testing.DatastoreHelper.getPollMessages;
|
import static google.registry.testing.DatastoreHelper.getPollMessages;
|
||||||
import static google.registry.testing.DatastoreHelper.persistResource;
|
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 static google.registry.testing.JUnitBackports.expectThrows;
|
||||||
|
|
||||||
|
import google.registry.flows.EppException;
|
||||||
import google.registry.flows.ResourceFlowUtils.BadAuthInfoForResourceException;
|
import google.registry.flows.ResourceFlowUtils.BadAuthInfoForResourceException;
|
||||||
import google.registry.flows.ResourceFlowUtils.ResourceDoesNotExistException;
|
import google.registry.flows.ResourceFlowUtils.ResourceDoesNotExistException;
|
||||||
import google.registry.flows.ResourceFlowUtils.ResourceNotOwnedException;
|
import google.registry.flows.ResourceFlowUtils.ResourceNotOwnedException;
|
||||||
|
@ -139,80 +140,101 @@ public class ContactTransferRejectFlowTest
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_badPassword() throws Exception {
|
public void testFailure_badPassword() throws Exception {
|
||||||
// Change the contact's password so it does not match the password in the file.
|
// Change the contact's password so it does not match the password in the file.
|
||||||
contact = persistResource(
|
contact =
|
||||||
contact.asBuilder()
|
persistResource(
|
||||||
|
contact
|
||||||
|
.asBuilder()
|
||||||
.setAuthInfo(ContactAuthInfo.create(PasswordAuth.create("badpassword")))
|
.setAuthInfo(ContactAuthInfo.create(PasswordAuth.create("badpassword")))
|
||||||
.build());
|
.build());
|
||||||
assertThrows(
|
EppException thrown =
|
||||||
|
expectThrows(
|
||||||
BadAuthInfoForResourceException.class,
|
BadAuthInfoForResourceException.class,
|
||||||
() -> doFailingTest("contact_transfer_reject_with_authinfo.xml"));
|
() -> doFailingTest("contact_transfer_reject_with_authinfo.xml"));
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_neverBeenTransferred() throws Exception {
|
public void testFailure_neverBeenTransferred() throws Exception {
|
||||||
changeTransferStatus(null);
|
changeTransferStatus(null);
|
||||||
assertThrows(
|
EppException thrown =
|
||||||
|
expectThrows(
|
||||||
NotPendingTransferException.class, () -> doFailingTest("contact_transfer_reject.xml"));
|
NotPendingTransferException.class, () -> doFailingTest("contact_transfer_reject.xml"));
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_clientApproved() throws Exception {
|
public void testFailure_clientApproved() throws Exception {
|
||||||
changeTransferStatus(TransferStatus.CLIENT_APPROVED);
|
changeTransferStatus(TransferStatus.CLIENT_APPROVED);
|
||||||
assertThrows(
|
EppException thrown =
|
||||||
|
expectThrows(
|
||||||
NotPendingTransferException.class, () -> doFailingTest("contact_transfer_reject.xml"));
|
NotPendingTransferException.class, () -> doFailingTest("contact_transfer_reject.xml"));
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_clientRejected() throws Exception {
|
public void testFailure_clientRejected() throws Exception {
|
||||||
changeTransferStatus(TransferStatus.CLIENT_REJECTED);
|
changeTransferStatus(TransferStatus.CLIENT_REJECTED);
|
||||||
assertThrows(
|
EppException thrown =
|
||||||
|
expectThrows(
|
||||||
NotPendingTransferException.class, () -> doFailingTest("contact_transfer_reject.xml"));
|
NotPendingTransferException.class, () -> doFailingTest("contact_transfer_reject.xml"));
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_clientCancelled() throws Exception {
|
public void testFailure_clientCancelled() throws Exception {
|
||||||
changeTransferStatus(TransferStatus.CLIENT_CANCELLED);
|
changeTransferStatus(TransferStatus.CLIENT_CANCELLED);
|
||||||
assertThrows(
|
EppException thrown =
|
||||||
|
expectThrows(
|
||||||
NotPendingTransferException.class, () -> doFailingTest("contact_transfer_reject.xml"));
|
NotPendingTransferException.class, () -> doFailingTest("contact_transfer_reject.xml"));
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_serverApproved() throws Exception {
|
public void testFailure_serverApproved() throws Exception {
|
||||||
changeTransferStatus(TransferStatus.SERVER_APPROVED);
|
changeTransferStatus(TransferStatus.SERVER_APPROVED);
|
||||||
assertThrows(
|
EppException thrown =
|
||||||
|
expectThrows(
|
||||||
NotPendingTransferException.class, () -> doFailingTest("contact_transfer_reject.xml"));
|
NotPendingTransferException.class, () -> doFailingTest("contact_transfer_reject.xml"));
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_serverCancelled() throws Exception {
|
public void testFailure_serverCancelled() throws Exception {
|
||||||
changeTransferStatus(TransferStatus.SERVER_CANCELLED);
|
changeTransferStatus(TransferStatus.SERVER_CANCELLED);
|
||||||
assertThrows(
|
EppException thrown =
|
||||||
|
expectThrows(
|
||||||
NotPendingTransferException.class, () -> doFailingTest("contact_transfer_reject.xml"));
|
NotPendingTransferException.class, () -> doFailingTest("contact_transfer_reject.xml"));
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_gainingClient() throws Exception {
|
public void testFailure_gainingClient() throws Exception {
|
||||||
setClientIdForFlow("NewRegistrar");
|
setClientIdForFlow("NewRegistrar");
|
||||||
assertThrows(
|
EppException thrown =
|
||||||
|
expectThrows(
|
||||||
ResourceNotOwnedException.class, () -> doFailingTest("contact_transfer_reject.xml"));
|
ResourceNotOwnedException.class, () -> doFailingTest("contact_transfer_reject.xml"));
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_unrelatedClient() throws Exception {
|
public void testFailure_unrelatedClient() throws Exception {
|
||||||
setClientIdForFlow("ClientZ");
|
setClientIdForFlow("ClientZ");
|
||||||
assertThrows(
|
EppException thrown =
|
||||||
|
expectThrows(
|
||||||
ResourceNotOwnedException.class, () -> doFailingTest("contact_transfer_reject.xml"));
|
ResourceNotOwnedException.class, () -> doFailingTest("contact_transfer_reject.xml"));
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_deletedContact() throws Exception {
|
public void testFailure_deletedContact() throws Exception {
|
||||||
contact = persistResource(
|
contact =
|
||||||
contact.asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build());
|
persistResource(contact.asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build());
|
||||||
ResourceDoesNotExistException thrown =
|
ResourceDoesNotExistException thrown =
|
||||||
expectThrows(
|
expectThrows(
|
||||||
ResourceDoesNotExistException.class,
|
ResourceDoesNotExistException.class,
|
||||||
() -> doFailingTest("contact_transfer_reject.xml"));
|
() -> doFailingTest("contact_transfer_reject.xml"));
|
||||||
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
|
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -223,6 +245,7 @@ public class ContactTransferRejectFlowTest
|
||||||
ResourceDoesNotExistException.class,
|
ResourceDoesNotExistException.class,
|
||||||
() -> doFailingTest("contact_transfer_reject.xml"));
|
() -> doFailingTest("contact_transfer_reject.xml"));
|
||||||
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
|
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -28,12 +28,13 @@ import static google.registry.testing.DatastoreHelper.deleteResource;
|
||||||
import static google.registry.testing.DatastoreHelper.getPollMessages;
|
import static google.registry.testing.DatastoreHelper.getPollMessages;
|
||||||
import static google.registry.testing.DatastoreHelper.persistActiveContact;
|
import static google.registry.testing.DatastoreHelper.persistActiveContact;
|
||||||
import static google.registry.testing.DatastoreHelper.persistResource;
|
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 static google.registry.testing.JUnitBackports.expectThrows;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
import com.googlecode.objectify.Key;
|
import com.googlecode.objectify.Key;
|
||||||
|
import google.registry.flows.EppException;
|
||||||
import google.registry.flows.ResourceFlowUtils.BadAuthInfoForResourceException;
|
import google.registry.flows.ResourceFlowUtils.BadAuthInfoForResourceException;
|
||||||
import google.registry.flows.ResourceFlowUtils.ResourceDoesNotExistException;
|
import google.registry.flows.ResourceFlowUtils.ResourceDoesNotExistException;
|
||||||
import google.registry.flows.exceptions.AlreadyPendingTransferException;
|
import google.registry.flows.exceptions.AlreadyPendingTransferException;
|
||||||
|
@ -156,20 +157,27 @@ public class ContactTransferRequestFlowTest
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_noAuthInfo() throws Exception {
|
public void testFailure_noAuthInfo() throws Exception {
|
||||||
assertThrows(
|
EppException thrown =
|
||||||
|
expectThrows(
|
||||||
MissingTransferRequestAuthInfoException.class,
|
MissingTransferRequestAuthInfoException.class,
|
||||||
() -> doFailingTest("contact_transfer_request_no_authinfo.xml"));
|
() -> doFailingTest("contact_transfer_request_no_authinfo.xml"));
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_badPassword() throws Exception {
|
public void testFailure_badPassword() throws Exception {
|
||||||
// Change the contact's password so it does not match the password in the file.
|
// Change the contact's password so it does not match the password in the file.
|
||||||
contact = persistResource(
|
contact =
|
||||||
contact.asBuilder()
|
persistResource(
|
||||||
|
contact
|
||||||
|
.asBuilder()
|
||||||
.setAuthInfo(ContactAuthInfo.create(PasswordAuth.create("badpassword")))
|
.setAuthInfo(ContactAuthInfo.create(PasswordAuth.create("badpassword")))
|
||||||
.build());
|
.build());
|
||||||
assertThrows(
|
EppException thrown =
|
||||||
BadAuthInfoForResourceException.class, () -> doFailingTest("contact_transfer_request.xml"));
|
expectThrows(
|
||||||
|
BadAuthInfoForResourceException.class,
|
||||||
|
() -> doFailingTest("contact_transfer_request.xml"));
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -204,33 +212,45 @@ public class ContactTransferRequestFlowTest
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_pending() throws Exception {
|
public void testFailure_pending() throws Exception {
|
||||||
contact = persistResource(
|
contact =
|
||||||
contact.asBuilder()
|
persistResource(
|
||||||
.setTransferData(contact.getTransferData().asBuilder()
|
contact
|
||||||
|
.asBuilder()
|
||||||
|
.setTransferData(
|
||||||
|
contact
|
||||||
|
.getTransferData()
|
||||||
|
.asBuilder()
|
||||||
.setTransferStatus(TransferStatus.PENDING)
|
.setTransferStatus(TransferStatus.PENDING)
|
||||||
.setPendingTransferExpirationTime(clock.nowUtc().plusDays(1))
|
.setPendingTransferExpirationTime(clock.nowUtc().plusDays(1))
|
||||||
.build())
|
.build())
|
||||||
.build());
|
.build());
|
||||||
assertThrows(
|
EppException thrown =
|
||||||
AlreadyPendingTransferException.class, () -> doFailingTest("contact_transfer_request.xml"));
|
expectThrows(
|
||||||
|
AlreadyPendingTransferException.class,
|
||||||
|
() -> doFailingTest("contact_transfer_request.xml"));
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_sponsoringClient() throws Exception {
|
public void testFailure_sponsoringClient() throws Exception {
|
||||||
setClientIdForFlow("TheRegistrar");
|
setClientIdForFlow("TheRegistrar");
|
||||||
assertThrows(
|
EppException thrown =
|
||||||
ObjectAlreadySponsoredException.class, () -> doFailingTest("contact_transfer_request.xml"));
|
expectThrows(
|
||||||
|
ObjectAlreadySponsoredException.class,
|
||||||
|
() -> doFailingTest("contact_transfer_request.xml"));
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_deletedContact() throws Exception {
|
public void testFailure_deletedContact() throws Exception {
|
||||||
contact = persistResource(
|
contact =
|
||||||
contact.asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build());
|
persistResource(contact.asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build());
|
||||||
ResourceDoesNotExistException thrown =
|
ResourceDoesNotExistException thrown =
|
||||||
expectThrows(
|
expectThrows(
|
||||||
ResourceDoesNotExistException.class,
|
ResourceDoesNotExistException.class,
|
||||||
() -> doFailingTest("contact_transfer_request.xml"));
|
() -> doFailingTest("contact_transfer_request.xml"));
|
||||||
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
|
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -241,39 +261,45 @@ public class ContactTransferRequestFlowTest
|
||||||
ResourceDoesNotExistException.class,
|
ResourceDoesNotExistException.class,
|
||||||
() -> doFailingTest("contact_transfer_request.xml"));
|
() -> doFailingTest("contact_transfer_request.xml"));
|
||||||
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
|
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_clientTransferProhibited() throws Exception {
|
public void testFailure_clientTransferProhibited() throws Exception {
|
||||||
contact = persistResource(
|
contact =
|
||||||
|
persistResource(
|
||||||
contact.asBuilder().addStatusValue(StatusValue.CLIENT_TRANSFER_PROHIBITED).build());
|
contact.asBuilder().addStatusValue(StatusValue.CLIENT_TRANSFER_PROHIBITED).build());
|
||||||
ResourceStatusProhibitsOperationException thrown =
|
ResourceStatusProhibitsOperationException thrown =
|
||||||
expectThrows(
|
expectThrows(
|
||||||
ResourceStatusProhibitsOperationException.class,
|
ResourceStatusProhibitsOperationException.class,
|
||||||
() -> doFailingTest("contact_transfer_request.xml"));
|
() -> doFailingTest("contact_transfer_request.xml"));
|
||||||
assertThat(thrown).hasMessageThat().contains("clientTransferProhibited");
|
assertThat(thrown).hasMessageThat().contains("clientTransferProhibited");
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_serverTransferProhibited() throws Exception {
|
public void testFailure_serverTransferProhibited() throws Exception {
|
||||||
contact = persistResource(
|
contact =
|
||||||
|
persistResource(
|
||||||
contact.asBuilder().addStatusValue(StatusValue.SERVER_TRANSFER_PROHIBITED).build());
|
contact.asBuilder().addStatusValue(StatusValue.SERVER_TRANSFER_PROHIBITED).build());
|
||||||
ResourceStatusProhibitsOperationException thrown =
|
ResourceStatusProhibitsOperationException thrown =
|
||||||
expectThrows(
|
expectThrows(
|
||||||
ResourceStatusProhibitsOperationException.class,
|
ResourceStatusProhibitsOperationException.class,
|
||||||
() -> doFailingTest("contact_transfer_request.xml"));
|
() -> doFailingTest("contact_transfer_request.xml"));
|
||||||
assertThat(thrown).hasMessageThat().contains("serverTransferProhibited");
|
assertThat(thrown).hasMessageThat().contains("serverTransferProhibited");
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_pendingDelete() throws Exception {
|
public void testFailure_pendingDelete() throws Exception {
|
||||||
contact = persistResource(
|
contact =
|
||||||
contact.asBuilder().addStatusValue(StatusValue.PENDING_DELETE).build());
|
persistResource(contact.asBuilder().addStatusValue(StatusValue.PENDING_DELETE).build());
|
||||||
ResourceStatusProhibitsOperationException thrown =
|
ResourceStatusProhibitsOperationException thrown =
|
||||||
expectThrows(
|
expectThrows(
|
||||||
ResourceStatusProhibitsOperationException.class,
|
ResourceStatusProhibitsOperationException.class,
|
||||||
() -> doFailingTest("contact_transfer_request.xml"));
|
() -> doFailingTest("contact_transfer_request.xml"));
|
||||||
assertThat(thrown).hasMessageThat().contains("pendingDelete");
|
assertThat(thrown).hasMessageThat().contains("pendingDelete");
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -21,11 +21,12 @@ import static google.registry.testing.DatastoreHelper.newContactResource;
|
||||||
import static google.registry.testing.DatastoreHelper.persistActiveContact;
|
import static google.registry.testing.DatastoreHelper.persistActiveContact;
|
||||||
import static google.registry.testing.DatastoreHelper.persistDeletedContact;
|
import static google.registry.testing.DatastoreHelper.persistDeletedContact;
|
||||||
import static google.registry.testing.DatastoreHelper.persistResource;
|
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 static google.registry.testing.JUnitBackports.expectThrows;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
import google.registry.flows.EppException;
|
||||||
import google.registry.flows.ResourceFlowTestCase;
|
import google.registry.flows.ResourceFlowTestCase;
|
||||||
import google.registry.flows.ResourceFlowUtils.AddRemoveSameValueException;
|
import google.registry.flows.ResourceFlowUtils.AddRemoveSameValueException;
|
||||||
import google.registry.flows.ResourceFlowUtils.ResourceDoesNotExistException;
|
import google.registry.flows.ResourceFlowUtils.ResourceDoesNotExistException;
|
||||||
|
@ -259,6 +260,7 @@ public class ContactUpdateFlowTest
|
||||||
ResourceDoesNotExistException thrown =
|
ResourceDoesNotExistException thrown =
|
||||||
expectThrows(ResourceDoesNotExistException.class, this::runFlow);
|
expectThrows(ResourceDoesNotExistException.class, this::runFlow);
|
||||||
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
|
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -267,13 +269,15 @@ public class ContactUpdateFlowTest
|
||||||
ResourceDoesNotExistException thrown =
|
ResourceDoesNotExistException thrown =
|
||||||
expectThrows(ResourceDoesNotExistException.class, this::runFlow);
|
expectThrows(ResourceDoesNotExistException.class, this::runFlow);
|
||||||
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
|
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_statusValueNotClientSettable() throws Exception {
|
public void testFailure_statusValueNotClientSettable() throws Exception {
|
||||||
setEppInput("contact_update_prohibited_status.xml");
|
setEppInput("contact_update_prohibited_status.xml");
|
||||||
persistActiveContact(getUniqueIdFromCommand());
|
persistActiveContact(getUniqueIdFromCommand());
|
||||||
assertThrows(StatusNotClientSettableException.class, this::runFlow);
|
EppException thrown = expectThrows(StatusNotClientSettableException.class, this::runFlow);
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -282,16 +286,15 @@ public class ContactUpdateFlowTest
|
||||||
persistActiveContact(getUniqueIdFromCommand());
|
persistActiveContact(getUniqueIdFromCommand());
|
||||||
clock.advanceOneMilli();
|
clock.advanceOneMilli();
|
||||||
runFlowAssertResponse(
|
runFlowAssertResponse(
|
||||||
CommitMode.LIVE,
|
CommitMode.LIVE, UserPrivileges.SUPERUSER, loadFile("contact_update_response.xml"));
|
||||||
UserPrivileges.SUPERUSER,
|
|
||||||
loadFile("contact_update_response.xml"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_unauthorizedClient() throws Exception {
|
public void testFailure_unauthorizedClient() throws Exception {
|
||||||
sessionMetadata.setClientId("NewRegistrar");
|
sessionMetadata.setClientId("NewRegistrar");
|
||||||
persistActiveContact(getUniqueIdFromCommand());
|
persistActiveContact(getUniqueIdFromCommand());
|
||||||
assertThrows(ResourceNotOwnedException.class, this::runFlow);
|
EppException thrown = expectThrows(ResourceNotOwnedException.class, this::runFlow);
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -307,11 +310,13 @@ public class ContactUpdateFlowTest
|
||||||
public void testSuccess_clientUpdateProhibited_removed() throws Exception {
|
public void testSuccess_clientUpdateProhibited_removed() throws Exception {
|
||||||
setEppInput("contact_update_remove_client_update_prohibited.xml");
|
setEppInput("contact_update_remove_client_update_prohibited.xml");
|
||||||
persistResource(
|
persistResource(
|
||||||
newContactResource(getUniqueIdFromCommand()).asBuilder()
|
newContactResource(getUniqueIdFromCommand())
|
||||||
|
.asBuilder()
|
||||||
.setStatusValues(ImmutableSet.of(StatusValue.CLIENT_UPDATE_PROHIBITED))
|
.setStatusValues(ImmutableSet.of(StatusValue.CLIENT_UPDATE_PROHIBITED))
|
||||||
.build());
|
.build());
|
||||||
doSuccessfulTest();
|
doSuccessfulTest();
|
||||||
assertAboutContacts().that(reloadResourceByForeignKey())
|
assertAboutContacts()
|
||||||
|
.that(reloadResourceByForeignKey())
|
||||||
.doesNotHaveStatusValue(StatusValue.CLIENT_UPDATE_PROHIBITED);
|
.doesNotHaveStatusValue(StatusValue.CLIENT_UPDATE_PROHIBITED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -319,48 +324,56 @@ public class ContactUpdateFlowTest
|
||||||
public void testSuccess_superuserClientUpdateProhibited_notRemoved() throws Exception {
|
public void testSuccess_superuserClientUpdateProhibited_notRemoved() throws Exception {
|
||||||
setEppInput("contact_update_prohibited_status.xml");
|
setEppInput("contact_update_prohibited_status.xml");
|
||||||
persistResource(
|
persistResource(
|
||||||
newContactResource(getUniqueIdFromCommand()).asBuilder()
|
newContactResource(getUniqueIdFromCommand())
|
||||||
|
.asBuilder()
|
||||||
.setStatusValues(ImmutableSet.of(StatusValue.CLIENT_UPDATE_PROHIBITED))
|
.setStatusValues(ImmutableSet.of(StatusValue.CLIENT_UPDATE_PROHIBITED))
|
||||||
.build());
|
.build());
|
||||||
clock.advanceOneMilli();
|
clock.advanceOneMilli();
|
||||||
runFlowAssertResponse(
|
runFlowAssertResponse(
|
||||||
CommitMode.LIVE,
|
CommitMode.LIVE, UserPrivileges.SUPERUSER, loadFile("contact_update_response.xml"));
|
||||||
UserPrivileges.SUPERUSER,
|
assertAboutContacts()
|
||||||
loadFile("contact_update_response.xml"));
|
.that(reloadResourceByForeignKey())
|
||||||
assertAboutContacts().that(reloadResourceByForeignKey())
|
.hasStatusValue(StatusValue.CLIENT_UPDATE_PROHIBITED)
|
||||||
.hasStatusValue(StatusValue.CLIENT_UPDATE_PROHIBITED).and()
|
.and()
|
||||||
.hasStatusValue(StatusValue.SERVER_DELETE_PROHIBITED);
|
.hasStatusValue(StatusValue.SERVER_DELETE_PROHIBITED);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_clientUpdateProhibited_notRemoved() throws Exception {
|
public void testFailure_clientUpdateProhibited_notRemoved() throws Exception {
|
||||||
persistResource(
|
persistResource(
|
||||||
newContactResource(getUniqueIdFromCommand()).asBuilder()
|
newContactResource(getUniqueIdFromCommand())
|
||||||
|
.asBuilder()
|
||||||
.setStatusValues(ImmutableSet.of(StatusValue.CLIENT_UPDATE_PROHIBITED))
|
.setStatusValues(ImmutableSet.of(StatusValue.CLIENT_UPDATE_PROHIBITED))
|
||||||
.build());
|
.build());
|
||||||
assertThrows(ResourceHasClientUpdateProhibitedException.class, this::runFlow);
|
EppException thrown =
|
||||||
|
expectThrows(ResourceHasClientUpdateProhibitedException.class, this::runFlow);
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_serverUpdateProhibited() throws Exception {
|
public void testFailure_serverUpdateProhibited() throws Exception {
|
||||||
persistResource(
|
persistResource(
|
||||||
newContactResource(getUniqueIdFromCommand()).asBuilder()
|
newContactResource(getUniqueIdFromCommand())
|
||||||
|
.asBuilder()
|
||||||
.setStatusValues(ImmutableSet.of(StatusValue.SERVER_UPDATE_PROHIBITED))
|
.setStatusValues(ImmutableSet.of(StatusValue.SERVER_UPDATE_PROHIBITED))
|
||||||
.build());
|
.build());
|
||||||
ResourceStatusProhibitsOperationException thrown =
|
ResourceStatusProhibitsOperationException thrown =
|
||||||
expectThrows(ResourceStatusProhibitsOperationException.class, this::runFlow);
|
expectThrows(ResourceStatusProhibitsOperationException.class, this::runFlow);
|
||||||
assertThat(thrown).hasMessageThat().contains("serverUpdateProhibited");
|
assertThat(thrown).hasMessageThat().contains("serverUpdateProhibited");
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_pendingDeleteProhibited() throws Exception {
|
public void testFailure_pendingDeleteProhibited() throws Exception {
|
||||||
persistResource(
|
persistResource(
|
||||||
newContactResource(getUniqueIdFromCommand()).asBuilder()
|
newContactResource(getUniqueIdFromCommand())
|
||||||
|
.asBuilder()
|
||||||
.setStatusValues(ImmutableSet.of(StatusValue.PENDING_DELETE))
|
.setStatusValues(ImmutableSet.of(StatusValue.PENDING_DELETE))
|
||||||
.build());
|
.build());
|
||||||
ResourceStatusProhibitsOperationException thrown =
|
ResourceStatusProhibitsOperationException thrown =
|
||||||
expectThrows(ResourceStatusProhibitsOperationException.class, this::runFlow);
|
expectThrows(ResourceStatusProhibitsOperationException.class, this::runFlow);
|
||||||
assertThat(thrown).hasMessageThat().contains("pendingDelete");
|
assertThat(thrown).hasMessageThat().contains("pendingDelete");
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -373,21 +386,26 @@ public class ContactUpdateFlowTest
|
||||||
public void testFailure_nonAsciiInIntAddress() throws Exception {
|
public void testFailure_nonAsciiInIntAddress() throws Exception {
|
||||||
setEppInput("contact_update_hebrew_int.xml");
|
setEppInput("contact_update_hebrew_int.xml");
|
||||||
persistActiveContact(getUniqueIdFromCommand());
|
persistActiveContact(getUniqueIdFromCommand());
|
||||||
assertThrows(BadInternationalizedPostalInfoException.class, this::runFlow);
|
EppException thrown =
|
||||||
|
expectThrows(BadInternationalizedPostalInfoException.class, this::runFlow);
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_declineDisclosure() throws Exception {
|
public void testFailure_declineDisclosure() throws Exception {
|
||||||
setEppInput("contact_update_decline_disclosure.xml");
|
setEppInput("contact_update_decline_disclosure.xml");
|
||||||
persistActiveContact(getUniqueIdFromCommand());
|
persistActiveContact(getUniqueIdFromCommand());
|
||||||
assertThrows(DeclineContactDisclosureFieldDisallowedPolicyException.class, this::runFlow);
|
EppException thrown =
|
||||||
|
expectThrows(DeclineContactDisclosureFieldDisallowedPolicyException.class, this::runFlow);
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_addRemoveSameValue() throws Exception {
|
public void testFailure_addRemoveSameValue() throws Exception {
|
||||||
setEppInput("contact_update_add_remove_same.xml");
|
setEppInput("contact_update_add_remove_same.xml");
|
||||||
persistActiveContact(getUniqueIdFromCommand());
|
persistActiveContact(getUniqueIdFromCommand());
|
||||||
assertThrows(AddRemoveSameValueException.class, this::runFlow);
|
EppException thrown = expectThrows(AddRemoveSameValueException.class, this::runFlow);
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -30,7 +30,7 @@ import static google.registry.testing.DatastoreHelper.persistReservedList;
|
||||||
import static google.registry.testing.DatastoreHelper.persistResource;
|
import static google.registry.testing.DatastoreHelper.persistResource;
|
||||||
import static google.registry.testing.DomainApplicationSubject.assertAboutApplications;
|
import static google.registry.testing.DomainApplicationSubject.assertAboutApplications;
|
||||||
import static google.registry.testing.DomainResourceSubject.assertAboutDomains;
|
import static google.registry.testing.DomainResourceSubject.assertAboutDomains;
|
||||||
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.testing.JUnitBackports.expectThrows;
|
||||||
import static google.registry.testing.TaskQueueHelper.assertDnsTasksEnqueued;
|
import static google.registry.testing.TaskQueueHelper.assertDnsTasksEnqueued;
|
||||||
import static google.registry.testing.TaskQueueHelper.assertNoDnsTasksEnqueued;
|
import static google.registry.testing.TaskQueueHelper.assertNoDnsTasksEnqueued;
|
||||||
|
@ -43,6 +43,7 @@ import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.googlecode.objectify.Key;
|
import com.googlecode.objectify.Key;
|
||||||
|
import google.registry.flows.EppException;
|
||||||
import google.registry.flows.ResourceFlowTestCase;
|
import google.registry.flows.ResourceFlowTestCase;
|
||||||
import google.registry.flows.domain.DomainAllocateFlow.HasFinalStatusException;
|
import google.registry.flows.domain.DomainAllocateFlow.HasFinalStatusException;
|
||||||
import google.registry.flows.domain.DomainAllocateFlow.MissingApplicationException;
|
import google.registry.flows.domain.DomainAllocateFlow.MissingApplicationException;
|
||||||
|
@ -258,6 +259,7 @@ public class DomainAllocateFlowTest
|
||||||
NameserversNotAllowedForTldException thrown =
|
NameserversNotAllowedForTldException thrown =
|
||||||
expectThrows(NameserversNotAllowedForTldException.class, this::runFlowAsSuperuser);
|
expectThrows(NameserversNotAllowedForTldException.class, this::runFlowAsSuperuser);
|
||||||
assertThat(thrown).hasMessageThat().contains("ns1.example.net");
|
assertThat(thrown).hasMessageThat().contains("ns1.example.net");
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -273,6 +275,7 @@ public class DomainAllocateFlowTest
|
||||||
RegistrantNotAllowedException thrown =
|
RegistrantNotAllowedException thrown =
|
||||||
expectThrows(RegistrantNotAllowedException.class, this::runFlowAsSuperuser);
|
expectThrows(RegistrantNotAllowedException.class, this::runFlowAsSuperuser);
|
||||||
assertThat(thrown).hasMessageThat().contains("jd1234");
|
assertThat(thrown).hasMessageThat().contains("jd1234");
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -285,9 +288,11 @@ public class DomainAllocateFlowTest
|
||||||
.setAllowedRegistrantContactIds(ImmutableSet.of("jd1234"))
|
.setAllowedRegistrantContactIds(ImmutableSet.of("jd1234"))
|
||||||
.setAllowedFullyQualifiedHostNames(ImmutableSet.of("ns1.example.net, ns2.example.net"))
|
.setAllowedFullyQualifiedHostNames(ImmutableSet.of("ns1.example.net, ns2.example.net"))
|
||||||
.build());
|
.build());
|
||||||
assertThrows(
|
EppException thrown =
|
||||||
|
expectThrows(
|
||||||
NameserversNotSpecifiedForTldWithNameserverWhitelistException.class,
|
NameserversNotSpecifiedForTldWithNameserverWhitelistException.class,
|
||||||
this::runFlowAsSuperuser);
|
this::runFlowAsSuperuser);
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -319,6 +324,7 @@ public class DomainAllocateFlowTest
|
||||||
NameserversNotAllowedForDomainException thrown =
|
NameserversNotAllowedForDomainException thrown =
|
||||||
expectThrows(NameserversNotAllowedForDomainException.class, this::runFlowAsSuperuser);
|
expectThrows(NameserversNotAllowedForDomainException.class, this::runFlowAsSuperuser);
|
||||||
assertThat(thrown).hasMessageThat().contains("ns1.example.net");
|
assertThat(thrown).hasMessageThat().contains("ns1.example.net");
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -333,9 +339,11 @@ public class DomainAllocateFlowTest
|
||||||
"reserved",
|
"reserved",
|
||||||
"example-one,NAMESERVER_RESTRICTED," + "ns2.example.net:ns3.example.net"))
|
"example-one,NAMESERVER_RESTRICTED," + "ns2.example.net:ns3.example.net"))
|
||||||
.build());
|
.build());
|
||||||
assertThrows(
|
EppException thrown =
|
||||||
|
expectThrows(
|
||||||
NameserversNotSpecifiedForNameserverRestrictedDomainException.class,
|
NameserversNotSpecifiedForNameserverRestrictedDomainException.class,
|
||||||
this::runFlowAsSuperuser);
|
this::runFlowAsSuperuser);
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -373,6 +381,7 @@ public class DomainAllocateFlowTest
|
||||||
NameserversNotAllowedForDomainException thrown =
|
NameserversNotAllowedForDomainException thrown =
|
||||||
expectThrows(NameserversNotAllowedForDomainException.class, this::runFlowAsSuperuser);
|
expectThrows(NameserversNotAllowedForDomainException.class, this::runFlowAsSuperuser);
|
||||||
assertThat(thrown).hasMessageThat().contains("ns1.example.net");
|
assertThat(thrown).hasMessageThat().contains("ns1.example.net");
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -392,6 +401,7 @@ public class DomainAllocateFlowTest
|
||||||
NameserversNotAllowedForTldException thrown =
|
NameserversNotAllowedForTldException thrown =
|
||||||
expectThrows(NameserversNotAllowedForTldException.class, this::runFlowAsSuperuser);
|
expectThrows(NameserversNotAllowedForTldException.class, this::runFlowAsSuperuser);
|
||||||
assertThat(thrown).hasMessageThat().contains("ns1.example.net");
|
assertThat(thrown).hasMessageThat().contains("ns1.example.net");
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -404,7 +414,9 @@ public class DomainAllocateFlowTest
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_nonDefaultAddGracePeriod() throws Exception {
|
public void testSuccess_nonDefaultAddGracePeriod() throws Exception {
|
||||||
setupDomainApplication("tld", TldState.QUIET_PERIOD);
|
setupDomainApplication("tld", TldState.QUIET_PERIOD);
|
||||||
persistResource(Registry.get("tld").asBuilder()
|
persistResource(
|
||||||
|
Registry.get("tld")
|
||||||
|
.asBuilder()
|
||||||
.setAddGracePeriodLength(Duration.standardMinutes(6))
|
.setAddGracePeriodLength(Duration.standardMinutes(6))
|
||||||
.build());
|
.build());
|
||||||
doSuccessfulTest(2);
|
doSuccessfulTest(2);
|
||||||
|
@ -413,7 +425,9 @@ public class DomainAllocateFlowTest
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_nonDefaultSunrushAddGracePeriod() throws Exception {
|
public void testSuccess_nonDefaultSunrushAddGracePeriod() throws Exception {
|
||||||
setupDomainApplication("tld", TldState.QUIET_PERIOD);
|
setupDomainApplication("tld", TldState.QUIET_PERIOD);
|
||||||
persistResource(Registry.get("tld").asBuilder()
|
persistResource(
|
||||||
|
Registry.get("tld")
|
||||||
|
.asBuilder()
|
||||||
.setSunrushAddGracePeriodLength(Duration.standardMinutes(9))
|
.setSunrushAddGracePeriodLength(Duration.standardMinutes(9))
|
||||||
.build());
|
.build());
|
||||||
doSuccessfulTest(2);
|
doSuccessfulTest(2);
|
||||||
|
@ -439,9 +453,10 @@ public class DomainAllocateFlowTest
|
||||||
setupDomainApplication("tld", TldState.QUIET_PERIOD);
|
setupDomainApplication("tld", TldState.QUIET_PERIOD);
|
||||||
setEppInput("domain_allocate_dsdata.xml");
|
setEppInput("domain_allocate_dsdata.xml");
|
||||||
doSuccessfulTest(2);
|
doSuccessfulTest(2);
|
||||||
assertAboutDomains().that(reloadResourceByForeignKey())
|
assertAboutDomains()
|
||||||
.hasExactlyDsData(DelegationSignerData.create(
|
.that(reloadResourceByForeignKey())
|
||||||
12345, 3, 1, base16().decode("49FD46E6C4B45C55D4AC")));
|
.hasExactlyDsData(
|
||||||
|
DelegationSignerData.create(12345, 3, 1, base16().decode("49FD46E6C4B45C55D4AC")));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -466,8 +481,10 @@ public class DomainAllocateFlowTest
|
||||||
private void doSuccessfulClaimsNoticeTest() throws Exception {
|
private void doSuccessfulClaimsNoticeTest() throws Exception {
|
||||||
setEppInput("domain_allocate_claims_notice.xml");
|
setEppInput("domain_allocate_claims_notice.xml");
|
||||||
runFlowAsSuperuser();
|
runFlowAsSuperuser();
|
||||||
assertAboutDomains().that(getOnlyGlobalResource(DomainResource.class))
|
assertAboutDomains()
|
||||||
.hasLaunchNotice(LaunchNotice.create(
|
.that(getOnlyGlobalResource(DomainResource.class))
|
||||||
|
.hasLaunchNotice(
|
||||||
|
LaunchNotice.create(
|
||||||
"370d0b7c9223372036854775807",
|
"370d0b7c9223372036854775807",
|
||||||
"tmch",
|
"tmch",
|
||||||
DateTime.parse("2011-08-16T09:00:00.0Z"),
|
DateTime.parse("2011-08-16T09:00:00.0Z"),
|
||||||
|
@ -478,12 +495,12 @@ public class DomainAllocateFlowTest
|
||||||
public void testSuccess_claimsNotice() throws Exception {
|
public void testSuccess_claimsNotice() throws Exception {
|
||||||
setupDomainApplication("tld", TldState.QUIET_PERIOD);
|
setupDomainApplication("tld", TldState.QUIET_PERIOD);
|
||||||
doSuccessfulClaimsNoticeTest();
|
doSuccessfulClaimsNoticeTest();
|
||||||
String expectedCsv = String.format(
|
String expectedCsv =
|
||||||
|
String.format(
|
||||||
"%s,example-one.tld,370d0b7c9223372036854775807,1,"
|
"%s,example-one.tld,370d0b7c9223372036854775807,1,"
|
||||||
+ "2010-09-16T10:00:00.000Z,2010-07-16T09:00:00.000Z,2010-08-16T10:00:00.000Z",
|
+ "2010-09-16T10:00:00.000Z,2010-07-16T09:00:00.000Z,2010-08-16T10:00:00.000Z",
|
||||||
reloadResourceByForeignKey().getRepoId());
|
reloadResourceByForeignKey().getRepoId());
|
||||||
assertTasksEnqueued(
|
assertTasksEnqueued("lordn-claims", new TaskMatcher().payload(expectedCsv).tag("tld"));
|
||||||
"lordn-claims", new TaskMatcher().payload(expectedCsv).tag("tld"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -491,7 +508,8 @@ public class DomainAllocateFlowTest
|
||||||
setupDomainApplication("tld", TldState.QUIET_PERIOD);
|
setupDomainApplication("tld", TldState.QUIET_PERIOD);
|
||||||
clock.setTo(DateTime.parse("2011-08-17T09:00:00.0Z"));
|
clock.setTo(DateTime.parse("2011-08-17T09:00:00.0Z"));
|
||||||
doSuccessfulClaimsNoticeTest();
|
doSuccessfulClaimsNoticeTest();
|
||||||
String expectedCsv = String.format(
|
String expectedCsv =
|
||||||
|
String.format(
|
||||||
"%s,example-one.tld,370d0b7c9223372036854775807,1,"
|
"%s,example-one.tld,370d0b7c9223372036854775807,1,"
|
||||||
+ "2011-08-17T09:00:00.000Z,2010-07-16T09:00:00.000Z,2010-08-16T10:00:00.000Z",
|
+ "2011-08-17T09:00:00.000Z,2010-07-16T09:00:00.000Z,2010-08-16T10:00:00.000Z",
|
||||||
reloadResourceByForeignKey().getRepoId());
|
reloadResourceByForeignKey().getRepoId());
|
||||||
|
@ -505,11 +523,11 @@ public class DomainAllocateFlowTest
|
||||||
doSuccessfulTest(2);
|
doSuccessfulTest(2);
|
||||||
DomainResource domain = getOnlyGlobalResource(DomainResource.class);
|
DomainResource domain = getOnlyGlobalResource(DomainResource.class);
|
||||||
assertThat(domain.getSmdId()).isEqualTo(SMD_ID);
|
assertThat(domain.getSmdId()).isEqualTo(SMD_ID);
|
||||||
String expectedCsv = String.format(
|
String expectedCsv =
|
||||||
|
String.format(
|
||||||
"%s,example-one.tld,1-1,1,2010-09-16T10:00:00.000Z,2010-08-16T10:00:00.000Z",
|
"%s,example-one.tld,1-1,1,2010-09-16T10:00:00.000Z,2010-08-16T10:00:00.000Z",
|
||||||
domain.getRepoId());
|
domain.getRepoId());
|
||||||
assertTasksEnqueued(
|
assertTasksEnqueued("lordn-sunrise", new TaskMatcher().payload(expectedCsv).tag("tld"));
|
||||||
"lordn-sunrise", new TaskMatcher().payload(expectedCsv).tag("tld"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -575,7 +593,9 @@ public class DomainAllocateFlowTest
|
||||||
public void testFailure_alreadyExists() throws Exception {
|
public void testFailure_alreadyExists() throws Exception {
|
||||||
setupDomainApplication("tld", TldState.QUIET_PERIOD);
|
setupDomainApplication("tld", TldState.QUIET_PERIOD);
|
||||||
persistActiveDomain(getUniqueIdFromCommand());
|
persistActiveDomain(getUniqueIdFromCommand());
|
||||||
assertThrows(ResourceAlreadyExistsException.class, this::runFlowAsSuperuser);
|
EppException thrown =
|
||||||
|
expectThrows(ResourceAlreadyExistsException.class, this::runFlowAsSuperuser);
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -610,32 +630,34 @@ public class DomainAllocateFlowTest
|
||||||
public void testFailure_applicationDeleted() throws Exception {
|
public void testFailure_applicationDeleted() throws Exception {
|
||||||
setupDomainApplication("tld", TldState.QUIET_PERIOD);
|
setupDomainApplication("tld", TldState.QUIET_PERIOD);
|
||||||
persistResource(application.asBuilder().setDeletionTime(clock.nowUtc()).build());
|
persistResource(application.asBuilder().setDeletionTime(clock.nowUtc()).build());
|
||||||
assertThrows(MissingApplicationException.class, this::runFlowAsSuperuser);
|
EppException thrown = expectThrows(MissingApplicationException.class, this::runFlowAsSuperuser);
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_applicationRejected() throws Exception {
|
public void testFailure_applicationRejected() throws Exception {
|
||||||
setupDomainApplication("tld", TldState.QUIET_PERIOD);
|
setupDomainApplication("tld", TldState.QUIET_PERIOD);
|
||||||
persistResource(application.asBuilder()
|
persistResource(
|
||||||
.setApplicationStatus(ApplicationStatus.REJECTED)
|
application.asBuilder().setApplicationStatus(ApplicationStatus.REJECTED).build());
|
||||||
.build());
|
EppException thrown = expectThrows(HasFinalStatusException.class, this::runFlowAsSuperuser);
|
||||||
assertThrows(HasFinalStatusException.class, this::runFlowAsSuperuser);
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_applicationAllocated() throws Exception {
|
public void testFailure_applicationAllocated() throws Exception {
|
||||||
setupDomainApplication("tld", TldState.QUIET_PERIOD);
|
setupDomainApplication("tld", TldState.QUIET_PERIOD);
|
||||||
persistResource(application.asBuilder()
|
persistResource(
|
||||||
.setApplicationStatus(ApplicationStatus.ALLOCATED)
|
application.asBuilder().setApplicationStatus(ApplicationStatus.ALLOCATED).build());
|
||||||
.build());
|
EppException thrown = expectThrows(HasFinalStatusException.class, this::runFlowAsSuperuser);
|
||||||
assertThrows(HasFinalStatusException.class, this::runFlowAsSuperuser);
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_applicationDoesNotExist() throws Exception {
|
public void testFailure_applicationDoesNotExist() throws Exception {
|
||||||
setupDomainApplication("tld", TldState.QUIET_PERIOD);
|
setupDomainApplication("tld", TldState.QUIET_PERIOD);
|
||||||
setEppInput("domain_allocate_bad_application_roid.xml");
|
setEppInput("domain_allocate_bad_application_roid.xml");
|
||||||
assertThrows(MissingApplicationException.class, this::runFlowAsSuperuser);
|
EppException thrown = expectThrows(MissingApplicationException.class, this::runFlowAsSuperuser);
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -644,16 +666,20 @@ public class DomainAllocateFlowTest
|
||||||
clock.advanceOneMilli();
|
clock.advanceOneMilli();
|
||||||
setEppInput("domain_allocate_no_nameservers.xml");
|
setEppInput("domain_allocate_no_nameservers.xml");
|
||||||
assertTransactionalFlow(true);
|
assertTransactionalFlow(true);
|
||||||
assertThrows(
|
EppException thrown =
|
||||||
|
expectThrows(
|
||||||
OnlySuperuserCanAllocateException.class,
|
OnlySuperuserCanAllocateException.class,
|
||||||
() -> runFlow(CommitMode.LIVE, UserPrivileges.NORMAL));
|
() -> runFlow(CommitMode.LIVE, UserPrivileges.NORMAL));
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_max10Years() throws Exception {
|
public void testFailure_max10Years() throws Exception {
|
||||||
setupDomainApplication("tld", TldState.QUIET_PERIOD);
|
setupDomainApplication("tld", TldState.QUIET_PERIOD);
|
||||||
setEppInput("domain_allocate_11_years.xml");
|
setEppInput("domain_allocate_11_years.xml");
|
||||||
assertThrows(ExceedsMaxRegistrationYearsException.class, this::runFlowAsSuperuser);
|
EppException thrown =
|
||||||
|
expectThrows(ExceedsMaxRegistrationYearsException.class, this::runFlowAsSuperuser);
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -678,7 +704,8 @@ public class DomainAllocateFlowTest
|
||||||
DomainResource domain = reloadResourceByForeignKey();
|
DomainResource domain = reloadResourceByForeignKey();
|
||||||
HistoryEntry historyEntry =
|
HistoryEntry historyEntry =
|
||||||
getOnlyHistoryEntryOfType(domain, HistoryEntry.Type.DOMAIN_ALLOCATE);
|
getOnlyHistoryEntryOfType(domain, HistoryEntry.Type.DOMAIN_ALLOCATE);
|
||||||
assertThat(historyEntry.getDomainTransactionRecords()).containsExactly(
|
assertThat(historyEntry.getDomainTransactionRecords())
|
||||||
|
.containsExactly(
|
||||||
DomainTransactionRecord.create(
|
DomainTransactionRecord.create(
|
||||||
"tld",
|
"tld",
|
||||||
historyEntry.getModificationTime().plusMinutes(9),
|
historyEntry.getModificationTime().plusMinutes(9),
|
||||||
|
|
|
@ -20,9 +20,11 @@ import static google.registry.testing.DatastoreHelper.newDomainResource;
|
||||||
import static google.registry.testing.DatastoreHelper.persistActiveContact;
|
import static google.registry.testing.DatastoreHelper.persistActiveContact;
|
||||||
import static google.registry.testing.DatastoreHelper.persistActiveHost;
|
import static google.registry.testing.DatastoreHelper.persistActiveHost;
|
||||||
import static google.registry.testing.DatastoreHelper.persistResource;
|
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.ImmutableList;
|
||||||
|
import google.registry.flows.EppException;
|
||||||
import google.registry.flows.FlowTestCase;
|
import google.registry.flows.FlowTestCase;
|
||||||
import google.registry.flows.poll.PollRequestFlow.UnexpectedMessageIdException;
|
import google.registry.flows.poll.PollRequestFlow.UnexpectedMessageIdException;
|
||||||
import google.registry.model.contact.ContactResource;
|
import google.registry.model.contact.ContactResource;
|
||||||
|
@ -221,6 +223,7 @@ public class PollRequestFlowTest extends FlowTestCase<PollRequestFlow> {
|
||||||
public void testFailure_messageIdProvided() throws Exception {
|
public void testFailure_messageIdProvided() throws Exception {
|
||||||
setEppInput("poll_with_id.xml");
|
setEppInput("poll_with_id.xml");
|
||||||
assertTransactionalFlow(false);
|
assertTransactionalFlow(false);
|
||||||
assertThrows(UnexpectedMessageIdException.class, this::runFlow);
|
EppException thrown = expectThrows(UnexpectedMessageIdException.class, this::runFlow);
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,8 +17,10 @@ package google.registry.flows.session;
|
||||||
import static google.registry.testing.DatastoreHelper.deleteResource;
|
import static google.registry.testing.DatastoreHelper.deleteResource;
|
||||||
import static google.registry.testing.DatastoreHelper.loadRegistrar;
|
import static google.registry.testing.DatastoreHelper.loadRegistrar;
|
||||||
import static google.registry.testing.DatastoreHelper.persistResource;
|
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 google.registry.flows.EppException;
|
||||||
import google.registry.flows.EppException.UnimplementedExtensionException;
|
import google.registry.flows.EppException.UnimplementedExtensionException;
|
||||||
import google.registry.flows.EppException.UnimplementedObjectServiceException;
|
import google.registry.flows.EppException.UnimplementedObjectServiceException;
|
||||||
import google.registry.flows.EppException.UnimplementedProtocolVersionException;
|
import google.registry.flows.EppException.UnimplementedProtocolVersionException;
|
||||||
|
@ -61,9 +63,10 @@ public abstract class LoginFlowTestCase extends FlowTestCase<LoginFlow> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Also called in subclasses.
|
// Also called in subclasses.
|
||||||
void doFailingTest(String xmlFilename, Class<? extends Exception> exception) throws Exception {
|
void doFailingTest(String xmlFilename, Class<? extends EppException> exception) throws Exception {
|
||||||
setEppInput(xmlFilename);
|
setEppInput(xmlFilename);
|
||||||
assertThrows(exception, this::runFlow);
|
EppException thrown = expectThrows(exception, this::runFlow);
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -15,8 +15,10 @@
|
||||||
package google.registry.flows.session;
|
package google.registry.flows.session;
|
||||||
|
|
||||||
import static google.registry.testing.DatastoreHelper.createTld;
|
import static google.registry.testing.DatastoreHelper.createTld;
|
||||||
import static google.registry.testing.JUnitBackports.assertThrows;
|
import static google.registry.testing.EppExceptionSubject.assertAboutEppExceptions;
|
||||||
|
import static google.registry.testing.JUnitBackports.expectThrows;
|
||||||
|
|
||||||
|
import google.registry.flows.EppException;
|
||||||
import google.registry.flows.FlowTestCase;
|
import google.registry.flows.FlowTestCase;
|
||||||
import google.registry.flows.FlowUtils.NotLoggedInException;
|
import google.registry.flows.FlowUtils.NotLoggedInException;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
@ -44,6 +46,7 @@ public class LogoutFlowTest extends FlowTestCase<LogoutFlow> {
|
||||||
@Test
|
@Test
|
||||||
public void testFailure() throws Exception {
|
public void testFailure() throws Exception {
|
||||||
sessionMetadata.setClientId(null); // Turn off the implicit login
|
sessionMetadata.setClientId(null); // Turn off the implicit login
|
||||||
assertThrows(NotLoggedInException.class, this::runFlow);
|
EppException thrown = expectThrows(NotLoggedInException.class, this::runFlow);
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,9 @@ import static google.registry.model.registrar.Registrar.State.ACTIVE;
|
||||||
import static google.registry.testing.DatastoreHelper.createTld;
|
import static google.registry.testing.DatastoreHelper.createTld;
|
||||||
import static google.registry.testing.DatastoreHelper.loadRegistrar;
|
import static google.registry.testing.DatastoreHelper.loadRegistrar;
|
||||||
import static google.registry.testing.DatastoreHelper.persistResource;
|
import static google.registry.testing.DatastoreHelper.persistResource;
|
||||||
|
import static google.registry.testing.EppExceptionSubject.assertAboutEppExceptions;
|
||||||
import static google.registry.testing.JUnitBackports.assertThrows;
|
import static google.registry.testing.JUnitBackports.assertThrows;
|
||||||
|
import static google.registry.testing.JUnitBackports.expectThrows;
|
||||||
|
|
||||||
import com.beust.jcommander.ParameterException;
|
import com.beust.jcommander.ParameterException;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
|
@ -63,7 +65,8 @@ public class ValidateLoginCredentialsCommandTest
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_loginWithBadPassword() throws Exception {
|
public void testFailure_loginWithBadPassword() throws Exception {
|
||||||
assertThrows(
|
EppException thrown =
|
||||||
|
expectThrows(
|
||||||
BadRegistrarPasswordException.class,
|
BadRegistrarPasswordException.class,
|
||||||
() ->
|
() ->
|
||||||
runCommand(
|
runCommand(
|
||||||
|
@ -71,11 +74,13 @@ public class ValidateLoginCredentialsCommandTest
|
||||||
"--password=" + new StringBuilder(PASSWORD).reverse(),
|
"--password=" + new StringBuilder(PASSWORD).reverse(),
|
||||||
"--cert_hash=" + CERT_HASH,
|
"--cert_hash=" + CERT_HASH,
|
||||||
"--ip_address=" + CLIENT_IP));
|
"--ip_address=" + CLIENT_IP));
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_loginWithBadCertificateHash() throws Exception {
|
public void testFailure_loginWithBadCertificateHash() throws Exception {
|
||||||
assertThrows(
|
EppException thrown =
|
||||||
|
expectThrows(
|
||||||
EppException.class,
|
EppException.class,
|
||||||
() ->
|
() ->
|
||||||
runCommand(
|
runCommand(
|
||||||
|
@ -83,11 +88,13 @@ public class ValidateLoginCredentialsCommandTest
|
||||||
"--password=" + PASSWORD,
|
"--password=" + PASSWORD,
|
||||||
"--cert_hash=" + new StringBuilder(CERT_HASH).reverse(),
|
"--cert_hash=" + new StringBuilder(CERT_HASH).reverse(),
|
||||||
"--ip_address=" + CLIENT_IP));
|
"--ip_address=" + CLIENT_IP));
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_loginWithBadIp() throws Exception {
|
public void testFailure_loginWithBadIp() throws Exception {
|
||||||
assertThrows(
|
EppException thrown =
|
||||||
|
expectThrows(
|
||||||
EppException.class,
|
EppException.class,
|
||||||
() ->
|
() ->
|
||||||
runCommand(
|
runCommand(
|
||||||
|
@ -95,6 +102,7 @@ public class ValidateLoginCredentialsCommandTest
|
||||||
"--password=" + PASSWORD,
|
"--password=" + PASSWORD,
|
||||||
"--cert_hash=" + CERT_HASH,
|
"--cert_hash=" + CERT_HASH,
|
||||||
"--ip_address=" + new StringBuilder(CLIENT_IP).reverse()));
|
"--ip_address=" + new StringBuilder(CLIENT_IP).reverse()));
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue