KEYCLOAK-12606 Add test

This commit is contained in:
mhajas 2020-02-26 15:34:13 +01:00 committed by Hynek Mlnařík
parent 1ca417c2c0
commit df11a8a864
2 changed files with 35 additions and 6 deletions

View file

@ -8,11 +8,17 @@ import static org.keycloak.testsuite.broker.BrokerTestConstants.IDP_OIDC_PROVIDE
import static org.keycloak.testsuite.broker.BrokerTestConstants.USER_EMAIL; import static org.keycloak.testsuite.broker.BrokerTestConstants.USER_EMAIL;
import static org.keycloak.testsuite.broker.BrokerTestTools.createIdentityProvider; import static org.keycloak.testsuite.broker.BrokerTestTools.createIdentityProvider;
import static org.keycloak.testsuite.broker.BrokerTestTools.waitForPage; import static org.keycloak.testsuite.broker.BrokerTestTools.waitForPage;
import static org.keycloak.testsuite.util.WaitUtils.waitForPageToLoad;
import org.junit.Test;
import org.keycloak.admin.client.resource.UserResource;
import org.keycloak.admin.client.resource.UsersResource; import org.keycloak.admin.client.resource.UsersResource;
import org.keycloak.representations.idm.IdentityProviderRepresentation; import org.keycloak.representations.idm.IdentityProviderRepresentation;
import org.keycloak.representations.idm.UserRepresentation; import org.keycloak.representations.idm.UserRepresentation;
import org.keycloak.testsuite.Assert; import org.keycloak.testsuite.Assert;
import org.keycloak.testsuite.arquillian.SuiteContext; import org.keycloak.testsuite.arquillian.SuiteContext;
import org.keycloak.testsuite.updaters.Creator;
import org.keycloak.testsuite.util.UserBuilder;
public class KcOidcBrokerLoginHintTest extends AbstractBrokerTest { public class KcOidcBrokerLoginHintTest extends AbstractBrokerTest {
@ -21,11 +27,6 @@ public class KcOidcBrokerLoginHintTest extends AbstractBrokerTest {
return new KcOidcBrokerConfigurationWithLoginHint(); return new KcOidcBrokerConfigurationWithLoginHint();
} }
@Override
protected String getAccountUrl(String realmName) {
return BrokerTestTools.getAuthRoot(suiteContext) + "/auth/realms/" + realmName + "/account";
}
private class KcOidcBrokerConfigurationWithLoginHint extends KcOidcBrokerConfiguration { private class KcOidcBrokerConfigurationWithLoginHint extends KcOidcBrokerConfiguration {
@Override @Override
@ -86,4 +87,32 @@ public class KcOidcBrokerLoginHintTest extends AbstractBrokerTest {
Assert.assertTrue("There must be user " + bc.getUserLogin() + " in realm " + bc.consumerRealmName(), Assert.assertTrue("There must be user " + bc.getUserLogin() + " in realm " + bc.consumerRealmName(),
isUserFound); isUserFound);
} }
@Test
public void loginHintWithExistingUser() {
try (Creator<UserResource> c = Creator.create(adminClient.realm(bc.consumerRealmName()),
UserBuilder.create()
.username(bc.getUserLogin())
.password(bc.getUserPassword())
.email(bc.getUserEmail())
.enabled(true)
.build()
)) {
driver.navigate().to(getAccountUrl(bc.consumerRealmName()));
waitForPageToLoad();
driver.navigate().to(driver.getCurrentUrl() + "&login_hint=" + USER_EMAIL + "&kc_idp_hint=" + IDP_OIDC_ALIAS);
waitForPageToLoad();
loginPage.login(bc.getUserPassword());
updateAccountInformationPage.assertCurrent();
updateAccountInformationPage.updateAccountInformation(bc.getUserLogin(), bc.getUserEmail(), "Firstname", "Lastname");
idpConfirmLinkPage.assertCurrent();
idpConfirmLinkPage.clickLinkAccount();
loginPage.login(bc.getUserPassword());
accountPage.isCurrent();
}
}
} }

View file

@ -15,7 +15,7 @@ import org.keycloak.representations.idm.UserRepresentation;
import org.keycloak.testsuite.Assert; import org.keycloak.testsuite.Assert;
import org.keycloak.testsuite.arquillian.SuiteContext; import org.keycloak.testsuite.arquillian.SuiteContext;
public class KcOidcBrokerNoLoginHintTest extends KcOidcBrokerLoginHintTest { public class KcOidcBrokerNoLoginHintTest extends AbstractBrokerTest {
@Override @Override
protected BrokerConfiguration getBrokerConfiguration() { protected BrokerConfiguration getBrokerConfiguration() {