Trustore support in adapter tests + fix tests
This commit is contained in:
parent
8830f87a76
commit
77c37ccaf6
12 changed files with 200 additions and 36 deletions
|
@ -0,0 +1,52 @@
|
|||
<!--
|
||||
~ Copyright 2016 Red Hat, Inc. and/or its affiliates
|
||||
~ and other contributors as indicated by the @author tags.
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
|
||||
<project name="inject-truststore" basedir="." default="inject-truststore">
|
||||
|
||||
<scriptdef name="inject-truststore" language="javascript" manager="bsf">
|
||||
<attribute name="path"/>
|
||||
<![CDATA[
|
||||
importClass(Packages.java.io.File);
|
||||
importClass(Packages.org.keycloak.util.JsonSerialization);
|
||||
|
||||
path = attributes.get("path");
|
||||
file = new File(path + "/standalone/configuration/keycloak-server.json");
|
||||
root = JsonSerialization.mapper.readTree(file);
|
||||
|
||||
jNode = JsonSerialization.mapper.createObjectNode();
|
||||
//jNode.put("file","${auth.server.home:" + path + "}/standalone/configuration/keycloak.truststore");
|
||||
jNode.put("file","${jboss.home.dir}/standalone/configuration/keycloak.truststore");
|
||||
jNode.put("password","secret");
|
||||
jNode.put("hostname-verification-policy","WILDCARD");
|
||||
jNode.put("disabled","false");
|
||||
|
||||
fileNode = JsonSerialization.mapper.createObjectNode();
|
||||
fileNode.set("file", jNode);
|
||||
truststoreNode = JsonSerialization.mapper.createObjectNode();
|
||||
truststoreNode.set("truststore", fileNode);
|
||||
|
||||
root.putAll(truststoreNode);
|
||||
|
||||
// save file
|
||||
JsonSerialization.prettyMapper.writeValue(file, root);
|
||||
]]>
|
||||
</scriptdef>
|
||||
|
||||
<target name="inject-truststore">
|
||||
<inject-truststore path="${auth.server.home}"/>
|
||||
</target>
|
||||
</project>
|
|
@ -55,14 +55,6 @@
|
|||
<socket-binding name="proxy-https" port="8443"/>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="//j:extensions">
|
||||
<xsl:copy-of select="."/>
|
||||
<system-properties>
|
||||
<property name="javax.net.ssl.trustStore" value="${{jboss.server.config.dir}}/keycloak.truststore"/>
|
||||
<property name="javax.net.ssl.trustStorePassword" value="secret"/>
|
||||
</system-properties>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="@*|node()">
|
||||
<xsl:copy>
|
||||
<xsl:apply-templates select="@*|node()" />
|
||||
|
|
|
@ -351,6 +351,60 @@
|
|||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-antrun-plugin</artifactId>
|
||||
<version>1.8</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>inject-truststore-into-keycloak-server-json</id>
|
||||
<phase>process-resources</phase>
|
||||
<goals>
|
||||
<goal>run</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<target>
|
||||
<ant antfile="../build-truststore.xml" inheritRefs="true">
|
||||
<target name="inject-truststore"/>
|
||||
</ant>
|
||||
</target>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>ant-contrib</groupId>
|
||||
<artifactId>ant-contrib</artifactId>
|
||||
<version>1.0b3</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>ant</groupId>
|
||||
<artifactId>ant</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.ant</groupId>
|
||||
<artifactId>ant-apache-bsf</artifactId>
|
||||
<version>1.9.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.bsf</groupId>
|
||||
<artifactId>bsf-api</artifactId>
|
||||
<version>3.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>rhino</groupId>
|
||||
<artifactId>js</artifactId>
|
||||
<version>1.7R2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.keycloak</groupId>
|
||||
<artifactId>keycloak-core</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
</build>
|
||||
|
|
|
@ -51,7 +51,8 @@
|
|||
"/js-console/*"
|
||||
],
|
||||
"webOrigins": [
|
||||
"http://localhost:8280"
|
||||
"http://localhost:8280",
|
||||
"https://localhost:8643"
|
||||
]
|
||||
}
|
||||
],
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
<html>
|
||||
<head>
|
||||
<script src="http://localhost:8180/auth/js/keycloak.js"></script>
|
||||
<script src="https://localhost:8543/auth/js/keycloak.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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 <a href="mailto:bburke@redhat.com">Bill Burke</a>
|
||||
|
@ -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";
|
||||
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
<extension qualifier="webdriver">
|
||||
<property name="browser">${browser}</property>
|
||||
<property name="firefox_binary">${firefox_binary}</property>
|
||||
<property name="phantomjs.cli.args">--ignore-ssl-errors=true --web-security=false</property>
|
||||
</extension>
|
||||
|
||||
<extension qualifier="graphene">
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<xsl:strip-space elements="*"/>
|
||||
|
||||
<xsl:variable name="keycloakSubsystem" select="'urn:jboss:domain:keycloak:1.1'"/>
|
||||
<xsl:param name="auth-server-port"/>
|
||||
<xsl:param name="auth-server-host"/>
|
||||
|
||||
<xsl:template match="//*[local-name()='subsystem' and starts-with(namespace-uri(), $keycloakSubsystem)]">
|
||||
<xsl:copy>
|
||||
|
@ -16,7 +16,7 @@
|
|||
<secure-deployment name="customer-portal-subsystem.war">
|
||||
<realm>demo</realm>
|
||||
<realm-public-key>MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCrVrCuTtArbgaZzL1hvh0xtL5mc7o0NqPVnYXkLvgcwiC3BjLGw1tGEGoJaXDuSaRllobm53JBhjx33UNv+5z/UMG4kytBWxheNVKnL6GgqlNabMaFfPLPCF8kAgKnsi79NMo+n6KnSY8YeUmec/p2vjO2NjsSAVcWEQMVhJ31LwIDAQAB</realm-public-key>
|
||||
<auth-server-url>http://localhost:<xsl:value-of select="$auth-server-port"/>/auth</auth-server-url>
|
||||
<auth-server-url><xsl:value-of select="$auth-server-host"/>/auth</auth-server-url>
|
||||
<ssl-required>EXTERNAL</ssl-required>
|
||||
<resource>customer-portal-subsystem</resource>
|
||||
<credential name="secret">password</credential>
|
||||
|
|
|
@ -61,8 +61,8 @@
|
|||
<outputDir>${app.server.home}/standalone/configuration</outputDir>
|
||||
<parameters>
|
||||
<parameter>
|
||||
<name>auth-server-port</name>
|
||||
<value>${auth.server.http.port}</value>
|
||||
<name>auth-server-host</name>
|
||||
<value>http://localhost:${auth.server.http.port}</value>
|
||||
</parameter>
|
||||
</parameters>
|
||||
</transformationSet>
|
||||
|
@ -75,6 +75,50 @@
|
|||
</build>
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>ssl</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>app.server.ssl.required</name>
|
||||
<value>true</value>
|
||||
</property>
|
||||
</activation>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>xml-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>Configure keycloak subsystem</id>
|
||||
<phase>process-test-resources</phase>
|
||||
<goals>
|
||||
<goal>transform</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<transformationSets>
|
||||
<transformationSet>
|
||||
<dir>${app.server.home}/standalone/configuration</dir>
|
||||
<includes>
|
||||
<include>standalone.xml</include>
|
||||
</includes>
|
||||
<stylesheet>${common.resources}/xslt/keycloak-subsystem.xsl</stylesheet>
|
||||
<outputDir>${app.server.home}/standalone/configuration</outputDir>
|
||||
<parameters>
|
||||
<parameter>
|
||||
<name>auth-server-host</name>
|
||||
<value>https://localhost:${auth.server.https.port}</value>
|
||||
</parameter>
|
||||
</parameters>
|
||||
</transformationSet>
|
||||
</transformationSets>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>adapter-test-jboss-submodules</id>
|
||||
<activation>
|
||||
|
|
|
@ -53,7 +53,12 @@
|
|||
|
||||
<app.server.ssl.required>false</app.server.ssl.required>
|
||||
|
||||
<adapter.test.props>-Dapp.server.base.url=http://localhost:${app.server.http.port} -Dmy.host.name=localhost</adapter.test.props>
|
||||
<adapter.test.props>
|
||||
-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
|
||||
</adapter.test.props>
|
||||
|
||||
<app.server.home>${containers.home}/app-server-${app.server}</app.server.home>
|
||||
<adapter.libs.mode>bundled</adapter.libs.mode>
|
||||
|
|
|
@ -637,6 +637,7 @@
|
|||
<dependency>
|
||||
<groupId>org.jboss.arquillian.extension</groupId>
|
||||
<artifactId>arquillian-phantom-driver</artifactId>
|
||||
<version>1.2.1.Final</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jboss.arquillian.graphene</groupId>
|
||||
|
|
Loading…
Reference in a new issue