From ff823a10f049e06c711537560ba10f3dc826afcd Mon Sep 17 00:00:00 2001 From: Quentin Dufour Date: Thu, 23 May 2024 10:01:43 +0200 Subject: improve ical date parsing --- aerogramme/tests/behavior.rs | 57 +++++++++++++++++++++++++++++++------------- 1 file changed, 41 insertions(+), 16 deletions(-) (limited to 'aerogramme') diff --git a/aerogramme/tests/behavior.rs b/aerogramme/tests/behavior.rs index a83f1a7..b6c1c6e 100644 --- a/aerogramme/tests/behavior.rs +++ b/aerogramme/tests/behavior.rs @@ -592,9 +592,9 @@ fn rfc4791_webdav_caldav() { assert_eq!(resp.status(), 201); // A generic function to check a query result - let check_full_cal = + let check_cal = |multistatus: &dav::Multistatus, - (ref_path, ref_etag, ref_ical): (&str, &str, &[u8])| { + (ref_path, ref_etag, ref_ical): (&str, Option<&str>, Option<&[u8]>)| { let obj_stats = multistatus .responses .iter() @@ -616,11 +616,10 @@ fn rfc4791_webdav_caldav() { .0 .iter() .find_map(|p| match p { - dav::AnyProperty::Value(dav::Property::GetEtag(x)) => Some(x), + dav::AnyProperty::Value(dav::Property::GetEtag(x)) => Some(x.as_str()), _ => None, - }) - .expect("etag is return in propstats"); - assert_eq!(etag.as_str(), ref_etag); + }); + assert_eq!(etag, ref_etag); let calendar_data = obj_success .prop .0 @@ -628,11 +627,10 @@ fn rfc4791_webdav_caldav() { .find_map(|p| match p { dav::AnyProperty::Value(dav::Property::Extension( realization::Property::Cal(cal::Property::CalendarData(x)), - )) => Some(x), + )) => Some(x.payload.as_bytes()), _ => None, - }) - .expect("calendar data is returned in propstats"); - assert_eq!(calendar_data.payload.as_bytes(), ref_ical); + }); + assert_eq!(calendar_data, ref_ical); }; // --- AUTODISCOVERY --- @@ -720,16 +718,43 @@ fn rfc4791_webdav_caldav() { ] .iter() .for_each(|(ref_path, ref_etag, ref_ical)| { - check_full_cal( + check_cal( &multistatus, ( ref_path, - ref_etag.to_str().expect("etag header convertible to str"), - ref_ical, + Some(ref_etag.to_str().expect("etag header convertible to str")), + Some(ref_ical), ), ) }); + // 8.2.1.2. Synchronize by Time Range (here: July 2006) + let cal_query = r#" + + + + + + + + + + + + "#; + let resp = http + .request( + reqwest::Method::from_bytes(b"REPORT")?, + "http://localhost:8087/alice/calendar/Personal/", + ) + .body(cal_query) + .send()?; + assert_eq!(resp.status(), 207); + let multistatus = dav_deserialize::>(&resp.text()?); + assert_eq!(multistatus.responses.len(), 1); + check_cal(&multistatus, ("/alice/calendar/Personal/rfc2.ics", Some(obj2_etag.to_str().expect("etag header convertible to str")), None)); + + // --- REPORT calendar-multiget --- let cal_query = r#" @@ -756,12 +781,12 @@ fn rfc4791_webdav_caldav() { ] .iter() .for_each(|(ref_path, ref_etag, ref_ical)| { - check_full_cal( + check_cal( &multistatus, ( ref_path, - ref_etag.to_str().expect("etag header convertible to str"), - ref_ical, + Some(ref_etag.to_str().expect("etag header convertible to str")), + Some(ref_ical), ), ) }); -- cgit v1.2.3