diff --git a/config/src/test/java/org/springframework/security/intercept/method/aopalliance/MethodSecurityInterceptorWithAopConfigTests.java b/config/src/test/java/org/springframework/security/intercept/method/aopalliance/MethodSecurityInterceptorWithAopConfigTests.java
index a394fd03fc..8fe50b00e4 100644
--- a/config/src/test/java/org/springframework/security/intercept/method/aopalliance/MethodSecurityInterceptorWithAopConfigTests.java
+++ b/config/src/test/java/org/springframework/security/intercept/method/aopalliance/MethodSecurityInterceptorWithAopConfigTests.java
@@ -1,5 +1,7 @@
package org.springframework.security.intercept.method.aopalliance;
+import static org.junit.Assert.*;
+
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -10,7 +12,7 @@ import org.springframework.security.config.util.InMemoryXmlApplicationContext;
import org.springframework.security.core.context.SecurityContextHolder;
/**
- * Tests for SEC-428.
+ * Tests for SEC-428 (and SEC-1204).
*
* @author Luke Taylor
* @author Ben Alex
@@ -31,6 +33,18 @@ public class MethodSecurityInterceptorWithAopConfigTests {
" " +
"";
+ static final String TARGET_BEAN_AND_INTERCEPTOR =
+ "" +
+ "" +
+ " " +
+ " " +
+ "org.springframework.security.ITargetObject.makeLower*=ROLE_A\n" +
+ "org.springframework.security.TargetObject.makeUpper*=ROLE_A\n" +
+ "org.springframework.security.ITargetObject.computeHashCode*=ROLE_B\n" +
+ " " +
+ " " +
+ "";
+
private AbstractXmlApplicationContext appContext;
@Before
@@ -50,24 +64,53 @@ public class MethodSecurityInterceptorWithAopConfigTests {
@Test(expected=AuthenticationCredentialsNotFoundException.class)
public void securityInterceptorIsAppliedWhenUsedWithAopConfig() {
setContext(
- "" +
+ "" +
" " +
" " +
"" +
- "" +
- "" +
- " " +
- " " +
- "org.springframework.security.TargetObject.makeLower*=ROLE_A\n" +
- "org.springframework.security.TargetObject.makeUpper*=ROLE_A\n" +
- "org.springframework.security.TargetObject.computeHashCode*=ROLE_B\n" +
- " " +
- " " +
- "" +
+ TARGET_BEAN_AND_INTERCEPTOR +
AUTH_PROVIDER_XML + ACCESS_MANAGER_XML);
ITargetObject target = (ITargetObject) appContext.getBean("target");
- target.makeLowerCase("TEST");
+
+ // Check both against interface and class
+ try {
+ target.makeLowerCase("TEST");
+ fail("AuthenticationCredentialsNotFoundException expected");
+ } catch (AuthenticationCredentialsNotFoundException expected) {
+ }
+
+ target.makeUpperCase("test");
+ }
+
+ @Test(expected=AuthenticationCredentialsNotFoundException.class)
+ public void securityInterceptorIsAppliedWhenUsedWithBeanNameAutoProxyCreator() {
+ setContext(
+ "" +
+ " " +
+ " " +
+ " securityInterceptor" +
+ " " +
+ " " +
+ " " +
+ " " +
+ " target" +
+ " " +
+ " " +
+ " " +
+ "" +
+ TARGET_BEAN_AND_INTERCEPTOR +
+ AUTH_PROVIDER_XML + ACCESS_MANAGER_XML);
+
+ ITargetObject target = (ITargetObject) appContext.getBean("target");
+
+ try {
+ target.makeLowerCase("TEST");
+ fail("AuthenticationCredentialsNotFoundException expected");
+ } catch (AuthenticationCredentialsNotFoundException expected) {
+ }
+
+ target.makeUpperCase("test");
}