Author: owulff
Date: Mon Jan 14 07:50:53 2013
New Revision: 1432822
URL: http://svn.apache.org/viewvc?rev=1432822&view=rev
Log:
Systests restructured for tomcat support
Added:
cxf/fediz/trunk/systests/jetty8/
cxf/fediz/trunk/systests/jetty8/pom.xml
- copied, changed from r1432500, cxf/fediz/trunk/systests/tests/pom.xml
cxf/fediz/trunk/systests/jetty8/src/
cxf/fediz/trunk/systests/jetty8/src/test/
cxf/fediz/trunk/systests/jetty8/src/test/java/
cxf/fediz/trunk/systests/jetty8/src/test/java/org/
cxf/fediz/trunk/systests/jetty8/src/test/java/org/apache/
cxf/fediz/trunk/systests/jetty8/src/test/java/org/apache/cxf/
cxf/fediz/trunk/systests/jetty8/src/test/java/org/apache/cxf/fediz/
cxf/fediz/trunk/systests/jetty8/src/test/java/org/apache/cxf/fediz/integrationtests/
cxf/fediz/trunk/systests/jetty8/src/test/java/org/apache/cxf/fediz/integrationtests/JettyTest.java
cxf/fediz/trunk/systests/jetty8/src/test/resources/
cxf/fediz/trunk/systests/jetty8/src/test/resources/fediz_config.xml
- copied, changed from r1432500,
cxf/fediz/trunk/systests/tests/src/test/resources/fediz_config.xml
cxf/fediz/trunk/systests/jetty8/src/test/resources/jetty/
cxf/fediz/trunk/systests/jetty8/src/test/resources/jetty/idp-server.xml
- copied, changed from r1432500,
cxf/fediz/trunk/systests/tests/src/test/resources/jetty/idp-server.xml
cxf/fediz/trunk/systests/jetty8/src/test/resources/jetty/rp-server.xml
- copied, changed from r1432500,
cxf/fediz/trunk/systests/tests/src/test/resources/jetty/rp-server.xml
cxf/fediz/trunk/systests/jetty8/src/test/resources/server.jks
- copied, changed from r1432500,
cxf/fediz/trunk/systests/tests/src/test/resources/server.jks
cxf/fediz/trunk/systests/jetty8/src/test/resources/stsstore.jks
- copied, changed from r1432500,
cxf/fediz/trunk/systests/tests/src/test/resources/stsstore.jks
cxf/fediz/trunk/systests/tests/src/test/java/org/apache/cxf/fediz/integrationtests/AbstractTests.java
- copied, changed from r1432500,
cxf/fediz/trunk/systests/tests/src/test/java/org/apache/cxf/fediz/integrationtests/JettyTest.java
Removed:
cxf/fediz/trunk/systests/tests/src/test/java/org/apache/cxf/fediz/integrationtests/JettyTest.java
cxf/fediz/trunk/systests/tests/src/test/resources/fediz_config.xml
cxf/fediz/trunk/systests/tests/src/test/resources/jetty/idp-server.xml
cxf/fediz/trunk/systests/tests/src/test/resources/jetty/rp-server.xml
cxf/fediz/trunk/systests/tests/src/test/resources/server.jks
cxf/fediz/trunk/systests/tests/src/test/resources/stsstore.jks
Modified:
cxf/fediz/trunk/systests/pom.xml
cxf/fediz/trunk/systests/tests/pom.xml
Copied: cxf/fediz/trunk/systests/jetty8/pom.xml (from r1432500,
cxf/fediz/trunk/systests/tests/pom.xml)
URL:
http://svn.apache.org/viewvc/cxf/fediz/trunk/systests/jetty8/pom.xml?p2=cxf/fediz/trunk/systests/jetty8/pom.xml&p1=cxf/fediz/trunk/systests/tests/pom.xml&r1=1432500&r2=1432822&rev=1432822&view=diff
==============================================================================
--- cxf/fediz/trunk/systests/tests/pom.xml (original)
+++ cxf/fediz/trunk/systests/jetty8/pom.xml Mon Jan 14 07:50:53 2013
@@ -26,8 +26,8 @@
<relativePath>../pom.xml</relativePath>
</parent>
<groupId>org.apache.cxf.fediz.systests</groupId>
- <artifactId>systests-test</artifactId>
- <name>Apache Fediz Systests</name>
+ <artifactId>systests-jetty8</artifactId>
+ <name>Apache Fediz Systests Jetty 8</name>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@@ -69,21 +69,16 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>org.apache.cxf.fediz</groupId>
- <artifactId>fediz-jetty</artifactId>
+ <groupId>org.apache.cxf.fediz.systests</groupId>
+ <artifactId>systests-tests</artifactId>
<version>${project.version}</version>
+ <type>test-jar</type>
<scope>test</scope>
- </dependency>
+ </dependency>
<dependency>
- <groupId>org.apache.httpcomponents</groupId>
- <artifactId>httpclient</artifactId>
- <version>4.2.2</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>net.htmlparser.jericho</groupId>
- <artifactId>jericho-html</artifactId>
- <version>3.2</version>
+ <groupId>org.apache.cxf.fediz</groupId>
+ <artifactId>fediz-jetty</artifactId>
+ <version>${project.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
@@ -110,6 +105,26 @@
</testResources>
<plugins>
<plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <version>1.7</version>
+ <executions>
+ <execution>
+ <id>reserve-network-port</id>
+ <goals>
+ <goal>reserve-network-port</goal>
+ </goals>
+ <phase>initialize</phase>
+ <configuration>
+ <portNames>
+ <portName>idp.https.port</portName>
+ <portName>rp.https.port</portName>
+ </portNames>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.6</version>
Added:
cxf/fediz/trunk/systests/jetty8/src/test/java/org/apache/cxf/fediz/integrationtests/JettyTest.java
URL:
http://svn.apache.org/viewvc/cxf/fediz/trunk/systests/jetty8/src/test/java/org/apache/cxf/fediz/integrationtests/JettyTest.java?rev=1432822&view=auto
==============================================================================
---
cxf/fediz/trunk/systests/jetty8/src/test/java/org/apache/cxf/fediz/integrationtests/JettyTest.java
(added)
+++
cxf/fediz/trunk/systests/jetty8/src/test/java/org/apache/cxf/fediz/integrationtests/JettyTest.java
Mon Jan 14 07:50:53 2013
@@ -0,0 +1,113 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.cxf.fediz.integrationtests;
+
+
+
+
+import org.eclipse.jetty.server.Server;
+import org.eclipse.jetty.util.resource.Resource;
+import org.eclipse.jetty.xml.XmlConfiguration;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+
+
+public class JettyTest extends AbstractTests {
+
+ static String idpHttpsPort;
+ static String rpHttpsPort;
+
+ private static Server idpServer;
+ private static Server rpServer;
+
+ @BeforeClass
+ public static void init() {
+ System.setProperty("org.apache.commons.logging.Log",
"org.apache.commons.logging.impl.SimpleLog");
+
+
System.setProperty("org.apache.commons.logging.simplelog.showdatetime", "true");
+
+
System.setProperty("org.apache.commons.logging.simplelog.log.httpclient.wire",
"debug");
+
+
System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.commons.httpclient",
"debug");
+
+ idpHttpsPort = System.getProperty("idp.https.port");
+ Assert.assertNotNull("Property 'idp.https.port' null", idpHttpsPort);
+ rpHttpsPort = System.getProperty("rp.https.port");
+ Assert.assertNotNull("Property 'rp.https.port' null", rpHttpsPort);
+
+ initIdp();
+ Assert.assertTrue("IDP server not running", idpServer.isRunning());
+ initRp();
+ Assert.assertTrue("RP server not running", rpServer.isRunning());
+ }
+
+ private static void initIdp() {
+ try {
+ Resource testServerConfig =
Resource.newSystemResource("jetty/rp-server.xml");
+ XmlConfiguration configuration = new
XmlConfiguration(testServerConfig.getInputStream());
+ idpServer = (Server)configuration.configure();
+ idpServer.start();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ private static void initRp() {
+ try {
+ Resource testServerConfig =
Resource.newSystemResource("jetty/idp-server.xml");
+ XmlConfiguration configuration = new
XmlConfiguration(testServerConfig.getInputStream());
+ rpServer = (Server)configuration.configure();
+ rpServer.start();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @AfterClass
+ public static void cleanup() {
+ if (idpServer != null && idpServer.isStarted()) {
+ try {
+ idpServer.stop();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ if (rpServer != null && rpServer.isStarted()) {
+ try {
+ rpServer.stop();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ @Override
+ public String getIdpHttpsPort() {
+ return idpHttpsPort;
+ }
+
+ @Override
+ public String getRpHttpsPort() {
+ return rpHttpsPort;
+ }
+
+
+}
Copied: cxf/fediz/trunk/systests/jetty8/src/test/resources/fediz_config.xml
(from r1432500,
cxf/fediz/trunk/systests/tests/src/test/resources/fediz_config.xml)
URL:
http://svn.apache.org/viewvc/cxf/fediz/trunk/systests/jetty8/src/test/resources/fediz_config.xml?p2=cxf/fediz/trunk/systests/jetty8/src/test/resources/fediz_config.xml&p1=cxf/fediz/trunk/systests/tests/src/test/resources/fediz_config.xml&r1=1432500&r2=1432822&rev=1432822&view=diff
==============================================================================
(empty)
Copied: cxf/fediz/trunk/systests/jetty8/src/test/resources/jetty/idp-server.xml
(from r1432500,
cxf/fediz/trunk/systests/tests/src/test/resources/jetty/idp-server.xml)
URL:
http://svn.apache.org/viewvc/cxf/fediz/trunk/systests/jetty8/src/test/resources/jetty/idp-server.xml?p2=cxf/fediz/trunk/systests/jetty8/src/test/resources/jetty/idp-server.xml&p1=cxf/fediz/trunk/systests/tests/src/test/resources/jetty/idp-server.xml&r1=1432500&r2=1432822&rev=1432822&view=diff
==============================================================================
(empty)
Copied: cxf/fediz/trunk/systests/jetty8/src/test/resources/jetty/rp-server.xml
(from r1432500,
cxf/fediz/trunk/systests/tests/src/test/resources/jetty/rp-server.xml)
URL:
http://svn.apache.org/viewvc/cxf/fediz/trunk/systests/jetty8/src/test/resources/jetty/rp-server.xml?p2=cxf/fediz/trunk/systests/jetty8/src/test/resources/jetty/rp-server.xml&p1=cxf/fediz/trunk/systests/tests/src/test/resources/jetty/rp-server.xml&r1=1432500&r2=1432822&rev=1432822&view=diff
==============================================================================
(empty)
Copied: cxf/fediz/trunk/systests/jetty8/src/test/resources/server.jks (from
r1432500, cxf/fediz/trunk/systests/tests/src/test/resources/server.jks)
URL:
http://svn.apache.org/viewvc/cxf/fediz/trunk/systests/jetty8/src/test/resources/server.jks?p2=cxf/fediz/trunk/systests/jetty8/src/test/resources/server.jks&p1=cxf/fediz/trunk/systests/tests/src/test/resources/server.jks&r1=1432500&r2=1432822&rev=1432822&view=diff
==============================================================================
(empty)
Copied: cxf/fediz/trunk/systests/jetty8/src/test/resources/stsstore.jks (from
r1432500, cxf/fediz/trunk/systests/tests/src/test/resources/stsstore.jks)
URL:
http://svn.apache.org/viewvc/cxf/fediz/trunk/systests/jetty8/src/test/resources/stsstore.jks?p2=cxf/fediz/trunk/systests/jetty8/src/test/resources/stsstore.jks&p1=cxf/fediz/trunk/systests/tests/src/test/resources/stsstore.jks&r1=1432500&r2=1432822&rev=1432822&view=diff
==============================================================================
(empty)
Modified: cxf/fediz/trunk/systests/pom.xml
URL:
http://svn.apache.org/viewvc/cxf/fediz/trunk/systests/pom.xml?rev=1432822&r1=1432821&r2=1432822&view=diff
==============================================================================
--- cxf/fediz/trunk/systests/pom.xml (original)
+++ cxf/fediz/trunk/systests/pom.xml Mon Jan 14 07:50:53 2013
@@ -29,42 +29,14 @@
<name>Apache Fediz System tests</name>
<packaging>pom</packaging>
- <build>
- <plugins>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>build-helper-maven-plugin</artifactId>
- <version>1.7</version>
- <executions>
- <execution>
- <id>reserve-network-port</id>
- <goals>
- <goal>reserve-network-port</goal>
- </goals>
- <phase>initialize</phase>
- <configuration>
- <portNames>
- <portName>idp.https.port</portName>
- <portName>rp.https.port</portName>
- </portNames>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-
-
<modules>
-<!--
- <module>idp</module>
- <module>sts</module>
--->
+ <module>tests</module>
<module>simpleWebapp</module>
<!--
<module>springWebapp</module>
-->
- <module>tests</module>
+ <module>jetty8</module>
+<!-- <module>tomcat7</module>-->
</modules>
</project>
Modified: cxf/fediz/trunk/systests/tests/pom.xml
URL:
http://svn.apache.org/viewvc/cxf/fediz/trunk/systests/tests/pom.xml?rev=1432822&r1=1432821&r2=1432822&view=diff
==============================================================================
--- cxf/fediz/trunk/systests/tests/pom.xml (original)
+++ cxf/fediz/trunk/systests/tests/pom.xml Mon Jan 14 07:50:53 2013
@@ -26,43 +26,14 @@
<relativePath>../pom.xml</relativePath>
</parent>
<groupId>org.apache.cxf.fediz.systests</groupId>
- <artifactId>systests-test</artifactId>
- <name>Apache Fediz Systests</name>
+ <artifactId>systests-tests</artifactId>
+ <name>Apache Fediz Systests Tests</name>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
-
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<dependencies>
<dependency>
- <groupId>org.eclipse.jetty</groupId>
- <artifactId>jetty-server</artifactId>
- <version>${jetty.version}</version>
- </dependency>
- <dependency>
- <groupId>org.eclipse.jetty</groupId>
- <artifactId>jetty-security</artifactId>
- <version>${jetty.version}</version>
- </dependency>
- <dependency>
- <groupId>org.eclipse.jetty</groupId>
- <artifactId>jetty-xml</artifactId>
- <version>${jetty.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.eclipse.jetty</groupId>
- <artifactId>jetty-webapp</artifactId>
- <version>${jetty.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.eclipse.jetty</groupId>
- <artifactId>jetty-jsp</artifactId>
- <version>${jetty.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
@@ -70,132 +41,34 @@
</dependency>
<dependency>
<groupId>org.apache.cxf.fediz</groupId>
- <artifactId>fediz-jetty</artifactId>
+ <artifactId>fediz-core</artifactId>
<version>${project.version}</version>
- <scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.2.2</version>
- <scope>test</scope>
</dependency>
<dependency>
<groupId>net.htmlparser.jericho</groupId>
<artifactId>jericho-html</artifactId>
<version>3.2</version>
- <scope>test</scope>
</dependency>
</dependencies>
<build>
- <testResources>
- <testResource>
- <directory>src/test/resources</directory>
- <filtering>true</filtering>
- <includes>
- <include>**/idp-server.xml</include>
- <include>**/rp-server.xml</include>
- <include>**/fediz_config.xml</include>
- </includes>
- </testResource>
- <testResource>
- <directory>src/test/resources</directory>
- <filtering>false</filtering>
- <excludes>
- <exclude>**/idp-server.xml</exclude>
- <exclude>**/rp-server.xml</exclude>
- <exclude>**/fediz_config.xml</exclude>
- </excludes>
- </testResource>
- </testResources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-dependency-plugin</artifactId>
- <version>2.6</version>
+ <artifactId>maven-jar-plugin</artifactId>
+ <version>2.2</version>
<executions>
<execution>
- <id>copy-idp-sts</id>
- <phase>generate-resources</phase>
<goals>
- <goal>copy</goal>
+ <goal>test-jar</goal>
</goals>
- <configuration>
- <artifactItems>
- <artifactItem>
- <groupId>org.apache.cxf.fediz</groupId>
- <artifactId>fediz-idp</artifactId>
- <version>${project.version}</version>
- <type>war</type>
- <overWrite>true</overWrite>
- </artifactItem>
- <artifactItem>
- <groupId>org.apache.cxf.fediz</groupId>
- <artifactId>fediz-idp-sts</artifactId>
- <version>${project.version}</version>
- <type>war</type>
- <overWrite>true</overWrite>
- </artifactItem>
- <artifactItem>
-
<groupId>org.apache.cxf.fediz.systests</groupId>
-
<artifactId>systests-simpleWebapp</artifactId>
- <version>${project.version}</version>
- <type>war</type>
- <overWrite>true</overWrite>
- </artifactItem>
- </artifactItems>
-
<outputAbsoluteArtifactFilename>true</outputAbsoluteArtifactFilename>
- <outputDirectory>target</outputDirectory>
- <overWriteSnapshots>true</overWriteSnapshots>
- <overWriteIfNewer>true</overWriteIfNewer>
- <stripVersion>true</stripVersion>
- </configuration>
</execution>
</executions>
</plugin>
- <plugin>
- <artifactId>maven-failsafe-plugin</artifactId>
- <version>2.12.2</version>
- <inherited>true</inherited>
- <executions>
- <execution>
- <id>integration-test</id>
- <phase>integration-test</phase>
- <goals>
- <goal>integration-test</goal>
- </goals>
- <configuration>
- <skip>false</skip>
- <systemPropertyVariables>
- <wt.headless>true</wt.headless>
-
<idp.https.port>${idp.https.port}</idp.https.port>
- <rp.https.port>${rp.https.port}</rp.https.port>
- </systemPropertyVariables>
- <includes>
- <include>**/integrationtests/**</include>
- </includes>
- </configuration>
- </execution>
- <execution>
- <id>verify</id>
- <phase>verify</phase>
- <goals>
- <goal>verify</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <version>2.12</version>
- <inherited>true</inherited>
- <configuration>
- <excludes>
- <exclude>**/integrationtests/**</exclude>
- </excludes>
- </configuration>
- </plugin>
</plugins>
</build>
</project>
Copied:
cxf/fediz/trunk/systests/tests/src/test/java/org/apache/cxf/fediz/integrationtests/AbstractTests.java
(from r1432500,
cxf/fediz/trunk/systests/tests/src/test/java/org/apache/cxf/fediz/integrationtests/JettyTest.java)
URL:
http://svn.apache.org/viewvc/cxf/fediz/trunk/systests/tests/src/test/java/org/apache/cxf/fediz/integrationtests/AbstractTests.java?p2=cxf/fediz/trunk/systests/tests/src/test/java/org/apache/cxf/fediz/integrationtests/AbstractTests.java&p1=cxf/fediz/trunk/systests/tests/src/test/java/org/apache/cxf/fediz/integrationtests/JettyTest.java&r1=1432500&r2=1432822&rev=1432822&view=diff
==============================================================================
---
cxf/fediz/trunk/systests/tests/src/test/java/org/apache/cxf/fediz/integrationtests/JettyTest.java
(original)
+++
cxf/fediz/trunk/systests/tests/src/test/java/org/apache/cxf/fediz/integrationtests/AbstractTests.java
Mon Jan 14 07:50:53 2013
@@ -28,8 +28,6 @@ import java.util.List;
import net.htmlparser.jericho.FormField;
import net.htmlparser.jericho.FormFields;
import net.htmlparser.jericho.Source;
-
-
import org.apache.cxf.fediz.core.ClaimTypes;
import org.apache.http.Consts;
import org.apache.http.HttpEntity;
@@ -46,87 +44,30 @@ import org.apache.http.impl.client.Defau
import org.apache.http.impl.client.LaxRedirectStrategy;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;
-import org.eclipse.jetty.server.Server;
-import org.eclipse.jetty.util.resource.Resource;
-import org.eclipse.jetty.xml.XmlConfiguration;
-import org.junit.AfterClass;
import org.junit.Assert;
-import org.junit.BeforeClass;
-
-
-public class JettyTest {
-
- private static String idpHttpsPort;
- private static String rpHttpsPort;
-
- private static Server idpServer;
- private static Server rpServer;
-
- @BeforeClass
- public static void init() {
- System.setProperty("org.apache.commons.logging.Log",
"org.apache.commons.logging.impl.SimpleLog");
-
-
System.setProperty("org.apache.commons.logging.simplelog.showdatetime", "true");
-
System.setProperty("org.apache.commons.logging.simplelog.log.httpclient.wire",
"debug");
+public abstract class AbstractTests {
-
System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.commons.httpclient",
"debug");
+ public AbstractTests() {
+ super();
+ }
- idpHttpsPort = System.getProperty("idp.https.port");
- Assert.assertNotNull(idpHttpsPort);
- rpHttpsPort = System.getProperty("rp.https.port");
- Assert.assertNotNull(rpHttpsPort);
+ public abstract String getIdpHttpsPort();
- initIdp();
- Assert.assertTrue("IDP server not running", idpServer.isRunning());
- initRp();
- Assert.assertTrue("RP server not running", rpServer.isRunning());
- }
-
- private static void initIdp() {
- try {
- Resource testServerConfig =
Resource.newSystemResource("jetty/rp-server.xml");
- XmlConfiguration configuration = new
XmlConfiguration(testServerConfig.getInputStream());
- idpServer = (Server)configuration.configure();
- idpServer.start();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- private static void initRp() {
- try {
- Resource testServerConfig =
Resource.newSystemResource("jetty/idp-server.xml");
- XmlConfiguration configuration = new
XmlConfiguration(testServerConfig.getInputStream());
- rpServer = (Server)configuration.configure();
- rpServer.start();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- /*
- @org.junit.Test
- @Ignore
- public void testStart() throws Exception {
- System.out.println(System.getProperty("jetty.home"));
- System.out.println(Server.getVersion());
- System.out.println(server.isRunning());
- }
- */
+ public abstract String getRpHttpsPort();
@org.junit.Test
public void testUserAlice() throws Exception {
- String url = "https://localhost:" + rpHttpsPort +
"/fedizhelloworld/secure/fedservlet";
+ String url = "https://localhost:" + getRpHttpsPort() +
"/fedizhelloworld/secure/fedservlet";
String user = "alice";
String password = "ecila";
String response = sendHttpGet(url, user, password);
-
+
Assert.assertTrue("Principal not " + user,
response.indexOf("userPrincipal=" + user) > 0);
Assert.assertTrue("User " + user + " does not have role Admin",
response.indexOf("role:Admin=false") > 0);
Assert.assertTrue("User " + user + " does not have role Manager",
response.indexOf("role:Manager=false") > 0);
Assert.assertTrue("User " + user + " must have role User",
response.indexOf("role:User=true") > 0);
-
+
String claim = ClaimTypes.FIRSTNAME.toString();
Assert.assertTrue("User " + user + " claim " + claim + " is not
'Alice'",
response.indexOf(claim + "=Alice") > 0);
@@ -136,21 +77,21 @@ public class JettyTest {
claim = ClaimTypes.EMAILADDRESS.toString();
Assert.assertTrue("User " + user + " claim " + claim + " is not
'[email protected]'",
response.indexOf(claim + "[email protected]") >
0);
-
+
}
-
+
@org.junit.Test
public void testUserBob() throws Exception {
- String url = "https://localhost:" + rpHttpsPort +
"/fedizhelloworld/secure/fedservlet";
+ String url = "https://localhost:" + getRpHttpsPort() +
"/fedizhelloworld/secure/fedservlet";
String user = "bob";
String password = "bob";
String response = sendHttpGet(url, user, password);
-
+
Assert.assertTrue("Principal not " + user,
response.indexOf("userPrincipal=" + user) > 0);
Assert.assertTrue("User " + user + " does not have role Admin",
response.indexOf("role:Admin=true") > 0);
Assert.assertTrue("User " + user + " does not have role Manager",
response.indexOf("role:Manager=true") > 0);
Assert.assertTrue("User " + user + " must have role User",
response.indexOf("role:User=true") > 0);
-
+
String claim = ClaimTypes.FIRSTNAME.toString();
Assert.assertTrue("User " + user + " claim " + claim + " is not 'Bob'",
response.indexOf(claim + "=Bob") > 0);
@@ -161,19 +102,19 @@ public class JettyTest {
Assert.assertTrue("User " + user + " claim " + claim + " is not
'[email protected]'",
response.indexOf(claim + "[email protected]") > 0);
}
-
+
@org.junit.Test
public void testUserTed() throws Exception {
- String url = "https://localhost:" + rpHttpsPort +
"/fedizhelloworld/secure/fedservlet";
+ String url = "https://localhost:" + getRpHttpsPort() +
"/fedizhelloworld/secure/fedservlet";
String user = "ted";
String password = "det";
String response = sendHttpGet(url, user, password);
-
+
Assert.assertTrue("Principal not " + user,
response.indexOf("userPrincipal=" + user) > 0);
Assert.assertTrue("User " + user + " does not have role Admin",
response.indexOf("role:Admin=false") > 0);
Assert.assertTrue("User " + user + " does not have role Manager",
response.indexOf("role:Manager=false") > 0);
Assert.assertTrue("User " + user + " must have role User",
response.indexOf("role:User=false") > 0);
-
+
String claim = ClaimTypes.FIRSTNAME.toString();
Assert.assertTrue("User " + user + " claim " + claim + " is not 'Ted'",
response.indexOf(claim + "=Ted") > 0);
@@ -184,44 +125,44 @@ public class JettyTest {
Assert.assertTrue("User " + user + " claim " + claim + " is not
'[email protected]'",
response.indexOf(claim + "[email protected]") >
0);
}
-
+
@org.junit.Test
public void testUserAliceNoAccess() throws Exception {
- String url = "https://localhost:" + rpHttpsPort +
"/fedizhelloworld/secure/admin/fedservlet";
+ String url = "https://localhost:" + getRpHttpsPort() +
"/fedizhelloworld/secure/admin/fedservlet";
String user = "alice";
String password = "ecila";
sendHttpGet(url, user, password, 200, 403);
}
-
+
@org.junit.Ignore
@org.junit.Test
public void testUserAliceWrongPassword() throws Exception {
- String url = "https://localhost:" + rpHttpsPort +
"/fedizhelloworld/secure/fedservlet";
+ String url = "https://localhost:" + getRpHttpsPort() +
"/fedizhelloworld/secure/fedservlet";
String user = "alice";
String password = "alice";
//[TODO] Fix IDP return code from 500 to 401
sendHttpGet(url, user, password, 500, 0);
}
-
+
@org.junit.Test
public void testUserTedNoAccess() throws Exception {
- String url = "https://localhost:" + rpHttpsPort +
"/fedizhelloworld/secure/admin/fedservlet";
+ String url = "https://localhost:" + getRpHttpsPort() +
"/fedizhelloworld/secure/admin/fedservlet";
String user = "ted";
String password = "det";
sendHttpGet(url, user, password, 200, 403);
}
-
+
private String sendHttpGet(String url, String user, String password)
throws Exception {
return sendHttpGet(url, user, password, 200, 200);
}
-
- private String sendHttpGet(String url, String user, String password,
- int returnCodeIDP, int returnCodeRP) throws
Exception {
+
+ private String sendHttpGet(String url, String user, String password, int
returnCodeIDP, int returnCodeRP)
+ throws Exception {
DefaultHttpClient httpclient = new DefaultHttpClient();
try {
httpclient.getCredentialsProvider().setCredentials(
- new AuthScope("localhost", Integer.parseInt(idpHttpsPort)),
- new UsernamePasswordCredentials(user, password));
+ new AuthScope("localhost",
Integer.parseInt(getIdpHttpsPort())),
+ new UsernamePasswordCredentials(user, password));
KeyStore trustStore =
KeyStore.getInstance(KeyStore.getDefaultType());
FileInputStream instream = new FileInputStream(new
File("./target/test-classes/server.jks"));
@@ -236,16 +177,16 @@ public class JettyTest {
}
SSLSocketFactory socketFactory = new SSLSocketFactory(trustStore);
- Scheme schIdp = new Scheme("https",
Integer.parseInt(idpHttpsPort), socketFactory);
+ Scheme schIdp = new Scheme("https",
Integer.parseInt(getIdpHttpsPort()), socketFactory);
httpclient.getConnectionManager().getSchemeRegistry().register(schIdp);
- Scheme schRp = new Scheme("https", Integer.parseInt(rpHttpsPort),
socketFactory);
+ Scheme schRp = new Scheme("https",
Integer.parseInt(getRpHttpsPort()), socketFactory);
httpclient.getConnectionManager().getSchemeRegistry().register(schRp);
HttpGet httpget = new HttpGet(url);
HttpResponse response = httpclient.execute(httpget);
HttpEntity entity = response.getEntity();
-
+
System.out.println(response.getStatusLine());
if (entity != null) {
System.out.println("Response content length: " +
entity.getContentLength());
@@ -253,21 +194,21 @@ public class JettyTest {
Assert.assertTrue("IDP HTTP Response code: " +
response.getStatusLine().getStatusCode()
+ " [Expected: " + returnCodeIDP + "]",
returnCodeIDP ==
response.getStatusLine().getStatusCode());
-
+
if (response.getStatusLine().getStatusCode() != 200) {
return null;
}
-
-// Redirect to a POST is not supported without user interaction
-// http://www.ietf.org/rfc/rfc2616.txt
-// If the 301 status code is received in response to a request other
-// than GET or HEAD, the user agent MUST NOT automatically redirect
the
-// request unless it can be confirmed by the user, since this might
-// change the conditions under which the request was issued.
-
+
+ // Redirect to a POST is not supported without user
interaction
+ // http://www.ietf.org/rfc/rfc2616.txt
+ // If the 301 status code is received in response to a
request other
+ // than GET or HEAD, the user agent MUST NOT
automatically redirect the
+ // request unless it can be confirmed by the user,
since this might
+ // change the conditions under which the request was
issued.
+
httpclient.setRedirectStrategy(new LaxRedirectStrategy());
HttpPost httppost = new HttpPost(url);
-
+
Source source = new Source(EntityUtils.toString(entity));
List <NameValuePair> nvps = new ArrayList <NameValuePair>();
FormFields formFields = source.getFormFields();
@@ -279,17 +220,17 @@ public class JettyTest {
httppost.setEntity(new UrlEncodedFormEntity(nvps, Consts.UTF_8));
response = httpclient.execute(httppost);
-
+
entity = response.getEntity();
System.out.println(response.getStatusLine());
Assert.assertTrue("RP HTTP Response code: " +
response.getStatusLine().getStatusCode()
+ " [Expected: " + returnCodeRP + "]",
returnCodeRP ==
response.getStatusLine().getStatusCode());
-
+
if (entity != null) {
System.out.println("Response content length: " +
entity.getContentLength());
}
-
+
return EntityUtils.toString(entity);
} finally {
// When HttpClient instance is no longer needed,
@@ -297,27 +238,7 @@ public class JettyTest {
// immediate deallocation of all system resources
httpclient.getConnectionManager().shutdown();
}
-
- }
-
-
- @AfterClass
- public static void cleanup() {
- if (idpServer != null && idpServer.isStarted()) {
- try {
- idpServer.stop();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- if (rpServer != null && rpServer.isStarted()) {
- try {
- rpServer.stop();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
+
}
-
-
+
}