diff --git a/src/dav/encoder.rs b/src/dav/encoder.rs index 6475da8..a16f498 100644 --- a/src/dav/encoder.rs +++ b/src/dav/encoder.rs @@ -325,7 +325,7 @@ impl QuickWritable for Property { let end = start.to_end(); xml.write_event_async(Event::Start(start.clone())).await?; - xml.write_event_async(Event::Text(BytesText::new(&date.to_rfc3339()))).await?; + xml.write_event_async(Event::Text(BytesText::new(&date.to_rfc2822()))).await?; xml.write_event_async(Event::End(end)).await?; }, LockDiscovery(many_locks) => { @@ -796,6 +796,167 @@ mod tests { "#; + assert_eq!(&got, expected, "\n---GOT---\n{got}\n---EXP---\n{expected}\n"); + } + + #[tokio::test] + async fn rfc_allprop_req() { + let got = serialize( + NoExtension { root: true }, + &PropFind::AllProp(None), + ).await; + + let expected = r#" + +"#; + + assert_eq!(&got, expected, "\n---GOT---\n{got}\n---EXP---\n{expected}\n"); + } + + #[tokio::test] + async fn rfc_allprop_res() { + use chrono::{DateTime,FixedOffset,TimeZone}; + let got = serialize( + NoExtension { root: true }, + &Multistatus { + responses: vec![ + Response { + href: Href("/container/".into()), + status_or_propstat: StatusOrPropstat::PropStat(vec![PropStat { + prop: Prop::Value(vec![ + Property::CreationDate(FixedOffset::west_opt(8 * 3600) + .unwrap() + .with_ymd_and_hms(1997, 12, 1, 17, 42, 21) + .unwrap()), + Property::DisplayName("Example collection".into()), + Property::ResourceType(vec![ResourceType::Collection]), + Property::SupportedLock(vec![ + LockEntry { + lockscope: LockScope::Exclusive, + locktype: LockType::Write, + }, + LockEntry { + lockscope: LockScope::Shared, + locktype: LockType::Write, + }, + ]), + ]), + status: Status(http::status::StatusCode::OK), + error: None, + responsedescription: None, + }]), + error: None, + responsedescription: None, + location: None, + }, + Response { + href: Href("/container/front.html".into()), + status_or_propstat: StatusOrPropstat::PropStat(vec![PropStat { + prop: Prop::Value(vec![ + Property::CreationDate(FixedOffset::west_opt(8 * 3600) + .unwrap() + .with_ymd_and_hms(1997, 12, 1, 18, 27, 21) + .unwrap()), + Property::DisplayName("Example HTML resource".into()), + Property::GetContentLength(4525), + Property::GetContentType("text/html".into()), + Property::GetEtag(r#""zzyzx""#.into()), + Property::GetLastModified(FixedOffset::east_opt(0) + .unwrap() + .with_ymd_and_hms(1998, 1, 12, 9, 25, 56) + .unwrap()), + Property::ResourceType(vec![]), + Property::SupportedLock(vec![ + LockEntry { + lockscope: LockScope::Exclusive, + locktype: LockType::Write, + }, + LockEntry { + lockscope: LockScope::Shared, + locktype: LockType::Write, + }, + ]), + ]), + status: Status(http::status::StatusCode::OK), + error: None, + responsedescription: None, + }]), + error: None, + responsedescription: None, + location: None, + }, + ], + responsedescription: None, + } + ).await; + + let expected = r#" + + /container/ + + + 1997-12-01T17:42:21-08:00 + Example collection + + + + + + + + + + + + + + + + + + + + + + + HTTP/1.1 200 OK + + + + /container/front.html + + + 1997-12-01T18:27:21-08:00 + Example HTML resource + 4525 + text/html + "zzyzx" + Mon, 12 Jan 1998 09:25:56 +0000 + + + + + + + + + + + + + + + + + + + + + HTTP/1.1 200 OK + + +"#; + assert_eq!(&got, expected, "\n---GOT---\n{got}\n---EXP---\n{expected}\n"); } }