Skip to content

Commit

Permalink
Fix some assertions_on_constants and match_like_matches_macro lints
Browse files Browse the repository at this point in the history
  • Loading branch information
asomers authored and hannesdejager committed Mar 13, 2024
1 parent 8ce10f6 commit 02900d2
Showing 1 changed file with 18 additions and 21 deletions.
39 changes: 18 additions & 21 deletions crates/unftp-auth-jsonfile/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -500,21 +500,18 @@ mod test {
);
assert_eq!(json_authenticator.authenticate("carol", &"not so secure".into()).await.unwrap(), DefaultUser);
assert_eq!(json_authenticator.authenticate("dan", &"".into()).await.unwrap(), DefaultUser);
let mut is_err = match json_authenticator.authenticate("carol", &"this is the wrong password".into()).await {
Err(AuthenticationError::BadPassword) => true,
_ => false,
};
assert!(is_err);
is_err = match json_authenticator.authenticate("bella", &"this is the wrong password".into()).await {
Err(AuthenticationError::BadPassword) => true,
_ => false,
};
assert!(is_err);
is_err = match json_authenticator.authenticate("chuck", &"12345678".into()).await {
Err(AuthenticationError::BadUser) => true,
_ => false,
};
assert!(is_err);
assert!(matches!(
json_authenticator.authenticate("carol", &"this is the wrong password".into()).await,
Err(AuthenticationError::BadPassword)
));
assert!(matches!(
json_authenticator.authenticate("bella", &"this is the wrong password".into()).await,
Err(AuthenticationError::BadPassword)
));
assert!(matches!(
json_authenticator.authenticate("chuck", &"12345678".into()).await,
Err(AuthenticationError::BadUser)
));

assert_eq!(
json_authenticator
Expand Down Expand Up @@ -542,8 +539,8 @@ mod test {
)
.await
{
Err(AuthenticationError::IpDisallowed) => assert!(true),
_ => assert!(false),
Err(AuthenticationError::IpDisallowed) => (),
_ => panic!(),
}
}

Expand Down Expand Up @@ -702,8 +699,8 @@ mod test {
)
.await
{
Err(AuthenticationError::CnDisallowed) => assert!(true),
_ => assert!(false),
Err(AuthenticationError::CnDisallowed) => (),
_ => panic!(),
}

// correct certificate and no password needed according to json file authenticates successfully
Expand Down Expand Up @@ -734,8 +731,8 @@ mod test {
)
.await
{
Err(AuthenticationError::CnDisallowed) => assert!(true),
_ => assert!(false),
Err(AuthenticationError::CnDisallowed) => (),
_ => panic!(),
}

// any trusted certificate without password according to json file authenticates successfully
Expand Down

0 comments on commit 02900d2

Please sign in to comment.