Skip to content

Commit a760010

Browse files
committed
test: expand test-tls-get-ca-certificates-x509-option.js coverage
1 parent 29ea9ad commit a760010

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

test/parallel/test-tls-get-ca-certificates-x509-option.js

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,11 @@ const { X509Certificate } = require('crypto');
1313

1414
assert.ok(Array.isArray(certs), 'should return an array');
1515
assert.ok(certs.length > 0, 'should return non-empty array');
16-
assert.ok(certs[0] instanceof X509Certificate,
17-
'each cert should be instance of X509Certificate');
16+
17+
for (let i = 0; i < certs.length; i++) {
18+
assert.ok(certs[i] instanceof X509Certificate,
19+
`cert at index ${i} should be instance of X509Certificate`);
20+
}
1821

1922
assert.match(certs[0].serialNumber, /^[0-9A-F]+$/i,
2023
'serialNumber should be hex string');
@@ -24,14 +27,22 @@ const { X509Certificate } = require('crypto');
2427
const certs = tls.getCACertificates({ type: 'default', as: 'buffer' });
2528
assert.ok(Array.isArray(certs));
2629
assert.ok(certs.length > 0);
27-
assert.ok(Buffer.isBuffer(certs[0]));
30+
31+
for (let i = 0; i < certs.length; i++) {
32+
assert.ok(Buffer.isBuffer(certs[i]),
33+
`cert at index ${i} should be a Buffer`);
34+
}
2835
}
2936

3037
{
3138
const certs = tls.getCACertificates({ type: 'default' });
3239
assert.ok(Array.isArray(certs));
3340
assert.ok(certs.length > 0);
34-
assert.ok(Buffer.isBuffer(certs[0]));
41+
42+
for (let i = 0; i < certs.length; i++) {
43+
assert.ok(Buffer.isBuffer(certs[i]),
44+
`cert at index ${i} should be a Buffer`);
45+
}
3546
}
3647

3748
{
@@ -48,7 +59,11 @@ const { X509Certificate } = require('crypto');
4859
const certs = tls.getCACertificates({ as: 'buffer' });
4960
assert.ok(Array.isArray(certs));
5061
assert.ok(certs.length > 0);
51-
assert.ok(Buffer.isBuffer(certs[0]));
62+
63+
for (let i = 0; i < certs.length; i++) {
64+
assert.ok(Buffer.isBuffer(certs[i]),
65+
`cert at index ${i} should be a Buffer`);
66+
}
5267
}
5368

5469
{

0 commit comments

Comments
 (0)