From 77c37ccaf6e71e3b9891ede54e4f1dc762c98677 Mon Sep 17 00:00:00 2001 From: mhajas Date: Wed, 13 Apr 2016 09:45:28 +0200 Subject: [PATCH] Trustore support in adapter tests + fix tests --- .../auth-server/jboss/build-truststore.xml | 52 +++++++++++ .../auth-server/jboss/common/security.xsl | 8 -- .../servers/auth-server/jboss/pom.xml | 90 +++++++++++++++---- .../test-apps/js-console/example-realm.json | 3 +- .../js-console/src/main/webapp/index.html | 1 + .../adapter/servlet/CustomerServlet.java | 10 ++- .../adapter/servlet/InputServlet.java | 9 +- .../base/src/test/resources/arquillian.xml | 1 + .../jboss/common/xslt/keycloak-subsystem.xsl | 4 +- .../tests/other/adapters/jboss/pom.xml | 50 ++++++++++- .../tests/other/adapters/pom.xml | 7 +- .../integration-arquillian/tests/pom.xml | 1 + 12 files changed, 200 insertions(+), 36 deletions(-) create mode 100644 testsuite/integration-arquillian/servers/auth-server/jboss/build-truststore.xml diff --git a/testsuite/integration-arquillian/servers/auth-server/jboss/build-truststore.xml b/testsuite/integration-arquillian/servers/auth-server/jboss/build-truststore.xml new file mode 100644 index 0000000000..073f860a32 --- /dev/null +++ b/testsuite/integration-arquillian/servers/auth-server/jboss/build-truststore.xml @@ -0,0 +1,52 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/testsuite/integration-arquillian/servers/auth-server/jboss/common/security.xsl b/testsuite/integration-arquillian/servers/auth-server/jboss/common/security.xsl index 2a238993f8..ec6b9defdc 100644 --- a/testsuite/integration-arquillian/servers/auth-server/jboss/common/security.xsl +++ b/testsuite/integration-arquillian/servers/auth-server/jboss/common/security.xsl @@ -55,14 +55,6 @@ - - - - - - - - diff --git a/testsuite/integration-arquillian/servers/auth-server/jboss/pom.xml b/testsuite/integration-arquillian/servers/auth-server/jboss/pom.xml index a64313e24f..a3ad98a38b 100644 --- a/testsuite/integration-arquillian/servers/auth-server/jboss/pom.xml +++ b/testsuite/integration-arquillian/servers/auth-server/jboss/pom.xml @@ -26,21 +26,21 @@ 4.0.0 pom - + integration-arquillian-servers-auth-server-jboss - + Auth Server - JBoss - + ${project.parent.basedir}/common ${project.parent.basedir}/assembly.xml - + org.keycloak keycloak-server-dist ${project.version} keycloak-${auth.server.dist.version} - + org.keycloak keycloak-server-overlay @@ -50,18 +50,18 @@ wildfly-dist ${wildfly.version} wildfly-${overlaid.container.version} - + ${auth.server.dist.groupId} ${auth.server.dist.artifactId} ${auth.server.dist.version} - + ${project.build.directory}/unpacked/${auth.server.dist.unpacked.folder.name} - + false - + @@ -226,7 +226,7 @@ - + server-overlay @@ -280,7 +280,7 @@ - @@ -291,7 +291,7 @@ - + ssl @@ -351,11 +351,65 @@ + + org.apache.maven.plugins + maven-antrun-plugin + 1.8 + + + inject-truststore-into-keycloak-server-json + process-resources + + run + + + + + + + + + + + + + ant-contrib + ant-contrib + 1.0b3 + + + ant + ant + + + + + org.apache.ant + ant-apache-bsf + 1.9.3 + + + org.apache.bsf + bsf-api + 3.1 + + + rhino + js + 1.7R2 + + + org.keycloak + keycloak-core + ${project.version} + + + - + jpa @@ -411,7 +465,7 @@ ${jdbc.mvn.groupId} - ${jdbc.mvn.artifactId} + ${jdbc.mvn.artifactId} ${jdbc.mvn.version} jar @@ -498,8 +552,8 @@ - - + + auth-server-cluster @@ -583,7 +637,7 @@ - + auth-server-wildfly @@ -596,6 +650,6 @@ eap - + diff --git a/testsuite/integration-arquillian/test-apps/js-console/example-realm.json b/testsuite/integration-arquillian/test-apps/js-console/example-realm.json index 659e5b4476..3bc609ef84 100755 --- a/testsuite/integration-arquillian/test-apps/js-console/example-realm.json +++ b/testsuite/integration-arquillian/test-apps/js-console/example-realm.json @@ -51,7 +51,8 @@ "/js-console/*" ], "webOrigins": [ - "http://localhost:8280" + "http://localhost:8280", + "https://localhost:8643" ] } ], diff --git a/testsuite/integration-arquillian/test-apps/js-console/src/main/webapp/index.html b/testsuite/integration-arquillian/test-apps/js-console/src/main/webapp/index.html index 1c41fcf11e..04d7a8e202 100755 --- a/testsuite/integration-arquillian/test-apps/js-console/src/main/webapp/index.html +++ b/testsuite/integration-arquillian/test-apps/js-console/src/main/webapp/index.html @@ -18,6 +18,7 @@ + diff --git a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/adapter/servlet/CustomerServlet.java b/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/adapter/servlet/CustomerServlet.java index 7b75a0f9bc..e174d7e007 100644 --- a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/adapter/servlet/CustomerServlet.java +++ b/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/adapter/servlet/CustomerServlet.java @@ -56,7 +56,15 @@ public class CustomerServlet extends HttpServlet { //try { StringBuilder result = new StringBuilder(); - URL url = new URL(System.getProperty("app.server.base.url", "http://localhost:8280") + "/customer-db/"); + String urlBase; + + if (System.getProperty("app.server.ssl.required", "false").equals("true")) { + urlBase = System.getProperty("app.server.ssl.base.url", "https://localhost:8643"); + } else { + urlBase = System.getProperty("app.server.base.url", "http://localhost:8280"); + } + + URL url = new URL(urlBase + "/customer-db/"); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setRequestMethod("GET"); conn.setRequestProperty(HttpHeaders.AUTHORIZATION, "Bearer " + context.getTokenString()); diff --git a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/adapter/servlet/InputServlet.java b/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/adapter/servlet/InputServlet.java index 171b4b41bf..a2038bf698 100644 --- a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/adapter/servlet/InputServlet.java +++ b/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/adapter/servlet/InputServlet.java @@ -18,12 +18,12 @@ package org.keycloak.testsuite.adapter.servlet; import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.io.PrintWriter; -import javax.servlet.annotation.WebServlet; /** * @author Bill Burke @@ -33,7 +33,12 @@ public class InputServlet extends HttpServlet { @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { - String appBase = System.getProperty("app.server.base.url", "http://localhost:8280"); + String appBase; + if (System.getProperty("app.server.ssl.required", "false").equals("true")) { + appBase = System.getProperty("app.server.ssl.base.url", "https://localhost:8643"); + } else { + appBase = System.getProperty("app.server.base.url", "http://localhost:8280"); + } String actionUrl = appBase + "/input-portal/secured/post"; diff --git a/testsuite/integration-arquillian/tests/base/src/test/resources/arquillian.xml b/testsuite/integration-arquillian/tests/base/src/test/resources/arquillian.xml index f1188a1137..189389a4c9 100644 --- a/testsuite/integration-arquillian/tests/base/src/test/resources/arquillian.xml +++ b/testsuite/integration-arquillian/tests/base/src/test/resources/arquillian.xml @@ -25,6 +25,7 @@ ${browser} ${firefox_binary} + --ignore-ssl-errors=true --web-security=false diff --git a/testsuite/integration-arquillian/tests/other/adapters/jboss/common/xslt/keycloak-subsystem.xsl b/testsuite/integration-arquillian/tests/other/adapters/jboss/common/xslt/keycloak-subsystem.xsl index bb776134c2..0027550eda 100644 --- a/testsuite/integration-arquillian/tests/other/adapters/jboss/common/xslt/keycloak-subsystem.xsl +++ b/testsuite/integration-arquillian/tests/other/adapters/jboss/common/xslt/keycloak-subsystem.xsl @@ -7,7 +7,7 @@ - + @@ -16,7 +16,7 @@ demo MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCrVrCuTtArbgaZzL1hvh0xtL5mc7o0NqPVnYXkLvgcwiC3BjLGw1tGEGoJaXDuSaRllobm53JBhjx33UNv+5z/UMG4kytBWxheNVKnL6GgqlNabMaFfPLPCF8kAgKnsi79NMo+n6KnSY8YeUmec/p2vjO2NjsSAVcWEQMVhJ31LwIDAQAB - http://localhost:/auth + /auth EXTERNAL customer-portal-subsystem password diff --git a/testsuite/integration-arquillian/tests/other/adapters/jboss/pom.xml b/testsuite/integration-arquillian/tests/other/adapters/jboss/pom.xml index 42780cf1e1..f674bc6d0e 100644 --- a/testsuite/integration-arquillian/tests/other/adapters/jboss/pom.xml +++ b/testsuite/integration-arquillian/tests/other/adapters/jboss/pom.xml @@ -61,8 +61,8 @@ ${app.server.home}/standalone/configuration - auth-server-port - ${auth.server.http.port} + auth-server-host + http://localhost:${auth.server.http.port} @@ -75,6 +75,50 @@ + + ssl + + + app.server.ssl.required + true + + + + + + org.codehaus.mojo + xml-maven-plugin + + + Configure keycloak subsystem + process-test-resources + + transform + + + + + ${app.server.home}/standalone/configuration + + standalone.xml + + ${common.resources}/xslt/keycloak-subsystem.xsl + ${app.server.home}/standalone/configuration + + + auth-server-host + https://localhost:${auth.server.https.port} + + + + + + + + + + + adapter-test-jboss-submodules @@ -89,7 +133,7 @@ - + app-server-as7 diff --git a/testsuite/integration-arquillian/tests/other/adapters/pom.xml b/testsuite/integration-arquillian/tests/other/adapters/pom.xml index 4189dad2e9..b1edcf6030 100644 --- a/testsuite/integration-arquillian/tests/other/adapters/pom.xml +++ b/testsuite/integration-arquillian/tests/other/adapters/pom.xml @@ -53,7 +53,12 @@ false - -Dapp.server.base.url=http://localhost:${app.server.http.port} -Dmy.host.name=localhost + + -Dapp.server.base.url=http://localhost:${app.server.http.port} + -Dapp.server.ssl.base.url=https://localhost:${app.server.https.port} + -Dapp.server.ssl.required=${app.server.ssl.required} + -Dmy.host.name=localhost + ${containers.home}/app-server-${app.server} bundled diff --git a/testsuite/integration-arquillian/tests/pom.xml b/testsuite/integration-arquillian/tests/pom.xml index 4d53e7431d..76a4ed3aef 100755 --- a/testsuite/integration-arquillian/tests/pom.xml +++ b/testsuite/integration-arquillian/tests/pom.xml @@ -637,6 +637,7 @@ org.jboss.arquillian.extension arquillian-phantom-driver + 1.2.1.Final org.jboss.arquillian.graphene