mirror of
https://github.com/google/nomulus.git
synced 2025-04-30 03:57:51 +02:00
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
This commit is contained in:
parent
32e8e8fdb0
commit
1ed77d5572
2 changed files with 21 additions and 2 deletions
|
@ -318,8 +318,9 @@ public class DomainFlowUtils {
|
||||||
static void validateRegistrantAllowedOnTld(String tld, String registrantContactId)
|
static void validateRegistrantAllowedOnTld(String tld, String registrantContactId)
|
||||||
throws RegistrantNotAllowedException {
|
throws RegistrantNotAllowedException {
|
||||||
ImmutableSet<String> whitelist = Registry.get(tld).getAllowedRegistrantContactIds();
|
ImmutableSet<String> whitelist = Registry.get(tld).getAllowedRegistrantContactIds();
|
||||||
// Empty whitelists are ignored.
|
// Empty whitelists or null registrantContactId are ignored.
|
||||||
if (!whitelist.isEmpty() && !whitelist.contains(registrantContactId)) {
|
if (registrantContactId != null && !whitelist.isEmpty()
|
||||||
|
&& !whitelist.contains(registrantContactId)) {
|
||||||
throw new RegistrantNotAllowedException(registrantContactId);
|
throw new RegistrantNotAllowedException(registrantContactId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1094,6 +1094,24 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
||||||
runFlow();
|
runFlow();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSuccess_newNameserverWhitelisted() throws Exception {
|
||||||
|
setEppInput("domain_update_add_nameserver.xml");
|
||||||
|
persistReferencedEntities();
|
||||||
|
persistDomain();
|
||||||
|
// No registrant is given but both nameserver and registrant whitelist exist.
|
||||||
|
persistResource(
|
||||||
|
Registry.get("tld").asBuilder()
|
||||||
|
.setAllowedRegistrantContactIds(ImmutableSet.of("sh8013"))
|
||||||
|
.setAllowedFullyQualifiedHostNames(ImmutableSet.of("ns2.example.foo"))
|
||||||
|
.build());
|
||||||
|
assertThat(reloadResourceByUniqueId().getNameservers()).doesNotContain(
|
||||||
|
Ref.create(loadByUniqueId(HostResource.class, "ns2.example.foo", clock.nowUtc())));
|
||||||
|
runFlow();
|
||||||
|
assertThat(reloadResourceByUniqueId().getNameservers()).contains(
|
||||||
|
Ref.create(loadByUniqueId(HostResource.class, "ns2.example.foo", clock.nowUtc())));
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_nameserverAndRegistrantWhitelisted() throws Exception {
|
public void testSuccess_nameserverAndRegistrantWhitelisted() throws Exception {
|
||||||
persistReferencedEntities();
|
persistReferencedEntities();
|
||||||
|
|
Loading…
Add table
Reference in a new issue