LoginAbstractAzkabanServlet extends AbstractAzkabanServlet { @Override protected void doGet(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException { getWebMetrics().markWebGetCall(); final Session session = getSessionFromRequest(req); logRequest(req, session); if (hasParam(req, "logout")) { resp.sendRedirect(req.getContextPath()); if (session != null) { getApplication().getSessionCache().removeSession(session.getSessionId()); WebUtils.reportLoginEvent(EventType.USER_LOGOUT, session.getUser().getUserId(), WebUtils.getRealClientIpAddr(req)); } else { WebUtils.reportLoginEvent(EventType.USER_LOGOUT, null, WebUtils.getRealClientIpAddr(req), false, "Not logged in"); } return; } if (session != null) { if (logger.isDebugEnabled()) { logger.debug("Found session " + session.getUser()); } if (handleFileGet(req, resp)) { return; } handleGet(req, resp, session); } else { if (hasParam(req, "ajax")) { final HashMap<String, String> retVal = new HashMap<>(); retVal.put("error", "session"); this.writeJSON(resp, retVal); } else { handleLogin(req, resp); } } } LoginAbstractAzkabanServlet(final List<AzkabanAPI> apiEndpoints); @Override void init(final ServletConfig config); static AzkabanAPI getLoginAPI(); void setResourceDirectory(final File file); boolean isUserAuthenticated(final HttpServletRequest req);  }
@Test public void testWhenGetRequestSessionIsValid() throws Exception, IOException, ServletException { final String clientIp = "127.0.0.1:10000"; final String sessionId = "111"; final HttpServletRequest req = MockLoginAzkabanServlet .getRequestWithNoUpstream(clientIp, sessionId, "GET"); final StringWriter writer = new StringWriter(); final HttpServletResponse resp = getResponse(writer); final MockLoginAzkabanServlet servlet = MockLoginAzkabanServlet.getServletWithSession(sessionId, "user", "127.0.0.1"); servlet.doGet(req, resp); assertEquals("SUCCESS_MOCK_LOGIN_SERVLET", writer.toString()); }