@@ -5,8 +5,6 @@ import { get as httpsGet } from 'https';
5
5
import { expect } from 'chai' ;
6
6
import sinon from 'sinon' ;
7
7
import { HTTPServerProxyTestSetup } from '../test/helpers' ;
8
- import socks5AuthNone from 'socksv5/lib/auth/None' ;
9
- import socks5AuthUserPassword from 'socksv5/lib/auth/UserPassword' ;
10
8
11
9
describe ( 'createAgent' , function ( ) {
12
10
let setup : HTTPServerProxyTestSetup ;
@@ -47,7 +45,7 @@ describe('createAgent', function () {
47
45
48
46
context ( 'socks5' , function ( ) {
49
47
it ( 'can connect to a socks5 proxy without auth' , async function ( ) {
50
- setup . socks5ProxyServer . useAuth ( socks5AuthNone ( ) ) ;
48
+ setup . socks5AuthNone ( ) ;
51
49
52
50
const res = await get (
53
51
'http://example.com/hello' ,
@@ -61,7 +59,7 @@ describe('createAgent', function () {
61
59
62
60
it ( 'can connect to a socks5 proxy with successful auth' , async function ( ) {
63
61
const authHandler = sinon . stub ( ) . yields ( true ) ;
64
- setup . socks5ProxyServer . useAuth ( socks5AuthUserPassword ( authHandler ) ) ;
62
+ setup . socks5AuthUsernamePassword ( authHandler ) ;
65
63
66
64
const res = await get (
67
65
'http://example.com/hello' ,
@@ -78,7 +76,7 @@ describe('createAgent', function () {
78
76
79
77
it ( 'fails to connect to a socks5 proxy with unsuccessful auth' , async function ( ) {
80
78
const authHandler = sinon . stub ( ) . yields ( false ) ;
81
- setup . socks5ProxyServer . useAuth ( socks5AuthUserPassword ( authHandler ) ) ;
79
+ setup . socks5AuthUsernamePassword ( authHandler ) ;
82
80
83
81
try {
84
82
await get (
@@ -95,7 +93,7 @@ describe('createAgent', function () {
95
93
} ) ;
96
94
97
95
context ( 'http proxy' , function ( ) {
98
- it ( 'can connect to a socks5 proxy without auth' , async function ( ) {
96
+ it ( 'can connect to a http proxy without auth' , async function ( ) {
99
97
const res = await get (
100
98
'http://example.com/hello' ,
101
99
createAgent ( { proxy : `http://127.0.0.1:${ setup . httpProxyPort } ` } )
@@ -106,7 +104,7 @@ describe('createAgent', function () {
106
104
] ) ;
107
105
} ) ;
108
106
109
- it ( 'can connect to a socks5 proxy with successful auth' , async function ( ) {
107
+ it ( 'can connect to a http proxy with successful auth' , async function ( ) {
110
108
setup . authHandler = sinon . stub ( ) . returns ( true ) ;
111
109
112
110
const res = await get (
@@ -122,7 +120,7 @@ describe('createAgent', function () {
122
120
expect ( setup . authHandler ) . to . have . been . calledOnceWith ( 'foo' , 'bar' ) ;
123
121
} ) ;
124
122
125
- it ( 'fails to connect to a socks5 proxy with unsuccessful auth' , async function ( ) {
123
+ it ( 'fails to connect to a http proxy with unsuccessful auth' , async function ( ) {
126
124
setup . authHandler = sinon . stub ( ) . returns ( false ) ;
127
125
128
126
const res = await get (
@@ -147,7 +145,7 @@ describe('createAgent', function () {
147
145
] ) ;
148
146
} ) ;
149
147
150
- it ( 'can connect to a socks5 proxy with successful auth' , async function ( ) {
148
+ it ( 'can connect to a https proxy with successful auth' , async function ( ) {
151
149
setup . authHandler = sinon . stub ( ) . returns ( true ) ;
152
150
153
151
const res = await get (
@@ -163,7 +161,7 @@ describe('createAgent', function () {
163
161
expect ( setup . authHandler ) . to . have . been . calledOnceWith ( 'foo' , 'bar' ) ;
164
162
} ) ;
165
163
166
- it ( 'fails to connect to a socks5 proxy with unsuccessful auth' , async function ( ) {
164
+ it ( 'fails to connect to a https proxy with unsuccessful auth' , async function ( ) {
167
165
setup . authHandler = sinon . stub ( ) . returns ( false ) ;
168
166
169
167
const res = await get (
@@ -177,25 +175,25 @@ describe('createAgent', function () {
177
175
} ) ;
178
176
179
177
context ( 'ssh proxy' , function ( ) {
180
- it ( 'can connect to a ssh proxy without auth' , async function ( ) {
178
+ it ( 'can connect to an ssh proxy without auth' , async function ( ) {
181
179
const res = await get (
182
- 'https ://example.com/hello' ,
180
+ 'http ://example.com/hello' ,
183
181
createAgent ( { proxy :
`ssh://[email protected] :${ setup . sshProxyPort } ` } )
184
182
) ;
185
183
expect ( res . body ) . to . equal ( 'OK /hello' ) ;
186
184
expect ( setup . getRequestedUrls ( ) ) . to . deep . equal ( [
187
185
'http://example.com/hello' ,
188
186
] ) ;
189
187
expect ( setup . sshTunnelInfos ) . to . deep . equal ( [
190
- { destIP : 'example.com' , destPort : 0 , srcIP : '127.0.0.1' , srcPort : 0 } ,
188
+ { destIP : 'example.com' , destPort : 80 , srcIP : '127.0.0.1' , srcPort : 0 } ,
191
189
] ) ;
192
190
} ) ;
193
191
194
- it ( 'can connect to a ssh proxy with successful auth' , async function ( ) {
192
+ it ( 'can connect to an ssh proxy with successful auth' , async function ( ) {
195
193
setup . authHandler = sinon . stub ( ) . returns ( true ) ;
196
194
197
195
const res = await get (
198
- 'https ://example.com/hello' ,
196
+ 'http ://example.com/hello' ,
199
197
createAgent ( { proxy :
`ssh://foo:[email protected] :${ setup . sshProxyPort } ` } )
200
198
) ;
201
199
expect ( res . body ) . to . equal ( 'OK /hello' ) ;
@@ -205,7 +203,7 @@ describe('createAgent', function () {
205
203
expect ( setup . authHandler ) . to . have . been . calledOnceWith ( 'foo' , 'bar' ) ;
206
204
} ) ;
207
205
208
- it ( 'fails to connect to a ssh proxy with unsuccessful auth' , async function ( ) {
206
+ it ( 'fails to connect to an ssh proxy with unsuccessful auth' , async function ( ) {
209
207
setup . authHandler = sinon . stub ( ) . returns ( false ) ;
210
208
211
209
try {
@@ -223,7 +221,7 @@ describe('createAgent', function () {
223
221
}
224
222
} ) ;
225
223
226
- it ( 'fails to connect to a ssh proxy with unavailable tunneling' , async function ( ) {
224
+ it ( 'fails to connect to an ssh proxy with unavailable tunneling' , async function ( ) {
227
225
setup . authHandler = sinon . stub ( ) . returns ( true ) ;
228
226
setup . canTunnel = false ;
229
227
0 commit comments