use shared_entity::error_code::ErrorCode; use crate::client::utils::{ generate_unique_email, REGISTERED_EMAIL, REGISTERED_PASSWORD, REGISTERED_USER_MUTEX, }; use crate::client_api_client; #[tokio::test] async fn update_but_not_logged_in() { let mut c = client_api_client(); let new_email = generate_unique_email(); let new_password = "Hello123!"; let res = c.update(&new_email, new_password).await; assert!(res.is_err()); } #[tokio::test] async fn update_password_same_password() { let _guard = REGISTERED_USER_MUTEX.lock().await; let mut c = client_api_client(); c.sign_in_password(®ISTERED_EMAIL, ®ISTERED_PASSWORD) .await .unwrap(); let err = c .update(®ISTERED_EMAIL, ®ISTERED_PASSWORD) .await .err() .unwrap(); assert_eq!(err.code, ErrorCode::InvalidPassword); assert_eq!( err.message, "New password should be different from the old password." ); } #[tokio::test] async fn update_password_and_revert() { let _guard = REGISTERED_USER_MUTEX.lock().await; let new_password = "Hello456!"; { // change password to new_password let mut c = client_api_client(); c.sign_in_password(®ISTERED_EMAIL, ®ISTERED_PASSWORD) .await .unwrap(); c.update(®ISTERED_EMAIL, new_password).await.unwrap(); } { // revert password to old_password let mut c = client_api_client(); c.sign_in_password(®ISTERED_EMAIL, new_password) .await .unwrap(); c.update(®ISTERED_EMAIL, ®ISTERED_PASSWORD) .await .unwrap(); } }