diff options
author | Quentin Dufour <quentin@deuxfleurs.fr> | 2024-03-04 09:29:03 +0100 |
---|---|---|
committer | Quentin Dufour <quentin@deuxfleurs.fr> | 2024-03-04 09:29:03 +0100 |
commit | 4d3d1c8c19f8819e4cf14a6062ef1c4cc91b8749 (patch) | |
tree | f99ae63a7170f02d793a378ea2ce22d8604e69f6 /src | |
parent | 352814aec9c44129c2fe917fa8dfa34adb3e8c78 (diff) | |
download | aerogramme-4d3d1c8c19f8819e4cf14a6062ef1c4cc91b8749.tar.gz aerogramme-4d3d1c8c19f8819e4cf14a6062ef1c4cc91b8749.zip |
Add new caldav test from RFC
Diffstat (limited to 'src')
-rw-r--r-- | src/dav/calencoder.rs | 76 |
1 files changed, 75 insertions, 1 deletions
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 { @@ -818,4 +818,78 @@ 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#"<D:multistatus xmlns:D="DAV:" xmlns:C="urn:ietf:params:xml:ns:caldav"> + <D:response> + <D:href>http://cal.example.com/bernard/work/abcd2.ics</D:href> + <D:propstat> + <D:prop> + <D:getetag>"fffff-abcd2"</D:getetag> + <C:calendar-data>PLACEHOLDER</C:calendar-data> + </D:prop> + <D:status>HTTP/1.1 200 OK</D:status> + </D:propstat> + </D:response> + <D:response> + <D:href>http://cal.example.com/bernard/work/abcd3.ics</D:href> + <D:propstat> + <D:prop> + <D:getetag>"fffff-abcd3"</D:getetag> + <C:calendar-data>PLACEHOLDER</C:calendar-data> + </D:prop> + <D:status>HTTP/1.1 200 OK</D:status> + </D:propstat> + </D:response> +</D:multistatus>"#; + + + assert_eq!(&got, expected, "\n---GOT---\n{got}\n---EXP---\n{expected}\n"); + } } |