Merge pull request #4860 from pdrozd/KEYCLOAK-6047

KEYCLOAK-6047 Added ide time window to mellon test
This commit is contained in:
Pavel Drozd 2017-12-15 22:23:19 +01:00 committed by GitHub
commit 4097a81142
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -5,6 +5,7 @@ import org.junit.Test;
import org.keycloak.representations.idm.RealmRepresentation; import org.keycloak.representations.idm.RealmRepresentation;
import org.keycloak.testsuite.AbstractAuthTest; import org.keycloak.testsuite.AbstractAuthTest;
import org.keycloak.testsuite.util.URLAssert; import org.keycloak.testsuite.util.URLAssert;
import org.keycloak.models.utils.SessionTimeoutHelper;
import java.util.List; import java.util.List;
@ -42,24 +43,29 @@ public class ModAuthMellonTest extends AbstractAuthTest {
@Test @Test
public void singleLoginAndLogoutTest() { public void singleLoginAndLogoutTest() {
modAuthMellonProtectedResourcePage.navigateTo(); try {
URLAssert.assertCurrentUrlStartsWith(testRealmSAMLRedirectLoginPage); modAuthMellonProtectedResourcePage.navigateTo();
testRealmSAMLRedirectLoginPage.form().login(bburkeUser); URLAssert.assertCurrentUrlStartsWith(testRealmSAMLRedirectLoginPage);
assertTrue(driver.getPageSource().contains("Protected resource")); testRealmSAMLRedirectLoginPage.form().login(bburkeUser);
assertTrue(driver.getPageSource().contains("Protected resource"));
modAuthMellonProtectedResourcePage2.navigateTo(); modAuthMellonProtectedResourcePage2.navigateTo();
assertTrue(driver.getPageSource().contains("Protected resource 2")); assertTrue(driver.getPageSource().contains("Protected resource 2"));
modAuthMellonProtectedResourcePage2.logout(); modAuthMellonProtectedResourcePage2.logout();
assertTrue(driver.getPageSource().contains("Unprotected resource 2")); assertTrue(driver.getPageSource().contains("Unprotected resource 2"));
modAuthMellonProtectedResourcePage2.navigateTo(); modAuthMellonProtectedResourcePage2.navigateTo();
URLAssert.assertCurrentUrlStartsWith(testRealmSAMLRedirectLoginPage); URLAssert.assertCurrentUrlStartsWith(testRealmSAMLRedirectLoginPage);
pause(5000); //session length setTimeOffset(SessionTimeoutHelper.IDLE_TIMEOUT_WINDOW_SECONDS * 1000);
pause(5000); //session length
modAuthMellonProtectedResourcePage.navigateTo(); modAuthMellonProtectedResourcePage.navigateTo();
URLAssert.assertCurrentUrlStartsWith(testRealmSAMLRedirectLoginPage); URLAssert.assertCurrentUrlStartsWith(testRealmSAMLRedirectLoginPage);
} finally {
resetTimeOffset();
}
} }
@Test @Test
@ -76,13 +82,17 @@ public class ModAuthMellonTest extends AbstractAuthTest {
@Test @Test
public void sessionExpiration() { public void sessionExpiration() {
modAuthMellonProtectedResourcePage.navigateTo(); try {
testRealmSAMLRedirectLoginPage.form().login(bburkeUser); modAuthMellonProtectedResourcePage.navigateTo();
assertTrue(driver.getPageSource().contains("Protected resource")); testRealmSAMLRedirectLoginPage.form().login(bburkeUser);
assertTrue(driver.getPageSource().contains("Protected resource"));
setTimeOffset(SessionTimeoutHelper.IDLE_TIMEOUT_WINDOW_SECONDS * 1000);
pause(5000); //session length
pause(5000); //session length modAuthMellonProtectedResourcePage.navigateTo();
URLAssert.assertCurrentUrlStartsWith(testRealmSAMLRedirectLoginPage);
modAuthMellonProtectedResourcePage.navigateTo(); } finally {
URLAssert.assertCurrentUrlStartsWith(testRealmSAMLRedirectLoginPage); resetTimeOffset();
}
} }
} }