Old account console dependencies removed. Closes #19668
* ConsentsTest * UserTest * SessionTest * LoginEventsTest * AbstractKeycloakTest
This commit is contained in:
parent
9943c977de
commit
5e323ae173
5 changed files with 71 additions and 63 deletions
|
@ -17,6 +17,7 @@
|
|||
package org.keycloak.testsuite;
|
||||
|
||||
import io.appium.java_client.AppiumDriver;
|
||||
import jakarta.ws.rs.core.Response;
|
||||
import org.apache.commons.configuration.ConfigurationException;
|
||||
import org.apache.commons.configuration.PropertiesConfiguration;
|
||||
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.UserCache;
|
||||
import org.keycloak.models.utils.TimeBasedOTP;
|
||||
import org.keycloak.protocol.oidc.OIDCAdvancedConfigWrapper;
|
||||
import org.keycloak.provider.Provider;
|
||||
import org.keycloak.representations.idm.ClientRepresentation;
|
||||
import org.keycloak.representations.idm.RealmRepresentation;
|
||||
|
@ -194,7 +196,7 @@ public abstract class AbstractKeycloakTest {
|
|||
}
|
||||
|
||||
oauth.init(driver);
|
||||
|
||||
createAppClientInRealm("test");
|
||||
}
|
||||
|
||||
public void reconnectAdminClient() throws Exception {
|
||||
|
@ -586,6 +588,23 @@ public abstract class AbstractKeycloakTest {
|
|||
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) {
|
||||
AuthenticationManagementResource managementResource = adminClient.realm(realm).flows();
|
||||
|
||||
|
@ -771,4 +790,6 @@ public abstract class AbstractKeycloakTest {
|
|||
.fetchString(s -> s.getKeycloakSessionFactory().getProviderFactory(UserCache.class));
|
||||
return Objects.nonNull(userCache);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -28,7 +28,6 @@ import org.keycloak.admin.client.resource.ClientResource;
|
|||
import org.keycloak.admin.client.resource.RealmResource;
|
||||
import org.keycloak.admin.client.resource.UserResource;
|
||||
import org.keycloak.admin.client.resource.UsersResource;
|
||||
import org.keycloak.common.Profile;
|
||||
import org.keycloak.events.Details;
|
||||
import org.keycloak.events.Errors;
|
||||
import org.keycloak.models.ClientModel;
|
||||
|
@ -42,7 +41,6 @@ import org.keycloak.representations.idm.UserSessionRepresentation;
|
|||
import org.keycloak.testsuite.AbstractKeycloakTest;
|
||||
import org.keycloak.testsuite.Assert;
|
||||
import org.keycloak.testsuite.AssertEvents;
|
||||
import org.keycloak.testsuite.arquillian.annotation.DisableFeature;
|
||||
import org.keycloak.testsuite.pages.AppPage;
|
||||
import org.keycloak.testsuite.pages.ConsentPage;
|
||||
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>
|
||||
*/
|
||||
@DisableFeature(value = Profile.Feature.ACCOUNT2, skipRestart = true) // TODO remove this (KEYCLOAK-16228)
|
||||
public class ConsentsTest extends AbstractKeycloakTest {
|
||||
|
||||
final static String REALM_PROV_NAME = "provider";
|
||||
|
@ -268,7 +265,10 @@ public class ConsentsTest extends AbstractKeycloakTest {
|
|||
|
||||
@Test
|
||||
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());
|
||||
accountLoginPage.clickSocial(getIDPAlias());
|
||||
|
@ -338,6 +338,10 @@ public class ConsentsTest extends AbstractKeycloakTest {
|
|||
sessions = userResource.getUserSessions();
|
||||
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());
|
||||
|
||||
// oauth clean up
|
||||
oauth.realm("test");
|
||||
oauth.redirectUri(oauth.SERVER_ROOT + "/auth/realms/master/app/auth");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -20,8 +20,8 @@ package org.keycloak.testsuite.admin;
|
|||
import org.hamcrest.Matchers;
|
||||
import org.jboss.arquillian.drone.api.annotation.Drone;
|
||||
import org.jboss.arquillian.graphene.page.Page;
|
||||
import org.jboss.arquillian.test.api.ArquillianResource;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Rule;
|
||||
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.UserResource;
|
||||
import org.keycloak.admin.client.resource.UsersResource;
|
||||
import org.keycloak.common.Profile;
|
||||
import org.keycloak.common.VerificationException;
|
||||
import org.keycloak.common.util.Base64;
|
||||
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.RoleRepresentation;
|
||||
import org.keycloak.representations.idm.UserRepresentation;
|
||||
import org.keycloak.services.resources.RealmsResource;
|
||||
import org.keycloak.storage.UserStorageProvider;
|
||||
import org.keycloak.testsuite.arquillian.annotation.DisableFeature;
|
||||
import org.keycloak.testsuite.federation.DummyUserFederationProviderFactory;
|
||||
import org.keycloak.testsuite.page.LoginPasswordUpdatePage;
|
||||
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.runonserver.RunHelpers;
|
||||
import org.keycloak.testsuite.updaters.Creator;
|
||||
import org.keycloak.testsuite.util.AccountHelper;
|
||||
import org.keycloak.testsuite.util.AdminClientUtil;
|
||||
import org.keycloak.testsuite.util.AdminEventPaths;
|
||||
import org.keycloak.testsuite.util.ClientBuilder;
|
||||
import org.keycloak.testsuite.util.GreenMailRule;
|
||||
import org.keycloak.testsuite.util.GroupBuilder;
|
||||
import org.keycloak.testsuite.util.MailUtils;
|
||||
import org.keycloak.testsuite.util.OAuthClient;
|
||||
import org.keycloak.testsuite.util.RealmBuilder;
|
||||
import org.keycloak.testsuite.util.RoleBuilder;
|
||||
import org.keycloak.testsuite.util.UserBuilder;
|
||||
|
@ -93,7 +90,6 @@ import jakarta.ws.rs.BadRequestException;
|
|||
import jakarta.ws.rs.ClientErrorException;
|
||||
import jakarta.ws.rs.NotFoundException;
|
||||
import jakarta.ws.rs.core.Response;
|
||||
import jakarta.ws.rs.core.UriBuilder;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
@ -139,9 +135,6 @@ public class UserTest extends AbstractAdminTest {
|
|||
@Page
|
||||
protected LoginPasswordUpdatePage passwordUpdatePage;
|
||||
|
||||
@ArquillianResource
|
||||
protected OAuthClient oAuthClient;
|
||||
|
||||
@Page
|
||||
protected InfoPage infoPage;
|
||||
|
||||
|
@ -154,6 +147,12 @@ public class UserTest extends AbstractAdminTest {
|
|||
@Page
|
||||
protected LoginPage loginPage;
|
||||
|
||||
@Before
|
||||
public void beforeUserTest() {
|
||||
createAppClientInRealm(REALM_NAME);
|
||||
assertAdminEvents.clear();
|
||||
}
|
||||
|
||||
@After
|
||||
public void after() {
|
||||
realm.identityProviders().findAll()
|
||||
|
@ -371,7 +370,6 @@ public class UserTest extends AbstractAdminTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
@DisableFeature(value = Profile.Feature.ACCOUNT2, skipRestart = true) // TODO remove this (KEYCLOAK-16228)
|
||||
public void updateUserWithHashedCredentials() {
|
||||
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);
|
||||
|
||||
String accountUrl = RealmsResource.accountUrl(UriBuilder.fromUri(getAuthServerRoot())).build(REALM_NAME).toString();
|
||||
|
||||
driver.navigate().to(accountUrl);
|
||||
oauth.realm(REALM_NAME);
|
||||
driver.navigate().to(oauth.getLoginFormUrl());
|
||||
|
||||
assertEquals("Sign in to your account", PageUtils.getPageTitle(driver));
|
||||
|
||||
loginPage.login("user_hashed_creds", "admin");
|
||||
|
||||
assertTrue(driver.getTitle().contains("Account Management"));
|
||||
assertTrue(driver.getTitle().contains("AUTH_RESPONSE"));
|
||||
|
||||
// oauth cleanup
|
||||
oauth.realm("test");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -2392,7 +2392,6 @@ public class UserTest extends AbstractAdminTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
@DisableFeature(value = Profile.Feature.ACCOUNT2, skipRestart = true) // TODO remove this (KEYCLOAK-16228)
|
||||
public void resetUserPassword() {
|
||||
String userId = createUser("user1", "user1@localhost");
|
||||
|
||||
|
@ -2404,15 +2403,17 @@ public class UserTest extends AbstractAdminTest {
|
|||
realm.users().get(userId).resetPassword(cred);
|
||||
assertAdminEvents.assertEvent(realmId, OperationType.ACTION, AdminEventPaths.userResetPasswordPath(userId), ResourceType.USER);
|
||||
|
||||
String accountUrl = RealmsResource.accountUrl(UriBuilder.fromUri(getAuthServerRoot())).build(REALM_NAME).toString();
|
||||
|
||||
driver.navigate().to(accountUrl);
|
||||
oauth.realm(REALM_NAME);
|
||||
driver.navigate().to(oauth.getLoginFormUrl());
|
||||
|
||||
assertEquals("Sign in to your account", PageUtils.getPageTitle(driver));
|
||||
|
||||
loginPage.login("user1", "password");
|
||||
|
||||
assertTrue(driver.getTitle().contains("Account Management"));
|
||||
assertTrue(driver.getTitle().contains("AUTH_RESPONSE"));
|
||||
|
||||
// oauth cleanup
|
||||
oauth.realm("test");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -2754,19 +2755,18 @@ public class UserTest extends AbstractAdminTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
@DisableFeature(value = Profile.Feature.ACCOUNT2, skipRestart = true) // TODO remove this (KEYCLOAK-16228)
|
||||
public void loginShouldFailAfterPasswordDeleted() {
|
||||
String userName = "credential-tester";
|
||||
String userPass = "s3cr37";
|
||||
String userId = createUser(REALM_NAME, userName, userPass);
|
||||
getCleanup(REALM_NAME).addUserId(userId);
|
||||
|
||||
String accountUrl = RealmsResource.accountUrl(UriBuilder.fromUri(getAuthServerRoot())).build(REALM_NAME).toString();
|
||||
driver.navigate().to(accountUrl);
|
||||
oauth.realm(REALM_NAME);
|
||||
driver.navigate().to(oauth.getLoginFormUrl());
|
||||
assertEquals("Test user should be on the login page.", "Sign in to your account", PageUtils.getPageTitle(driver));
|
||||
loginPage.login(userName, userPass);
|
||||
assertTrue("Test user should be successfully logged in.", driver.getTitle().contains("Account Management"));
|
||||
accountPage.logOut();
|
||||
assertTrue("Test user should be successfully logged in.", driver.getTitle().contains("AUTH_RESPONSE"));
|
||||
AccountHelper.logout(realm, userName);
|
||||
|
||||
Optional<CredentialRepresentation> passwordCredential =
|
||||
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());
|
||||
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));
|
||||
loginPage.login(userName, userPass);
|
||||
assertTrue("Test user should fail to log in after password was deleted.",
|
||||
driver.getCurrentUrl().contains(String.format("/realms/%s/login-actions/authenticate", REALM_NAME)));
|
||||
|
||||
//oauth cleanup
|
||||
oauth.realm("test");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -17,18 +17,15 @@
|
|||
|
||||
package org.keycloak.testsuite.admin.client;
|
||||
|
||||
import org.jboss.arquillian.graphene.page.Page;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.keycloak.admin.client.resource.ClientResource;
|
||||
import org.keycloak.common.Profile;
|
||||
import org.keycloak.events.admin.OperationType;
|
||||
import org.keycloak.events.admin.ResourceType;
|
||||
import org.keycloak.representations.idm.RealmRepresentation;
|
||||
import org.keycloak.representations.idm.UserRepresentation;
|
||||
import org.keycloak.representations.idm.UserSessionRepresentation;
|
||||
import org.keycloak.testsuite.arquillian.annotation.DisableFeature;
|
||||
import org.keycloak.testsuite.auth.page.account.AccountManagement;
|
||||
import org.keycloak.testsuite.util.AccountHelper;
|
||||
import org.keycloak.testsuite.util.AdminEventPaths;
|
||||
|
||||
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.
|
||||
*/
|
||||
@DisableFeature(value = Profile.Feature.ACCOUNT2, skipRestart = true) // TODO remove this (KEYCLOAK-16228)
|
||||
public class SessionTest extends AbstractClientTest {
|
||||
|
||||
|
||||
@Page
|
||||
protected AccountManagement testRealmAccountManagementPage;
|
||||
|
||||
@Before
|
||||
public void init() {
|
||||
// make user test user exists in test realm
|
||||
|
@ -63,23 +55,22 @@ public class SessionTest extends AbstractClientTest {
|
|||
@Override
|
||||
public void setDefaultPageUriParameters() {
|
||||
super.setDefaultPageUriParameters();
|
||||
testRealmAccountManagementPage.setAuthRealm(TEST);
|
||||
loginPage.setAuthRealm(TEST);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetAppSessionCount() {
|
||||
ClientResource accountClient = findClientResourceById("account");
|
||||
ClientResource accountClient = findClientResourceById("test-app");
|
||||
int sessionCount = accountClient.getApplicationSessionCount().get("count");
|
||||
assertEquals(0, sessionCount);
|
||||
|
||||
testRealmAccountManagementPage.navigateTo();
|
||||
driver.navigate().to(oauth.getLoginFormUrl());
|
||||
loginPage.form().login(testUser);
|
||||
|
||||
sessionCount = accountClient.getApplicationSessionCount().get("count");
|
||||
assertEquals(1, sessionCount);
|
||||
|
||||
testRealmAccountManagementPage.signOut();
|
||||
AccountHelper.logout(testRealmResource(), testUser.getUsername());
|
||||
|
||||
sessionCount = accountClient.getApplicationSessionCount().get("count");
|
||||
assertEquals(0, sessionCount);
|
||||
|
@ -88,9 +79,9 @@ public class SessionTest extends AbstractClientTest {
|
|||
@Test
|
||||
public void testGetUserSessions() {
|
||||
//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);
|
||||
|
||||
List<UserSessionRepresentation> sessions = account.getUserSessions(0, 5);
|
||||
|
@ -103,13 +94,13 @@ public class SessionTest extends AbstractClientTest {
|
|||
assertEquals(testUserRep.getUsername(), rep.getUsername());
|
||||
|
||||
String clientId = account.toRepresentation().getId();
|
||||
assertEquals("account", rep.getClients().get(clientId));
|
||||
assertEquals("test-app", rep.getClients().get(clientId));
|
||||
assertNotNull(rep.getIpAddress());
|
||||
assertNotNull(rep.getLastAccess());
|
||||
assertNotNull(rep.getStart());
|
||||
assertFalse(rep.isRememberMe());
|
||||
|
||||
testRealmAccountManagementPage.signOut();
|
||||
AccountHelper.logout(testRealmResource(), testUser.getUsername());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -118,17 +109,17 @@ public class SessionTest extends AbstractClientTest {
|
|||
realm.setRememberMe(true);
|
||||
adminClient.realm(TEST).update(realm);
|
||||
|
||||
testRealmAccountManagementPage.navigateTo();
|
||||
driver.navigate().to(oauth.getLoginFormUrl());
|
||||
loginPage.form().rememberMe(true);
|
||||
loginPage.form().login(testUser);
|
||||
|
||||
ClientResource account = findClientResourceById("account");
|
||||
ClientResource account = findClientResourceById("test-app");
|
||||
List<UserSessionRepresentation> sessions = account.getUserSessions(0, 5);
|
||||
assertEquals(1, sessions.size());
|
||||
|
||||
UserSessionRepresentation rep = sessions.get(0);
|
||||
assertTrue(rep.isRememberMe());
|
||||
|
||||
testRealmAccountManagementPage.signOut();
|
||||
AccountHelper.logout(testRealmResource(), testUser.getUsername());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,18 +17,11 @@
|
|||
|
||||
package org.keycloak.testsuite.admin.event;
|
||||
|
||||
import org.jboss.arquillian.graphene.page.Page;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
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.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.List;
|
||||
|
@ -45,17 +38,14 @@ import static org.junit.Assert.fail;
|
|||
*
|
||||
* @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 {
|
||||
|
||||
@Page
|
||||
private LoginEvents loginEventsPage;
|
||||
|
||||
@Before
|
||||
public void init() {
|
||||
configRep.setEventsEnabled(true);
|
||||
saveConfig();
|
||||
testRealmResource().clearEvents();
|
||||
createAppClientInRealm(testRealmResource().toRepresentation().getRealm());
|
||||
}
|
||||
|
||||
private List<EventRepresentation> events() {
|
||||
|
@ -63,7 +53,7 @@ public class LoginEventsTest extends AbstractEventTest {
|
|||
}
|
||||
|
||||
private void badLogin() {
|
||||
accountPage.navigateTo();
|
||||
driver.navigate().to(oauth.getLoginFormUrl());
|
||||
loginPage.form().login("bad", "user");
|
||||
}
|
||||
|
||||
|
@ -189,5 +179,4 @@ public class LoginEventsTest extends AbstractEventTest {
|
|||
pause(900); // pause 900 seconds
|
||||
assertEquals(0, events().size());
|
||||
}**/
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue