fixed UI tests broken by KEYCLOAK-1431
This commit is contained in:
parent
30359b51fa
commit
08f2b0dea9
3 changed files with 89 additions and 90 deletions
|
@ -15,7 +15,6 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.keycloak.testsuite.ui.fragment;
|
package org.keycloak.testsuite.ui.fragment;
|
||||||
|
|
||||||
import org.jboss.arquillian.drone.api.annotation.Drone;
|
import org.jboss.arquillian.drone.api.annotation.Drone;
|
||||||
|
@ -33,9 +32,9 @@ import org.openqa.selenium.WebElement;
|
||||||
* @author Petr Mensik
|
* @author Petr Mensik
|
||||||
*/
|
*/
|
||||||
public class Navigation {
|
public class Navigation {
|
||||||
|
|
||||||
@Drone
|
@Drone
|
||||||
private WebDriver driver;
|
private WebDriver driver;
|
||||||
|
|
||||||
@FindByJQuery("a:contains('Settings')")
|
@FindByJQuery("a:contains('Settings')")
|
||||||
private WebElement settingsLink;
|
private WebElement settingsLink;
|
||||||
|
@ -54,8 +53,8 @@ public class Navigation {
|
||||||
|
|
||||||
@FindByJQuery("a:contains('Tokens')")
|
@FindByJQuery("a:contains('Tokens')")
|
||||||
private WebElement tokensLink;
|
private WebElement tokensLink;
|
||||||
|
|
||||||
@FindByJQuery("a:contains('Sessions')")
|
@FindByJQuery("a:contains('Sessions')")
|
||||||
private WebElement sessionLink;
|
private WebElement sessionLink;
|
||||||
|
|
||||||
@FindByJQuery("a:contains('Security Defenses')")
|
@FindByJQuery("a:contains('Security Defenses')")
|
||||||
|
@ -63,32 +62,32 @@ public class Navigation {
|
||||||
|
|
||||||
@FindByJQuery("a:contains('Events')")
|
@FindByJQuery("a:contains('Events')")
|
||||||
private WebElement eventsLink;
|
private WebElement eventsLink;
|
||||||
|
|
||||||
@FindByJQuery("a:contains('Login')")
|
@FindByJQuery("a:contains('Login')")
|
||||||
private WebElement loginLink;
|
private WebElement loginLink;
|
||||||
|
|
||||||
@FindByJQuery("a:contains('Themes')")
|
@FindByJQuery("a:contains('Themes')")
|
||||||
private WebElement themesLink;
|
private WebElement themesLink;
|
||||||
|
|
||||||
@FindByJQuery("a:contains('Role Mappings')")
|
@FindByJQuery("a:contains('Role Mappings')")
|
||||||
private WebElement usersRoleMappings;
|
private WebElement usersRoleMappings;
|
||||||
|
|
||||||
@FindByJQuery("a:contains('Add Realm')")
|
@FindByJQuery("a:contains('Add Realm')")
|
||||||
private WebElement addRealm;
|
private WebElement addRealm;
|
||||||
|
|
||||||
@FindByJQuery("a:contains('Credentials')")
|
@FindByJQuery("a:contains('Credentials')")
|
||||||
private WebElement credentials;
|
private WebElement credentials;
|
||||||
|
|
||||||
@FindByJQuery("a:contains('Attributes')")
|
@FindByJQuery("a:contains('Attributes')")
|
||||||
private WebElement attributes;
|
private WebElement attributes;
|
||||||
|
|
||||||
@FindBy(css = "div h1")
|
@FindBy(css = "div h1")
|
||||||
private WebElement currentHeader;
|
private WebElement currentHeader;
|
||||||
|
|
||||||
public void selectRealm(String realmName) {
|
public void selectRealm(String realmName) {
|
||||||
driver.findElement(By.linkText(realmName)).click();
|
driver.findElement(By.linkText(realmName)).click();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void settings() {
|
public void settings() {
|
||||||
openPage(settingsLink, "Settings");
|
openPage(settingsLink, "Settings");
|
||||||
}
|
}
|
||||||
|
@ -104,7 +103,7 @@ public class Navigation {
|
||||||
public void clients() {
|
public void clients() {
|
||||||
openPage(clientsLink, "Clients");
|
openPage(clientsLink, "Clients");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void oauth() {
|
public void oauth() {
|
||||||
openPage(oauthLink, "OAuth Clients");
|
openPage(oauthLink, "OAuth Clients");
|
||||||
}
|
}
|
||||||
|
@ -112,10 +111,10 @@ public class Navigation {
|
||||||
public void tokens() {
|
public void tokens() {
|
||||||
openPage(tokensLink, "Settings");
|
openPage(tokensLink, "Settings");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sessions() {
|
public void sessions() {
|
||||||
openPage(sessionLink, "Sessions");
|
openPage(sessionLink, "Sessions");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void security() {
|
public void security() {
|
||||||
openPage(securityLink, "Settings");
|
openPage(securityLink, "Settings");
|
||||||
|
@ -124,30 +123,32 @@ public class Navigation {
|
||||||
public void events() {
|
public void events() {
|
||||||
openPage(eventsLink, "Events");
|
openPage(eventsLink, "Events");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void login() {
|
|
||||||
openPage(loginLink, "Settings");
|
|
||||||
}
|
|
||||||
|
|
||||||
public void themes() {
|
public void login() {
|
||||||
openPage(themesLink, "Settings");
|
openPage(loginLink, "Settings");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void roleMappings() {
|
public void themes() {
|
||||||
openPage(usersRoleMappings, "User");
|
openPage(themesLink, "Settings");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addRealm() {
|
public void roleMappings(String username) {
|
||||||
openPage(addRealm, "Add Realm");
|
String usernameCapitalized = Character.toUpperCase(username.charAt(0))
|
||||||
}
|
+ username.substring(1);
|
||||||
|
openPage(usersRoleMappings, usernameCapitalized);
|
||||||
public void credentials() {
|
}
|
||||||
openPage(credentials, "Settings");
|
|
||||||
}
|
public void addRealm() {
|
||||||
|
openPage(addRealm, "Add Realm");
|
||||||
public void attributes() {
|
}
|
||||||
openPage(attributes, "Attributes");
|
|
||||||
}
|
public void credentials() {
|
||||||
|
openPage(credentials, "Settings");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void attributes() {
|
||||||
|
openPage(attributes, "Attributes");
|
||||||
|
}
|
||||||
|
|
||||||
private void openPage(WebElement page, String headerText) {
|
private void openPage(WebElement page, String headerText) {
|
||||||
waitGuiForElement(page);
|
waitGuiForElement(page);
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
* To change this template file, choose Tools | Templates
|
* To change this template file, choose Tools | Templates
|
||||||
* and open the template in the editor.
|
* and open the template in the editor.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.keycloak.testsuite.ui.test.role;
|
package org.keycloak.testsuite.ui.test.role;
|
||||||
|
|
||||||
import org.jboss.arquillian.graphene.findby.FindByJQuery;
|
import org.jboss.arquillian.graphene.findby.FindByJQuery;
|
||||||
|
@ -21,36 +20,35 @@ import org.keycloak.testsuite.ui.page.settings.user.UserPage;
|
||||||
import static org.openqa.selenium.By.id;
|
import static org.openqa.selenium.By.id;
|
||||||
import org.openqa.selenium.support.ui.Select;
|
import org.openqa.selenium.support.ui.Select;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Petr Mensik
|
* @author Petr Mensik
|
||||||
*/
|
*/
|
||||||
public class AddNewRoleTest extends AbstractKeyCloakTest<RolesPage> {
|
public class AddNewRoleTest extends AbstractKeyCloakTest<RolesPage> {
|
||||||
|
|
||||||
@Page
|
@Page
|
||||||
private UserPage userPage;
|
private UserPage userPage;
|
||||||
|
|
||||||
@FindByJQuery(".alert")
|
@FindByJQuery(".alert")
|
||||||
private FlashMessage flashMessage;
|
private FlashMessage flashMessage;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void beforeTestAddNewRole() {
|
public void beforeTestAddNewRole() {
|
||||||
navigation.roles();
|
navigation.roles();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAddNewRole() {
|
public void testAddNewRole() {
|
||||||
Role role = new Role("role1");
|
Role role = new Role("role1");
|
||||||
page.addRole(role);
|
page.addRole(role);
|
||||||
flashMessage.waitUntilPresent();
|
flashMessage.waitUntilPresent();
|
||||||
assertTrue(flashMessage.getText(), flashMessage.isSuccess());
|
assertTrue(flashMessage.getText(), flashMessage.isSuccess());
|
||||||
navigation.roles();
|
navigation.roles();
|
||||||
assertEquals("role1", page.findRole(role.getName()).getName());
|
assertEquals("role1", page.findRole(role.getName()).getName());
|
||||||
page.deleteRole(role);
|
page.deleteRole(role);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Ignore
|
@Ignore
|
||||||
@Test
|
@Test
|
||||||
public void testAddNewRoleWithLongName() {
|
public void testAddNewRoleWithLongName() {
|
||||||
String name = "hjewr89y1894yh98(*&*&$jhjkashd)*(&y8934h*&@#hjkahsdj";
|
String name = "hjewr89y1894yh98(*&*&$jhjkashd)*(&y8934h*&@#hjkahsdj";
|
||||||
|
@ -59,36 +57,36 @@ public class AddNewRoleTest extends AbstractKeyCloakTest<RolesPage> {
|
||||||
navigation.roles();
|
navigation.roles();
|
||||||
page.deleteRole(name);
|
page.deleteRole(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAddExistingRole() {
|
public void testAddExistingRole() {
|
||||||
Role role = new Role("role2");
|
Role role = new Role("role2");
|
||||||
page.addRole(role);
|
page.addRole(role);
|
||||||
flashMessage.waitUntilPresent();
|
flashMessage.waitUntilPresent();
|
||||||
assertTrue(flashMessage.getText(), flashMessage.isSuccess());
|
assertTrue(flashMessage.getText(), flashMessage.isSuccess());
|
||||||
navigation.roles();
|
navigation.roles();
|
||||||
page.addRole(role);
|
page.addRole(role);
|
||||||
flashMessage.waitUntilPresent();
|
flashMessage.waitUntilPresent();
|
||||||
assertTrue(flashMessage.getText(), flashMessage.isDanger());
|
assertTrue(flashMessage.getText(), flashMessage.isDanger());
|
||||||
navigation.roles();
|
navigation.roles();
|
||||||
page.deleteRole(role);
|
page.deleteRole(role);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRoleIsAvailableForUsers() {
|
public void testRoleIsAvailableForUsers() {
|
||||||
Role role = new Role("User role");
|
Role role = new Role("User role");
|
||||||
page.addRole(role);
|
page.addRole(role);
|
||||||
flashMessage.waitUntilPresent();
|
flashMessage.waitUntilPresent();
|
||||||
assertTrue(flashMessage.getText(), flashMessage.isSuccess());
|
assertTrue(flashMessage.getText(), flashMessage.isSuccess());
|
||||||
navigation.users();
|
navigation.users();
|
||||||
userPage.showAllUsers();
|
userPage.showAllUsers();
|
||||||
userPage.goToUser("admin");
|
userPage.goToUser("admin");
|
||||||
navigation.roleMappings();
|
navigation.roleMappings("Admin");
|
||||||
Select rolesSelect = new Select(driver.findElement(id("available")));
|
Select rolesSelect = new Select(driver.findElement(id("available")));
|
||||||
assertEquals("User role should be present in admin role mapping",
|
assertEquals("User role should be present in admin role mapping",
|
||||||
role.getName(), rolesSelect.getOptions().get(0).getText());
|
role.getName(), rolesSelect.getOptions().get(0).getText());
|
||||||
navigation.roles();
|
navigation.roles();
|
||||||
page.deleteRole(role);
|
page.deleteRole(role);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ public class RoleMappingsTest extends AbstractKeyCloakTest<RoleMappingsPage> {
|
||||||
navigation.users();
|
navigation.users();
|
||||||
userPage.findUser(testUsername);
|
userPage.findUser(testUsername);
|
||||||
driver.findElement(linkText(testUsername)).click();
|
driver.findElement(linkText(testUsername)).click();
|
||||||
navigation.roleMappings();
|
navigation.roleMappings(testUsername);
|
||||||
|
|
||||||
page.addAvailableRole("create-realm");
|
page.addAvailableRole("create-realm");
|
||||||
assertTrue(flashMessage.getText(), flashMessage.isSuccess());
|
assertTrue(flashMessage.getText(), flashMessage.isSuccess());
|
||||||
|
@ -58,7 +58,7 @@ public class RoleMappingsTest extends AbstractKeyCloakTest<RoleMappingsPage> {
|
||||||
navigation.users();
|
navigation.users();
|
||||||
userPage.findUser(testUsername);
|
userPage.findUser(testUsername);
|
||||||
driver.findElement(linkText(testUsername)).click();
|
driver.findElement(linkText(testUsername)).click();
|
||||||
navigation.roleMappings();
|
navigation.roleMappings(testUsername);
|
||||||
|
|
||||||
page.addAvailableRole("create-realm");
|
page.addAvailableRole("create-realm");
|
||||||
assertTrue(flashMessage.getText(), flashMessage.isSuccess());
|
assertTrue(flashMessage.getText(), flashMessage.isSuccess());
|
||||||
|
|
Loading…
Reference in a new issue