From beee0c1e672fe66158db58a9f7161d26daab7c84 Mon Sep 17 00:00:00 2001 From: Bartosz Majsak Date: Fri, 3 Mar 2017 14:55:40 +0100 Subject: [PATCH] Implements social login test for OpenShift --- .../testsuite/broker/SocialLoginTest.java | 25 ++++++++++++++++--- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/broker/SocialLoginTest.java b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/broker/SocialLoginTest.java index 6ac3970ca6..46c856ec4c 100644 --- a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/broker/SocialLoginTest.java +++ b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/broker/SocialLoginTest.java @@ -2,15 +2,12 @@ package org.keycloak.testsuite.broker; import org.jboss.arquillian.graphene.Graphene; import org.jboss.arquillian.graphene.page.Page; -import org.jboss.arquillian.graphene.wait.WebDriverWait; -import org.junit.Assume; import org.junit.BeforeClass; import org.junit.Test; -import org.keycloak.common.Profile; import org.keycloak.representations.idm.IdentityProviderRepresentation; import org.keycloak.representations.idm.RealmRepresentation; +import org.keycloak.social.openshift.OpenshiftV3IdentityProvider; import org.keycloak.testsuite.AbstractKeycloakTest; -import org.keycloak.testsuite.cli.exec.ExecutionException; import org.keycloak.testsuite.pages.AccountUpdateProfilePage; import org.keycloak.testsuite.pages.LoginPage; import org.keycloak.testsuite.pages.LoginUpdateProfilePage; @@ -59,6 +56,7 @@ public class SocialLoginTest extends AbstractKeycloakTest { List idps = new LinkedList<>(); rep.setIdentityProviders(idps); + idps.add(buildIdp("openshift-v3")); idps.add(buildIdp("google")); idps.add(buildIdp("facebook")); idps.add(buildIdp("github")); @@ -70,6 +68,22 @@ public class SocialLoginTest extends AbstractKeycloakTest { testRealms.add(rep); } + @Test + public void openshiftLogin() throws Exception { + account.open("social"); + loginPage.clickSocial("openshift-v3"); + + Graphene.waitGui().until(ExpectedConditions.visibilityOfElementLocated(By.id("inputUsername"))); + driver.findElement(By.id("inputUsername")).sendKeys(config.getProperty("openshift-v3.username", config.getProperty("common.username"))); + driver.findElement(By.id("inputPassword")).sendKeys(config.getProperty("openshift-v3.password", config.getProperty("common.password"))); + driver.findElement(By.cssSelector("button[type=submit]")).click(); + + Graphene.waitGui().until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("input[name=approve]"))); + driver.findElement(By.cssSelector("input[name=approve]")).click(); + + assertEquals(config.getProperty("openshift-v3.username", config.getProperty("common.profile.username")), account.getUsername()); + } + @Test public void googleLogin() throws InterruptedException { account.open("social"); @@ -226,6 +240,9 @@ public class SocialLoginTest extends AbstractKeycloakTest { if (id.equals("stackoverflow")) { idp.getConfig().put("key", config.getProperty(id + ".clientKey")); } + if (id.equals("openshift-v3")) { + idp.getConfig().put("baseUrl", config.getProperty(id + ".baseUrl", OpenshiftV3IdentityProvider.BASE_URL)); + } return idp; }