use of org.keycloak.testsuite.util.javascript.JSObjectBuilder in project keycloak by keycloak.
the class JavascriptAdapterTest method testIframeInit.
@Test
public // KEYCLOAK-13206
void testIframeInit() {
// to speed up the test a bit
JSObjectBuilder iframeInterval = defaultArguments().setCheckLoginIframeIntervalTo1();
testExecutor.init(iframeInterval).login().loginForm(testUser).init(iframeInterval).wait(2000, (driver1, output, events) -> {
// iframe is initialized after ~1 second, 2 seconds is just to be sure
assertAdapterIsLoggedIn(driver1, output, events);
final String logMsg = "3rd party cookies aren't supported by this browser.";
if (SuiteContext.BROWSER_STRICT_COOKIES) {
// this is here not really to test the log but also to make sure the browser is configured properly
// and cookies were blocked
assertEventsWebElementContains(logMsg, driver1, output, events);
} else {
assertEventsWebElementDoesntContain(logMsg, driver1, output, events);
}
});
}
use of org.keycloak.testsuite.util.javascript.JSObjectBuilder in project keycloak by keycloak.
the class JavascriptAdapterTest method checkInitWithUnavailableAuthServer.
// In case of unavailable Authorization Server due to network or other kind of problems,
// JavaScript Adapter init() should fail-fast and reject Promise with KeycloakError.
@Test
public void checkInitWithUnavailableAuthServer() {
JSObjectBuilder keycloakConfig = JSObjectBuilder.create().add("url", "https://localhost:12345/auth").add("realm", REALM_NAME).add("clientId", CLIENT_ID);
JSObjectBuilder initOptions = defaultArguments().add("messageReceiveTimeout", 5000);
testExecutor.configure(keycloakConfig).init(initOptions, assertErrorResponse("Timeout when waiting for 3rd party check iframe message."));
}
use of org.keycloak.testsuite.util.javascript.JSObjectBuilder in project keycloak by keycloak.
the class JavascriptAdapterTest method testLoginWithPkceS256.
@Test
public void testLoginWithPkceS256() {
JSObjectBuilder pkceS256 = defaultArguments().pkceS256();
testExecutor.init(pkceS256, this::assertInitNotAuth).login(this::assertOnLoginPage).loginForm(testUser, this::assertOnTestAppUrl).init(pkceS256, this::assertInitAuth).logout(this::assertOnTestAppUrl).init(pkceS256, this::assertInitNotAuth);
}
use of org.keycloak.testsuite.util.javascript.JSObjectBuilder in project keycloak by keycloak.
the class JavascriptAdapterTest method testSilentCheckSso.
@Test
public void testSilentCheckSso() {
JSObjectBuilder checkSSO = defaultArguments().checkSSOOnLoad().add("silentCheckSsoRedirectUri", authServerContextRootPage.toString().replace(AUTH_SERVER_HOST, JS_APP_HOST) + JAVASCRIPT_URL + "/silent-check-sso.html");
// when 3rd party cookies are disabled, the adapter has to do a full redirect to KC to check whether the user
// is logged in or not – it can't rely on silent check-sso iframe
testExecutor.init(checkSSO, this::assertInitNotAuth, SuiteContext.BROWSER_STRICT_COOKIES).login(this::assertOnLoginPage).loginForm(testUser, this::assertOnTestAppUrl).init(checkSSO, this::assertInitAuth, false).refresh().init(checkSSO, this::assertInitAuth, SuiteContext.BROWSER_STRICT_COOKIES);
}
use of org.keycloak.testsuite.util.javascript.JSObjectBuilder in project keycloak by keycloak.
the class JavascriptAdapterTest method spaceInRealmNameTest.
@Test
public void spaceInRealmNameTest() {
// Unfortunately this test doesn't work on phantomjs
// it looks like phantomjs double encode %20 => %25%20
Assume.assumeTrue("This test doesn't work with phantomjs", !"phantomjs".equals(System.getProperty("js.browser")));
try {
adminClient.realm(REALM_NAME).update(RealmBuilder.edit(adminClient.realm(REALM_NAME).toRepresentation()).name(SPACE_REALM_NAME).build());
JSObjectBuilder configuration = JSObjectBuilder.create().add("url", authServerContextRootPage + "/auth").add("realm", SPACE_REALM_NAME).add("clientId", CLIENT_ID);
testAppUrl = authServerContextRootPage + JAVASCRIPT_ENCODED_SPACE_URL + "/index.html";
jsDriver.navigate().to(testAppUrl);
jsDriverTestRealmLoginPage.setAuthRealm(SPACE_REALM_NAME);
testExecutor.configure(configuration).init(defaultArguments(), this::assertInitNotAuth).login(this::assertOnLoginPage).loginForm(testUser, this::assertOnTestAppUrl).configure(configuration).init(defaultArguments(), this::assertInitAuth);
} finally {
adminClient.realm(SPACE_REALM_NAME).update(RealmBuilder.edit(adminClient.realm(SPACE_REALM_NAME).toRepresentation()).name(REALM_NAME).build());
jsDriverTestRealmLoginPage.setAuthRealm(REALM_NAME);
}
}
Aggregations