@@ -33,7 +33,7 @@ test.before(() => {
33
33
// Fake server to respond to URL
34
34
http . createServer ( ( req , res ) => {
35
35
res . statusCode = 200
36
- res . end ( 'ok' )
36
+ res . end ( `ok - host: ${ req . headers . host } ` )
37
37
} ) . listen ( 4000 )
38
38
39
39
// Add server
@@ -72,6 +72,9 @@ test.before(() => {
72
72
// Add URL
73
73
servers . add ( 'http://localhost:4000' , { n : 'proxy' } )
74
74
75
+ // Add https URL
76
+ servers . add ( 'https://jsonplaceholder.typicode.com' , { n : 'proxy-with-https-target' } )
77
+
75
78
// Add unavailable URL
76
79
servers . add ( 'http://localhost:4100' , { n : 'unavailable-proxy' } )
77
80
@@ -101,12 +104,16 @@ test.cb('GET http://hotel.dev/index.html should serve index.html', (t) => {
101
104
. expect ( 200 , t . end )
102
105
} )
103
106
104
- test . cb ( 'GET http://node.dev should proxy request' , ( t ) => {
105
- request ( app )
106
- . get ( '/' )
107
- . set ( 'Host' , 'node.dev' )
108
- . expect ( 200 , / H e l l o W o r l d / , t . end )
109
- } )
107
+ test . cb (
108
+ 'GET http://node.dev should proxy request and host should be node.dev' ,
109
+ ( t ) => {
110
+ request ( app )
111
+ . get ( '/' )
112
+ . set ( 'Host' , 'node.dev' )
113
+ . expect ( / h o s t : n o d e .d e v / )
114
+ . expect ( 200 , / H e l l o W o r l d / , t . end )
115
+ }
116
+ )
110
117
111
118
test . cb ( 'GET http://subdomain.node.dev should proxy request' , ( t ) => {
112
119
request ( app )
@@ -136,10 +143,20 @@ test.cb('GET http://failing.dev should return 502', (t) => {
136
143
. expect ( 502 , t . end )
137
144
} )
138
145
139
- test . cb ( 'GET http://proxy.dev should return 502' , ( t ) => {
146
+ test . cb (
147
+ 'GET http://proxy.dev should return 200 and host should be proxy.dev' ,
148
+ ( t ) => {
149
+ request ( app )
150
+ . get ( '/' )
151
+ . set ( 'Host' , 'proxy.dev' )
152
+ . expect ( 200 , / h o s t : p r o x y .d e v / , t . end )
153
+ }
154
+ )
155
+
156
+ test . cb ( 'GET http://proxy-with-https-target.dev should return 200' , ( t ) => {
140
157
request ( app )
141
158
. get ( '/' )
142
- . set ( 'Host' , 'proxy.dev' )
159
+ . set ( 'Host' , 'proxy-with-https-target .dev' )
143
160
. expect ( 200 , t . end )
144
161
} )
145
162
@@ -166,7 +183,7 @@ test.cb('GET /_/servers', t => {
166
183
. get ( '/_/servers' )
167
184
. expect ( 200 , ( err , res ) => {
168
185
if ( err ) return t . end ( err )
169
- t . is ( Object . keys ( res . body ) . length , 8 , 'got wrong number of servers' )
186
+ t . is ( Object . keys ( res . body ) . length , 9 , 'got wrong number of servers' )
170
187
t . end ( )
171
188
} )
172
189
} )
0 commit comments