Skip to content

Commit 6b10245

Browse files
committed
add test for password and user access
1 parent 4ba43ac commit 6b10245

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

gix-url/tests/access/mod.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,28 @@ mod canonicalized {
3030
}
3131
}
3232

33+
#[test]
34+
fn password() -> crate::Result {
35+
let mut url = gix_url::parse("https://user:password@host/path".into())?;
36+
37+
assert_eq!(url.password(), Some("password"));
38+
assert_eq!(url.set_password(Some("new-pass".into())), Some("password".into()));
39+
assert_eq!(url.password(), Some("new-pass"));
40+
41+
Ok(())
42+
}
43+
44+
#[test]
45+
fn user() -> crate::Result {
46+
let mut url = gix_url::parse("https://user:password@host/path".into())?;
47+
48+
assert_eq!(url.user(), Some("user"));
49+
assert_eq!(url.set_user(Some("new-user".into())), Some("user".into()));
50+
assert_eq!(url.user(), Some("new-user"));
51+
52+
Ok(())
53+
}
54+
3355
#[test]
3456
fn host_argument_safe() -> crate::Result {
3557
let url = gix_url::parse("ssh://-oProxyCommand=open$IFS-aCalculator/foo".into())?;

0 commit comments

Comments
 (0)