aboutsummaryrefslogtreecommitdiffstats
path: root/crates/rocie-server/tests/users
diff options
context:
space:
mode:
Diffstat (limited to 'crates/rocie-server/tests/users')
-rw-r--r--crates/rocie-server/tests/users/mod.rs53
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)
+ );
+}