@@ -125,7 +125,7 @@ var serverKey = loadPEM('agent2-key');
125
125
var serverCert = loadPEM ( 'agent2-cert' ) ;
126
126
127
127
128
- function runClient ( port , options , cb ) {
128
+ function runClient ( prefix , port , options , cb ) {
129
129
130
130
// Client can connect in three ways:
131
131
// - Self-signed cert
@@ -135,7 +135,7 @@ function runClient(port, options, cb) {
135
135
var args = [ 's_client' , '-connect' , '127.0.0.1:' + port ] ;
136
136
137
137
138
- console . log ( ' connecting with' , options . name ) ;
138
+ console . log ( prefix + ' connecting with' , options . name ) ;
139
139
140
140
switch ( options . name ) {
141
141
case 'agent1' :
@@ -176,7 +176,7 @@ function runClient(port, options, cb) {
176
176
break ;
177
177
178
178
default :
179
- throw new Error ( 'Unknown agent name' ) ;
179
+ throw new Error ( prefix + 'Unknown agent name' ) ;
180
180
}
181
181
182
182
// To test use: openssl s_client -connect localhost:8000
@@ -193,15 +193,15 @@ function runClient(port, options, cb) {
193
193
out += d ;
194
194
195
195
if ( ! goodbye && / _ u n a u t h e d / g. test ( out ) ) {
196
- console . error ( ' * unauthed' ) ;
196
+ console . error ( prefix + ' * unauthed' ) ;
197
197
goodbye = true ;
198
198
client . stdin . end ( 'goodbye\n' ) ;
199
199
authed = false ;
200
200
rejected = false ;
201
201
}
202
202
203
203
if ( ! goodbye && / _ a u t h e d / g. test ( out ) ) {
204
- console . error ( ' * authed' ) ;
204
+ console . error ( prefix + ' * authed' ) ;
205
205
goodbye = true ;
206
206
client . stdin . end ( 'goodbye\n' ) ;
207
207
authed = true ;
@@ -212,15 +212,17 @@ function runClient(port, options, cb) {
212
212
//client.stdout.pipe(process.stdout);
213
213
214
214
client . on ( 'exit' , function ( code ) {
215
- //assert.equal(0, code, options.name +
215
+ //assert.equal(0, code, prefix + options.name +
216
216
// ": s_client exited with error code " + code);
217
217
if ( options . shouldReject ) {
218
- assert . equal ( true , rejected , options . name +
218
+ assert . equal ( true , rejected , prefix + options . name +
219
219
' NOT rejected, but should have been' ) ;
220
220
} else {
221
- assert . equal ( false , rejected , options . name +
221
+ assert . equal ( false , rejected , prefix + options . name +
222
222
' rejected, but should NOT have been' ) ;
223
- assert . equal ( options . shouldAuth , authed ) ;
223
+ assert . equal ( options . shouldAuth , authed , prefix +
224
+ options . name + ' authed is ' + authed +
225
+ ' but should have been ' + options . shouldAuth ) ;
224
226
}
225
227
226
228
cb ( ) ;
@@ -231,10 +233,11 @@ function runClient(port, options, cb) {
231
233
// Run the tests
232
234
var successfulTests = 0 ;
233
235
function runTest ( port , testIndex ) {
236
+ var prefix = testIndex + ' ' ;
234
237
var tcase = testCases [ testIndex ] ;
235
238
if ( ! tcase ) return ;
236
239
237
- console . error ( "Running '%s'" , tcase . title ) ;
240
+ console . error ( prefix + "Running '%s'" , tcase . title ) ;
238
241
239
242
var cas = tcase . CAs . map ( loadPEM ) ;
240
243
@@ -265,7 +268,7 @@ function runTest(port, testIndex) {
265
268
if ( tcase . renegotiate && ! renegotiated ) {
266
269
renegotiated = true ;
267
270
setTimeout ( function ( ) {
268
- console . error ( '- connected, renegotiating' ) ;
271
+ console . error ( prefix + '- connected, renegotiating' ) ;
269
272
c . write ( '\n_renegotiating\n' ) ;
270
273
return c . renegotiate ( {
271
274
requestCert : true ,
@@ -281,19 +284,19 @@ function runTest(port, testIndex) {
281
284
282
285
connections ++ ;
283
286
if ( c . authorized ) {
284
- console . error ( '- authed connection: ' +
287
+ console . error ( prefix + '- authed connection: ' +
285
288
c . getPeerCertificate ( ) . subject . CN ) ;
286
289
c . write ( '\n_authed\n' ) ;
287
290
} else {
288
- console . error ( '- unauthed connection: %s' , c . authorizationError ) ;
291
+ console . error ( prefix + '- unauthed connection: %s' , c . authorizationError ) ;
289
292
c . write ( '\n_unauthed\n' ) ;
290
293
}
291
294
} ) ;
292
295
293
296
function runNextClient ( clientIndex ) {
294
297
var options = tcase . clients [ clientIndex ] ;
295
298
if ( options ) {
296
- runClient ( port , options , function ( ) {
299
+ runClient ( prefix + clientIndex + ' ' , port , options , function ( ) {
297
300
runNextClient ( clientIndex + 1 ) ;
298
301
} ) ;
299
302
} else {
@@ -305,14 +308,14 @@ function runTest(port, testIndex) {
305
308
306
309
server . listen ( port , function ( ) {
307
310
if ( tcase . debug ) {
308
- console . error ( 'TLS server running on port ' + port ) ;
311
+ console . error ( prefix + 'TLS server running on port ' + port ) ;
309
312
} else {
310
313
if ( tcase . renegotiate ) {
311
314
runNextClient ( 0 ) ;
312
315
} else {
313
316
var clientsCompleted = 0 ;
314
317
for ( var i = 0 ; i < tcase . clients . length ; i ++ ) {
315
- runClient ( port , tcase . clients [ i ] , function ( ) {
318
+ runClient ( prefix + i + ' ' , port , tcase . clients [ i ] , function ( ) {
316
319
clientsCompleted ++ ;
317
320
if ( clientsCompleted === tcase . clients . length ) {
318
321
server . close ( ) ;
0 commit comments