mirror of
https://github.com/google/nomulus.git
synced 2025-08-05 09:21:49 +02:00
Fix bug which caused exceptions when attempting to redirect to the console login page
When the registrar console code determines that a user has not logged in, it redirects to a login page. But when authenticating as an internal request (which should never happen), the redirection code encountered an exception, resulting in a 500 error. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=163867018
This commit is contained in:
parent
2a29ada032
commit
5fefa8906d
2 changed files with 33 additions and 1 deletions
|
@ -14,7 +14,9 @@
|
|||
|
||||
package google.registry.ui.server.registrar;
|
||||
|
||||
import static com.google.common.net.HttpHeaders.LOCATION;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static javax.servlet.http.HttpServletResponse.SC_MOVED_TEMPORARILY;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
@ -112,4 +114,22 @@ public class ConsoleUiActionTest {
|
|||
action.run();
|
||||
assertThat(response.getPayload()).contains("<h1>You need permission</h1>");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNoUser_redirect() throws Exception {
|
||||
when(request.getRequestURI()).thenReturn("/test");
|
||||
action.authResult = AuthResult.NOT_AUTHENTICATED;
|
||||
action.run();
|
||||
assertThat(response.getStatus()).isEqualTo(SC_MOVED_TEMPORARILY);
|
||||
assertThat(response.getHeaders().get(LOCATION)).isEqualTo("/_ah/login?continue=%2Ftest");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNoUserInformationAtAll_redirectToRoot() throws Exception {
|
||||
when(request.getRequestURI()).thenThrow(new IllegalArgumentException());
|
||||
action.authResult = AuthResult.NOT_AUTHENTICATED;
|
||||
action.run();
|
||||
assertThat(response.getStatus()).isEqualTo(SC_MOVED_TEMPORARILY);
|
||||
assertThat(response.getHeaders().get(LOCATION)).isEqualTo("/");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue