From: maxcooper Date: Tue, 10 Jun 2003 11:37:06 +0000 (+0000) Subject: tests for path tricks X-Git-Tag: rel-2_0-alpha1~70 X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=9a7787ef29264c3149cc3d035c863df7ee6c7388;p=securityfilter.git tests for path tricks /./securePage.jsp /public/../securePage.jsp --- diff --git a/src/test/org/securityfilter/test/http/form/PathTricksTest.java b/src/test/org/securityfilter/test/http/form/PathTricksTest.java new file mode 100644 index 0000000..984fa30 --- /dev/null +++ b/src/test/org/securityfilter/test/http/form/PathTricksTest.java @@ -0,0 +1,115 @@ +/* + * $Header: /cvsroot/securityfilter/securityfilter/src/test/org/securityfilter/test/http/form/PathTricksTest.java,v 1.1 2003/06/10 11:37:06 maxcooper Exp $ + * $Revision: 1.1 $ + * $Date: 2003/06/10 11:37:06 $ + * + * ==================================================================== + * The SecurityFilter Software License, Version 1.1 + * + * (this license is derived and fully compatible with the Apache Software + * License - see http://www.apache.org/LICENSE.txt) + * + * Copyright (c) 2002 SecurityFilter.org. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, + * if any, must include the following acknowledgment: + * "This product includes software developed by + * SecurityFilter.org (http://www.securityfilter.org/)." + * Alternately, this acknowledgment may appear in the software itself, + * if and wherever such third-party acknowledgments normally appear. + * + * 4. The name "SecurityFilter" must not be used to endorse or promote + * products derived from this software without prior written permission. + * For written permission, please contact license@securityfilter.org . + * + * 5. Products derived from this software may not be called "SecurityFilter", + * nor may "SecurityFilter" appear in their name, without prior written + * permission of SecurityFilter.org. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE SECURITY FILTER PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + */ + +package org.securityfilter.test.http.form; + +import com.meterware.httpunit.WebResponse; +import org.securityfilter.example.Constants; +import org.securityfilter.test.http.TestBase; + +/** + * PathTricksTest - tests for proper operation when "path tricks" are employed in URLs: + * /./securePage.jsp + * /public/../securePage.jsp + * + * @author Max Cooper (max@maxcooper.com) + * @version $Revision: 1.1 $ $Date: 2003/06/10 11:37:06 $ + */ +public class PathTricksTest extends TestBase { + /** + * Constructor + * + * @param name + */ + public PathTricksTest(String name) { + super(name); + } + + /** + * Test that the user is asked to login before accessing /./securePage.jsp. + * + * @throws Exception + */ + public void testSingleDotURLTrick() throws Exception { + // request the secure page and login + WebResponse response = performJustInTimeLogin("/./securePage.jsp"); + + // make sure the response leads to the secure page + String title = response.getTitle(); + assertEquals( + "Expected secure page, got:" + title, + Constants.SECURE_TITLE, + title + ); + } + + /** + * Test that the user is asked to login before accessing /public/../securePage.jsp. + * + * @throws Exception + */ + public void testDoubleDotURLTrick() throws Exception { + // request the secure page and login + WebResponse response = performJustInTimeLogin("/public/../securePage.jsp"); + + // make sure the response leads to the secure page + String title = response.getTitle(); + assertEquals( + "Expected secure page, got:" + title, + Constants.SECURE_TITLE, + title + ); + } +}