@@ -213,59 +213,38 @@ mod tests {
213213 use std:: future:: poll_fn;
214214
215215 use http:: Uri ;
216- use hyper_util:: client:: legacy:: connect:: HttpConnector ;
216+ use hyper_util:: rt:: TokioIo ;
217+ use tokio:: net:: TcpStream ;
217218 use tower_service:: Service ;
218219
219- use super :: HttpsConnector ;
220- use crate :: { ConfigBuilderExt , HttpsConnectorBuilder } ;
220+ use super :: * ;
221+ use crate :: { ConfigBuilderExt , HttpsConnectorBuilder , MaybeHttpsStream } ;
221222
222223 #[ tokio:: test]
223224 async fn connects_https ( ) {
224- oneshot ( https_or_http_connector ( ) , true )
225- . await
226- . unwrap ( ) ;
225+ connect ( false , true ) . await . unwrap ( ) ;
227226 }
228227
229228 #[ tokio:: test]
230229 async fn connects_http ( ) {
231- oneshot ( https_or_http_connector ( ) , false )
232- . await
233- . unwrap ( ) ;
230+ connect ( false , false ) . await . unwrap ( ) ;
234231 }
235232
236233 #[ tokio:: test]
237234 async fn connects_https_only ( ) {
238- oneshot ( https_only_connector ( ) , true )
239- . await
240- . unwrap ( ) ;
235+ connect ( true , true ) . await . unwrap ( ) ;
241236 }
242237
243238 #[ tokio:: test]
244239 async fn enforces_https_only ( ) {
245- let message = oneshot ( https_only_connector ( ) , false )
240+ let message = connect ( true , false )
246241 . await
247242 . unwrap_err ( )
248243 . to_string ( ) ;
249244
250245 assert_eq ! ( message, "unsupported scheme http" ) ;
251246 }
252247
253- fn https_or_http_connector ( ) -> HttpsConnector < HttpConnector > {
254- HttpsConnectorBuilder :: new ( )
255- . with_tls_config ( tls_config ( ) )
256- . https_or_http ( )
257- . enable_http1 ( )
258- . build ( )
259- }
260-
261- fn https_only_connector ( ) -> HttpsConnector < HttpConnector > {
262- HttpsConnectorBuilder :: new ( )
263- . with_tls_config ( tls_config ( ) )
264- . https_only ( )
265- . enable_http1 ( )
266- . build ( )
267- }
268-
269248 fn tls_config ( ) -> rustls:: ClientConfig {
270249 #[ cfg( feature = "rustls-platform-verifier" ) ]
271250 return rustls:: ClientConfig :: builder ( )
@@ -284,10 +263,18 @@ mod tests {
284263 . with_no_client_auth ( ) ;
285264 }
286265
287- async fn oneshot < S : Service < Uri > > (
288- mut service : S ,
266+ async fn connect (
267+ https_only : bool ,
289268 https : bool ,
290- ) -> Result < S :: Response , S :: Error > {
269+ ) -> Result < MaybeHttpsStream < TokioIo < TcpStream > > , BoxError > {
270+ let builder = HttpsConnectorBuilder :: new ( ) . with_tls_config ( tls_config ( ) ) ;
271+ let mut service = match https_only {
272+ true => builder. https_only ( ) ,
273+ false => builder. https_or_http ( ) ,
274+ }
275+ . enable_http1 ( )
276+ . build ( ) ;
277+
291278 poll_fn ( |cx| service. poll_ready ( cx) ) . await ?;
292279 service
293280 . call ( Uri :: from_static ( match https {
0 commit comments