Fix NPE bug in DomainCommand.cloneAndLinkReferences()

See b/30806813 for more context.  Copied from there:  This appears to be happening if we get an EPP domain create command that is missing any contacts (but has a registrant; with no registrant we exercise a different codepath).  In that case, JAXB leaves the contacts field on the Create null, and we try to pass it into Sets.union() as a result of Corey's refactoring in [] that changed contact loading to load the contacts and registrant all at once.  The fix is just to apply nullToEmpty() first.

Note that it's always an error to try to create a domain without any non-registrant contacts, but that's supposed to happen later on in BaseDomainCreateFlow.verifyCreateIsAllowed() via validateRequiredContactsPresent(), which will produce a nice error message.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=130309019
This commit is contained in:
nickfelt 2016-08-15 12:14:40 -07:00 committed by Ben McIlwain
parent 160266f37a
commit d1ea3e3a68
7 changed files with 178 additions and 3 deletions

View file

@ -1025,6 +1025,14 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
runFlow();
}
@Test
public void testFailure_missingNonRegistrantContacts() throws Exception {
thrown.expect(MissingAdminContactException.class);
setEppInput("domain_create_missing_non_registrant_contacts.xml");
persistContactsAndHosts();
runFlow();
}
@Test
public void testFailure_badIdn() throws Exception {
thrown.expect(InvalidIdnDomainLabelException.class);