Skip to content

Commit

Permalink
Improve OIDRegistryTestCase cross-platform compat
Browse files Browse the repository at this point in the history
Updated OIDRegistryTestCase to improve its cross-platform behavior.
It previously used a comparison that did not tolerate differences
between end-of-line characters, and it also included non-ASCII
characters (curly single quotes for apostrophes) that may have been
rendered differently on systems with different default character set
encodings.
  • Loading branch information
dirmgr committed Apr 25, 2022
1 parent 3f6c922 commit a529157
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 13 deletions.
4 changes: 2 additions & 2 deletions docs/ldap-oid-reference.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<h2>LDAP OID Reference</h2>

<p>
Object identifiers are used throughout LDAP, but they’re particularly common in schema elements, controls, and extended operations. This document provides a table of some of the most common OIDs used in LDAP along with a brief explanation of their purpose and (when applicable) a reference to the appropriate specification.
Object identifiers are used throughout LDAP, but they are particularly common in schema elements, controls, and extended operations. This document provides a table of some of the most common OIDs used in LDAP along with a brief explanation of their purpose and (when applicable) a reference to the appropriate specification.
</p>

<table border="1" cellpadding="5" cellspacing="0">
Expand Down Expand Up @@ -1183,7 +1183,7 @@ <h2>LDAP OID Reference</h2>
</tr>
<tr>
<td>1.3.6.1.1.22</td>
<td>LDAP Dont Use Copy Control</td>
<td>LDAP Don't Use Copy Control</td>
<td><a href="https://docs.ldap.com/specs/rfc6171.txt" target="_blank">RFC 6171</a></td>
</tr>
<tr>
Expand Down
2 changes: 1 addition & 1 deletion resource/oid-registry.json
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@
{ "oid":"1.3.6.1.1.21.2", "name":"Transaction Specification", "type":"Request Control", "origin":"RFC 5805", "url":"https://docs.ldap.com/specs/rfc5805.txt" }
{ "oid":"1.3.6.1.1.21.3", "name":"End Transaction", "type":"Extended Request", "origin":"RFC 5805", "url":"https://docs.ldap.com/specs/rfc5805.txt" }
{ "oid":"1.3.6.1.1.21.4", "name":"Aborted Transaction", "type":"Unsolicited Notification", "origin":"RFC 5805", "url":"https://docs.ldap.com/specs/rfc5805.txt" }
{ "oid":"1.3.6.1.1.22", "name":"LDAP Dont Use Copy", "type":"Control", "origin":"RFC 6171", "url":"https://docs.ldap.com/specs/rfc6171.txt" }
{ "oid":"1.3.6.1.1.22", "name":"LDAP Don't Use Copy", "type":"Control", "origin":"RFC 6171", "url":"https://docs.ldap.com/specs/rfc6171.txt" }
{ "oid":"1.3.6.1.4.1.42.2.27.4.1.6", "name":"javaClassName", "type":"Attribute Type", "origin":"RFC 2713", "url":"https://docs.ldap.com/specs/rfc2713.txt" }
{ "oid":"1.3.6.1.4.1.42.2.27.4.1.7", "name":"javaCodebase", "type":"Attribute Type", "origin":"RFC 2713", "url":"https://docs.ldap.com/specs/rfc2713.txt" }
{ "oid":"1.3.6.1.4.1.42.2.27.4.1.8", "name":"javaSerializedData", "type":"Attribute Type", "origin":"RFC 2713", "url":"https://docs.ldap.com/specs/rfc2713.txt" }
Expand Down
16 changes: 6 additions & 10 deletions tests/unit/src/com/unboundid/util/OIDRegistryTestCase.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
import java.io.PrintWriter;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.security.MessageDigest;
import java.util.ArrayList;
import java.util.List;

Expand Down Expand Up @@ -314,7 +313,7 @@ public void testLDAPSDKDocumentationIsUpToDate()
w.println();
w.println(baseIndent + "<p>");
w.println(baseIndent + " Object identifiers are used throughout LDAP, " +
"but they\u2019re particularly common in schema elements, " +
"but they are particularly common in schema elements, " +
"controls, and extended operations. This document provides a " +
"table of some of the most common OIDs used in LDAP along with a " +
"brief explanation of their purpose and (when applicable) a " +
Expand Down Expand Up @@ -380,18 +379,15 @@ public void testLDAPSDKDocumentationIsUpToDate()
// Compute SHA-256 digests of the newly generated OID reference with the
// existing version in the documentation. If they are different, then fail
// the test.
final MessageDigest sha256 = CryptoHelper.getMessageDigest("SHA-256");
final byte[] generatedFileBytes =
StaticUtils.readFileBytes(generatedHTMLFile);
final byte[] generatedFileDigest = sha256.digest(generatedFileBytes);
final List<String> generatedFileLines =
StaticUtils.readFileLines(generatedHTMLFile);

final File docsDir = new File(baseDir, "docs");
final File existingHTMLFile = new File(docsDir, "ldap-oid-reference.html");
final byte[] existingFileBytes =
StaticUtils.readFileBytes(existingHTMLFile);
final byte[] existingFileDigest = sha256.digest(existingFileBytes);
final List<String> existingFileLines =
StaticUtils.readFileLines(existingHTMLFile);

assertEquals(generatedFileBytes, existingFileBytes,
assertEquals(existingFileLines, generatedFileLines,
"It appears that the OID registry has been updated, but the version " +
"in the LDAP SDK documentation has not been updated. Replace '" +
existingHTMLFile.getAbsolutePath() + "' with '" +
Expand Down

0 comments on commit a529157

Please sign in to comment.