Run SAML adapter tests with EAP 8

Closes #24168

Signed-off-by: Martin Bartoš <mabartos@redhat.com>
This commit is contained in:
Martin Bartoš 2023-11-14 18:02:57 +01:00 committed by Marek Posolda
parent c03c2e953a
commit e71d850a03
32 changed files with 906 additions and 42 deletions

View file

@ -41,7 +41,7 @@
<cache.server.java.home>${java.home}</cache.server.java.home>
<!--component versions-->
<arquillian-core.version>1.7.0.Alpha14</arquillian-core.version>
<arquillian-core.version>1.7.1.Final</arquillian-core.version>
<!--the version of shrinkwrap_resolver should align with the version in arquillian-bom-->
<shrinkwrap-resolver.version>3.1.4</shrinkwrap-resolver.version>
<selenium.version>3.14.0</selenium.version>

View file

@ -0,0 +1,168 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>org.keycloak.testsuite</groupId>
<artifactId>integration-arquillian-servers-app-server-jboss</artifactId>
<version>999.0.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>integration-arquillian-servers-app-server-jboss-galleon</artifactId>
<packaging>jar</packaging>
<name>App Server - JBoss Galleon (EAP8)</name>
<properties>
<app.server.jboss>eap8</app.server.jboss>
<eap.version>${eap8.version}</eap.version>
<app.server.jboss.groupId>org.jboss.eap</app.server.jboss.groupId>
<app.server.jboss.artifactId>wildfly-ee-dist</app.server.jboss.artifactId>
<app.server.jboss.version>${eap.version}</app.server.jboss.version>
<app.server.jboss.unpacked.folder.path>${containers.home}/jboss-distribution
</app.server.jboss.unpacked.folder.path>
<app.server.jboss.unpacked.folder.name>jboss-eap-8.0</app.server.jboss.unpacked.folder.name>
<app.server.saml.adapter.artifactId>keycloak-saml-adapter-galleon-pack</app.server.saml.adapter.artifactId>
<skip.apply.offline.cli>true</skip.apply.offline.cli>
<skip.configure.clustered.scenario>true</skip.configure.clustered.scenario>
<skip.elytron.adapter.installation>true</skip.elytron.adapter.installation>
<skip.oidc.adapter.installation>true</skip.oidc.adapter.installation>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.keycloak.testsuite</groupId>
<artifactId>integration-arquillian-servers-app-server-spi</artifactId>
<version>${project.version}</version>
<exclusions>
<exclusion>
<groupId>org.jboss.arquillian.protocol</groupId>
<artifactId>arquillian-protocol-servlet</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.protocol</groupId>
<artifactId>arquillian-protocol-servlet-jakarta</artifactId>
</dependency>
<dependency>
<groupId>org.wildfly.arquillian</groupId>
<artifactId>wildfly-arquillian-container-managed</artifactId>
<exclusions>
<exclusion>
<groupId>org.jboss.arquillian.protocol</groupId>
<artifactId>arquillian-protocol-servlet</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.keycloak.testsuite</groupId>
<artifactId>integration-arquillian-util</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.jboss.galleon</groupId>
<artifactId>galleon-maven-plugin</artifactId>
<version>${org.jboss.galleon.version}</version>
<!--Provision a server with relevant layers-->
<executions>
<execution>
<id>server-provisioning</id>
<goals>
<goal>provision</goal>
</goals>
<phase>generate-sources</phase>
<configuration>
<install-dir>${app.server.jboss.home}</install-dir>
<record-state>true</record-state>
<log-time>${galleon.log.time}</log-time>
<offline>false</offline>
<feature-packs>
<feature-pack>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-saml-adapter-galleon-pack</artifactId>
<version>${project.version}</version>
</feature-pack>
</feature-packs>
<pluginOptions>
<optional-packages>all</optional-packages>
</pluginOptions>
<configurations>
<config>
<model>standalone</model>
<name>standalone.xml</name>
<layers>
<layer>core-server</layer>
<layer>web-server</layer>
<layer>jaxrs-server</layer>
<layer>datasources-web-server</layer>
<layer>web-console</layer>
<layer>keycloak-saml</layer>
<layer>keycloak-client-saml</layer>
<layer>keycloak-client-saml-ejb</layer>
</layers>
</config>
</configurations>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>copy-standalone-file</id>
<phase>generate-resources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${app.server.jboss.home}/standalone/configuration</outputDirectory>
<resources>
<resource>
<directory>
${app.server.jboss.unpacked.folder.path}/${app.server.jboss.unpacked.folder.name}/standalone/configuration
</directory>
<includes>
<include>standalone.xml</include>
</includes>
</resource>
</resources>
</configuration>
</execution>
<execution>
<id>copy-welcome-content</id>
<phase>generate-resources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${app.server.jboss.home}/welcome-content</outputDirectory>
<resources>
<resource>
<directory>
${app.server.jboss.unpacked.folder.path}/${app.server.jboss.unpacked.folder.name}/welcome-content
</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View file

@ -0,0 +1,31 @@
/*
* Copyright 2023 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.
*/
package org.keycloak.testsuite.arquillian.galleon;
import org.jboss.arquillian.container.test.spi.client.deployment.ApplicationArchiveProcessor;
import org.jboss.arquillian.core.spi.LoadableExtension;
import org.keycloak.testsuite.arquillian.galleon.container.EAP8DeploymentArchiveProcessor;
public class EAP8AppServerArquillianExtension implements LoadableExtension {
@Override
public void register(ExtensionBuilder builder) {
builder.service(ApplicationArchiveProcessor.class, EAP8DeploymentArchiveProcessor.class);
}
}

View file

@ -0,0 +1,169 @@
/*
* Copyright 2023 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.
*/
package org.keycloak.testsuite.arquillian.galleon.container;
import org.jboss.arquillian.core.spi.Validate;
import org.jboss.as.arquillian.container.managed.ManagedDeployableContainer;
import org.jboss.shrinkwrap.descriptor.spi.node.Node;
import org.keycloak.testsuite.arquillian.container.AppServerContainerProvider;
import java.util.ArrayList;
import java.util.List;
/**
* Copied from <code>org.keycloak.testsuite.arquillian.eap.container.EAPAppServerProvider</code>
* <p>
* Create common class when refactoring
*/
public class EAP8AppServerProvider implements AppServerContainerProvider {
private Node configuration;
private static final String containerName = "eap8";
private final String appServerHome;
private final String appServerJavaHome;
private final String appServerPortOffset;
private final String managementProtocol;
private final String managementPort;
private final String startupTimeoutInSeconds;
public EAP8AppServerProvider() {
appServerHome = System.getProperty("app.server.home");
appServerJavaHome = System.getProperty("app.server.java.home");
appServerPortOffset = System.getProperty("app.server.port.offset");
managementProtocol = System.getProperty("app.server.management.protocol");
managementPort = System.getProperty("app.server.management.port");
startupTimeoutInSeconds = System.getProperty("app.server.startup.timeout");
Validate.notNullOrEmpty(containerName, "app.server is not set.");
Validate.notNullOrEmpty(appServerHome, "app.server.home is not set.");
Validate.notNullOrEmpty(appServerJavaHome, "app.server.java.home is not set.");
Validate.notNullOrEmpty(appServerPortOffset, "app.server.port.offset is not set.");
Validate.notNullOrEmpty(managementProtocol, "app.server.management.protocol is not set.");
Validate.notNullOrEmpty(managementPort, "app.server.management.port is not set.");
Validate.notNullOrEmpty(startupTimeoutInSeconds, "app.server.startup.timeout is not set.");
}
@Override
public String getName() {
return containerName;
}
@Override
public List<Node> getContainers() {
List<Node> containers = new ArrayList<>();
containers.add(standaloneContainer());
containers.add(clusterGroup());
return containers;
}
private void createChild(String name, String text) {
configuration.createChild("property").attribute("name", name).text(text);
}
private Node standaloneContainer() {
Node container = new Node("container");
container.attribute("mode", "manual");
container.attribute("qualifier", AppServerContainerProvider.APP_SERVER + "-" + containerName);
configuration = container.createChild("configuration");
createChild("enabled", "true");
createChild("adapterImplClass", ManagedDeployableContainer.class.getName());
createChild("jbossHome", appServerHome);
createChild("javaHome", appServerJavaHome);
createChild("jbossArguments",
"-Djboss.server.base.dir=" + appServerHome + "/standalone-test " +
"-Djboss.server.config.dir=" + appServerHome + "/standalone-test/configuration " +
"-Djboss.server.log.dir=" + appServerHome + "/standalone-test/log " +
"-Djboss.socket.binding.port-offset=" + appServerPortOffset + " " +
System.getProperty("adapter.test.props", " ") +
System.getProperty("kie.maven.settings", " ")
);
createChild("javaVmArguments",
System.getProperty("app.server.jboss.jvm.debug.args", "") + " " +
System.getProperty("app.server.memory.settings", "") + " " +
"-Djava.net.preferIPv4Stack=true"
);
createChild("managementProtocol", managementProtocol);
createChild("managementPort", managementPort);
createChild("startupTimeoutInSeconds", startupTimeoutInSeconds);
return container;
}
private Node clusterGroup() {
Node group = new Node("group");
group.attribute("qualifier", "app-server-eap-clustered");
addHaNodeContainer(group, 1);
addHaNodeContainer(group, 2);
return group;
}
private void addHaNodeContainer(Node group, int number) {
String portOffset = System.getProperty("app.server." + number + ".port.offset");
String managementPort = System.getProperty("app.server." + number + ".management.port");
Validate.notNullOrEmpty(portOffset, "app.server." + number + ".port.offset is not set.");
Validate.notNullOrEmpty(managementPort, "app.server." + number + ".management.port is not set.");
Node container = group.createChild("container");
container.attribute("mode", "manual");
container.attribute("qualifier", AppServerContainerProvider.APP_SERVER + "-" + containerName + "-ha-node-" + number);
configuration = container.createChild("configuration");
createChild("enabled", "true");
createChild("adapterImplClass", ManagedDeployableContainer.class.getName());
createChild("jbossHome", appServerHome);
createChild("javaHome", appServerJavaHome);
//cleanServerBaseDir cannot be used until WFARQ-44 is fixed
// createChild("cleanServerBaseDir", appServerHome + "/standalone-ha-node-" + number);
createChild("serverConfig", "standalone-ha.xml");
createChild("jbossArguments",
"-Djboss.server.base.dir=" + appServerHome + "/standalone-ha-node-" + number + " " +
"-Djboss.socket.binding.port-offset=" + portOffset + " " +
"-Djboss.node.name=ha-node-" + number + " " +
getCrossDCProperties(number, portOffset) +
System.getProperty("adapter.test.props", " ") +
System.getProperty("kie.maven.settings", " ")
);
createChild("javaVmArguments",
System.getProperty("app.server." + number + ".jboss.jvm.debug.args") + " " +
System.getProperty("app.server.memory.settings", "") + " " +
"-Djava.net.preferIPv4Stack=true" + " " +
System.getProperty("app.server.jvm.args.extra")
);
createChild("managementProtocol", managementProtocol);
createChild("managementPort", managementPort);
createChild("startupTimeoutInSeconds", startupTimeoutInSeconds);
}
private String getCrossDCProperties(int number, String portOffset) {
if (System.getProperty("cache.server") == null || System.getProperty("cache.server").equals("undefined")) {
return "";
}
String cacheHotrodPortString = System.getProperty("cache.server." + number + ".port.offset");
Validate.notNullOrEmpty(cacheHotrodPortString, "cache.server." + number + ".port.offset is not set.");
int tcppingPort = 7600 + Integer.parseInt(portOffset);
int cacheHotrodPort = 11222 + Integer.parseInt(cacheHotrodPortString);
//properties used in servers/app-server/jboss/common/cli/configure-crossdc-config.cli
return "-Dtcpping.port=" + tcppingPort + " -Dcache.hotrod.port=" + cacheHotrodPort + " ";
}
}

View file

@ -0,0 +1,61 @@
/*
* Copyright 2023 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.
*/
package org.keycloak.testsuite.arquillian.galleon.container;
import org.jboss.arquillian.container.test.spi.client.deployment.ApplicationArchiveProcessor;
import org.jboss.arquillian.test.spi.TestClass;
import org.jboss.logging.Logger;
import org.jboss.shrinkwrap.api.Archive;
import org.keycloak.testsuite.utils.annotation.UseServletFilter;
import org.keycloak.testsuite.utils.arquillian.DeploymentArchiveProcessorUtils;
public class EAP8DeploymentArchiveProcessor implements ApplicationArchiveProcessor {
private final Logger log = Logger.getLogger(EAP8DeploymentArchiveProcessor.class);
@Override
public void process(Archive<?> archive, TestClass testClass) {
if (DeploymentArchiveProcessorUtils.checkRunOnServerDeployment(archive)) return;
modifyWebXML(archive, testClass);
modifySAMLAdapterConfig(archive, DeploymentArchiveProcessorUtils.SAML_ADAPTER_CONFIG_PATH);
modifySAMLAdapterConfig(archive, DeploymentArchiveProcessorUtils.SAML_ADAPTER_CONFIG_PATH_TENANT1);
modifySAMLAdapterConfig(archive, DeploymentArchiveProcessorUtils.SAML_ADAPTER_CONFIG_PATH_TENANT2);
}
private void modifyWebXML(Archive<?> archive, TestClass testClass) {
if (!archive.contains(DeploymentArchiveProcessorUtils.WEBXML_PATH)) return;
DeploymentArchiveProcessorUtils.useJakartaEEServletClass(archive, DeploymentArchiveProcessorUtils.WEBXML_PATH);
if (!testClass.getJavaClass().isAnnotationPresent(UseServletFilter.class)) return;
if (!archive.contains(DeploymentArchiveProcessorUtils.JBOSS_DEPLOYMENT_XML_PATH)) return;
log.debug("Modifying WEB.XML in " + archive.getName() + " for Servlet Filter.");
DeploymentArchiveProcessorUtils.modifyWebXMLForServletFilter(archive, testClass);
DeploymentArchiveProcessorUtils.addFilterDependencies(archive, testClass);
}
private void modifySAMLAdapterConfig(Archive<?> archive, String adapterConfigPath) {
if (!archive.contains(adapterConfigPath)) return;
log.debug("Modifying adapter config " + adapterConfigPath + " in " + archive.getName());
DeploymentArchiveProcessorUtils.modifySAMLAdapterConfig(archive, adapterConfigPath);
}
}

View file

@ -0,0 +1 @@
org.keycloak.testsuite.arquillian.galleon.EAP8AppServerArquillianExtension

View file

@ -34,10 +34,14 @@
<common.resources>${project.parent.basedir}/common</common.resources>
<assembly.xml>${project.parent.basedir}/assembly.xml</assembly.xml>
<app.server.jboss.home>${containers.home}/${app.server.jboss.unpacked.folder.name}</app.server.jboss.home>
<app.server.jboss.unpacked.folder.path>${containers.home}</app.server.jboss.unpacked.folder.path>
<app.server.oidc.adapter.artifactId>keycloak-wildfly-adapter-dist</app.server.oidc.adapter.artifactId>
<oidc-adapter.version>${project.version}</oidc-adapter.version>
<saml-adapter.version>${project.version}</saml-adapter.version>
<skip.elytron.adapter.installation>true</skip.elytron.adapter.installation>
<skip.adapter.offline.installation>true</skip.adapter.offline.installation>
<skip.oidc.adapter.installation>false</skip.oidc.adapter.installation>
<skip.java17.enablement>true</skip.java17.enablement>
<!-- Workaround for WFCORE-5335 issue -->
<cli.executable>bash</cli.executable>
@ -127,7 +131,7 @@
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>unpack-wildfly-and-oidc-adapter</id>
<id>unpack-jboss-distribution</id>
<phase>generate-resources</phase>
<goals>
<goal>unpack</goal>
@ -139,8 +143,20 @@
<artifactId>${app.server.jboss.artifactId}</artifactId>
<version>${app.server.jboss.version}</version>
<type>zip</type>
<outputDirectory>${containers.home}</outputDirectory>
<outputDirectory>${app.server.jboss.unpacked.folder.path}</outputDirectory>
</artifactItem>
</artifactItems>
</configuration>
</execution>
<execution>
<id>unpack-oidc-adapter</id>
<phase>generate-resources</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<skip>${skip.oidc.adapter.installation}</skip>
<artifactItems>
<artifactItem>
<groupId>org.keycloak</groupId>
<artifactId>${app.server.oidc.adapter.artifactId}</artifactId>
@ -794,7 +810,7 @@
</build>
</profile>
<!-- Latest EAP (currently 7.2.X) -->
<!-- Latest EAP (currently 7.4.X) -->
<profile>
<id>app-server-eap</id>
<activation>
@ -808,6 +824,20 @@
</modules>
</profile>
<!-- EAP8 (not available to community yet) -->
<profile>
<id>app-server-eap8</id>
<activation>
<property>
<name>app.server</name>
<value>eap8</value>
</property>
</activation>
<modules>
<module>galleon</module>
</modules>
</profile>
<profile>
<id>app-server-eap71</id>
<activation>

View file

@ -77,7 +77,7 @@
</dependency>
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-servlet-filter-adapter</artifactId>
<artifactId>keycloak-jakarta-servlet-filter-adapter</artifactId>
</dependency>
<dependency>
<groupId>commons-io</groupId>

View file

@ -33,9 +33,10 @@
<script.suffix>sh</script.suffix>
<!--app container versions-->
<eap.version>7.4.9.GA-redhat-00003</eap.version>
<eap.version>${eap7.version}</eap.version>
<eap6.version>7.5.21.Final-redhat-1</eap6.version>
<eap71.version>7.1.5.GA-redhat-00002</eap71.version>
<eap7.version>7.4.9.GA-redhat-00003</eap7.version>
<jboss.as.version>7.1.1.Final</jboss.as.version>
<jboss.default.worker.io-threads>16</jboss.default.worker.io-threads>

View file

@ -20,6 +20,7 @@
<module>servlet-authz</module>
<module>servlet-policy-enforcer</module>
<module>servlets</module>
<module>servlets-jakarta</module>
<module>app-profile-jee</module>
<module>cors</module>
<module>spring-boot-adapter-app</module>

View file

@ -0,0 +1 @@
src/

View file

@ -0,0 +1,134 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.keycloak.testsuite</groupId>
<artifactId>integration-arquillian-test-apps</artifactId>
<version>999.0.0-SNAPSHOT</version>
</parent>
<artifactId>integration-arquillian-test-apps-servlets-jakarta</artifactId>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jakarta-transformer-sources>${project.basedir}/../servlets</jakarta-transformer-sources>
<jakarta-transformer-target>${project.basedir}</jakarta-transformer-target>
</properties>
<dependencies>
<dependency>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-adapter-core</artifactId>
</dependency>
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-policy-enforcer</artifactId>
</dependency>
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-core</artifactId>
</dependency>
<dependency>
<groupId>jakarta.ws.rs</groupId>
<artifactId>jakarta.ws.rs-api</artifactId>
</dependency>
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-adapter-spi</artifactId>
</dependency>
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-saml-adapter-api-public</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-core</artifactId>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</dependency>
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-saml-core</artifactId>
</dependency>
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-saml-adapter-core</artifactId>
</dependency>
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-saml-core-public</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<id>transform</id>
<phase>initialize</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<property name="plugin_classpath" refid="maven.plugin.classpath"/>
<java classname="org.eclipse.transformer.jakarta.JakartaTransformer" fork="true">
<arg value="-o"/>
<arg value="${jakarta-transformer-sources}"/>
<arg value="${jakarta-transformer-target}/tmp"/>
<classpath>
<pathelement path="${plugin_classpath}"/>
</classpath>
</java>
<touch>
<fileset dir="${jakarta-transformer-target}"/>
</touch>
<copy todir="${jakarta-transformer-target}" overwrite="false">
<fileset dir="${jakarta-transformer-target}/tmp"/>
</copy>
<delete dir="${jakarta-transformer-target}/tmp"/>
</target>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.eclipse.transformer</groupId>
<artifactId>org.eclipse.transformer.cli</artifactId>
<version>0.2.0</version>
</dependency>
<dependency>
<groupId>ant-contrib</groupId>
<artifactId>ant-contrib</artifactId>
<version>1.0b3</version>
<exclusions>
<exclusion>
<groupId>ant</groupId>
<artifactId>ant</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</project>

View file

@ -32,6 +32,7 @@
<description></description>
<properties>
<arquillian.protocol.default>Servlet 3.0</arquillian.protocol.default>
<cli.log.output>false</cli.log.output>
<test.intermittent>false</test.intermittent>
<exclude.test>-</exclude.test>
@ -256,7 +257,39 @@
</configuration>
</execution>
</executions>
</plugin>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>xml-maven-plugin</artifactId>
<executions>
<execution>
<id>arquillian-default-protocol</id>
<phase>process-resources</phase>
<goals>
<goal>transform</goal>
</goals>
<configuration>
<transformationSets>
<transformationSet>
<dir>src/test/resources</dir>
<includes>
<include>arquillian.xml</include>
</includes>
<stylesheet>src/test/resources/arquillian.xsl</stylesheet>
<outputDir>${project.build.directory}/dependency</outputDir>
<parameters>
<parameter>
<name>defaultProtocol</name>
<value>${arquillian.protocol.default}</value>
</parameter>
</parameters>
</transformationSet>
</transformationSets>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
@ -291,14 +324,12 @@
<resource>
<directory>src/test/resources</directory>
<includes>
<include>arquillian.xml</include>
<include>wildfly-config.xml</include>
<include>password-blacklists/**</include>
<include>log4j.properties</include>
<include>vault/**</include>
<include>firefox-cookies-prefs.js</include>
</includes>
<!--<filtering>true</filtering>-->
</resource>
</resources>
</configuration>
@ -587,6 +618,46 @@
</build>
</profile>
<profile>
<id>app-server-eap8</id>
<activation>
<property>
<name>app.server</name>
<value>eap8</value>
</property>
</activation>
<properties>
<app.server>eap8</app.server>
<app.server.skip.unpack>false</app.server.skip.unpack>
<app.server.artifactId>integration-arquillian-servers-app-server-jboss-galleon</app.server.artifactId>
<arquillian.protocol.default>Servlet 5.0</arquillian.protocol.default>
<wildfly.core.version>${tests.wildfly.core.version}</wildfly.core.version>
</properties>
<dependencies>
<dependency>
<groupId>org.keycloak.testsuite</groupId>
<artifactId>integration-arquillian-servers-app-server-jboss-galleon</artifactId>
<version>${project.version}</version>
<scope>runtime</scope>
</dependency>
<!--required by creaper-core-->
<dependency>
<groupId>org.wildfly.core</groupId>
<artifactId>wildfly-cli</artifactId>
<scope>test</scope>
<version>${wildfly.core.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.commonjava.maven.plugins</groupId>
<artifactId>directory-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>app-server-eap71</id>
<activation>

View file

@ -379,6 +379,10 @@ public class AppServerTestEnricher {
return CURRENT_APP_SERVER.equals("eap");
}
public static boolean isJBossJakartaAppServer() {
return CURRENT_APP_SERVER.equals("eap8");
}
public static boolean isWASAppServer() {
return CURRENT_APP_SERVER.equals("was");
}

View file

@ -23,6 +23,7 @@ import org.jboss.shrinkwrap.api.asset.StringAsset;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.keycloak.representations.idm.RealmRepresentation;
import org.keycloak.testsuite.adapter.filter.AdapterActionsFilter;
import org.keycloak.testsuite.arquillian.AppServerTestEnricher;
import org.keycloak.testsuite.util.DroneUtils;
import org.keycloak.testsuite.utils.arquillian.DeploymentArchiveProcessorUtils;
import org.keycloak.testsuite.utils.io.IOUtil;
@ -152,6 +153,10 @@ public abstract class AbstractServletsAdapterTest extends AbstractAdapterTest {
addContextXml(deployment, name);
if (AppServerTestEnricher.isJBossJakartaAppServer()) {
DeploymentArchiveProcessorUtils.useJakartaEEServletClass(deployment, "/WEB-INF/web.xml");
}
return deployment;
}

View file

@ -49,6 +49,7 @@ import static org.keycloak.testsuite.util.SamlClient.Binding.POST;
@AppServerContainer(ContainerConstants.APP_SERVER_EAP)
@AppServerContainer(ContainerConstants.APP_SERVER_EAP6)
@AppServerContainer(ContainerConstants.APP_SERVER_EAP71)
@AppServerContainer(ContainerConstants.APP_SERVER_EAP8)
@AppServerContainer(ContainerConstants.APP_SERVER_JETTY94)
public class SAMLClockSkewAdapterTest extends AbstractSAMLServletAdapterTest {
@ -139,6 +140,7 @@ public class SAMLClockSkewAdapterTest extends AbstractSAMLServletAdapterTest {
@AppServerContainer(value = ContainerConstants.APP_SERVER_EAP, skip = true)
@AppServerContainer(value = ContainerConstants.APP_SERVER_EAP6, skip = true)
@AppServerContainer(value = ContainerConstants.APP_SERVER_EAP71, skip = true)
@AppServerContainer(value = ContainerConstants.APP_SERVER_EAP8, skip = true)
@AppServerContainer(value = ContainerConstants.APP_SERVER_JETTY94, skip = true)
public void testClockSkewTomcat() throws Exception {

View file

@ -0,0 +1,28 @@
/*
* Copyright 2023 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.
*/
package org.keycloak.testsuite.adapter.servlet;
import org.keycloak.testsuite.arquillian.annotation.AppServerContainer;
import org.keycloak.testsuite.utils.annotation.UseServletFilter;
import org.keycloak.testsuite.utils.arquillian.ContainerConstants;
@AppServerContainer(ContainerConstants.APP_SERVER_EAP8)
@UseServletFilter(filterName = "saml-filter", filterClass = "org.keycloak.adapters.saml.servlet.SamlFilter",
filterDependency = "org.keycloak:keycloak-saml-jakarta-servlet-filter-adapter")
public class SAMLFilterJakartaLoginResponseHandlingTest extends SAMLFilterLoginResponseHandlingTest {
}

View file

@ -0,0 +1,28 @@
/*
* Copyright 2023 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.
*/
package org.keycloak.testsuite.adapter.servlet;
import org.keycloak.testsuite.arquillian.annotation.AppServerContainer;
import org.keycloak.testsuite.utils.annotation.UseServletFilter;
import org.keycloak.testsuite.utils.arquillian.ContainerConstants;
@AppServerContainer(ContainerConstants.APP_SERVER_EAP8)
@UseServletFilter(filterName = "saml-filter", filterClass = "org.keycloak.adapters.saml.servlet.SamlFilter",
filterDependency = "org.keycloak:keycloak-saml-jakarta-servlet-filter-adapter")
public class SAMLFilterServletJakartaAdapterTest extends SAMLFilterServletAdapterTest {
}

View file

@ -0,0 +1,28 @@
/*
* Copyright 2023 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.
*/
package org.keycloak.testsuite.adapter.servlet;
import org.keycloak.testsuite.arquillian.annotation.AppServerContainer;
import org.keycloak.testsuite.utils.annotation.UseServletFilter;
import org.keycloak.testsuite.utils.arquillian.ContainerConstants;
@AppServerContainer(ContainerConstants.APP_SERVER_EAP8)
@UseServletFilter(filterName = "saml-filter", filterClass = "org.keycloak.adapters.saml.servlet.SamlFilter",
filterDependency = "org.keycloak:keycloak-saml-jakarta-servlet-filter-adapter")
public class SAMLFilterServletJakartaSessionTimeoutTest extends SAMLFilterServletSessionTimeoutTest {
}

View file

@ -59,6 +59,7 @@ import static org.keycloak.testsuite.util.WaitUtils.waitUntilElement;
@AppServerContainer(ContainerConstants.APP_SERVER_EAP)
@AppServerContainer(ContainerConstants.APP_SERVER_EAP6)
@AppServerContainer(ContainerConstants.APP_SERVER_EAP71)
@AppServerContainer(ContainerConstants.APP_SERVER_EAP8)
@AppServerContainer(ContainerConstants.APP_SERVER_TOMCAT8)
@AppServerContainer(ContainerConstants.APP_SERVER_TOMCAT9)
@AppServerContainer(ContainerConstants.APP_SERVER_JETTY94)

View file

@ -54,6 +54,7 @@ import static org.keycloak.testsuite.util.SamlClient.Binding.REDIRECT;
@AppServerContainer(ContainerConstants.APP_SERVER_EAP)
@AppServerContainer(ContainerConstants.APP_SERVER_EAP6)
@AppServerContainer(ContainerConstants.APP_SERVER_EAP71)
@AppServerContainer(ContainerConstants.APP_SERVER_EAP8)
@AppServerContainer(ContainerConstants.APP_SERVER_TOMCAT8)
@AppServerContainer(ContainerConstants.APP_SERVER_TOMCAT9)
public class SAMLLogoutAdapterTest extends AbstractServletsAdapterTest {

View file

@ -192,6 +192,7 @@ import org.xml.sax.SAXException;
@AppServerContainer(ContainerConstants.APP_SERVER_EAP)
@AppServerContainer(ContainerConstants.APP_SERVER_EAP6)
@AppServerContainer(ContainerConstants.APP_SERVER_EAP71)
@AppServerContainer(ContainerConstants.APP_SERVER_EAP8)
@AppServerContainer(ContainerConstants.APP_SERVER_TOMCAT8)
@AppServerContainer(ContainerConstants.APP_SERVER_TOMCAT9)
public class SAMLServletAdapterTest extends AbstractSAMLServletAdapterTest {

View file

@ -38,6 +38,7 @@ import static org.keycloak.testsuite.util.Matchers.bodyHC;
@AppServerContainer(ContainerConstants.APP_SERVER_EAP)
@AppServerContainer(ContainerConstants.APP_SERVER_EAP6)
@AppServerContainer(ContainerConstants.APP_SERVER_EAP71)
@AppServerContainer(ContainerConstants.APP_SERVER_EAP8)
@AppServerContainer(ContainerConstants.APP_SERVER_TOMCAT8)
@AppServerContainer(ContainerConstants.APP_SERVER_TOMCAT9)
@AppServerContainer(ContainerConstants.APP_SERVER_JETTY94)

View file

@ -81,6 +81,7 @@ import static org.keycloak.testsuite.saml.AbstractSamlTest.REALM_SIGNING_CERTIFI
@AppServerContainer(ContainerConstants.APP_SERVER_EAP)
@AppServerContainer(ContainerConstants.APP_SERVER_EAP6)
@AppServerContainer(ContainerConstants.APP_SERVER_EAP71)
@AppServerContainer(ContainerConstants.APP_SERVER_EAP8)
@AppServerContainer(ContainerConstants.APP_SERVER_TOMCAT8)
@AppServerContainer(ContainerConstants.APP_SERVER_TOMCAT9)
public class SamlSignatureTest extends AbstractAdapterTest {

View file

@ -46,7 +46,7 @@ import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertTrue;
import java.io.IOException;
import javax.ws.rs.core.Response;
import jakarta.ws.rs.core.Response;
/**
* @author <a href="mailto:sthorger@redhat.com">Stian Thorgersen</a>

View file

@ -37,6 +37,7 @@ import static org.keycloak.testsuite.util.Matchers.statusCodeIsHC;
@AppServerContainer(ContainerConstants.APP_SERVER_EAP)
@AppServerContainer(ContainerConstants.APP_SERVER_EAP6)
@AppServerContainer(ContainerConstants.APP_SERVER_EAP71)
@AppServerContainer(ContainerConstants.APP_SERVER_EAP8)
@AppServerContainer(ContainerConstants.APP_SERVER_TOMCAT8)
@AppServerContainer(ContainerConstants.APP_SERVER_TOMCAT9)
public class SamlXMLAttacksTest extends AbstractSamlTest {

View file

@ -20,8 +20,6 @@
xsi:schemaLocation="http://jboss.org/schema/arquillian
http://jboss.org/schema/arquillian/arquillian_1_0.xsd">
<defaultProtocol type="Servlet 3.0" />
<extension qualifier="webdriver">
<property name="browser">${browser}</property>
<property name="downloadBinaries">${webdriverDownloadBinaries}</property>

View file

@ -0,0 +1,25 @@
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xalan="http://xml.apache.org/xalan"
xmlns:a="http://jboss.org/schema/arquillian"
version="2.0"
exclude-result-prefixes="xalan a">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" xalan:indent-amount="4" standalone="no"/>
<xsl:strip-space elements="*"/>
<xsl:param name="defaultProtocol" select="'Servlet 3.0'"/>
<xsl:template match="/a:arquillian">
<xsl:copy>
<defaultProtocol type="{$defaultProtocol}"/>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>

View file

@ -1672,12 +1672,6 @@
<version>1.0.13</version>
</dependency>
<dependency>
<groupId>org.keycloak.testsuite</groupId>
<artifactId>integration-arquillian-test-apps-servlets</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.keycloak.testsuite</groupId>
<artifactId>integration-arquillian-util</artifactId>
@ -1948,6 +1942,40 @@
</properties>
</profile>
<profile>
<id>app-server-eap8</id>
<activation>
<property>
<name>app.server</name>
<value>eap8</value>
</property>
</activation>
<dependencies>
<dependency>
<groupId>org.keycloak.testsuite</groupId>
<artifactId>integration-arquillian-test-apps-servlets-jakarta</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</profile>
<profile>
<id>not-app-server-eap8</id>
<activation>
<property>
<name>app.server</name>
<value>!eap8</value>
</property>
</activation>
<dependencies>
<dependency>
<groupId>org.keycloak.testsuite</groupId>
<artifactId>integration-arquillian-test-apps-servlets</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</profile>
<profile>
<id>generate-certs-for-custom-auth-server-host</id>
<activation>

View file

@ -17,27 +17,28 @@
package org.keycloak.testsuite.utils.arquillian;
public interface ContainerConstants {
public static final String APP_SERVER_PREFIX = "app-server-";
String APP_SERVER_PREFIX = "app-server-";
public static final String APP_SERVER_UNDERTOW = APP_SERVER_PREFIX + "undertow";
String APP_SERVER_UNDERTOW = APP_SERVER_PREFIX + "undertow";
public static final String APP_SERVER_WILDFLY = APP_SERVER_PREFIX + "wildfly";
public static final String APP_SERVER_WILDFLY_CLUSTER = APP_SERVER_WILDFLY + "-ha-node-1;" + APP_SERVER_WILDFLY + "-ha-node-2";
String APP_SERVER_WILDFLY = APP_SERVER_PREFIX + "wildfly";
String APP_SERVER_WILDFLY_CLUSTER = APP_SERVER_WILDFLY + "-ha-node-1;" + APP_SERVER_WILDFLY + "-ha-node-2";
public static final String APP_SERVER_EAP = APP_SERVER_PREFIX + "eap";
public static final String APP_SERVER_EAP_CLUSTER = APP_SERVER_EAP + "-ha-node-1;" + APP_SERVER_EAP + "-ha-node-2";
String APP_SERVER_EAP = APP_SERVER_PREFIX + "eap";
String APP_SERVER_EAP_CLUSTER = APP_SERVER_EAP + "-ha-node-1;" + APP_SERVER_EAP + "-ha-node-2";
public static final String APP_SERVER_EAP71 = APP_SERVER_PREFIX + "eap71";
String APP_SERVER_EAP8 = APP_SERVER_PREFIX + "eap8";
String APP_SERVER_EAP71 = APP_SERVER_PREFIX + "eap71";
public static final String APP_SERVER_EAP6 = APP_SERVER_PREFIX + "eap6";
public static final String APP_SERVER_EAP6_CLUSTER = APP_SERVER_EAP6 + "-ha-node-1;" + APP_SERVER_EAP6 + "-ha-node-2";
String APP_SERVER_EAP6 = APP_SERVER_PREFIX + "eap6";
String APP_SERVER_EAP6_CLUSTER = APP_SERVER_EAP6 + "-ha-node-1;" + APP_SERVER_EAP6 + "-ha-node-2";
public static final String APP_SERVER_FUSE63 = APP_SERVER_PREFIX + "fuse63";
public static final String APP_SERVER_FUSE7X = APP_SERVER_PREFIX + "fuse7x";
String APP_SERVER_FUSE63 = APP_SERVER_PREFIX + "fuse63";
String APP_SERVER_FUSE7X = APP_SERVER_PREFIX + "fuse7x";
public static final String APP_SERVER_JETTY94 = APP_SERVER_PREFIX + "jetty94";
String APP_SERVER_JETTY94 = APP_SERVER_PREFIX + "jetty94";
public static final String APP_SERVER_TOMCAT8 = APP_SERVER_PREFIX + "tomcat8";
public static final String APP_SERVER_TOMCAT9 = APP_SERVER_PREFIX + "tomcat9";
String APP_SERVER_TOMCAT8 = APP_SERVER_PREFIX + "tomcat8";
String APP_SERVER_TOMCAT9 = APP_SERVER_PREFIX + "tomcat9";
}

View file

@ -16,18 +16,11 @@
*/
package org.keycloak.testsuite.utils.arquillian;
import java.io.File;
import java.io.IOException;
import java.util.Arrays;
import java.util.Collection;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathExpression;
import javax.xml.xpath.XPathExpressionException;
import javax.xml.xpath.XPathFactory;
import org.jboss.arquillian.test.spi.TestClass;
import org.jboss.logging.Logger;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.Node;
import org.jboss.shrinkwrap.api.asset.Asset;
import org.jboss.shrinkwrap.api.asset.StringAsset;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.keycloak.adapters.servlet.KeycloakOIDCFilter;
@ -40,9 +33,22 @@ import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import static org.keycloak.testsuite.utils.io.IOUtil.modifyDocElementAttribute;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathExpression;
import javax.xml.xpath.XPathExpressionException;
import javax.xml.xpath.XPathFactory;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.Collection;
import java.util.Optional;
import static org.keycloak.testsuite.util.ServerURLs.getAppServerContextRoot;
import static org.keycloak.testsuite.util.ServerURLs.getAuthServerContextRoot;
import static org.keycloak.testsuite.utils.io.IOUtil.modifyDocElementAttribute;
import static org.keycloak.testsuite.utils.io.IOUtil.modifyDocElementValue;
/**
*
@ -269,6 +275,42 @@ public class DeploymentArchiveProcessorUtils {
modifyDocElementAttribute(doc, "SP", "logoutPage", AUTH_SERVER_REPLACED_URL, getAppServerContextRoot());
}
public static void useJakartaEEServletClass(Archive<?> archive, String adapterConfigPath) {
final String SERVLET_TAG = "servlet";
final String SERVLET_CLASS_TAG = "servlet-class";
final String JAVAX_APPLICATION = "javax.ws.rs.core.Application";
final String JAKARTA_APPLICATION = "jakarta.ws.rs.core.Application";
final Asset configAsset = Optional.ofNullable(archive.get(adapterConfigPath))
.map(Node::getAsset)
.orElseThrow(() -> new IllegalArgumentException(String.format("Cannot find '%s' config path", adapterConfigPath)));
try (InputStream configStream = configAsset.openStream()) {
final Document doc = IOUtil.loadXML(configStream);
final NodeList servletNodeList = doc.getElementsByTagName(SERVLET_TAG);
if (servletNodeList.getLength() == 1) {
final int servletClassCount = doc.getElementsByTagName(SERVLET_CLASS_TAG).getLength();
if (servletClassCount == 0) {
final Element servletClassElement = doc.createElement(SERVLET_CLASS_TAG);
servletClassElement.setTextContent(JAKARTA_APPLICATION);
servletNodeList.item(0).appendChild(servletClassElement);
log.infof("Appending '%s' tag with Jakarta application class to '%s'\n", SERVLET_CLASS_TAG, archive.getName());
} else if (servletClassCount == 1) {
modifyDocElementValue(doc, SERVLET_CLASS_TAG, JAVAX_APPLICATION, JAKARTA_APPLICATION);
log.infof("Modifying 'servlet-class' tag to use Jakarta application class in '%s'\n", SERVLET_CLASS_TAG, archive.getName());
} else {
log.error(String.format("Invalid count of '%s' tags for '%s'\n", SERVLET_CLASS_TAG, archive.getName()));
return;
}
archive.add(new StringAsset(IOUtil.documentToString(doc)), adapterConfigPath);
}
} catch (IOException e) {
throw new RuntimeException(e);
}
}
private static String getAuthServerUrl() {
String scheme = AUTH_SERVER_SSL_REQUIRED ? "https" : "http";
String host = System.getProperty("auth.server.host", "localhost");