diff --git a/.travis.yml b/.travis.yml index 1e16f36..7f62d97 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,15 +1,14 @@ language: java jdk: - - oraclejdk9 + - openjdk10 services: - docker - before_install: - docker pull jboss/keycloak:4.5.0.Final - - docker run -d -e KEYCLOAK_USER=admin -e KEYCLOAK_PASSWORD=admin -e KEYCLOAK_IMPORT=/tmp/elastic-realm-export.json -v "$(TRAVIS_BUILD_DIR)"/src/test/resources/config/elastic-realm-export.json:/tmp/elastic-realm-export.json jboss/keycloak:4.5.0.Final + - docker run -d -e KEYCLOAK_USER=admin -e KEYCLOAK_PASSWORD=admin -e KEYCLOAK_IMPORT=/tmp/elastic-realm-export.json -v "${TRAVIS_BUILD_DIR}"/src/test/resources/config/elastic-realm-export.json:/tmp/elastic-realm-export.json -p 8080:8080 jboss/keycloak install: - ./gradlew assemble diff --git a/src/test/java/org/elasticsearch/plugin/keycloak/KeycloakUtils.java b/src/test/java/org/elasticsearch/plugin/keycloak/KeycloakUtils.java index da56db9..950e0f6 100644 --- a/src/test/java/org/elasticsearch/plugin/keycloak/KeycloakUtils.java +++ b/src/test/java/org/elasticsearch/plugin/keycloak/KeycloakUtils.java @@ -36,10 +36,11 @@ public class KeycloakUtils { private static HttpClient httpClient = HttpClients.createDefault(); + private static final String KEYCLOAK_BASE_URL="http://localhost:8080"; public static void addUser(String username,String password) throws IOException { String adminToken = getKeycloakAdminToken("admin","admin"); - HttpPost httpPost = new HttpPost("http://localhost:8080/auth/admin/realms/elastic/users"); + HttpPost httpPost = new HttpPost(KEYCLOAK_BASE_URL.concat("/auth/admin/realms/elastic/users")); httpPost.setHeader(HttpHeaders.AUTHORIZATION,"Bearer "+adminToken); StringBuilder request = new StringBuilder(); @@ -57,7 +58,7 @@ public static void addUser(String username,String password) throws IOException { private static String getKeycloakAdminToken(String username,String password){ - HttpPost httpPost = new HttpPost("http://localhost:8080/auth/realms/master/protocol/openid-connect/token"); + HttpPost httpPost = new HttpPost(KEYCLOAK_BASE_URL.concat("/auth/realms/master/protocol/openid-connect/token")); List params = new ArrayList<>(); params.add(new BasicNameValuePair("grant_type", "password")); params.add(new BasicNameValuePair("username", username)); @@ -75,7 +76,7 @@ private static String getKeycloakAdminToken(String username,String password){ } public static String getKeycloakUserToken(String username,String password){ - HttpPost httpPost = new HttpPost("http://localhost:8080/auth/realms/elastic/protocol/openid-connect/token"); + HttpPost httpPost = new HttpPost(KEYCLOAK_BASE_URL.concat("/auth/realms/elastic/protocol/openid-connect/token")); List params = new ArrayList<>(); params.add(new BasicNameValuePair("grant_type", "password")); params.add(new BasicNameValuePair("username", username));