1
0
mirror of synced 2026-08-05 01:36:56 +00:00

SEC-1749: Add support for PageContext lookup of objects and use of PermissionEvaluator when using web access expressions.

This commit is contained in:
Luke Taylor
2011-05-19 14:35:37 +01:00
parent c758f36629
commit 63f160dc72
8 changed files with 112 additions and 26 deletions
@@ -44,6 +44,7 @@ public class AuthorizeTagTests {
//~ Instance fields ================================================================================================
private JspAuthorizeTag authorizeTag;
private MockHttpServletRequest request = new MockHttpServletRequest();
private final TestingAuthenticationToken currentUser = new TestingAuthenticationToken("abc", "123", "ROLE SUPERVISOR", "ROLE_TELLER");
//~ Methods ========================================================================================================
@@ -57,7 +58,7 @@ public class AuthorizeTagTests {
MockServletContext servletCtx = new MockServletContext();
servletCtx.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, ctx);
authorizeTag = new JspAuthorizeTag();
authorizeTag.setPageContext(new MockPageContext(servletCtx, new MockHttpServletRequest(), new MockHttpServletResponse()));
authorizeTag.setPageContext(new MockPageContext(servletCtx, request, new MockHttpServletResponse()));
}
@After
@@ -86,6 +87,13 @@ public class AuthorizeTagTests {
assertEquals(Tag.EVAL_BODY_INCLUDE, authorizeTag.doStartTag());
}
@Test
public void requestAttributeIsResolvedAsElVariable() throws JspException {
request.setAttribute("blah", "blah");
authorizeTag.setAccess("#blah == 'blah'");
assertEquals(Tag.EVAL_BODY_INCLUDE, authorizeTag.doStartTag());
}
// url attribute tests
@Test
public void skipsBodyWithUrlSetIfNoAuthenticationPresent() throws Exception {