shiro-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lhazlew...@apache.org
Subject svn commit: r964871 - in /incubator/shiro/trunk/support/aspectj/src/test: java/org/apache/shiro/aspectj/DummyServiceTest.java java/org/apache/shiro/aspectj/SecuredDummyService.java resources/shiroDummyServiceTest.ini
Date Fri, 16 Jul 2010 17:41:49 GMT
Author: lhazlewood
Date: Fri Jul 16 17:41:48 2010
New Revision: 964871

URL: http://svn.apache.org/viewvc?rev=964871&view=rev
Log:
test semantics were slightly incorrect - fixed to reflect @RequiresGuest semantics

Modified:
    incubator/shiro/trunk/support/aspectj/src/test/java/org/apache/shiro/aspectj/DummyServiceTest.java
    incubator/shiro/trunk/support/aspectj/src/test/java/org/apache/shiro/aspectj/SecuredDummyService.java
    incubator/shiro/trunk/support/aspectj/src/test/resources/shiroDummyServiceTest.ini

Modified: incubator/shiro/trunk/support/aspectj/src/test/java/org/apache/shiro/aspectj/DummyServiceTest.java
URL: http://svn.apache.org/viewvc/incubator/shiro/trunk/support/aspectj/src/test/java/org/apache/shiro/aspectj/DummyServiceTest.java?rev=964871&r1=964870&r2=964871&view=diff
==============================================================================
--- incubator/shiro/trunk/support/aspectj/src/test/java/org/apache/shiro/aspectj/DummyServiceTest.java
(original)
+++ incubator/shiro/trunk/support/aspectj/src/test/java/org/apache/shiro/aspectj/DummyServiceTest.java
Fri Jul 16 17:41:48 2010
@@ -30,10 +30,7 @@ import org.apache.shiro.config.IniSecuri
 import org.apache.shiro.mgt.SecurityManager;
 import org.apache.shiro.subject.Subject;
 import org.apache.shiro.util.Factory;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.*;
 
 /**
  */
@@ -56,6 +53,12 @@ public class DummyServiceTest {
         RESTRICTED_SERVICE = new RestrictedDummyService();
     }
 
+    @AfterClass
+    public static void tearDownClass() throws Exception {
+        //don't corrupt other test cases since this is static memory:
+        SecurityUtils.setSecurityManager(null);
+    }
+
     private Subject subject;
 
     @Before
@@ -68,11 +71,6 @@ public class DummyServiceTest {
         subject.logout();
     }
 
-
-    private void loginAsGuest() {
-        subject.login(new UsernamePasswordToken("john", "doe"));
-    }
-
     private void loginAsUser() {
         subject.login(new UsernamePasswordToken("joe", "bob"));
     }
@@ -81,21 +79,13 @@ public class DummyServiceTest {
         subject.login(new UsernamePasswordToken("root", "secret"));
     }
 
-
     // TEST ANONYMOUS
-
     @Test
     public void testAnonymous_asAnonymous() throws Exception {
         SECURED_SERVICE.anonymous();
     }
 
     @Test
-    public void testAnonymous_asGuest() throws Exception {
-        loginAsGuest();
-        SECURED_SERVICE.anonymous();
-    }
-
-    @Test
     public void testAnonymous_asUser() throws Exception {
         loginAsUser();
         SECURED_SERVICE.anonymous();
@@ -107,47 +97,31 @@ public class DummyServiceTest {
         SECURED_SERVICE.anonymous();
     }
 
-
     // TEST GUEST
-
-    @Test(expected = UnauthenticatedException.class)
-    public void testGuest_asAnonymous() throws Exception {
-        SECURED_SERVICE.guest();
-    }
-
     @Test
-    public void testGuest_asGuest() throws Exception {
-        loginAsGuest();
+    public void testGuest_asAnonymous() throws Exception {
         SECURED_SERVICE.guest();
     }
 
-    @Test
+    @Test(expected = UnauthenticatedException.class)
     public void testGuest_asUser() throws Exception {
         loginAsUser();
         SECURED_SERVICE.guest();
     }
 
-    @Test
+    @Test(expected = UnauthenticatedException.class)
     public void testGuest_asAdmin() throws Exception {
         loginAsAdmin();
         SECURED_SERVICE.guest();
     }
 
-
     // TEST PEEK
-
     @Test(expected = UnauthenticatedException.class)
     public void testPeek_asAnonymous() throws Exception {
         SECURED_SERVICE.peek();
     }
 
     @Test
-    public void testPeek_asGuest() throws Exception {
-        loginAsGuest();
-        SECURED_SERVICE.peek();
-    }
-
-    @Test
     public void testPeek_asUser() throws Exception {
         loginAsUser();
         SECURED_SERVICE.peek();
@@ -159,21 +133,13 @@ public class DummyServiceTest {
         SECURED_SERVICE.peek();
     }
 
-
     // TEST RETRIEVE
-
     @Test(expected = UnauthenticatedException.class)
     //UnauthenticatedException per SHIRO-146
     public void testRetrieve_asAnonymous() throws Exception {
         SECURED_SERVICE.retrieve();
     }
 
-    @Test(expected = UnauthorizedException.class)
-    public void testRetrieve_asGuest() throws Exception {
-        loginAsGuest();
-        SECURED_SERVICE.retrieve();
-    }
-
     @Test
     public void testRetrieve_asUser() throws Exception {
         loginAsUser();
@@ -186,9 +152,7 @@ public class DummyServiceTest {
         SECURED_SERVICE.retrieve();
     }
 
-
     // TEST CHANGE
-
     @Test(expected = UnauthenticatedException.class)
     //UnauthenticatedException per SHIRO-146
     public void testChange_asAnonymous() throws Exception {
@@ -196,12 +160,6 @@ public class DummyServiceTest {
     }
 
     @Test(expected = UnauthorizedException.class)
-    public void testChange_asGuest() throws Exception {
-        loginAsGuest();
-        SECURED_SERVICE.change();
-    }
-
-    @Test(expected = UnauthorizedException.class)
     public void testChange_asUser() throws Exception {
         loginAsUser();
         SECURED_SERVICE.change();
@@ -213,9 +171,7 @@ public class DummyServiceTest {
         SECURED_SERVICE.change();
     }
 
-
     // TEST RETRIEVE RESTRICTED
-
     @Test(expected = UnauthenticatedException.class)
     //UnauthenticatedException per SHIRO-146
     public void testRetrieveRestricted_asAnonymous() throws Exception {
@@ -223,12 +179,6 @@ public class DummyServiceTest {
     }
 
     @Test(expected = UnauthorizedException.class)
-    public void testRetrieveRestricted_asGuest() throws Exception {
-        loginAsGuest();
-        RESTRICTED_SERVICE.retrieve();
-    }
-
-    @Test(expected = UnauthorizedException.class)
     public void testRetrieveRestricted_asUser() throws Exception {
         loginAsUser();
         RESTRICTED_SERVICE.retrieve();

Modified: incubator/shiro/trunk/support/aspectj/src/test/java/org/apache/shiro/aspectj/SecuredDummyService.java
URL: http://svn.apache.org/viewvc/incubator/shiro/trunk/support/aspectj/src/test/java/org/apache/shiro/aspectj/SecuredDummyService.java?rev=964871&r1=964870&r2=964871&view=diff
==============================================================================
--- incubator/shiro/trunk/support/aspectj/src/test/java/org/apache/shiro/aspectj/SecuredDummyService.java
(original)
+++ incubator/shiro/trunk/support/aspectj/src/test/java/org/apache/shiro/aspectj/SecuredDummyService.java
Fri Jul 16 17:41:48 2010
@@ -19,6 +19,7 @@
 package org.apache.shiro.aspectj;
 
 import org.apache.shiro.authz.annotation.RequiresAuthentication;
+import org.apache.shiro.authz.annotation.RequiresGuest;
 import org.apache.shiro.authz.annotation.RequiresPermissions;
 import org.apache.shiro.authz.annotation.RequiresUser;
 
@@ -42,7 +43,7 @@ public class SecuredDummyService impleme
         log("anonymous");
     }
 
-    @RequiresAuthentication
+    @RequiresGuest
     public void guest() {
         log("guest");
     }

Modified: incubator/shiro/trunk/support/aspectj/src/test/resources/shiroDummyServiceTest.ini
URL: http://svn.apache.org/viewvc/incubator/shiro/trunk/support/aspectj/src/test/resources/shiroDummyServiceTest.ini?rev=964871&r1=964870&r2=964871&view=diff
==============================================================================
--- incubator/shiro/trunk/support/aspectj/src/test/resources/shiroDummyServiceTest.ini (original)
+++ incubator/shiro/trunk/support/aspectj/src/test/resources/shiroDummyServiceTest.ini Fri
Jul 16 17:41:48 2010
@@ -27,8 +27,6 @@
 [users]
 root = secret, admin
 joe = bob, user
-john = doe
-
 
 # -----------------------------------------------------------------------------
 # Roles with assigned permissions



Mime
View raw message