]> git.argeo.org Git - lgpl/argeo-commons.git/blobdiff - org.argeo.security.core/ext/test/org/argeo/osgi/useradmin/LdifParserTest.java
Fix unit tests
[lgpl/argeo-commons.git] / org.argeo.security.core / ext / test / org / argeo / osgi / useradmin / LdifParserTest.java
index ae584a18c61a9ff883e33446f1a49d4871a2689d..34ac98b1cb0e8f069945fd85d2233251aea5005f 100644 (file)
@@ -14,28 +14,28 @@ import junit.framework.TestCase;
 import org.apache.commons.codec.binary.Base64;
 import org.apache.commons.codec.digest.DigestUtils;
 
-public class LdifParserTest extends TestCase {
-       public void testSimpleLdif() throws Exception {
+public class LdifParserTest extends TestCase implements BasicTestConstants {
+       public void testBasicLdif() throws Exception {
                LdifParser ldifParser = new LdifParser();
                SortedMap<LdapName, Attributes> res = ldifParser.read(getClass()
-                               .getResourceAsStream("test.ldif"));
-               LdapName rootDn = new LdapName(
-                               "uid=root+cn=Super Admin,ou=People,dc=demo,dc=example,dc=org");
+                               .getResourceAsStream("basic.ldif"));
+               LdapName rootDn = new LdapName(ROOT_USER_DN);
                Attributes rootAttributes = res.get(rootDn);
                assertNotNull(rootAttributes);
-               assertEquals("Superuser", rootAttributes.get("description").get());
-               byte[] rawPwEntry = (byte[]) rootAttributes.get("userpassword").get();
+               assertEquals("Superuser",
+                               rootAttributes.get(LdifName.description.name()).get());
+               byte[] rawPwEntry = (byte[]) rootAttributes.get(
+                               LdifName.userPassword.name()).get();
                assertEquals("{SHA}ieSV55Qc+eQOaYDRSha/AjzNTJE=",
                                new String(rawPwEntry));
                byte[] hashedPassword = DigestUtils.sha1("demo".getBytes());
                assertEquals("{SHA}" + Base64.encodeBase64String(hashedPassword),
                                new String(rawPwEntry));
 
-               LdapName adminDn = new LdapName(
-                               "cn=admin,ou=Roles,dc=demo,dc=example,dc=org");
+               LdapName adminDn = new LdapName(ADMIN_GROUP_DN);
                Attributes adminAttributes = res.get(adminDn);
                assertNotNull(adminAttributes);
-               Attribute memberAttribute = adminAttributes.get("member");
+               Attribute memberAttribute = adminAttributes.get(LdifName.member.name());
                assertNotNull(memberAttribute);
                NamingEnumeration<?> members = memberAttribute.getAll();
                List<String> users = new ArrayList<String>();