Merge pull request #1358 from tkyjovsk/master
fixed some UI tests broken by KEYCLOAK-1431
This commit is contained in:
commit
b5ee395aac
7 changed files with 240 additions and 95 deletions
|
@ -15,7 +15,6 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.keycloak.testsuite.ui.fragment;
|
||||
|
||||
import org.jboss.arquillian.drone.api.annotation.Drone;
|
||||
|
@ -33,9 +32,9 @@ import org.openqa.selenium.WebElement;
|
|||
* @author Petr Mensik
|
||||
*/
|
||||
public class Navigation {
|
||||
|
||||
@Drone
|
||||
private WebDriver driver;
|
||||
|
||||
@Drone
|
||||
private WebDriver driver;
|
||||
|
||||
@FindByJQuery("a:contains('Settings')")
|
||||
private WebElement settingsLink;
|
||||
|
@ -54,8 +53,8 @@ public class Navigation {
|
|||
|
||||
@FindByJQuery("a:contains('Tokens')")
|
||||
private WebElement tokensLink;
|
||||
|
||||
@FindByJQuery("a:contains('Sessions')")
|
||||
|
||||
@FindByJQuery("a:contains('Sessions')")
|
||||
private WebElement sessionLink;
|
||||
|
||||
@FindByJQuery("a:contains('Security Defenses')")
|
||||
|
@ -63,32 +62,32 @@ public class Navigation {
|
|||
|
||||
@FindByJQuery("a:contains('Events')")
|
||||
private WebElement eventsLink;
|
||||
|
||||
@FindByJQuery("a:contains('Login')")
|
||||
|
||||
@FindByJQuery("a:contains('Login')")
|
||||
private WebElement loginLink;
|
||||
|
||||
@FindByJQuery("a:contains('Themes')")
|
||||
private WebElement themesLink;
|
||||
|
||||
@FindByJQuery("a:contains('Role Mappings')")
|
||||
@FindByJQuery("a:contains('Role Mappings')")
|
||||
private WebElement usersRoleMappings;
|
||||
|
||||
@FindByJQuery("a:contains('Add Realm')")
|
||||
|
||||
@FindByJQuery("a:contains('Add Realm')")
|
||||
private WebElement addRealm;
|
||||
|
||||
@FindByJQuery("a:contains('Credentials')")
|
||||
|
||||
@FindByJQuery("a:contains('Credentials')")
|
||||
private WebElement credentials;
|
||||
|
||||
@FindByJQuery("a:contains('Attributes')")
|
||||
|
||||
@FindByJQuery("a:contains('Attributes')")
|
||||
private WebElement attributes;
|
||||
|
||||
|
||||
@FindBy(css = "div h1")
|
||||
private WebElement currentHeader;
|
||||
|
||||
public void selectRealm(String realmName) {
|
||||
driver.findElement(By.linkText(realmName)).click();
|
||||
}
|
||||
|
||||
public void selectRealm(String realmName) {
|
||||
driver.findElement(By.linkText(realmName)).click();
|
||||
}
|
||||
|
||||
public void settings() {
|
||||
openPage(settingsLink, "Settings");
|
||||
}
|
||||
|
@ -104,7 +103,7 @@ public class Navigation {
|
|||
public void clients() {
|
||||
openPage(clientsLink, "Clients");
|
||||
}
|
||||
|
||||
|
||||
public void oauth() {
|
||||
openPage(oauthLink, "OAuth Clients");
|
||||
}
|
||||
|
@ -112,10 +111,10 @@ public class Navigation {
|
|||
public void tokens() {
|
||||
openPage(tokensLink, "Settings");
|
||||
}
|
||||
|
||||
public void sessions() {
|
||||
openPage(sessionLink, "Sessions");
|
||||
}
|
||||
|
||||
public void sessions() {
|
||||
openPage(sessionLink, "Sessions");
|
||||
}
|
||||
|
||||
public void security() {
|
||||
openPage(securityLink, "Settings");
|
||||
|
@ -124,30 +123,32 @@ public class Navigation {
|
|||
public void events() {
|
||||
openPage(eventsLink, "Events");
|
||||
}
|
||||
|
||||
public void login() {
|
||||
openPage(loginLink, "Settings");
|
||||
}
|
||||
|
||||
public void themes() {
|
||||
openPage(themesLink, "Settings");
|
||||
}
|
||||
public void login() {
|
||||
openPage(loginLink, "Settings");
|
||||
}
|
||||
|
||||
public void roleMappings() {
|
||||
openPage(usersRoleMappings, "User");
|
||||
}
|
||||
|
||||
public void addRealm() {
|
||||
openPage(addRealm, "Add Realm");
|
||||
}
|
||||
|
||||
public void credentials() {
|
||||
openPage(credentials, "Settings");
|
||||
}
|
||||
|
||||
public void attributes() {
|
||||
openPage(attributes, "Attributes");
|
||||
}
|
||||
public void themes() {
|
||||
openPage(themesLink, "Settings");
|
||||
}
|
||||
|
||||
public void roleMappings(String username) {
|
||||
String usernameCapitalized = Character.toUpperCase(username.charAt(0))
|
||||
+ username.substring(1);
|
||||
openPage(usersRoleMappings, usernameCapitalized);
|
||||
}
|
||||
|
||||
public void addRealm() {
|
||||
openPage(addRealm, "Add Realm");
|
||||
}
|
||||
|
||||
public void credentials() {
|
||||
openPage(credentials, "Settings");
|
||||
}
|
||||
|
||||
public void attributes() {
|
||||
openPage(attributes, "Attributes");
|
||||
}
|
||||
|
||||
private void openPage(WebElement page, String headerText) {
|
||||
waitGuiForElement(page);
|
||||
|
|
|
@ -0,0 +1,71 @@
|
|||
package org.keycloak.testsuite.ui.page.settings.user;
|
||||
|
||||
import org.keycloak.testsuite.ui.page.AbstractPage;
|
||||
import org.openqa.selenium.By;
|
||||
import org.openqa.selenium.WebElement;
|
||||
import org.openqa.selenium.support.FindBy;
|
||||
import org.openqa.selenium.support.ui.Select;
|
||||
|
||||
import static org.keycloak.testsuite.ui.util.SeleniumUtils.waitGuiForElement;
|
||||
|
||||
/**
|
||||
* Created by fkiss.
|
||||
*/
|
||||
public class RoleMappingsPage extends AbstractPage {
|
||||
|
||||
@FindBy(id = "available")
|
||||
private Select availableRolesSelect;
|
||||
|
||||
@FindBy(id = "assigned")
|
||||
private Select assignedRolesSelect;
|
||||
|
||||
@FindBy(id = "realm-composite")
|
||||
private Select effectiveRolesSelect;
|
||||
|
||||
@FindBy(id = "available-client")
|
||||
private Select availableClientRolesSelect;
|
||||
|
||||
@FindBy(id = "assigned-client")
|
||||
private Select assignedClientRolesSelect;
|
||||
|
||||
@FindBy(css = "button[ng-click*='addRealm']")
|
||||
private WebElement addSelected;
|
||||
|
||||
@FindBy(css = "button[ng-click*='addRealm']")
|
||||
private WebElement addSelectedButton;
|
||||
|
||||
@FindBy(css = "button[ng-click*='deleteRealm']")
|
||||
private WebElement removeSelectedButton;
|
||||
|
||||
@FindBy(id = "clients")
|
||||
private Select clientRolesSelect;
|
||||
|
||||
public void addAvailableRole(String role){
|
||||
waitGuiForElement(By.id("available"));
|
||||
availableRolesSelect.selectByVisibleText(role);
|
||||
addSelected.click();
|
||||
}
|
||||
|
||||
public void removeAssignedRole(String client){
|
||||
waitGuiForElement(By.id("assigned"));
|
||||
assignedRolesSelect.selectByVisibleText(client);
|
||||
removeSelectedButton.click();
|
||||
}
|
||||
|
||||
public void selectClientRole(String client){
|
||||
waitGuiForElement(By.id("clients"));
|
||||
clientRolesSelect.selectByVisibleText(client);
|
||||
}
|
||||
|
||||
public void addAvailableClientRole(String role){
|
||||
waitGuiForElement(By.id("available-client"));
|
||||
availableRolesSelect.selectByVisibleText(role);
|
||||
addSelected.click();
|
||||
}
|
||||
|
||||
public void removeAssignedClientRole(String client){
|
||||
waitGuiForElement(By.id("assigned-client"));
|
||||
assignedClientRolesSelect.selectByVisibleText(client);
|
||||
removeSelectedButton.click();
|
||||
}
|
||||
}
|
|
@ -16,7 +16,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.keycloak.testsuite.ui.page.settings;
|
||||
package org.keycloak.testsuite.ui.page.settings.user;
|
||||
|
||||
import org.jboss.arquillian.graphene.findby.FindByJQuery;
|
||||
import org.keycloak.testsuite.ui.model.User;
|
|
@ -3,7 +3,6 @@
|
|||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package org.keycloak.testsuite.ui.test.role;
|
||||
|
||||
import org.jboss.arquillian.graphene.findby.FindByJQuery;
|
||||
|
@ -17,40 +16,39 @@ import org.junit.Before;
|
|||
import org.junit.Ignore;
|
||||
import org.keycloak.testsuite.ui.AbstractKeyCloakTest;
|
||||
import org.keycloak.testsuite.ui.fragment.FlashMessage;
|
||||
import org.keycloak.testsuite.ui.page.settings.UserPage;
|
||||
import org.keycloak.testsuite.ui.page.settings.user.UserPage;
|
||||
import static org.openqa.selenium.By.id;
|
||||
import org.openqa.selenium.support.ui.Select;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Petr Mensik
|
||||
*/
|
||||
public class AddNewRoleTest extends AbstractKeyCloakTest<RolesPage> {
|
||||
|
||||
@Page
|
||||
private UserPage userPage;
|
||||
|
||||
@FindByJQuery(".alert")
|
||||
|
||||
@Page
|
||||
private UserPage userPage;
|
||||
|
||||
@FindByJQuery(".alert")
|
||||
private FlashMessage flashMessage;
|
||||
|
||||
@Before
|
||||
public void beforeTestAddNewRole() {
|
||||
navigation.roles();
|
||||
}
|
||||
|
||||
|
||||
@Before
|
||||
public void beforeTestAddNewRole() {
|
||||
navigation.roles();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddNewRole() {
|
||||
Role role = new Role("role1");
|
||||
page.addRole(role);
|
||||
flashMessage.waitUntilPresent();
|
||||
assertTrue(flashMessage.getText(), flashMessage.isSuccess());
|
||||
navigation.roles();
|
||||
flashMessage.waitUntilPresent();
|
||||
assertTrue(flashMessage.getText(), flashMessage.isSuccess());
|
||||
navigation.roles();
|
||||
assertEquals("role1", page.findRole(role.getName()).getName());
|
||||
page.deleteRole(role);
|
||||
}
|
||||
|
||||
@Ignore
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void testAddNewRoleWithLongName() {
|
||||
String name = "hjewr89y1894yh98(*&*&$jhjkashd)*(&y8934h*&@#hjkahsdj";
|
||||
|
@ -59,36 +57,36 @@ public class AddNewRoleTest extends AbstractKeyCloakTest<RolesPage> {
|
|||
navigation.roles();
|
||||
page.deleteRole(name);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testAddExistingRole() {
|
||||
Role role = new Role("role2");
|
||||
page.addRole(role);
|
||||
flashMessage.waitUntilPresent();
|
||||
assertTrue(flashMessage.getText(), flashMessage.isSuccess());
|
||||
flashMessage.waitUntilPresent();
|
||||
assertTrue(flashMessage.getText(), flashMessage.isSuccess());
|
||||
navigation.roles();
|
||||
page.addRole(role);
|
||||
flashMessage.waitUntilPresent();
|
||||
assertTrue(flashMessage.getText(), flashMessage.isDanger());
|
||||
flashMessage.waitUntilPresent();
|
||||
assertTrue(flashMessage.getText(), flashMessage.isDanger());
|
||||
navigation.roles();
|
||||
page.deleteRole(role);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRoleIsAvailableForUsers() {
|
||||
Role role = new Role("User role");
|
||||
page.addRole(role);
|
||||
flashMessage.waitUntilPresent();
|
||||
assertTrue(flashMessage.getText(), flashMessage.isSuccess());
|
||||
navigation.users();
|
||||
userPage.showAllUsers();
|
||||
userPage.goToUser("admin");
|
||||
navigation.roleMappings();
|
||||
Select rolesSelect = new Select(driver.findElement(id("available")));
|
||||
assertEquals("User role should be present in admin role mapping",
|
||||
role.getName(), rolesSelect.getOptions().get(0).getText());
|
||||
navigation.roles();
|
||||
page.deleteRole(role);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testRoleIsAvailableForUsers() {
|
||||
Role role = new Role("User role");
|
||||
page.addRole(role);
|
||||
flashMessage.waitUntilPresent();
|
||||
assertTrue(flashMessage.getText(), flashMessage.isSuccess());
|
||||
navigation.users();
|
||||
userPage.showAllUsers();
|
||||
userPage.goToUser("admin");
|
||||
navigation.roleMappings("Admin");
|
||||
Select rolesSelect = new Select(driver.findElement(id("available")));
|
||||
assertEquals("User role should be present in admin role mapping",
|
||||
role.getName(), rolesSelect.getOptions().get(0).getText());
|
||||
navigation.roles();
|
||||
page.deleteRole(role);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ import org.jboss.arquillian.graphene.findby.FindByJQuery;
|
|||
import org.junit.Test;
|
||||
import org.keycloak.testsuite.ui.fragment.FlashMessage;
|
||||
import org.keycloak.testsuite.ui.model.User;
|
||||
import org.keycloak.testsuite.ui.page.settings.UserPage;
|
||||
import org.keycloak.testsuite.ui.page.settings.user.UserPage;
|
||||
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
@ -100,13 +100,16 @@ public class AddNewUserTest extends AbstractKeyCloakTest<UserPage> {
|
|||
|
||||
@Test
|
||||
public void addDisabledUser() {
|
||||
page.addUser(TEST_USER1);
|
||||
User disabledUser = new User(TEST_USER1);
|
||||
disabledUser.setUserEnabled(false);
|
||||
disabledUser.setUserName("disabled_user");
|
||||
page.addUser(disabledUser);
|
||||
assertTrue(flashMessage.getText(), flashMessage.isSuccess());
|
||||
navigation.users();
|
||||
page.deleteUser(TEST_USER1.getUserName());
|
||||
page.deleteUser(disabledUser.getUserName());
|
||||
flashMessage.waitUntilPresent();
|
||||
assertTrue(flashMessage.getText(), flashMessage.isSuccess());
|
||||
assertNull(page.findUser(TEST_USER1.getUserName()));
|
||||
assertNull(page.findUser(disabledUser.getUserName()));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ import org.junit.Test;
|
|||
import org.keycloak.testsuite.ui.fragment.FlashMessage;
|
||||
import org.keycloak.testsuite.ui.model.User;
|
||||
import org.keycloak.testsuite.ui.page.RegisterPage;
|
||||
import org.keycloak.testsuite.ui.page.settings.UserPage;
|
||||
import org.keycloak.testsuite.ui.page.settings.user.UserPage;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import org.junit.Before;
|
||||
|
|
|
@ -0,0 +1,72 @@
|
|||
package org.keycloak.testsuite.ui.test.user;
|
||||
|
||||
import org.jboss.arquillian.graphene.findby.FindByJQuery;
|
||||
import org.jboss.arquillian.graphene.page.Page;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.keycloak.testsuite.ui.AbstractKeyCloakTest;
|
||||
import org.keycloak.testsuite.ui.fragment.FlashMessage;
|
||||
import org.keycloak.testsuite.ui.model.User;
|
||||
import org.keycloak.testsuite.ui.page.settings.user.RoleMappingsPage;
|
||||
import org.keycloak.testsuite.ui.page.settings.user.UserPage;
|
||||
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.openqa.selenium.By.linkText;
|
||||
|
||||
/**
|
||||
* Created by fkiss.
|
||||
*/
|
||||
public class RoleMappingsTest extends AbstractKeyCloakTest<RoleMappingsPage> {
|
||||
|
||||
@Page
|
||||
private UserPage userPage;
|
||||
|
||||
@FindByJQuery(".alert")
|
||||
private FlashMessage flashMessage;
|
||||
|
||||
@Before
|
||||
public void beforeAddNewUserTest() {
|
||||
navigation.users();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void addUserAndAssignRole() {
|
||||
String testUsername = "tester1";
|
||||
User testUser = new User(testUsername, "pass");
|
||||
userPage.addUser(testUser);
|
||||
flashMessage.waitUntilPresent();
|
||||
assertTrue(flashMessage.getText(), flashMessage.isSuccess());
|
||||
navigation.users();
|
||||
userPage.findUser(testUsername);
|
||||
driver.findElement(linkText(testUsername)).click();
|
||||
navigation.roleMappings(testUsername);
|
||||
|
||||
page.addAvailableRole("create-realm");
|
||||
assertTrue(flashMessage.getText(), flashMessage.isSuccess());
|
||||
navigation.users();
|
||||
userPage.deleteUser(testUsername);
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void addAndRemoveUserAndAssignRole() {
|
||||
String testUsername = "tester2";
|
||||
User testUser = new User(testUsername, "pass");
|
||||
userPage.addUser(testUser);
|
||||
flashMessage.waitUntilPresent();
|
||||
assertTrue(flashMessage.getText(), flashMessage.isSuccess());
|
||||
navigation.users();
|
||||
userPage.findUser(testUsername);
|
||||
driver.findElement(linkText(testUsername)).click();
|
||||
navigation.roleMappings(testUsername);
|
||||
|
||||
page.addAvailableRole("create-realm");
|
||||
assertTrue(flashMessage.getText(), flashMessage.isSuccess());
|
||||
page.removeAssignedRole("create-realm");
|
||||
assertTrue(flashMessage.getText(), flashMessage.isSuccess());
|
||||
navigation.users();
|
||||
userPage.deleteUser(testUsername);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue