KEYCLOAK-7213 Make example tests running on app-server-undertow
This commit is contained in:
parent
42553cdc44
commit
ccba07a5c0
15 changed files with 75 additions and 19 deletions
|
@ -23,11 +23,16 @@ 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.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import javax.servlet.ServletException;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.arquillian.undertow.UndertowContainerConfiguration;
|
||||
import org.jboss.arquillian.container.spi.client.container.DeployableContainer;
|
||||
import org.jboss.arquillian.container.spi.client.container.DeploymentException;
|
||||
|
@ -91,6 +96,21 @@ public class UndertowAppServer implements DeployableContainer<UndertowAppServerC
|
|||
@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();
|
||||
|
|
|
@ -136,6 +136,12 @@
|
|||
<groupId>org.wildfly.arquillian</groupId>
|
||||
<artifactId>wildfly-arquillian-container-managed</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.keycloak.testsuite</groupId>
|
||||
<artifactId>photoz-restful-api</artifactId>
|
||||
<type>war</type>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
|
|
@ -138,7 +138,7 @@ public abstract class AbstractBaseServletAuthzAdapterTest extends AbstractExampl
|
|||
}
|
||||
|
||||
protected void navigateTo() {
|
||||
this.driver.navigate().to(getResourceServerUrl());
|
||||
this.driver.navigate().to(getResourceServerUrl() + "/");
|
||||
WaitUtils.waitUntilElement(By.xpath("//a[text() = 'Dynamic Menu']"));
|
||||
}
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
*/
|
||||
package org.keycloak.testsuite.adapter.example.authorization;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.keycloak.admin.client.resource.ClientPoliciesResource;
|
||||
import org.keycloak.admin.client.resource.RealmResource;
|
||||
|
@ -197,6 +198,7 @@ public abstract class AbstractServletAuthzAdapterTest extends AbstractBaseServle
|
|||
|
||||
//KEYCLOAK-3830
|
||||
@Test
|
||||
@Ignore // Ignored because: KEYCLOAK-7941
|
||||
public void testAccessPublicResource() throws Exception {
|
||||
performTests(() -> {
|
||||
driver.navigate().to(getResourceServerUrl() + "/public-html.html");
|
||||
|
|
|
@ -50,6 +50,7 @@ import static org.keycloak.testsuite.utils.io.IOUtil.loadRealm;
|
|||
@AppServerContainer(ContainerConstants.APP_SERVER_WILDFLY10)
|
||||
@AppServerContainer(ContainerConstants.APP_SERVER_EAP)
|
||||
@AppServerContainer(ContainerConstants.APP_SERVER_EAP6)
|
||||
@AppServerContainer(ContainerConstants.APP_SERVER_UNDERTOW)
|
||||
@AppServerContainer(ContainerConstants.APP_SERVER_EAP71)
|
||||
public class DefaultAuthzConfigAdapterTest extends AbstractExampleAdapterTest {
|
||||
|
||||
|
@ -104,7 +105,7 @@ public class DefaultAuthzConfigAdapterTest extends AbstractExampleAdapterTest {
|
|||
}
|
||||
|
||||
private void login() throws MalformedURLException {
|
||||
this.driver.navigate().to(getResourceServerUrl());
|
||||
this.driver.navigate().to(getResourceServerUrl() + "/");
|
||||
this.loginPage.form().login("alice", "alice");
|
||||
}
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@ import org.keycloak.testsuite.arquillian.containers.ContainerConstants;
|
|||
@AppServerContainer(ContainerConstants.APP_SERVER_WILDFLY10)
|
||||
@AppServerContainer(ContainerConstants.APP_SERVER_EAP)
|
||||
@AppServerContainer(ContainerConstants.APP_SERVER_EAP6)
|
||||
@AppServerContainer(ContainerConstants.APP_SERVER_UNDERTOW)
|
||||
@AppServerContainer(ContainerConstants.APP_SERVER_EAP71)
|
||||
public class PermissiveModeAdapterTest extends AbstractBaseServletAuthzAdapterTest {
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@ import org.keycloak.testsuite.arquillian.containers.ContainerConstants;
|
|||
@AppServerContainer(ContainerConstants.APP_SERVER_WILDFLY10)
|
||||
@AppServerContainer(ContainerConstants.APP_SERVER_EAP)
|
||||
@AppServerContainer(ContainerConstants.APP_SERVER_EAP6)
|
||||
@AppServerContainer(ContainerConstants.APP_SERVER_UNDERTOW)
|
||||
@AppServerContainer(ContainerConstants.APP_SERVER_EAP71)
|
||||
public class ServletAuthzCIPAdapterTest extends AbstractServletAuthzAdapterTest {
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@ import org.keycloak.testsuite.arquillian.containers.ContainerConstants;
|
|||
@AppServerContainer(ContainerConstants.APP_SERVER_WILDFLY10)
|
||||
@AppServerContainer(ContainerConstants.APP_SERVER_EAP)
|
||||
@AppServerContainer(ContainerConstants.APP_SERVER_EAP6)
|
||||
@AppServerContainer(ContainerConstants.APP_SERVER_UNDERTOW)
|
||||
@AppServerContainer(ContainerConstants.APP_SERVER_EAP71)
|
||||
public class ServletAuthzCacheDisabledAdapterTest extends AbstractServletAuthzAdapterTest {
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@ import org.keycloak.testsuite.arquillian.containers.ContainerConstants;
|
|||
@AppServerContainer(ContainerConstants.APP_SERVER_WILDFLY10)
|
||||
@AppServerContainer(ContainerConstants.APP_SERVER_EAP)
|
||||
@AppServerContainer(ContainerConstants.APP_SERVER_EAP6)
|
||||
@AppServerContainer(ContainerConstants.APP_SERVER_UNDERTOW)
|
||||
@AppServerContainer(ContainerConstants.APP_SERVER_EAP71)
|
||||
public class ServletAuthzCacheLifespanAdapterTest extends AbstractServletAuthzAdapterTest {
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@ import org.keycloak.testsuite.arquillian.containers.ContainerConstants;
|
|||
@AppServerContainer(ContainerConstants.APP_SERVER_WILDFLY10)
|
||||
@AppServerContainer(ContainerConstants.APP_SERVER_EAP)
|
||||
@AppServerContainer(ContainerConstants.APP_SERVER_EAP6)
|
||||
@AppServerContainer(ContainerConstants.APP_SERVER_UNDERTOW)
|
||||
@AppServerContainer(ContainerConstants.APP_SERVER_EAP71)
|
||||
public class ServletAuthzLazyLoadPathsAdapterTest extends AbstractServletAuthzAdapterTest {
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@ import org.keycloak.testsuite.arquillian.containers.ContainerConstants;
|
|||
@AppServerContainer(ContainerConstants.APP_SERVER_WILDFLY10)
|
||||
@AppServerContainer(ContainerConstants.APP_SERVER_EAP)
|
||||
@AppServerContainer(ContainerConstants.APP_SERVER_EAP6)
|
||||
@AppServerContainer(ContainerConstants.APP_SERVER_UNDERTOW)
|
||||
@AppServerContainer(ContainerConstants.APP_SERVER_EAP71)
|
||||
public class ServletAuthzNoLazyLoadPathsAdapterTest extends AbstractServletAuthzAdapterTest {
|
||||
|
||||
|
|
|
@ -56,6 +56,7 @@ import org.openqa.selenium.By;
|
|||
@AppServerContainer(ContainerConstants.APP_SERVER_WILDFLY10)
|
||||
@AppServerContainer(ContainerConstants.APP_SERVER_EAP)
|
||||
@AppServerContainer(ContainerConstants.APP_SERVER_EAP6)
|
||||
@AppServerContainer(ContainerConstants.APP_SERVER_UNDERTOW)
|
||||
@AppServerContainer(ContainerConstants.APP_SERVER_EAP71)
|
||||
public class ServletPolicyEnforcerTest extends AbstractExampleAdapterTest {
|
||||
|
||||
|
@ -545,7 +546,7 @@ public class ServletPolicyEnforcerTest extends AbstractExampleAdapterTest {
|
|||
}
|
||||
|
||||
private void navigateTo() {
|
||||
this.driver.navigate().to(getResourceServerUrl());
|
||||
this.driver.navigate().to(getResourceServerUrl() + "/");
|
||||
WaitUtils.waitUntilElement(By.xpath("//p[text() = 'Welcome']"));
|
||||
}
|
||||
|
||||
|
|
|
@ -240,7 +240,6 @@
|
|||
<goal>copy</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<skip>${app.server.skip.unpack}</skip>
|
||||
<artifactItems>
|
||||
<artifactItem>
|
||||
<groupId>org.keycloak.testsuite</groupId>
|
||||
|
@ -296,7 +295,6 @@
|
|||
<goal>unpack</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<skip>${app.server.skip.unpack}</skip>
|
||||
<artifactItems>
|
||||
<artifactItem>
|
||||
<groupId>org.keycloak.testsuite</groupId>
|
||||
|
|
|
@ -65,5 +65,11 @@
|
|||
<artifactId>org.osgi.enterprise</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<!-- Ability to compile/run jsp on undertow -->
|
||||
<groupId>io.undertow.jastow</groupId>
|
||||
<artifactId>jastow</artifactId>
|
||||
<version>2.1.0.Final</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
|
@ -16,26 +16,17 @@
|
|||
*/
|
||||
package org.keycloak.testsuite.utils.undertow;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.net.URLStreamHandler;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.Servlet;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
|
||||
import io.undertow.UndertowMessages;
|
||||
import io.undertow.jsp.HackInstanceManager;
|
||||
import io.undertow.jsp.JspServletBuilder;
|
||||
import io.undertow.server.handlers.resource.Resource;
|
||||
import io.undertow.server.handlers.resource.ResourceChangeListener;
|
||||
import io.undertow.server.handlers.resource.ResourceManager;
|
||||
import io.undertow.server.handlers.resource.URLResource;
|
||||
import io.undertow.servlet.api.DeploymentInfo;
|
||||
import io.undertow.servlet.api.ServletInfo;
|
||||
import org.apache.jasper.deploy.JspPropertyGroup;
|
||||
import org.apache.jasper.deploy.TagLibraryInfo;
|
||||
import org.arquillian.undertow.UndertowContainerConfiguration;
|
||||
import org.jboss.logging.Logger;
|
||||
import org.jboss.shrinkwrap.api.Archive;
|
||||
|
@ -46,6 +37,19 @@ import org.jboss.shrinkwrap.api.spec.WebArchive;
|
|||
import org.w3c.dom.Document;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
import javax.servlet.Servlet;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.net.URLStreamHandler;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a>
|
||||
*/
|
||||
|
@ -55,7 +59,13 @@ public class UndertowDeployerHelper {
|
|||
|
||||
public DeploymentInfo getDeploymentInfo(UndertowContainerConfiguration config, WebArchive archive) {
|
||||
String archiveName = archive.getName();
|
||||
String contextPath = "/" + archive.getName().substring(0, archive.getName().lastIndexOf('.'));
|
||||
|
||||
String appName = archive.getName().substring(0, archive.getName().lastIndexOf('.'));
|
||||
if (appName.contains(System.getProperty("project.version"))) {
|
||||
appName = archive.getName().substring(0, archive.getName().lastIndexOf("-" + System.getProperty("project.version")));
|
||||
}
|
||||
|
||||
String contextPath = "/" + appName;
|
||||
String appContextUrl = "http://" + config.getBindAddress() + ":" + config.getBindHttpPort() + contextPath;
|
||||
|
||||
try {
|
||||
|
@ -75,6 +85,12 @@ public class UndertowDeployerHelper {
|
|||
new SimpleWebXmlParser().parseWebXml(webXml, di);
|
||||
}
|
||||
|
||||
di.addServlet(JspServletBuilder.createServlet("Default Jsp Servlet", "*.jsp"));
|
||||
|
||||
di.addWelcomePages("index.html", "index.jsp");
|
||||
|
||||
JspServletBuilder.setupDeployment(di, new HashMap<String, JspPropertyGroup>(), new HashMap<String, TagLibraryInfo>(), new HackInstanceManager());
|
||||
|
||||
addAnnotatedServlets(di, archive);
|
||||
|
||||
return di;
|
||||
|
|
Loading…
Reference in a new issue