X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;f=org.argeo.enterprise%2Fext%2Ftest%2Forg%2Fargeo%2Fosgi%2Fuseradmin%2FLdifParserTest.java;h=012a50ed1e6c7e98dc6cae6b7f6eb4babda3a2e6;hb=438237c2b8c995d4f9562d53bfe4ea63c4442054;hp=e7c94609f1c724ee14ea20caf2e82c29989594a6;hpb=77a5498dd5d10d2442127022efd6501a7dbddbae;p=lgpl%2Fargeo-commons.git diff --git a/org.argeo.enterprise/ext/test/org/argeo/osgi/useradmin/LdifParserTest.java b/org.argeo.enterprise/ext/test/org/argeo/osgi/useradmin/LdifParserTest.java index e7c94609f..012a50ed1 100644 --- a/org.argeo.enterprise/ext/test/org/argeo/osgi/useradmin/LdifParserTest.java +++ b/org.argeo.enterprise/ext/test/org/argeo/osgi/useradmin/LdifParserTest.java @@ -10,40 +10,35 @@ import javax.naming.directory.Attribute; import javax.naming.directory.Attributes; import javax.naming.ldap.LdapName; -import junit.framework.TestCase; +import org.argeo.naming.LdapAttrs; +import org.argeo.naming.LdifParser; -import org.argeo.util.naming.LdifParser; - -public class LdifParserTest extends TestCase implements BasicTestConstants { +/** {@link LdifParser} tests. */ +public class LdifParserTest implements BasicTestConstants { public void testBasicLdif() throws Exception { LdifParser ldifParser = new LdifParser(); - SortedMap res = ldifParser.read(getClass() - .getResourceAsStream("basic.ldif")); + SortedMap res = ldifParser.read(getClass().getResourceAsStream("basic.ldif")); LdapName rootDn = new LdapName(ROOT_USER_DN); Attributes rootAttributes = res.get(rootDn); - assertNotNull(rootAttributes); - 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)); + assert rootAttributes != null; + assert "Superuser".equals(rootAttributes.get(LdapAttrs.description.name()).get()); + byte[] rawPwEntry = (byte[]) rootAttributes.get(LdapAttrs.userPassword.name()).get(); + assert "{SHA}ieSV55Qc+eQOaYDRSha/AjzNTJE=".contentEquals(new String(rawPwEntry)); byte[] hashedPassword = DigestUtils.sha1("demo".getBytes()); - assertEquals("{SHA}" + Base64.getEncoder().encodeToString(hashedPassword), - new String(rawPwEntry)); + assert ("{SHA}" + Base64.getEncoder().encodeToString(hashedPassword)).equals(new String(rawPwEntry)); LdapName adminDn = new LdapName(ADMIN_GROUP_DN); Attributes adminAttributes = res.get(adminDn); - assertNotNull(adminAttributes); - Attribute memberAttribute = adminAttributes.get(LdifName.member.name()); - assertNotNull(memberAttribute); + assert adminAttributes != null; + Attribute memberAttribute = adminAttributes.get(LdapAttrs.member.name()); + assert memberAttribute != null; 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))); + assert 1 == users.size(); + assert rootDn.equals(new LdapName(users.get(0))); } }