bdemers commented on a change in pull request #132: [SHIRO-685] Potential
NullPointerException if PermissionResolver retu…
URL: https://github.com/apache/shiro/pull/132#discussion_r282270904
##########
File path: core/src/test/java/org/apache/shiro/realm/AuthorizingRealmTest.java
##########
@@ -214,6 +228,36 @@ public void testRealmWithRolePermissionResolver()
assertTrue( realm.isPermitted( pCollection, "other:bar:foo" ) );
}
+ @Test
+ public void testRealmWithEmptyOrNullPermissions() {
+ Principal principal = new UsernamePrincipal("rolePermResolver");
+ PrincipalCollection pCollection = new
SimplePrincipalCollection(principal, "testRealmWithRolePermissionResolver");
+
+ AuthorizingRealm realm = new AllowAllRealm();
+ realm.setRolePermissionResolver( new RolePermissionResolver()
+ {
+ public Collection<Permission> resolvePermissionsInRole( String
roleString )
+ {
+ Collection<Permission> permissions = new HashSet<Permission>();
+ if( roleString.equals( ROLE ))
+ {
+ permissions.add( new WildcardPermission( ROLE + ":perm1" )
);
+ permissions.add( new WildcardPermission( ROLE + ":perm2" )
);
+ permissions.add( new WildcardPermission( "other:*:foo" ) );
Review comment:
Looks good!
Couple minor nits:
We should probably add a null/empty string here too?
and maybe a whitespace string to both? `" "` `"\t "`? (that might be covered
in existing tests though)
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services