File tree Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -7,9 +7,12 @@ module.exports = class Socket extends EventEmitter {
7
7
constructor ( options ) {
8
8
super ( )
9
9
10
+ // Pretend this is a TLSSocket
10
11
if ( options . proto === 'https' ) {
11
12
// https://github.com/nock/nock/issues/158
12
13
this . authorized = true
14
+ // https://github.com/nock/nock/issues/2147
15
+ this . encrypted = true
13
16
}
14
17
15
18
this . bufferSize = 0
Original file line number Diff line number Diff line change 1
1
'use strict'
2
2
3
+ const { expect } = require ( 'chai' )
3
4
const http = require ( 'http' )
5
+ const https = require ( 'https' )
4
6
const nock = require ( '..' )
5
7
6
8
require ( './setup' )
7
9
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
+
8
30
describe ( '`Socket#setTimeout()`' , ( ) => {
9
31
it ( 'adds callback as a one-time listener for parity with a real socket' , done => {
10
32
nock ( 'http://example.test' ) . get ( '/' ) . delayConnection ( 100 ) . reply ( )
You can’t perform that action at this time.
0 commit comments