Search in sources :

Example 26 with UserDetailsService

use of org.springframework.security.core.userdetails.UserDetailsService in project Activiti by Activiti.

the class SecurityAutoConfigurationTest method userDetailsService.

@Test
public void userDetailsService() throws Throwable {
    this.applicationContext = new AnnotationConfigApplicationContext();
    this.applicationContext.register(SecurityConfiguration.class);
    this.applicationContext.refresh();
    UserDetailsService userDetailsService = this.applicationContext.getBean(UserDetailsService.class);
    Assert.assertNotNull("the userDetailsService should not be null", userDetailsService);
    Assert.assertEquals("there should only be 1 authority", 1, userDetailsService.loadUserByUsername("jlong").getAuthorities().size());
    Assert.assertEquals("there should be 2 authorities", 2, userDetailsService.loadUserByUsername("jbarrez").getAuthorities().size());
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) UserDetailsService(org.springframework.security.core.userdetails.UserDetailsService) Test(org.junit.Test)

Aggregations

UserDetailsService (org.springframework.security.core.userdetails.UserDetailsService)26 Test (org.junit.Test)19 UserDetails (org.springframework.security.core.userdetails.UserDetails)14 LdapUserDetailsService (org.springframework.security.ldap.userdetails.LdapUserDetailsService)7 User (org.springframework.security.core.userdetails.User)3 InetOrgPerson (org.springframework.security.ldap.userdetails.InetOrgPerson)3 Before (org.junit.Before)2 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)2 UsernamePasswordAuthenticationToken (org.springframework.security.authentication.UsernamePasswordAuthenticationToken)2 Authentication (org.springframework.security.core.Authentication)2 HashMap (java.util.HashMap)1 List (java.util.List)1 Person (org.devgateway.toolkit.persistence.dao.Person)1 ApplicationContextException (org.springframework.context.ApplicationContextException)1 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)1 Bean (org.springframework.context.annotation.Bean)1 DirContextAdapter (org.springframework.ldap.core.DirContextAdapter)1 AuthenticationManager (org.springframework.security.authentication.AuthenticationManager)1 ProviderManager (org.springframework.security.authentication.ProviderManager)1 DaoAuthenticationProvider (org.springframework.security.authentication.dao.DaoAuthenticationProvider)1