test: move crypto related common utilities in common/crypto

Since `common/crypto` already exists, it makes sense to keep
crypto-related utilities there. The only exception being
common.hasCrypto which is needed up front to determine
if tests should be skipped.

Eliminate the redundant check in hasFipsCrypto and just
use crypto.getFips() directly where needed.

PR-URL: https://github.com/nodejs/node/pull/56714
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
James M Snell authored and Antoine du Hamel committed 2025-01-30 10:44:34 +01:00
1 parent c7a132229f
commit 6edf04ee5e
89 files changed
+506 -289

No files matched your search

+7 -3
View File
@@ -21,11 +21,15 @@
'use strict';
const common = require('../common');
if (!common.hasCrypto)
if (!common.hasCrypto) {
common.skip('missing crypto');
}
if (!common.opensslCli)
const { opensslCli } = require('../common/crypto');
if (!opensslCli) {
common.skip('node compiled without OpenSSL CLI.');
}
const assert = require('assert');
const fixtures = require('../common/fixtures');
@@ -67,7 +71,7 @@ server.listen(0, function() {
'-cert', fixtures.path('keys/rsa_cert_foafssl_b.crt'),
'-key', fixtures.path('keys/rsa_private_b.pem')];
const client = spawn(common.opensslCli, args);
const client = spawn(opensslCli, args);
client.stdout.on('data', function(data) {
console.log('response received');