Skip to content

Commit

Permalink
added UI tests for client mappers oidc
Browse files Browse the repository at this point in the history
  • Loading branch information
vramik committed Dec 2, 2015
1 parent c4f3bd3 commit 2b25c12
Show file tree
Hide file tree
Showing 17 changed files with 650 additions and 198 deletions.

This file was deleted.

This file was deleted.

@@ -0,0 +1,63 @@
/*
* JBoss, Home of Professional Open Source.
* Copyright 2012, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.keycloak.testsuite.console.page.clients.mappers;

import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;

/**
*
* @author <a href="mailto:vramik@redhat.com">Vlastislav Ramik</a>
*/
public class ClientMapper extends ClientMappers {

public static final String MAPPER_ID = "mapperId";

@FindBy(xpath = "//i[contains(@class, 'delete')]")
private WebElement deleteIcon;

@FindBy(tagName = "form")
private MapperSettingsForm form;

@Override
public String getUriFragment() {
return super.getUriFragment() + "/{" + MAPPER_ID + "}";
}

public void setMapperId(String id) {
setUriParameter(MAPPER_ID, id);
}

public String getMapperId() {
return getUriParameter(MAPPER_ID).toString();
}

@Override
public void delete() {
deleteIcon.click();
modalDialog.confirmDeletion();
}

public MapperSettingsForm form() {
return form;
}
}
@@ -1,4 +1,4 @@
package org.keycloak.testsuite.console.page.clients; package org.keycloak.testsuite.console.page.clients.mappers;


import org.keycloak.representations.idm.ProtocolMapperRepresentation; import org.keycloak.representations.idm.ProtocolMapperRepresentation;
import org.keycloak.testsuite.console.page.fragment.DataTable; import org.keycloak.testsuite.console.page.fragment.DataTable;
Expand All @@ -8,6 +8,7 @@


import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.keycloak.testsuite.console.page.clients.Client;


/** /**
* *
Expand All @@ -32,6 +33,9 @@ public ClientMapperTable mapperTable() {


public class ClientMapperTable extends DataTable { public class ClientMapperTable extends DataTable {


@FindBy(xpath = "//button[text() = 'Add selected']")
private WebElement addSelectedButton;

public List<ProtocolMapperRepresentation> searchMappings(String searchPattern) { public List<ProtocolMapperRepresentation> searchMappings(String searchPattern) {
search(searchPattern); search(searchPattern);
return getMappingsFromRows(); return getMappingsFromRows();
Expand Down Expand Up @@ -80,6 +84,14 @@ public void deleteMapper(String mapperName) {
public void deleteMapper(ProtocolMapperRepresentation mapper) { public void deleteMapper(ProtocolMapperRepresentation mapper) {
clickMapperActionButton(mapper, DELETE); clickMapperActionButton(mapper, DELETE);
} }

public void checkBuiltinMapper(String mapperName) {
body().findElement(By.xpath("//td[text() = '" + mapperName + "']/..//input")).click();
}

public void clickAddSelectedBuiltinMapper() {
addSelectedButton.click();
}


public ProtocolMapperRepresentation getMappingFromRow(WebElement row) { public ProtocolMapperRepresentation getMappingFromRow(WebElement row) {
if (!row.isDisplayed()) {return null;} // Is that necessary? if (!row.isDisplayed()) {return null;} // Is that necessary?
Expand All @@ -96,7 +108,7 @@ public ProtocolMapperRepresentation getMappingFromRow(WebElement row) {
} }


public List<ProtocolMapperRepresentation> getMappingsFromRows() { public List<ProtocolMapperRepresentation> getMappingsFromRows() {
List<ProtocolMapperRepresentation> mappings = new ArrayList<ProtocolMapperRepresentation>(); List<ProtocolMapperRepresentation> mappings = new ArrayList<>();


for (WebElement row : rows()) { for (WebElement row : rows()) {
ProtocolMapperRepresentation mapperRepresentation = getMappingFromRow(row); ProtocolMapperRepresentation mapperRepresentation = getMappingFromRow(row);
Expand Down
@@ -1,4 +1,4 @@
package org.keycloak.testsuite.console.page.clients; package org.keycloak.testsuite.console.page.clients.mappers;


import org.jboss.arquillian.graphene.page.Page; import org.jboss.arquillian.graphene.page.Page;
import org.keycloak.testsuite.console.page.AdminConsoleCreate; import org.keycloak.testsuite.console.page.AdminConsoleCreate;
Expand Down
@@ -1,15 +1,11 @@
package org.keycloak.testsuite.console.page.clients; package org.keycloak.testsuite.console.page.clients.mappers;


import org.jboss.arquillian.test.api.ArquillianResource;
import org.keycloak.testsuite.console.page.fragment.OnOffSwitch; import org.keycloak.testsuite.console.page.fragment.OnOffSwitch;
import org.keycloak.testsuite.page.Form; import org.keycloak.testsuite.page.Form;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement; import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.support.FindBy; import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.ui.Select; import org.openqa.selenium.support.ui.Select;


import java.util.List;


/** /**
* @author Vaclav Muzikar <vmuzikar@redhat.com> * @author Vaclav Muzikar <vmuzikar@redhat.com>
Expand All @@ -27,7 +23,12 @@ public class CreateClientMappersForm extends Form {
public static final String USERS_FULL_NAME = "User's full name"; public static final String USERS_FULL_NAME = "User's full name";
public static final String USER_ATTRIBUTE = "User Attribute"; public static final String USER_ATTRIBUTE = "User Attribute";
public static final String USER_PROPERTY = "User Property"; public static final String USER_PROPERTY = "User Property";
public static final String GROUP_MEMBERSHIP = "Group Membership";


// Role types
public static final String REALM_ROLE = "realm";
public static final String CLIENT_ROLE = "client";

@FindBy(id = "name") @FindBy(id = "name")
private WebElement nameElement; private WebElement nameElement;


Expand All @@ -52,7 +53,7 @@ public class CreateClientMappersForm extends Form {
@FindBy(xpath = ".//div[@properties='mapperType.properties']//label[text()='Multivalued']//following-sibling::node()//div[@class='onoffswitch']") @FindBy(xpath = ".//div[@properties='mapperType.properties']//label[text()='Multivalued']//following-sibling::node()//div[@class='onoffswitch']")
private OnOffSwitch multivaluedInput; private OnOffSwitch multivaluedInput;


@FindBy(xpath = ".//div[@properties='mapperType.properties']//label[text()='Role']//following-sibling::node()//input[@type='text']") @FindBy(xpath = ".//button[text() = 'Select Role']/../..//input")
private WebElement roleInput; private WebElement roleInput;


@FindBy(xpath = ".//div[@properties='mapperType.properties']//label[text()='New Role Name']//following-sibling::node()//input[@type='text']") @FindBy(xpath = ".//div[@properties='mapperType.properties']//label[text()='New Role Name']//following-sibling::node()//input[@type='text']")
Expand All @@ -72,7 +73,74 @@ public class CreateClientMappersForm extends Form {


@FindBy(xpath = ".//div[@properties='mapperType.properties']//label[text()='Add to access token']//following-sibling::node()//div[@class='onoffswitch']") @FindBy(xpath = ".//div[@properties='mapperType.properties']//label[text()='Add to access token']//following-sibling::node()//div[@class='onoffswitch']")
private OnOffSwitch addToAccessTokenInput; private OnOffSwitch addToAccessTokenInput;


@FindBy(xpath = ".//div[@properties='mapperType.properties']//label[text()='Full group path']//following-sibling::node()//div[@class='onoffswitch']")
private OnOffSwitch fullGroupPath;

@FindBy(xpath = ".//button[text() = 'Select Role']")
private WebElement selectRoleButton;

@FindBy(xpath = "//div[@class='modal-dialog']")
private RoleSelectorModalDialog roleSelectorModalDialog;

public class RoleSelectorModalDialog {
@FindBy(id = "available")
private Select realmAvailable;
@FindBy(xpath = ".//button[@tooltip='Select realm role']")
private WebElement selectRealmRoleButton;

@FindBy(id = "available-client")
private Select clientAvailable;
@FindBy(id = "clients")
private Select clientSelect;
@FindBy(xpath = ".//button[@tooltip='Select client role']")
private WebElement selectClientRoleButton;
@FindBy(xpath = ".//button[@class='close']")
private WebElement closeButton;

public void closeRoleSelectorModalDialog() {
closeButton.click();
}

public void selectRealmRole(String roleName) {
if (roleName != null) {
realmAvailable.selectByVisibleText(roleName);
}
selectRealmRoleButton.click();
}

public void selectClientRole(String clientName, String roleName) {
if (roleName != null || clientName != null) {
clientSelect.selectByVisibleText(clientName);
clientAvailable.selectByVisibleText(roleName);
}
selectClientRoleButton.click();
}
}

public void selectRole(String roleType, String roleName, String clientName) {
selectRoleButton.click();
switch (roleType) {
case REALM_ROLE:
roleSelectorModalDialog.selectRealmRole(roleName);
break;
case CLIENT_ROLE:
roleSelectorModalDialog.selectClientRole(clientName, roleName);
break;
default:
throw new IllegalArgumentException("No such role type, use \"" +
REALM_ROLE + "\" or \"" + CLIENT_ROLE + "\"");
}
}

public void closeRoleSelectorModalDialog() {
roleSelectorModalDialog.closeRoleSelectorModalDialog();
}

public void setName(String value) {
setInputValue(nameElement, value);
}

public boolean isConsentRequired() { public boolean isConsentRequired() {
return consentRequiredSwitch.isOn(); return consentRequiredSwitch.isOn();
} }
Expand All @@ -89,10 +157,6 @@ public void setConsentText(String consentText) {
setInputValue(consentTextElement, consentText); setInputValue(consentTextElement, consentText);
} }


public String getMapperType() {
return mapperTypeSelect.getFirstSelectedOption().getText();
}

public void setMapperType(String type) { public void setMapperType(String type) {
mapperTypeSelect.selectByVisibleText(type); mapperTypeSelect.selectByVisibleText(type);
} }
Expand Down Expand Up @@ -184,4 +248,13 @@ public boolean isAddToAccessToken() {
public void setAddToAccessToken(boolean value) { public void setAddToAccessToken(boolean value) {
addToAccessTokenInput.setOn(value); addToAccessTokenInput.setOn(value);
} }

public boolean isFullGroupPath() {
return fullGroupPath.isOn();
}

public void setFullGroupPath(boolean value) {
fullGroupPath.setOn(value);
}

} }
@@ -0,0 +1,56 @@
/*
* JBoss, Home of Professional Open Source.
* Copyright 2012, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.keycloak.testsuite.console.page.clients.mappers;

import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;

/**
* @author <a href="mailto:vramik@redhat.com">Vlastislav Ramik</a>
*/
public class MapperSettingsForm extends CreateClientMappersForm {

@FindBy(id = "protocol")
private WebElement protocolInput;
@FindBy(id = "mapperId")
private WebElement mapperIdInput;
@FindBy(id = "name")
private WebElement nameInput;
@FindBy(id = "mapperType")
private WebElement mapperTypeInput;

public String getProtocol() {
return getInputValue(protocolInput);
}

public String getMapperId() {
return getInputValue(mapperIdInput);
}

public String getName() {
return getInputValue(nameInput);
}

public String getMapperType() {
return getInputValue(mapperTypeInput);
}
}

0 comments on commit 2b25c12

Please sign in to comment.