diff --git a/src/integration_tests/caldav/calendar.rs b/src/integration_tests/caldav/calendar.rs index 0cc0b3d..a1df6b7 100644 --- a/src/integration_tests/caldav/calendar.rs +++ b/src/integration_tests/caldav/calendar.rs @@ -75,12 +75,31 @@ async fn test_caldav_calendar( .unwrap() }; + // Try OPTIONS without authentication + let request = Request::builder() + .method("OPTIONS") + .uri(&url) + .body(Body::empty()) + .unwrap(); + let response = app.clone().oneshot(request).await.unwrap(); + insta::assert_debug_snapshot!(response, @r#" + Response { + status: 200, + version: HTTP/1.1, + headers: { + "dav": "1, 3, access-control, calendar-access, webdav-push", + "allow": "PROPFIND, PROPPATCH, COPY, MOVE, DELETE, OPTIONS, REPORT, GET, HEAD, POST, MKCOL, MKCALENDAR, IMPORT", + }, + body: Body( + UnsyncBoxBody, + ), + } + "#); + // Try without authentication let request = request_template(); let response = app.clone().oneshot(request).await.unwrap(); assert_eq!(response.status(), StatusCode::UNAUTHORIZED); - let body = response.extract_string().await; - insta::assert_snapshot!(body); // Try with correct credentials let mut request = request_template(); @@ -90,7 +109,7 @@ async fn test_caldav_calendar( let response = app.clone().oneshot(request).await.unwrap(); assert_eq!(response.status(), StatusCode::CREATED); let body = response.extract_string().await; - insta::assert_snapshot!(body); + insta::assert_snapshot!("mkcalendar_body", body); let mut request = Request::builder() .method("GET") @@ -103,7 +122,7 @@ async fn test_caldav_calendar( let response = app.clone().oneshot(request).await.unwrap(); assert_eq!(response.status(), StatusCode::OK); let body = response.extract_string().await; - insta::assert_snapshot!(body); + insta::assert_snapshot!("get_body", body); assert_eq!( cal_store @@ -130,7 +149,7 @@ async fn test_caldav_calendar( (r"[0-9a-f-]+", "[PUSH_TOPIC]") ] }, { - insta::assert_snapshot!(body); + insta::assert_snapshot!("propfind_body", body); }); let proppatch_request: &str = r#" @@ -159,7 +178,7 @@ async fn test_caldav_calendar( let response = app.clone().oneshot(request).await.unwrap(); assert_eq!(response.status(), StatusCode::MULTI_STATUS); let body = response.extract_string().await; - insta::assert_snapshot!(body); + insta::assert_snapshot!("proppatch_body", body); calendar_meta.displayname = Some("New Displayname".to_string()); calendar_meta.description = None; @@ -185,7 +204,7 @@ async fn test_caldav_calendar( let response = app.clone().oneshot(request).await.unwrap(); assert_eq!(response.status(), StatusCode::OK); let body = response.extract_string().await; - insta::assert_snapshot!(body); + insta::assert_snapshot!("delete_body", body); assert!(matches!( cal_store.get_calendar(principal, cal_id, false).await, diff --git a/src/integration_tests/caldav/mod.rs b/src/integration_tests/caldav/mod.rs index 87db81d..a34f104 100644 --- a/src/integration_tests/caldav/mod.rs +++ b/src/integration_tests/caldav/mod.rs @@ -29,8 +29,6 @@ async fn test_caldav_root( let request = request_template(); let response = app.clone().oneshot(request).await.unwrap(); assert_eq!(response.status(), StatusCode::UNAUTHORIZED); - let body = response.extract_string().await; - insta::assert_snapshot!(body); // Try with wrong password let mut request = request_template(); @@ -39,8 +37,6 @@ async fn test_caldav_root( .typed_insert(Authorization::basic("user", "wrongpass")); let response = app.clone().oneshot(request).await.unwrap(); assert_eq!(response.status(), StatusCode::UNAUTHORIZED); - let body = response.extract_string().await; - insta::assert_snapshot!(body); // Try with correct credentials let mut request = request_template(); @@ -51,7 +47,7 @@ async fn test_caldav_root( let response = app.oneshot(request).await.unwrap(); assert_eq!(response.status(), StatusCode::MULTI_STATUS); let body = response.extract_string().await; - insta::assert_snapshot!(body); + insta::assert_snapshot!("propfind_body", body); } #[rstest] @@ -75,8 +71,6 @@ async fn test_caldav_principal( let request = request_template(); let response = app.clone().oneshot(request).await.unwrap(); assert_eq!(response.status(), StatusCode::UNAUTHORIZED); - let body = response.extract_string().await; - insta::assert_snapshot!(body); // Try with wrong password let mut request = request_template(); @@ -85,8 +79,6 @@ async fn test_caldav_principal( .typed_insert(Authorization::basic("user", "wrongpass")); let response = app.clone().oneshot(request).await.unwrap(); assert_eq!(response.status(), StatusCode::UNAUTHORIZED); - let body = response.extract_string().await; - insta::assert_snapshot!(body); // Try with correct credentials let mut request = request_template(); @@ -96,7 +88,7 @@ async fn test_caldav_principal( let response = app.clone().oneshot(request).await.unwrap(); assert_eq!(response.status(), StatusCode::MULTI_STATUS); let body = response.extract_string().await; - insta::assert_snapshot!(body); + insta::assert_snapshot!("propfind_depth_0", body); // Try with Depth: 1 let mut request = request_template(); @@ -114,6 +106,6 @@ async fn test_caldav_principal( (r"[0-9a-f-]+", "[PUSH_TOPIC]") ] }, { - insta::assert_snapshot!(body); + insta::assert_snapshot!("propfind_depth_1", body); }); } diff --git a/src/integration_tests/caldav/snapshots/rustical__integration_tests__caldav__caldav_principal-2.snap b/src/integration_tests/caldav/snapshots/rustical__integration_tests__caldav__caldav_principal-2.snap deleted file mode 100644 index 64c638c..0000000 --- a/src/integration_tests/caldav/snapshots/rustical__integration_tests__caldav__caldav_principal-2.snap +++ /dev/null @@ -1,5 +0,0 @@ ---- -source: src/integration_tests/caldav/mod.rs -expression: body ---- - diff --git a/src/integration_tests/caldav/snapshots/rustical__integration_tests__caldav__caldav_principal.snap b/src/integration_tests/caldav/snapshots/rustical__integration_tests__caldav__caldav_principal.snap deleted file mode 100644 index 64c638c..0000000 --- a/src/integration_tests/caldav/snapshots/rustical__integration_tests__caldav__caldav_principal.snap +++ /dev/null @@ -1,5 +0,0 @@ ---- -source: src/integration_tests/caldav/mod.rs -expression: body ---- - diff --git a/src/integration_tests/caldav/snapshots/rustical__integration_tests__caldav__caldav_root-2.snap b/src/integration_tests/caldav/snapshots/rustical__integration_tests__caldav__caldav_root-2.snap deleted file mode 100644 index 64c638c..0000000 --- a/src/integration_tests/caldav/snapshots/rustical__integration_tests__caldav__caldav_root-2.snap +++ /dev/null @@ -1,5 +0,0 @@ ---- -source: src/integration_tests/caldav/mod.rs -expression: body ---- - diff --git a/src/integration_tests/caldav/snapshots/rustical__integration_tests__caldav__caldav_root.snap b/src/integration_tests/caldav/snapshots/rustical__integration_tests__caldav__caldav_root.snap deleted file mode 100644 index 64c638c..0000000 --- a/src/integration_tests/caldav/snapshots/rustical__integration_tests__caldav__caldav_root.snap +++ /dev/null @@ -1,5 +0,0 @@ ---- -source: src/integration_tests/caldav/mod.rs -expression: body ---- - diff --git a/src/integration_tests/caldav/snapshots/rustical__integration_tests__caldav__calendar__caldav_calendar.snap b/src/integration_tests/caldav/snapshots/rustical__integration_tests__caldav__calendar__caldav_calendar.snap deleted file mode 100644 index ae58472..0000000 --- a/src/integration_tests/caldav/snapshots/rustical__integration_tests__caldav__calendar__caldav_calendar.snap +++ /dev/null @@ -1,5 +0,0 @@ ---- -source: src/integration_tests/caldav/calendar.rs -expression: body ---- - diff --git a/src/integration_tests/caldav/snapshots/rustical__integration_tests__caldav__calendar__caldav_calendar-2.snap b/src/integration_tests/caldav/snapshots/rustical__integration_tests__caldav__calendar__delete_body.snap similarity index 100% rename from src/integration_tests/caldav/snapshots/rustical__integration_tests__caldav__calendar__caldav_calendar-2.snap rename to src/integration_tests/caldav/snapshots/rustical__integration_tests__caldav__calendar__delete_body.snap diff --git a/src/integration_tests/caldav/snapshots/rustical__integration_tests__caldav__calendar__caldav_calendar-3.snap b/src/integration_tests/caldav/snapshots/rustical__integration_tests__caldav__calendar__get_body.snap similarity index 100% rename from src/integration_tests/caldav/snapshots/rustical__integration_tests__caldav__calendar__caldav_calendar-3.snap rename to src/integration_tests/caldav/snapshots/rustical__integration_tests__caldav__calendar__get_body.snap diff --git a/src/integration_tests/caldav/snapshots/rustical__integration_tests__caldav__calendar__caldav_calendar-6.snap b/src/integration_tests/caldav/snapshots/rustical__integration_tests__caldav__calendar__mkcalendar_body.snap similarity index 100% rename from src/integration_tests/caldav/snapshots/rustical__integration_tests__caldav__calendar__caldav_calendar-6.snap rename to src/integration_tests/caldav/snapshots/rustical__integration_tests__caldav__calendar__mkcalendar_body.snap diff --git a/src/integration_tests/caldav/snapshots/rustical__integration_tests__caldav__calendar__caldav_calendar-4.snap b/src/integration_tests/caldav/snapshots/rustical__integration_tests__caldav__calendar__propfind_body.snap similarity index 100% rename from src/integration_tests/caldav/snapshots/rustical__integration_tests__caldav__calendar__caldav_calendar-4.snap rename to src/integration_tests/caldav/snapshots/rustical__integration_tests__caldav__calendar__propfind_body.snap diff --git a/src/integration_tests/caldav/snapshots/rustical__integration_tests__caldav__calendar__caldav_calendar-5.snap b/src/integration_tests/caldav/snapshots/rustical__integration_tests__caldav__calendar__proppatch_body.snap similarity index 100% rename from src/integration_tests/caldav/snapshots/rustical__integration_tests__caldav__calendar__caldav_calendar-5.snap rename to src/integration_tests/caldav/snapshots/rustical__integration_tests__caldav__calendar__proppatch_body.snap diff --git a/src/integration_tests/caldav/snapshots/rustical__integration_tests__caldav__caldav_root-3.snap b/src/integration_tests/caldav/snapshots/rustical__integration_tests__caldav__propfind_body.snap similarity index 100% rename from src/integration_tests/caldav/snapshots/rustical__integration_tests__caldav__caldav_root-3.snap rename to src/integration_tests/caldav/snapshots/rustical__integration_tests__caldav__propfind_body.snap diff --git a/src/integration_tests/caldav/snapshots/rustical__integration_tests__caldav__caldav_principal-3.snap b/src/integration_tests/caldav/snapshots/rustical__integration_tests__caldav__propfind_depth_0.snap similarity index 100% rename from src/integration_tests/caldav/snapshots/rustical__integration_tests__caldav__caldav_principal-3.snap rename to src/integration_tests/caldav/snapshots/rustical__integration_tests__caldav__propfind_depth_0.snap diff --git a/src/integration_tests/caldav/snapshots/rustical__integration_tests__caldav__caldav_principal-4.snap b/src/integration_tests/caldav/snapshots/rustical__integration_tests__caldav__propfind_depth_1.snap similarity index 100% rename from src/integration_tests/caldav/snapshots/rustical__integration_tests__caldav__caldav_principal-4.snap rename to src/integration_tests/caldav/snapshots/rustical__integration_tests__caldav__propfind_depth_1.snap