KEYCLOAK-10420 Broker tests don't work with RH-SSO
This commit is contained in:
parent
1bdf77f409
commit
90b35cc13d
8 changed files with 39 additions and 34 deletions
|
@ -142,7 +142,7 @@ public abstract class AbstractAdvancedBrokerTest extends AbstractBrokerTest {
|
|||
|
||||
driver.navigate().to(getAccountUrl(bc.consumerRealmName()));
|
||||
logInWithBroker(bc);
|
||||
waitForPage(driver, "keycloak account management", true);
|
||||
waitForAccountManagementTitle();
|
||||
accountUpdateProfilePage.assertCurrent();
|
||||
logoutFromRealm(bc.providerRealmName());
|
||||
logoutFromRealm(bc.consumerRealmName());
|
||||
|
@ -175,7 +175,7 @@ public abstract class AbstractAdvancedBrokerTest extends AbstractBrokerTest {
|
|||
driver.navigate().to(getAccountUrl(bc.consumerRealmName()));
|
||||
logInWithBroker(bc);
|
||||
updatePasswordPage.updatePasswords("password", "password");
|
||||
waitForPage(driver, "keycloak account management", true);
|
||||
waitForAccountManagementTitle();
|
||||
accountUpdateProfilePage.assertCurrent();
|
||||
|
||||
String username = bc.getUserLogin();
|
||||
|
@ -421,7 +421,7 @@ public abstract class AbstractAdvancedBrokerTest extends AbstractBrokerTest {
|
|||
driver.getCurrentUrl().contains("/auth/realms/" + bc.providerRealmName() + "/"));
|
||||
log.debug("Logging in");
|
||||
loginPage.login(bc.getUserLogin(), bc.getUserPassword());
|
||||
waitForPage(driver, "keycloak account management", true);
|
||||
waitForAccountManagementTitle();
|
||||
accountUpdateProfilePage.assertCurrent();
|
||||
}
|
||||
|
||||
|
@ -475,7 +475,7 @@ public abstract class AbstractAdvancedBrokerTest extends AbstractBrokerTest {
|
|||
driver.navigate().to(getAccountUrl(bc.consumerRealmName()));
|
||||
loginPage.clickSocial(bc.getIDPAlias());
|
||||
loginPage.login("test-user", "password");
|
||||
waitForPage(driver, "keycloak account management", true);
|
||||
waitForAccountManagementTitle();
|
||||
accountUpdateProfilePage.assertCurrent();
|
||||
|
||||
accountPage.password();
|
||||
|
@ -492,7 +492,7 @@ public abstract class AbstractAdvancedBrokerTest extends AbstractBrokerTest {
|
|||
driver.navigate().to(getAccountUrl(bc.consumerRealmName()));
|
||||
loginPage.clickSocial(bc.getIDPAlias());
|
||||
loginPage.login("test-user-noemail", "password");
|
||||
waitForPage(driver, "keycloak account management", true);
|
||||
waitForAccountManagementTitle();
|
||||
accountUpdateProfilePage.assertCurrent();
|
||||
|
||||
accountPage.password();
|
||||
|
|
|
@ -32,6 +32,8 @@ import org.keycloak.representations.idm.UserRepresentation;
|
|||
import org.keycloak.services.resources.RealmsResource;
|
||||
import org.keycloak.testsuite.AbstractKeycloakTest;
|
||||
import org.keycloak.testsuite.Assert;
|
||||
import org.keycloak.testsuite.arquillian.annotation.AuthServerContainerExclude;
|
||||
import org.keycloak.testsuite.arquillian.annotation.AuthServerContainerExclude.AuthServer;
|
||||
import org.keycloak.testsuite.pages.AccountApplicationsPage;
|
||||
import org.keycloak.testsuite.pages.AccountFederatedIdentityPage;
|
||||
import org.keycloak.testsuite.pages.AccountPasswordPage;
|
||||
|
@ -62,8 +64,6 @@ import static org.junit.Assert.assertEquals;
|
|||
import static org.junit.Assert.assertThat;
|
||||
import static org.keycloak.testsuite.admin.ApiUtil.createUserWithAdminClient;
|
||||
import static org.keycloak.testsuite.admin.ApiUtil.resetUserPassword;
|
||||
import org.keycloak.testsuite.arquillian.annotation.AuthServerContainerExclude;
|
||||
import org.keycloak.testsuite.arquillian.annotation.AuthServerContainerExclude.AuthServer;
|
||||
import static org.keycloak.testsuite.broker.BrokerTestConstants.USER_EMAIL;
|
||||
import static org.keycloak.testsuite.broker.BrokerTestTools.encodeUrl;
|
||||
import static org.keycloak.testsuite.broker.BrokerTestTools.waitForPage;
|
||||
|
@ -275,12 +275,18 @@ public abstract class AbstractBaseBrokerTest extends AbstractKeycloakTest {
|
|||
|
||||
|
||||
protected void assertLoggedInAccountManagement() {
|
||||
waitForPage(driver, "keycloak account management", true);
|
||||
waitForAccountManagementTitle();
|
||||
Assert.assertTrue(accountUpdateProfilePage.isCurrent());
|
||||
Assert.assertEquals(accountUpdateProfilePage.getUsername(), bc.getUserLogin());
|
||||
Assert.assertEquals(accountUpdateProfilePage.getEmail(), bc.getUserEmail());
|
||||
}
|
||||
|
||||
protected void waitForAccountManagementTitle() {
|
||||
boolean isProduct = adminClient.serverInfo().getInfo().getProfileInfo().getName().equals("product");
|
||||
String title = isProduct ? "rh-sso account management" : "keycloak account management";
|
||||
waitForPage(driver, title, true);
|
||||
}
|
||||
|
||||
|
||||
protected void assertErrorPage(String expectedError) {
|
||||
errorPage.assertCurrent();
|
||||
|
|
|
@ -106,7 +106,7 @@ public abstract class AbstractFirstBrokerLoginTest extends AbstractInitializedBa
|
|||
}
|
||||
|
||||
loginPage.login("password");
|
||||
waitForPage(driver, "keycloak account management", true);
|
||||
waitForAccountManagementTitle();
|
||||
accountUpdateProfilePage.assertCurrent();
|
||||
|
||||
assertNumFederatedIdentities(existingUser, 1);
|
||||
|
@ -177,7 +177,7 @@ public abstract class AbstractFirstBrokerLoginTest extends AbstractInitializedBa
|
|||
|
||||
// Use correct password now
|
||||
loginPage.login("password");
|
||||
waitForPage(driver, "keycloak account management", true);
|
||||
waitForAccountManagementTitle();
|
||||
accountUpdateProfilePage.assertCurrent();
|
||||
assertNumFederatedIdentities(userId, 1);
|
||||
}
|
||||
|
@ -229,7 +229,7 @@ public abstract class AbstractFirstBrokerLoginTest extends AbstractInitializedBa
|
|||
this.passwordUpdatePage.assertCurrent();
|
||||
this.passwordUpdatePage.changePassword("password", "password");
|
||||
|
||||
waitForPage(driver, "keycloak account management", true);
|
||||
waitForAccountManagementTitle();
|
||||
accountUpdateProfilePage.assertCurrent();
|
||||
assertNumFederatedIdentities(existingUser, 1);
|
||||
}
|
||||
|
@ -309,7 +309,7 @@ public abstract class AbstractFirstBrokerLoginTest extends AbstractInitializedBa
|
|||
driver.navigate().to(getAccountUrl(bc.consumerRealmName()));
|
||||
logInWithBroker(bc);
|
||||
|
||||
waitForPage(driver, "keycloak account management", true);
|
||||
waitForAccountManagementTitle();
|
||||
accountUpdateProfilePage.assertCurrent();
|
||||
}
|
||||
|
||||
|
@ -378,7 +378,7 @@ public abstract class AbstractFirstBrokerLoginTest extends AbstractInitializedBa
|
|||
|
||||
waitForPage(driver, "update password", false);
|
||||
updatePasswordPage.updatePasswords("password", "password");
|
||||
waitForPage(driver, "keycloak account management", true);
|
||||
waitForAccountManagementTitle();
|
||||
accountUpdateProfilePage.assertCurrent();
|
||||
}
|
||||
|
||||
|
@ -420,7 +420,7 @@ public abstract class AbstractFirstBrokerLoginTest extends AbstractInitializedBa
|
|||
waitForPage(driver, "update account information", false);
|
||||
Assert.assertTrue(updateAccountInformationPage.isCurrent());
|
||||
updateAccountInformationPage.updateAccountInformation("test", "test@localhost.com", "FirstName", "LastName");
|
||||
waitForPage(driver, "keycloak account management", true);
|
||||
waitForAccountManagementTitle();
|
||||
accountUpdateProfilePage.assertCurrent();
|
||||
}
|
||||
|
||||
|
@ -456,7 +456,7 @@ public abstract class AbstractFirstBrokerLoginTest extends AbstractInitializedBa
|
|||
updateAccountInformationPage.assertCurrent();
|
||||
updateAccountInformationPage.updateAccountInformation("FirstName", "LastName");
|
||||
|
||||
waitForPage(driver, "keycloak account management", true);
|
||||
waitForAccountManagementTitle();
|
||||
accountUpdateProfilePage.assertCurrent();
|
||||
testingClient.server().run(assertHardCodedSessionNote());
|
||||
}
|
||||
|
@ -490,7 +490,7 @@ public abstract class AbstractFirstBrokerLoginTest extends AbstractInitializedBa
|
|||
}
|
||||
|
||||
updateAccountInformationPage.updateAccountInformation("test@redhat.com", "FirstName", "LastName");
|
||||
waitForPage(driver, "keycloak account management", true);
|
||||
waitForAccountManagementTitle();
|
||||
accountUpdateProfilePage.assertCurrent();
|
||||
|
||||
assertEquals(1, realm.users().search("test@redhat.com").size());
|
||||
|
@ -570,7 +570,7 @@ public abstract class AbstractFirstBrokerLoginTest extends AbstractInitializedBa
|
|||
"verify your email address", false);
|
||||
|
||||
driver.navigate().to(verificationUrl.trim());
|
||||
waitForPage(driver, "keycloak account management", true);
|
||||
waitForAccountManagementTitle();
|
||||
accountUpdateProfilePage.assertCurrent();
|
||||
}
|
||||
|
||||
|
@ -600,7 +600,7 @@ public abstract class AbstractFirstBrokerLoginTest extends AbstractInitializedBa
|
|||
log.debug("Logging in");
|
||||
loginPage.login("no-email", "password");
|
||||
|
||||
waitForPage(driver, "keycloak account management", true);
|
||||
waitForAccountManagementTitle();
|
||||
accountUpdateProfilePage.assertCurrent();
|
||||
|
||||
List<UserRepresentation> users = realm.users().search("no-email");
|
||||
|
@ -637,7 +637,7 @@ public abstract class AbstractFirstBrokerLoginTest extends AbstractInitializedBa
|
|||
updateAccountInformationPage.assertCurrent();
|
||||
updateAccountInformationPage.updateAccountInformation("FirstName", "LastName");
|
||||
|
||||
waitForPage(driver, "keycloak account management", true);
|
||||
waitForAccountManagementTitle();
|
||||
accountUpdateProfilePage.assertCurrent();
|
||||
|
||||
List<UserRepresentation> users = realm.users().search(bc.getUserLogin());
|
||||
|
@ -680,7 +680,7 @@ public abstract class AbstractFirstBrokerLoginTest extends AbstractInitializedBa
|
|||
"verify your email address", false);
|
||||
|
||||
driver.navigate().to(verificationUrl.trim());
|
||||
waitForPage(driver, "keycloak account management", true);
|
||||
waitForAccountManagementTitle();
|
||||
accountUpdateProfilePage.assertCurrent();
|
||||
|
||||
List<UserRepresentation> users = realm.users().search(bc.getUserLogin());
|
||||
|
@ -838,7 +838,7 @@ public abstract class AbstractFirstBrokerLoginTest extends AbstractInitializedBa
|
|||
waitForPage(driver, "update account information", false);
|
||||
updateAccountInformationPage.assertCurrent();
|
||||
updateAccountInformationPage.updateAccountInformation("FirstName", "LastName");
|
||||
waitForPage(driver, "keycloak account management", true);
|
||||
waitForAccountManagementTitle();
|
||||
accountUpdateProfilePage.assertCurrent();
|
||||
|
||||
logoutFromRealm(bc.providerRealmName());
|
||||
|
@ -856,7 +856,7 @@ public abstract class AbstractFirstBrokerLoginTest extends AbstractInitializedBa
|
|||
waitForPage(driver, "update account information", false);
|
||||
updateAccountInformationPage.assertCurrent();
|
||||
updateAccountInformationPage.updateAccountInformation("FirstName", "LastName");
|
||||
waitForPage(driver, "keycloak account management", true);
|
||||
waitForAccountManagementTitle();
|
||||
accountUpdateProfilePage.assertCurrent();
|
||||
|
||||
logoutFromRealm(bc.providerRealmName());
|
||||
|
@ -875,7 +875,7 @@ public abstract class AbstractFirstBrokerLoginTest extends AbstractInitializedBa
|
|||
updateAccountInformationPage.assertCurrent();
|
||||
updateAccountInformationPage.updateAccountInformation("no-email@localhost.com", "FirstName", "LastName");
|
||||
|
||||
waitForPage(driver, "keycloak account management", true);
|
||||
waitForAccountManagementTitle();
|
||||
accountUpdateProfilePage.assertCurrent();
|
||||
}
|
||||
|
||||
|
@ -897,7 +897,7 @@ public abstract class AbstractFirstBrokerLoginTest extends AbstractInitializedBa
|
|||
log.debug("Logging in");
|
||||
loginPage.login("all-info-set", "password");
|
||||
|
||||
waitForPage(driver, "keycloak account management", true);
|
||||
waitForAccountManagementTitle();
|
||||
accountUpdateProfilePage.assertCurrent();
|
||||
}
|
||||
|
||||
|
@ -911,7 +911,7 @@ public abstract class AbstractFirstBrokerLoginTest extends AbstractInitializedBa
|
|||
|
||||
driver.navigate().to(getAccountUrl(bc.consumerRealmName()));
|
||||
logInWithBroker(bc);
|
||||
waitForPage(driver, "keycloak account management", true);
|
||||
waitForAccountManagementTitle();
|
||||
accountUpdateProfilePage.assertCurrent();
|
||||
}
|
||||
|
||||
|
|
|
@ -76,8 +76,7 @@ public class KcOidcBrokerLogoutTest extends AbstractBaseBrokerTest {
|
|||
logoutFromRealm(bc.consumerRealmName(), "kc-oidc-idp");
|
||||
driver.navigate().to(getAccountUrl(REALM_PROV_NAME));
|
||||
|
||||
//could be 'keycloak account management' or 'rh-sso account management'
|
||||
waitForPage(driver, " account management", true);
|
||||
waitForAccountManagementTitle();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -70,7 +70,7 @@ public class KcOidcBrokerPromptNoneRedirectTest extends AbstractInitializedBaseB
|
|||
|
||||
/* no need to log in again, the idp should have been able to identify that the user is already logged in and the authenticated user should
|
||||
have been established in the consumer realm. Lastly, user must be redirected to the account app as expected. */
|
||||
waitForPage(driver, "keycloak account management", true);
|
||||
waitForAccountManagementTitle();
|
||||
Assert.assertTrue(driver.getCurrentUrl().contains("/auth/realms/" + bc.consumerRealmName() + "/account"));
|
||||
accountUpdateProfilePage.assertCurrent();
|
||||
|
||||
|
@ -215,7 +215,7 @@ public class KcOidcBrokerPromptNoneRedirectTest extends AbstractInitializedBaseB
|
|||
driver.getCurrentUrl().contains("/auth/realms/" + bc.providerRealmName() + "/"));
|
||||
loginPage.login(bc.getUserLogin(), bc.getUserPassword());
|
||||
|
||||
waitForPage(driver, "keycloak account management", true);
|
||||
waitForAccountManagementTitle();
|
||||
Assert.assertTrue(driver.getCurrentUrl().contains("/auth/realms/" + bc.providerRealmName() + "/account"));
|
||||
accountUpdateProfilePage.assertCurrent();
|
||||
}
|
||||
|
|
|
@ -269,7 +269,7 @@ public final class KcOidcBrokerTest extends AbstractAdvancedBrokerTest {
|
|||
|
||||
loginTotpPage.assertCurrent();
|
||||
loginTotpPage.login(totp.generateTOTP(totpSecret));
|
||||
waitForPage(driver, "keycloak account management", true);
|
||||
waitForAccountManagementTitle();
|
||||
accountUpdateProfilePage.assertCurrent();
|
||||
|
||||
assertNumFederatedIdentities(consumerRealm.users().search(samlBrokerConfig.getUserLogin()).get(0).getId(), 2);
|
||||
|
|
|
@ -223,7 +223,7 @@ public class KcOidcFirstBrokerLoginNewAuthTest extends AbstractInitializedBaseBr
|
|||
|
||||
|
||||
private void assertUserAuthenticatedInConsumer(String consumerRealmUserId) {
|
||||
waitForPage(driver, "keycloak account management", true);
|
||||
waitForAccountManagementTitle();
|
||||
accountUpdateProfilePage.assertCurrent();
|
||||
assertNumFederatedIdentities(consumerRealmUserId, 1);
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ public class KcOidcFirstBrokerLoginTest extends AbstractFirstBrokerLoginTest {
|
|||
driver.navigate().to(getAccountUrl(bc.consumerRealmName()));
|
||||
|
||||
logInWithBroker(samlBrokerConfig);
|
||||
waitForPage(driver, "keycloak account management", true);
|
||||
waitForAccountManagementTitle();
|
||||
accountUpdateProfilePage.assertCurrent();
|
||||
logoutFromRealm(bc.consumerRealmName());
|
||||
|
||||
|
@ -62,7 +62,7 @@ public class KcOidcFirstBrokerLoginTest extends AbstractFirstBrokerLoginTest {
|
|||
|
||||
log.debug("Clicking social " + samlBrokerConfig.getIDPAlias());
|
||||
loginPage.clickSocial(samlBrokerConfig.getIDPAlias());
|
||||
waitForPage(driver, "keycloak account management", true);
|
||||
waitForAccountManagementTitle();
|
||||
accountUpdateProfilePage.assertCurrent();
|
||||
|
||||
assertNumFederatedIdentities(consumerRealm.users().search(samlBrokerConfig.getUserLogin()).get(0).getId(), 2);
|
||||
|
@ -103,7 +103,7 @@ public class KcOidcFirstBrokerLoginTest extends AbstractFirstBrokerLoginTest {
|
|||
// User is federated after log in with the original broker
|
||||
log.debug("Clicking social " + samlBrokerConfig.getIDPAlias());
|
||||
loginPage.clickSocial(samlBrokerConfig.getIDPAlias());
|
||||
waitForPage(driver, "keycloak account management", true);
|
||||
waitForAccountManagementTitle();
|
||||
accountUpdateProfilePage.assertCurrent();
|
||||
|
||||
assertNumFederatedIdentities(consumerRealm.users().search(samlBrokerConfig.getUserLogin()).get(0).getId(), 1);
|
||||
|
|
Loading…
Reference in a new issue