Old account console dependencies removed. Closes #19668

* ConsentsTest
* UserTest
* SessionTest
* LoginEventsTest
* AbstractKeycloakTest
This commit is contained in:
Lukas Hanusovsky 2023-05-04 14:40:41 +02:00 committed by Michal Hajas
parent 9943c977de
commit 5e323ae173
5 changed files with 71 additions and 63 deletions

View file

@ -17,6 +17,7 @@
package org.keycloak.testsuite; package org.keycloak.testsuite;
import io.appium.java_client.AppiumDriver; import io.appium.java_client.AppiumDriver;
import jakarta.ws.rs.core.Response;
import org.apache.commons.configuration.ConfigurationException; import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.PropertiesConfiguration; import org.apache.commons.configuration.PropertiesConfiguration;
import org.jboss.arquillian.container.test.api.RunAsClient; import org.jboss.arquillian.container.test.api.RunAsClient;
@ -40,6 +41,7 @@ import org.keycloak.models.RealmProvider;
import org.keycloak.models.cache.CacheRealmProvider; import org.keycloak.models.cache.CacheRealmProvider;
import org.keycloak.models.cache.UserCache; import org.keycloak.models.cache.UserCache;
import org.keycloak.models.utils.TimeBasedOTP; import org.keycloak.models.utils.TimeBasedOTP;
import org.keycloak.protocol.oidc.OIDCAdvancedConfigWrapper;
import org.keycloak.provider.Provider; import org.keycloak.provider.Provider;
import org.keycloak.representations.idm.ClientRepresentation; import org.keycloak.representations.idm.ClientRepresentation;
import org.keycloak.representations.idm.RealmRepresentation; import org.keycloak.representations.idm.RealmRepresentation;
@ -194,7 +196,7 @@ public abstract class AbstractKeycloakTest {
} }
oauth.init(driver); oauth.init(driver);
createAppClientInRealm("test");
} }
public void reconnectAdminClient() throws Exception { public void reconnectAdminClient() throws Exception {
@ -586,6 +588,23 @@ public abstract class AbstractKeycloakTest {
return user; return user;
} }
protected void createAppClientInRealm(String realm) {
ClientRepresentation client = new ClientRepresentation();
client.setClientId("test-app");
client.setName("test-app");
client.setSecret("password");
client.setEnabled(true);
client.setDirectAccessGrantsEnabled(true);
client.setRedirectUris(Collections.singletonList(oauth.SERVER_ROOT + "/auth/*"));
client.setBaseUrl(oauth.SERVER_ROOT + "/auth/realms/" + realm + "/app");
OIDCAdvancedConfigWrapper.fromClientRepresentation(client).setPostLogoutRedirectUris(Collections.singletonList("+"));
Response response = adminClient.realm(realm).clients().create(client);
response.close();
}
public void setRequiredActionEnabled(String realm, String requiredAction, boolean enabled, boolean defaultAction) { public void setRequiredActionEnabled(String realm, String requiredAction, boolean enabled, boolean defaultAction) {
AuthenticationManagementResource managementResource = adminClient.realm(realm).flows(); AuthenticationManagementResource managementResource = adminClient.realm(realm).flows();
@ -771,4 +790,6 @@ public abstract class AbstractKeycloakTest {
.fetchString(s -> s.getKeycloakSessionFactory().getProviderFactory(UserCache.class)); .fetchString(s -> s.getKeycloakSessionFactory().getProviderFactory(UserCache.class));
return Objects.nonNull(userCache); return Objects.nonNull(userCache);
} }
} }

View file

@ -28,7 +28,6 @@ import org.keycloak.admin.client.resource.ClientResource;
import org.keycloak.admin.client.resource.RealmResource; import org.keycloak.admin.client.resource.RealmResource;
import org.keycloak.admin.client.resource.UserResource; import org.keycloak.admin.client.resource.UserResource;
import org.keycloak.admin.client.resource.UsersResource; import org.keycloak.admin.client.resource.UsersResource;
import org.keycloak.common.Profile;
import org.keycloak.events.Details; import org.keycloak.events.Details;
import org.keycloak.events.Errors; import org.keycloak.events.Errors;
import org.keycloak.models.ClientModel; import org.keycloak.models.ClientModel;
@ -42,7 +41,6 @@ import org.keycloak.representations.idm.UserSessionRepresentation;
import org.keycloak.testsuite.AbstractKeycloakTest; import org.keycloak.testsuite.AbstractKeycloakTest;
import org.keycloak.testsuite.Assert; import org.keycloak.testsuite.Assert;
import org.keycloak.testsuite.AssertEvents; import org.keycloak.testsuite.AssertEvents;
import org.keycloak.testsuite.arquillian.annotation.DisableFeature;
import org.keycloak.testsuite.pages.AppPage; import org.keycloak.testsuite.pages.AppPage;
import org.keycloak.testsuite.pages.ConsentPage; import org.keycloak.testsuite.pages.ConsentPage;
import org.keycloak.testsuite.pages.ErrorPage; import org.keycloak.testsuite.pages.ErrorPage;
@ -69,7 +67,6 @@ import org.openqa.selenium.By;
/** /**
* @author <a href="mailto:mstrukel@redhat.com">Marko Strukelj</a> * @author <a href="mailto:mstrukel@redhat.com">Marko Strukelj</a>
*/ */
@DisableFeature(value = Profile.Feature.ACCOUNT2, skipRestart = true) // TODO remove this (KEYCLOAK-16228)
public class ConsentsTest extends AbstractKeycloakTest { public class ConsentsTest extends AbstractKeycloakTest {
final static String REALM_PROV_NAME = "provider"; final static String REALM_PROV_NAME = "provider";
@ -268,7 +265,10 @@ public class ConsentsTest extends AbstractKeycloakTest {
@Test @Test
public void testConsents() { public void testConsents() {
driver.navigate().to(getAccountUrl(consumerRealmName())); oauth.realm(consumerRealmName());
oauth.redirectUri(oauth.SERVER_ROOT + "/auth/realms/" + consumerRealmName() + "/app/auth");
createAppClientInRealm(consumerRealmName());
driver.navigate().to(oauth.getLoginFormUrl());
log.debug("Clicking social " + getIDPAlias()); log.debug("Clicking social " + getIDPAlias());
accountLoginPage.clickSocial(getIDPAlias()); accountLoginPage.clickSocial(getIDPAlias());
@ -338,6 +338,10 @@ public class ConsentsTest extends AbstractKeycloakTest {
sessions = userResource.getUserSessions(); sessions = userResource.getUserSessions();
Assert.assertEquals("There should be one active session", 1, sessions.size()); Assert.assertEquals("There should be one active session", 1, sessions.size());
Assert.assertEquals("There should be no client in user session", 0, sessions.get(0).getClients().size()); Assert.assertEquals("There should be no client in user session", 0, sessions.get(0).getClients().size());
// oauth clean up
oauth.realm("test");
oauth.redirectUri(oauth.SERVER_ROOT + "/auth/realms/master/app/auth");
} }
/** /**

View file

@ -20,8 +20,8 @@ package org.keycloak.testsuite.admin;
import org.hamcrest.Matchers; import org.hamcrest.Matchers;
import org.jboss.arquillian.drone.api.annotation.Drone; import org.jboss.arquillian.drone.api.annotation.Drone;
import org.jboss.arquillian.graphene.page.Page; import org.jboss.arquillian.graphene.page.Page;
import org.jboss.arquillian.test.api.ArquillianResource;
import org.junit.After; import org.junit.After;
import org.junit.Before;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Rule; import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
@ -33,7 +33,6 @@ import org.keycloak.admin.client.resource.RealmResource;
import org.keycloak.admin.client.resource.RoleMappingResource; import org.keycloak.admin.client.resource.RoleMappingResource;
import org.keycloak.admin.client.resource.UserResource; import org.keycloak.admin.client.resource.UserResource;
import org.keycloak.admin.client.resource.UsersResource; import org.keycloak.admin.client.resource.UsersResource;
import org.keycloak.common.Profile;
import org.keycloak.common.VerificationException; import org.keycloak.common.VerificationException;
import org.keycloak.common.util.Base64; import org.keycloak.common.util.Base64;
import org.keycloak.common.util.ObjectUtil; import org.keycloak.common.util.ObjectUtil;
@ -62,9 +61,7 @@ import org.keycloak.representations.idm.RealmRepresentation;
import org.keycloak.representations.idm.RequiredActionProviderRepresentation; import org.keycloak.representations.idm.RequiredActionProviderRepresentation;
import org.keycloak.representations.idm.RoleRepresentation; import org.keycloak.representations.idm.RoleRepresentation;
import org.keycloak.representations.idm.UserRepresentation; import org.keycloak.representations.idm.UserRepresentation;
import org.keycloak.services.resources.RealmsResource;
import org.keycloak.storage.UserStorageProvider; import org.keycloak.storage.UserStorageProvider;
import org.keycloak.testsuite.arquillian.annotation.DisableFeature;
import org.keycloak.testsuite.federation.DummyUserFederationProviderFactory; import org.keycloak.testsuite.federation.DummyUserFederationProviderFactory;
import org.keycloak.testsuite.page.LoginPasswordUpdatePage; import org.keycloak.testsuite.page.LoginPasswordUpdatePage;
import org.keycloak.testsuite.pages.ErrorPage; import org.keycloak.testsuite.pages.ErrorPage;
@ -74,13 +71,13 @@ import org.keycloak.testsuite.pages.PageUtils;
import org.keycloak.testsuite.pages.ProceedPage; import org.keycloak.testsuite.pages.ProceedPage;
import org.keycloak.testsuite.runonserver.RunHelpers; import org.keycloak.testsuite.runonserver.RunHelpers;
import org.keycloak.testsuite.updaters.Creator; import org.keycloak.testsuite.updaters.Creator;
import org.keycloak.testsuite.util.AccountHelper;
import org.keycloak.testsuite.util.AdminClientUtil; import org.keycloak.testsuite.util.AdminClientUtil;
import org.keycloak.testsuite.util.AdminEventPaths; import org.keycloak.testsuite.util.AdminEventPaths;
import org.keycloak.testsuite.util.ClientBuilder; import org.keycloak.testsuite.util.ClientBuilder;
import org.keycloak.testsuite.util.GreenMailRule; import org.keycloak.testsuite.util.GreenMailRule;
import org.keycloak.testsuite.util.GroupBuilder; import org.keycloak.testsuite.util.GroupBuilder;
import org.keycloak.testsuite.util.MailUtils; import org.keycloak.testsuite.util.MailUtils;
import org.keycloak.testsuite.util.OAuthClient;
import org.keycloak.testsuite.util.RealmBuilder; import org.keycloak.testsuite.util.RealmBuilder;
import org.keycloak.testsuite.util.RoleBuilder; import org.keycloak.testsuite.util.RoleBuilder;
import org.keycloak.testsuite.util.UserBuilder; import org.keycloak.testsuite.util.UserBuilder;
@ -93,7 +90,6 @@ import jakarta.ws.rs.BadRequestException;
import jakarta.ws.rs.ClientErrorException; import jakarta.ws.rs.ClientErrorException;
import jakarta.ws.rs.NotFoundException; import jakarta.ws.rs.NotFoundException;
import jakarta.ws.rs.core.Response; import jakarta.ws.rs.core.Response;
import jakarta.ws.rs.core.UriBuilder;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
@ -139,9 +135,6 @@ public class UserTest extends AbstractAdminTest {
@Page @Page
protected LoginPasswordUpdatePage passwordUpdatePage; protected LoginPasswordUpdatePage passwordUpdatePage;
@ArquillianResource
protected OAuthClient oAuthClient;
@Page @Page
protected InfoPage infoPage; protected InfoPage infoPage;
@ -154,6 +147,12 @@ public class UserTest extends AbstractAdminTest {
@Page @Page
protected LoginPage loginPage; protected LoginPage loginPage;
@Before
public void beforeUserTest() {
createAppClientInRealm(REALM_NAME);
assertAdminEvents.clear();
}
@After @After
public void after() { public void after() {
realm.identityProviders().findAll() realm.identityProviders().findAll()
@ -371,7 +370,6 @@ public class UserTest extends AbstractAdminTest {
} }
@Test @Test
@DisableFeature(value = Profile.Feature.ACCOUNT2, skipRestart = true) // TODO remove this (KEYCLOAK-16228)
public void updateUserWithHashedCredentials() { public void updateUserWithHashedCredentials() {
String userId = createUser("user_hashed_creds", "user_hashed_creds@localhost"); String userId = createUser("user_hashed_creds", "user_hashed_creds@localhost");
@ -387,15 +385,17 @@ public class UserTest extends AbstractAdminTest {
realm.users().get(userId).update(userRepresentation); realm.users().get(userId).update(userRepresentation);
String accountUrl = RealmsResource.accountUrl(UriBuilder.fromUri(getAuthServerRoot())).build(REALM_NAME).toString(); oauth.realm(REALM_NAME);
driver.navigate().to(oauth.getLoginFormUrl());
driver.navigate().to(accountUrl);
assertEquals("Sign in to your account", PageUtils.getPageTitle(driver)); assertEquals("Sign in to your account", PageUtils.getPageTitle(driver));
loginPage.login("user_hashed_creds", "admin"); loginPage.login("user_hashed_creds", "admin");
assertTrue(driver.getTitle().contains("Account Management")); assertTrue(driver.getTitle().contains("AUTH_RESPONSE"));
// oauth cleanup
oauth.realm("test");
} }
@Test @Test
@ -2392,7 +2392,6 @@ public class UserTest extends AbstractAdminTest {
} }
@Test @Test
@DisableFeature(value = Profile.Feature.ACCOUNT2, skipRestart = true) // TODO remove this (KEYCLOAK-16228)
public void resetUserPassword() { public void resetUserPassword() {
String userId = createUser("user1", "user1@localhost"); String userId = createUser("user1", "user1@localhost");
@ -2404,15 +2403,17 @@ public class UserTest extends AbstractAdminTest {
realm.users().get(userId).resetPassword(cred); realm.users().get(userId).resetPassword(cred);
assertAdminEvents.assertEvent(realmId, OperationType.ACTION, AdminEventPaths.userResetPasswordPath(userId), ResourceType.USER); assertAdminEvents.assertEvent(realmId, OperationType.ACTION, AdminEventPaths.userResetPasswordPath(userId), ResourceType.USER);
String accountUrl = RealmsResource.accountUrl(UriBuilder.fromUri(getAuthServerRoot())).build(REALM_NAME).toString(); oauth.realm(REALM_NAME);
driver.navigate().to(oauth.getLoginFormUrl());
driver.navigate().to(accountUrl);
assertEquals("Sign in to your account", PageUtils.getPageTitle(driver)); assertEquals("Sign in to your account", PageUtils.getPageTitle(driver));
loginPage.login("user1", "password"); loginPage.login("user1", "password");
assertTrue(driver.getTitle().contains("Account Management")); assertTrue(driver.getTitle().contains("AUTH_RESPONSE"));
// oauth cleanup
oauth.realm("test");
} }
@Test @Test
@ -2754,19 +2755,18 @@ public class UserTest extends AbstractAdminTest {
} }
@Test @Test
@DisableFeature(value = Profile.Feature.ACCOUNT2, skipRestart = true) // TODO remove this (KEYCLOAK-16228)
public void loginShouldFailAfterPasswordDeleted() { public void loginShouldFailAfterPasswordDeleted() {
String userName = "credential-tester"; String userName = "credential-tester";
String userPass = "s3cr37"; String userPass = "s3cr37";
String userId = createUser(REALM_NAME, userName, userPass); String userId = createUser(REALM_NAME, userName, userPass);
getCleanup(REALM_NAME).addUserId(userId); getCleanup(REALM_NAME).addUserId(userId);
String accountUrl = RealmsResource.accountUrl(UriBuilder.fromUri(getAuthServerRoot())).build(REALM_NAME).toString(); oauth.realm(REALM_NAME);
driver.navigate().to(accountUrl); driver.navigate().to(oauth.getLoginFormUrl());
assertEquals("Test user should be on the login page.", "Sign in to your account", PageUtils.getPageTitle(driver)); assertEquals("Test user should be on the login page.", "Sign in to your account", PageUtils.getPageTitle(driver));
loginPage.login(userName, userPass); loginPage.login(userName, userPass);
assertTrue("Test user should be successfully logged in.", driver.getTitle().contains("Account Management")); assertTrue("Test user should be successfully logged in.", driver.getTitle().contains("AUTH_RESPONSE"));
accountPage.logOut(); AccountHelper.logout(realm, userName);
Optional<CredentialRepresentation> passwordCredential = Optional<CredentialRepresentation> passwordCredential =
realm.users().get(userId).credentials().stream() realm.users().get(userId).credentials().stream()
@ -2775,11 +2775,14 @@ public class UserTest extends AbstractAdminTest {
assertTrue("Test user should have a password credential set.", passwordCredential.isPresent()); assertTrue("Test user should have a password credential set.", passwordCredential.isPresent());
realm.users().get(userId).removeCredential(passwordCredential.get().getId()); realm.users().get(userId).removeCredential(passwordCredential.get().getId());
driver.navigate().to(accountUrl); driver.navigate().to(oauth.getLoginFormUrl());
assertEquals("Test user should be on the login page.", "Sign in to your account", PageUtils.getPageTitle(driver)); assertEquals("Test user should be on the login page.", "Sign in to your account", PageUtils.getPageTitle(driver));
loginPage.login(userName, userPass); loginPage.login(userName, userPass);
assertTrue("Test user should fail to log in after password was deleted.", assertTrue("Test user should fail to log in after password was deleted.",
driver.getCurrentUrl().contains(String.format("/realms/%s/login-actions/authenticate", REALM_NAME))); driver.getCurrentUrl().contains(String.format("/realms/%s/login-actions/authenticate", REALM_NAME)));
//oauth cleanup
oauth.realm("test");
} }
@Test @Test

View file

@ -17,18 +17,15 @@
package org.keycloak.testsuite.admin.client; package org.keycloak.testsuite.admin.client;
import org.jboss.arquillian.graphene.page.Page;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.keycloak.admin.client.resource.ClientResource; import org.keycloak.admin.client.resource.ClientResource;
import org.keycloak.common.Profile;
import org.keycloak.events.admin.OperationType; import org.keycloak.events.admin.OperationType;
import org.keycloak.events.admin.ResourceType; import org.keycloak.events.admin.ResourceType;
import org.keycloak.representations.idm.RealmRepresentation; import org.keycloak.representations.idm.RealmRepresentation;
import org.keycloak.representations.idm.UserRepresentation; import org.keycloak.representations.idm.UserRepresentation;
import org.keycloak.representations.idm.UserSessionRepresentation; import org.keycloak.representations.idm.UserSessionRepresentation;
import org.keycloak.testsuite.arquillian.annotation.DisableFeature; import org.keycloak.testsuite.util.AccountHelper;
import org.keycloak.testsuite.auth.page.account.AccountManagement;
import org.keycloak.testsuite.util.AdminEventPaths; import org.keycloak.testsuite.util.AdminEventPaths;
import java.util.List; import java.util.List;
@ -43,13 +40,8 @@ import static org.keycloak.testsuite.auth.page.AuthRealm.TEST;
* *
* @author Stan Silvert ssilvert@redhat.com (C) 2016 Red Hat Inc. * @author Stan Silvert ssilvert@redhat.com (C) 2016 Red Hat Inc.
*/ */
@DisableFeature(value = Profile.Feature.ACCOUNT2, skipRestart = true) // TODO remove this (KEYCLOAK-16228)
public class SessionTest extends AbstractClientTest { public class SessionTest extends AbstractClientTest {
@Page
protected AccountManagement testRealmAccountManagementPage;
@Before @Before
public void init() { public void init() {
// make user test user exists in test realm // make user test user exists in test realm
@ -63,23 +55,22 @@ public class SessionTest extends AbstractClientTest {
@Override @Override
public void setDefaultPageUriParameters() { public void setDefaultPageUriParameters() {
super.setDefaultPageUriParameters(); super.setDefaultPageUriParameters();
testRealmAccountManagementPage.setAuthRealm(TEST);
loginPage.setAuthRealm(TEST); loginPage.setAuthRealm(TEST);
} }
@Test @Test
public void testGetAppSessionCount() { public void testGetAppSessionCount() {
ClientResource accountClient = findClientResourceById("account"); ClientResource accountClient = findClientResourceById("test-app");
int sessionCount = accountClient.getApplicationSessionCount().get("count"); int sessionCount = accountClient.getApplicationSessionCount().get("count");
assertEquals(0, sessionCount); assertEquals(0, sessionCount);
testRealmAccountManagementPage.navigateTo(); driver.navigate().to(oauth.getLoginFormUrl());
loginPage.form().login(testUser); loginPage.form().login(testUser);
sessionCount = accountClient.getApplicationSessionCount().get("count"); sessionCount = accountClient.getApplicationSessionCount().get("count");
assertEquals(1, sessionCount); assertEquals(1, sessionCount);
testRealmAccountManagementPage.signOut(); AccountHelper.logout(testRealmResource(), testUser.getUsername());
sessionCount = accountClient.getApplicationSessionCount().get("count"); sessionCount = accountClient.getApplicationSessionCount().get("count");
assertEquals(0, sessionCount); assertEquals(0, sessionCount);
@ -88,9 +79,9 @@ public class SessionTest extends AbstractClientTest {
@Test @Test
public void testGetUserSessions() { public void testGetUserSessions() {
//List<java.util.Map<String, String>> stats = this.testRealmResource().getClientSessionStats(); //List<java.util.Map<String, String>> stats = this.testRealmResource().getClientSessionStats();
ClientResource account = findClientResourceById("account"); ClientResource account = findClientResourceById("test-app");
testRealmAccountManagementPage.navigateTo(); driver.navigate().to(oauth.getLoginFormUrl());
loginPage.form().login(testUser); loginPage.form().login(testUser);
List<UserSessionRepresentation> sessions = account.getUserSessions(0, 5); List<UserSessionRepresentation> sessions = account.getUserSessions(0, 5);
@ -103,13 +94,13 @@ public class SessionTest extends AbstractClientTest {
assertEquals(testUserRep.getUsername(), rep.getUsername()); assertEquals(testUserRep.getUsername(), rep.getUsername());
String clientId = account.toRepresentation().getId(); String clientId = account.toRepresentation().getId();
assertEquals("account", rep.getClients().get(clientId)); assertEquals("test-app", rep.getClients().get(clientId));
assertNotNull(rep.getIpAddress()); assertNotNull(rep.getIpAddress());
assertNotNull(rep.getLastAccess()); assertNotNull(rep.getLastAccess());
assertNotNull(rep.getStart()); assertNotNull(rep.getStart());
assertFalse(rep.isRememberMe()); assertFalse(rep.isRememberMe());
testRealmAccountManagementPage.signOut(); AccountHelper.logout(testRealmResource(), testUser.getUsername());
} }
@Test @Test
@ -118,17 +109,17 @@ public class SessionTest extends AbstractClientTest {
realm.setRememberMe(true); realm.setRememberMe(true);
adminClient.realm(TEST).update(realm); adminClient.realm(TEST).update(realm);
testRealmAccountManagementPage.navigateTo(); driver.navigate().to(oauth.getLoginFormUrl());
loginPage.form().rememberMe(true); loginPage.form().rememberMe(true);
loginPage.form().login(testUser); loginPage.form().login(testUser);
ClientResource account = findClientResourceById("account"); ClientResource account = findClientResourceById("test-app");
List<UserSessionRepresentation> sessions = account.getUserSessions(0, 5); List<UserSessionRepresentation> sessions = account.getUserSessions(0, 5);
assertEquals(1, sessions.size()); assertEquals(1, sessions.size());
UserSessionRepresentation rep = sessions.get(0); UserSessionRepresentation rep = sessions.get(0);
assertTrue(rep.isRememberMe()); assertTrue(rep.isRememberMe());
testRealmAccountManagementPage.signOut(); AccountHelper.logout(testRealmResource(), testUser.getUsername());
} }
} }

View file

@ -17,18 +17,11 @@
package org.keycloak.testsuite.admin.event; package org.keycloak.testsuite.admin.event;
import org.jboss.arquillian.graphene.page.Page;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.keycloak.admin.client.resource.RealmResource; import org.keycloak.admin.client.resource.RealmResource;
import org.keycloak.admin.client.resource.UsersResource;
import org.keycloak.common.Profile;
import org.keycloak.events.EventBuilder;
import org.keycloak.events.EventType; import org.keycloak.events.EventType;
import org.keycloak.representations.idm.EventRepresentation; import org.keycloak.representations.idm.EventRepresentation;
import org.keycloak.testsuite.arquillian.annotation.DisableFeature;
import org.keycloak.testsuite.console.page.events.LoginEvents;
import org.keycloak.testsuite.util.UserBuilder;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
@ -45,17 +38,14 @@ import static org.junit.Assert.fail;
* *
* @author Stan Silvert ssilvert@redhat.com (C) 2016 Red Hat Inc. * @author Stan Silvert ssilvert@redhat.com (C) 2016 Red Hat Inc.
*/ */
@DisableFeature(value = Profile.Feature.ACCOUNT2, skipRestart = true) // TODO remove this (KEYCLOAK-16228)
public class LoginEventsTest extends AbstractEventTest { public class LoginEventsTest extends AbstractEventTest {
@Page
private LoginEvents loginEventsPage;
@Before @Before
public void init() { public void init() {
configRep.setEventsEnabled(true); configRep.setEventsEnabled(true);
saveConfig(); saveConfig();
testRealmResource().clearEvents(); testRealmResource().clearEvents();
createAppClientInRealm(testRealmResource().toRepresentation().getRealm());
} }
private List<EventRepresentation> events() { private List<EventRepresentation> events() {
@ -63,7 +53,7 @@ public class LoginEventsTest extends AbstractEventTest {
} }
private void badLogin() { private void badLogin() {
accountPage.navigateTo(); driver.navigate().to(oauth.getLoginFormUrl());
loginPage.form().login("bad", "user"); loginPage.form().login("bad", "user");
} }
@ -189,5 +179,4 @@ public class LoginEventsTest extends AbstractEventTest {
pause(900); // pause 900 seconds pause(900); // pause 900 seconds
assertEquals(0, events().size()); assertEquals(0, events().size());
}**/ }**/
} }