SEC-428: Tests to prove proxy-target-class="true" works.

This commit is contained in:
Ben Alex 2008-03-24 23:10:01 +00:00
parent f8b5000d40
commit f4eb15b08b
3 changed files with 27 additions and 6 deletions

View File

@ -55,7 +55,6 @@
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>1.5.4</version>
<scope>test</scope>
<optional>true</optional>
</dependency>
@ -64,6 +63,12 @@
<artifactId>spring-ldap</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib-nodep</artifactId>
<scope>test</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache</artifactId>

View File

@ -13,6 +13,7 @@ import org.springframework.security.util.InMemoryXmlApplicationContext;
* Tests for SEC-428.
*
* @author Luke Taylor
* @author Ben Alex
*/
public class MethodSecurityInterceptorWithAopConfigTests {
static final String AUTH_PROVIDER_XML =
@ -39,7 +40,8 @@ public class MethodSecurityInterceptorWithAopConfigTests {
@After
public void closeAppContext() {
if (appContext != null) {
SecurityContextHolder.clearContext();
if (appContext != null) {
appContext.close();
appContext = null;
}
@ -48,7 +50,7 @@ public class MethodSecurityInterceptorWithAopConfigTests {
@Test(expected=AuthenticationCredentialsNotFoundException.class)
public void securityInterceptorIsAppliedWhenUsedWithAopConfig() {
setContext(
"<aop:config>" +
"<aop:config proxy-target-class=\"true\">" +
" <aop:pointcut id='targetMethods' expression='execution(* org.springframework.security.TargetObject.*(..))'/>" +
" <aop:advisor advice-ref='securityInterceptor' pointcut-ref='targetMethods' />" +
"</aop:config>" +
@ -56,9 +58,9 @@ public class MethodSecurityInterceptorWithAopConfigTests {
"<b:bean id='securityInterceptor' class='org.springframework.security.intercept.method.aopalliance.MethodSecurityInterceptor' autowire='byType' >" +
" <b:property name='objectDefinitionSource'>" +
" <b:value>" +
"org.springframework.security.ITargetObject.makeLower*=ROLE_A\n" +
"org.springframework.security.ITargetObject.makeUpper*=ROLE_A\n" +
"org.springframework.security.ITargetObject.computeHashCode*=ROLE_B\n" +
"org.springframework.security.TargetObject.makeLower*=ROLE_A\n" +
"org.springframework.security.TargetObject.makeUpper*=ROLE_A\n" +
"org.springframework.security.TargetObject.computeHashCode*=ROLE_B\n" +
" </b:value>" +
" </b:property>" +
"</b:bean>" +

14
pom.xml
View File

@ -659,6 +659,13 @@
<artifactId>spring-ldap</artifactId>
<version>1.2.1</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<scope>test</scope>
<optional>true</optional>
<version>1.5.4</version>
</dependency>
<dependency>
<groupId>aspectj</groupId>
<artifactId>aspectjrt</artifactId>
@ -669,6 +676,13 @@
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib-nodep</artifactId>
<scope>test</scope>
<optional>true</optional>
<version>2.1_3</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>