@Test public void roleSearchWithEscapedCharacterSucceeds() throws Exception { String param = "cn=mouse\\, jerry,ou=people,dc=springframework,dc=org"; Set<String> values = template.searchForSingleAttributeValues( "ou=groups", "(member={0})", new String[] {param}, "cn"); assertEquals(1, values.size()); }
@Test public void testRoleSearchForMissingAttributeFailsGracefully() { String param = "uid=ben,ou=people,dc=springframework,dc=org"; Set<String> values = template.searchForSingleAttributeValues( "ou=groups", "(member={0})", new String[] {param}, "mail"); assertEquals(0, values.size()); }
@Test public void roleSearchReturnsCorrectNumberOfRoles() { String param = "uid=ben,ou=people,dc=springframework,dc=org"; Set<String> values = template.searchForSingleAttributeValues( "ou=groups", "(member={0})", new String[] {param}, "ou"); assertEquals("Expected 3 results from search", 3, values.size()); assertTrue(values.contains("developer")); assertTrue(values.contains("manager")); assertTrue(values.contains("submanager")); }