KEYCLOAK-10283 Update FuseAdapterTest to check login page directly

This commit is contained in:
vramik 2019-05-16 12:23:43 +02:00 committed by Hynek Mlnařík
parent 4ced3b0aee
commit ac6d877954
2 changed files with 16 additions and 14 deletions

View file

@ -23,7 +23,6 @@ import static org.keycloak.testsuite.auth.page.AuthRealm.DEMO;
import static org.keycloak.testsuite.utils.fuse.FuseUtils.assertCommand;
import static org.keycloak.testsuite.utils.fuse.FuseUtils.getCommandOutput;
import static org.keycloak.testsuite.utils.io.IOUtil.loadRealm;
import static org.keycloak.testsuite.util.URLAssert.assertCurrentUrlDoesntStartWith;
import static org.keycloak.testsuite.util.URLAssert.assertCurrentUrlStartsWith;
import static org.keycloak.testsuite.util.URLAssert.assertCurrentUrlStartsWithLoginUrlOf;
@ -57,6 +56,7 @@ import org.keycloak.testsuite.adapter.page.fuse.CustomerListing;
import org.keycloak.testsuite.adapter.page.fuse.CustomerPortalFuseExample;
import org.keycloak.testsuite.adapter.page.fuse.ProductPortalFuseExample;
import org.keycloak.testsuite.arquillian.annotation.AppServerContainer;
import org.keycloak.testsuite.auth.page.AuthRealm;
import org.keycloak.testsuite.auth.page.account.Account;
import org.keycloak.testsuite.utils.arquillian.ContainerConstants;
import org.keycloak.testsuite.auth.page.login.OIDCLogin;
@ -86,6 +86,9 @@ public class FuseAdapterTest extends AbstractExampleAdapterTest {
private OIDCLogin testRealmLoginPageFuse;
@Page
@JavascriptBrowser
private AuthRealm loginPageFuse;
@Page
@JavascriptBrowser
protected CustomerPortalFuseExample customerPortal;
@Page
@JavascriptBrowser
@ -99,7 +102,7 @@ public class FuseAdapterTest extends AbstractExampleAdapterTest {
@Page
@JavascriptBrowser
protected Account testRealmAccount;
@Override
public void addAdapterTestRealms(List<RealmRepresentation> testRealms) {
RealmRepresentation fuseRealm = loadRealm(new File(TEST_APPS_HOME_DIR + "/fuse/demorealm.json"));
@ -113,6 +116,7 @@ public class FuseAdapterTest extends AbstractExampleAdapterTest {
testRealmPage.setAuthRealm(DEMO);
testRealmLoginPage.setAuthRealm(DEMO);
testRealmAccount.setAuthRealm(DEMO);
loginPageFuse.setAuthRealm(DEMO);
}
@Before
@ -130,12 +134,12 @@ public class FuseAdapterTest extends AbstractExampleAdapterTest {
public void hawtio1LoginTest() throws Exception {
hawtioPage.navigateTo();
WaitUtils.waitForPageToLoad();
assertCurrentUrlDoesntStartWith(hawtioPage);
assertCurrentUrlStartsWith(loginPageFuse);
testRealmLoginPageFuse.form().login("user", "invalid-password");
assertCurrentUrlDoesntStartWith(hawtioPage);
assertCurrentUrlStartsWith(loginPageFuse);
testRealmLoginPageFuse.form().login("invalid-user", "password");
assertCurrentUrlDoesntStartWith(hawtioPage);
assertCurrentUrlStartsWith(loginPageFuse);
testRealmLoginPageFuse.form().login("root", "password");
assertCurrentUrlStartsWith(hawtioPage.toString() + "/welcome");
@ -160,12 +164,12 @@ public class FuseAdapterTest extends AbstractExampleAdapterTest {
hawtio2Page.navigateTo();
WaitUtils.waitForPageToLoad();
assertCurrentUrlDoesntStartWith(hawtio2Page);
assertCurrentUrlStartsWith(loginPageFuse);
testRealmLoginPageFuse.form().login("user", "invalid-password");
assertCurrentUrlDoesntStartWith(hawtio2Page);
assertCurrentUrlStartsWith(loginPageFuse);
testRealmLoginPageFuse.form().login("invalid-user", "password");
assertCurrentUrlDoesntStartWith(hawtio2Page);
assertCurrentUrlStartsWith(loginPageFuse);
testRealmLoginPageFuse.form().login("root", "password");
assertCurrentUrlStartsWith(hawtio2Page.toString());

View file

@ -35,10 +35,8 @@ import java.io.InputStreamReader;
import java.io.Reader;
import java.io.StringWriter;
import java.net.URI;
import java.net.URL;
import java.nio.charset.Charset;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.keycloak.testsuite.util.URLUtils.currentUrlDoesntStartWith;
import static org.keycloak.testsuite.util.URLUtils.currentUrlEquals;
@ -69,7 +67,7 @@ public class URLAssert {
}
public static void assertCurrentUrlEquals(final String url) {
assertTrue("Expected URL: " + url + "; actual: " + DroneUtils.getCurrentDriver().getCurrentUrl(),
assertTrue("Expected URL: " + url + " ; actual: " + DroneUtils.getCurrentDriver().getCurrentUrl(),
currentUrlEquals(url));
}
@ -88,7 +86,7 @@ public class URLAssert {
}
public static void assertCurrentUrlStartsWith(final String url){
assertTrue("URL expected to begin with:" + url + "; actual URL: " + DroneUtils.getCurrentDriver().getCurrentUrl(),
assertTrue("URL expected to begin with: " + url + " ; actual URL: " + DroneUtils.getCurrentDriver().getCurrentUrl(),
currentUrlStartsWith(url));
}
@ -111,7 +109,7 @@ public class URLAssert {
}
public static void assertCurrentUrlDoesntStartWith(final String url) {
assertTrue("URL expected NOT to begin with:" + url + "; actual URL: " + DroneUtils.getCurrentDriver().getCurrentUrl(),
assertTrue("URL expected NOT to begin with: " + url + " ; actual URL: " + DroneUtils.getCurrentDriver().getCurrentUrl(),
currentUrlDoesntStartWith(url));
}
@ -176,7 +174,7 @@ public class URLAssert {
char [] buf = new char[8192];
StringWriter out = new StringWriter();
Reader in = new InputStreamReader(entity.getContent(), Charset.forName("utf-8"));
int rc = 0;
int rc;
try {
while ((rc = in.read(buf)) != -1) {
out.write(buf, 0, rc);