Add a test for password change

This commit is contained in:
Ty 2024-01-26 21:29:39 -07:00
parent 214f2491ce
commit 5e872c6092
No known key found for this signature in database
GPG Key ID: 2813440C772555A4

View File

@ -126,6 +126,42 @@ async fn registration() {
server.await.unwrap();
}
#[tokio::test]
async fn change_password() {
let path = format!("/{}", uuid_v7().as_simple());
let (address, shutdown, server) = start_server(&path).await;
// -- REGISTRATION --
let username = uuid_v7().as_simple().to_string();
let password = uuid_v7().as_simple().to_string();
let client = register_inner(&address, &username, &password).await;
// the session token works
let status = client.status().await.unwrap();
assert_eq!(status.username, username);
// -- PASSWORD CHANGE --
let current_password = password;
let new_password = uuid_v7().as_simple().to_string();
let result = client.change_password(current_password, new_password.clone()).await;
// the password change request succeeded
assert!(result.is_ok());
// -- LOGIN --
let client = login(&address, username.clone(), new_password).await;
// login with new password yields a working token
let status = client.status().await.unwrap();
assert_eq!(status.username, username);
shutdown.send(()).unwrap();
server.await.unwrap();
}
#[tokio::test]
async fn sync() {
let path = format!("/{}", uuid_v7().as_simple());