Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit f6c14bd

Browse filesBrowse files
sam-githubaddaleax
authored andcommitted
test: rework ephemeralkeyinfo to run in parallel
Remove: - use of tls global so tests can run in parallel - test counting in favour of common.mustCall() - limit of only one cipher suite per ephemeral key type tested The last change will allow adding TLS 1.3 cipher suites and testing 'ECDH' key info with them. PR-URL: #25409 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Tobias Nießen <tniessen@tnie.de>
1 parent 840ec23 commit f6c14bd
Copy full SHA for f6c14bd

File tree

Expand file treeCollapse file tree

1 file changed

+15
-56
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+15
-56
lines changed
Open diff view settings
Collapse file

‎test/parallel/test-tls-client-getephemeralkeyinfo.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-tls-client-getephemeralkeyinfo.js
+15-56Lines changed: 15 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -10,90 +10,49 @@ const tls = require('tls');
1010
const key = fixtures.readKey('agent2-key.pem');
1111
const cert = fixtures.readKey('agent2-cert.pem');
1212

13-
let ntests = 0;
14-
let nsuccess = 0;
15-
1613
function loadDHParam(n) {
1714
return fixtures.readKey(`dh${n}.pem`);
1815
}
1916

20-
const cipherlist = {
21-
'NOT_PFS': 'AES128-SHA256',
22-
'DH': 'DHE-RSA-AES128-GCM-SHA256',
23-
'ECDH': 'ECDHE-RSA-AES128-GCM-SHA256'
24-
};
25-
26-
function test(size, type, name, next) {
27-
const cipher = type ? cipherlist[type] : cipherlist.NOT_PFS;
28-
29-
if (name) tls.DEFAULT_ECDH_CURVE = name;
17+
function test(size, type, name, cipher) {
18+
assert(cipher);
3019

3120
const options = {
3221
key: key,
3322
cert: cert,
3423
ciphers: cipher
3524
};
3625

26+
if (name) options.ecdhCurve = name;
27+
3728
if (type === 'DH') options.dhparam = loadDHParam(size);
3829

39-
const server = tls.createServer(options, function(conn) {
30+
const server = tls.createServer(options, common.mustCall((conn) => {
4031
assert.strictEqual(conn.getEphemeralKeyInfo(), null);
4132
conn.end();
42-
});
33+
}));
4334

44-
server.on('close', common.mustCall(function(err) {
35+
server.on('close', common.mustCall((err) => {
4536
assert.ifError(err);
46-
if (next) next();
4737
}));
4838

49-
server.listen(0, '127.0.0.1', common.mustCall(function() {
39+
server.listen(0, '127.0.0.1', common.mustCall(() => {
5040
const client = tls.connect({
51-
port: this.address().port,
41+
port: server.address().port,
5242
rejectUnauthorized: false
5343
}, function() {
5444
const ekeyinfo = client.getEphemeralKeyInfo();
5545
assert.strictEqual(ekeyinfo.type, type);
5646
assert.strictEqual(ekeyinfo.size, size);
5747
assert.strictEqual(ekeyinfo.name, name);
58-
nsuccess++;
5948
server.close();
6049
});
6150
}));
6251
}
6352

64-
function testNOT_PFS() {
65-
test(undefined, undefined, undefined, testDHE1024);
66-
ntests++;
67-
}
68-
69-
function testDHE1024() {
70-
test(1024, 'DH', undefined, testDHE2048);
71-
ntests++;
72-
}
73-
74-
function testDHE2048() {
75-
test(2048, 'DH', undefined, testECDHE256);
76-
ntests++;
77-
}
78-
79-
function testECDHE256() {
80-
test(256, 'ECDH', 'prime256v1', testECDHE512);
81-
ntests++;
82-
}
83-
84-
function testECDHE512() {
85-
test(521, 'ECDH', 'secp521r1', testX25519);
86-
ntests++;
87-
}
88-
89-
function testX25519() {
90-
test(253, 'ECDH', 'X25519', null);
91-
ntests++;
92-
}
93-
94-
testNOT_PFS();
95-
96-
process.on('exit', function() {
97-
assert.strictEqual(ntests, nsuccess);
98-
assert.strictEqual(ntests, 6);
99-
});
53+
test(undefined, undefined, undefined, 'AES128-SHA256');
54+
test(1024, 'DH', undefined, 'DHE-RSA-AES128-GCM-SHA256');
55+
test(2048, 'DH', undefined, 'DHE-RSA-AES128-GCM-SHA256');
56+
test(256, 'ECDH', 'prime256v1', 'ECDHE-RSA-AES128-GCM-SHA256');
57+
test(521, 'ECDH', 'secp521r1', 'ECDHE-RSA-AES128-GCM-SHA256');
58+
test(253, 'ECDH', 'X25519', 'ECDHE-RSA-AES128-GCM-SHA256');

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.