Remove adapter app-server-undertow profile which is not used
Closes #30347 Signed-off-by: rmartinc <rmartinc@redhat.com>
This commit is contained in:
parent
99d3611afe
commit
7d42ab822b
20 changed files with 0 additions and 798 deletions
|
@ -44,7 +44,6 @@
|
||||||
<id>build-app-servers</id>
|
<id>build-app-servers</id>
|
||||||
<modules>
|
<modules>
|
||||||
<module>jboss</module>
|
<module>jboss</module>
|
||||||
<module>undertow</module>
|
|
||||||
</modules>
|
</modules>
|
||||||
</profile>
|
</profile>
|
||||||
</profiles>
|
</profiles>
|
||||||
|
|
|
@ -1,70 +0,0 @@
|
||||||
<?xml version="1.0"?>
|
|
||||||
<!--
|
|
||||||
~ Copyright 2018 Red Hat, Inc. and/or its affiliates
|
|
||||||
~ and other contributors as indicated by the @author tags.
|
|
||||||
~
|
|
||||||
<?xml version="1.0"?>
|
|
||||||
~ 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 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
|
||||||
<parent>
|
|
||||||
<groupId>org.keycloak.testsuite</groupId>
|
|
||||||
<artifactId>integration-arquillian-servers-app-server</artifactId>
|
|
||||||
<version>999.0.0-SNAPSHOT</version>
|
|
||||||
</parent>
|
|
||||||
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
|
|
||||||
<artifactId>integration-arquillian-servers-app-server-undertow</artifactId>
|
|
||||||
<packaging>jar</packaging>
|
|
||||||
<name>App Server - Undertow</name>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.keycloak.testsuite</groupId>
|
|
||||||
<artifactId>keycloak-saml-undertow-adapter-jakarta</artifactId>
|
|
||||||
<version>${project.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.keycloak.testsuite</groupId>
|
|
||||||
<artifactId>integration-arquillian-servers-app-server-spi</artifactId>
|
|
||||||
<version>${project.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.keycloak.testsuite</groupId>
|
|
||||||
<artifactId>integration-arquillian-util</artifactId>
|
|
||||||
<version>${project.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.jboss.resteasy</groupId>
|
|
||||||
<artifactId>resteasy-undertow</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.jboss.arquillian.container</groupId>
|
|
||||||
<artifactId>undertow-embedded</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>commons-io</groupId>
|
|
||||||
<artifactId>commons-io</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
|
|
||||||
<!--
|
|
||||||
it is required for undertow adapter example authorization tests when they run with -Pauth-server-eap
|
|
||||||
todo: find out why it doesn't happen with -Pauth-server-wildfly
|
|
||||||
-->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.jboss.spec.javax.servlet.jsp</groupId>
|
|
||||||
<artifactId>jboss-jsp-api_2.3_spec</artifactId>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
|
|
||||||
</project>
|
|
|
@ -1,261 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2018 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.undertow;
|
|
||||||
|
|
||||||
import io.undertow.Undertow;
|
|
||||||
import io.undertow.server.handlers.PathHandler;
|
|
||||||
import io.undertow.servlet.api.DeploymentInfo;
|
|
||||||
import io.undertow.servlet.api.DeploymentManager;
|
|
||||||
import io.undertow.servlet.api.ServletContainer;
|
|
||||||
import io.undertow.servlet.api.ServletInfo;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.nio.charset.Charset;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import jakarta.servlet.ServletException;
|
|
||||||
import jakarta.ws.rs.Path;
|
|
||||||
import jakarta.ws.rs.core.Application;
|
|
||||||
|
|
||||||
import org.apache.commons.io.FileUtils;
|
|
||||||
import org.apache.commons.io.IOUtils;
|
|
||||||
import org.arquillian.undertow.UndertowContainerConfiguration;
|
|
||||||
import org.jboss.arquillian.container.spi.client.container.DeployableContainer;
|
|
||||||
import org.jboss.arquillian.container.spi.client.container.DeploymentException;
|
|
||||||
import org.jboss.arquillian.container.spi.client.container.LifecycleException;
|
|
||||||
import org.jboss.arquillian.container.spi.client.protocol.ProtocolDescription;
|
|
||||||
import org.jboss.arquillian.container.spi.client.protocol.metadata.HTTPContext;
|
|
||||||
import org.jboss.arquillian.container.spi.client.protocol.metadata.ProtocolMetaData;
|
|
||||||
import org.jboss.arquillian.container.spi.client.protocol.metadata.Servlet;
|
|
||||||
import org.jboss.logging.Logger;
|
|
||||||
import org.jboss.resteasy.core.ResteasyDeploymentImpl;
|
|
||||||
import org.jboss.resteasy.plugins.server.undertow.UndertowJaxrsServer;
|
|
||||||
import org.jboss.resteasy.spi.ResteasyDeployment;
|
|
||||||
import org.jboss.shrinkwrap.api.Archive;
|
|
||||||
import org.jboss.shrinkwrap.api.Node;
|
|
||||||
import org.jboss.shrinkwrap.api.asset.ClassAsset;
|
|
||||||
import org.jboss.shrinkwrap.api.spec.WebArchive;
|
|
||||||
import org.jboss.shrinkwrap.descriptor.api.Descriptor;
|
|
||||||
import org.jboss.shrinkwrap.undertow.api.UndertowWebArchive;
|
|
||||||
import org.keycloak.common.util.reflections.Reflections;
|
|
||||||
import org.keycloak.testsuite.arquillian.undertow.saml.util.RestSamlApplicationConfig;
|
|
||||||
import org.keycloak.testsuite.utils.undertow.UndertowDeployerHelper;
|
|
||||||
import org.keycloak.testsuite.utils.undertow.UndertowWarClassLoader;
|
|
||||||
import java.io.InputStream;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author <a href="mailto:vramik@redhat.com">Vlasta Ramik</a>
|
|
||||||
*/
|
|
||||||
public class UndertowAppServer implements DeployableContainer<UndertowAppServerConfiguration> {
|
|
||||||
|
|
||||||
private static final Logger log = Logger.getLogger(UndertowAppServer.class);
|
|
||||||
|
|
||||||
private UndertowContainerConfiguration configuration;
|
|
||||||
private UndertowJaxrsServer undertow;
|
|
||||||
Map<String, String> deployedArchivesToContextPath = new ConcurrentHashMap<>();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Class<UndertowAppServerConfiguration> getConfigurationClass() {
|
|
||||||
return UndertowAppServerConfiguration.class;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setup(UndertowAppServerConfiguration configuration) {
|
|
||||||
this.configuration = configuration;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void start() throws LifecycleException {
|
|
||||||
long start = System.currentTimeMillis();
|
|
||||||
|
|
||||||
undertow = new UndertowJaxrsServer();
|
|
||||||
undertow.start(Undertow.builder()
|
|
||||||
.addHttpListener(configuration.getBindHttpPort(), configuration.getBindAddress()));
|
|
||||||
log.infof("App server started in %dms on http://%s:%d/", (System.currentTimeMillis() - start), configuration.getBindAddress(), configuration.getBindHttpPort());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void stop() throws LifecycleException {
|
|
||||||
undertow.stop();
|
|
||||||
log.info("App Server stopped.");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ProtocolDescription getDefaultProtocol() {
|
|
||||||
return new ProtocolDescription("Servlet 3.1");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ProtocolMetaData deploy(Archive<?> archive) throws DeploymentException {
|
|
||||||
log.info("Deploying archive " + archive.getName());
|
|
||||||
|
|
||||||
// Remove jsps
|
|
||||||
String ioTMPDir = System.getProperty("java.io.tmpdir", ""); // My Intellij and Terminal stores tmp directory in this property
|
|
||||||
if (!ioTMPDir.isEmpty()) {
|
|
||||||
ioTMPDir = ioTMPDir.endsWith("/") ? ioTMPDir : ioTMPDir + "/";
|
|
||||||
File tmpUndertowJSPDirectory = new File(ioTMPDir + "org/apache/jsp");
|
|
||||||
if (tmpUndertowJSPDirectory.exists()) {
|
|
||||||
try {
|
|
||||||
FileUtils.deleteDirectory(tmpUndertowJSPDirectory);
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
DeploymentInfo di;
|
|
||||||
if (archive instanceof UndertowWebArchive) {
|
|
||||||
di = ((UndertowWebArchive) archive).getDeploymentInfo();
|
|
||||||
} else if (archive instanceof WebArchive) {
|
|
||||||
WebArchive webArchive = (WebArchive)archive;
|
|
||||||
|
|
||||||
Optional<Node> applicationClassNode = archive.getContent(archivePath ->
|
|
||||||
archivePath.get().startsWith("/WEB-INF/classes/") && archivePath.get().endsWith("Application.class"))
|
|
||||||
.values().stream().findFirst();
|
|
||||||
|
|
||||||
if (isJaxrsApp(webArchive)) {
|
|
||||||
di = new UndertowDeployerHelper().getDeploymentInfo(configuration, webArchive,
|
|
||||||
undertow.undertowDeployment(discoverPathAnnotatedClasses(webArchive)));
|
|
||||||
} else if (applicationClassNode.isPresent()) {
|
|
||||||
String applicationPath = applicationClassNode.get().getPath().get();
|
|
||||||
|
|
||||||
ResteasyDeployment deployment = new ResteasyDeploymentImpl();
|
|
||||||
deployment.setApplicationClass(extractClassName(applicationPath));
|
|
||||||
di = new UndertowDeployerHelper().getDeploymentInfo(configuration, (WebArchive) archive, undertow.undertowDeployment(deployment));
|
|
||||||
} else {
|
|
||||||
di = new UndertowDeployerHelper().getDeploymentInfo(configuration, webArchive);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
throw new IllegalArgumentException("UndertowContainer only supports UndertowWebArchive or WebArchive.");
|
|
||||||
}
|
|
||||||
|
|
||||||
if ("ROOT.war".equals(archive.getName())) {
|
|
||||||
di.setContextPath("/");
|
|
||||||
}
|
|
||||||
|
|
||||||
ClassLoader parentCl = Thread.currentThread().getContextClassLoader();
|
|
||||||
UndertowWarClassLoader classLoader = new UndertowWarClassLoader(parentCl, archive);
|
|
||||||
Thread.currentThread().setContextClassLoader(classLoader);
|
|
||||||
|
|
||||||
try {
|
|
||||||
undertow.deploy(di);
|
|
||||||
} finally {
|
|
||||||
Thread.currentThread().setContextClassLoader(parentCl);
|
|
||||||
}
|
|
||||||
|
|
||||||
deployedArchivesToContextPath.put(archive.getName(), di.getContextPath());
|
|
||||||
|
|
||||||
return new ProtocolMetaData().addContext(
|
|
||||||
createHttpContextForDeploymentInfo(di));
|
|
||||||
}
|
|
||||||
|
|
||||||
private String extractClassName(String applicationPath) {
|
|
||||||
applicationPath = applicationPath
|
|
||||||
.substring(0, applicationPath.lastIndexOf(".class")) // Remove .class
|
|
||||||
.replaceFirst("^/WEB-INF/classes/", ""); // Remove /WEB-INF/classes/ from beginning
|
|
||||||
|
|
||||||
return applicationPath.replaceAll("/", ".");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void undeploy(Archive<?> archive) throws DeploymentException {
|
|
||||||
log.info("Undeploying archive " + archive.getName());
|
|
||||||
Field containerField = Reflections.findDeclaredField(UndertowJaxrsServer.class, "container");
|
|
||||||
Reflections.setAccessible(containerField);
|
|
||||||
ServletContainer container = (ServletContainer) Reflections.getFieldValue(containerField, undertow);
|
|
||||||
|
|
||||||
DeploymentManager deploymentMgr = container.getDeployment(archive.getName());
|
|
||||||
if (deploymentMgr != null) {
|
|
||||||
DeploymentInfo deployment = deploymentMgr.getDeployment().getDeploymentInfo();
|
|
||||||
|
|
||||||
try {
|
|
||||||
deploymentMgr.stop();
|
|
||||||
} catch (ServletException se) {
|
|
||||||
throw new DeploymentException(se.getMessage(), se);
|
|
||||||
}
|
|
||||||
|
|
||||||
deploymentMgr.undeploy();
|
|
||||||
|
|
||||||
Field rootField = Reflections.findDeclaredField(UndertowJaxrsServer.class, "root");
|
|
||||||
Reflections.setAccessible(rootField);
|
|
||||||
PathHandler root = (PathHandler) Reflections.getFieldValue(rootField, undertow);
|
|
||||||
|
|
||||||
String path = deployedArchivesToContextPath.get(archive.getName());
|
|
||||||
root.removePrefixPath(path);
|
|
||||||
|
|
||||||
container.removeDeployment(deployment);
|
|
||||||
} else {
|
|
||||||
log.warnf("Deployment '%s' not found", archive.getName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void deploy(Descriptor descriptor) throws DeploymentException {
|
|
||||||
throw new UnsupportedOperationException("Not implemented");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void undeploy(Descriptor descriptor) throws DeploymentException {
|
|
||||||
throw new UnsupportedOperationException("Not implemented");
|
|
||||||
}
|
|
||||||
|
|
||||||
private HTTPContext createHttpContextForDeploymentInfo(DeploymentInfo deploymentInfo) {
|
|
||||||
HTTPContext httpContext = new HTTPContext(configuration.getBindAddress(), configuration.getBindHttpPort());
|
|
||||||
final Map<String, ServletInfo> servlets = deploymentInfo.getServlets();
|
|
||||||
final Collection<ServletInfo> servletsInfo = servlets.values();
|
|
||||||
for (ServletInfo servletInfo : servletsInfo) {
|
|
||||||
httpContext.add(new Servlet(servletInfo.getName(), deploymentInfo.getContextPath()));
|
|
||||||
}
|
|
||||||
return httpContext;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isJaxrsApp(WebArchive archive) throws DeploymentException {
|
|
||||||
if (! archive.contains("/WEB-INF/web.xml")) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
try (InputStream stream = archive.get("/WEB-INF/web.xml").getAsset().openStream()) {
|
|
||||||
return
|
|
||||||
IOUtils.toString(stream, Charset.forName("UTF-8"))
|
|
||||||
.contains(Application.class.getName());
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new DeploymentException("Unable to read archive.", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private ResteasyDeployment discoverPathAnnotatedClasses(WebArchive webArchive) {
|
|
||||||
//take all classes from war and add those with @Path annotation to RestSamlApplicationConfig
|
|
||||||
Set<Class<?>> classes = webArchive.getContent(archivePath ->
|
|
||||||
archivePath.get().startsWith("/WEB-INF/classes/") &&
|
|
||||||
archivePath.get().endsWith(".class")
|
|
||||||
).values().stream()
|
|
||||||
.filter(node -> node.getAsset() instanceof ClassAsset)
|
|
||||||
.map(node -> ((ClassAsset)node.getAsset()).getSource())
|
|
||||||
.filter(clazz -> clazz.isAnnotationPresent(Path.class))
|
|
||||||
.collect(Collectors.toSet());
|
|
||||||
|
|
||||||
ResteasyDeployment deployment = new ResteasyDeploymentImpl();
|
|
||||||
deployment.setApplication(new RestSamlApplicationConfig(classes));
|
|
||||||
return deployment;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,39 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2018 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.undertow;
|
|
||||||
|
|
||||||
import org.jboss.arquillian.container.spi.client.container.DeployableContainer;
|
|
||||||
import org.jboss.arquillian.container.test.spi.client.deployment.ApplicationArchiveProcessor;
|
|
||||||
import org.jboss.arquillian.core.spi.LoadableExtension;
|
|
||||||
import org.keycloak.testsuite.arquillian.undertow.container.UndertowDeploymentArchiveProcessor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author <a href="mailto:vramik@redhat.com">Vlasta Ramik</a>
|
|
||||||
*/
|
|
||||||
public class UndertowAppServerArquillianExtension implements LoadableExtension {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void register(ExtensionBuilder builder) {
|
|
||||||
builder
|
|
||||||
.service(DeployableContainer.class, UndertowAppServer.class)
|
|
||||||
.service(ApplicationArchiveProcessor.class, UndertowDeploymentArchiveProcessor.class);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,48 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2018 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.undertow;
|
|
||||||
|
|
||||||
import org.arquillian.undertow.UndertowContainerConfiguration;
|
|
||||||
import org.jboss.arquillian.container.spi.ConfigurationException;
|
|
||||||
import org.jboss.logging.Logger;
|
|
||||||
|
|
||||||
public class UndertowAppServerConfiguration extends UndertowContainerConfiguration {
|
|
||||||
|
|
||||||
protected static final Logger log = Logger.getLogger(UndertowAppServerConfiguration.class);
|
|
||||||
|
|
||||||
private int bindHttpPortOffset = 0;
|
|
||||||
|
|
||||||
public int getBindHttpPortOffset() {
|
|
||||||
return bindHttpPortOffset;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setBindHttpPortOffset(int bindHttpPortOffset) {
|
|
||||||
this.bindHttpPortOffset = bindHttpPortOffset;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void validate() throws ConfigurationException {
|
|
||||||
super.validate();
|
|
||||||
|
|
||||||
int basePort = getBindHttpPort();
|
|
||||||
int newPort = basePort + bindHttpPortOffset;
|
|
||||||
setBindHttpPort(newPort);
|
|
||||||
log.info("App server undertow will listen on port: " + newPort);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,85 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2018 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.undertow.container;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import org.jboss.shrinkwrap.descriptor.spi.node.Node;
|
|
||||||
import org.keycloak.testsuite.arquillian.undertow.UndertowAppServer;
|
|
||||||
import org.keycloak.testsuite.arquillian.container.AppServerContainerProvider;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author <a href="mailto:vramik@redhat.com">Vlasta Ramik</a>
|
|
||||||
*/
|
|
||||||
public class UndertowAppServerProvider implements AppServerContainerProvider {
|
|
||||||
|
|
||||||
private Node configuration;
|
|
||||||
private static final String containerName = "undertow";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName() {
|
|
||||||
return containerName;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Node> getContainers() {
|
|
||||||
List<Node> containers = new ArrayList<>();
|
|
||||||
|
|
||||||
containers.add(standaloneContainer());
|
|
||||||
|
|
||||||
//not supported yet
|
|
||||||
// containers.add(haNodeContainer(1));
|
|
||||||
// containers.add(haNodeContainer(2));
|
|
||||||
|
|
||||||
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("bindAddress", "0.0.0.0");
|
|
||||||
createChild("bindHttpPort", "8280");
|
|
||||||
createChild("adapterImplClass", UndertowAppServer.class.getName());
|
|
||||||
|
|
||||||
return container;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Node haNodeContainer(int number) {
|
|
||||||
Node container = new Node("container");
|
|
||||||
container.attribute("mode", "manual");
|
|
||||||
container.attribute("qualifier", AppServerContainerProvider.APP_SERVER + "-" + containerName + "-ha-node-" + number);
|
|
||||||
|
|
||||||
configuration = container.createChild("configuration");
|
|
||||||
createChild("enabled", "true");
|
|
||||||
createChild("bindAddress", "localhost");
|
|
||||||
createChild("bindHttpPort", "8280");
|
|
||||||
createChild("bindHttpPortOffset", Integer.toString(number));
|
|
||||||
createChild("adapterImplClass", UndertowAppServer.class.getName());
|
|
||||||
|
|
||||||
return container;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,67 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2018 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.undertow.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.arquillian.DeploymentArchiveProcessorUtils;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:vramik@redhat.com">Vlasta Ramik</a>
|
|
||||||
*/
|
|
||||||
public class UndertowDeploymentArchiveProcessor implements ApplicationArchiveProcessor {
|
|
||||||
|
|
||||||
private final Logger log = Logger.getLogger(UndertowDeploymentArchiveProcessor.class);
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void process(Archive<?> archive, TestClass testClass) {
|
|
||||||
if (DeploymentArchiveProcessorUtils.checkRunOnServerDeployment(archive)) return;
|
|
||||||
if (!System.getProperty("app.server", "undertow").equals("undertow")) return;
|
|
||||||
|
|
||||||
modifyWebXML(archive, testClass);
|
|
||||||
|
|
||||||
modifyOIDCAdapterConfig(archive, DeploymentArchiveProcessorUtils.ADAPTER_CONFIG_PATH);
|
|
||||||
|
|
||||||
modifySAMLAdapterConfig(archive, DeploymentArchiveProcessorUtils.SAML_ADAPTER_CONFIG_PATH);
|
|
||||||
modifySAMLAdapterConfig(archive, DeploymentArchiveProcessorUtils.SAML_ADAPTER_CONFIG_PATH_TENANT1);
|
|
||||||
modifySAMLAdapterConfig(archive, DeploymentArchiveProcessorUtils.SAML_ADAPTER_CONFIG_PATH_TENANT2);
|
|
||||||
|
|
||||||
modifyOIDCAdapterConfig(archive, DeploymentArchiveProcessorUtils.ADAPTER_CONFIG_PATH_JS);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void modifyWebXML(Archive<?> archive, TestClass testClass) {
|
|
||||||
if (!archive.contains(DeploymentArchiveProcessorUtils.WEBXML_PATH)) return;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void modifyOIDCAdapterConfig(Archive<?> archive, String adapterConfigPath) {
|
|
||||||
if (!archive.contains(adapterConfigPath)) return;
|
|
||||||
|
|
||||||
log.debug("Modifying adapter config " + adapterConfigPath + " in " + archive.getName());
|
|
||||||
|
|
||||||
DeploymentArchiveProcessorUtils.modifyOIDCAdapterConfig(archive, adapterConfigPath);
|
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,47 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2018 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.undertow.saml.util;
|
|
||||||
|
|
||||||
import java.util.Set;
|
|
||||||
import jakarta.ws.rs.core.Application;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Wildfly JAX-RS Integration has support for scanning deployment for annotations.
|
|
||||||
*
|
|
||||||
* https://github.com/wildfly/wildfly/blob/14.0.1.Final/jaxrs/src/main/java/org/jboss/as/jaxrs/deployment/JaxrsAnnotationProcessor.java
|
|
||||||
*
|
|
||||||
* On undertow we have to set Application Class manually:
|
|
||||||
*
|
|
||||||
* ResteasyDeployment deployment = new ResteasyDeployment();
|
|
||||||
* deployment.setApplication(application);
|
|
||||||
*
|
|
||||||
* @author vramik
|
|
||||||
*/
|
|
||||||
public class RestSamlApplicationConfig extends Application {
|
|
||||||
|
|
||||||
private final Set<Class<?>> classes;
|
|
||||||
|
|
||||||
public RestSamlApplicationConfig(Set<Class<?>> classes) {
|
|
||||||
this.classes = classes;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Set<Class<?>> getClasses() {
|
|
||||||
return classes;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1 +0,0 @@
|
||||||
org.keycloak.testsuite.arquillian.undertow.UndertowAppServerArquillianExtension
|
|
|
@ -1 +0,0 @@
|
||||||
org.keycloak.testsuite.arquillian.undertow.container.UndertowAppServerProvider
|
|
|
@ -476,26 +476,6 @@
|
||||||
</build>
|
</build>
|
||||||
</profile>
|
</profile>
|
||||||
|
|
||||||
<profile>
|
|
||||||
<id>app-server-undertow</id>
|
|
||||||
<activation>
|
|
||||||
<property>
|
|
||||||
<name>app.server</name>
|
|
||||||
<value>undertow</value>
|
|
||||||
</property>
|
|
||||||
</activation>
|
|
||||||
<properties>
|
|
||||||
<app.server>undertow</app.server> <!--in case the profile is called directly-->
|
|
||||||
</properties>
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.keycloak.testsuite</groupId>
|
|
||||||
<artifactId>integration-arquillian-servers-app-server-undertow</artifactId>
|
|
||||||
<version>${project.version}</version>
|
|
||||||
<scope>runtime</scope>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
</profile>
|
|
||||||
<profile>
|
<profile>
|
||||||
<id>app-server-wildfly</id>
|
<id>app-server-wildfly</id>
|
||||||
<activation>
|
<activation>
|
||||||
|
|
|
@ -42,7 +42,6 @@ import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
import static org.keycloak.testsuite.util.SamlClient.Binding.POST;
|
import static org.keycloak.testsuite.util.SamlClient.Binding.POST;
|
||||||
|
|
||||||
|
|
||||||
@AppServerContainer(ContainerConstants.APP_SERVER_UNDERTOW)
|
|
||||||
@AppServerContainer(ContainerConstants.APP_SERVER_WILDFLY)
|
@AppServerContainer(ContainerConstants.APP_SERVER_WILDFLY)
|
||||||
@AppServerContainer(ContainerConstants.APP_SERVER_EAP)
|
@AppServerContainer(ContainerConstants.APP_SERVER_EAP)
|
||||||
@AppServerContainer(ContainerConstants.APP_SERVER_EAP8)
|
@AppServerContainer(ContainerConstants.APP_SERVER_EAP8)
|
||||||
|
|
|
@ -53,7 +53,6 @@ import static org.keycloak.testsuite.util.WaitUtils.waitUntilElement;
|
||||||
/**
|
/**
|
||||||
* @author mhajas
|
* @author mhajas
|
||||||
*/
|
*/
|
||||||
@AppServerContainer(ContainerConstants.APP_SERVER_UNDERTOW)
|
|
||||||
@AppServerContainer(ContainerConstants.APP_SERVER_WILDFLY)
|
@AppServerContainer(ContainerConstants.APP_SERVER_WILDFLY)
|
||||||
@AppServerContainer(ContainerConstants.APP_SERVER_EAP)
|
@AppServerContainer(ContainerConstants.APP_SERVER_EAP)
|
||||||
@AppServerContainer(ContainerConstants.APP_SERVER_EAP8)
|
@AppServerContainer(ContainerConstants.APP_SERVER_EAP8)
|
||||||
|
|
|
@ -49,7 +49,6 @@ import static org.keycloak.testsuite.util.SamlClient.Binding.REDIRECT;
|
||||||
*
|
*
|
||||||
* @author hmlnarik
|
* @author hmlnarik
|
||||||
*/
|
*/
|
||||||
@AppServerContainer(ContainerConstants.APP_SERVER_UNDERTOW)
|
|
||||||
@AppServerContainer(ContainerConstants.APP_SERVER_WILDFLY)
|
@AppServerContainer(ContainerConstants.APP_SERVER_WILDFLY)
|
||||||
@AppServerContainer(ContainerConstants.APP_SERVER_EAP)
|
@AppServerContainer(ContainerConstants.APP_SERVER_EAP)
|
||||||
@AppServerContainer(ContainerConstants.APP_SERVER_EAP8)
|
@AppServerContainer(ContainerConstants.APP_SERVER_EAP8)
|
||||||
|
|
|
@ -192,7 +192,6 @@ import org.xml.sax.SAXException;
|
||||||
/**
|
/**
|
||||||
* @author mhajas
|
* @author mhajas
|
||||||
*/
|
*/
|
||||||
@AppServerContainer(ContainerConstants.APP_SERVER_UNDERTOW)
|
|
||||||
@AppServerContainer(ContainerConstants.APP_SERVER_WILDFLY)
|
@AppServerContainer(ContainerConstants.APP_SERVER_WILDFLY)
|
||||||
@AppServerContainer(ContainerConstants.APP_SERVER_EAP)
|
@AppServerContainer(ContainerConstants.APP_SERVER_EAP)
|
||||||
@AppServerContainer(ContainerConstants.APP_SERVER_EAP8)
|
@AppServerContainer(ContainerConstants.APP_SERVER_EAP8)
|
||||||
|
|
|
@ -32,7 +32,6 @@ import static org.keycloak.testsuite.saml.AbstractSamlTest.REALM_NAME;
|
||||||
import static org.keycloak.testsuite.util.Matchers.bodyHC;
|
import static org.keycloak.testsuite.util.Matchers.bodyHC;
|
||||||
|
|
||||||
|
|
||||||
@AppServerContainer(ContainerConstants.APP_SERVER_UNDERTOW)
|
|
||||||
@AppServerContainer(ContainerConstants.APP_SERVER_WILDFLY)
|
@AppServerContainer(ContainerConstants.APP_SERVER_WILDFLY)
|
||||||
@AppServerContainer(ContainerConstants.APP_SERVER_EAP)
|
@AppServerContainer(ContainerConstants.APP_SERVER_EAP)
|
||||||
@AppServerContainer(ContainerConstants.APP_SERVER_EAP8)
|
@AppServerContainer(ContainerConstants.APP_SERVER_EAP8)
|
||||||
|
|
|
@ -76,7 +76,6 @@ import static org.keycloak.testsuite.saml.AbstractSamlTest.REALM_SIGNING_CERTIFI
|
||||||
*
|
*
|
||||||
* @author hmlnarik
|
* @author hmlnarik
|
||||||
*/
|
*/
|
||||||
@AppServerContainer(ContainerConstants.APP_SERVER_UNDERTOW)
|
|
||||||
@AppServerContainer(ContainerConstants.APP_SERVER_WILDFLY)
|
@AppServerContainer(ContainerConstants.APP_SERVER_WILDFLY)
|
||||||
@AppServerContainer(ContainerConstants.APP_SERVER_EAP)
|
@AppServerContainer(ContainerConstants.APP_SERVER_EAP)
|
||||||
@AppServerContainer(ContainerConstants.APP_SERVER_EAP8)
|
@AppServerContainer(ContainerConstants.APP_SERVER_EAP8)
|
||||||
|
|
|
@ -33,7 +33,6 @@ import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
import static org.keycloak.testsuite.util.Matchers.bodyHC;
|
import static org.keycloak.testsuite.util.Matchers.bodyHC;
|
||||||
import static org.keycloak.testsuite.util.Matchers.statusCodeIsHC;
|
import static org.keycloak.testsuite.util.Matchers.statusCodeIsHC;
|
||||||
|
|
||||||
@AppServerContainer(ContainerConstants.APP_SERVER_UNDERTOW)
|
|
||||||
@AppServerContainer(ContainerConstants.APP_SERVER_WILDFLY)
|
@AppServerContainer(ContainerConstants.APP_SERVER_WILDFLY)
|
||||||
@AppServerContainer(ContainerConstants.APP_SERVER_EAP)
|
@AppServerContainer(ContainerConstants.APP_SERVER_EAP)
|
||||||
@AppServerContainer(ContainerConstants.APP_SERVER_EAP8)
|
@AppServerContainer(ContainerConstants.APP_SERVER_EAP8)
|
||||||
|
|
|
@ -1,149 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2018 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.undertow.servlet;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import org.jboss.arquillian.container.test.api.Deployment;
|
|
||||||
import org.jboss.arquillian.graphene.page.Page;
|
|
||||||
import org.jboss.shrinkwrap.api.spec.WebArchive;
|
|
||||||
import org.junit.Assert;
|
|
||||||
import org.junit.Ignore;
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.keycloak.representations.idm.RealmRepresentation;
|
|
||||||
import org.keycloak.testsuite.adapter.AbstractServletsAdapterTest;
|
|
||||||
import org.keycloak.testsuite.adapter.filter.AdapterActionsFilter;
|
|
||||||
import org.keycloak.testsuite.adapter.page.CustomerDb;
|
|
||||||
import org.keycloak.testsuite.adapter.page.CustomerPortal;
|
|
||||||
import org.keycloak.testsuite.adapter.page.ProductPortal;
|
|
||||||
import org.keycloak.testsuite.adapter.servlet.CustomerDatabaseServlet;
|
|
||||||
import org.keycloak.testsuite.adapter.servlet.CustomerServlet;
|
|
||||||
import org.keycloak.testsuite.adapter.servlet.ErrorServlet;
|
|
||||||
import org.keycloak.testsuite.adapter.servlet.ProductServlet;
|
|
||||||
import org.keycloak.testsuite.adapter.servlet.ServletTestUtils;
|
|
||||||
import org.keycloak.testsuite.arquillian.annotation.AppServerContainer;
|
|
||||||
import org.keycloak.testsuite.util.AccountHelper;
|
|
||||||
|
|
||||||
import static org.keycloak.testsuite.arquillian.AuthServerTestEnricher.AUTH_SERVER_CONTAINER_DEFAULT;
|
|
||||||
import static org.keycloak.testsuite.auth.page.AuthRealm.DEMO;
|
|
||||||
import static org.keycloak.testsuite.utils.io.IOUtil.loadRealm;
|
|
||||||
import static org.keycloak.testsuite.util.URLAssert.assertCurrentUrlEquals;
|
|
||||||
import static org.keycloak.testsuite.util.URLAssert.assertCurrentUrlStartsWithLoginUrlOf;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Also tests relative URIs in the adapter and valid redirect uris.
|
|
||||||
* Also tests adapters not configured with public key
|
|
||||||
*
|
|
||||||
* note: migrated from old testsuite
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:bburke@redhat.com">Bill Burke</a>
|
|
||||||
*/
|
|
||||||
@AppServerContainer(AUTH_SERVER_CONTAINER_DEFAULT)
|
|
||||||
@Ignore(value = "Need to resolve default relative scenario when running on non-undertow")
|
|
||||||
public class UndertowRelaviteUriAdapterTest extends AbstractServletsAdapterTest {
|
|
||||||
|
|
||||||
@Page
|
|
||||||
private CustomerPortal customerPortal;
|
|
||||||
@Page
|
|
||||||
private ProductPortal productPortal;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addAdapterTestRealms(List<RealmRepresentation> testRealms) {
|
|
||||||
testRealms.add(loadRealm("/adapter-test/demorealm-relative.json"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deployment(name = CustomerPortal.DEPLOYMENT_NAME)
|
|
||||||
protected static WebArchive customerPortal() {
|
|
||||||
return servletDeployment(CustomerPortal.DEPLOYMENT_NAME, "keycloak-relative.json", CustomerServlet.class, ErrorServlet.class, ServletTestUtils.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deployment(name = CustomerDb.DEPLOYMENT_NAME)
|
|
||||||
protected static WebArchive customerDb() {
|
|
||||||
return servletDeployment(CustomerDb.DEPLOYMENT_NAME, "keycloak-relative.json", AdapterActionsFilter.class, CustomerDatabaseServlet.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deployment(name = ProductPortal.DEPLOYMENT_NAME)
|
|
||||||
protected static WebArchive productPortal() {
|
|
||||||
return servletDeployment(ProductPortal.DEPLOYMENT_NAME, "keycloak-relative.json", ProductServlet.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testLoginSSOAndLogout() {
|
|
||||||
// test login to customer-portal which does a bearer request to customer-db
|
|
||||||
customerPortal.navigateTo();
|
|
||||||
assertCurrentUrlStartsWithLoginUrlOf(testRealmPage);
|
|
||||||
testRealmLoginPage.form().login("bburke@redhat.com", "password");
|
|
||||||
assertCurrentUrlEquals(customerPortal);
|
|
||||||
String pageSource = driver.getPageSource();
|
|
||||||
Assert.assertTrue(pageSource.contains("Bill Burke") && pageSource.contains("Stian Thorgersen"));
|
|
||||||
|
|
||||||
// test SSO
|
|
||||||
productPortal.navigateTo();
|
|
||||||
assertCurrentUrlEquals(productPortal);
|
|
||||||
pageSource = driver.getPageSource();
|
|
||||||
Assert.assertTrue(pageSource.contains("iPhone") && pageSource.contains("iPad"));
|
|
||||||
|
|
||||||
// View stats
|
|
||||||
List<Map<String, String>> stats = adminClient.realm(DEMO).getClientSessionStats();
|
|
||||||
Map<String, String> customerPortalStats = null;
|
|
||||||
Map<String, String> productPortalStats = null;
|
|
||||||
for (Map<String, String> s : stats) {
|
|
||||||
switch (s.get("clientId")) {
|
|
||||||
case "customer-portal":
|
|
||||||
customerPortalStats = s;
|
|
||||||
break;
|
|
||||||
case "product-portal":
|
|
||||||
productPortalStats = s;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Assert.assertEquals(1, Integer.parseInt(customerPortalStats.get("active")));
|
|
||||||
Assert.assertEquals(1, Integer.parseInt(productPortalStats.get("active")));
|
|
||||||
|
|
||||||
// test logout
|
|
||||||
AccountHelper.logout(testRealmResource(), testUser.getUsername());
|
|
||||||
|
|
||||||
assertCurrentUrlStartsWithLoginUrlOf(testRealmPage);
|
|
||||||
productPortal.navigateTo();
|
|
||||||
assertCurrentUrlStartsWithLoginUrlOf(testRealmPage);
|
|
||||||
customerPortal.navigateTo();
|
|
||||||
assertCurrentUrlStartsWithLoginUrlOf(testRealmPage);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testServletRequestLogout() {
|
|
||||||
customerPortal.navigateTo();
|
|
||||||
assertCurrentUrlStartsWithLoginUrlOf(testRealmPage);
|
|
||||||
testRealmLoginPage.form().login("bburke@redhat.com", "password");
|
|
||||||
assertCurrentUrlEquals(customerPortal);
|
|
||||||
Assert.assertTrue(driver.getPageSource().contains("Bill Burke"));
|
|
||||||
|
|
||||||
|
|
||||||
productPortal.navigateTo();
|
|
||||||
assertCurrentUrlEquals(productPortal);
|
|
||||||
Assert.assertTrue(driver.getPageSource().contains("iPhone"));
|
|
||||||
|
|
||||||
// test logout
|
|
||||||
driver.navigate().to(customerPortal.logout().toASCIIString());
|
|
||||||
Assert.assertTrue(driver.getPageSource().contains("servlet logout ok"));
|
|
||||||
|
|
||||||
customerPortal.navigateTo();
|
|
||||||
assertCurrentUrlStartsWithLoginUrlOf(testRealmPage);
|
|
||||||
productPortal.navigateTo();
|
|
||||||
assertCurrentUrlStartsWithLoginUrlOf(testRealmPage);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -19,8 +19,6 @@ package org.keycloak.testsuite.utils.arquillian;
|
||||||
public interface ContainerConstants {
|
public interface ContainerConstants {
|
||||||
String APP_SERVER_PREFIX = "app-server-";
|
String APP_SERVER_PREFIX = "app-server-";
|
||||||
|
|
||||||
String APP_SERVER_UNDERTOW = APP_SERVER_PREFIX + "undertow";
|
|
||||||
|
|
||||||
String APP_SERVER_WILDFLY = APP_SERVER_PREFIX + "wildfly";
|
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";
|
String APP_SERVER_WILDFLY_CLUSTER = APP_SERVER_WILDFLY + "-ha-node-1;" + APP_SERVER_WILDFLY + "-ha-node-2";
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue