use of org.springframework.security.userdetails.ldap.LdapUserDetailsImpl in project gocd by gocd.
the class UserHelperTest method shouldGetNameFromLdapUserDetailsIfCannotGetFullName.
@Test
public void shouldGetNameFromLdapUserDetailsIfCannotGetFullName() {
TestingAuthenticationToken authentication = new TestingAuthenticationToken(new LdapUserDetailsImpl() {
public String getUsername() {
return "test1";
}
public String getDn() {
return "n=Test User, ou=Beijing, ou=Employees, ou=Enterprise, ou=Principal";
}
}, null, null);
assertThat(UserHelper.getUserName(authentication).getDisplayName(), is("test1"));
}
use of org.springframework.security.userdetails.ldap.LdapUserDetailsImpl in project gocd by gocd.
the class GoVelocityViewTest method shouldRetriveLdapCompleteNameFromSessionWhenAuthenticated.
@Test
public void shouldRetriveLdapCompleteNameFromSessionWhenAuthenticated() throws Exception {
securityContext.setAuthentication(new TestingAuthenticationToken(new LdapUserDetailsImpl() {
public String getUsername() {
return "test1";
}
public String getDn() {
return "cn=Test User, ou=Beijing, ou=Employees, ou=Enterprise, ou=Principal";
}
}, null, null));
request.getSession().setAttribute(SPRING_SECURITY_CONTEXT_KEY, securityContext);
view.exposeHelpers(velocityContext, request);
assertThat(velocityContext.get(GoVelocityView.PRINCIPAL), is("Test User"));
}
use of org.springframework.security.userdetails.ldap.LdapUserDetailsImpl in project gocd by gocd.
the class UserHelperTest method shouldGetFullNameFromLdapUserDetails.
@Test
public void shouldGetFullNameFromLdapUserDetails() {
TestingAuthenticationToken authentication = new TestingAuthenticationToken(new LdapUserDetailsImpl() {
public String getUsername() {
return "test1";
}
public String getDn() {
return "cn=Test User, ou=Beijing, ou=Employees, ou=Enterprise, ou=Principal";
}
}, null, null);
assertThat(UserHelper.getUserName(authentication).getDisplayName(), is("Test User"));
}
Aggregations