From 901525f3fc6cb41b4f55bc50747c134ded86d50a Mon Sep 17 00:00:00 2001 From: Gabor Szabo Date: Wed, 25 Sep 2024 16:59:07 +0300 Subject: [PATCH] remove the use of private_cookie in the tests --- src/test_lib.rs | 31 ++++++--------------------- src/test_resend_email_verification.rs | 2 +- src/test_reset_password.rs | 3 +-- src/test_users.rs | 10 +++++---- 4 files changed, 15 insertions(+), 31 deletions(-) diff --git a/src/test_lib.rs b/src/test_lib.rs index 88881e0..634788a 100644 --- a/src/test_lib.rs +++ b/src/test_lib.rs @@ -196,25 +196,11 @@ impl TestRunner { } pub fn setup_event(&self, eid: usize) { + self.login_owner(); match eid { - 1 => &self.add_event_helper( - "First event", - "2030-01-01 10:10", - "1", - String::from(OWNER_EMAIL), - ), - 2 => &self.add_event_helper( - "Second event", - "2030-01-02 10:10", - "1", - String::from(OWNER_EMAIL), - ), - 3 => &self.add_event_helper( - "Third event", - "2030-01-03 10:10", - "2", - String::from(OWNER_EMAIL), - ), + 1 => &self.add_event_helper("First event", "2030-01-01 10:10", "1"), + 2 => &self.add_event_helper("Second event", "2030-01-02 10:10", "1"), + 3 => &self.add_event_helper("Third event", "2030-01-03 10:10", "2"), _ => panic!("no such eid",), }; @@ -250,7 +236,7 @@ impl TestRunner { self.verify_email(); } - pub fn add_event_helper(&self, title: &str, date: &str, gid: &str, owner_email: String) { + pub fn add_event_helper(&self, title: &str, date: &str, gid: &str) { self.login_owner(); let res = self .client @@ -387,11 +373,8 @@ macro_rules! check_profile_by_guest { pub(crate) use check_profile_by_guest; macro_rules! check_profile_by_user { - ($client: expr, $email: expr, $h1: expr) => {{ - let res = $client - .get("/profile") - .private_cookie(("meet-os", $email.to_owned())) - .dispatch(); + ($client: expr, $h1: expr) => {{ + let res = $client.get("/profile").dispatch(); assert_eq!(res.status(), Status::Ok); let html = res.into_string().unwrap(); diff --git a/src/test_resend_email_verification.rs b/src/test_resend_email_verification.rs index 7121462..a7dec68 100644 --- a/src/test_resend_email_verification.rs +++ b/src/test_resend_email_verification.rs @@ -107,5 +107,5 @@ fn post_resend_email_verification_unverified_email() { ); check_user_menu!(&html); - check_profile_by_user!(&tr.client, UNVERIFIED_EMAIL, UNVERIFIED_NAME); + check_profile_by_user!(&tr.client, UNVERIFIED_NAME); } diff --git a/src/test_reset_password.rs b/src/test_reset_password.rs index 7f73af7..18ada0c 100644 --- a/src/test_reset_password.rs +++ b/src/test_reset_password.rs @@ -133,10 +133,9 @@ fn reset_password_full() { assert_eq!(res.status(), Status::Ok); let html = res.into_string().unwrap(); - //assert_eq!(html, ""); check_html!(&html, "title", "Welcome back"); check_user_menu!(&html); - check_profile_by_user!(&tr.client, &OWNER_EMAIL, name); + check_profile_by_user!(&tr.client, name); // Try again with the same code // Try with id that does not exist diff --git a/src/test_users.rs b/src/test_users.rs index 8647adb..fd67468 100644 --- a/src/test_users.rs +++ b/src/test_users.rs @@ -102,7 +102,7 @@ fn register_user() { ); check_user_menu!(&html); - check_profile_by_user!(&tr.client, OWNER_EMAIL, OWNER_NAME); + check_profile_by_user!(&tr.client, OWNER_NAME); } #[test] @@ -184,7 +184,9 @@ fn post_login_regular_user() { tr.register_and_verify_user(OWNER_NAME, OWNER_EMAIL, OWNER_PW); tr.logout(); - check_profile_by_user!(&tr.client, &OWNER_EMAIL, OWNER_NAME); + tr.login_owner(); + + check_profile_by_user!(&tr.client, OWNER_NAME); let res = tr .client @@ -198,7 +200,7 @@ fn post_login_regular_user() { check_html!(&html, "title", "Welcome back"); check_user_menu!(&html); - check_profile_by_user!(&tr.client, &OWNER_EMAIL, OWNER_NAME); + check_profile_by_user!(&tr.client, OWNER_NAME); // logout let res = tr.client.get("/logout").dispatch(); @@ -235,7 +237,7 @@ fn post_login_admin() { check_html!(&html, "title", "Welcome back"); check_admin_menu!(&html); - check_profile_by_user!(&tr.client, &ADMIN_EMAIL, ADMIN_NAME); + check_profile_by_user!(&tr.client, ADMIN_NAME); // logout let res = tr.client.get("/logout").dispatch();