mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-07-05 10:12:36 +00:00
Added tests for nameExists method
This commit is contained in:
parent
9f385eb1e0
commit
f0b11109b4
@ -23,40 +23,36 @@ import java.util.Set;
|
|||||||
* @version $Id$
|
* @version $Id$
|
||||||
*/
|
*/
|
||||||
public class LdapTemplateTests extends AbstractLdapServerTestCase {
|
public class LdapTemplateTests extends AbstractLdapServerTestCase {
|
||||||
|
private LdapTemplate template;
|
||||||
|
|
||||||
protected void onSetUp() {
|
protected void onSetUp() {
|
||||||
getInitialCtxFactory().setManagerDn(MANAGER_USER);
|
getInitialCtxFactory().setManagerDn(MANAGER_USER);
|
||||||
getInitialCtxFactory().setManagerPassword(MANAGER_PASSWORD);
|
getInitialCtxFactory().setManagerPassword(MANAGER_PASSWORD);
|
||||||
|
template = new LdapTemplate(getInitialCtxFactory());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void testCompareOfCorrectValueSucceeds() {
|
public void testCompareOfCorrectValueSucceeds() {
|
||||||
LdapTemplate template = new LdapTemplate(getInitialCtxFactory());
|
|
||||||
assertTrue(template.compare("uid=bob,ou=people", "uid", "bob"));
|
assertTrue(template.compare("uid=bob,ou=people", "uid", "bob"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testCompareOfWrongValueFails() {
|
public void testCompareOfWrongValueFails() {
|
||||||
LdapTemplate template = new LdapTemplate(getInitialCtxFactory());
|
|
||||||
assertFalse(template.compare("uid=bob,ou=people", "uid", "wrongvalue"));
|
assertFalse(template.compare("uid=bob,ou=people", "uid", "wrongvalue"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testCompareOfCorrectByteValueSucceeds() {
|
public void testCompareOfCorrectByteValueSucceeds() {
|
||||||
LdapTemplate template = new LdapTemplate(getInitialCtxFactory());
|
|
||||||
|
|
||||||
// Doesn't work with embedded server due to bugs in apacheds
|
// Doesn't work with embedded server due to bugs in apacheds
|
||||||
// assertTrue(template.compare("uid=bob,ou=people", "userPassword", LdapUtils.getUtf8Bytes("bobspassword")));
|
// assertTrue(template.compare("uid=bob,ou=people", "userPassword", LdapUtils.getUtf8Bytes("bobspassword")));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testCompareOfWrongByteValueFails() {
|
public void testCompareOfWrongByteValueFails() {
|
||||||
LdapTemplate template = new LdapTemplate(getInitialCtxFactory());
|
|
||||||
|
|
||||||
// Doesn't work with embedded server due to bugs in apacheds
|
// Doesn't work with embedded server due to bugs in apacheds
|
||||||
// assertFalse(template.compare("uid=bob,ou=people", "userPassword", LdapUtils.getUtf8Bytes("wrongvalue")));
|
// assertFalse(template.compare("uid=bob,ou=people", "userPassword", LdapUtils.getUtf8Bytes("wrongvalue")));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testSearchForSingleAttributeValues() {
|
public void testSearchForSingleAttributeValues() {
|
||||||
LdapTemplate template = new LdapTemplate(getInitialCtxFactory());
|
|
||||||
|
|
||||||
String param = "uid=ben,ou=people," + getInitialCtxFactory().getRootDn();
|
String param = "uid=ben,ou=people," + getInitialCtxFactory().getRootDn();
|
||||||
|
|
||||||
Set values = template.searchForSingleAttributeValues("ou=groups", "(member={0})", new String[] {param}, "ou");
|
Set values = template.searchForSingleAttributeValues("ou=groups", "(member={0})", new String[] {param}, "ou");
|
||||||
@ -65,4 +61,12 @@ public class LdapTemplateTests extends AbstractLdapServerTestCase {
|
|||||||
assertTrue(values.contains("developer"));
|
assertTrue(values.contains("developer"));
|
||||||
assertTrue(values.contains("manager"));
|
assertTrue(values.contains("manager"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testNameExistsForValidNameSucceeds() {
|
||||||
|
assertTrue(template.nameExists("ou=groups,dc=acegisecurity,dc=org"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testNameExistsForInValidNameFails() {
|
||||||
|
assertFalse(template.nameExists("ou=doesntexist,dc=acegisecurity,dc=org"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user