Fix bug related to detecting incorrect use of SecureContext property.
This commit is contained in:
parent
3e37b74e3f
commit
2996d67b06
|
@ -100,7 +100,7 @@ public abstract class AbstractIntegrationFilter implements InitializingBean,
|
|||
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
if ((this.secureContext == null)
|
||||
|| (!this.secureContext.isAssignableFrom(SecureContext.class))) {
|
||||
|| (!SecureContext.class.isAssignableFrom(this.secureContext))) {
|
||||
throw new IllegalArgumentException(
|
||||
"secureContext must be defined and implement SecureContext");
|
||||
}
|
||||
|
|
|
@ -152,13 +152,26 @@ public class AbstractIntegrationFilterTests extends TestCase {
|
|||
}
|
||||
}
|
||||
|
||||
public void testSecureContextSettersGetters() throws Exception {
|
||||
public void testRejectsInvalidSecureContextClass()
|
||||
throws Exception {
|
||||
MockAbstractIntegrationFilterImpl filter = new MockAbstractIntegrationFilterImpl(null);
|
||||
|
||||
// check the default
|
||||
assertEquals(SecureContextImpl.class, filter.getSecureContext());
|
||||
// Test rejects classes not implementing SecureContext
|
||||
filter.setSecureContext(String.class);
|
||||
|
||||
// check null causes exception
|
||||
try {
|
||||
filter.afterPropertiesSet();
|
||||
fail("Should have thrown IllegalArgumentException");
|
||||
} catch (IllegalArgumentException expected) {
|
||||
assertTrue(true);
|
||||
}
|
||||
|
||||
// Test accepts classes implementing SecureContext
|
||||
filter.setSecureContext(SecureContextImpl.class);
|
||||
filter.afterPropertiesSet();
|
||||
assertTrue(true);
|
||||
|
||||
// Test rejects null
|
||||
filter.setSecureContext(null);
|
||||
|
||||
try {
|
||||
|
@ -169,6 +182,17 @@ public class AbstractIntegrationFilterTests extends TestCase {
|
|||
}
|
||||
}
|
||||
|
||||
public void testSecureContextSettersGetters() throws Exception {
|
||||
MockAbstractIntegrationFilterImpl filter = new MockAbstractIntegrationFilterImpl(null);
|
||||
|
||||
// check the default
|
||||
assertEquals(SecureContextImpl.class, filter.getSecureContext());
|
||||
|
||||
// check the setter
|
||||
filter.setSecureContext(null);
|
||||
assertNull(filter.getSecureContext());
|
||||
}
|
||||
|
||||
public void testSuccessWhenConcreteClassReturnsValidAuthenticationObject()
|
||||
throws Exception {
|
||||
PrincipalAcegiUserToken principal = new PrincipalAcegiUserToken("key",
|
||||
|
|
Loading…
Reference in New Issue