Fix selenium-tests.sh add keycloak token endpoint to settings

6.19.x
Anton Korneta 2017-10-02 11:14:45 +03:00
parent 5ee2914e95
commit 09f062370c
3 changed files with 19 additions and 13 deletions

View File

@ -18,6 +18,7 @@ import static org.eclipse.che.multiuser.keycloak.shared.KeycloakConstants.OSO_EN
import static org.eclipse.che.multiuser.keycloak.shared.KeycloakConstants.PASSWORD_ENDPOINT_SETTING;
import static org.eclipse.che.multiuser.keycloak.shared.KeycloakConstants.PROFILE_ENDPOINT_SETTING;
import static org.eclipse.che.multiuser.keycloak.shared.KeycloakConstants.REALM_SETTING;
import static org.eclipse.che.multiuser.keycloak.shared.KeycloakConstants.TOKEN_ENDPOINT_SETTING;
import com.google.common.collect.Maps;
import java.util.Collections;
@ -49,6 +50,7 @@ public class KeycloakSettings {
settings.put(
LOGOUT_ENDPOINT_SETTING,
serverURL + "/realms/" + realm + "/protocol/openid-connect/logout");
settings.put(TOKEN_ENDPOINT_SETTING,serverURL + "/realms/" + realm + "/protocol/openid-connect/token");
settings.put(OSO_ENDPOINT_SETTING, osoEndpoint);
settings.put(GITHUB_ENDPOINT_SETTING, gitHubEndpoint);

View File

@ -14,11 +14,8 @@ export CALLER=$(basename $0)
cd $CUR_DIR
index=0
params=($*)
CLEAN_GOAL="clean"
TESTS_SCOPE="--suite=CheSuite.xml"
cheMultiuserValue=${CHE_MULTIUSER:-false}
CLEAN_GOAL="clean"
for var in "$@"; do
if [[ "$var" =~ --test=.* ]] || [[ "$var" =~ --suite=.* ]]; then
TESTS_SCOPE=
@ -32,11 +29,16 @@ for var in "$@"; do
CLEAN_GOAL=
break
fi
done
index=0
params=($*)
cheMultiuserValue=${CHE_MULTIUSER:-false}
for var in "$@"; do
if [[ "$var" =~ --multiuser ]]; then
cheMultiuserValue=true
unset params[$index] # remove "--multiuser" from parameters
break
cheMultiuserValue=true
unset params[$index] # remove "--multiuser" from parameters
break
fi
let "index+=1"
done
@ -45,7 +47,6 @@ export CHE_MULTIUSER=$cheMultiuserValue
set -- "${params[@]}"
mvn $CLEAN_GOAL dependency:unpack-dependencies \
-DincludeArtifactIds=che-selenium-core \
-DincludeGroupIds=org.eclipse.che.selenium \
@ -53,5 +54,4 @@ mvn $CLEAN_GOAL dependency:unpack-dependencies \
-DoutputDirectory=${CUR_DIR}/target/bin
chmod +x target/bin/webdriver.sh
(target/bin/webdriver.sh "$TESTS_SCOPE" $@)
(target/bin/webdriver.sh "$TESTS_SCOPE" $@)

View File

@ -113,9 +113,13 @@ public class KeycloakTestAuthServiceClient implements TestAuthServiceClient {
private KeycloakToken requestToken(String grandType, List<Pair<String, ?>> params) {
KeycloakToken token = null;
HttpURLConnection http = null;
final String keycloakApiEndpoint = keycloakSettings.getKeycloakTokenEndpoint();
final String keycloakTokenEndpoint = keycloakSettings.getKeycloakTokenEndpoint();
if (keycloakTokenEndpoint == null) {
throw new RuntimeException("Keycloak token endpoint is not configured");
}
try {
http = (HttpURLConnection) new URL(keycloakApiEndpoint).openConnection();
http = (HttpURLConnection) new URL(keycloakTokenEndpoint).openConnection();
http.setRequestMethod(POST);
http.setAllowUserInteraction(false);
http.setRequestProperty(CONTENT_TYPE, FORM_MIME_TYPE);
@ -137,7 +141,7 @@ public class KeycloakTestAuthServiceClient implements TestAuthServiceClient {
if (http.getResponseCode() != 200) {
throw new RuntimeException(
"Can not get access token using the KeyCloak REST API. Server response code: "
+ keycloakApiEndpoint
+ keycloakTokenEndpoint
+ " "
+ http.getResponseCode()
+ IoUtil.readStream(http.getErrorStream()));