Event login1 = events.expectLogin().assertEvent();
WebDriver driver2 = WebRule.createWebDriver();
try {
OAuthClient oauth2 = new OAuthClient(driver2);
oauth2.state("mystate");
oauth2.doLogin("test-user@localhost", "password");
Event login2 = events.expectLogin().assertEvent();
Assert.assertEquals(RequestType.AUTH_RESPONSE, RequestType.valueOf(driver2.getTitle()));
Assert.assertNotNull(oauth2.getCurrentQuery().get(OAuth2Constants.CODE));
assertNotEquals(login1.getSessionId(), login2.getSessionId());
oauth.openLogout();
events.expectLogout(login1.getSessionId()).assertEvent();
oauth.openLoginForm();
assertTrue(loginPage.isCurrent());
oauth2.openLoginForm();
events.expectLogin().session(login2.getSessionId()).detail(Details.AUTH_METHOD, "sso").removeDetail(Details.USERNAME).assertEvent();
Assert.assertEquals(RequestType.AUTH_RESPONSE, RequestType.valueOf(driver2.getTitle()));
Assert.assertNotNull(oauth2.getCurrentQuery().get(OAuth2Constants.CODE));
oauth2.openLogout();
events.expectLogout(login2.getSessionId()).assertEvent();
oauth2.openLoginForm();
assertTrue(driver2.getTitle().equals("Log in to test"));
} finally {
driver2.close();
}