diff options
| author | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2025-12-09 13:07:14 +0100 |
|---|---|---|
| committer | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2025-12-09 13:07:14 +0100 |
| commit | c91dce4f77ae12453203f0a28b91efb6533cc095 (patch) | |
| tree | 4f50e755dff7f717d45309b08f9fe2c8c87f88bd /crates/rocie-server/tests/users/mod.rs | |
| parent | chore(rocie-client): Regenerate (diff) | |
| download | server-c91dce4f77ae12453203f0a28b91efb6533cc095.zip | |
feat(rocie-server): Implement basic user handling and authentication
Diffstat (limited to '')
| -rw-r--r-- | crates/rocie-server/tests/users/mod.rs | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/crates/rocie-server/tests/users/mod.rs b/crates/rocie-server/tests/users/mod.rs new file mode 100644 index 0000000..eaa387f --- /dev/null +++ b/crates/rocie-server/tests/users/mod.rs @@ -0,0 +1,53 @@ +use rocie_client::{ + apis::{ + api_get_no_auth_user_api::user_by_id, + api_set_auth_user_api::register_user, + api_set_no_auth_user_api::{login, logout}, + }, + models::{LoginInfo, UserStub}, +}; + +use crate::testenv::{TestEnv, init::function_name, log::request}; + +#[tokio::test] +async fn test_register_user() { + let env = TestEnv::new_no_login(function_name!()); + + let user_id = request!( + env, + register_user(UserStub { + description: Some("Myself".to_string()), + name: "me".to_string(), + password: "hunter14".to_string() + }) + ); + + request!( + @expect_error "The password is wrong" + env, + login(LoginInfo { + id: user_id, + password: "hunter13".to_owned() + }) + ); + + request!( + env, + login(LoginInfo { + id: user_id, + password: "hunter14".to_owned() + }) + ); + + let user = request!(env, user_by_id(user_id)); + + assert_eq!(&user.name, "me"); + assert_eq!(user.description.as_deref(), Some("Myself")); + + request!(env, logout()); + request!( + @expect_error "We are not logged in anymore" + env, + user_by_id(user_id) + ); +} |
