Merge pull request #3977 from vmuzikar/KEYCLOAK-4613
KEYCLOAK-4613 Fix Console UI and Social Login tests
This commit is contained in:
commit
45ea3c8b47
4 changed files with 52 additions and 29 deletions
|
@ -2,11 +2,13 @@ package org.keycloak.testsuite.broker;
|
||||||
|
|
||||||
import org.jboss.arquillian.graphene.Graphene;
|
import org.jboss.arquillian.graphene.Graphene;
|
||||||
import org.jboss.arquillian.graphene.page.Page;
|
import org.jboss.arquillian.graphene.page.Page;
|
||||||
|
import org.junit.After;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.keycloak.representations.idm.IdentityProviderRepresentation;
|
import org.keycloak.representations.idm.IdentityProviderRepresentation;
|
||||||
import org.keycloak.representations.idm.RealmRepresentation;
|
import org.keycloak.representations.idm.RealmRepresentation;
|
||||||
import org.keycloak.social.openshift.OpenshiftV3IdentityProvider;
|
import org.keycloak.social.openshift.OpenshiftV3IdentityProvider;
|
||||||
|
import org.keycloak.representations.idm.UserRepresentation;
|
||||||
import org.keycloak.testsuite.AbstractKeycloakTest;
|
import org.keycloak.testsuite.AbstractKeycloakTest;
|
||||||
import org.keycloak.testsuite.pages.AccountUpdateProfilePage;
|
import org.keycloak.testsuite.pages.AccountUpdateProfilePage;
|
||||||
import org.keycloak.testsuite.pages.LoginPage;
|
import org.keycloak.testsuite.pages.LoginPage;
|
||||||
|
@ -31,6 +33,7 @@ import static org.junit.Assume.assumeTrue;
|
||||||
public class SocialLoginTest extends AbstractKeycloakTest {
|
public class SocialLoginTest extends AbstractKeycloakTest {
|
||||||
|
|
||||||
public static final String SOCIAL_CONFIG = "social.config";
|
public static final String SOCIAL_CONFIG = "social.config";
|
||||||
|
public static final String REALM = "social";
|
||||||
|
|
||||||
private static Properties config = new Properties();
|
private static Properties config = new Properties();
|
||||||
|
|
||||||
|
@ -50,9 +53,17 @@ public class SocialLoginTest extends AbstractKeycloakTest {
|
||||||
config.load(new FileInputStream(System.getProperty(SOCIAL_CONFIG)));
|
config.load(new FileInputStream(System.getProperty(SOCIAL_CONFIG)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@After
|
||||||
|
public void removeUser() {
|
||||||
|
List<UserRepresentation> users = adminClient.realm(REALM).users().search(null, null, null);
|
||||||
|
for (UserRepresentation user : users) {
|
||||||
|
adminClient.realm(REALM).users().get(user.getId()).remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addTestRealms(List<RealmRepresentation> testRealms) {
|
public void addTestRealms(List<RealmRepresentation> testRealms) {
|
||||||
RealmRepresentation rep = RealmBuilder.create().name("social").build();
|
RealmRepresentation rep = RealmBuilder.create().name(REALM).build();
|
||||||
List<IdentityProviderRepresentation> idps = new LinkedList<>();
|
List<IdentityProviderRepresentation> idps = new LinkedList<>();
|
||||||
rep.setIdentityProviders(idps);
|
rep.setIdentityProviders(idps);
|
||||||
|
|
||||||
|
@ -70,7 +81,7 @@ public class SocialLoginTest extends AbstractKeycloakTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void openshiftLogin() throws Exception {
|
public void openshiftLogin() throws Exception {
|
||||||
account.open("social");
|
account.open(REALM);
|
||||||
loginPage.clickSocial("openshift-v3");
|
loginPage.clickSocial("openshift-v3");
|
||||||
|
|
||||||
Graphene.waitGui().until(ExpectedConditions.visibilityOfElementLocated(By.id("inputUsername")));
|
Graphene.waitGui().until(ExpectedConditions.visibilityOfElementLocated(By.id("inputUsername")));
|
||||||
|
@ -86,7 +97,7 @@ public class SocialLoginTest extends AbstractKeycloakTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void googleLogin() throws InterruptedException {
|
public void googleLogin() throws InterruptedException {
|
||||||
account.open("social");
|
account.open(REALM);
|
||||||
|
|
||||||
loginPage.clickSocial("google");
|
loginPage.clickSocial("google");
|
||||||
|
|
||||||
|
@ -111,7 +122,7 @@ public class SocialLoginTest extends AbstractKeycloakTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void faceBookLogin() {
|
public void faceBookLogin() {
|
||||||
account.open("social");
|
account.open(REALM);
|
||||||
|
|
||||||
loginPage.clickSocial("facebook");
|
loginPage.clickSocial("facebook");
|
||||||
|
|
||||||
|
@ -128,7 +139,7 @@ public class SocialLoginTest extends AbstractKeycloakTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void githubLogin() {
|
public void githubLogin() {
|
||||||
account.open("social");
|
account.open(REALM);
|
||||||
|
|
||||||
loginPage.clickSocial("github");
|
loginPage.clickSocial("github");
|
||||||
|
|
||||||
|
@ -145,7 +156,7 @@ public class SocialLoginTest extends AbstractKeycloakTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void twitterLogin() {
|
public void twitterLogin() {
|
||||||
account.open("social");
|
account.open(REALM);
|
||||||
|
|
||||||
loginPage.clickSocial("twitter");
|
loginPage.clickSocial("twitter");
|
||||||
|
|
||||||
|
@ -170,7 +181,7 @@ public class SocialLoginTest extends AbstractKeycloakTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void linkedinLogin() {
|
public void linkedinLogin() {
|
||||||
account.open("social");
|
account.open(REALM);
|
||||||
|
|
||||||
loginPage.clickSocial("linkedin");
|
loginPage.clickSocial("linkedin");
|
||||||
|
|
||||||
|
@ -187,7 +198,7 @@ public class SocialLoginTest extends AbstractKeycloakTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void microsoftLogin() {
|
public void microsoftLogin() {
|
||||||
account.open("social");
|
account.open(REALM);
|
||||||
|
|
||||||
loginPage.clickSocial("microsoft");
|
loginPage.clickSocial("microsoft");
|
||||||
|
|
||||||
|
@ -206,7 +217,7 @@ public class SocialLoginTest extends AbstractKeycloakTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void stackoverflowLogin() {
|
public void stackoverflowLogin() {
|
||||||
account.open("social");
|
account.open(REALM);
|
||||||
|
|
||||||
loginPage.clickSocial("stackoverflow");
|
loginPage.clickSocial("stackoverflow");
|
||||||
|
|
||||||
|
|
|
@ -76,6 +76,12 @@ public abstract class AbstractConsoleTest extends AbstractAuthTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Fix the tests so this workaround is not necessary
|
||||||
|
@Override
|
||||||
|
protected boolean isImportAfterEachMethod() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public void loginToMasterRealmAdminConsoleAs(UserRepresentation user) {
|
public void loginToMasterRealmAdminConsoleAs(UserRepresentation user) {
|
||||||
loginToAdminConsoleAs(adminConsolePage, loginPage, user);
|
loginToAdminConsoleAs(adminConsolePage, loginPage, user);
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,6 @@
|
||||||
*/
|
*/
|
||||||
package org.keycloak.testsuite.console.authentication;
|
package org.keycloak.testsuite.console.authentication;
|
||||||
|
|
||||||
import org.apache.commons.collections.CollectionUtils;
|
|
||||||
import org.jboss.arquillian.graphene.page.Page;
|
import org.jboss.arquillian.graphene.page.Page;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -38,6 +37,7 @@ import org.keycloak.testsuite.console.page.authentication.flows.FlowsTable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static org.hamcrest.CoreMatchers.hasItem;
|
import static org.hamcrest.CoreMatchers.hasItem;
|
||||||
|
@ -74,7 +74,7 @@ public class FlowsTest extends AbstractConsoleTest {
|
||||||
assertAlertSuccess();
|
assertAlertSuccess();
|
||||||
|
|
||||||
// Checking if test flow is created via rest
|
// Checking if test flow is created via rest
|
||||||
AuthenticationFlowRepresentation testFlow = getLastFlowFromREST();
|
AuthenticationFlowRepresentation testFlow = getFlowFromREST("testFlow");
|
||||||
assertEquals("testFlow", testFlow.getAlias());
|
assertEquals("testFlow", testFlow.getAlias());
|
||||||
|
|
||||||
// Checking if testFlow is selected in UI
|
// Checking if testFlow is selected in UI
|
||||||
|
@ -86,7 +86,7 @@ public class FlowsTest extends AbstractConsoleTest {
|
||||||
assertAlertSuccess();
|
assertAlertSuccess();
|
||||||
|
|
||||||
// Checking if execution flow is created via rest
|
// Checking if execution flow is created via rest
|
||||||
testFlow = getLastFlowFromREST();
|
testFlow = getFlowFromREST("testFlow");
|
||||||
assertEquals("testExecution", testFlow.getAuthenticationExecutions().get(0).getFlowAlias());
|
assertEquals("testExecution", testFlow.getAuthenticationExecutions().get(0).getFlowAlias());
|
||||||
|
|
||||||
// Checking if testFlow is selected in UI
|
// Checking if testFlow is selected in UI
|
||||||
|
@ -98,7 +98,6 @@ public class FlowsTest extends AbstractConsoleTest {
|
||||||
assertAlertSuccess();
|
assertAlertSuccess();
|
||||||
|
|
||||||
// Checking if both test flow and execution flow is removed via UI
|
// Checking if both test flow and execution flow is removed via UI
|
||||||
assertEquals("Browser", flowsPage.getFlowSelectValue());
|
|
||||||
assertThat(flowsPage.getFlowAllValues(), not(hasItem("TestFlow")));
|
assertThat(flowsPage.getFlowAllValues(), not(hasItem("TestFlow")));
|
||||||
|
|
||||||
// Checking if both test flow and execution flow is removed via rest
|
// Checking if both test flow and execution flow is removed via rest
|
||||||
|
@ -152,7 +151,7 @@ public class FlowsTest extends AbstractConsoleTest {
|
||||||
//rest: copied flow present
|
//rest: copied flow present
|
||||||
assertThat(testRealmResource().flows().getFlows().stream()
|
assertThat(testRealmResource().flows().getFlows().stream()
|
||||||
.map(AuthenticationFlowRepresentation::getAlias).
|
.map(AuthenticationFlowRepresentation::getAlias).
|
||||||
collect(Collectors.toList()), hasItem(getLastFlowFromREST().getAlias()));
|
collect(Collectors.toList()), hasItem(getFlowFromREST("test copy of browser").getAlias()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -168,8 +167,9 @@ public class FlowsTest extends AbstractConsoleTest {
|
||||||
assertAlertSuccess();
|
assertAlertSuccess();
|
||||||
|
|
||||||
// REST
|
// REST
|
||||||
assertEquals(1, getLastFlowFromREST().getAuthenticationExecutions().size());
|
AuthenticationFlowRepresentation flowRest = getFlowFromREST("testFlow");
|
||||||
assertEquals("reset-password", getLastFlowFromREST().getAuthenticationExecutions().get(0).getAuthenticator());
|
assertEquals(1, flowRest.getAuthenticationExecutions().size());
|
||||||
|
assertEquals("reset-password", flowRest.getAuthenticationExecutions().get(0).getAuthenticator());
|
||||||
|
|
||||||
// UI
|
// UI
|
||||||
assertEquals("TestFlow", flowsPage.getFlowSelectValue());
|
assertEquals("TestFlow", flowsPage.getFlowSelectValue());
|
||||||
|
@ -222,10 +222,12 @@ public class FlowsTest extends AbstractConsoleTest {
|
||||||
assertTrue(expectedOrder.containsAll(flowsPage.table().getFlowsAliasesWithRequirements().keySet()));
|
assertTrue(expectedOrder.containsAll(flowsPage.table().getFlowsAliasesWithRequirements().keySet()));
|
||||||
|
|
||||||
//REST
|
//REST
|
||||||
assertEquals("auth-spnego", getLastFlowFromREST().getAuthenticationExecutions().get(0).getAuthenticator());
|
List<AuthenticationExecutionExportRepresentation> executionsRest =
|
||||||
assertEquals("auth-cookie", getLastFlowFromREST().getAuthenticationExecutions().get(1).getAuthenticator());
|
getFlowFromREST("Copy of browser").getAuthenticationExecutions();
|
||||||
assertEquals("Copy of browser forms", getLastFlowFromREST().getAuthenticationExecutions().get(2).getFlowAlias());
|
assertEquals("auth-spnego", executionsRest.get(0).getAuthenticator());
|
||||||
assertEquals("identity-provider-redirector", getLastFlowFromREST().getAuthenticationExecutions().get(3).getAuthenticator());
|
assertEquals("auth-cookie", executionsRest.get(1).getAuthenticator());
|
||||||
|
assertEquals("Copy of browser forms", executionsRest.get(2).getFlowAlias());
|
||||||
|
assertEquals("identity-provider-redirector", executionsRest.get(3).getAuthenticator());
|
||||||
flowsPage.clickDelete();
|
flowsPage.clickDelete();
|
||||||
modalDialog.confirmDeletion();
|
modalDialog.confirmDeletion();
|
||||||
}
|
}
|
||||||
|
@ -252,8 +254,7 @@ public class FlowsTest extends AbstractConsoleTest {
|
||||||
assertTrue(expectedOrder.containsAll(flowsPage.table().getFlowsAliasesWithRequirements().values()));
|
assertTrue(expectedOrder.containsAll(flowsPage.table().getFlowsAliasesWithRequirements().values()));
|
||||||
|
|
||||||
//REST:
|
//REST:
|
||||||
List<AuthenticationExecutionExportRepresentation> browserFlow = testRealmResource().flows()
|
List<AuthenticationExecutionExportRepresentation> browserFlow = getFlowFromREST("browser").getAuthenticationExecutions();
|
||||||
.getFlows().get(0).getAuthenticationExecutions();
|
|
||||||
assertEquals("DISABLED", browserFlow.get(0).getRequirement());
|
assertEquals("DISABLED", browserFlow.get(0).getRequirement());
|
||||||
assertEquals("ALTERNATIVE", browserFlow.get(1).getRequirement());
|
assertEquals("ALTERNATIVE", browserFlow.get(1).getRequirement());
|
||||||
assertEquals("ALTERNATIVE", browserFlow.get(2).getRequirement());
|
assertEquals("ALTERNATIVE", browserFlow.get(2).getRequirement());
|
||||||
|
@ -289,16 +290,22 @@ public class FlowsTest extends AbstractConsoleTest {
|
||||||
assertTrue(expectedOrder.containsAll(flowsPage.table().getFlowsAliasesWithRequirements().keySet()));
|
assertTrue(expectedOrder.containsAll(flowsPage.table().getFlowsAliasesWithRequirements().keySet()));
|
||||||
|
|
||||||
//REST
|
//REST
|
||||||
assertEquals("identity-provider-redirector", getLastFlowFromREST().getAuthenticationExecutions().get(0).getAuthenticator());
|
List<AuthenticationExecutionExportRepresentation> executionsRest =
|
||||||
String tmpFlowAlias = getLastFlowFromREST().getAuthenticationExecutions().get(1).getFlowAlias();
|
getFlowFromREST("Copy of browser").getAuthenticationExecutions();
|
||||||
|
assertEquals("identity-provider-redirector", executionsRest.get(0).getAuthenticator());
|
||||||
|
String tmpFlowAlias = executionsRest.get(1).getFlowAlias();
|
||||||
assertEquals("Copy of browser forms", tmpFlowAlias);
|
assertEquals("Copy of browser forms", tmpFlowAlias);
|
||||||
assertEquals("Username Password Form", testRealmResource().flows().getExecutions(tmpFlowAlias).get(0).getDisplayName());
|
assertEquals("Username Password Form", testRealmResource().flows().getExecutions(tmpFlowAlias).get(0).getDisplayName());
|
||||||
assertEquals("nestedFlow", testRealmResource().flows().getExecutions(tmpFlowAlias).get(2).getDisplayName());
|
assertEquals("nestedFlow", testRealmResource().flows().getExecutions(tmpFlowAlias).get(2).getDisplayName());
|
||||||
}
|
}
|
||||||
|
|
||||||
private AuthenticationFlowRepresentation getLastFlowFromREST() {
|
private AuthenticationFlowRepresentation getFlowFromREST(String alias) {
|
||||||
List<AuthenticationFlowRepresentation> allFlows = testRealmResource().flows().getFlows();
|
Optional<AuthenticationFlowRepresentation> flow = testRealmResource()
|
||||||
return (AuthenticationFlowRepresentation) CollectionUtils.
|
.flows()
|
||||||
get(allFlows, (allFlows.size() - 1));
|
.getFlows()
|
||||||
|
.stream()
|
||||||
|
.filter(f -> f.getAlias().equals(alias))
|
||||||
|
.findFirst();
|
||||||
|
return flow.isPresent() ? flow.get() : null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,7 +87,6 @@ public abstract class AbstractClientTest extends AbstractConsoleTest {
|
||||||
attributes.put(SAML_SIGNATURE_ALGORITHM, "RSA_SHA256");
|
attributes.put(SAML_SIGNATURE_ALGORITHM, "RSA_SHA256");
|
||||||
attributes.put(SAML_FORCE_NAME_ID_FORMAT, "false");
|
attributes.put(SAML_FORCE_NAME_ID_FORMAT, "false");
|
||||||
attributes.put(SAML_NAME_ID_FORMAT, "username");
|
attributes.put(SAML_NAME_ID_FORMAT, "username");
|
||||||
attributes.put(SAML_ONETIMEUSE_CONDITION, "true");
|
|
||||||
return attributes;
|
return attributes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue