Remove requireLogin action attribute

The affected actions have been changed to check that the user is logged in by [] so this attribute is no longer needed.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=159572365
This commit is contained in:
mountford 2017-06-20 09:42:45 -07:00 committed by Ben McIlwain
parent d05151b026
commit 9d96072e01
14 changed files with 83 additions and 159 deletions

View file

@ -97,17 +97,6 @@ public final class RequestHandlerTest {
public void run() {}
}
@Action(
path = "/users-only",
method = GET,
requireLogin = true,
auth = @Auth(minimumLevel = AuthLevel.NONE)
)
public static class UsersOnlyAction implements Runnable {
@Override
public void run() {}
}
@Action(path = "/fail", auth = @Auth(minimumLevel = AuthLevel.NONE))
public static final class FailTask implements Runnable {
@Override
@ -189,10 +178,6 @@ public final class RequestHandlerTest {
return safeSlothTask;
}
public UsersOnlyAction usersOnlyAction() {
return usersOnlyAction;
}
public FailTask failTask() {
return new FailTask();
}
@ -223,7 +208,6 @@ public final class RequestHandlerTest {
private final HttpServletResponse rsp = mock(HttpServletResponse.class);
private final BumblebeeTask bumblebeeTask = mock(BumblebeeTask.class);
private final SlothTask slothTask = mock(SlothTask.class);
private final UsersOnlyAction usersOnlyAction = mock(UsersOnlyAction.class);
private final SafeSlothTask safeSlothTask = mock(SafeSlothTask.class);
private final Component component = new Component();
@ -259,7 +243,6 @@ public final class RequestHandlerTest {
return component;
}
}),
userService,
requestAuthenticator);
when(rsp.getWriter()).thenReturn(new PrintWriter(httpOutput));
}
@ -400,24 +383,6 @@ public final class RequestHandlerTest {
verify(safeSlothTask).run();
}
@Test
public void testMustBeLoggedIn_notLoggedIn_redirectsToLoginPage() throws Exception {
when(req.getMethod()).thenReturn("GET");
when(req.getRequestURI()).thenReturn("/users-only");
handler.handleRequest(req, rsp);
verify(rsp).setStatus(302);
verify(rsp).setHeader("Location", "/login?dest=/users-only");
}
@Test
public void testMustBeLoggedIn_loggedIn_runsAction() throws Exception {
userService.setUser(testUser, false);
when(req.getMethod()).thenReturn("GET");
when(req.getRequestURI()).thenReturn("/users-only");
handler.handleRequest(req, rsp);
verify(usersOnlyAction).run();
}
@Test
public void testNoAuthNeeded_success() throws Exception {
when(req.getMethod()).thenReturn("GET");