mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-07-05 18:22:26 +00:00
SEC-850: custom-authentication-provider Registering Separate Bean Definitions in App Context and Providers List
http://jira.springframework.org/browse/SEC-850. Added extra test.
This commit is contained in:
parent
d1005e4cfb
commit
871e529840
@ -11,6 +11,22 @@ public class CustomAuthenticationProviderBeanDefinitionDecoratorTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void decoratedProviderParsesSuccessfully() {
|
public void decoratedProviderParsesSuccessfully() {
|
||||||
|
InMemoryXmlApplicationContext ctx = new InMemoryXmlApplicationContext(
|
||||||
|
"<b:bean class='org.springframework.security.providers.dao.DaoAuthenticationProvider'>" +
|
||||||
|
" <custom-authentication-provider />" +
|
||||||
|
" <b:property name='userDetailsService' ref='us'/>" +
|
||||||
|
"</b:bean>" +
|
||||||
|
"<user-service id='us'>" +
|
||||||
|
" <user name='bob' password='bobspassword' authorities='ROLE_A,ROLE_B' />" +
|
||||||
|
"</user-service>"
|
||||||
|
);
|
||||||
|
ProviderManager authMgr = (ProviderManager) ctx.getBean(BeanIds.AUTHENTICATION_MANAGER);
|
||||||
|
assertEquals(1, authMgr.getProviders().size());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void decoratedBeanAndRegisteredProviderAreTheSameObject() {
|
||||||
InMemoryXmlApplicationContext ctx = new InMemoryXmlApplicationContext(
|
InMemoryXmlApplicationContext ctx = new InMemoryXmlApplicationContext(
|
||||||
"<b:bean id='myProvider' class='org.springframework.security.providers.dao.DaoAuthenticationProvider'>" +
|
"<b:bean id='myProvider' class='org.springframework.security.providers.dao.DaoAuthenticationProvider'>" +
|
||||||
" <custom-authentication-provider />" +
|
" <custom-authentication-provider />" +
|
||||||
@ -18,15 +34,11 @@ public class CustomAuthenticationProviderBeanDefinitionDecoratorTests {
|
|||||||
"</b:bean>" +
|
"</b:bean>" +
|
||||||
"<user-service id='us'>" +
|
"<user-service id='us'>" +
|
||||||
" <user name='bob' password='bobspassword' authorities='ROLE_A,ROLE_B' />" +
|
" <user name='bob' password='bobspassword' authorities='ROLE_A,ROLE_B' />" +
|
||||||
" <user name='bill' password='billspassword' authorities='ROLE_A,ROLE_B,AUTH_OTHER' />" +
|
|
||||||
"</user-service>"
|
"</user-service>"
|
||||||
|
|
||||||
);
|
);
|
||||||
|
|
||||||
Object myProvider = ctx.getBean("myProvider");
|
|
||||||
|
|
||||||
ProviderManager authMgr = (ProviderManager) ctx.getBean(BeanIds.AUTHENTICATION_MANAGER);
|
ProviderManager authMgr = (ProviderManager) ctx.getBean(BeanIds.AUTHENTICATION_MANAGER);
|
||||||
|
assertEquals(1, authMgr.getProviders().size());
|
||||||
assertSame(myProvider, authMgr.getProviders().get(0));
|
assertSame(ctx.getBean("myProvider"), authMgr.getProviders().get(0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user