@@ -103,8 +103,9 @@ async function run () {
103103 const resultRoot = await got (
104104 `http://localhost:${ server . server . address ( ) . port } /this-has-data` ,
105105 {
106- body : { hello : 'world' } ,
107- json : true
106+ method : 'POST' ,
107+ json : { hello : 'world' } ,
108+ responseType : 'json'
108109 }
109110 )
110111 t . deepEqual ( resultRoot . body , { something : 'posted' } )
@@ -126,7 +127,7 @@ async function run () {
126127 try {
127128 await got ( `http://localhost:${ server . server . address ( ) . port } ` )
128129 } catch ( err ) {
129- t . equal ( err . statusCode , 401 )
130+ t . equal ( err . response . statusCode , 401 )
130131 errored = true
131132 }
132133 t . ok ( errored )
@@ -135,7 +136,7 @@ async function run () {
135136 try {
136137 await got ( `http://localhost:${ server . server . address ( ) . port } /a` )
137138 } catch ( err ) {
138- t . equal ( err . statusCode , 401 )
139+ t . equal ( err . response . statusCode , 401 )
139140 errored = true
140141 }
141142 t . ok ( errored )
@@ -159,38 +160,7 @@ async function run () {
159160 try {
160161 await got ( `http://localhost:${ server . server . address ( ) . port } ` )
161162 } catch ( err ) {
162- t . equal ( err . statusCode , 401 )
163- errored = true
164- }
165- t . ok ( errored )
166- } )
167-
168- test ( 'beforeHandler(deprecated)' , async t => {
169- const server = Fastify ( )
170- server . register ( proxy , {
171- upstream : `http://localhost:${ origin . server . address ( ) . port } ` ,
172- async beforeHandler ( request , reply ) {
173- throw new Unauthorized ( )
174- }
175- } )
176-
177- await server . listen ( 0 )
178- t . tearDown ( server . close . bind ( server ) )
179-
180- var errored = false
181- try {
182- await got ( `http://localhost:${ server . server . address ( ) . port } ` )
183- } catch ( err ) {
184- t . equal ( err . statusCode , 401 )
185- errored = true
186- }
187- t . ok ( errored )
188-
189- errored = false
190- try {
191- await got ( `http://localhost:${ server . server . address ( ) . port } /a` )
192- } catch ( err ) {
193- t . equal ( err . statusCode , 401 )
163+ t . equal ( err . response . statusCode , 401 )
194164 errored = true
195165 }
196166 t . ok ( errored )
@@ -300,8 +270,8 @@ async function run () {
300270 } = await got (
301271 `http://localhost:${ proxyServer . server . address ( ) . port } /api/this-has-data` ,
302272 {
303- body : { hello : 'world' } ,
304- json : true
273+ method : 'POST' ,
274+ json : { hello : 'world' }
305275 }
306276 )
307277 t . equal ( location , '/api/something' )
0 commit comments