11use std:: { io:: Write , process:: Stdio } ;
22use tokio:: process:: Command ;
33use tracing:: { instrument, trace, warn} ;
4- use uv_redacted:: DisplaySafeUrlRef ;
4+ use uv_redacted:: DisplaySafeUrl ;
55use uv_warnings:: warn_user_once;
66
77use crate :: credentials:: Credentials ;
@@ -36,11 +36,7 @@ impl KeyringProvider {
3636 /// Returns [`None`] if no password was found for the username or if any errors
3737 /// are encountered in the keyring backend.
3838 #[ instrument( skip_all, fields( url = % url. to_string( ) , username) ) ]
39- pub async fn fetch (
40- & self ,
41- url : DisplaySafeUrlRef < ' _ > ,
42- username : Option < & str > ,
43- ) -> Option < Credentials > {
39+ pub async fn fetch ( & self , url : & DisplaySafeUrl , username : Option < & str > ) -> Option < Credentials > {
4440 // Validate the request
4541 debug_assert ! (
4642 url. host_str( ) . is_some( ) ,
@@ -229,7 +225,7 @@ mod tests {
229225 let keyring = KeyringProvider :: empty ( ) ;
230226 // Panics due to debug assertion; returns `None` in production
231227 let result = std:: panic:: AssertUnwindSafe (
232- keyring. fetch ( DisplaySafeUrlRef :: from ( & url) , Some ( "user" ) ) ,
228+ keyring. fetch ( DisplaySafeUrl :: ref_cast ( & url) , Some ( "user" ) ) ,
233229 )
234230 . catch_unwind ( )
235231 . await ;
@@ -242,7 +238,7 @@ mod tests {
242238 let keyring = KeyringProvider :: empty ( ) ;
243239 // Panics due to debug assertion; returns `None` in production
244240 let result = std:: panic:: AssertUnwindSafe (
245- keyring. fetch ( DisplaySafeUrlRef :: from ( & url) , Some ( url. username ( ) ) ) ,
241+ keyring. fetch ( DisplaySafeUrl :: ref_cast ( & url) , Some ( url. username ( ) ) ) ,
246242 )
247243 . catch_unwind ( )
248244 . await ;
@@ -255,7 +251,7 @@ mod tests {
255251 let keyring = KeyringProvider :: empty ( ) ;
256252 // Panics due to debug assertion; returns `None` in production
257253 let result = std:: panic:: AssertUnwindSafe (
258- keyring. fetch ( DisplaySafeUrlRef :: from ( & url) , Some ( url. username ( ) ) ) ,
254+ keyring. fetch ( DisplaySafeUrl :: ref_cast ( & url) , Some ( url. username ( ) ) ) ,
259255 )
260256 . catch_unwind ( )
261257 . await ;
@@ -265,7 +261,7 @@ mod tests {
265261 #[ tokio:: test]
266262 async fn fetch_url_no_auth ( ) {
267263 let url = Url :: parse ( "https://example.com" ) . unwrap ( ) ;
268- let url = DisplaySafeUrlRef :: from ( & url) ;
264+ let url = DisplaySafeUrl :: ref_cast ( & url) ;
269265 let keyring = KeyringProvider :: empty ( ) ;
270266 let credentials = keyring. fetch ( url, Some ( "user" ) ) ;
271267 assert ! ( credentials. await . is_none( ) ) ;
@@ -277,7 +273,7 @@ mod tests {
277273 let keyring = KeyringProvider :: dummy ( [ ( url. host_str ( ) . unwrap ( ) , "user" , "password" ) ] ) ;
278274 assert_eq ! (
279275 keyring
280- . fetch( DisplaySafeUrlRef :: from ( & url) , Some ( "user" ) )
276+ . fetch( DisplaySafeUrl :: ref_cast ( & url) , Some ( "user" ) )
281277 . await ,
282278 Some ( Credentials :: basic(
283279 Some ( "user" . to_string( ) ) ,
@@ -287,7 +283,7 @@ mod tests {
287283 assert_eq ! (
288284 keyring
289285 . fetch(
290- DisplaySafeUrlRef :: from ( & url. join( "test" ) . unwrap( ) ) ,
286+ DisplaySafeUrl :: ref_cast ( & url. join( "test" ) . unwrap( ) ) ,
291287 Some ( "user" )
292288 )
293289 . await ,
@@ -303,7 +299,7 @@ mod tests {
303299 let url = Url :: parse ( "https://example.com" ) . unwrap ( ) ;
304300 let keyring = KeyringProvider :: dummy ( [ ( "other.com" , "user" , "password" ) ] ) ;
305301 let credentials = keyring
306- . fetch ( DisplaySafeUrlRef :: from ( & url) , Some ( "user" ) )
302+ . fetch ( DisplaySafeUrl :: ref_cast ( & url) , Some ( "user" ) )
307303 . await ;
308304 assert_eq ! ( credentials, None ) ;
309305 }
@@ -318,7 +314,7 @@ mod tests {
318314 assert_eq ! (
319315 keyring
320316 . fetch(
321- DisplaySafeUrlRef :: from ( & url. join( "foo" ) . unwrap( ) ) ,
317+ DisplaySafeUrl :: ref_cast ( & url. join( "foo" ) . unwrap( ) ) ,
322318 Some ( "user" )
323319 )
324320 . await ,
@@ -329,7 +325,7 @@ mod tests {
329325 ) ;
330326 assert_eq ! (
331327 keyring
332- . fetch( DisplaySafeUrlRef :: from ( & url) , Some ( "user" ) )
328+ . fetch( DisplaySafeUrl :: ref_cast ( & url) , Some ( "user" ) )
333329 . await ,
334330 Some ( Credentials :: basic(
335331 Some ( "user" . to_string( ) ) ,
@@ -339,7 +335,7 @@ mod tests {
339335 assert_eq ! (
340336 keyring
341337 . fetch(
342- DisplaySafeUrlRef :: from ( & url. join( "bar" ) . unwrap( ) ) ,
338+ DisplaySafeUrl :: ref_cast ( & url. join( "bar" ) . unwrap( ) ) ,
343339 Some ( "user" )
344340 )
345341 . await ,
@@ -355,7 +351,7 @@ mod tests {
355351 let url = Url :: parse ( "https://example.com" ) . unwrap ( ) ;
356352 let keyring = KeyringProvider :: dummy ( [ ( url. host_str ( ) . unwrap ( ) , "user" , "password" ) ] ) ;
357353 let credentials = keyring
358- . fetch ( DisplaySafeUrlRef :: from ( & url) , Some ( "user" ) )
354+ . fetch ( DisplaySafeUrl :: ref_cast ( & url) , Some ( "user" ) )
359355 . await ;
360356 assert_eq ! (
361357 credentials,
@@ -370,7 +366,7 @@ mod tests {
370366 async fn fetch_url_no_username ( ) {
371367 let url = Url :: parse ( "https://example.com" ) . unwrap ( ) ;
372368 let keyring = KeyringProvider :: dummy ( [ ( url. host_str ( ) . unwrap ( ) , "user" , "password" ) ] ) ;
373- let credentials = keyring. fetch ( DisplaySafeUrlRef :: from ( & url) , None ) . await ;
369+ let credentials = keyring. fetch ( DisplaySafeUrl :: ref_cast ( & url) , None ) . await ;
374370 assert_eq ! (
375371 credentials,
376372 Some ( Credentials :: basic(
@@ -385,14 +381,14 @@ mod tests {
385381 let url = Url :: parse ( "https://example.com" ) . unwrap ( ) ;
386382 let keyring = KeyringProvider :: dummy ( [ ( url. host_str ( ) . unwrap ( ) , "foo" , "password" ) ] ) ;
387383 let credentials = keyring
388- . fetch ( DisplaySafeUrlRef :: from ( & url) , Some ( "bar" ) )
384+ . fetch ( DisplaySafeUrl :: ref_cast ( & url) , Some ( "bar" ) )
389385 . await ;
390386 assert_eq ! ( credentials, None ) ;
391387
392388 // Still fails if we have `foo` in the URL itself
393389 let url = Url :: parse ( "https://foo@example.com" ) . unwrap ( ) ;
394390 let credentials = keyring
395- . fetch ( DisplaySafeUrlRef :: from ( & url) , Some ( "bar" ) )
391+ . fetch ( DisplaySafeUrl :: ref_cast ( & url) , Some ( "bar" ) )
396392 . await ;
397393 assert_eq ! ( credentials, None ) ;
398394 }
0 commit comments