Skip to content

Commit

Permalink
remove the use of private_cookie in the tests
Browse files Browse the repository at this point in the history
  • Loading branch information
szabgab committed Sep 25, 2024
1 parent c805df6 commit 901525f
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 31 deletions.
31 changes: 7 additions & 24 deletions src/test_lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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",),
};
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/test_resend_email_verification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
3 changes: 1 addition & 2 deletions src/test_reset_password.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 6 additions & 4 deletions src/test_users.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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
Expand All @@ -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();
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 901525f

Please sign in to comment.