diff options
author | Ty <ty@blahaj.land> | 2024-01-26 21:29:39 -0700 |
---|---|---|
committer | Ty <ty@blahaj.land> | 2024-01-26 21:29:39 -0700 |
commit | 5e872c6092a0986aee0c1d0e842a2b579b334e18 (patch) | |
tree | 405da401d90d87093fca060577673c5253d8a826 | |
parent | 214f2491cef6c90469eee3da757bc2c91de2d355 (diff) |
Add a test for password change
-rw-r--r-- | atuin/tests/sync.rs | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/atuin/tests/sync.rs b/atuin/tests/sync.rs index 8c42b171..ac85be12 100644 --- a/atuin/tests/sync.rs +++ b/atuin/tests/sync.rs @@ -127,6 +127,42 @@ async fn registration() { } #[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()); let (address, shutdown, server) = start_server(&path).await; |