@Test public void sessions() { loginPage.open(); loginPage.clickRegister(); registerPage.register( "view", "sessions", "view-sessions@localhost", "view-sessions", "password", "password"); Event registerEvent = events.expectRegister("view-sessions", "view-sessions@localhost").assertEvent(); String userId = registerEvent.getUserId(); events.expectLogin().user(userId).detail(Details.USERNAME, "view-sessions").assertEvent(); sessionsPage.open(); Assert.assertTrue(sessionsPage.isCurrent()); List<List<String>> sessions = sessionsPage.getSessions(); Assert.assertEquals(1, sessions.size()); Assert.assertEquals("127.0.0.1", sessions.get(0).get(0)); // Create second session WebDriver driver2 = WebRule.createWebDriver(); try { OAuthClient oauth2 = new OAuthClient(driver2); oauth2.state("mystate"); oauth2.doLogin("view-sessions", "password"); Event login2Event = events.expectLogin().user(userId).detail(Details.USERNAME, "view-sessions").assertEvent(); sessionsPage.open(); sessions = sessionsPage.getSessions(); Assert.assertEquals(2, sessions.size()); sessionsPage.logoutAll(); events.expectLogout(registerEvent.getSessionId()); events.expectLogout(login2Event.getSessionId()); } finally { driver2.close(); } }
@Override protected void after() { super.after(); webRule.after(); }
@Override protected void before() throws Throwable { super.before(); webRule.before(); }