@Before public void setUp() { Map<String, List<String>> attributes = new HashMap<String, List<String>>(); attributes.put(SpringSecurityLdapTemplate.DN_KEY, Arrays.asList(DN)); attributes.put("mail", Arrays.asList("filip@ldap.test.org", "filip@ldap.test2.org")); authority = new LdapAuthority("testRole", DN, attributes); }
@Test public void testGetAttributes() throws Exception { assertThat(authority.getAttributes()).isNotNull(); assertThat(authority.getAttributeValues("mail")).isNotNull(); assertThat(authority.getAttributeValues("mail")).hasSize(2); assertThat(authority.getFirstAttributeValue("mail")).isEqualTo("filip@ldap.test.org"); assertThat(authority.getAttributeValues("mail").get(0)).isEqualTo("filip@ldap.test.org"); assertThat(authority.getAttributeValues("mail").get(1)).isEqualTo("filip@ldap.test2.org"); }
@Test public void testGetAuthority() throws Exception { assertThat(authority.getAuthority()).isNotNull(); assertThat(authority.getAuthority()).isEqualTo("testRole"); } }
@Test public void testGetDn() throws Exception { assertThat(authority.getDn()).isEqualTo(DN); assertThat(authority.getAttributeValues(SpringSecurityLdapTemplate.DN_KEY)).isNotNull(); assertThat(authority.getAttributeValues(SpringSecurityLdapTemplate.DN_KEY)).hasSize(1); assertThat(authority.getFirstAttributeValue(SpringSecurityLdapTemplate.DN_KEY)).isEqualTo(DN); }
/** * Returns the first attribute value for a specified attribute * * @param name * @return the first attribute value for a specified attribute, may be null */ public String getFirstAttributeValue(String name) { List<String> result = getAttributeValues(name); if (result.isEmpty()) { return null; } else { return result.get(0); } }
/** * Returns the first attribute value for a specified attribute * * @param name * @return the first attribute value for a specified attribute, may be null */ public String getFirstAttributeValue(String name) { List<String> result = getAttributeValues(name); if (result.isEmpty()) { return null; } else { return result.get(0); } }
| (!authorities.add(new LdapAuthority(role, dn, record)));
| (!authorities.add(new LdapAuthority(role, dn, record)));