X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=org.argeo.security.core%2Fext%2Ftest%2Forg%2Fargeo%2Fosgi%2Fuseradmin%2FLdifParserTest.java;fp=org.argeo.security.core%2Fext%2Ftest%2Forg%2Fargeo%2Fosgi%2Fuseradmin%2FLdifParserTest.java;h=6a579668a6db4fcdb7d8d06c0a7a2c6840012fda;hb=526ad82ec71f69802d53a68326b4892a8dc84db9;hp=dd32dca171632641a5c15359e696dc7b028389d8;hpb=700f034e0772a4d3e33a31227b85ef6a8486e78d;p=lgpl%2Fargeo-commons.git diff --git a/org.argeo.security.core/ext/test/org/argeo/osgi/useradmin/LdifParserTest.java b/org.argeo.security.core/ext/test/org/argeo/osgi/useradmin/LdifParserTest.java index dd32dca17..6a579668a 100644 --- a/org.argeo.security.core/ext/test/org/argeo/osgi/useradmin/LdifParserTest.java +++ b/org.argeo.security.core/ext/test/org/argeo/osgi/useradmin/LdifParserTest.java @@ -1,15 +1,19 @@ package org.argeo.osgi.useradmin; +import java.util.ArrayList; +import java.util.List; import java.util.SortedMap; +import javax.naming.NamingEnumeration; +import javax.naming.directory.Attribute; import javax.naming.directory.Attributes; import javax.naming.ldap.LdapName; +import junit.framework.TestCase; + import org.apache.commons.codec.binary.Base64; import org.apache.commons.codec.digest.DigestUtils; -import junit.framework.TestCase; - public class LdifParserTest extends TestCase { public void testSimpleLdif() throws Exception { LdifParser ldifParser = new LdifParser(); @@ -27,5 +31,19 @@ public class LdifParserTest extends TestCase { assertEquals("{SHA}" + Base64.encodeBase64String(hashedPassword), new String(rawPwEntry)); + LdapName adminDn = new LdapName( + "cn=admin,ou=Roles,dc=demo,dc=example,dc=org"); + Attributes adminAttributes = res.get(adminDn); + assertNotNull(adminAttributes); + Attribute memberAttribute = adminAttributes.get("member"); + assertNotNull(memberAttribute); + NamingEnumeration members = memberAttribute.getAll(); + List users = new ArrayList(); + while (members.hasMore()) { + Object value = members.next(); + users.add(value.toString()); + } + assertEquals(1, users.size()); + assertEquals(rootDn, new LdapName(users.get(0))); } }