install adapter via cli script from java code after start
This commit is contained in:
parent
efa112f820
commit
448a15b2ca
14 changed files with 233 additions and 402 deletions
|
@ -273,7 +273,6 @@
|
|||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<version>2.7</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>copy-keystore</id>
|
||||
|
@ -309,7 +308,6 @@
|
|||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-enforcer-plugin</artifactId>
|
||||
<version>1.4</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>enforce-properties</id>
|
||||
|
|
|
@ -15,22 +15,29 @@
|
|||
<as7.version>7.1.1.Final</as7.version>
|
||||
<app.server.as7.home>${containers.home}/jboss-as-${as7.version}</app.server.as7.home>
|
||||
<adapter.libs.as7>${containers.home}/keycloak-as7-adapter-dist</adapter.libs.as7>
|
||||
<startup.timeout.sec>150</startup.timeout.sec>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.wildfly</groupId>
|
||||
<artifactId>wildfly-arquillian-container-managed</artifactId>
|
||||
</dependency>
|
||||
<!--for as7-->
|
||||
<dependency>
|
||||
<groupId>org.jboss.as</groupId>
|
||||
<artifactId>jboss-as-arquillian-container-managed</artifactId>
|
||||
<version>${as7.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jboss.as</groupId>
|
||||
<artifactId>jboss-as-dist</artifactId>
|
||||
<version>${as7.version}</version>
|
||||
<type>zip</type>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wildfly</groupId>
|
||||
<artifactId>wildfly-arquillian-container-managed</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.keycloak</groupId>
|
||||
<artifactId>keycloak-eap6-adapter-dist</artifactId>
|
||||
<artifactId>keycloak-as7-adapter-dist</artifactId>
|
||||
<type>zip</type>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
@ -79,15 +86,36 @@
|
|||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.18.1</version>
|
||||
<configuration>
|
||||
<systemPropertyVariables>
|
||||
<app.server.as7>true</app.server.as7>
|
||||
<app.server.as7.home>${app.server.as7.home}</app.server.as7.home>
|
||||
<adapter.libs.as7>${adapter.libs.as7}</adapter.libs.as7>
|
||||
<startup.timeout.sec>${startup.timeout.sec}</startup.timeout.sec>
|
||||
<adapter.as7.jdk7.path>${adapter.as7.jdk7.path}</adapter.as7.jdk7.path>
|
||||
</systemPropertyVariables>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-enforcer-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>enforce-properties</id>
|
||||
<goals>
|
||||
<goal>enforce</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<rules>
|
||||
<requireProperty>
|
||||
<property>adapter.as7.jdk7.path</property>
|
||||
</requireProperty>
|
||||
</rules>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
@ -102,35 +130,6 @@
|
|||
<properties>
|
||||
<adapter.libs.as7>${app.server.as7.home}</adapter.libs.as7>
|
||||
</properties>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>xml-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>configure-adapter-subsystem</id>
|
||||
<phase>process-resources</phase>
|
||||
<goals>
|
||||
<goal>transform</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<transformationSets>
|
||||
<transformationSet>
|
||||
<dir>${app.server.as7.home}/standalone/configuration</dir>
|
||||
<includes>
|
||||
<include>standalone.xml</include>
|
||||
</includes>
|
||||
<stylesheet>src/main/xslt/standalone.xsl</stylesheet>
|
||||
<outputDir>${app.server.as7.home}/standalone/configuration</outputDir>
|
||||
</transformationSet>
|
||||
</transformationSets>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
</profiles>
|
||||
</project>
|
||||
|
|
|
@ -20,6 +20,8 @@
|
|||
<property name="managementAddress">localhost</property>
|
||||
<property name="managementProtocol">remote</property>
|
||||
<property name="managementPort">${app.server.management.port.jmx}</property>
|
||||
<property name="startupTimeoutInSeconds">${startup.timeout.sec}</property>
|
||||
<property name="javaHome">${adapter.as7.jdk7.path}</property>
|
||||
</configuration>
|
||||
</container>
|
||||
|
||||
|
|
|
@ -1,51 +0,0 @@
|
|||
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
||||
xmlns:xalan="http://xml.apache.org/xalan"
|
||||
xmlns:j="urn:jboss:domain:1.2"
|
||||
xmlns:ds="urn:jboss:domain:datasources:1.0"
|
||||
xmlns:k="urn:jboss:domain:keycloak:1.1"
|
||||
xmlns:sec="urn:jboss:domain:security:1.1"
|
||||
version="2.0"
|
||||
exclude-result-prefixes="xalan j ds k sec">
|
||||
|
||||
<xsl:param name="config"/>
|
||||
|
||||
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" xalan:indent-amount="4" standalone="no"/>
|
||||
<xsl:strip-space elements="*"/>
|
||||
|
||||
<xsl:template match="//j:extensions">
|
||||
<xsl:copy>
|
||||
<xsl:apply-templates select="node()|@*"/>
|
||||
<extension module="org.keycloak.keycloak-adapter-subsystem"/>
|
||||
</xsl:copy>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="//j:profile">
|
||||
<xsl:copy>
|
||||
<xsl:apply-templates select="node()|@*"/>
|
||||
<subsystem xmlns="urn:jboss:domain:keycloak:1.1"/>
|
||||
</xsl:copy>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="//sec:security-domains">
|
||||
<xsl:copy>
|
||||
<xsl:apply-templates select="node()[name(.)='security-domain']"/>
|
||||
<security-domain name="keycloak">
|
||||
<authentication>
|
||||
<login-module code="org.keycloak.adapters.jboss.KeycloakLoginModule" flag="required"/>
|
||||
</authentication>
|
||||
</security-domain>
|
||||
<security-domain name="sp" cache-type="default">
|
||||
<authentication>
|
||||
<login-module code="org.picketlink.identity.federation.bindings.wildfly.SAML2LoginModule" flag="required"/>
|
||||
</authentication>
|
||||
</security-domain>
|
||||
</xsl:copy>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="@*|node()">
|
||||
<xsl:copy>
|
||||
<xsl:apply-templates select="@*|node()" />
|
||||
</xsl:copy>
|
||||
</xsl:template>
|
||||
|
||||
</xsl:stylesheet>
|
|
@ -12,17 +12,17 @@
|
|||
<name>Adapter Tests on EAP 6</name>
|
||||
|
||||
<properties>
|
||||
<app.server.eap6.home>${containers.home}</app.server.eap6.home>
|
||||
<app.server.eap6.home>${containers.home}/jboss-eap-6.4</app.server.eap6.home>
|
||||
<adapter.libs.eap6>${containers.home}/keycloak-eap6-adapter-dist</adapter.libs.eap6>
|
||||
<skip.configure.adapter.subsystem>false</skip.configure.adapter.subsystem>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<!-- <dependency>
|
||||
<!-- This dependency is for starting auth server based on wildfly (eap7)-->
|
||||
<dependency>
|
||||
<groupId>org.wildfly</groupId>
|
||||
<artifactId>wildfly-arquillian-container-managed</artifactId>
|
||||
</dependency>-->
|
||||
<!--TODO: this is for EAP6-->
|
||||
</dependency>
|
||||
<!-- This is for EAP6-->
|
||||
<dependency>
|
||||
<groupId>org.jboss.as</groupId>
|
||||
<artifactId>jboss-as-arquillian-container-managed</artifactId>
|
||||
|
@ -53,11 +53,10 @@
|
|||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.18.1</version>
|
||||
<configuration>
|
||||
<systemPropertyVariables>
|
||||
<app.server.eap6>true</app.server.eap6>
|
||||
<app.server.eap6.home>${app.server.eap6.home}/jboss-eap-6.4</app.server.eap6.home>
|
||||
<app.server.eap6.home>${app.server.eap6.home}</app.server.eap6.home>
|
||||
<adapter.libs.eap6>${adapter.libs.eap6}</adapter.libs.eap6>
|
||||
</systemPropertyVariables>
|
||||
</configuration>
|
||||
|
@ -97,46 +96,6 @@
|
|||
</build>
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>prod</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>prod</name>
|
||||
<value>true</value>
|
||||
</property>
|
||||
</activation>
|
||||
<properties>
|
||||
<skip.configure.adapter.subsystem>true</skip.configure.adapter.subsystem>
|
||||
</properties>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-dependency-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>unpack-eap6-with-adapter</id>
|
||||
<phase>generate-resources</phase>
|
||||
<goals>
|
||||
<goal>unpack</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<artifactItems>
|
||||
<artifactItem>
|
||||
<groupId>org.keycloak</groupId>
|
||||
<artifactId>rh-sso-eap6-adapter</artifactId>
|
||||
<version>${version.rh.soo}</version>
|
||||
<type>zip</type>
|
||||
<outputDirectory>${app.server.eap6.home}</outputDirectory>
|
||||
</artifactItem>
|
||||
</artifactItems>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>adapter-jdk</id>
|
||||
<activation>
|
||||
|
@ -190,36 +149,6 @@
|
|||
<properties>
|
||||
<adapter.libs.eap6>${app.server.eap6.home}</adapter.libs.eap6>
|
||||
</properties>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>xml-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>configure-adapter-subsystem</id>
|
||||
<phase>process-resources</phase>
|
||||
<goals>
|
||||
<goal>transform</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<skip>${skip.configure.adapter.subsystem}</skip>
|
||||
<transformationSets>
|
||||
<transformationSet>
|
||||
<dir>${app.server.eap6.home}/standalone/configuration</dir>
|
||||
<includes>
|
||||
<include>standalone.xml</include>
|
||||
</includes>
|
||||
<stylesheet>src/main/xslt/standalone.xsl</stylesheet>
|
||||
<outputDir>${app.server.eap6.home}/standalone/configuration</outputDir>
|
||||
</transformationSet>
|
||||
</transformationSets>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>ssl</id>
|
||||
|
|
|
@ -1,51 +0,0 @@
|
|||
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
||||
xmlns:xalan="http://xml.apache.org/xalan"
|
||||
xmlns:j="urn:jboss:domain:1.7"
|
||||
xmlns:ds="urn:jboss:domain:datasources:1.2"
|
||||
xmlns:k="urn:jboss:domain:keycloak:1.1"
|
||||
xmlns:sec="urn:jboss:domain:security:1.2"
|
||||
version="2.0"
|
||||
exclude-result-prefixes="xalan j ds k sec">
|
||||
|
||||
<xsl:param name="config"/>
|
||||
|
||||
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" xalan:indent-amount="4" standalone="no"/>
|
||||
<xsl:strip-space elements="*"/>
|
||||
|
||||
<xsl:template match="//j:extensions">
|
||||
<xsl:copy>
|
||||
<xsl:apply-templates select="node()|@*"/>
|
||||
<extension module="org.keycloak.keycloak-adapter-subsystem"/>
|
||||
</xsl:copy>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="//j:profile">
|
||||
<xsl:copy>
|
||||
<xsl:apply-templates select="node()|@*"/>
|
||||
<subsystem xmlns="urn:jboss:domain:keycloak:1.1"/>
|
||||
</xsl:copy>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="//sec:security-domains">
|
||||
<xsl:copy>
|
||||
<xsl:apply-templates select="node()[name(.)='security-domain']"/>
|
||||
<security-domain name="keycloak">
|
||||
<authentication>
|
||||
<login-module code="org.keycloak.adapters.jboss.KeycloakLoginModule" flag="required"/>
|
||||
</authentication>
|
||||
</security-domain>
|
||||
<security-domain name="sp" cache-type="default">
|
||||
<authentication>
|
||||
<login-module code="org.picketlink.identity.federation.bindings.wildfly.SAML2LoginModule" flag="required"/>
|
||||
</authentication>
|
||||
</security-domain>
|
||||
</xsl:copy>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="@*|node()">
|
||||
<xsl:copy>
|
||||
<xsl:apply-templates select="@*|node()" />
|
||||
</xsl:copy>
|
||||
</xsl:template>
|
||||
|
||||
</xsl:stylesheet>
|
|
@ -189,7 +189,6 @@
|
|||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-dependency-plugin</artifactId>
|
||||
<version>2.10</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>example-wars</id>
|
||||
|
@ -384,6 +383,13 @@
|
|||
<exclude.adapters>**/adapter/**/*Test.java</exclude.adapters>
|
||||
</properties>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>no-relative</id>
|
||||
<properties>
|
||||
<!-- Exclude relative adapters tests. -->
|
||||
<exclude.adapters>**/adapter/**/WildflyRelative*Test.java</exclude.adapters>
|
||||
</properties>
|
||||
</profile>
|
||||
|
||||
</profiles>
|
||||
|
||||
|
|
|
@ -100,35 +100,6 @@
|
|||
<properties>
|
||||
<adapter.libs.wildfly>${app.server.wildfly.home}</adapter.libs.wildfly>
|
||||
</properties>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>xml-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>configure-adapter-subsystem</id>
|
||||
<phase>process-resources</phase>
|
||||
<goals>
|
||||
<goal>transform</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<transformationSets>
|
||||
<transformationSet>
|
||||
<dir>${app.server.wildfly.home}/standalone/configuration</dir>
|
||||
<includes>
|
||||
<include>standalone.xml</include>
|
||||
</includes>
|
||||
<stylesheet>src/main/xslt/standalone.xsl</stylesheet>
|
||||
<outputDir>${app.server.wildfly.home}/standalone/configuration</outputDir>
|
||||
</transformationSet>
|
||||
</transformationSets>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>ssl</id>
|
||||
|
@ -166,7 +137,6 @@
|
|||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<version>2.7</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>copy-keystore</id>
|
||||
|
|
|
@ -79,7 +79,6 @@
|
|||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.18.1</version>
|
||||
<configuration>
|
||||
<systemPropertyVariables>
|
||||
<app.server.wildfly>true</app.server.wildfly>
|
||||
|
@ -102,35 +101,6 @@
|
|||
<properties>
|
||||
<adapter.libs.wildfly>${app.server.wildfly.home}</adapter.libs.wildfly>
|
||||
</properties>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>xml-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>configure-adapter-subsystem</id>
|
||||
<phase>process-resources</phase>
|
||||
<goals>
|
||||
<goal>transform</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<transformationSets>
|
||||
<transformationSet>
|
||||
<dir>${app.server.wildfly.home}/standalone/configuration</dir>
|
||||
<includes>
|
||||
<include>standalone.xml</include>
|
||||
</includes>
|
||||
<stylesheet>src/main/xslt/standalone.xsl</stylesheet>
|
||||
<outputDir>${app.server.wildfly.home}/standalone/configuration</outputDir>
|
||||
</transformationSet>
|
||||
</transformationSets>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
</profiles>
|
||||
</project>
|
||||
|
|
|
@ -1,51 +0,0 @@
|
|||
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
||||
xmlns:xalan="http://xml.apache.org/xalan"
|
||||
xmlns:j="urn:jboss:domain:2.2"
|
||||
xmlns:ds="urn:jboss:domain:datasources:2.0"
|
||||
xmlns:k="urn:jboss:domain:keycloak:1.1"
|
||||
xmlns:sec="urn:jboss:domain:security:1.2"
|
||||
version="2.0"
|
||||
exclude-result-prefixes="xalan j ds k sec">
|
||||
|
||||
<xsl:param name="config"/>
|
||||
|
||||
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" xalan:indent-amount="4" standalone="no"/>
|
||||
<xsl:strip-space elements="*"/>
|
||||
|
||||
<xsl:template match="//j:extensions">
|
||||
<xsl:copy>
|
||||
<xsl:apply-templates select="node()|@*"/>
|
||||
<extension module="org.keycloak.keycloak-adapter-subsystem"/>
|
||||
</xsl:copy>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="//j:profile">
|
||||
<xsl:copy>
|
||||
<xsl:apply-templates select="node()|@*"/>
|
||||
<subsystem xmlns="urn:jboss:domain:keycloak:1.1"/>
|
||||
</xsl:copy>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="//sec:security-domains">
|
||||
<xsl:copy>
|
||||
<xsl:apply-templates select="node()[name(.)='security-domain']"/>
|
||||
<security-domain name="keycloak">
|
||||
<authentication>
|
||||
<login-module code="org.keycloak.adapters.jboss.KeycloakLoginModule" flag="required"/>
|
||||
</authentication>
|
||||
</security-domain>
|
||||
<security-domain name="sp" cache-type="default">
|
||||
<authentication>
|
||||
<login-module code="org.picketlink.identity.federation.bindings.wildfly.SAML2LoginModule" flag="required"/>
|
||||
</authentication>
|
||||
</security-domain>
|
||||
</xsl:copy>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="@*|node()">
|
||||
<xsl:copy>
|
||||
<xsl:apply-templates select="@*|node()" />
|
||||
</xsl:copy>
|
||||
</xsl:template>
|
||||
|
||||
</xsl:stylesheet>
|
|
@ -15,6 +15,7 @@
|
|||
<exclude.console>-</exclude.console>
|
||||
<exclude.account>-</exclude.account>
|
||||
<exclude.client>-</exclude.client>
|
||||
<exclude.migration>-</exclude.migration>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
|
@ -50,6 +51,7 @@
|
|||
<exclude>${exclude.console}</exclude>
|
||||
<exclude>${exclude.account}</exclude>
|
||||
<exclude>${exclude.client}</exclude>
|
||||
<exclude>${exclude.migration}</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
@ -77,6 +79,7 @@
|
|||
<exclude.console>**/console/**/*Test.java</exclude.console>
|
||||
<exclude.account>**/account/**/*Test.java</exclude.account>
|
||||
<exclude.client>**/client/**/*Test.java</exclude.client>
|
||||
<exclude.migration>**/migration/**/*Test.java</exclude.migration>
|
||||
</properties>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
|
|
@ -1,10 +1,14 @@
|
|||
package org.keycloak.testsuite.arquillian;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.LinkedList;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.jboss.arquillian.container.spi.Container;
|
||||
import org.jboss.arquillian.container.spi.ContainerRegistry;
|
||||
|
@ -19,6 +23,7 @@ import org.jboss.arquillian.core.api.annotation.Observes;
|
|||
import org.jboss.arquillian.test.spi.annotation.ClassScoped;
|
||||
import org.jboss.arquillian.test.spi.annotation.SuiteScoped;
|
||||
import org.jboss.arquillian.container.spi.event.container.AfterStart;
|
||||
import org.jboss.arquillian.container.spi.event.container.BeforeStart;
|
||||
import org.jboss.arquillian.test.spi.event.suite.BeforeClass;
|
||||
import org.jboss.arquillian.test.spi.event.suite.BeforeSuite;
|
||||
import org.jboss.logging.Logger;
|
||||
|
@ -83,7 +88,7 @@ public class ContainersTestEnricher {
|
|||
}
|
||||
init = true;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* non-javadoc
|
||||
*
|
||||
|
@ -103,43 +108,92 @@ public class ContainersTestEnricher {
|
|||
* After start container. Server logs are checked (in case jboss based container).
|
||||
* In case of migration scenario: previous container is stopped.
|
||||
*/
|
||||
public void afterStart(@Observes AfterStart event) throws IOException {
|
||||
if (System.getProperty("check.server.log", "true").equals("true")) {
|
||||
checkServerLog();
|
||||
public void afterStart(@Observes AfterStart event) throws IOException, InterruptedException {
|
||||
Container container = containers.pollFirst();
|
||||
String jbossHomePath = null;
|
||||
|
||||
if (isJBossBased(container)) {
|
||||
jbossHomePath = container.getContainerConfiguration().getContainerProperties().get("jbossHome");
|
||||
log.debug("jbossHome: " + jbossHomePath + "\n");
|
||||
|
||||
if (System.getProperty("check.server.log", "true").equals("true")) {
|
||||
checkServerLog(jbossHomePath);
|
||||
}
|
||||
}
|
||||
|
||||
if (migrationTests && !alreadyStopped) {
|
||||
log.info("\n\n### Stopping keycloak " + System.getProperty("version", "- previous") + " ###\n");
|
||||
stopSuiteContainers.fire(new StopSuiteContainers());
|
||||
log.info("\n\n### Starting keycloak current version ###\n");
|
||||
alreadyStopped = true;
|
||||
}
|
||||
alreadyStopped = true;
|
||||
|
||||
if (isJBossBased(container) && container.getName().startsWith("app-server")) {
|
||||
log.info("Installing adapter to app server via cli script");
|
||||
String jbossCliPath = jbossHomePath + "/bin/jboss-cli.sh";
|
||||
String scriptPathArg = "--file=" + jbossHomePath + "/bin/adapter-install.cli";
|
||||
String managementPort = container.getContainerConfiguration().getContainerProperties().get("managementPort");
|
||||
String controllerArg = "--controller=localhost:" + managementPort;
|
||||
|
||||
execCommand(new String[]{"/bin/sh", jbossCliPath, "--connect", scriptPathArg, controllerArg});
|
||||
log.debug("Restarting container");
|
||||
execCommand(new String[]{"/bin/sh", jbossCliPath, "--connect", "--command=:reload", controllerArg});
|
||||
}
|
||||
}
|
||||
|
||||
private void execCommand(String... command) throws IOException, InterruptedException {
|
||||
Process process = Runtime.getRuntime().exec(command);
|
||||
|
||||
printOutput(process.getInputStream());
|
||||
|
||||
if (process.waitFor(10, TimeUnit.SECONDS)) {
|
||||
if (process.exitValue() != 0) {
|
||||
log.error("Std Error:");
|
||||
printOutput(process.getErrorStream());
|
||||
throw new RuntimeException("Adapter installation failed.");
|
||||
}
|
||||
} else {
|
||||
process.destroy();
|
||||
throw new RuntimeException("Timeout after 10 seconds.");
|
||||
}
|
||||
}
|
||||
|
||||
private void printOutput(InputStream is) throws IOException {
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
|
||||
StringBuilder builder = new StringBuilder();
|
||||
while (reader.ready()) {
|
||||
builder.append(reader.readLine());
|
||||
}
|
||||
log.info(builder);
|
||||
}
|
||||
|
||||
private boolean isJBossBased(Container container) {
|
||||
if (container == null) {
|
||||
return false;
|
||||
}
|
||||
return container.getName().matches("a.*-server-wildfly")
|
||||
|| container.getName().matches("a.*-server-eap.")
|
||||
|| container.getName().equals("app-server-as7");
|
||||
}
|
||||
|
||||
/*
|
||||
* non-javadoc
|
||||
*
|
||||
* check server logs (in case jboss based container) whether there are no ERRORs or SEVEREs
|
||||
* check server logs whether there are no ERRORs or SEVEREs
|
||||
*/
|
||||
private void checkServerLog() throws IOException {
|
||||
Container container = containers.removeFirst();
|
||||
if (container.getName().equals("auth-server-wildfly")
|
||||
|| container.getName().matches("auth-server-eap.")) {
|
||||
String jbossHomePath = container.getContainerConfiguration().getContainerProperties().get("jbossHome");
|
||||
log.debug("jbossHome: " + jbossHomePath + "\n");
|
||||
private void checkServerLog(String jbossHomePath) throws IOException {
|
||||
File serverLog = new File(jbossHomePath + "/standalone/log/server.log");
|
||||
String serverLogContent = FileUtils.readFileToString(serverLog);
|
||||
|
||||
String serverLogContent = FileUtils.readFileToString(new File(jbossHomePath + "/standalone/log/server.log"));
|
||||
boolean containsError
|
||||
= serverLogContent.contains("ERROR")
|
||||
|| serverLogContent.contains("SEVERE")
|
||||
|| serverLogContent.contains("Exception ");
|
||||
//There is expected string "Exception" in server log: Adding provider
|
||||
//singleton org.keycloak.services.resources.ModelExceptionMapper
|
||||
|
||||
boolean containsError
|
||||
= serverLogContent.contains("ERROR")
|
||||
|| serverLogContent.contains("SEVERE")
|
||||
|| serverLogContent.contains("Exception ");
|
||||
//There is expected string "Exception" in server log: Adding provider
|
||||
//singleton org.keycloak.services.resources.ModelExceptionMapper
|
||||
|
||||
if (containsError) {
|
||||
throw new RuntimeException(container.getName() + ": Server log contains ERROR.");
|
||||
}
|
||||
if (containsError) {
|
||||
throw new RuntimeException(serverLog.getPath() + " contains ERROR.");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -154,9 +208,7 @@ public class ContainersTestEnricher {
|
|||
appServerQualifier = getAppServerQualifier(testClass);
|
||||
|
||||
if (!controller.isStarted(appServerQualifier)) {
|
||||
log.info("\nSTARTING APP SERVER: " + appServerQualifier + "\n");
|
||||
controller.start(appServerQualifier);
|
||||
log.info("");
|
||||
}
|
||||
|
||||
initializeTestContext(testClass);
|
||||
|
|
|
@ -79,14 +79,16 @@ public abstract class AbstractAdapterTest extends AbstractAuthTest {
|
|||
}
|
||||
|
||||
protected void modifyClientUrls(RealmRepresentation realm, String regex, String replacement) {
|
||||
for (ClientRepresentation client : realm.getClients()) {
|
||||
String baseUrl = client.getBaseUrl();
|
||||
if (baseUrl != null) {
|
||||
client.setBaseUrl(baseUrl.replaceAll(regex, replacement));
|
||||
}
|
||||
String adminUrl = client.getAdminUrl();
|
||||
if (adminUrl != null) {
|
||||
client.setAdminUrl(adminUrl.replaceAll(regex, replacement));
|
||||
if (realm.getClients() != null) {
|
||||
for (ClientRepresentation client : realm.getClients()) {
|
||||
String baseUrl = client.getBaseUrl();
|
||||
if (baseUrl != null) {
|
||||
client.setBaseUrl(baseUrl.replaceAll(regex, replacement));
|
||||
}
|
||||
String adminUrl = client.getAdminUrl();
|
||||
if (adminUrl != null) {
|
||||
client.setAdminUrl(adminUrl.replaceAll(regex, replacement));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
{ "type" : "password",
|
||||
"value" : "password" }
|
||||
],
|
||||
"realmRoles": [ "user", "admin" ],
|
||||
"realmRoles": [ "user" ],
|
||||
"applicationRoles": {
|
||||
"account": [ "manage-account" ]
|
||||
}
|
||||
|
@ -34,12 +34,36 @@
|
|||
"lastName": "Posolda",
|
||||
"credentials" : [
|
||||
{ "type" : "password",
|
||||
"value" : "password" }
|
||||
"value" : "password" }
|
||||
],
|
||||
"realmRoles": [ "user" ],
|
||||
"applicationRoles": {
|
||||
"account": [ "manage-account" ]
|
||||
}
|
||||
},
|
||||
{
|
||||
"username" : "topGroupUser",
|
||||
"enabled": true,
|
||||
"email" : "top@redhat.com",
|
||||
"credentials" : [
|
||||
{ "type" : "password",
|
||||
"value" : "password" }
|
||||
],
|
||||
"groups": [
|
||||
"/top"
|
||||
]
|
||||
},
|
||||
{
|
||||
"username" : "level2GroupUser",
|
||||
"enabled": true,
|
||||
"email" : "level2@redhat.com",
|
||||
"credentials" : [
|
||||
{ "type" : "password",
|
||||
"value" : "password" }
|
||||
],
|
||||
"groups": [
|
||||
"/top/level2"
|
||||
]
|
||||
}
|
||||
],
|
||||
"roles" : {
|
||||
|
@ -54,6 +78,29 @@
|
|||
}
|
||||
]
|
||||
},
|
||||
"groups" : [
|
||||
{
|
||||
"name": "top",
|
||||
"attributes": {
|
||||
"topAttribute": ["true"]
|
||||
|
||||
},
|
||||
"realmRoles": ["user"],
|
||||
"clientRoles": {
|
||||
"account": ["manage-account"]
|
||||
},
|
||||
"subGroups": [
|
||||
{
|
||||
"name": "level2",
|
||||
"realmRoles": ["admin"],
|
||||
"attributes": {
|
||||
"level2Attribute": ["true"]
|
||||
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"scopeMappings": [
|
||||
{
|
||||
"client": "third-party",
|
||||
|
@ -69,38 +116,39 @@
|
|||
}
|
||||
|
||||
],
|
||||
"clients": [
|
||||
"applications": [
|
||||
{
|
||||
"clientId": "customer-portal",
|
||||
"name": "customer-portal",
|
||||
"enabled": true,
|
||||
"adminUrl": "/customer-portal",
|
||||
"baseUrl": "/customer-portal",
|
||||
"directAccessGrantsEnabled": true,
|
||||
"adminUrl": "http://localhost:8081/customer-portal",
|
||||
"baseUrl": "http://localhost:8081/customer-portal",
|
||||
"redirectUris": [
|
||||
"/customer-portal/*"
|
||||
"http://localhost:8081/customer-portal/*"
|
||||
],
|
||||
"secret": "password"
|
||||
},
|
||||
{
|
||||
"clientId": "customer-cookie-portal",
|
||||
"name": "customer-cookie-portal",
|
||||
"enabled": true,
|
||||
"baseUrl": "/customer-cookie-portal",
|
||||
"baseUrl": "http://localhost:8081/customer-cookie-portal",
|
||||
"redirectUris": [
|
||||
"/customer-cookie-portal/*"
|
||||
"http://localhost:8081/customer-cookie-portal/*"
|
||||
],
|
||||
"secret": "password"
|
||||
},
|
||||
{
|
||||
"clientId": "customer-portal-js",
|
||||
"name": "customer-portal-js",
|
||||
"enabled": true,
|
||||
"publicClient": true,
|
||||
"adminUrl": "/customer-portal-js",
|
||||
"baseUrl": "/customer-portal-js",
|
||||
"adminUrl": "http://localhost:8081/customer-portal-js",
|
||||
"baseUrl": "http://localhost:8081/customer-portal-js",
|
||||
"redirectUris": [
|
||||
"/customer-portal-js/*"
|
||||
"http://localhost:8080/customer-portal-js/*"
|
||||
]
|
||||
},
|
||||
{
|
||||
"clientId": "customer-portal-cli",
|
||||
"name": "customer-portal-cli",
|
||||
"enabled": true,
|
||||
"publicClient": true,
|
||||
"redirectUris": [
|
||||
|
@ -109,51 +157,56 @@
|
|||
]
|
||||
},
|
||||
{
|
||||
"clientId": "product-portal",
|
||||
"name": "product-portal",
|
||||
"enabled": true,
|
||||
"adminUrl": "/product-portal",
|
||||
"baseUrl": "/product-portal",
|
||||
"adminUrl": "http://localhost:8081/product-portal",
|
||||
"baseUrl": "http://localhost:8081/product-portal",
|
||||
"redirectUris": [
|
||||
"/product-portal/*"
|
||||
"http://localhost:8081/product-portal/*"
|
||||
],
|
||||
"secret": "password"
|
||||
},
|
||||
{
|
||||
"clientId": "secure-portal",
|
||||
"name": "secure-portal",
|
||||
"enabled": true,
|
||||
"adminUrl": "/secure-portal",
|
||||
"baseUrl": "/secure-portal",
|
||||
"adminUrl": "http://localhost:8081/secure-portal",
|
||||
"baseUrl": "http://localhost:8081/secure-portal",
|
||||
"clientAuthenticatorType": "client-jwt",
|
||||
"redirectUris": [
|
||||
"/secure-portal/*"
|
||||
"http://localhost:8081/secure-portal/*"
|
||||
],
|
||||
"attributes": {
|
||||
"jwt.credential.certificate": "MIICnTCCAYUCBgFPPLDaTzANBgkqhkiG9w0BAQsFADASMRAwDgYDVQQDDAdjbGllbnQxMB4XDTE1MDgxNzE3MjI0N1oXDTI1MDgxNzE3MjQyN1owEjEQMA4GA1UEAwwHY2xpZW50MTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAIUjjgv+V3s96O+Za9002Lp/trtGuHBeaeVL9dFKMKzO2MPqdRmHB4PqNlDdd28Rwf5Xn6iWdFpyUKOnI/yXDLhdcuFpR0sMNK/C9Lt+hSpPFLuzDqgtPgDotlMxiHIWDOZ7g9/gPYNXbNvjv8nSiyqoguoCQiiafW90bPHsiVLdP7ZIUwCcfi1qQm7FhxRJ1NiW5dvUkuCnnWEf0XR+Wzc5eC9EgB0taLFiPsSEIlWMm5xlahYyXkPdNOqZjiRnrTWm5Y4uk8ZcsD/KbPTf/7t7cQXipVaswgjdYi1kK2/zRwOhg1QwWFX/qmvdd+fLxV0R6VqRDhn7Qep2cxwMxLsCAwEAATANBgkqhkiG9w0BAQsFAAOCAQEAKE6OA46sf20bz8LZPoiNsqRwBUDkaMGXfnob7s/hJZIIwDEx0IAQ3uKsG7q9wb+aA6s+v7S340zb2k3IxuhFaHaZpAd4CyR5cn1FHylbzoZ7rI/3ASqHDqpljdJaFqPH+m7nZWtyDvtZf+gkZ8OjsndwsSBK1d/jMZPp29qYbl1+XfO7RCp/jDqro/R3saYFaIFiEZPeKn1hUJn6BO48vxH1xspSu9FmlvDOEAOz4AuM58z4zRMP49GcFdCWr1wkonJUHaSptJaQwmBwLFUkCbE5I1ixGMb7mjEud6Y5jhfzJiZMo2U8RfcjNbrN0diZl3jB6LQIwESnhYSghaTjNQ=="
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "session-portal",
|
||||
"enabled": true,
|
||||
"adminUrl": "http://localhost:8081/session-portal",
|
||||
"baseUrl": "http://localhost:8081/session-portal",
|
||||
"redirectUris": [
|
||||
"http://localhost:8081/session-portal/*"
|
||||
],
|
||||
"secret": "password"
|
||||
},
|
||||
{
|
||||
"clientId": "session-portal",
|
||||
"name": "input-portal",
|
||||
"enabled": true,
|
||||
"adminUrl": "/session-portal",
|
||||
"baseUrl": "/session-portal",
|
||||
"adminUrl": "http://localhost:8081/input-portal",
|
||||
"baseUrl": "http://localhost:8081/input-portal",
|
||||
"redirectUris": [
|
||||
"/session-portal/*"
|
||||
"http://localhost:8081/input-portal/*"
|
||||
],
|
||||
"secret": "password"
|
||||
},
|
||||
}
|
||||
],
|
||||
"oauthClients": [
|
||||
{
|
||||
"clientId": "input-portal",
|
||||
"enabled": true,
|
||||
"adminUrl": "/input-portal",
|
||||
"baseUrl": "/input-portal",
|
||||
"redirectUris": [
|
||||
"/input-portal/*"
|
||||
],
|
||||
"secret": "password"
|
||||
},
|
||||
{
|
||||
"clientId": "third-party",
|
||||
"name": "third-party",
|
||||
"enabled": true,
|
||||
"redirectUris": [
|
||||
"/oauth-client/*",
|
||||
"/oauth-client-cdi/*"
|
||||
"http://localhost:8081/oauth-client/*",
|
||||
"http://localhost:8081/oauth-client-cdi/*"
|
||||
],
|
||||
"secret": "password"
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue