Skip to content

Commit 026ce08

Browse files
committed
Fix webdriver tests on the rebase
1 parent 7d732d7 commit 026ce08

File tree

1 file changed

+32
-17
lines changed

1 file changed

+32
-17
lines changed

src/virtualdevices/webdriver/web_api.rs

Lines changed: 32 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ mod handlers {
240240
};
241241
}
242242

243-
pub fn validate_rp_id(rp_id: &String) -> crate::Result<()> {
243+
pub fn validate_rp_id(rp_id: &str) -> crate::Result<()> {
244244
if let Ok(uri) = rp_id.parse::<uri::Uri>().map_err(|_| {
245245
crate::errors::AuthenticatorError::U2FToken(crate::errors::U2FTokenError::Unknown)
246246
}) {
@@ -252,7 +252,7 @@ mod handlers {
252252
if uri.authority().unwrap() == uri.host().unwrap() {
253253
// Don't try too hard to ensure it's a valid domain, just
254254
// ensure there's a label delim in there somewhere
255-
if uri.host().unwrap().find(".").is_some() {
255+
if uri.host().unwrap().find('.').is_some() {
256256
return Ok(());
257257
}
258258
}
@@ -525,35 +525,50 @@ mod tests {
525525
#[test]
526526
fn test_validate_rp_id() {
527527
init();
528-
assert_eq!(
528+
529+
assert_matches!(
529530
validate_rp_id(&String::from("http://example.com")),
530-
Err(crate::Error::Unknown)
531+
Err(crate::errors::AuthenticatorError::U2FToken(
532+
crate::errors::U2FTokenError::Unknown,
533+
))
531534
);
532-
assert_eq!(
535+
assert_matches!(
533536
validate_rp_id(&String::from("https://example.com")),
534-
Err(crate::Error::Unknown)
537+
Err(crate::errors::AuthenticatorError::U2FToken(
538+
crate::errors::U2FTokenError::Unknown,
539+
))
535540
);
536-
assert_eq!(
541+
assert_matches!(
537542
validate_rp_id(&String::from("example.com:443")),
538-
Err(crate::Error::Unknown)
543+
Err(crate::errors::AuthenticatorError::U2FToken(
544+
crate::errors::U2FTokenError::Unknown,
545+
))
539546
);
540-
assert_eq!(
547+
assert_matches!(
541548
validate_rp_id(&String::from("example.com/path")),
542-
Err(crate::Error::Unknown)
549+
Err(crate::errors::AuthenticatorError::U2FToken(
550+
crate::errors::U2FTokenError::Unknown,
551+
))
543552
);
544-
assert_eq!(
553+
assert_matches!(
545554
validate_rp_id(&String::from("example.com:443/path")),
546-
Err(crate::Error::Unknown)
555+
Err(crate::errors::AuthenticatorError::U2FToken(
556+
crate::errors::U2FTokenError::Unknown,
557+
))
547558
);
548-
assert_eq!(
559+
assert_matches!(
549560
validate_rp_id(&String::from("user:pass@example.com")),
550-
Err(crate::Error::Unknown)
561+
Err(crate::errors::AuthenticatorError::U2FToken(
562+
crate::errors::U2FTokenError::Unknown,
563+
))
551564
);
552-
assert_eq!(
565+
assert_matches!(
553566
validate_rp_id(&String::from("com")),
554-
Err(crate::Error::Unknown)
567+
Err(crate::errors::AuthenticatorError::U2FToken(
568+
crate::errors::U2FTokenError::Unknown,
569+
))
555570
);
556-
assert_eq!(validate_rp_id(&String::from("example.com")), Ok(()));
571+
assert_matches!(validate_rp_id(&String::from("example.com")), Ok(()));
557572
}
558573

559574
fn mk_state_with_token_list(ids: &[u64]) -> Arc<Mutex<VirtualManagerState>> {

0 commit comments

Comments
 (0)