@Test public void onSuccessfulLogin() { HttpServletRequest mockRequest = createNiceMock(HttpServletRequest.class); HttpServletResponse mockResponse = createNiceMock(HttpServletResponse.class); WebSubject mockSubject = createNiceMock(WebSubject.class); expect(mockSubject.getServletRequest()).andReturn(mockRequest).anyTimes(); expect(mockSubject.getServletResponse()).andReturn(mockResponse).anyTimes(); CookieRememberMeManager mgr = new CookieRememberMeManager(); org.apache.shiro.web.servlet.Cookie cookie = createMock(org.apache.shiro.web.servlet.Cookie.class); mgr.setCookie(cookie); cookie.removeFrom(isA(HttpServletRequest.class), isA(HttpServletResponse.class)); expect(cookie.getName()).andReturn("rememberMe"); expect(cookie.getValue()).andReturn(null); expect(cookie.getComment()).andReturn(null); expect(cookie.getDomain()).andReturn(null); expect(cookie.getPath()).andReturn(null); expect(cookie.getMaxAge()).andReturn(SimpleCookie.DEFAULT_MAX_AGE); expect(cookie.getVersion()).andReturn(SimpleCookie.DEFAULT_VERSION); expect(cookie.isSecure()).andReturn(false); expect(cookie.isHttpOnly()).andReturn(true); expect(cookie.getSameSite()).andReturn(org.apache.shiro.web.servlet.Cookie.SameSiteOptions.LAX); UsernamePasswordToken token = new UsernamePasswordToken("user", "secret"); token.setRememberMe(true); AuthenticationInfo account = new SimpleAuthenticationInfo("user", "secret", "test"); replay(mockSubject); replay(mockRequest); replay(cookie); mgr.onSuccessfulLogin(mockSubject, token, account); verify(mockRequest); verify(mockSubject); verify(cookie); }
@SuppressWarnings({"UnusedDeclaration"}) public void setCookie(Cookie cookie) { this.cookie = cookie; }
CookieRememberMeManager extends AbstractRememberMeManager { @SuppressWarnings({"UnusedDeclaration"}) public void setCookie(Cookie cookie) { this.cookie = cookie; } }
CookieRememberMeManager extends AbstractRememberMeManager { @SuppressWarnings({"UnusedDeclaration"}) public void setCookie(Cookie cookie) { this.cookie = cookie; } CookieRememberMeManager(); }
CookieRememberMeManager extends AbstractRememberMeManager { @SuppressWarnings({"UnusedDeclaration"}) public void setCookie(Cookie cookie) { this.cookie = cookie; } CookieRememberMeManager(); Cookie getCookie(); @SuppressWarnings({"UnusedDeclaration"}) void setCookie(Cookie cookie); void forgetIdentity(SubjectContext subjectContext); }
CookieRememberMeManager extends AbstractRememberMeManager { @SuppressWarnings({"UnusedDeclaration"}) public void setCookie(Cookie cookie) { this.cookie = cookie; } CookieRememberMeManager(); Cookie getCookie(); @SuppressWarnings({"UnusedDeclaration"}) void setCookie(Cookie cookie); void forgetIdentity(SubjectContext subjectContext); static final String DEFAULT_REMEMBER_ME_COOKIE_NAME; }