Skip to content

Commit 7b2c798

Browse files
committed
fix: add one more test
1 parent aacb179 commit 7b2c798

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

test/x509_crl.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ describe("X509CrlGenerator", () => {
259259
expect(entry?.serialNumber).toBe(cert.serialNumber);
260260
});
261261

262-
it.each(["00", "0000"])("should keep a zero serial number %s as given", async (serialNumber) => {
262+
it.each(["", "00", "0000"])("should keep the zero serial number %j as given", async (serialNumber) => {
263263
const crl = await x509.X509CrlGenerator.create({
264264
issuer: "CN=Test CA",
265265
thisUpdate: new Date(),
@@ -296,3 +296,16 @@ describe("X509CrlGenerator", () => {
296296
})).rejects.toThrow("already exists");
297297
});
298298
});
299+
300+
describe("X509CrlEntry", () => {
301+
it("should normalize the serial number", () => {
302+
// High bit set, so the serial number gets a sign-pad byte on encoding, and
303+
// the getter strips it again.
304+
const entry = new x509.X509CrlEntry("f6f3c8", new Date(), []);
305+
expect(entry.serialNumber).toBe("f6f3c8");
306+
307+
// Zero serial numbers must be normalized, not replaced by a random one.
308+
const zeroEntry = new x509.X509CrlEntry("0000", new Date(), []);
309+
expect(zeroEntry.serialNumber).toBe("00");
310+
});
311+
});

0 commit comments

Comments
 (0)