Skip to content

Commit

Permalink
provide bad credential coverage (#203)
Browse files Browse the repository at this point in the history
  • Loading branch information
maxcountryman committed Mar 21, 2024
1 parent 89c64bc commit e959752
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions axum-login/src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,33 @@ mod tests {
assert!(result.unwrap().is_some());
}

#[tokio::test]
async fn test_authenticate_bad_credentials() {
let mut mock_backend = MockBackend::default();
let bad_creds = MockCredentials;

mock_backend
.expect_authenticate()
.with(eq(bad_creds.clone()))
.times(1)
.returning(|_| Ok(None));

let store = Arc::new(MemoryStore::default());

let session = Session::new(None, store, None);
let auth_session = AuthSession {
user: None,
backend: mock_backend,
data: Data::default(),
session,
data_key: "auth_data",
};

let result = auth_session.authenticate(bad_creds).await;
assert!(result.is_ok());
assert!(result.unwrap().is_none());
}

#[tokio::test]
async fn test_login() {
let mock_backend = MockBackend::default();
Expand Down

0 comments on commit e959752

Please sign in to comment.