KEYCLOAK-6546 Run filter test on WebLogic and WebSphere
This commit is contained in:
parent
bde9210fa3
commit
fe1c447d9a
12 changed files with 146 additions and 37 deletions
|
@ -119,7 +119,24 @@ public class DeploymentArchiveProcessor implements ApplicationArchiveProcessor {
|
|||
.addClass(org.keycloak.testsuite.arquillian.annotation.AppServerContainer.class)
|
||||
.addClass(org.keycloak.testsuite.arquillian.annotation.UseServletFilter.class);
|
||||
}
|
||||
|
||||
|
||||
if (isWASAppServer(testClass.getJavaClass())) {
|
||||
// {
|
||||
MavenResolverSystem resolver = Maven.resolver();
|
||||
MavenFormatStage dependencies = resolver
|
||||
.loadPomFromFile("pom.xml")
|
||||
.importTestDependencies()
|
||||
.resolve("org.apache.httpcomponents:httpclient")
|
||||
.withTransitivity();
|
||||
|
||||
((WebArchive) archive)
|
||||
.addAsLibraries(dependencies.asFile())
|
||||
.addClass(org.keycloak.testsuite.arquillian.annotation.AppServerContainer.class)
|
||||
.addClass(org.keycloak.testsuite.arquillian.annotation.UseServletFilter.class);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static boolean isAdapterTest(TestClass testClass) {
|
||||
|
@ -294,30 +311,6 @@ public class DeploymentArchiveProcessor implements ApplicationArchiveProcessor {
|
|||
removeElementsFromDoc(webXmlDoc, "web-app", "security-constraint");
|
||||
removeElementsFromDoc(webXmlDoc, "web-app", "login-config");
|
||||
removeElementsFromDoc(webXmlDoc, "web-app", "security-role");
|
||||
|
||||
if (isWASAppServer(testClass.getJavaClass())) {
|
||||
removeElementsFromDoc(webXmlDoc, "web-app", "servlet-mapping");
|
||||
removeElementsFromDoc(webXmlDoc, "web-app", "servlet");
|
||||
}
|
||||
|
||||
if (isWLSAppServer(testClass.getJavaClass())) {
|
||||
|
||||
// add <servlet> tag in case it is missing
|
||||
NodeList nodes = webXmlDoc.getElementsByTagName("servlet");
|
||||
if (nodes.getLength() < 1) {
|
||||
Element servlet = webXmlDoc.createElement("servlet");
|
||||
Element servletName = webXmlDoc.createElement("servlet-name");
|
||||
Element servletClass = webXmlDoc.createElement("servlet-class");
|
||||
|
||||
servletName.setTextContent("javax.ws.rs.core.Application");
|
||||
servletClass.setTextContent(getServletClassName(archive));
|
||||
|
||||
servlet.appendChild(servletName);
|
||||
servlet.appendChild(servletClass);
|
||||
|
||||
appendChildInDocument(webXmlDoc, "web-app", servlet);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
archive.add(new StringAsset((documentToString(webXmlDoc))), WEBXML_PATH);
|
||||
|
|
|
@ -37,9 +37,9 @@ public abstract class AbstractPageWithInjectedUrl extends AbstractPage {
|
|||
}
|
||||
try {
|
||||
if(Boolean.parseBoolean(System.getProperty("app.server.ssl.required"))) {
|
||||
return new URL("https://localhost:" + System.getProperty("app.server.https.port", "8543") + "/" + url);
|
||||
return new URL("https://localhost:" + System.getProperty("app.server.https.port", "8643") + "/" + url);
|
||||
};
|
||||
return new URL("http://localhost:" + System.getProperty("app.server.http.port", "8180") + "/" + url);
|
||||
return new URL("http://localhost:" + System.getProperty("app.server.http.port", "8280") + "/" + url);
|
||||
} catch (MalformedURLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
|
|
@ -207,6 +207,7 @@ public abstract class AbstractSAMLServletsAdapterTest extends AbstractServletsAd
|
|||
protected SalesPostAutodetectServlet salesPostAutodetectServletPage;
|
||||
|
||||
public static final String FORBIDDEN_TEXT = "HTTP status code: 403";
|
||||
public static final String WEBSPHERE_FORBIDDEN_TEXT = "Error reported: 403";
|
||||
|
||||
@Deployment(name = BadClientSalesPostSigServlet.DEPLOYMENT_NAME)
|
||||
protected static WebArchive badClientSalesPostSig() {
|
||||
|
@ -354,7 +355,10 @@ public abstract class AbstractSAMLServletsAdapterTest extends AbstractServletsAd
|
|||
private void assertForbidden(AbstractPage page, String expectedNotContains) {
|
||||
page.navigateTo();
|
||||
waitUntilElement(By.xpath("//body")).text().not().contains(expectedNotContains);
|
||||
assertTrue(driver.getPageSource().contains("Forbidden") || driver.getPageSource().contains(FORBIDDEN_TEXT));
|
||||
//Different 403 status page on EAP and Wildfly
|
||||
assertTrue(driver.getPageSource().contains("Forbidden")
|
||||
|| driver.getPageSource().contains(FORBIDDEN_TEXT)
|
||||
|| driver.getPageSource().contains(WEBSPHERE_FORBIDDEN_TEXT)); // WebSphere
|
||||
}
|
||||
|
||||
private void assertSuccessfullyLoggedIn(AbstractPage page, String expectedText) {
|
||||
|
@ -368,7 +372,9 @@ public abstract class AbstractSAMLServletsAdapterTest extends AbstractServletsAd
|
|||
loginPage.form().login(username, password);
|
||||
waitUntilElement(By.xpath("//body")).text().not().contains(expectedNotContains);
|
||||
//Different 403 status page on EAP and Wildfly
|
||||
assertTrue(driver.getPageSource().contains("Forbidden") || driver.getPageSource().contains(FORBIDDEN_TEXT));
|
||||
assertTrue(driver.getPageSource().contains("Forbidden")
|
||||
|| driver.getPageSource().contains(FORBIDDEN_TEXT)
|
||||
|| driver.getPageSource().contains(WEBSPHERE_FORBIDDEN_TEXT)); // WebSphere
|
||||
}
|
||||
|
||||
private void assertSuccessfulLogin(AbstractPage page, UserRepresentation user, Login loginPage, String expectedString) {
|
||||
|
@ -460,7 +466,9 @@ public abstract class AbstractSAMLServletsAdapterTest extends AbstractServletsAd
|
|||
|
||||
waitUntilElement(By.xpath("//body")).text().not().contains("principal=");
|
||||
//Different 403 status page on EAP and Wildfly
|
||||
assertTrue(driver.getPageSource().contains("Forbidden") || driver.getPageSource().contains(FORBIDDEN_TEXT));
|
||||
assertTrue(driver.getPageSource().contains("Forbidden")
|
||||
|| driver.getPageSource().contains(FORBIDDEN_TEXT)
|
||||
|| driver.getPageSource().contains(WEBSPHERE_FORBIDDEN_TEXT)); // WebSphere
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -845,7 +853,10 @@ public abstract class AbstractSAMLServletsAdapterTest extends AbstractServletsAd
|
|||
samlidpInitiatedLoginPage.form().login("unauthorized", "password");
|
||||
|
||||
waitUntilElement(By.xpath("//body")).text().not().contains("bburke");
|
||||
assertTrue(driver.getPageSource().contains("Forbidden") || driver.getPageSource().contains(FORBIDDEN_TEXT));
|
||||
//Different 403 status page on EAP and Wildfly
|
||||
assertTrue(driver.getPageSource().contains("Forbidden")
|
||||
|| driver.getPageSource().contains(FORBIDDEN_TEXT)
|
||||
|| driver.getPageSource().contains(WEBSPHERE_FORBIDDEN_TEXT)); // WebSphere
|
||||
|
||||
assertForbidden(employee2ServletPage, "principal=");
|
||||
employee2ServletPage.logout();
|
||||
|
@ -1281,6 +1292,11 @@ public abstract class AbstractSAMLServletsAdapterTest extends AbstractServletsAd
|
|||
}
|
||||
|
||||
private void assertOnForbiddenPage() {
|
||||
waitUntilElement(By.xpath("//body")).text().contains(FORBIDDEN_TEXT);
|
||||
waitUntilElement(By.xpath("//body")).is().present();
|
||||
|
||||
//Different 403 status page on EAP and Wildfly
|
||||
assertTrue(driver.getPageSource().contains("Forbidden")
|
||||
|| driver.getPageSource().contains(FORBIDDEN_TEXT)
|
||||
|| driver.getPageSource().contains(WEBSPHERE_FORBIDDEN_TEXT)); // WebSphere
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,6 +23,11 @@
|
|||
|
||||
<module-name>%CONTEXT_PATH%</module-name>
|
||||
|
||||
<servlet>
|
||||
<servlet-name>javax.ws.rs.core.Application</servlet-name>
|
||||
<load-on-startup>1</load-on-startup>
|
||||
</servlet>
|
||||
|
||||
<servlet-mapping>
|
||||
<servlet-name>javax.ws.rs.core.Application</servlet-name>
|
||||
<url-pattern>/*</url-pattern>
|
||||
|
|
|
@ -23,6 +23,10 @@
|
|||
|
||||
<module-name>%CONTEXT_PATH%</module-name>
|
||||
|
||||
<servlet>
|
||||
<servlet-name>javax.ws.rs.core.Application</servlet-name>
|
||||
<load-on-startup>1</load-on-startup>
|
||||
</servlet>
|
||||
<servlet-mapping>
|
||||
<servlet-name>javax.ws.rs.core.Application</servlet-name>
|
||||
<url-pattern>/*</url-pattern>
|
||||
|
|
|
@ -70,6 +70,8 @@
|
|||
<settings.path></settings.path>
|
||||
<maven.repo.local></maven.repo.local>
|
||||
<repo.url></repo.url>
|
||||
<wl.password></wl.password>
|
||||
<wl.home></wl.home>
|
||||
|
||||
<adapter.test.props>
|
||||
-Dapp.server.base.url=http://localhost:${app.server.http.port}
|
||||
|
@ -83,6 +85,8 @@
|
|||
-Dkie.maven.settings.custom=${settings.path}
|
||||
-Dkie.maven.repo.local=${maven.repo.local}
|
||||
-Drepo.url=${repo.url}
|
||||
-Dwl.password=${wl.password}
|
||||
-Dwl.home=${wl.home}
|
||||
</adapter.test.props>
|
||||
|
||||
<app.server.home>${containers.home}/app-server-${app.server}</app.server.home>
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
<property name="remoteServerAddress">localhost</property>
|
||||
<property name="remoteServerSoapPort">8880</property>
|
||||
<property name="securityEnabled">false</property>
|
||||
<property name="username">admin</property>
|
||||
<property name="username">wsadmin</property>
|
||||
<property name="adapterImplClass">org.jboss.arquillian.container.was.remote_8_5.WebSphereRemoteContainer</property>
|
||||
</configuration>
|
||||
</container>
|
||||
|
@ -50,4 +50,4 @@
|
|||
</xsl:template>
|
||||
|
||||
|
||||
</xsl:stylesheet>
|
||||
</xsl:stylesheet>
|
||||
|
|
|
@ -1,9 +1,39 @@
|
|||
package org.keycloak.testsuite.adapter;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.keycloak.testsuite.adapter.servlet.AbstractSAMLFilterServletAdapterTest;
|
||||
import org.keycloak.testsuite.arquillian.annotation.AppServerContainer;
|
||||
|
||||
@AppServerContainer("app-server-was")
|
||||
public class WASSAMLFilterAdapterTest extends AbstractSAMLFilterServletAdapterTest {
|
||||
@Override
|
||||
@Ignore // KEYCLOAK-6152
|
||||
@Test
|
||||
public void testPostBadAssertionSignature() {}
|
||||
|
||||
@Override
|
||||
@Ignore // KEYCLOAK-6152
|
||||
@Test
|
||||
public void salesPostEncRejectConsent() {}
|
||||
|
||||
@Override
|
||||
@Ignore // KEYCLOAK-6152
|
||||
@Test
|
||||
public void salesPostRejectConsent() {}
|
||||
|
||||
@Override
|
||||
@Ignore // KEYCLOAK-6152
|
||||
@Test
|
||||
public void testDifferentCookieName() {}
|
||||
|
||||
@Override
|
||||
@Ignore
|
||||
@Test
|
||||
public void testMissingAssertionSignature() {}
|
||||
|
||||
@Override
|
||||
@Ignore // KEYCLOAK-6152
|
||||
@Test
|
||||
public void testRelayStateEncoding() {}
|
||||
}
|
||||
|
|
|
@ -34,9 +34,9 @@
|
|||
<property name="adapterImplClass">org.jboss.arquillian.container.wls.remote_12_1_2.WebLogicContainer</property>
|
||||
<property name="adminUrl">t3://localhost:8280/</property>
|
||||
<property name="adminUserName">weblogic</property>
|
||||
<property name="adminPassword">weblogic1</property>
|
||||
<property name="adminPassword">${wl.password}</property>
|
||||
<property name="target">AdminServer</property>
|
||||
<property name="wlHome">/home/jenkins/Oracle/Middleware/Oracle_Home/wlserver</property>
|
||||
<property name="wlHome">${wl.home}</property>
|
||||
</configuration>
|
||||
</container>
|
||||
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
For running WebLogic tests you need to have WLS running on port 8280 on your local machine.
|
||||
|
||||
## Running WLS server
|
||||
|
||||
Run WebLogic server on port **8280**
|
||||
|
||||
For example for docker image it is necessary to run it with these arguments
|
||||
```bash
|
||||
docker run -d \
|
||||
--name="wls-server" \
|
||||
--net="host" \
|
||||
-v /tmp:/tmp \
|
||||
your_docker_image
|
||||
```
|
||||
|
||||
- We need to use --net="host" so that weblogic can access Keycloak server
|
||||
- Also we need to map /tmp directory to /tmp directory in docker. This way arquillian will move archives used in testsuite to docker filesystem so that they are deployed to WLS
|
||||
|
||||
```
|
||||
- And also our image always create new admin password when starting weblogic so you need to find out what password it generated
|
||||
```bash
|
||||
docker logs wls-server | grep password
|
||||
```
|
||||
## Running tests
|
||||
|
||||
1. At first we need to add our custom arquillian remote adapter to local repository. Only custom change is to always store tmp files in /tmp
|
||||
```bash
|
||||
git clone https://github.com/mhajas/arquillian-container-wls.git
|
||||
cd arquillian-container-wls/wls-common
|
||||
mvn clean install -DskipTests [-Dmaven.repo.local=/custom/repo/path]
|
||||
cd ../wls-remote-12.1.x
|
||||
mvn clean install -DskipTests [-Dmaven.repo.local=/custom/repo/path]
|
||||
```
|
||||
|
||||
2. Build testsuite-arquillian
|
||||
```bash
|
||||
mvn clean install -f testsuite/integration-arquillian/pom.xml -DskipTests=true
|
||||
```
|
||||
3. Run tests
|
||||
```bash
|
||||
mvn clean install -f testsuite/integration-arquillian/tests/other/pom.xml -Papp-server-wls -Dwl.username=${admin-username} -Dwl.password=${admin-password} -Dwl.home=${wl-home-path}
|
||||
```
|
||||
|
||||
In case of docker image one can replace wl-home-path with some preprepared directory which contains these files (example of downloading files):
|
||||
```bash
|
||||
docker cp wls-server:/u01/oracle/wlserver/server/lib/weblogic.jar ${wl-home-path}/server/lib/
|
||||
docker cp wls-server:/u01/oracle/wlserver/server/lib/wlclient.jar ${wl-home-path}/server/lib/
|
||||
docker cp wls-server:/u01/oracle/wlserver/server/lib/wljmxclient.jar ${wl-home-path}/server/lib/
|
||||
```
|
||||
|
|
@ -41,7 +41,8 @@
|
|||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.jboss.arquillian.container</groupId>
|
||||
<artifactId>arquillian-wls-remote-12.1.x</artifactId>
|
||||
<artifactId>arquillian-wls-custom-remote-12.1.x</artifactId>
|
||||
<version>1.0.2.Final-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
|
|
@ -1,9 +1,15 @@
|
|||
package org.keycloak.testsuite.adapter;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.keycloak.testsuite.adapter.servlet.AbstractSAMLFilterServletAdapterTest;
|
||||
import org.keycloak.testsuite.arquillian.annotation.AppServerContainer;
|
||||
|
||||
@AppServerContainer("app-server-wls")
|
||||
public class WLSSAMLFilterAdapterTest extends AbstractSAMLFilterServletAdapterTest {
|
||||
|
||||
@Ignore // KEYCLOAK-6152
|
||||
@Override
|
||||
@Test
|
||||
public void testDifferentCookieName() {}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue