From 5800f7d7e688043ba4eaa99118a37369abcc64eb Mon Sep 17 00:00:00 2001 From: Frederic Henrichs Date: Wed, 18 Dec 2024 10:19:09 +0100 Subject: [PATCH] backen: fix tests. --- backend/src/rate_limit.rs | 1 + backend/src/routes/auth/get_login_salt.rs | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/backend/src/rate_limit.rs b/backend/src/rate_limit.rs index dbaa16d..238c61a 100644 --- a/backend/src/rate_limit.rs +++ b/backend/src/rate_limit.rs @@ -102,6 +102,7 @@ impl LoginRateLimiter { let ip = if let Some(ip) = req.connection_info().realip_remote_addr() { ip.to_string() } else { + println!("No ip found for route {}", req.path()); return Err(crate::error::Error::InternalError.into()); }; diff --git a/backend/src/routes/auth/get_login_salt.rs b/backend/src/routes/auth/get_login_salt.rs index ab0618c..5fda4a4 100644 --- a/backend/src/routes/auth/get_login_salt.rs +++ b/backend/src/routes/auth/get_login_salt.rs @@ -83,6 +83,7 @@ pub mod tests { let req = TestRequest::get() .uri(&format!("/get_login_salt?email={}", mail)) + .append_header(("X-Forwarded-For", "123.123.123.2")) .to_request(); let resp = test::call_and_read_body_json(&app, req).await; @@ -101,6 +102,7 @@ pub mod tests { let req = test::TestRequest::get() .uri(&format!("/get_login_salt?email={}", mail)) + .append_header(("X-Forwarded-For", "123.123.123.2")) .to_request(); let resp = test::call_service(&app, req).await; println!("{}", resp.status()); @@ -128,6 +130,7 @@ pub mod tests { let req = test::TestRequest::get() .uri(&format!("/get_login_salt?email={}", mail)) + .append_header(("X-Forwarded-For", "123.123.123.2")) .to_request(); let resp = test::call_service(&app, req).await; assert!(resp.status().is_success()); @@ -137,6 +140,7 @@ pub mod tests { let req = test::TestRequest::get() .uri(&format!("/get_login_salt?email={}", mail)) + .append_header(("X-Forwarded-For", "123.123.123.2")) .to_request(); let resp = test::call_service(&app, req).await; assert!(resp.status().is_success()); @@ -146,6 +150,7 @@ pub mod tests { let mail = format!("{}@example.invalid", uuid::Uuid::new_v4().to_string()); let req = test::TestRequest::get() .uri(&format!("/get_login_salt?email={}", mail)) + .append_header(("X-Forwarded-For", "123.123.123.2")) .to_request(); let resp = test::call_service(&app, req).await; assert!(resp.status().is_success());