@@ -55,28 +55,31 @@ const serverCallback = common.mustCall(function(req, res) {
55
55
56
56
const server = https . createServer ( options , serverCallback ) ;
57
57
58
- server . listen ( 0 , function ( ) {
58
+ server . listen ( 0 , common . mustCall ( ( ) => {
59
59
// Do a request ignoring the unauthorized server certs
60
+ const port = server . address ( ) . port ;
61
+
60
62
const noCertCheckOptions = {
61
63
hostname : '127.0.0.1' ,
62
- port : this . address ( ) . port ,
64
+ port : port ,
63
65
path : '/' ,
64
66
method : 'GET' ,
65
67
rejectUnauthorized : false
66
68
} ;
69
+
67
70
noCertCheckOptions . Agent = new https . Agent ( noCertCheckOptions ) ;
68
71
69
- const req = https . request ( noCertCheckOptions , function ( res ) {
72
+ const req = https . request ( noCertCheckOptions , common . mustCall ( ( res ) => {
70
73
let responseBody = '' ;
71
74
res . on ( 'data' , function ( d ) {
72
75
responseBody = responseBody + d ;
73
76
} ) ;
74
77
75
- res . on ( 'end' , function ( ) {
78
+ res . on ( 'end' , common . mustCall ( ( ) => {
76
79
assert . strictEqual ( responseBody , body ) ;
77
80
testSucceeded ( ) ;
78
- } ) ;
79
- } ) ;
81
+ } ) ) ;
82
+ } ) ) ;
80
83
req . end ( ) ;
81
84
82
85
req . on ( 'error' , function ( e ) {
@@ -86,7 +89,7 @@ server.listen(0, function() {
86
89
// Do a request that throws error due to the invalid server certs
87
90
const checkCertOptions = {
88
91
hostname : '127.0.0.1' ,
89
- port : this . address ( ) . port ,
92
+ port : port ,
90
93
path : '/' ,
91
94
method : 'GET'
92
95
} ;
@@ -102,11 +105,11 @@ server.listen(0, function() {
102
105
} ) ;
103
106
checkCertReq . end ( ) ;
104
107
105
- checkCertReq . on ( 'error' , function ( e ) {
108
+ checkCertReq . on ( 'error' , common . mustCall ( ( e ) => {
106
109
assert . strictEqual ( e . code , 'UNABLE_TO_VERIFY_LEAF_SIGNATURE' ) ;
107
110
testSucceeded ( ) ;
108
- } ) ;
109
- } ) ;
111
+ } ) ) ;
112
+ } ) ) ;
110
113
111
114
process . on ( 'exit' , function ( ) {
112
115
assert . strictEqual ( successful , tests ) ;
0 commit comments