@@ -34,28 +34,31 @@ const serverCallback = common.mustCall(function(req, res) {
34
34
35
35
const server = https . createServer ( options , serverCallback ) ;
36
36
37
- server . listen ( 0 , function ( ) {
37
+ server . listen ( 0 , common . mustCall ( ( ) => {
38
38
// Do a request ignoring the unauthorized server certs
39
+ const port = server . address ( ) . port ;
40
+
39
41
const noCertCheckOptions = {
40
42
hostname : '127.0.0.1' ,
41
- port : this . address ( ) . port ,
43
+ port : port ,
42
44
path : '/' ,
43
45
method : 'GET' ,
44
46
rejectUnauthorized : false
45
47
} ;
48
+
46
49
noCertCheckOptions . Agent = new https . Agent ( noCertCheckOptions ) ;
47
50
48
- const req = https . request ( noCertCheckOptions , function ( res ) {
51
+ const req = https . request ( noCertCheckOptions , common . mustCall ( ( res ) => {
49
52
let responseBody = '' ;
50
53
res . on ( 'data' , function ( d ) {
51
54
responseBody = responseBody + d ;
52
55
} ) ;
53
56
54
- res . on ( 'end' , function ( ) {
57
+ res . on ( 'end' , common . mustCall ( ( ) => {
55
58
assert . strictEqual ( responseBody , body ) ;
56
59
testSucceeded ( ) ;
57
- } ) ;
58
- } ) ;
60
+ } ) ) ;
61
+ } ) ) ;
59
62
req . end ( ) ;
60
63
61
64
req . on ( 'error' , function ( e ) {
@@ -65,7 +68,7 @@ server.listen(0, function() {
65
68
// Do a request that throws error due to the invalid server certs
66
69
const checkCertOptions = {
67
70
hostname : '127.0.0.1' ,
68
- port : this . address ( ) . port ,
71
+ port : port ,
69
72
path : '/' ,
70
73
method : 'GET'
71
74
} ;
@@ -81,11 +84,11 @@ server.listen(0, function() {
81
84
} ) ;
82
85
checkCertReq . end ( ) ;
83
86
84
- checkCertReq . on ( 'error' , function ( e ) {
87
+ checkCertReq . on ( 'error' , common . mustCall ( ( e ) => {
85
88
assert . strictEqual ( e . code , 'UNABLE_TO_VERIFY_LEAF_SIGNATURE' ) ;
86
89
testSucceeded ( ) ;
87
- } ) ;
88
- } ) ;
90
+ } ) ) ;
91
+ } ) ) ;
89
92
90
93
process . on ( 'exit' , function ( ) {
91
94
assert . strictEqual ( successful , tests ) ;
0 commit comments