diff --git a/backend/src/startup.rs b/backend/src/startup.rs index 50b0abf..328b52c 100644 --- a/backend/src/startup.rs +++ b/backend/src/startup.rs @@ -240,7 +240,7 @@ mod tests { }; // WHEN: The application is converted to a runnable application - let app = Application::build(settings.clone(), None); + let app = Application::build(settings, None); let _runnable_app = app.make_app(); // THEN: The middleware chain should use CORS settings from configuration diff --git a/backend/tests/cors_test.rs b/backend/tests/cors_test.rs index 114d325..f2596c3 100644 --- a/backend/tests/cors_test.rs +++ b/backend/tests/cors_test.rs @@ -18,13 +18,11 @@ fn get_test_app_with_cors( allow_credentials: bool, max_age_secs: i32, ) -> poem::middleware::AddDataEndpoint< - poem::middleware::CorsEndpoint< - sta::middleware::rate_limit::RateLimitEndpoint, - >, + poem::middleware::CorsEndpoint>, Settings, > { - let tcp_listener = std::net::TcpListener::bind("127.0.0.1:0") - .expect("Failed to bind a random TCP listener"); + let tcp_listener = + std::net::TcpListener::bind("127.0.0.1:0").expect("Failed to bind a random TCP listener"); let port = tcp_listener.local_addr().unwrap().port(); let listener = poem::listener::TcpListener::bind(format!("127.0.0.1:{port}")); @@ -44,11 +42,7 @@ fn get_test_app_with_cors( #[tokio::test] async fn preflight_request_returns_cors_headers() { // GIVEN: An app with CORS configured for specific origin - let app = get_test_app_with_cors( - vec!["http://localhost:5173".to_string()], - false, - 3600, - ); + let app = get_test_app_with_cors(vec!["http://localhost:5173".to_string()], false, 3600); let client = TestClient::new(app); // WHEN: A preflight OPTIONS request is sent with Origin header @@ -88,11 +82,7 @@ async fn preflight_request_returns_cors_headers() { #[tokio::test] async fn get_request_with_origin_returns_allow_origin_header() { // GIVEN: An app with CORS configured for specific origin - let app = get_test_app_with_cors( - vec!["http://localhost:5173".to_string()], - false, - 3600, - ); + let app = get_test_app_with_cors(vec!["http://localhost:5173".to_string()], false, 3600); let client = TestClient::new(app); // WHEN: A GET request is sent with Origin header @@ -227,11 +217,7 @@ async fn response_does_not_include_credentials_when_disabled() { #[tokio::test] async fn preflight_response_includes_correct_allowed_methods() { // GIVEN: An app with CORS configured - let app = get_test_app_with_cors( - vec!["http://localhost:5173".to_string()], - false, - 3600, - ); + let app = get_test_app_with_cors(vec!["http://localhost:5173".to_string()], false, 3600); let client = TestClient::new(app); // WHEN: A preflight OPTIONS request is sent @@ -355,11 +341,7 @@ async fn multiple_origins_are_supported() { #[tokio::test] async fn unauthorized_origin_is_rejected() { // GIVEN: An app with CORS configured for specific origins only - let app = get_test_app_with_cors( - vec!["http://localhost:5173".to_string()], - false, - 3600, - ); + let app = get_test_app_with_cors(vec!["http://localhost:5173".to_string()], false, 3600); let client = TestClient::new(app); // WHEN: A request is sent with an unauthorized origin