Skip to content

Commit 5fc4706

Browse files
codebyteretargos
authored andcommitted
test: leverage process.features.openssl_is_boringssl in test
PR-URL: #58421 Reviewed-By: Juan José Arboleda <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 4629b18 commit 5fc4706

6 files changed

+50
-23
lines changed

test/parallel/test-crypto-x509.js

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,6 @@ const der = Buffer.from(
9797
assert.strictEqual(x509.infoAccess, infoAccessCheck);
9898
assert.strictEqual(x509.validFrom, 'Sep 3 21:40:37 2022 GMT');
9999
assert.strictEqual(x509.validTo, 'Jun 17 21:40:37 2296 GMT');
100-
assert.deepStrictEqual(x509.validFromDate, new Date('2022-09-03T21:40:37Z'));
101-
assert.deepStrictEqual(x509.validToDate, new Date('2296-06-17T21:40:37Z'));
102100
assert.strictEqual(
103101
x509.fingerprint,
104102
'8B:89:16:C4:99:87:D2:13:1A:64:94:36:38:A5:32:01:F0:95:3B:53');
@@ -118,6 +116,11 @@ const der = Buffer.from(
118116

119117
assert.deepStrictEqual(x509.raw, der);
120118

119+
if (!process.features.openssl_is_boringssl) {
120+
assert.deepStrictEqual(x509.validFromDate, new Date('2022-09-03T21:40:37Z'));
121+
assert.deepStrictEqual(x509.validToDate, new Date('2296-06-17T21:40:37Z'));
122+
}
123+
121124
assert(x509.publicKey);
122125
assert.strictEqual(x509.publicKey.type, 'public');
123126

@@ -356,13 +359,15 @@ tAt3hIKFD1bJt6c6WtMH2Su3syosWxmdmGk5ihslB00lvLpfj/wed8i3bkcB1doq
356359
UcXd/5qu2GhokrKU2cPttU+XAN2Om6a0
357360
-----END CERTIFICATE-----`;
358361

359-
const cert = new X509Certificate(certPem);
360-
assert.throws(() => cert.publicKey, {
361-
message: hasOpenSSL3 ? /decode error/ : /wrong tag/,
362-
name: 'Error'
363-
});
362+
if (!process.features.openssl_is_boringssl) {
363+
const cert = new X509Certificate(certPem);
364+
assert.throws(() => cert.publicKey, {
365+
message: hasOpenSSL3 ? /decode error/ : /wrong tag/,
366+
name: 'Error'
367+
});
364368

365-
assert.strictEqual(cert.checkIssued(cert), false);
369+
assert.strictEqual(cert.checkIssued(cert), false);
370+
}
366371
}
367372

368373
{
@@ -401,8 +406,10 @@ UidvpWWipVLZgK+oDks+bKTobcoXGW9oXobiIYqslXPy
401406
-----END CERTIFICATE-----`.trim();
402407
const c1 = new X509Certificate(certPemUTCTime);
403408

404-
assert.deepStrictEqual(c1.validFromDate, new Date('1949-12-25T23:59:58Z'));
405-
assert.deepStrictEqual(c1.validToDate, new Date('1950-01-01T23:59:58Z'));
409+
if (!process.features.openssl_is_boringssl) {
410+
assert.deepStrictEqual(c1.validFromDate, new Date('1949-12-25T23:59:58Z'));
411+
assert.deepStrictEqual(c1.validToDate, new Date('1950-01-01T23:59:58Z'));
412+
}
406413

407414
// The GeneralizedTime format is used for dates in 2050 or later.
408415
const certPemGeneralizedTime = `-----BEGIN CERTIFICATE-----
@@ -436,6 +443,8 @@ CWwQO8JZjJqFtqtuzy2n+gLCvqePgG/gmSqHOPm2ZbLW
436443
-----END CERTIFICATE-----`.trim();
437444
const c2 = new X509Certificate(certPemGeneralizedTime);
438445

439-
assert.deepStrictEqual(c2.validFromDate, new Date('2049-12-26T00:00:01Z'));
440-
assert.deepStrictEqual(c2.validToDate, new Date('2050-01-02T00:00:01Z'));
446+
if (!process.features.openssl_is_boringssl) {
447+
assert.deepStrictEqual(c2.validFromDate, new Date('2049-12-26T00:00:01Z'));
448+
assert.deepStrictEqual(c2.validToDate, new Date('2050-01-02T00:00:01Z'));
449+
}
441450
}

test/parallel/test-https-agent-additional-options.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,31 @@ const options = {
1313
cert: fixtures.readKey('agent1-cert.pem'),
1414
ca: fixtures.readKey('ca1-cert.pem'),
1515
minVersion: 'TLSv1.1',
16-
ciphers: 'ALL@SECLEVEL=0'
1716
};
1817

18+
if (!process.features.openssl_is_boringssl) {
19+
options.ciphers = 'ALL@SECLEVEL=0';
20+
}
21+
1922
const server = https.Server(options, (req, res) => {
2023
res.writeHead(200);
2124
res.end('hello world\n');
2225
});
2326

2427
function getBaseOptions(port) {
25-
return {
28+
const baseOptions = {
2629
path: '/',
2730
port: port,
2831
ca: options.ca,
2932
rejectUnauthorized: true,
3033
servername: 'agent1',
31-
ciphers: 'ALL@SECLEVEL=0'
3234
};
35+
36+
if (!process.features.openssl_is_boringssl) {
37+
baseOptions.ciphers = 'ALL@SECLEVEL=0';
38+
}
39+
40+
return baseOptions;
3341
}
3442

3543
const updatedValues = new Map([

test/parallel/test-https-agent-session-eviction.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,12 @@ const options = {
1717
key: readKey('agent1-key.pem'),
1818
cert: readKey('agent1-cert.pem'),
1919
secureOptions: SSL_OP_NO_TICKET,
20-
ciphers: 'RSA@SECLEVEL=0'
2120
};
2221

22+
if (!process.features.openssl_is_boringssl) {
23+
options.ciphers = 'RSA@SECLEVEL=0';
24+
}
25+
2326
// Create TLS1.2 server
2427
https.createServer(options, function(req, res) {
2528
res.writeHead(200, { 'Connection': 'close' });

test/parallel/test-webcrypto-derivebits.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ const { subtle } = globalThis.crypto;
123123
assert.deepStrictEqual(secret1, secret2);
124124
}
125125

126-
test('X25519').then(common.mustCall());
127-
test('X448').then(common.mustCall());
126+
if (!process.features.openssl_is_boringssl) {
127+
test('X25519').then(common.mustCall());
128+
test('X448').then(common.mustCall());
129+
}
128130
}

test/parallel/test-webcrypto-derivekey.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,8 @@ const { KeyObject } = require('crypto');
206206
assert.deepStrictEqual(raw1, raw2);
207207
}
208208

209-
test('X25519').then(common.mustCall());
210-
test('X448').then(common.mustCall());
209+
if (!process.features.openssl_is_boringssl) {
210+
test('X25519').then(common.mustCall());
211+
test('X448').then(common.mustCall());
212+
}
211213
}

test/parallel/test-webcrypto-sign-verify.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,9 @@ const { subtle } = globalThis.crypto;
121121
name: 'Ed25519',
122122
}, publicKey, signature, ec.encode(data)));
123123
}
124-
125-
test('hello world').then(common.mustCall());
124+
if (!process.features.openssl_is_boringssl) {
125+
test('hello world').then(common.mustCall());
126+
}
126127
}
127128

128129
// Test Sign/Verify Ed448
@@ -142,5 +143,7 @@ const { subtle } = globalThis.crypto;
142143
}, publicKey, signature, ec.encode(data)));
143144
}
144145

145-
test('hello world').then(common.mustCall());
146+
if (!process.features.openssl_is_boringssl) {
147+
test('hello world').then(common.mustCall());
148+
}
146149
}

0 commit comments

Comments
 (0)