shiro-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lhazlew...@apache.org
Subject svn commit: r811404 - in /incubator/shiro/trunk/samples/web: pom.xml src/main/webapp/login.jsp src/test/java/org/apache/shiro/test/AbstractContainerTest.java src/test/java/org/apache/shiro/test/ContainerIntegrationTest.java
Date Fri, 04 Sep 2009 13:50:14 GMT
Author: lhazlewood
Date: Fri Sep  4 13:50:14 2009
New Revision: 811404

URL: http://svn.apache.org/viewvc?rev=811404&view=rev
Log:
SHIRO-96: applied patch

Modified:
    incubator/shiro/trunk/samples/web/pom.xml
    incubator/shiro/trunk/samples/web/src/main/webapp/login.jsp
    incubator/shiro/trunk/samples/web/src/test/java/org/apache/shiro/test/AbstractContainerTest.java
    incubator/shiro/trunk/samples/web/src/test/java/org/apache/shiro/test/ContainerIntegrationTest.java

Modified: incubator/shiro/trunk/samples/web/pom.xml
URL: http://svn.apache.org/viewvc/incubator/shiro/trunk/samples/web/pom.xml?rev=811404&r1=811403&r2=811404&view=diff
==============================================================================
--- incubator/shiro/trunk/samples/web/pom.xml (original)
+++ incubator/shiro/trunk/samples/web/pom.xml Fri Sep  4 13:50:14 2009
@@ -87,7 +87,7 @@
         <dependency>
             <groupId>net.sourceforge.htmlunit</groupId>
             <artifactId>htmlunit</artifactId>
-            <version>2.5</version>
+            <version>2.6</version>
             <scope>test</scope>
         </dependency>
         <dependency>

Modified: incubator/shiro/trunk/samples/web/src/main/webapp/login.jsp
URL: http://svn.apache.org/viewvc/incubator/shiro/trunk/samples/web/src/main/webapp/login.jsp?rev=811404&r1=811403&r2=811404&view=diff
==============================================================================
--- incubator/shiro/trunk/samples/web/src/main/webapp/login.jsp (original)
+++ incubator/shiro/trunk/samples/web/src/main/webapp/login.jsp Fri Sep  4 13:50:14 2009
@@ -37,7 +37,7 @@
             border-style: outset;
             border-color: blue;
             border-collapse: separate;
-            background-color: rgb( 255, 255, 240 );
+            background-color: rgb(255, 255, 240);
         }
 
         table.sample th {
@@ -45,7 +45,7 @@
             padding: 1px;
             border-style: none;
             border-color: blue;
-            background-color: rgb( 255, 255, 240 );
+            background-color: rgb(255, 255, 240);
         }
 
         table.sample td {
@@ -53,41 +53,41 @@
             padding: 1px;
             border-style: none;
             border-color: blue;
-            background-color: rgb( 255, 255, 240 );
+            background-color: rgb(255, 255, 240);
         }
     </style>
 
 
     <table class="sample">
         <thead>
-            <tr>
-                <th>Username</th>
-                <th>Password</th>
-            </tr>
+        <tr>
+            <th>Username</th>
+            <th>Password</th>
+        </tr>
         </thead>
         <tbody>
-            <tr>
-                <td>root</td>
-                <td>secret</td>
-            </tr>
-            <tr>
-                <td>presidentskroob</td>
-                <td>12345</td>
-            </tr>
-            <tr>
-                <td>darkhelmet</td>
-                <td>ludicrousspeed</td>
-            </tr>
-            <tr>
-                <td>lonestarr</td>
-                <td>vespa</td>
-            </tr>
+        <tr>
+            <td>root</td>
+            <td>secret</td>
+        </tr>
+        <tr>
+            <td>presidentskroob</td>
+            <td>12345</td>
+        </tr>
+        <tr>
+            <td>darkhelmet</td>
+            <td>ludicrousspeed</td>
+        </tr>
+        <tr>
+            <td>lonestarr</td>
+            <td>vespa</td>
+        </tr>
         </tbody>
     </table>
     <br/><br/>
 </shiro:guest>
 
-<form action="" method="post">
+<form name="loginform" action="" method="post">
     <table align="left" border="0" cellspacing="0" cellpadding="3">
         <tr>
             <td>Username:</td>
@@ -107,4 +107,4 @@
 </form>
 
 </body>
-</html>
\ No newline at end of file
+</html>

Modified: incubator/shiro/trunk/samples/web/src/test/java/org/apache/shiro/test/AbstractContainerTest.java
URL: http://svn.apache.org/viewvc/incubator/shiro/trunk/samples/web/src/test/java/org/apache/shiro/test/AbstractContainerTest.java?rev=811404&r1=811403&r2=811404&view=diff
==============================================================================
--- incubator/shiro/trunk/samples/web/src/test/java/org/apache/shiro/test/AbstractContainerTest.java
(original)
+++ incubator/shiro/trunk/samples/web/src/test/java/org/apache/shiro/test/AbstractContainerTest.java
Fri Sep  4 13:50:14 2009
@@ -19,7 +19,6 @@
 package org.apache.shiro.test;
 
 import com.gargoylesoftware.htmlunit.WebClient;
-import org.junit.AfterClass;
 import static org.junit.Assert.assertTrue;
 import org.junit.Before;
 import org.junit.BeforeClass;
@@ -55,18 +54,9 @@
             server.setHandler(handlers);
             server.start();
             assertTrue(server.isStarted());
-
         }
     }
 
-    @AfterClass
-    public static void stopContainer() throws Exception {
-        // Don't stop the server here, because it causes issues with already initialized
-        // statics - for example with file upload
-        // server.stop();
-        // server = null;
-    }
-
     @Before
     public void beforeTest() {
         webClient.setThrowExceptionOnFailingStatusCode(true);

Modified: incubator/shiro/trunk/samples/web/src/test/java/org/apache/shiro/test/ContainerIntegrationTest.java
URL: http://svn.apache.org/viewvc/incubator/shiro/trunk/samples/web/src/test/java/org/apache/shiro/test/ContainerIntegrationTest.java?rev=811404&r1=811403&r2=811404&view=diff
==============================================================================
--- incubator/shiro/trunk/samples/web/src/test/java/org/apache/shiro/test/ContainerIntegrationTest.java
(original)
+++ incubator/shiro/trunk/samples/web/src/test/java/org/apache/shiro/test/ContainerIntegrationTest.java
Fri Sep  4 13:50:14 2009
@@ -18,20 +18,61 @@
  */
 package org.apache.shiro.test;
 
+import com.gargoylesoftware.htmlunit.ElementNotFoundException;
 import com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException;
-import static com.gargoylesoftware.htmlunit.WebAssert.assertTitleEquals;
+import com.gargoylesoftware.htmlunit.WebAssert;
+import com.gargoylesoftware.htmlunit.html.HtmlCheckBoxInput;
+import com.gargoylesoftware.htmlunit.html.HtmlForm;
 import com.gargoylesoftware.htmlunit.html.HtmlPage;
+import org.junit.Before;
 import org.junit.Test;
 
 import java.io.IOException;
 import java.net.MalformedURLException;
 
 public class ContainerIntegrationTest extends AbstractContainerTest {
+    @Before
+    public void logOut() throws IOException {
+        // Make sure we are logged out
+        final HtmlPage homePage = webClient.getPage(BASEURI);
+        try {
+            homePage.getAnchorByHref("/logout.jsp").click();
+        }
+        catch (ElementNotFoundException e) {
+            //Ignore
+        }
+    }
+
     @Test
-    public void checkOrganizationsDisplayedOnIndexPage() throws FailingHttpStatusCodeException,
MalformedURLException, IOException {
-        final HtmlPage page = webClient.getPage(BASEURI);
-        //assertTrue(page.getTitleText().contains("Apache Shiro Quickstart") );
-        assertTitleEquals(page, "Apache Shiro Quickstart");
+    public void logIn() throws FailingHttpStatusCodeException, MalformedURLException, IOException,
InterruptedException {
 
+        HtmlPage page = webClient.getPage(BASEURI + "login.jsp");
+        HtmlForm form = page.getFormByName("loginform");
+        form.getInputByName("username").setValueAttribute("root");
+        form.getInputByName("password").setValueAttribute("secret");
+        page = form.getInputByName("submit").click();
+        // This'll throw an expection if not logged in
+        page.getAnchorByHref("/logout.jsp");
     }
+
+    @Test
+    public void logInAndRememberMe() throws Exception {
+        HtmlPage page = webClient.getPage(BASEURI + "login.jsp");
+        HtmlForm form = page.getFormByName("loginform");
+        form.getInputByName("username").setValueAttribute("root");
+        form.getInputByName("password").setValueAttribute("secret");
+        HtmlCheckBoxInput checkbox = form.getInputByName("rememberMe");
+        checkbox.setChecked(true);
+        page = form.getInputByName("submit").click();
+        server.stop();
+        server.start();
+        page = webClient.getPage(BASEURI);
+        // page.getAnchorByHref("/logout.jsp");
+        WebAssert.assertLinkPresentWithText(page, "Log out");
+        page = page.getAnchorByHref("/account").click();
+        // login page should be shown again - user remembered but not authenticated
+        WebAssert.assertFormPresent(page, "loginform");
+
+    }
+
 }



Mime
View raw message