From b33f7414dac43b079200dde879865ae7bfa65188 Mon Sep 17 00:00:00 2001 From: mhajas Date: Wed, 3 May 2017 08:51:26 +0200 Subject: [PATCH] KEYCLOAK-4503 Add test --- .../AbstractJSConsoleExampleAdapterTest.java | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/adapter/example/AbstractJSConsoleExampleAdapterTest.java b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/adapter/example/AbstractJSConsoleExampleAdapterTest.java index 37941b9fac..a71ef13757 100755 --- a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/adapter/example/AbstractJSConsoleExampleAdapterTest.java +++ b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/adapter/example/AbstractJSConsoleExampleAdapterTest.java @@ -404,7 +404,7 @@ public abstract class AbstractJSConsoleExampleAdapterTest extends AbstractExampl int timeSkew = Integer.parseInt(jsConsoleTestAppPage.getTimeSkewValue().getText()); assertTrue("TimeSkew was: " + timeSkew + ", but should be ~0", timeSkew >= 0 - TIME_SKEW_TOLERANCE); - assertTrue("TimeSkew was: " + timeSkew + ", but should be ~0", timeSkew <= TIME_SKEW_TOLERANCE); + assertTrue("TimeSkew was: " + timeSkew + ", but should be ~0", timeSkew <= TIME_SKEW_TOLERANCE); setTimeOffset(40); jsConsoleTestAppPage.refreshToken(); @@ -414,7 +414,7 @@ public abstract class AbstractJSConsoleExampleAdapterTest extends AbstractExampl timeSkew = Integer.parseInt(jsConsoleTestAppPage.getTimeSkewValue().getText()); assertTrue("TimeSkew was: " + timeSkew + ", but should be ~-40", timeSkew + 40 >= 0 - TIME_SKEW_TOLERANCE); - assertTrue("TimeSkew was: " + timeSkew + ", but should be ~-40", timeSkew + 40 <= TIME_SKEW_TOLERANCE); + assertTrue("TimeSkew was: " + timeSkew + ", but should be ~-40", timeSkew + 40 <= TIME_SKEW_TOLERANCE); } // KEYCLOAK-4179 @@ -525,6 +525,27 @@ public abstract class AbstractJSConsoleExampleAdapterTest extends AbstractExampl setTimeOffset(0); } + @Test + // KEYCLOAK-4503 + public void initializeWithRefreshToken() { + oauth.realm(EXAMPLE); + oauth.clientId("js-console"); + oauth.redirectUri("http://localhost:8280/js-console"); + oauth.doLogin("user", "password"); + + String code = oauth.getCurrentQuery().get(OAuth2Constants.CODE); + String token = oauth.doAccessTokenRequest(code, "password").getAccessToken(); + String refreshToken = oauth.doRefreshTokenRequest(token, "password").getRefreshToken(); + + jsConsoleTestAppPage.navigateTo(); + jsConsoleTestAppPage.setInput2(refreshToken); + + jsConsoleTestAppPage.initWithRefreshToken(); + + waitUntilElement(jsConsoleTestAppPage.getOutputElement()).text().contains("Init Success (Not Authenticated)"); + waitUntilElement(jsConsoleTestAppPage.getEventsElement()).text().not().contains("Auth Success"); + } + @Test public void reentrancyCallbackTest() { logInAndInit("standard");