Unit testing "authorize" Spring Security JSP taglib -
is there way unit test use of authorize tag provided spring security? mockmvc integration not go far enough that, can seem check forwarded/redirected url not content of url.
the work doing involves writing custom spel expressions , great check work on real sec:authorize
usages! right confined testing basic call these expressions working outside scope of jsp pages (specifically using access
attribute in intercept-url
element)
unfortunately, jsps don't work in unit testing since need compiled servlet container. recommend using works without container (i.e. thymeleaf) since can render response in these instances.
if use technology can render outside of container, can leverage htmlunit mockmvc integration found in spring framework 4.2+. if on older version of spring framework , cannot upgrade, can use spring test htmlunit.
note spring test htmlunit maintained part of spring framework 4.2+ , not distinct project.
if must use jsps, painful. however, there pretty decent github project lists mechanisms unit testing jsps. out of options jsptest seems promising (but still quite dated).
if feeling ambitious quite interesting see if provide hook jasper (tomcat's jsp compiler) work mockmvc.
Comments
Post a Comment