Repository: cxf-fediz Updated Branches: refs/heads/1.2.x-fixes bd5b3e3a5 -> 9afddd75f
Removing test Project: http://git-wip-us.apache.org/repos/asf/cxf-fediz/repo Commit: http://git-wip-us.apache.org/repos/asf/cxf-fediz/commit/9afddd75 Tree: http://git-wip-us.apache.org/repos/asf/cxf-fediz/tree/9afddd75 Diff: http://git-wip-us.apache.org/repos/asf/cxf-fediz/diff/9afddd75 Branch: refs/heads/1.2.x-fixes Commit: 9afddd75fcc3bdbc63f1338171a59d5f03b12ecd Parents: bd5b3e3 Author: Colm O hEigeartaigh <[email protected]> Authored: Mon Dec 14 16:46:25 2015 +0000 Committer: Colm O hEigeartaigh <[email protected]> Committed: Mon Dec 14 16:46:25 2015 +0000 ---------------------------------------------------------------------- .../cxf/fediz/integrationtests/BadWReqTest.java | 197 ------------------- 1 file changed, 197 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/9afddd75/systests/tomcat7/src/test/java/org/apache/cxf/fediz/integrationtests/BadWReqTest.java ---------------------------------------------------------------------- diff --git a/systests/tomcat7/src/test/java/org/apache/cxf/fediz/integrationtests/BadWReqTest.java b/systests/tomcat7/src/test/java/org/apache/cxf/fediz/integrationtests/BadWReqTest.java deleted file mode 100644 index 99c4fe1..0000000 --- a/systests/tomcat7/src/test/java/org/apache/cxf/fediz/integrationtests/BadWReqTest.java +++ /dev/null @@ -1,197 +0,0 @@ -/** - * 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 java.io.File; - -import com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException; - -import org.apache.catalina.Context; -import org.apache.catalina.LifecycleState; -import org.apache.catalina.connector.Connector; -import org.apache.catalina.startup.Tomcat; -import org.apache.cxf.fediz.tomcat.FederationAuthenticator; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; - -/** - * A test for sending a TokenType request to the IdP via the "wreq" parameter. This test sends - * a "bad" TokenType, and so a failure is expected. - */ -public class BadWReqTest { - - static String idpHttpsPort; - static String rpHttpsPort; - - private static Tomcat idpServer; - private static Tomcat 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", "info"); - System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.commons.httpclient", "info"); - System.setProperty("org.apache.commons.logging.simplelog.log.org.springframework.webflow", "info"); - System.setProperty("org.apache.commons.logging.simplelog.log.org.springframework.security.web", "info"); - System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.cxf.fediz", "info"); - System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.cxf", "info"); - - 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(); - initRp(); - } - - private static void initIdp() { - try { - idpServer = new Tomcat(); - idpServer.setPort(0); - String currentDir = new File(".").getCanonicalPath(); - idpServer.setBaseDir(currentDir + File.separator + "target"); - - idpServer.getHost().setAppBase("tomcat/idp/webapps"); - idpServer.getHost().setAutoDeploy(true); - idpServer.getHost().setDeployOnStartup(true); - - Connector httpsConnector = new Connector(); - httpsConnector.setPort(Integer.parseInt(idpHttpsPort)); - httpsConnector.setSecure(true); - httpsConnector.setScheme("https"); - //httpsConnector.setAttribute("keyAlias", keyAlias); - httpsConnector.setAttribute("keystorePass", "tompass"); - httpsConnector.setAttribute("keystoreFile", "test-classes/server.jks"); - httpsConnector.setAttribute("truststorePass", "tompass"); - httpsConnector.setAttribute("truststoreFile", "test-classes/server.jks"); - httpsConnector.setAttribute("clientAuth", "want"); - // httpsConnector.setAttribute("clientAuth", "false"); - httpsConnector.setAttribute("sslProtocol", "TLS"); - httpsConnector.setAttribute("SSLEnabled", true); - - idpServer.getService().addConnector(httpsConnector); - - idpServer.addWebapp("/fediz-idp-sts", "fediz-idp-sts"); - idpServer.addWebapp("/fediz-idp", "fediz-idp"); - - idpServer.start(); - } catch (Exception e) { - e.printStackTrace(); - } - } - - private static void initRp() { - try { - rpServer = new Tomcat(); - rpServer.setPort(0); - String currentDir = new File(".").getCanonicalPath(); - rpServer.setBaseDir(currentDir + File.separator + "target"); - - rpServer.getHost().setAppBase("tomcat/rp/webapps"); - rpServer.getHost().setAutoDeploy(true); - rpServer.getHost().setDeployOnStartup(true); - - Connector httpsConnector = new Connector(); - httpsConnector.setPort(Integer.parseInt(rpHttpsPort)); - httpsConnector.setSecure(true); - httpsConnector.setScheme("https"); - //httpsConnector.setAttribute("keyAlias", keyAlias); - httpsConnector.setAttribute("keystorePass", "tompass"); - httpsConnector.setAttribute("keystoreFile", "test-classes/server.jks"); - httpsConnector.setAttribute("truststorePass", "tompass"); - httpsConnector.setAttribute("truststoreFile", "test-classes/server.jks"); - // httpsConnector.setAttribute("clientAuth", "false"); - httpsConnector.setAttribute("clientAuth", "want"); - httpsConnector.setAttribute("sslProtocol", "TLS"); - httpsConnector.setAttribute("SSLEnabled", true); - - rpServer.getService().addConnector(httpsConnector); - - //Context ctx = - Context cxt = rpServer.addWebapp("/fedizhelloworld", "simpleWebapp"); - FederationAuthenticator fa = new FederationAuthenticator(); - fa.setConfigFile(currentDir + File.separator + "target" + File.separator - + "test-classes" + File.separator + "fediz_config_bad_wreq.xml"); - cxt.getPipeline().addValve(fa); - - - rpServer.start(); - } catch (Exception e) { - e.printStackTrace(); - } - } - - @AfterClass - public static void cleanup() { - try { - if (idpServer.getServer() != null - && idpServer.getServer().getState() != LifecycleState.DESTROYED) { - if (idpServer.getServer().getState() != LifecycleState.STOPPED) { - idpServer.stop(); - } - idpServer.destroy(); - } - } catch (Exception e) { - e.printStackTrace(); - } - - try { - if (rpServer.getServer() != null - && rpServer.getServer().getState() != LifecycleState.DESTROYED) { - if (rpServer.getServer().getState() != LifecycleState.STOPPED) { - rpServer.stop(); - } - rpServer.destroy(); - } - } catch (Exception e) { - e.printStackTrace(); - } - } - - public String getIdpHttpsPort() { - return idpHttpsPort; - } - - public String getRpHttpsPort() { - return rpHttpsPort; - } - - public String getServletContextName() { - return "fedizhelloworld"; - } - - @org.junit.Test - public void testSAML1TokenViaWReq() throws Exception { - String url = "https://localhost:" + getRpHttpsPort() + "/fedizhelloworld/secure/fedservlet"; - String user = "alice"; - String password = "ecila"; - - try { - HTTPTestUtils.login(url, user, password, getIdpHttpsPort()); - Assert.fail("Exception expected"); - } catch (FailingHttpStatusCodeException ex) { - Assert.assertEquals(ex.getStatusCode(), 400); - } - } - -}
