shiro-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lhazlew...@apache.org
Subject svn commit: r729768 - in /incubator/jsecurity/trunk: ./ samples/quickstart/ samples/standalone/ test/ test/org/jsecurity/web/ test/org/jsecurity/web/servlet/
Date Sun, 28 Dec 2008 19:51:42 GMT
Author: lhazlewood
Date: Sun Dec 28 11:51:41 2008
New Revision: 729768

URL: http://svn.apache.org/viewvc?rev=729768&view=rev
Log:
JSEC-33 - added two test cases to verify the issue is resolved

Modified:
    incubator/jsecurity/trunk/jsecurity.iml
    incubator/jsecurity/trunk/jsecurity.ipr
    incubator/jsecurity/trunk/samples/quickstart/quickstart.iml
    incubator/jsecurity/trunk/samples/standalone/standalone.iml
    incubator/jsecurity/trunk/test/log4j.properties
    incubator/jsecurity/trunk/test/org/jsecurity/web/DefaultWebSecurityManagerTest.java
    incubator/jsecurity/trunk/test/org/jsecurity/web/servlet/JSecurityFilterTest.java

Modified: incubator/jsecurity/trunk/jsecurity.iml
URL: http://svn.apache.org/viewvc/incubator/jsecurity/trunk/jsecurity.iml?rev=729768&r1=729767&r2=729768&view=diff
==============================================================================
--- incubator/jsecurity/trunk/jsecurity.iml (original)
+++ incubator/jsecurity/trunk/jsecurity.iml Sun Dec 28 11:51:41 2008
@@ -9,11 +9,6 @@
           <file>file://$MODULE_DIR$/samples/spring/webroot/WEB-INF/sample-servlet.xml</file>
           <file>file://$MODULE_DIR$/samples/spring/webroot/WEB-INF/remoting-servlet.xml</file>
         </fileset>
-        <options>
-          <option name="enableValidation" value="true" />
-          <option name="reportErrorsAsWarnings" value="true" />
-        </options>
-        <customNs />
       </configuration>
     </facet>
     <facet type="web" name="jsecurity-web">
@@ -32,11 +27,7 @@
           <setting name="EXPLODED_ENABLED" value="true" />
           <setting name="JAR_URL" value="file://$MODULE_DIR$/out/Quickstart Webapp.war"
/>
           <setting name="JAR_ENABLED" value="false" />
-          <setting name="BUILD_MODULE_ON_FRAME_DEACTIVATION" value="false" />
-          <setting name="BUILD_EXTERNAL_DEPENDENCIES" value="false" />
           <setting name="EXCLUDE_EXPLODED_DIRECTORY" value="true" />
-          <setting name="RUN_JASPER_VALIDATION" value="true" />
-          <setting name="BUILD_ONLY_WEB_RESOURCES" value="false" />
         </building>
         <packaging>
           <containerElement type="module" name="jsecurity">
@@ -89,7 +80,6 @@
       </library>
     </orderEntry>
     <orderEntry type="library" name="quickstart-libs" level="project" />
-    <orderEntryProperties />
   </component>
   <component name="copyright">
     <Base>

Modified: incubator/jsecurity/trunk/jsecurity.ipr
URL: http://svn.apache.org/viewvc/incubator/jsecurity/trunk/jsecurity.ipr?rev=729768&r1=729767&r2=729768&view=diff
==============================================================================
--- incubator/jsecurity/trunk/jsecurity.ipr (original)
+++ incubator/jsecurity/trunk/jsecurity.ipr Sun Dec 28 11:51:41 2008
@@ -7,6 +7,7 @@
       <antReference projectDefault="true" />
       <customJdkName value="" />
       <maximumHeapSize value="128" />
+      <maximumStackSize value="32" />
       <properties />
     </buildFile>
   </component>
@@ -60,6 +61,7 @@
     <option name="ADDITIONAL_OPTIONS_STRING" value="" />
     <option name="MAXIMUM_HEAP_SIZE" value="128" />
   </component>
+  <component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false"
/>
   <component name="EntryPointsManager">
     <entry_points version="2.0" />
   </component>
@@ -275,6 +277,9 @@
       </item>
     </group>
   </component>
+  <component name="ProjectDetails">
+    <option name="projectName" value="jsecurity" />
+  </component>
   <component name="ProjectFileVersion" converted="true" />
   <component name="ProjectModuleManager">
     <modules>
@@ -283,7 +288,7 @@
       <module fileurl="file://$PROJECT_DIR$/samples/standalone/standalone.iml" filepath="$PROJECT_DIR$/samples/standalone/standalone.iml"
/>
     </modules>
   </component>
-  <component name="ProjectRootManager" version="2" assert-keyword="true" jdk-15="true"
project-jdk-name="1.5" project-jdk-type="JavaSDK">
+  <component name="ProjectRootManager" version="2" languageLevel="JDK_1_5" assert-keyword="true"
jdk-15="true" project-jdk-name="1.5" project-jdk-type="JavaSDK">
     <output url="file://$PROJECT_DIR$/build/idea" />
   </component>
   <component name="ResourceManagerContainer">
@@ -318,7 +323,7 @@
         </entry>
       </map>
     </option>
-    <option name="myVersion" value="123" />
+    <option name="myVersion" value="124" />
   </component>
   <component name="VcsDirectoryMappings">
     <mapping directory="" vcs="svn" />

Modified: incubator/jsecurity/trunk/samples/quickstart/quickstart.iml
URL: http://svn.apache.org/viewvc/incubator/jsecurity/trunk/samples/quickstart/quickstart.iml?rev=729768&r1=729767&r2=729768&view=diff
==============================================================================
--- incubator/jsecurity/trunk/samples/quickstart/quickstart.iml (original)
+++ incubator/jsecurity/trunk/samples/quickstart/quickstart.iml Sun Dec 28 11:51:41 2008
@@ -9,7 +9,6 @@
     <orderEntry type="sourceFolder" forTests="false" />
     <orderEntry type="module" module-name="jsecurity" />
     <orderEntry type="library" name="quickstart-libs" level="project" />
-    <orderEntryProperties />
   </component>
   <component name="copyright">
     <Base>

Modified: incubator/jsecurity/trunk/samples/standalone/standalone.iml
URL: http://svn.apache.org/viewvc/incubator/jsecurity/trunk/samples/standalone/standalone.iml?rev=729768&r1=729767&r2=729768&view=diff
==============================================================================
--- incubator/jsecurity/trunk/samples/standalone/standalone.iml (original)
+++ incubator/jsecurity/trunk/samples/standalone/standalone.iml Sun Dec 28 11:51:41 2008
@@ -8,7 +8,6 @@
     <orderEntry type="inheritedJdk" />
     <orderEntry type="sourceFolder" forTests="false" />
     <orderEntry type="module" module-name="jsecurity" />
-    <orderEntryProperties />
   </component>
   <component name="copyright">
     <Base>

Modified: incubator/jsecurity/trunk/test/log4j.properties
URL: http://svn.apache.org/viewvc/incubator/jsecurity/trunk/test/log4j.properties?rev=729768&r1=729767&r2=729768&view=diff
==============================================================================
--- incubator/jsecurity/trunk/test/log4j.properties (original)
+++ incubator/jsecurity/trunk/test/log4j.properties Sun Dec 28 11:51:41 2008
@@ -32,4 +32,6 @@
 # General Apache libraries is WARN
 log4j.logger.org.apache=WARN
 
-log4j.logger.net.sf.ehcache=WARN
\ No newline at end of file
+log4j.logger.net.sf.ehcache=WARN
+
+log4j.logger.org.jsecurity.util.ThreadContext=WARN
\ No newline at end of file

Modified: incubator/jsecurity/trunk/test/org/jsecurity/web/DefaultWebSecurityManagerTest.java
URL: http://svn.apache.org/viewvc/incubator/jsecurity/trunk/test/org/jsecurity/web/DefaultWebSecurityManagerTest.java?rev=729768&r1=729767&r2=729768&view=diff
==============================================================================
--- incubator/jsecurity/trunk/test/org/jsecurity/web/DefaultWebSecurityManagerTest.java (original)
+++ incubator/jsecurity/trunk/test/org/jsecurity/web/DefaultWebSecurityManagerTest.java Sun
Dec 28 11:51:41 2008
@@ -29,26 +29,23 @@
  */
 public class DefaultWebSecurityManagerTest {
 
+    private DefaultWebSecurityManager sm;
+
     @Before
     public void setup() {
+        sm = new DefaultWebSecurityManager();
         ThreadContext.clear();
     }
 
     @After
     public void tearDown() {
+        sm.destroy();
         ThreadContext.clear();
     }
 
     @Test
-    public void simpleWebSecurityManagerInit() {
-        DefaultWebSecurityManager dwsm = new DefaultWebSecurityManager();
-        dwsm.destroy();
+    public void jsecuritySessionModeInit() {
+        sm.setSessionMode(DefaultWebSecurityManager.JSECURITY_SESSION_MODE);
     }
 
-    @Test
-    public void jsecuritySessionModeWebSecurityManagerInit() {
-        DefaultWebSecurityManager dwsm = new DefaultWebSecurityManager();
-        dwsm.setSessionMode(DefaultWebSecurityManager.JSECURITY_SESSION_MODE);
-        dwsm.destroy();
-    }
 }

Modified: incubator/jsecurity/trunk/test/org/jsecurity/web/servlet/JSecurityFilterTest.java
URL: http://svn.apache.org/viewvc/incubator/jsecurity/trunk/test/org/jsecurity/web/servlet/JSecurityFilterTest.java?rev=729768&r1=729767&r2=729768&view=diff
==============================================================================
--- incubator/jsecurity/trunk/test/org/jsecurity/web/servlet/JSecurityFilterTest.java (original)
+++ incubator/jsecurity/trunk/test/org/jsecurity/web/servlet/JSecurityFilterTest.java Sun
Dec 28 11:51:41 2008
@@ -19,10 +19,16 @@
 package org.jsecurity.web.servlet;
 
 import static org.easymock.EasyMock.*;
+import org.jsecurity.util.ThreadContext;
+import org.junit.After;
+import org.junit.Before;
 import org.junit.Test;
 
+import javax.servlet.FilterChain;
 import javax.servlet.FilterConfig;
 import javax.servlet.ServletContext;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
 
 /**
  * @author Les Hazlewood
@@ -30,13 +36,27 @@
  */
 public class JSecurityFilterTest {
 
+    private static final String FILTER_NAME = "JSecurityFilter";
+
     private JSecurityFilter filter;
     private FilterConfig mockFilterConfig;
     private ServletContext mockServletContext;
+    private FilterChain mockFilterChain;
+
+    @Before
+    public void setUp() {
+        ThreadContext.clear();
+    }
+
+    @After
+    public void tearDown() {
+        ThreadContext.clear();
+    }
 
     protected void setUp(String config) {
         mockFilterConfig = createMock(FilterConfig.class);
         mockServletContext = createMock(ServletContext.class);
+        mockFilterChain = createNiceMock(FilterChain.class);
 
         expect(mockFilterConfig.getServletContext()).andReturn(mockServletContext);
         expect(mockFilterConfig.getInitParameter(JSecurityFilter.CONFIG_CLASS_NAME_INIT_PARAM_NAME)).andReturn(null).once();
@@ -44,18 +64,6 @@
         expect(mockFilterConfig.getInitParameter(JSecurityFilter.CONFIG_URL_INIT_PARAM_NAME)).andReturn(null).once();
     }
 
-    public void tearDown() throws Exception {
-        reset(mockServletContext);
-        reset(mockFilterConfig);
-
-        replay(mockServletContext);
-
-        //this.filter.destroy();
-
-        verify(mockServletContext);
-        verify(mockFilterConfig);
-    }
-
     protected void replayAndVerify() throws Exception {
         replay(mockServletContext);
         replay(mockFilterConfig);
@@ -63,7 +71,6 @@
         this.filter = new JSecurityFilter();
         this.filter.init(mockFilterConfig);
 
-
         verify(mockFilterConfig);
         verify(mockServletContext);
     }
@@ -81,4 +88,52 @@
                 "authc.successUrl = /index.jsp");
         replayAndVerify();
     }
+
+    protected void testRequest(String config) throws Exception {
+        setUp(config);
+        expect(mockFilterConfig.getFilterName()).andReturn(FILTER_NAME);
+        replay(mockServletContext);
+        replay(mockFilterConfig);
+
+        filter = new JSecurityFilter();
+        filter.init(mockFilterConfig);
+
+        HttpServletRequest mockRequest = createNiceMock(HttpServletRequest.class);
+        mockRequest.setAttribute(FILTER_NAME + JSecurityFilter.ALREADY_FILTERED_SUFFIX, Boolean.TRUE);
+
+        HttpServletResponse mockResponse = createNiceMock(HttpServletResponse.class);
+
+        replay(mockRequest);
+
+        filter.doFilter(mockRequest, mockResponse, mockFilterChain);
+
+        verify(mockRequest);
+        verify(mockFilterConfig);
+        verify(mockServletContext);
+    }
+
+    /**
+     * Along with {@link #testSimpleRequestJSecuritySessionMode()}, this method asserts that
+     * <a href="https://issues.apache.org/jira/browse/JSEC-33">JSEC-33</a> is
resolved.
+     *
+     * @throws Exception if an error occurs
+     */
+    @Test
+    public void testSimpleRequest() throws Exception {
+        testRequest(null);
+    }
+
+    /**
+     * Along with {@link #testSimpleRequest()}, this method asserts that
+     * <a href="https://issues.apache.org/jira/browse/JSEC-33">JSEC-33</a> is
resolved.
+     *
+     * @throws Exception if an error occurs
+     */
+    @Test
+    public void testSimpleRequestJSecuritySessionMode() throws Exception {
+        String config = "[main]\n" +
+                "securityManager.sessionMode = jsecurity";
+        testRequest(config);
+
+    }
 }



Mime
View raw message