|
1 | 1 | use actix_web::{ |
2 | 2 | cookie::Cookie, |
3 | | - dev::Service, |
4 | 3 | http::{header, StatusCode}, |
5 | 4 | test, |
6 | 5 | web::{self, Data}, |
@@ -287,7 +286,6 @@ async fn setup_oidc_test( |
287 | 286 | Error = actix_web::Error, |
288 | 287 | >, |
289 | 288 | FakeOidcProvider, |
290 | | - Data<sqlpage::AppState>, |
291 | 289 | ) { |
292 | 290 | use sqlpage::{ |
293 | 291 | app_config::{test_database_url, AppConfig}, |
@@ -319,14 +317,13 @@ async fn setup_oidc_test( |
319 | 317 |
|
320 | 318 | let config: AppConfig = serde_json::from_str(&config_json).unwrap(); |
321 | 319 | let app_state = AppState::init(&config).await.unwrap(); |
322 | | - let app_data = Data::new(app_state); |
323 | | - let app = test::init_service(create_app(app_data.clone())).await; |
324 | | - (app, provider, app_data) |
| 320 | + let app = test::init_service(create_app(Data::new(app_state))).await; |
| 321 | + (app, provider) |
325 | 322 | } |
326 | 323 |
|
327 | 324 | #[actix_web::test] |
328 | 325 | async fn test_oidc_happy_path() { |
329 | | - let (app, provider, _) = setup_oidc_test(|_| {}).await; |
| 326 | + let (app, provider) = setup_oidc_test(|_| {}).await; |
330 | 327 | let mut cookies: Vec<Cookie<'static>> = Vec::new(); |
331 | 328 |
|
332 | 329 | let resp = request_with_cookies!(app, test::TestRequest::get().uri("/"), cookies); |
@@ -355,7 +352,7 @@ async fn assert_oidc_login_fails( |
355 | 352 | provider_mutator: impl FnOnce(&mut ProviderState), |
356 | 353 | state_override: Option<String>, |
357 | 354 | ) { |
358 | | - let (app, provider, _) = setup_oidc_test(provider_mutator).await; |
| 355 | + let (app, provider) = setup_oidc_test(provider_mutator).await; |
359 | 356 | let mut cookies: Vec<Cookie<'static>> = Vec::new(); |
360 | 357 |
|
361 | 358 | let resp = request_with_cookies!(app, test::TestRequest::get().uri("/"), cookies); |
@@ -638,15 +635,12 @@ async fn test_slow_token_endpoint_does_not_freeze_server() { |
638 | 635 | test::call_service(&app, req.to_request()).await |
639 | 636 | }); |
640 | 637 |
|
641 | | - // Let the localhost TCP round-trip complete so awc reads response headers. |
| 638 | + // Let the TCP round-trip complete so awc reads HTTP headers, |
| 639 | + // then advance past the body-read timeout. |
642 | 640 | tokio::time::sleep(Duration::from_millis(50)).await; |
643 | | - |
644 | | - // Freeze time and advance past the body-read timeout. |
645 | 641 | tokio::time::pause(); |
646 | 642 | tokio::time::advance(Duration::from_secs(60)).await; |
647 | 643 |
|
648 | | - // The body timeout should have fired, completing the request with an error |
649 | | - // that SQLPage handles by redirecting to the OIDC provider. |
650 | 644 | let resp = tokio::time::timeout(Duration::from_secs(1), handle) |
651 | 645 | .await |
652 | 646 | .expect("OIDC callback hung on a slow token endpoint") |
|
0 commit comments