use of org.mamute.auth.Access in project mamute by caelum.
the class AccessTest method should_not_auto_login_without_brutal_cookie.
@Test
public void should_not_auto_login_without_brutal_cookie() {
Cookie[] cookies = new Cookie[] { anyCookie(), anyCookie(), anyCookie(), anyCookie() };
when(request.getCookies()).thenReturn(cookies);
Access access = new Access(response, request, users);
assertFalse(access.tryToAutoLogin());
}
use of org.mamute.auth.Access in project mamute by caelum.
the class AccessTest method should_not_auto_login_with_invalid_session.
@Test
public void should_not_auto_login_with_invalid_session() {
String sessionKey = "invalid";
Cookie brutalCookie = new Cookie(Access.BRUTAL_SESSION, sessionKey);
Cookie[] cookies = new Cookie[] { anyCookie(), brutalCookie, anyCookie() };
when(request.getCookies()).thenReturn(cookies);
when(users.findBySessionKey(sessionKey)).thenReturn(null);
Access access = new Access(response, request, users);
assertFalse(access.tryToAutoLogin());
}
use of org.mamute.auth.Access in project mamute by caelum.
the class AccessTest method should_auto_login_with_valid_cookie.
@Test
public void should_auto_login_with_valid_cookie() {
String sessionKey = "session-key";
Cookie brutalCookie = new Cookie(Access.BRUTAL_SESSION, sessionKey);
Cookie[] cookies = new Cookie[] { anyCookie(), anyCookie(), brutalCookie, anyCookie(), anyCookie() };
when(request.getCookies()).thenReturn(cookies);
when(users.findBySessionKey(sessionKey)).thenReturn(new UserAndSession(user, new UserSession(user, sessionKey)));
Access access = new Access(response, request, users);
assertTrue(access.tryToAutoLogin());
}
Aggregations