protected void logout(AbstractPage targetPage) { if (!(targetPage instanceof PageWithLogOutAction)) { throw new IllegalArgumentException( targetPage.getClass().getSimpleName() + " must implement PageWithLogOutAction interface"); } targetPage.navigateTo(); assertCurrentUrlStartsWith(targetPage); ((PageWithLogOutAction) targetPage).logOut(); }
protected void verifyLoggedOut(AbstractPage targetPage) { // verify on target page targetPage.navigateTo(); driver.navigate().refresh(); assertCurrentUrlStartsWith(loginPage); Cookie sessionCookie = driver.manage().getCookieNamed(KEYCLOAK_SESSION_COOKIE); assertNull(sessionCookie); }
protected Cookie login(AbstractPage targetPage) { targetPage.navigateTo(); assertCurrentUrlStartsWith(loginPage); loginPage.form().login(ADMIN, ADMIN); assertCurrentUrlStartsWith(targetPage); Cookie sessionCookie = driver.manage().getCookieNamed(KEYCLOAK_SESSION_COOKIE); assertNotNull(sessionCookie); return sessionCookie; }
protected Cookie verifyLoggedIn(AbstractPage targetPage, Cookie sessionCookieForVerification) { // verify on realm path masterRealmPage.navigateTo(); Cookie sessionCookieOnRealmPath = driver.manage().getCookieNamed(KEYCLOAK_SESSION_COOKIE); assertNotNull(sessionCookieOnRealmPath); assertEquals(sessionCookieOnRealmPath.getValue(), sessionCookieForVerification.getValue()); // verify on target page targetPage.navigateTo(); assertCurrentUrlStartsWith(targetPage); Cookie sessionCookie = driver.manage().getCookieNamed(KEYCLOAK_SESSION_COOKIE); assertNotNull(sessionCookie); assertEquals(sessionCookie.getValue(), sessionCookieForVerification.getValue()); return sessionCookie; }