|
@@ -18,6 +18,8 @@ package org.springframework.security.taglibs.authz;
|
|
|
import junit.framework.TestCase;
|
|
|
|
|
|
|
|
|
+import org.springframework.mock.web.MockPageContext;
|
|
|
+import org.springframework.mock.web.MockServletContext;
|
|
|
import org.springframework.security.authentication.TestingAuthenticationToken;
|
|
|
import org.springframework.security.core.GrantedAuthority;
|
|
|
import org.springframework.security.core.authority.GrantedAuthorityImpl;
|
|
@@ -29,7 +31,6 @@ import javax.servlet.jsp.tagext.Tag;
|
|
|
|
|
|
|
|
|
/**
|
|
|
- * DOCUMENT ME!
|
|
|
*
|
|
|
* @author Francois Beausoleil
|
|
|
*/
|
|
@@ -42,7 +43,7 @@ public class AuthorizeTagAttributeTests extends TestCase {
|
|
|
//~ Methods ========================================================================================================
|
|
|
|
|
|
protected void setUp() throws Exception {
|
|
|
- super.setUp();
|
|
|
+ authorizeTag.setPageContext(new MockPageContext(new MockServletContext()));
|
|
|
|
|
|
currentUser = new TestingAuthenticationToken("abc", "123",
|
|
|
new GrantedAuthority[] {
|
|
@@ -75,21 +76,18 @@ public class AuthorizeTagAttributeTests extends TestCase {
|
|
|
assertEquals("prevents request - principal has ROLE_RESTRICTED", Tag.SKIP_BODY, authorizeTag.doStartTag());
|
|
|
}
|
|
|
|
|
|
- public void testAssertsIfNotGrantedIgnoresWhitespaceInAttribute()
|
|
|
- throws JspException {
|
|
|
+ public void testAssertsIfNotGrantedIgnoresWhitespaceInAttribute() throws JspException {
|
|
|
authorizeTag.setIfAnyGranted("\tROLE_SUPERVISOR \t, \r\n\t ROLE_TELLER ");
|
|
|
assertEquals("allows request - principal has ROLE_SUPERVISOR", Tag.EVAL_BODY_INCLUDE, authorizeTag.doStartTag());
|
|
|
}
|
|
|
|
|
|
- public void testIfAllGrantedIgnoresWhitespaceInAttribute()
|
|
|
- throws JspException {
|
|
|
+ public void testIfAllGrantedIgnoresWhitespaceInAttribute() throws JspException {
|
|
|
authorizeTag.setIfAllGranted("\nROLE_SUPERVISOR\t,ROLE_RESTRICTED\t\n\r ");
|
|
|
assertEquals("allows request - principal has ROLE_RESTRICTED " + "and ROLE_SUPERVISOR", Tag.EVAL_BODY_INCLUDE,
|
|
|
authorizeTag.doStartTag());
|
|
|
}
|
|
|
|
|
|
- public void testIfNotGrantedIgnoresWhitespaceInAttribute()
|
|
|
- throws JspException {
|
|
|
+ public void testIfNotGrantedIgnoresWhitespaceInAttribute() throws JspException {
|
|
|
authorizeTag.setIfNotGranted(" \t ROLE_TELLER \r");
|
|
|
assertEquals("allows request - principal does not have ROLE_TELLER", Tag.EVAL_BODY_INCLUDE,
|
|
|
authorizeTag.doStartTag());
|