KEYCLOAK-12972 Fix fuse tests

This commit is contained in:
mhajas 2020-03-24 09:44:26 +01:00 committed by Stian Thorgersen
parent f6a592b15a
commit 8b96882a1c
3 changed files with 14 additions and 11 deletions

View file

@ -3,7 +3,9 @@ package org.keycloak.testsuite.adapter.page;
import org.jboss.arquillian.graphene.wait.ElementBuilder; import org.jboss.arquillian.graphene.wait.ElementBuilder;
import org.keycloak.testsuite.page.AbstractPage; import org.keycloak.testsuite.page.AbstractPage;
import org.openqa.selenium.By; import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
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 javax.ws.rs.core.UriBuilder; import javax.ws.rs.core.UriBuilder;
@ -12,7 +14,7 @@ import org.keycloak.testsuite.util.JavascriptBrowser;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import static org.jboss.arquillian.graphene.Graphene.waitGui; import static org.jboss.arquillian.graphene.Graphene.waitGui;
import static org.keycloak.testsuite.util.WaitUtils.waitUntilElement; import static org.keycloak.testsuite.util.WaitUtils.pause;
/** /**
* @author mhajas * @author mhajas
@ -43,10 +45,16 @@ public class HawtioPage extends AbstractPage {
@JavascriptBrowser @JavascriptBrowser
private WebElement modal; private WebElement modal;
public void logout() { public void logout(WebDriver jsDriver) {
log.debug("logging out"); log.debug("logging out");
hawtioWaitUntil(dropDownMenu).is().clickable(); hawtioWaitUntil(dropDownMenu).is().clickable();
dropDownMenu.click(); dropDownMenu.click();
// There is a tooltip shown which prevents logout button from clicking
// So we need to move mouse away from dropDownMenu element
new Actions(jsDriver).moveToElement(logoutButton).perform();
pause(100); // Wait for tooltip to fade out
hawtioWaitUntil(logoutButton).is().clickable(); hawtioWaitUntil(logoutButton).is().clickable();
logoutButton.click(); logoutButton.click();
hawtioWaitUntil(modal).is().clickable(); hawtioWaitUntil(modal).is().clickable();

View file

@ -119,7 +119,7 @@ public class EAP6Fuse6HawtioAdapterTest extends AbstractExampleAdapterTest imple
waitUntilUrlStartsWith(hawtioPage.toString() + "/welcome", 180); waitUntilUrlStartsWith(hawtioPage.toString() + "/welcome", 180);
hawtioPage.logout(); hawtioPage.logout(jsDriver);
WaitUtils.waitForPageToLoad(); WaitUtils.waitForPageToLoad();
assertCurrentUrlStartsWith(testRealmLoginPageFuse); assertCurrentUrlStartsWith(testRealmLoginPageFuse);

View file

@ -144,19 +144,14 @@ public class FuseAdapterTest extends AbstractExampleAdapterTest {
testRealmLoginPageFuse.form().login("root", "password"); testRealmLoginPageFuse.form().login("root", "password");
assertCurrentUrlStartsWith(hawtioPage.toString() + "/welcome"); assertCurrentUrlStartsWith(hawtioPage.toString() + "/welcome");
hawtioPage.logout(); hawtioPage.logout(jsDriver);
assertCurrentUrlStartsWith(testRealmLoginPageFuse); assertCurrentUrlStartsWith(testRealmLoginPageFuse);
hawtioPage.navigateTo(); hawtioPage.navigateTo();
log.debug("logging in as mary"); log.debug("logging in as mary");
testRealmLoginPageFuse.form().login("mary", "password"); testRealmLoginPageFuse.form().login("mary", "password");
log.debug("Previous WARN waitForPageToLoad time exceeded! is expected"); log.debug("Previous WARN waitForPageToLoad time exceeded! is expected");
assertThat(DroneUtils.getCurrentDriver().getPageSource(), assertThat(DroneUtils.getCurrentDriver().getCurrentUrl(), not(containsString("welcome")));
allOf(
containsString("Unauthorized User"),
not(containsString("welcome"))
)
);
} }
@Test @Test
@ -227,7 +222,7 @@ public class FuseAdapterTest extends AbstractExampleAdapterTest {
@AppServerContainer(value = ContainerConstants.APP_SERVER_FUSE63, skip = true) @AppServerContainer(value = ContainerConstants.APP_SERVER_FUSE63, skip = true)
public void sshLoginTestFuse7() throws Exception { public void sshLoginTestFuse7() throws Exception {
assertCommand("mary", "password", "shell:date", Result.NOT_FOUND); assertCommand("mary", "password", "shell:date", Result.NOT_FOUND);
assertCommand("john", "password", "shell:info", Result.NOT_FOUND); assertCommand("john", "password", "shell:info", Result.OK);
assertCommand("john", "password", "shell:date", Result.OK); assertCommand("john", "password", "shell:date", Result.OK);
assertRoles("root", assertRoles("root",
"ssh", "ssh",