Change behavior when searching contacts by name

We no longer find contacts by name if the request is not authorized to see the name.

Several changes cascade from this. Previously, the code assumed that deleted contacts might still have full names, and therefore be searchable. This is not possible in all cases, because Datastore doesn't have the right index to find deleted contacts by name with a matching registrar. However, luckily, this situation can never occur, because contacts always have their name fields nulled out when they are deleted.

So instead, we simply ignore deleted records when searching by name, knowing that none can ever match.

The tests were then changed so that deleted records look the way the really will, meaning devoid of personal information.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=172776926
This commit is contained in:
mountford 2017-10-19 11:51:03 -07:00 committed by jianglai
parent f89ad27e17
commit ac822053cc
5 changed files with 182 additions and 67 deletions

View file

@ -19,6 +19,7 @@ import static google.registry.testing.DatastoreHelper.createTld;
import static google.registry.testing.DatastoreHelper.persistResource;
import static google.registry.testing.DatastoreHelper.persistSimpleResources;
import static google.registry.testing.FullFieldsTestEntityHelper.makeAndPersistContactResource;
import static google.registry.testing.FullFieldsTestEntityHelper.makeAndPersistDeletedContactResource;
import static google.registry.testing.FullFieldsTestEntityHelper.makeDomainResource;
import static google.registry.testing.FullFieldsTestEntityHelper.makeHostResource;
import static google.registry.testing.FullFieldsTestEntityHelper.makeRegistrar;
@ -148,11 +149,8 @@ public class RdapEntityActionTest {
clock.nowUtc(),
registrarLol);
deletedContact =
makeAndPersistContactResource(
makeAndPersistDeletedContactResource(
"8372808-DEL",
"(◕‿◕)",
"lol@cat.みんな",
ImmutableList.of("2 Smiley Row"),
clock.nowUtc().minusYears(1),
registrarLol,
clock.nowUtc().minusMonths(6));
@ -400,9 +398,9 @@ public class RdapEntityActionTest {
action.includeDeletedParam = Optional.of(true);
runSuccessfulTest(
deletedContact.getRepoId(),
"(◕‿◕)",
"active",
"\"2 Smiley Row\"",
"",
"removed",
"",
false,
"rdap_contact_deleted.json");
}
@ -413,9 +411,9 @@ public class RdapEntityActionTest {
action.includeDeletedParam = Optional.of(true);
runSuccessfulTest(
deletedContact.getRepoId(),
"(◕‿◕)",
"active",
"\"2 Smiley Row\"",
"",
"removed",
"",
false,
"rdap_contact_deleted.json");
}