From 1ed77d55727f94ce754493f0623f41842a1d3e89 Mon Sep 17 00:00:00 2001 From: Ben McIlwain Date: Thu, 7 Jul 2016 10:07:28 -0700 Subject: [PATCH] Fix a bug when updating a domain without changing its registrant When updating a filed other than the registrant for a domain, a null registratantContactId is passed to the registrant whitelist validator, causing an excpetion because null is not an element in the whitelist (if it exists). Added logic to handle null registrantContactId. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=126817310 --- .../registry/flows/domain/DomainFlowUtils.java | 5 +++-- .../flows/domain/DomainUpdateFlowTest.java | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/java/google/registry/flows/domain/DomainFlowUtils.java b/java/google/registry/flows/domain/DomainFlowUtils.java index 9458657e4..f30ef953f 100644 --- a/java/google/registry/flows/domain/DomainFlowUtils.java +++ b/java/google/registry/flows/domain/DomainFlowUtils.java @@ -318,8 +318,9 @@ public class DomainFlowUtils { static void validateRegistrantAllowedOnTld(String tld, String registrantContactId) throws RegistrantNotAllowedException { ImmutableSet whitelist = Registry.get(tld).getAllowedRegistrantContactIds(); - // Empty whitelists are ignored. - if (!whitelist.isEmpty() && !whitelist.contains(registrantContactId)) { + // Empty whitelists or null registrantContactId are ignored. + if (registrantContactId != null && !whitelist.isEmpty() + && !whitelist.contains(registrantContactId)) { throw new RegistrantNotAllowedException(registrantContactId); } } diff --git a/javatests/google/registry/flows/domain/DomainUpdateFlowTest.java b/javatests/google/registry/flows/domain/DomainUpdateFlowTest.java index f6cabb22b..2c4458755 100644 --- a/javatests/google/registry/flows/domain/DomainUpdateFlowTest.java +++ b/javatests/google/registry/flows/domain/DomainUpdateFlowTest.java @@ -1094,6 +1094,24 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase