mirror of
https://github.com/google/nomulus.git
synced 2025-05-16 17:37:13 +02:00
Don't throw an exception on orphaned contacts
Return Optional.absent() instead of throwing NotFoundException when a user has a contact record but the Registrar entity is missing. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=138423965
This commit is contained in:
parent
7a77819977
commit
cbe76e8615
2 changed files with 16 additions and 2 deletions
|
@ -16,6 +16,7 @@ package google.registry.ui.server.registrar;
|
|||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.testing.AppEngineRule.THE_REGISTRAR_GAE_USER_ID;
|
||||
import static google.registry.testing.DatastoreHelper.deleteResource;
|
||||
import static org.mockito.Matchers.eq;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.verifyNoMoreInteractions;
|
||||
|
@ -103,10 +104,17 @@ public class SessionUtilsTest {
|
|||
verify(session).invalidate();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCheckRegistrarConsoleLogin_orphanedContactIsDenied() throws Exception {
|
||||
deleteResource(Registrar.loadByClientId("TheRegistrar"));
|
||||
when(userService.getCurrentUser()).thenReturn(jart);
|
||||
assertThat(sessionUtils.checkRegistrarConsoleLogin(req)).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCheckRegistrarConsoleLogin_notLoggedIn_throwsIse() throws Exception {
|
||||
thrown.expect(IllegalStateException.class);
|
||||
assertThat(sessionUtils.checkRegistrarConsoleLogin(req)).isNull();
|
||||
boolean unused = sessionUtils.checkRegistrarConsoleLogin(req);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue