mirror of
https://github.com/bmlong137/alfresco-keycloak.git
synced 2025-09-10 14:11:09 +00:00
Rework project's Docker test setup
- use Docker Compose instead of fabric8io - don't use local paths to support running with remote Docker contexts - use latest Keycloak Docker image and make sure test realm works out-of-the-box - add flag to avoid failing on missing properties during JSON deserialisation (newer Keycloak versions offer more properties in IDM API response payloads)
This commit is contained in:
@@ -27,11 +27,6 @@
|
||||
<artifactId>de.acosix.alfresco.keycloak.repo</artifactId>
|
||||
<name>Acosix Alfresco Keycloak - Repository Module</name>
|
||||
|
||||
<properties>
|
||||
<docker.tests.keycloakPort>8380</docker.tests.keycloakPort>
|
||||
<docker.tests.skipSearchImage>false</docker.tests.skipSearchImage>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
@@ -74,7 +69,7 @@
|
||||
<!-- use default from Alfresco Repository -->
|
||||
<exclusion>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
<artifactId>*</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
@@ -103,7 +98,7 @@
|
||||
<!-- use default from Alfresco Repository -->
|
||||
<exclusion>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpcomponents-client</artifactId>
|
||||
<artifactId>*</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
@@ -136,98 +131,11 @@
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>de.acosix.alfresco.utility</groupId>
|
||||
<artifactId>de.acosix.alfresco.utility.core.repo</artifactId>
|
||||
<classifier>installable</classifier>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>de.acosix.alfresco.utility</groupId>
|
||||
<artifactId>de.acosix.alfresco.utility.repo</artifactId>
|
||||
<classifier>installable</classifier>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.orderofthebee.support-tools</groupId>
|
||||
<artifactId>support-tools-repo</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.activemq</groupId>
|
||||
<artifactId>activemq-broker</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
|
||||
<!-- some image customisations -->
|
||||
<!-- Maven + docker-maven-plugin result in somewhat weird inheritance handling -->
|
||||
<!-- (relying on positional order of images for overrides) -->
|
||||
<plugin>
|
||||
<groupId>io.fabric8</groupId>
|
||||
<artifactId>docker-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<images>
|
||||
<image>
|
||||
<!-- no change to postgres image (first image in parent POM) -->
|
||||
</image>
|
||||
<image>
|
||||
<!-- customise repository image (second image in parent POM) -->
|
||||
<run>
|
||||
<!-- add log directory mount to just the contentstore -->
|
||||
<!-- (cannot be done in parent POM due to hard requirement on specific project structure -->
|
||||
<!-- for tests to easily check contentstore files, we also mount alf_data locally, not in a volume -->
|
||||
<volumes>
|
||||
<bind>
|
||||
<volume>${moduleId}-repository-test-contentstore:/usr/local/tomcat/alf_data</volume>
|
||||
<volume>${project.build.directory}/docker/repository-logs:/usr/local/tomcat/logs</volume>
|
||||
</bind>
|
||||
</volumes>
|
||||
<dependsOn>
|
||||
<container>postgres</container>
|
||||
<container>keycloak</container>
|
||||
</dependsOn>
|
||||
</run>
|
||||
</image>
|
||||
<image>
|
||||
<!-- no change to Share image (we don't use it) -->
|
||||
</image>
|
||||
<image>
|
||||
<!-- no change to Search image -->
|
||||
</image>
|
||||
<image>
|
||||
<name>jboss/keycloak:${keycloak.version}</name>
|
||||
<alias>keycloak</alias>
|
||||
<run>
|
||||
<hostname>keycloak</hostname>
|
||||
<env>
|
||||
<KEYCLOAK_USER>admin</KEYCLOAK_USER>
|
||||
<KEYCLOAK_PASSWORD>admin</KEYCLOAK_PASSWORD>
|
||||
<KEYCLOAK_IMPORT>/tmp/test-realm.json</KEYCLOAK_IMPORT>
|
||||
<DB_VENDOR>h2</DB_VENDOR>
|
||||
</env>
|
||||
<ports>
|
||||
<port>${docker.tests.keycloakPort}:8080</port>
|
||||
</ports>
|
||||
<network>
|
||||
<mode>custom</mode>
|
||||
<name>${moduleId}-test</name>
|
||||
<alias>keycloak</alias>
|
||||
</network>
|
||||
<volumes>
|
||||
<bind>
|
||||
<volume>${project.build.directory}/docker/test-realm.json:/tmp/test-realm.json</volume>
|
||||
</bind>
|
||||
</volumes>
|
||||
</run>
|
||||
</image>
|
||||
</images>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
@@ -320,11 +228,6 @@
|
||||
|
||||
<plugins>
|
||||
|
||||
<plugin>
|
||||
<groupId>io.fabric8</groupId>
|
||||
<artifactId>docker-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
</plugin>
|
||||
|
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package de.acosix.alfresco.keycloak.repo.client;
|
||||
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.MappingIterator;
|
||||
|
||||
@@ -53,6 +54,12 @@ public abstract class AbstractIDMClientImpl implements InitializingBean
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(AbstractIDMClientImpl.class);
|
||||
|
||||
static
|
||||
{
|
||||
// newer Keycloak versions may introduce properties the libraries included in this project do not support
|
||||
JsonSerialization.mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||
}
|
||||
|
||||
protected KeycloakDeployment deployment;
|
||||
|
||||
protected AccessTokenService accessTokenService;
|
||||
|
@@ -288,7 +288,7 @@ public class KeycloakAdapterConfigBeanFactory implements FactoryBean<ExtendedAda
|
||||
{
|
||||
throw new IllegalStateException("Value " + trimmedValue + " has more than one character");
|
||||
}
|
||||
effectiveValue = new Character(trimmedValue.charAt(0));
|
||||
effectiveValue = Character.valueOf(trimmedValue.charAt(0));
|
||||
}
|
||||
else if (String.class.equals(valueType))
|
||||
{
|
||||
|
@@ -1,12 +0,0 @@
|
||||
FROM ${docker.tests.repositoryBaseImage}
|
||||
COPY maven ${docker.tests.repositoryWebappPath}
|
||||
|
||||
${docker.tests.repositoryImageBuilder.preRun}
|
||||
|
||||
# merge additions to alfresco-global.properties
|
||||
RUN echo "" >> ${docker.tests.repositoryWebappPath}/../../shared/classes/alfresco-global.properties \
|
||||
&& echo "#MergeGlobalProperties" >> ${docker.tests.repositoryWebappPath}/../../shared/classes/alfresco-global.properties \
|
||||
&& sed -i '/#MergeGlobalProperties/r ${docker.tests.repositoryWebappPath}/WEB-INF/classes/alfresco/extension/alfresco-global.addition.properties' ${docker.tests.repositoryWebappPath}/../../shared/classes/alfresco-global.properties \
|
||||
&& sed -i 's/<secure>true<\/secure>/<secure>false<\/secure>/' $CATALINA_HOME/conf/web.xml
|
||||
|
||||
${docker.tests.repositoryImageBuilder.postRun}
|
@@ -1,35 +0,0 @@
|
||||
#
|
||||
# Copyright 2019 - 2021 Acosix GmbH
|
||||
#
|
||||
# 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.
|
||||
|
||||
# note: this file is not named alfresco-global.properties to not override the default file in the image
|
||||
# instead it relies on Dockerfile post-processing to merge with the default file
|
||||
|
||||
authentication.chain=keycloak1:keycloak,alfrescoNtlm1:alfrescoNtlm
|
||||
|
||||
keycloak.adapter.auth-server-url=http://localhost:${docker.tests.keycloakPort}/auth
|
||||
keycloak.adapter.realm=test
|
||||
keycloak.adapter.resource=alfresco
|
||||
keycloak.adapter.credentials.provider=secret
|
||||
keycloak.adapter.credentials.secret=6f70a28f-98cd-41ca-8f2f-368a8797d708
|
||||
|
||||
# localhost in auth-server-url won't work for direct access in a Docker deployment
|
||||
keycloak.adapter.proxy-url=http://keycloak:8080
|
||||
|
||||
keycloak.roles.requiredClientScopes=alfresco-role-service
|
||||
|
||||
keycloak.synchronization.userFilter.containedInGroup.property.groupPaths=/Test A
|
||||
keycloak.synchronization.groupFilter.containedInGroup.property.groupPaths=/Test A
|
||||
|
||||
keycloak.synchronization.requiredClientScopes=alfresco-authority-sync
|
@@ -1,25 +0,0 @@
|
||||
#
|
||||
# Copyright 2019 - 2021 Acosix GmbH
|
||||
#
|
||||
# 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.
|
||||
|
||||
log4j.rootLogger=error, File
|
||||
|
||||
log4j.appender.File=org.apache.log4j.DailyRollingFileAppender
|
||||
log4j.appender.File.File=\${catalina.base}/logs/alfresco.log
|
||||
log4j.appender.File.Append=true
|
||||
log4j.appender.File.DatePattern='.'yyyy-MM-dd
|
||||
log4j.appender.File.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.File.layout.ConversionPattern=%d{ISO8601} %-5p [%c] [%t] %m%n
|
||||
|
||||
log4j.logger.${project.artifactId}=DEBUG
|
@@ -1,101 +0,0 @@
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<!--
|
||||
Copyright 2019 - 2021 Acosix GmbH
|
||||
|
||||
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.
|
||||
-->
|
||||
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3 http://maven.apache.org/xsd/assembly-1.1.3.xsd">
|
||||
<id>repository-it-docker</id>
|
||||
<formats>
|
||||
<format>dir</format>
|
||||
</formats>
|
||||
<includeBaseDirectory>false</includeBaseDirectory>
|
||||
<fileSets>
|
||||
<fileSet>
|
||||
<directory>${project.build.directory}</directory>
|
||||
<outputDirectory>WEB-INF/lib</outputDirectory>
|
||||
<includes>
|
||||
<include>${project.artifactId}-${project.version}-installable.jar</include>
|
||||
</includes>
|
||||
</fileSet>
|
||||
<fileSet>
|
||||
<directory>${project.basedir}/src/test/resources</directory>
|
||||
<outputDirectory>WEB-INF/classes</outputDirectory>
|
||||
<includes>
|
||||
<include>*.properties</include>
|
||||
<include>**/*.properties</include>
|
||||
</includes>
|
||||
<filtered>true</filtered>
|
||||
<lineEnding>lf</lineEnding>
|
||||
</fileSet>
|
||||
<fileSet>
|
||||
<directory>${project.basedir}/src/test/docker/alfresco</directory>
|
||||
<outputDirectory>WEB-INF/classes/alfresco</outputDirectory>
|
||||
<includes>
|
||||
<include>*</include>
|
||||
<include>**/*</include>
|
||||
</includes>
|
||||
<excludes>
|
||||
<exclude>*.js</exclude>
|
||||
<exclude>**/*.js</exclude>
|
||||
<exclude>*.ftl</exclude>
|
||||
<exclude>**/*.ftl</exclude>
|
||||
<exclude>*.keystore</exclude>
|
||||
<exclude>**/*.keystore</exclude>
|
||||
</excludes>
|
||||
<filtered>true</filtered>
|
||||
<lineEnding>lf</lineEnding>
|
||||
</fileSet>
|
||||
<fileSet>
|
||||
<directory>${project.basedir}/src/test/docker/alfresco</directory>
|
||||
<outputDirectory>WEB-INF/classes/alfresco</outputDirectory>
|
||||
<includes>
|
||||
<include>*.js</include>
|
||||
<include>**/*.js</include>
|
||||
<include>*.ftl</include>
|
||||
<include>**/*.ftl</include>
|
||||
<include>*.keystore</include>
|
||||
<include>**/*.keystore</include>
|
||||
</includes>
|
||||
</fileSet>
|
||||
</fileSets>
|
||||
<dependencySets>
|
||||
<dependencySet>
|
||||
<outputDirectory>WEB-INF/lib</outputDirectory>
|
||||
<includes>
|
||||
<include>${project.groupId}:${project.artifactId}.deps:*</include>
|
||||
</includes>
|
||||
<scope>compile</scope>
|
||||
</dependencySet>
|
||||
<dependencySet>
|
||||
<outputDirectory>WEB-INF/lib</outputDirectory>
|
||||
<includes>
|
||||
<!-- TODO: Report bug against Maven PatternIncludesArtifactFilter#matchAgainst for incorrect return false-->
|
||||
<!-- when patterns with 5 tokens are listed in includes (like the installable JAR of Acosix Utility Core Repo), they may prevent evaluation of any additional patterns -->
|
||||
<!-- this cost me half a day to track down when the following three patterns were sorted last -->
|
||||
<include>org.orderofthebee.support-tools:*</include>
|
||||
<include>com.cronutils:*</include>
|
||||
<include>net.time4j:*</include>
|
||||
<include>org.apache.activemq:activemq-broker</include>
|
||||
<include>de.acosix.alfresco.utility:de.acosix.alfresco.utility.common:*</include>
|
||||
<include>de.acosix.alfresco.utility:de.acosix.alfresco.utility.core.repo.quartz1:*</include>
|
||||
<include>de.acosix.alfresco.utility:de.acosix.alfresco.utility.core.repo.quartz2:*</include>
|
||||
<include>de.acosix.alfresco.utility:de.acosix.alfresco.utility.core.repo:jar:installable:*</include>
|
||||
<include>de.acosix.alfresco.utility:de.acosix.alfresco.utility.repo:jar:installable:*</include>
|
||||
</includes>
|
||||
<scope>test</scope>
|
||||
</dependencySet>
|
||||
</dependencySets>
|
||||
</assembly>
|
@@ -1 +0,0 @@
|
||||
# only exists to ensure Maven creates path in project ./target
|
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user