style: format backend

This commit is contained in:
2026-01-03 18:43:02 +01:00
parent e16e214b74
commit 4929266a8e
2 changed files with 8 additions and 26 deletions

View File

@@ -240,7 +240,7 @@ mod tests {
}; };
// WHEN: The application is converted to a runnable application // 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(); let _runnable_app = app.make_app();
// THEN: The middleware chain should use CORS settings from configuration // THEN: The middleware chain should use CORS settings from configuration

View File

@@ -18,13 +18,11 @@ fn get_test_app_with_cors(
allow_credentials: bool, allow_credentials: bool,
max_age_secs: i32, max_age_secs: i32,
) -> poem::middleware::AddDataEndpoint< ) -> poem::middleware::AddDataEndpoint<
poem::middleware::CorsEndpoint< poem::middleware::CorsEndpoint<sta::middleware::rate_limit::RateLimitEndpoint<poem::Route>>,
sta::middleware::rate_limit::RateLimitEndpoint<poem::Route>,
>,
Settings, Settings,
> { > {
let tcp_listener = std::net::TcpListener::bind("127.0.0.1:0") let tcp_listener =
.expect("Failed to bind a random 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 port = tcp_listener.local_addr().unwrap().port();
let listener = poem::listener::TcpListener::bind(format!("127.0.0.1:{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] #[tokio::test]
async fn preflight_request_returns_cors_headers() { async fn preflight_request_returns_cors_headers() {
// GIVEN: An app with CORS configured for specific origin // GIVEN: An app with CORS configured for specific origin
let app = get_test_app_with_cors( let app = get_test_app_with_cors(vec!["http://localhost:5173".to_string()], false, 3600);
vec!["http://localhost:5173".to_string()],
false,
3600,
);
let client = TestClient::new(app); let client = TestClient::new(app);
// WHEN: A preflight OPTIONS request is sent with Origin header // WHEN: A preflight OPTIONS request is sent with Origin header
@@ -88,11 +82,7 @@ async fn preflight_request_returns_cors_headers() {
#[tokio::test] #[tokio::test]
async fn get_request_with_origin_returns_allow_origin_header() { async fn get_request_with_origin_returns_allow_origin_header() {
// GIVEN: An app with CORS configured for specific origin // GIVEN: An app with CORS configured for specific origin
let app = get_test_app_with_cors( let app = get_test_app_with_cors(vec!["http://localhost:5173".to_string()], false, 3600);
vec!["http://localhost:5173".to_string()],
false,
3600,
);
let client = TestClient::new(app); let client = TestClient::new(app);
// WHEN: A GET request is sent with Origin header // WHEN: A GET request is sent with Origin header
@@ -227,11 +217,7 @@ async fn response_does_not_include_credentials_when_disabled() {
#[tokio::test] #[tokio::test]
async fn preflight_response_includes_correct_allowed_methods() { async fn preflight_response_includes_correct_allowed_methods() {
// GIVEN: An app with CORS configured // GIVEN: An app with CORS configured
let app = get_test_app_with_cors( let app = get_test_app_with_cors(vec!["http://localhost:5173".to_string()], false, 3600);
vec!["http://localhost:5173".to_string()],
false,
3600,
);
let client = TestClient::new(app); let client = TestClient::new(app);
// WHEN: A preflight OPTIONS request is sent // WHEN: A preflight OPTIONS request is sent
@@ -355,11 +341,7 @@ async fn multiple_origins_are_supported() {
#[tokio::test] #[tokio::test]
async fn unauthorized_origin_is_rejected() { async fn unauthorized_origin_is_rejected() {
// GIVEN: An app with CORS configured for specific origins only // GIVEN: An app with CORS configured for specific origins only
let app = get_test_app_with_cors( let app = get_test_app_with_cors(vec!["http://localhost:5173".to_string()], false, 3600);
vec!["http://localhost:5173".to_string()],
false,
3600,
);
let client = TestClient::new(app); let client = TestClient::new(app);
// WHEN: A request is sent with an unauthorized origin // WHEN: A request is sent with an unauthorized origin