Fix unit tests
authorMathieu Baudier <mbaudier@argeo.org>
Mon, 30 Nov 2015 12:29:17 +0000 (12:29 +0000)
committerMathieu Baudier <mbaudier@argeo.org>
Mon, 30 Nov 2015 12:29:17 +0000 (12:29 +0000)
git-svn-id: https://svn.argeo.org/commons/trunk@8656 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc

org.argeo.security.core/ext/test/org/argeo/osgi/useradmin/LdifParserTest.java
org.argeo.security.core/ext/test/org/argeo/osgi/useradmin/LdifUserAdminTest.java
org.argeo.security.core/ext/test/org/argeo/osgi/useradmin/basic.ldif
org.argeo.security.core/src/org/argeo/osgi/useradmin/LdifName.java

index 75a5c34b3442c4d39129b4c343349dcc2ead8ccc..34ac98b1cb0e8f069945fd85d2233251aea5005f 100644 (file)
@@ -22,19 +22,20 @@ public class LdifParserTest extends TestCase implements BasicTestConstants {
                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(
-                               ADMIN_GROUP_DN);
+               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>();
index 05167741781ef21b490ae5e3412ea8f40912a972..27e3c1dfc9a6a23f98615751d9ca82d2745e2a17 100644 (file)
@@ -66,8 +66,10 @@ public class LdifUserAdminTest extends TestCase implements BasicTestConstants {
                byte[] hashedPassword = ("{SHA}" + Base64
                                .encodeBase64String(DigestUtils.sha1("demo".getBytes())))
                                .getBytes();
-               assertTrue(rootUser.hasCredential("userpassword", hashedPassword));
-               assertTrue(demoUser.hasCredential("userpassword", hashedPassword));
+               assertTrue(rootUser.hasCredential(LdifName.userPassword.name(),
+                               hashedPassword));
+               assertTrue(demoUser.hasCredential(LdifName.userPassword.name(),
+                               hashedPassword));
 
                // search
                Role[] search = userAdmin.getRoles(null);
index 963407177fc2ebed574b2dfa63593610f29d7c89..d4b9848090cc52781bc569f0f6e1abf85eba8208 100644 (file)
@@ -21,11 +21,11 @@ objectClass: person
 objectClass: top
 cn: demo User
 description: Demo user
-givenname: Demo
+givenName: Demo
 mail: demo@localhost
 sn: User
 uid: demo
-userpassword:: e1NIQX1pZVNWNTVRYytlUU9hWURSU2hhL0Fqek5USkU9
+userPassword:: e1NIQX1pZVNWNTVRYytlUU9hWURSU2hhL0Fqek5USkU9
 
 dn: uid=root+cn=Super Admin,ou=People,dc=demo,dc=example,dc=org
 objectClass: inetOrgPerson
@@ -34,11 +34,11 @@ objectClass: organizationalPerson
 objectClass: top
 cn: Super Admin
 description: Superuser
-givenname: Root
+givenName: Root
 mail: root@localhost
 sn: Root
 uid: root
-userpassword:: e1NIQX1pZVNWNTVRYytlUU9hWURSU2hhL0Fqek5USkU9
+userPassword:: e1NIQX1pZVNWNTVRYytlUU9hWURSU2hhL0Fqek5USkU9
 
 dn: cn=admin,ou=Roles,dc=demo,dc=example,dc=org
 objectClass: groupOfNames
index 25125e0fbbfa8dfc7f0db6a857e23f4231cd3182..8693f60dd757f972a07d86b15152614cc1346f47 100644 (file)
@@ -9,7 +9,7 @@ import javax.naming.ldap.LdapName;
  */
 public enum LdifName {
        // Attributes
-       dn, cn, sn, uid, mail, displayName, objectClass, userPassword, givenName, description,
+       dn, cn, sn, uid, mail, displayName, objectClass, userPassword, givenName, description, member,
        // POSIX attributes
        uidNumber, gidNumber, homeDirectory, loginShell, gecos,
        // Object classes