File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -7,9 +7,12 @@ module.exports = class Socket extends EventEmitter {
77 constructor ( options ) {
88 super ( )
99
10+ // Pretend this is a TLSSocket
1011 if ( options . proto === 'https' ) {
1112 // https://github.com/nock/nock/issues/158
1213 this . authorized = true
14+ // https://github.com/nock/nock/issues/2147
15+ this . encrypted = true
1316 }
1417
1518 this . bufferSize = 0
Original file line number Diff line number Diff line change 11'use strict'
22
3+ const { expect } = require ( 'chai' )
34const http = require ( 'http' )
5+ const https = require ( 'https' )
46const nock = require ( '..' )
57
68require ( './setup' )
79
10+ it ( 'should expose TLSSocket attributes for HTTPS requests' , done => {
11+ nock ( 'https://example.test' ) . get ( '/' ) . reply ( )
12+
13+ https . get ( 'https://example.test' ) . on ( 'socket' , socket => {
14+ expect ( socket . authorized ) . to . equal ( true )
15+ expect ( socket . encrypted ) . to . equal ( true )
16+ done ( )
17+ } )
18+ } )
19+
20+ it ( 'should not have TLSSocket attributes for HTTP requests' , done => {
21+ nock ( 'http://example.test' ) . get ( '/' ) . reply ( )
22+
23+ http . get ( 'http://example.test' ) . on ( 'socket' , socket => {
24+ expect ( socket . authorized ) . to . equal ( undefined )
25+ expect ( socket . encrypted ) . to . equal ( undefined )
26+ done ( )
27+ } )
28+ } )
29+
830describe ( '`Socket#setTimeout()`' , ( ) => {
931 it ( 'adds callback as a one-time listener for parity with a real socket' , done => {
1032 nock ( 'http://example.test' ) . get ( '/' ) . delayConnection ( 100 ) . reply ( )
You can’t perform that action at this time.
0 commit comments