shiro-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdem...@apache.org
Subject [4/5] shiro git commit: added test cases
Date Mon, 02 Apr 2018 22:38:49 GMT
added test cases

Project: http://git-wip-us.apache.org/repos/asf/shiro/repo
Commit: http://git-wip-us.apache.org/repos/asf/shiro/commit/3ac4c0c2
Tree: http://git-wip-us.apache.org/repos/asf/shiro/tree/3ac4c0c2
Diff: http://git-wip-us.apache.org/repos/asf/shiro/diff/3ac4c0c2

Branch: refs/heads/master
Commit: 3ac4c0c2c0a91824c9694253c0653cc5e406d9e6
Parents: 2f949c7
Author: claude <claude@claude-XPS-15-9560>
Authored: Tue Jan 23 10:31:30 2018 +0000
Committer: claude <claude@claude-XPS-15-9560>
Committed: Tue Jan 23 10:31:30 2018 +0000

----------------------------------------------------------------------
 .../WildcardPermissionResolverTest.java         | 57 ++++++++++++++++++++
 1 file changed, 57 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/shiro/blob/3ac4c0c2/core/src/test/java/org/apache/shiro/authz/permission/WildcardPermissionResolverTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/shiro/authz/permission/WildcardPermissionResolverTest.java
b/core/src/test/java/org/apache/shiro/authz/permission/WildcardPermissionResolverTest.java
new file mode 100644
index 0000000..551512e
--- /dev/null
+++ b/core/src/test/java/org/apache/shiro/authz/permission/WildcardPermissionResolverTest.java
@@ -0,0 +1,57 @@
+package org.apache.shiro.authz.permission;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import javax.naming.spi.Resolver;
+
+import org.junit.Test;
+
+public class WildcardPermissionResolverTest {
+
+    @Test
+    public void testDefaultIsNonCaseSensitive()
+    {
+        WildcardPermissionResolver resolver = new WildcardPermissionResolver();
+        assertFalse( "Default sensitivity should be false", resolver.isCaseSensitive());
+        /* this is a round-about test as permissions don't store case sensitivity just lower
case 
+        the string. */
+        WildcardPermission permission = (WildcardPermission) resolver.resolvePermission(
"Foo:*" );
+        assertEquals( "string should be lowercase", "foo:*", permission.toString());
+    }
+    
+    @Test
+    public void testCaseSensitive()
+    {
+        WildcardPermissionResolver resolver = new WildcardPermissionResolver(true);
+        assertTrue( "Sensitivity should be true", resolver.isCaseSensitive());
+        /* this is a round-about test as permissions don't store case sensitivity just lower
case 
+        the string. */
+        WildcardPermission permission = (WildcardPermission) resolver.resolvePermission(
"Foo:*" );
+        assertEquals( "string should be mixed case", "Foo:*", permission.toString());
+    }
+
+    @Test
+    public void testCaseInsensitive()
+    {
+        WildcardPermissionResolver resolver = new WildcardPermissionResolver(false);
+        assertFalse( "Sensitivity should be false", resolver.isCaseSensitive());
+        /* this is a round-about test as permissions don't store case sensitivity just lower
case 
+        the string. */
+        WildcardPermission permission = (WildcardPermission) resolver.resolvePermission(
"Foo:*" );
+        assertEquals( "string should be lowercase", "foo:*", permission.toString());
+    }
+    
+    @Test
+    public void testCaseSensitiveToggle()
+    {
+        WildcardPermissionResolver resolver = new WildcardPermissionResolver();
+        assertFalse( "Default sensitivity should be false", resolver.isCaseSensitive());
+        resolver.setCaseSensitive( true );
+        assertTrue( "Sensitivity should be true", resolver.isCaseSensitive());
+        resolver.setCaseSensitive( false );
+        assertFalse( "Sensitivity should be false", resolver.isCaseSensitive());
+    }
+
+}


Mime
View raw message