Merge pull request #4735 from vmuzikar/fix-ui
KEYCLOAK-5816, KEYCLOAK-5815 UI tests fixes
This commit is contained in:
commit
a8bcdfb401
17 changed files with 265 additions and 133 deletions
|
@ -25,6 +25,7 @@ import org.openqa.selenium.support.FindBy;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import static org.keycloak.testsuite.util.UIUtils.clickLink;
|
||||||
import static org.keycloak.testsuite.util.WaitUtils.pause;
|
import static org.keycloak.testsuite.util.WaitUtils.pause;
|
||||||
import static org.keycloak.testsuite.util.WaitUtils.waitForPageToLoad;
|
import static org.keycloak.testsuite.util.WaitUtils.waitForPageToLoad;
|
||||||
import static org.openqa.selenium.By.xpath;
|
import static org.openqa.selenium.By.xpath;
|
||||||
|
@ -55,17 +56,15 @@ public class DataTable {
|
||||||
|
|
||||||
public void search(String pattern) {
|
public void search(String pattern) {
|
||||||
searchInput.sendKeys(pattern);
|
searchInput.sendKeys(pattern);
|
||||||
searchButton.click();
|
clickLink(searchButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clickHeaderButton(String buttonText) {
|
public void clickHeaderButton(String buttonText) {
|
||||||
header.findElement(By.xpath(".//button[text()='" + buttonText + "']")).click();
|
clickLink(header.findElement(By.xpath(".//button[text()='" + buttonText + "']")));
|
||||||
waitForPageToLoad();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clickHeaderLink(String linkText) {
|
public void clickHeaderLink(String linkText) {
|
||||||
header.findElement(By.linkText(linkText)).click();
|
clickLink(header.findElement(By.linkText(linkText)));
|
||||||
waitForPageToLoad();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public WebElement body() {
|
public WebElement body() {
|
||||||
|
@ -73,6 +72,7 @@ public class DataTable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<WebElement> rows() {
|
public List<WebElement> rows() {
|
||||||
|
waitForPageToLoad();
|
||||||
pause(500); // wait a bit to ensure the table is no more changing
|
pause(500); // wait a bit to ensure the table is no more changing
|
||||||
return rows;
|
return rows;
|
||||||
}
|
}
|
||||||
|
@ -83,11 +83,11 @@ public class DataTable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clickRowByLinkText(String text) {
|
public void clickRowByLinkText(String text) {
|
||||||
body.findElement(By.xpath(".//tr/td/a[text()='" + text + "']")).click();
|
clickLink(body.findElement(By.xpath(".//tr/td/a[text()='" + text + "']")));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clickRowActionButton(WebElement row, String buttonText) {
|
public void clickRowActionButton(WebElement row, String buttonText) {
|
||||||
row.findElement(xpath(".//td[contains(@class, 'kc-action-cell') and text()='" + buttonText + "']")).click();
|
clickLink(row.findElement(xpath(".//td[contains(@class, 'kc-action-cell') and text()='" + buttonText + "']")));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,7 @@ import org.openqa.selenium.WebElement;
|
||||||
import org.openqa.selenium.support.FindBy;
|
import org.openqa.selenium.support.FindBy;
|
||||||
|
|
||||||
import static org.jboss.arquillian.graphene.Graphene.guardAjax;
|
import static org.jboss.arquillian.graphene.Graphene.guardAjax;
|
||||||
|
import static org.keycloak.testsuite.util.UIUtils.clickLink;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -46,8 +47,7 @@ public class Form {
|
||||||
|
|
||||||
public void save() {
|
public void save() {
|
||||||
// guardAjax(save).click();
|
// guardAjax(save).click();
|
||||||
save.click();
|
clickLink(save);
|
||||||
WaitUtils.waitForPageToLoad();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void cancel() {
|
public void cancel() {
|
||||||
|
|
|
@ -22,9 +22,9 @@ import org.keycloak.representations.idm.authorization.PolicyRepresentation;
|
||||||
import org.keycloak.representations.idm.authorization.ResourcePermissionRepresentation;
|
import org.keycloak.representations.idm.authorization.ResourcePermissionRepresentation;
|
||||||
import org.keycloak.representations.idm.authorization.ScopePermissionRepresentation;
|
import org.keycloak.representations.idm.authorization.ScopePermissionRepresentation;
|
||||||
import org.keycloak.testsuite.console.page.clients.authorization.policy.PolicyTypeUI;
|
import org.keycloak.testsuite.console.page.clients.authorization.policy.PolicyTypeUI;
|
||||||
|
import org.keycloak.testsuite.console.page.fragment.ModalDialog;
|
||||||
import org.keycloak.testsuite.page.Form;
|
import org.keycloak.testsuite.page.Form;
|
||||||
import org.keycloak.testsuite.util.WaitUtils;
|
import org.keycloak.testsuite.util.WaitUtils;
|
||||||
import org.openqa.selenium.By;
|
|
||||||
import org.openqa.selenium.WebElement;
|
import org.openqa.selenium.WebElement;
|
||||||
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;
|
||||||
|
@ -49,6 +49,9 @@ public class Permissions extends Form {
|
||||||
@Page
|
@Page
|
||||||
private ScopePermission scopePermission;
|
private ScopePermission scopePermission;
|
||||||
|
|
||||||
|
@Page
|
||||||
|
private ModalDialog modalDialog;
|
||||||
|
|
||||||
public PermissionsTable permissions() {
|
public PermissionsTable permissions() {
|
||||||
return table;
|
return table;
|
||||||
}
|
}
|
||||||
|
@ -130,7 +133,7 @@ public class Permissions extends Form {
|
||||||
PolicyRepresentation actual = permissions().toRepresentation(row);
|
PolicyRepresentation actual = permissions().toRepresentation(row);
|
||||||
if (actual.getName().equalsIgnoreCase(name)) {
|
if (actual.getName().equalsIgnoreCase(name)) {
|
||||||
row.findElements(tagName("td")).get(4).click();
|
row.findElements(tagName("td")).get(4).click();
|
||||||
driver.findElement(By.xpath(".//button[text()='Delete']")).click();
|
modalDialog.confirmDeletion();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,21 +16,11 @@
|
||||||
*/
|
*/
|
||||||
package org.keycloak.testsuite.console.page.clients.authorization.policy;
|
package org.keycloak.testsuite.console.page.clients.authorization.policy;
|
||||||
|
|
||||||
import static org.keycloak.testsuite.util.WaitUtils.waitUntilElement;
|
|
||||||
import static org.openqa.selenium.By.tagName;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.function.Consumer;
|
|
||||||
import java.util.function.Function;
|
|
||||||
import java.util.function.Predicate;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import org.jboss.arquillian.drone.api.annotation.Drone;
|
import org.jboss.arquillian.drone.api.annotation.Drone;
|
||||||
|
import org.jboss.arquillian.graphene.page.Page;
|
||||||
import org.keycloak.representations.idm.authorization.GroupPolicyRepresentation;
|
import org.keycloak.representations.idm.authorization.GroupPolicyRepresentation;
|
||||||
import org.keycloak.representations.idm.authorization.Logic;
|
import org.keycloak.representations.idm.authorization.Logic;
|
||||||
|
import org.keycloak.testsuite.console.page.fragment.ModalDialog;
|
||||||
import org.keycloak.testsuite.page.Form;
|
import org.keycloak.testsuite.page.Form;
|
||||||
import org.openqa.selenium.By;
|
import org.openqa.selenium.By;
|
||||||
import org.openqa.selenium.WebDriver;
|
import org.openqa.selenium.WebDriver;
|
||||||
|
@ -38,6 +28,12 @@ import org.openqa.selenium.WebElement;
|
||||||
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.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static org.keycloak.testsuite.util.WaitUtils.waitUntilElement;
|
||||||
|
import static org.openqa.selenium.By.tagName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author <a href="mailto:psilva@redhat.com">Pedro Igor</a>
|
* @author <a href="mailto:psilva@redhat.com">Pedro Igor</a>
|
||||||
*/
|
*/
|
||||||
|
@ -58,12 +54,12 @@ public class GroupPolicyForm extends Form {
|
||||||
@FindBy(xpath = "//i[contains(@class,'pficon-delete')]")
|
@FindBy(xpath = "//i[contains(@class,'pficon-delete')]")
|
||||||
private WebElement deleteButton;
|
private WebElement deleteButton;
|
||||||
|
|
||||||
@FindBy(xpath = ACTIVE_DIV_XPATH + "/button[text()='Delete']")
|
|
||||||
private WebElement confirmDelete;
|
|
||||||
|
|
||||||
@FindBy(id = "selectGroup")
|
@FindBy(id = "selectGroup")
|
||||||
private WebElement selectGroupButton;
|
private WebElement selectGroupButton;
|
||||||
|
|
||||||
|
@Page
|
||||||
|
private ModalDialog modalDialog;
|
||||||
|
|
||||||
@Drone
|
@Drone
|
||||||
private WebDriver driver;
|
private WebDriver driver;
|
||||||
|
|
||||||
|
@ -131,7 +127,7 @@ public class GroupPolicyForm extends Form {
|
||||||
|
|
||||||
public void delete() {
|
public void delete() {
|
||||||
deleteButton.click();
|
deleteButton.click();
|
||||||
confirmDelete.click();
|
modalDialog.confirmDeletion();
|
||||||
}
|
}
|
||||||
|
|
||||||
public GroupPolicyRepresentation toRepresentation() {
|
public GroupPolicyRepresentation toRepresentation() {
|
||||||
|
|
|
@ -27,8 +27,8 @@ import org.keycloak.representations.idm.authorization.RolePolicyRepresentation;
|
||||||
import org.keycloak.representations.idm.authorization.RulePolicyRepresentation;
|
import org.keycloak.representations.idm.authorization.RulePolicyRepresentation;
|
||||||
import org.keycloak.representations.idm.authorization.TimePolicyRepresentation;
|
import org.keycloak.representations.idm.authorization.TimePolicyRepresentation;
|
||||||
import org.keycloak.representations.idm.authorization.UserPolicyRepresentation;
|
import org.keycloak.representations.idm.authorization.UserPolicyRepresentation;
|
||||||
|
import org.keycloak.testsuite.console.page.fragment.ModalDialog;
|
||||||
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.support.FindBy;
|
import org.openqa.selenium.support.FindBy;
|
||||||
import org.openqa.selenium.support.ui.Select;
|
import org.openqa.selenium.support.ui.Select;
|
||||||
|
@ -72,6 +72,9 @@ public class Policies extends Form {
|
||||||
@Page
|
@Page
|
||||||
private GroupPolicy groupPolicy;
|
private GroupPolicy groupPolicy;
|
||||||
|
|
||||||
|
@Page
|
||||||
|
private ModalDialog modalDialog;
|
||||||
|
|
||||||
public PoliciesTable policies() {
|
public PoliciesTable policies() {
|
||||||
return table;
|
return table;
|
||||||
}
|
}
|
||||||
|
@ -204,7 +207,7 @@ public class Policies extends Form {
|
||||||
PolicyRepresentation actual = policies().toRepresentation(row);
|
PolicyRepresentation actual = policies().toRepresentation(row);
|
||||||
if (actual.getName().equalsIgnoreCase(name)) {
|
if (actual.getName().equalsIgnoreCase(name)) {
|
||||||
row.findElements(tagName("td")).get(4).click();
|
row.findElements(tagName("td")).get(4).click();
|
||||||
driver.findElement(By.xpath(".//button[text()='Delete']")).click();
|
modalDialog.confirmDeletion();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,12 @@ import org.openqa.selenium.WebElement;
|
||||||
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.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import static org.jboss.arquillian.graphene.Graphene.waitGui;
|
||||||
|
import static org.keycloak.testsuite.util.UIUtils.clickLink;
|
||||||
|
import static org.openqa.selenium.By.id;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author <a href="mailto:psilva@redhat.com">Pedro Igor</a>
|
* @author <a href="mailto:psilva@redhat.com">Pedro Igor</a>
|
||||||
*/
|
*/
|
||||||
|
@ -76,8 +82,8 @@ public class RulePolicyForm extends Form {
|
||||||
setInputValue(artifactId, expected.getArtifactId());
|
setInputValue(artifactId, expected.getArtifactId());
|
||||||
setInputValue(artifactVersion, expected.getArtifactVersion());
|
setInputValue(artifactVersion, expected.getArtifactVersion());
|
||||||
|
|
||||||
resolveModuleButton.click();
|
clickLink(resolveModuleButton);
|
||||||
WaitUtils.waitForPageToLoad();
|
waitGui().withTimeout(30, TimeUnit.SECONDS).until().element(id("moduleName")).is().enabled();
|
||||||
|
|
||||||
moduleName.selectByVisibleText(expected.getModuleName());
|
moduleName.selectByVisibleText(expected.getModuleName());
|
||||||
WaitUtils.pause(1000);
|
WaitUtils.pause(1000);
|
||||||
|
|
|
@ -18,9 +18,9 @@ package org.keycloak.testsuite.console.page.clients.authorization.resource;
|
||||||
|
|
||||||
import org.jboss.arquillian.graphene.page.Page;
|
import org.jboss.arquillian.graphene.page.Page;
|
||||||
import org.keycloak.representations.idm.authorization.ResourceRepresentation;
|
import org.keycloak.representations.idm.authorization.ResourceRepresentation;
|
||||||
|
import org.keycloak.testsuite.console.page.fragment.ModalDialog;
|
||||||
import org.keycloak.testsuite.page.Form;
|
import org.keycloak.testsuite.page.Form;
|
||||||
import org.keycloak.testsuite.util.WaitUtils;
|
import org.keycloak.testsuite.util.WaitUtils;
|
||||||
import org.openqa.selenium.By;
|
|
||||||
import org.openqa.selenium.WebElement;
|
import org.openqa.selenium.WebElement;
|
||||||
import org.openqa.selenium.support.FindBy;
|
import org.openqa.selenium.support.FindBy;
|
||||||
|
|
||||||
|
@ -41,6 +41,9 @@ public class Resources extends Form {
|
||||||
@Page
|
@Page
|
||||||
private Resource resource;
|
private Resource resource;
|
||||||
|
|
||||||
|
@Page
|
||||||
|
private ModalDialog modalDialog;
|
||||||
|
|
||||||
public ResourcesTable resources() {
|
public ResourcesTable resources() {
|
||||||
return table;
|
return table;
|
||||||
}
|
}
|
||||||
|
@ -79,7 +82,7 @@ public class Resources extends Form {
|
||||||
ResourceRepresentation actual = resources().toRepresentation(row);
|
ResourceRepresentation actual = resources().toRepresentation(row);
|
||||||
if (actual.getName().equalsIgnoreCase(name)) {
|
if (actual.getName().equalsIgnoreCase(name)) {
|
||||||
row.findElements(tagName("td")).get(6).click();
|
row.findElements(tagName("td")).get(6).click();
|
||||||
driver.findElement(By.xpath(".//button[text()='Delete']")).click();
|
modalDialog.confirmDeletion();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,8 +18,8 @@ package org.keycloak.testsuite.console.page.clients.authorization.scope;
|
||||||
|
|
||||||
import org.jboss.arquillian.graphene.page.Page;
|
import org.jboss.arquillian.graphene.page.Page;
|
||||||
import org.keycloak.representations.idm.authorization.ScopeRepresentation;
|
import org.keycloak.representations.idm.authorization.ScopeRepresentation;
|
||||||
|
import org.keycloak.testsuite.console.page.fragment.ModalDialog;
|
||||||
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.support.FindBy;
|
import org.openqa.selenium.support.FindBy;
|
||||||
|
|
||||||
|
@ -40,6 +40,9 @@ public class Scopes extends Form {
|
||||||
@Page
|
@Page
|
||||||
private Scope scope;
|
private Scope scope;
|
||||||
|
|
||||||
|
@Page
|
||||||
|
private ModalDialog modalDialog;
|
||||||
|
|
||||||
public ScopesTable scopes() {
|
public ScopesTable scopes() {
|
||||||
return table;
|
return table;
|
||||||
}
|
}
|
||||||
|
@ -74,7 +77,7 @@ public class Scopes extends Form {
|
||||||
ScopeRepresentation actual = scopes().toRepresentation(row);
|
ScopeRepresentation actual = scopes().toRepresentation(row);
|
||||||
if (actual.getName().equalsIgnoreCase(name)) {
|
if (actual.getName().equalsIgnoreCase(name)) {
|
||||||
row.findElements(tagName("td")).get(3).click();
|
row.findElements(tagName("td")).get(3).click();
|
||||||
driver.findElement(By.xpath(".//button[text()='Delete']")).click();
|
modalDialog.confirmDeletion();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,9 +28,9 @@ public class ClientRole extends ClientRoles {
|
||||||
return getUriParameter(ROLE_ID).toString();
|
return getUriParameter(ROLE_ID).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private RoleForm form;
|
private RoleDetailsForm form;
|
||||||
|
|
||||||
public RoleForm form() {
|
public RoleDetailsForm form() {
|
||||||
return form;
|
return form;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,9 +14,9 @@ public class CreateRole extends AdminConsoleCreate {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Page
|
@Page
|
||||||
private RoleForm form;
|
private RoleDetailsForm form;
|
||||||
|
|
||||||
public RoleForm form() {
|
public RoleDetailsForm form() {
|
||||||
return form;
|
return form;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
package org.keycloak.testsuite.console.page.roles;
|
package org.keycloak.testsuite.console.page.roles;
|
||||||
|
|
||||||
import org.jboss.arquillian.graphene.page.Page;
|
import org.openqa.selenium.WebElement;
|
||||||
|
import org.openqa.selenium.support.FindBy;
|
||||||
|
|
||||||
|
import static org.keycloak.testsuite.util.UIUtils.clickLink;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -23,11 +26,34 @@ public class Role extends RealmRoles {
|
||||||
return getUriParameter(ROLE_ID).toString();
|
return getUriParameter(ROLE_ID).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Page
|
@FindBy(css = "ul.nav-tabs")
|
||||||
private RoleForm form;
|
private RoleTabs tabs;
|
||||||
|
|
||||||
public RoleForm form() {
|
public RoleTabs roleTabs() {
|
||||||
return form;
|
return tabs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class RoleTabs {
|
||||||
|
@FindBy(linkText = "Details")
|
||||||
|
private WebElement detailsTab;
|
||||||
|
|
||||||
|
@FindBy(linkText = "Permissions")
|
||||||
|
private WebElement permissionsTab;
|
||||||
|
|
||||||
|
@FindBy(linkText = "Users in Role")
|
||||||
|
private WebElement usersInRoleTab;
|
||||||
|
|
||||||
|
public void details() {
|
||||||
|
clickLink(detailsTab);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void permissions() {
|
||||||
|
clickLink(permissionsTab);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void usersInRole() {
|
||||||
|
clickLink(usersInRoleTab);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2017 Red Hat, Inc. and/or its affiliates
|
||||||
|
* and other contributors as indicated by the @author tags.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.keycloak.testsuite.console.page.roles;
|
||||||
|
|
||||||
|
import org.jboss.arquillian.graphene.page.Page;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Vaclav Muzikar <vmuzikar@redhat.com>
|
||||||
|
*/
|
||||||
|
public class RoleDetails extends Role {
|
||||||
|
|
||||||
|
@Page
|
||||||
|
private RoleDetailsForm form;
|
||||||
|
|
||||||
|
public RoleDetailsForm form() {
|
||||||
|
return form;
|
||||||
|
}
|
||||||
|
}
|
|
@ -10,7 +10,7 @@ import org.openqa.selenium.support.FindBy;
|
||||||
*
|
*
|
||||||
* @author tkyjovsk
|
* @author tkyjovsk
|
||||||
*/
|
*/
|
||||||
public class RoleForm extends Form {
|
public class RoleDetailsForm extends Form {
|
||||||
|
|
||||||
@FindBy(id = "name")
|
@FindBy(id = "name")
|
||||||
private WebElement nameInput;
|
private WebElement nameInput;
|
|
@ -0,0 +1,84 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2017 Red Hat, Inc. and/or its affiliates
|
||||||
|
* and other contributors as indicated by the @author tags.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.keycloak.testsuite.console.page.roles;
|
||||||
|
|
||||||
|
import org.keycloak.representations.idm.UserRepresentation;
|
||||||
|
import org.keycloak.testsuite.console.page.fragment.DataTable;
|
||||||
|
import org.openqa.selenium.NoSuchElementException;
|
||||||
|
import org.openqa.selenium.WebElement;
|
||||||
|
import org.openqa.selenium.support.FindBy;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import static org.openqa.selenium.By.tagName;
|
||||||
|
import static org.openqa.selenium.By.xpath;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Vaclav Muzikar <vmuzikar@redhat.com>
|
||||||
|
*/
|
||||||
|
public class UsersInRole extends Role {
|
||||||
|
@FindBy(css = "table[class*='table']")
|
||||||
|
private UsersInRoleTable usersInRoleTable;
|
||||||
|
|
||||||
|
public UsersInRoleTable usersTable() {
|
||||||
|
return usersInRoleTable;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class UsersInRoleTable extends DataTable {
|
||||||
|
|
||||||
|
public void clickUser(String userName) {
|
||||||
|
clickRowByLinkText(userName);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void editUser(String userName) {
|
||||||
|
clickRowActionButton(getRowByLinkText(userName), "Edit");
|
||||||
|
}
|
||||||
|
|
||||||
|
public UserRepresentation getUserFromTableRow(WebElement row) {
|
||||||
|
UserRepresentation user = null;
|
||||||
|
List<WebElement> tds = row.findElements(tagName("td"));
|
||||||
|
if (tds.size() == 5 && !tds.get(0).getText().isEmpty()) {
|
||||||
|
user = new UserRepresentation();
|
||||||
|
user.setUsername(tds.get(0).getText());
|
||||||
|
user.setLastName(tds.get(1).getText());
|
||||||
|
user.setFirstName(tds.get(2).getText());
|
||||||
|
user.setEmail(tds.get(3).getText());
|
||||||
|
}
|
||||||
|
return user;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<UserRepresentation> getUsersFromTableRows() {
|
||||||
|
return rows().stream()
|
||||||
|
.map(this::getUserFromTableRow)
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean noRoleMembersIsDisplayed() {
|
||||||
|
try {
|
||||||
|
return body().findElement(xpath(".//td[text()='No role members' and not(contains(@class, 'ng-hide'))]")).isDisplayed();
|
||||||
|
}
|
||||||
|
catch (NoSuchElementException e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -21,7 +21,6 @@ import org.jboss.arquillian.drone.api.annotation.Drone;
|
||||||
import org.keycloak.representations.idm.UserRepresentation;
|
import org.keycloak.representations.idm.UserRepresentation;
|
||||||
import org.keycloak.testsuite.console.page.AdminConsoleRealm;
|
import org.keycloak.testsuite.console.page.AdminConsoleRealm;
|
||||||
import org.keycloak.testsuite.console.page.fragment.DataTable;
|
import org.keycloak.testsuite.console.page.fragment.DataTable;
|
||||||
import org.keycloak.testsuite.util.URLUtils;
|
|
||||||
import org.openqa.selenium.By;
|
import org.openqa.selenium.By;
|
||||||
import org.openqa.selenium.WebDriver;
|
import org.openqa.selenium.WebDriver;
|
||||||
import org.openqa.selenium.WebElement;
|
import org.openqa.selenium.WebElement;
|
||||||
|
@ -30,8 +29,8 @@ import org.openqa.selenium.support.FindBy;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static org.keycloak.testsuite.util.WaitUtils.waitForPageToLoad;
|
import static org.keycloak.testsuite.util.UIUtils.clickLink;
|
||||||
import static org.openqa.selenium.By.*;
|
import static org.openqa.selenium.By.tagName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -79,18 +78,15 @@ public class Users extends AdminConsoleRealm {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clickUser(String username) {
|
public void clickUser(String username) {
|
||||||
URLUtils.navigateToUri(getRowByUsername(username).findElement(By.xpath("./td[position()=1]/a")).getAttribute("href"), true);
|
clickLink(getRowByUsername(username).findElement(By.xpath("./td[position()=1]/a")));
|
||||||
waitForPageToLoad();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void editUser(String username) {
|
public void editUser(String username) {
|
||||||
clickRowActionButton(getRowByUsername(username), EDIT);
|
clickRowActionButton(getRowByUsername(username), EDIT);
|
||||||
waitForPageToLoad();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void impersonateUser(String username) {
|
public void impersonateUser(String username) {
|
||||||
clickRowActionButton(getRowByUsername(username), IMPERSONATE);
|
clickRowActionButton(getRowByUsername(username), IMPERSONATE);
|
||||||
waitForPageToLoad();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteUser(String username) {
|
public void deleteUser(String username) {
|
||||||
|
|
|
@ -7,10 +7,13 @@ import org.junit.Test;
|
||||||
import org.keycloak.representations.idm.RoleRepresentation;
|
import org.keycloak.representations.idm.RoleRepresentation;
|
||||||
import org.keycloak.testsuite.console.page.roles.CreateRole;
|
import org.keycloak.testsuite.console.page.roles.CreateRole;
|
||||||
import org.keycloak.testsuite.console.page.roles.RealmRoles;
|
import org.keycloak.testsuite.console.page.roles.RealmRoles;
|
||||||
import org.keycloak.testsuite.console.page.roles.Role;
|
import org.keycloak.testsuite.console.page.roles.RoleDetails;
|
||||||
import org.keycloak.testsuite.util.Timer;
|
import org.keycloak.testsuite.util.Timer;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
|
import static org.junit.Assert.assertNotNull;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
import static org.keycloak.testsuite.util.URLAssert.assertCurrentUrlEquals;
|
import static org.keycloak.testsuite.util.URLAssert.assertCurrentUrlEquals;
|
||||||
import static org.keycloak.testsuite.util.WaitUtils.pause;
|
import static org.keycloak.testsuite.util.WaitUtils.pause;
|
||||||
|
|
||||||
|
@ -26,7 +29,7 @@ public class RealmRolesTest extends AbstractRolesTest {
|
||||||
@Page
|
@Page
|
||||||
private CreateRole createRolePage;
|
private CreateRole createRolePage;
|
||||||
@Page
|
@Page
|
||||||
private Role rolePage;
|
private RoleDetails roleDetailsPage;
|
||||||
|
|
||||||
private RoleRepresentation testRole;
|
private RoleRepresentation testRole;
|
||||||
|
|
||||||
|
@ -51,10 +54,10 @@ public class RealmRolesTest extends AbstractRolesTest {
|
||||||
assertCurrentUrlEquals(realmRolesPage);
|
assertCurrentUrlEquals(realmRolesPage);
|
||||||
realmRolesPage.table().editRole(roleRep.getName());
|
realmRolesPage.table().editRole(roleRep.getName());
|
||||||
// assertCurrentUrl(role); // can't do this, role id needed as uri param
|
// assertCurrentUrl(role); // can't do this, role id needed as uri param
|
||||||
rolePage.form().setBasicAttributes(roleRep);
|
roleDetailsPage.form().setBasicAttributes(roleRep);
|
||||||
rolePage.form().save();
|
roleDetailsPage.form().save();
|
||||||
assertAlertSuccess();
|
assertAlertSuccess();
|
||||||
rolePage.form().setCompositeRoles(roleRep);
|
roleDetailsPage.form().setCompositeRoles(roleRep);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void assertBasicRoleAttributesEqual(RoleRepresentation r1, RoleRepresentation r2) {
|
public void assertBasicRoleAttributesEqual(RoleRepresentation r1, RoleRepresentation r2) {
|
||||||
|
@ -72,12 +75,12 @@ public class RealmRolesTest extends AbstractRolesTest {
|
||||||
RoleRepresentation foundRole = realmRolesPage.table().findRole(testRole.getName()); // search & get role from table
|
RoleRepresentation foundRole = realmRolesPage.table().findRole(testRole.getName()); // search & get role from table
|
||||||
assertBasicRoleAttributesEqual(testRole, foundRole);
|
assertBasicRoleAttributesEqual(testRole, foundRole);
|
||||||
realmRolesPage.table().editRole(testRole.getName());
|
realmRolesPage.table().editRole(testRole.getName());
|
||||||
foundRole = rolePage.form().getBasicAttributes();
|
foundRole = roleDetailsPage.form().getBasicAttributes();
|
||||||
assertBasicRoleAttributesEqual(testRole, foundRole);
|
assertBasicRoleAttributesEqual(testRole, foundRole);
|
||||||
|
|
||||||
testRole.setDescription("updated role description");
|
testRole.setDescription("updated role description");
|
||||||
rolePage.form().setDescription(testRole.getDescription());
|
roleDetailsPage.form().setDescription(testRole.getDescription());
|
||||||
rolePage.form().save();
|
roleDetailsPage.form().save();
|
||||||
assertAlertSuccess();
|
assertAlertSuccess();
|
||||||
|
|
||||||
configure().roles();
|
configure().roles();
|
||||||
|
@ -96,7 +99,7 @@ public class RealmRolesTest extends AbstractRolesTest {
|
||||||
// add again
|
// add again
|
||||||
addRole(testRole);
|
addRole(testRole);
|
||||||
// delete from page
|
// delete from page
|
||||||
rolePage.form().delete();
|
roleDetailsPage.form().delete();
|
||||||
modalDialog.confirmDeletion();
|
modalDialog.confirmDeletion();
|
||||||
assertCurrentUrlEquals(realmRolesPage);
|
assertCurrentUrlEquals(realmRolesPage);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,33 +3,28 @@
|
||||||
*/
|
*/
|
||||||
package org.keycloak.testsuite.console.roles;
|
package org.keycloak.testsuite.console.roles;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
import static org.junit.Assert.assertFalse;
|
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
import static org.keycloak.testsuite.admin.ApiUtil.createUserWithAdminClient;
|
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
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;
|
||||||
import org.keycloak.admin.client.resource.RoleResource;
|
|
||||||
import org.keycloak.admin.client.resource.RolesResource;
|
|
||||||
import org.keycloak.admin.client.resource.UserResource;
|
|
||||||
import org.keycloak.representations.idm.RoleRepresentation;
|
import org.keycloak.representations.idm.RoleRepresentation;
|
||||||
import org.keycloak.representations.idm.UserRepresentation;
|
import org.keycloak.representations.idm.UserRepresentation;
|
||||||
import org.keycloak.testsuite.console.page.roles.DefaultRoles;
|
import org.keycloak.testsuite.console.page.roles.DefaultRoles;
|
||||||
import org.keycloak.testsuite.console.page.roles.RealmRoles;
|
import org.keycloak.testsuite.console.page.roles.RealmRoles;
|
||||||
import org.keycloak.testsuite.console.page.roles.Role;
|
import org.keycloak.testsuite.console.page.roles.UsersInRole;
|
||||||
import org.keycloak.testsuite.console.page.roles.Roles;
|
|
||||||
import org.keycloak.testsuite.console.page.users.UserRoleMappings;
|
import org.keycloak.testsuite.console.page.users.UserRoleMappings;
|
||||||
import org.keycloak.testsuite.console.page.users.Users;
|
import org.keycloak.testsuite.util.RealmRepUtil;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
import static org.keycloak.testsuite.admin.ApiUtil.assignRealmRoles;
|
||||||
|
import static org.keycloak.testsuite.admin.ApiUtil.createUserWithAdminClient;
|
||||||
|
import static org.keycloak.testsuite.util.URLAssert.assertCurrentUrlEquals;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author <a href="mailto:antonio.ferreira@fiercely.pt">Antonio Ferreira</a>
|
* See KEYCLOAK-2035
|
||||||
*
|
*
|
||||||
|
* @author <a href="mailto:antonio.ferreira@fiercely.pt">Antonio Ferreira</a>
|
||||||
|
* @author Vaclav Muzikar <vmuzikar@redhat.com>
|
||||||
*/
|
*/
|
||||||
public class UsersInRoleTest extends AbstractRolesTest {
|
public class UsersInRoleTest extends AbstractRolesTest {
|
||||||
|
|
||||||
|
@ -39,80 +34,61 @@ public class UsersInRoleTest extends AbstractRolesTest {
|
||||||
|
|
||||||
@Page
|
@Page
|
||||||
private UserRoleMappings userRolesPage;
|
private UserRoleMappings userRolesPage;
|
||||||
|
|
||||||
@Page
|
@Page
|
||||||
private Users usersPage;
|
private UsersInRole usersInRolePage;
|
||||||
|
|
||||||
@Page
|
|
||||||
private Roles rolesPage;
|
|
||||||
|
|
||||||
@Page
|
|
||||||
private Role rolePage;
|
|
||||||
|
|
||||||
@Page
|
@Page
|
||||||
private RealmRoles realmRolesPage;
|
private RealmRoles realmRolesPage;
|
||||||
|
|
||||||
private RoleRepresentation testRoleRep;
|
private RoleRepresentation testRoleRep;
|
||||||
|
private RoleRepresentation emptyTestRoleRep;
|
||||||
private UserRepresentation newUser;
|
private UserRepresentation newUser;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void beforeDefaultRolesTest() {
|
public void beforeUsersInRoleTestClass() {
|
||||||
// create a role via admin client
|
// create a role via admin client
|
||||||
testRoleRep = new RoleRepresentation("test-role", "", false);
|
testRoleRep = new RoleRepresentation("test-role", "", false);
|
||||||
rolesResource().create(testRoleRep);
|
testRealmResource().roles().create(testRoleRep);
|
||||||
|
|
||||||
|
emptyTestRoleRep = new RoleRepresentation("empty-test-role", "", false);
|
||||||
|
testRealmResource().roles().create(emptyTestRoleRep);
|
||||||
|
|
||||||
newUser = new UserRepresentation();
|
newUser = new UserRepresentation();
|
||||||
newUser.setUsername("test_user");
|
newUser.setUsername("test_user");
|
||||||
newUser.setEnabled(true);
|
newUser.setEnabled(true);
|
||||||
newUser.setEmail("test-role-member@test-role-member.com");
|
newUser.setId(createUserWithAdminClient(testRealmResource(), newUser));
|
||||||
newUser.setRequiredActions(Collections.<String>emptyList());
|
|
||||||
//testRealmResource().users().create(newUser);
|
assignRealmRoles(testRealmResource(), newUser.getId(), testRoleRep.getName());
|
||||||
createUserWithAdminClient(testRealmResource(), newUser);
|
|
||||||
rolesResource().create(testRoleRep);
|
userPage.setId(newUser.getId());
|
||||||
rolesPage.navigateTo();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public RolesResource rolesResource() {
|
|
||||||
return testRealmResource().roles();
|
|
||||||
}
|
|
||||||
|
|
||||||
//Added for KEYCLOAK-2035
|
|
||||||
@Test
|
@Test
|
||||||
public void usersInRoleTabIsPresent() {
|
public void userInRoleIsPresent() {
|
||||||
|
// Clicking user name link
|
||||||
|
navigateToUsersInRole(testRoleRep);
|
||||||
|
assertEquals(1, usersInRolePage.usersTable().getUsersFromTableRows().size());
|
||||||
|
usersInRolePage.usersTable().clickUser(newUser.getUsername());
|
||||||
|
assertCurrentUrlEquals(userPage);
|
||||||
|
|
||||||
rolesPage.navigateTo();
|
// Clicking edit button
|
||||||
rolesPage.tabs().realmRoles();
|
navigateToUsersInRole(testRoleRep);
|
||||||
realmRolesPage.table().search(testRoleRep.getName());
|
usersInRolePage.usersTable().editUser(newUser.getUsername());
|
||||||
realmRolesPage.table().clickRole(testRoleRep.getName());
|
assertCurrentUrlEquals(userPage);
|
||||||
//assert no users in list
|
|
||||||
//Role Page class missing a getUsers() method
|
|
||||||
|
|
||||||
List<UserRepresentation> users = testRealmResource().users().search("test_user", null, null, null, null, null);
|
|
||||||
assertEquals(1, users.size());
|
|
||||||
UserResource user = testRealmResource().users().get(users.get(0).getId());
|
|
||||||
UserRepresentation userRep = user.toRepresentation();
|
|
||||||
|
|
||||||
usersPage.navigateTo();
|
|
||||||
usersPage.table().search(userRep.getUsername());
|
|
||||||
usersPage.table().clickUser(userRep.getUsername());
|
|
||||||
|
|
||||||
assertFalse(userRolesPage.form().isAssignedRole(testRoleRep.getName()));
|
|
||||||
|
|
||||||
RoleResource roleResource = testRealmResource().roles().get(testRoleRep.getName());
|
|
||||||
List<RoleRepresentation> rolesToAdd = new LinkedList<>();
|
|
||||||
rolesToAdd.add(roleResource.toRepresentation());
|
|
||||||
testRealmResource().users().get(userRep.getId()).roles().realmLevel().add(rolesToAdd);
|
|
||||||
|
|
||||||
rolesPage.navigateTo();
|
|
||||||
rolesPage.tabs().realmRoles();
|
|
||||||
realmRolesPage.table().search(testRoleRep.getName());
|
|
||||||
realmRolesPage.table().clickRole(testRoleRep.getName());
|
|
||||||
|
|
||||||
assertTrue(userRolesPage.form().isAssignedRole(testRoleRep.getName()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void emptyRoleTest() {
|
||||||
|
navigateToUsersInRole(emptyTestRoleRep);
|
||||||
|
assertEquals(0, usersInRolePage.usersTable().getUsersFromTableRows().size());
|
||||||
|
assertTrue("No roles members message is not displayed", usersInRolePage.usersTable().noRoleMembersIsDisplayed());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void navigateToUsersInRole(RoleRepresentation role) {
|
||||||
|
realmRolesPage.navigateTo();
|
||||||
|
realmRolesPage.tabs().realmRoles();
|
||||||
|
realmRolesPage.table().clickRole(role.getName());
|
||||||
|
usersInRolePage.roleTabs().usersInRole();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue