UserStorageTest - old account console dependencies removed. Closes #19668

This commit is contained in:
Lukas Hanusovsky 2023-05-05 14:19:51 +02:00 committed by Michal Hajas
parent b8b9adbea2
commit 406aa21b0b

View file

@ -11,7 +11,6 @@ import org.junit.Rule;
import org.junit.Test;
import org.keycloak.admin.client.resource.RealmResource;
import org.keycloak.admin.client.resource.UserResource;
import org.keycloak.common.Profile;
import org.keycloak.common.util.MultivaluedHashMap;
import org.keycloak.common.util.ObjectUtil;
import org.keycloak.common.util.reflections.Types;
@ -39,15 +38,16 @@ import org.keycloak.storage.UserStorageProvider;
import org.keycloak.storage.UserStorageUtil;
import org.keycloak.testsuite.AbstractAuthTest;
import org.keycloak.testsuite.admin.ApiUtil;
import org.keycloak.testsuite.arquillian.annotation.DisableFeature;
import org.keycloak.testsuite.arquillian.annotation.ModelTest;
import org.keycloak.testsuite.federation.UserMapStorage;
import org.keycloak.testsuite.federation.UserMapStorageFactory;
import org.keycloak.testsuite.federation.UserPropertyFileStorageFactory;
import org.keycloak.testsuite.pages.AppPage;
import org.keycloak.testsuite.pages.LoginPage;
import org.keycloak.testsuite.pages.RegisterPage;
import org.keycloak.testsuite.pages.VerifyEmailPage;
import org.keycloak.testsuite.updaters.RealmAttributeUpdater;
import org.keycloak.testsuite.util.AccountHelper;
import org.keycloak.testsuite.util.GreenMailRule;
import org.keycloak.testsuite.util.TestCleanup;
import org.openqa.selenium.Cookie;
@ -73,7 +73,6 @@ import java.util.stream.Stream;
import static java.util.Calendar.DAY_OF_WEEK;
import static java.util.Calendar.HOUR_OF_DAY;
import static java.util.Calendar.MINUTE;
import static org.hamcrest.Matchers.contains;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.Matchers.is;
@ -94,13 +93,11 @@ import static org.keycloak.storage.UserStorageProviderModel.MAX_LIFESPAN;
import static org.keycloak.testsuite.actions.RequiredActionEmailVerificationTest.getPasswordResetEmailLink;
import static org.keycloak.testsuite.util.URLAssert.assertCurrentUrlDoesntStartWith;
import static org.keycloak.testsuite.util.URLAssert.assertCurrentUrlStartsWith;
/**
*
* @author tkyjovsk
*/
@DisableFeature(value = Profile.Feature.ACCOUNT2, skipRestart = true) // TODO remove this (KEYCLOAK-16228)
public class UserStorageTest extends AbstractAuthTest {
private String memProviderId;
@ -113,6 +110,9 @@ public class UserStorageTest extends AbstractAuthTest {
@Page
protected LoginPage loginPage;
@Page
protected AppPage appPage;
@Page
protected RegisterPage registerPage;
@ -207,16 +207,16 @@ public class UserStorageTest extends AbstractAuthTest {
}
private void loginSuccessAndLogout(String username, String password) {
testRealmAccountPage.navigateTo();
loginPage.open();
testRealmLoginPage.form().login(username, password);
assertCurrentUrlStartsWith(testRealmAccountPage);
testRealmAccountPage.logOut();
appPage.assertCurrent();
AccountHelper.logout(testRealmResource(), username);
}
public void loginBadPassword(String username) {
testRealmAccountPage.navigateTo();
loginPage.open();
testRealmLoginPage.form().login(username, "badpassword");
assertCurrentUrlDoesntStartWith(testRealmAccountPage);
assertCurrentUrlDoesntStartWith(oauth.APP_AUTH_ROOT);
}
// @Test
@ -249,9 +249,10 @@ public class UserStorageTest extends AbstractAuthTest {
@Test
public void testLoginSuccessWithSpecialCharacter() {
testRealmAccountPage.navigateTo();
loginPage.open();
testRealmLoginPage.form().login("spécial", "pw");
assertCurrentUrlStartsWith(testRealmAccountPage);
appPage.assertCurrent();
driver.navigate().to(oauth.AUTH_SERVER_ROOT + "/realms/" + testRealmResource().toRepresentation().getRealm() + "/login-actions/authenticate/" );
Cookie sameSiteSessionCookie = driver.manage().getCookieNamed(KEYCLOAK_SESSION_COOKIE);
Cookie legacySessionCookie = driver.manage().getCookieNamed(KEYCLOAK_SESSION_COOKIE + LEGACY_COOKIE);
@ -264,7 +265,7 @@ public class UserStorageTest extends AbstractAuthTest {
Assert.assertThat(legacyCookieValue.contains("spécial"), is(false));
Assert.assertThat(legacyCookieValue.contains("sp%C3%A9cial"), is(true));
testRealmAccountPage.logOut();
AccountHelper.logout(testRealmResource(), "spécial");
}
@Test
@ -345,7 +346,8 @@ public class UserStorageTest extends AbstractAuthTest {
Assert.assertNull(thor.getFirstName());
Assert.assertNull(thor.getLastName());
Assert.assertNull(thor.getEmail());
Assert.assertNull(thor.getAttributes());
// user after logout has set this attribute: fedNotBefore
Assert.assertTrue(thor.getAttributes().size() == 1);
Assert.assertFalse(thor.isEmailVerified());
foundGroup = false;
@ -380,7 +382,7 @@ public class UserStorageTest extends AbstractAuthTest {
})
.update()) {
testRealmAccountPage.navigateTo();
loginPage.open();
loginPage.clickRegister();
registerPage.register("firstName", "lastName", "email@mail.com", "verifyEmail", "password", "password");
@ -394,7 +396,7 @@ public class UserStorageTest extends AbstractAuthTest {
driver.navigate().to(verificationUrl.trim());
testRealmAccountPage.assertCurrent();
appPage.assertCurrent();
}
}