Skip to content

Commit 6bafd35

Browse files
lpincatargos
authored andcommitted
test: deflake test-tls-passphrase
Move `socket.end()` to client. Fixes: #28111 Refs: #27569 PR-URL: #29134 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Sam Roberts <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 82eeadb commit 6bafd35

File tree

1 file changed

+26
-24
lines changed

1 file changed

+26
-24
lines changed

test/parallel/test-tls-passphrase.js

+26-24
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,17 @@ assert(Buffer.isBuffer(cert));
3737
assert.strictEqual(typeof passKey.toString(), 'string');
3838
assert.strictEqual(typeof cert.toString(), 'string');
3939

40+
function onSecureConnect() {
41+
return common.mustCall(function() { this.end(); });
42+
}
43+
4044
const server = tls.Server({
4145
key: passKey,
4246
passphrase: 'password',
4347
cert: cert,
4448
ca: [cert],
4549
requestCert: true,
4650
rejectUnauthorized: true
47-
}, function(s) {
48-
s.end();
4951
});
5052

5153
server.listen(0, common.mustCall(function() {
@@ -56,22 +58,22 @@ server.listen(0, common.mustCall(function() {
5658
passphrase: 'password',
5759
cert: cert,
5860
rejectUnauthorized: false
59-
}, common.mustCall());
61+
}, onSecureConnect());
6062

6163
tls.connect({
6264
port: this.address().port,
6365
key: rawKey,
6466
cert: cert,
6567
rejectUnauthorized: false
66-
}, common.mustCall());
68+
}, onSecureConnect());
6769

6870
tls.connect({
6971
port: this.address().port,
7072
key: rawKey,
7173
passphrase: 'ignored',
7274
cert: cert,
7375
rejectUnauthorized: false
74-
}, common.mustCall());
76+
}, onSecureConnect());
7577

7678
// Buffer[]
7779
tls.connect({
@@ -80,22 +82,22 @@ server.listen(0, common.mustCall(function() {
8082
passphrase: 'password',
8183
cert: [cert],
8284
rejectUnauthorized: false
83-
}, common.mustCall());
85+
}, onSecureConnect());
8486

8587
tls.connect({
8688
port: this.address().port,
8789
key: [rawKey],
8890
cert: [cert],
8991
rejectUnauthorized: false
90-
}, common.mustCall());
92+
}, onSecureConnect());
9193

9294
tls.connect({
9395
port: this.address().port,
9496
key: [rawKey],
9597
passphrase: 'ignored',
9698
cert: [cert],
9799
rejectUnauthorized: false
98-
}, common.mustCall());
100+
}, onSecureConnect());
99101

100102
// string
101103
tls.connect({
@@ -104,22 +106,22 @@ server.listen(0, common.mustCall(function() {
104106
passphrase: 'password',
105107
cert: cert.toString(),
106108
rejectUnauthorized: false
107-
}, common.mustCall());
109+
}, onSecureConnect());
108110

109111
tls.connect({
110112
port: this.address().port,
111113
key: rawKey.toString(),
112114
cert: cert.toString(),
113115
rejectUnauthorized: false
114-
}, common.mustCall());
116+
}, onSecureConnect());
115117

116118
tls.connect({
117119
port: this.address().port,
118120
key: rawKey.toString(),
119121
passphrase: 'ignored',
120122
cert: cert.toString(),
121123
rejectUnauthorized: false
122-
}, common.mustCall());
124+
}, onSecureConnect());
123125

124126
// String[]
125127
tls.connect({
@@ -128,97 +130,97 @@ server.listen(0, common.mustCall(function() {
128130
passphrase: 'password',
129131
cert: [cert.toString()],
130132
rejectUnauthorized: false
131-
}, common.mustCall());
133+
}, onSecureConnect());
132134

133135
tls.connect({
134136
port: this.address().port,
135137
key: [rawKey.toString()],
136138
cert: [cert.toString()],
137139
rejectUnauthorized: false
138-
}, common.mustCall());
140+
}, onSecureConnect());
139141

140142
tls.connect({
141143
port: this.address().port,
142144
key: [rawKey.toString()],
143145
passphrase: 'ignored',
144146
cert: [cert.toString()],
145147
rejectUnauthorized: false
146-
}, common.mustCall());
148+
}, onSecureConnect());
147149

148150
// Object[]
149151
tls.connect({
150152
port: this.address().port,
151153
key: [{ pem: passKey, passphrase: 'password' }],
152154
cert: cert,
153155
rejectUnauthorized: false
154-
}, common.mustCall());
156+
}, onSecureConnect());
155157

156158
tls.connect({
157159
port: this.address().port,
158160
key: [{ pem: passKey, passphrase: 'password' }],
159161
passphrase: 'ignored',
160162
cert: cert,
161163
rejectUnauthorized: false
162-
}, common.mustCall());
164+
}, onSecureConnect());
163165

164166
tls.connect({
165167
port: this.address().port,
166168
key: [{ pem: passKey }],
167169
passphrase: 'password',
168170
cert: cert,
169171
rejectUnauthorized: false
170-
}, common.mustCall());
172+
}, onSecureConnect());
171173

172174
tls.connect({
173175
port: this.address().port,
174176
key: [{ pem: passKey.toString(), passphrase: 'password' }],
175177
cert: cert,
176178
rejectUnauthorized: false
177-
}, common.mustCall());
179+
}, onSecureConnect());
178180

179181
tls.connect({
180182
port: this.address().port,
181183
key: [{ pem: rawKey, passphrase: 'ignored' }],
182184
cert: cert,
183185
rejectUnauthorized: false
184-
}, common.mustCall());
186+
}, onSecureConnect());
185187

186188
tls.connect({
187189
port: this.address().port,
188190
key: [{ pem: rawKey.toString(), passphrase: 'ignored' }],
189191
cert: cert,
190192
rejectUnauthorized: false
191-
}, common.mustCall());
193+
}, onSecureConnect());
192194

193195
tls.connect({
194196
port: this.address().port,
195197
key: [{ pem: rawKey }],
196198
passphrase: 'ignored',
197199
cert: cert,
198200
rejectUnauthorized: false
199-
}, common.mustCall());
201+
}, onSecureConnect());
200202

201203
tls.connect({
202204
port: this.address().port,
203205
key: [{ pem: rawKey.toString() }],
204206
passphrase: 'ignored',
205207
cert: cert,
206208
rejectUnauthorized: false
207-
}, common.mustCall());
209+
}, onSecureConnect());
208210

209211
tls.connect({
210212
port: this.address().port,
211213
key: [{ pem: rawKey }],
212214
cert: cert,
213215
rejectUnauthorized: false
214-
}, common.mustCall());
216+
}, onSecureConnect());
215217

216218
tls.connect({
217219
port: this.address().port,
218220
key: [{ pem: rawKey.toString() }],
219221
cert: cert,
220222
rejectUnauthorized: false
221-
}, common.mustCall());
223+
}, onSecureConnect());
222224
})).unref();
223225

224226
const errMessagePassword = /bad decrypt/;

0 commit comments

Comments
 (0)