assertFalse(gaeUser.isAdmin());
}
/** Test doFilter() when the user is logged in and is not an admin user, with client roles. */
@Test public void testDoFilterLoggedInWithClientRoles() throws Exception {
UserService userService = mock(UserService.class);
AuthenticationManager authenticationManager = mock(AuthenticationManager.class);
StubbedGaeAuthenticationFilter filter = new StubbedGaeAuthenticationFilter();
filter.setUserService(userService);
filter.setAuthenticationManager(authenticationManager);
filter.afterPropertiesSet();
User user = new User("email", "authDomain", "userId", "federatedIdentity");
when(authenticationManager.authenticate(isA(GaeUserAuthenticationToken.class))).thenAnswer(new AuthenticationAnswer());
when(userService.isUserLoggedIn()).thenReturn(true); // user is logged in
when(userService.isUserAdmin()).thenReturn(false); // user is not an admin
when(userService.getCurrentUser()).thenReturn(user); // this is the logged in user
GaeUser gaeUser = callDoFilter(filter, "ONE");
assertEquals(user.getAuthDomain(), gaeUser.getAuthDomain());
assertEquals(user.getFederatedIdentity(), gaeUser.getFederatedIdentity());
assertEquals(user.getEmail(), gaeUser.getEmail());