From 4d3d1c8c19f8819e4cf14a6062ef1c4cc91b8749 Mon Sep 17 00:00:00 2001 From: Quentin Dufour Date: Mon, 4 Mar 2024 09:29:03 +0100 Subject: [PATCH] Add new caldav test from RFC --- src/dav/calencoder.rs | 76 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 75 insertions(+), 1 deletion(-) diff --git a/src/dav/calencoder.rs b/src/dav/calencoder.rs index 12a6939..db7ece4 100644 --- a/src/dav/calencoder.rs +++ b/src/dav/calencoder.rs @@ -714,7 +714,7 @@ mod tests { } #[tokio::test] - async fn rfc_calendar_query1() { + async fn rfc_calendar_query1_req() { let got = serialize( CalExtension { root: true }, &CalendarQuery { @@ -816,6 +816,80 @@ mod tests { "#; + assert_eq!(&got, expected, "\n---GOT---\n{got}\n---EXP---\n{expected}\n"); + } + + #[tokio::test] + async fn rfc_calendar_query1_res() { + let got = serialize( + CalExtension { root: true }, + &dav::Multistatus { + responses: vec![ + dav::Response { + href: dav::Href("http://cal.example.com/bernard/work/abcd2.ics".into()), + status_or_propstat: dav::StatusOrPropstat::PropStat(vec![dav::PropStat { + prop: dav::AnyProp::Value(dav::PropValue(vec![ + dav::Property::GetEtag("\"fffff-abcd2\"".into()), + dav::Property::Extension(Property::CalendarData(CalendarDataPayload { + mime: None, + payload: "PLACEHOLDER".into() + })), + ])), + status: dav::Status(http::status::StatusCode::OK), + error: None, + responsedescription: None, + }]), + location: None, + error: None, + responsedescription: None, + }, + dav::Response { + href: dav::Href("http://cal.example.com/bernard/work/abcd3.ics".into()), + status_or_propstat: dav::StatusOrPropstat::PropStat(vec![dav::PropStat { + prop: dav::AnyProp::Value(dav::PropValue(vec![ + dav::Property::GetEtag("\"fffff-abcd3\"".into()), + dav::Property::Extension(Property::CalendarData(CalendarDataPayload{ + mime: None, + payload: "PLACEHOLDER".into(), + })), + ])), + status: dav::Status(http::status::StatusCode::OK), + error: None, + responsedescription: None, + }]), + location: None, + error: None, + responsedescription: None, + }, + ], + responsedescription: None, + }, + ).await; + + let expected = r#" + + http://cal.example.com/bernard/work/abcd2.ics + + + "fffff-abcd2" + PLACEHOLDER + + HTTP/1.1 200 OK + + + + http://cal.example.com/bernard/work/abcd3.ics + + + "fffff-abcd3" + PLACEHOLDER + + HTTP/1.1 200 OK + + +"#; + + assert_eq!(&got, expected, "\n---GOT---\n{got}\n---EXP---\n{expected}\n"); } }