@Test void getLoginPageAuthenticated() { MolgenisLoginController controller = new MolgenisLoginController(); Model model = mock(Model.class); HttpServletRequest request = mock(HttpServletRequest.class); HttpSession session = mock(HttpSession.class); SavedRequest savedRequest = mock(SavedRequest.class); SecurityContext securityContext = mock(SecurityContext.class); Cookie cookie = mock(Cookie.class); Authentication authentication = mock(Authentication.class); when(cookie.getName()).thenReturn("JSESSIONID"); when(securityContext.getAuthentication()).thenReturn(authentication); when(savedRequest.getCookies()).thenReturn(Collections.singletonList(cookie)); when(session.getAttribute(SPRING_SECURITY_SAVED_REQUEST)).thenReturn(savedRequest); when(session.getAttribute(SPRING_SECURITY_CONTEXT)).thenReturn(securityContext); when(request.getSession(false)).thenReturn(session); assertEquals(VIEW_LOGIN, controller.getLoginPage(request, model)); verifyNoMoreInteractions(model); }
@GetMapping public String getLoginPage(HttpServletRequest httpServletRequest, Model model) { if (hasInvalidSessionId(httpServletRequest)) { return getLoginErrorPage(model); } return VIEW_LOGIN; }
MolgenisLoginController { @GetMapping public String getLoginPage(HttpServletRequest httpServletRequest, Model model) { if (hasInvalidSessionId(httpServletRequest)) { return getLoginErrorPage(model); } return VIEW_LOGIN; } }
MolgenisLoginController { @GetMapping public String getLoginPage(HttpServletRequest httpServletRequest, Model model) { if (hasInvalidSessionId(httpServletRequest)) { return getLoginErrorPage(model); } return VIEW_LOGIN; }  }
MolgenisLoginController { @GetMapping public String getLoginPage(HttpServletRequest httpServletRequest, Model model) { if (hasInvalidSessionId(httpServletRequest)) { return getLoginErrorPage(model); } return VIEW_LOGIN; }  @GetMapping String getLoginPage(HttpServletRequest httpServletRequest, Model model); @GetMapping(params = PARAM_SESSION_EXPIRED) String getLoginErrorPage(Model model); @GetMapping(params = "error") String getLoginErrorPage(Model model, HttpServletRequest request); }
MolgenisLoginController { @GetMapping public String getLoginPage(HttpServletRequest httpServletRequest, Model model) { if (hasInvalidSessionId(httpServletRequest)) { return getLoginErrorPage(model); } return VIEW_LOGIN; }  @GetMapping String getLoginPage(HttpServletRequest httpServletRequest, Model model); @GetMapping(params = PARAM_SESSION_EXPIRED) String getLoginErrorPage(Model model); @GetMapping(params = "error") String getLoginErrorPage(Model model, HttpServletRequest request); static final String PARAM_SESSION_EXPIRED; static final String URI; static final String ERROR_MESSAGE_ATTRIBUTE; static final String ERROR_MESSAGE_DISABLED; static final String SPRING_SECURITY_CONTEXT; static final String SPRING_SECURITY_SAVED_REQUEST; static final String JSESSIONID; }