aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorQuentin Dufour <quentin@deuxfleurs.fr>2024-03-07 14:25:08 +0100
committerQuentin Dufour <quentin@deuxfleurs.fr>2024-03-07 14:25:08 +0100
commite52ce4a61dc8bffabb8e4c5152c973d739e2b499 (patch)
tree14157fad3d181316c6997ce47eb5cd3f45b35ffa
parent2d14587d83f5c90158bc5b5193b07b49ed6946ee (diff)
downloadaerogramme-e52ce4a61dc8bffabb8e4c5152c973d739e2b499.tar.gz
aerogramme-e52ce4a61dc8bffabb8e4c5152c973d739e2b499.zip
Testing decoder against RFC
-rw-r--r--src/dav/decoder.rs71
1 files changed, 70 insertions, 1 deletions
diff --git a/src/dav/decoder.rs b/src/dav/decoder.rs
index fd11cf0..aa3c7e5 100644
--- a/src/dav/decoder.rs
+++ b/src/dav/decoder.rs
@@ -383,7 +383,7 @@ impl<E: Extension> QRead<Property<E>> for Property<E> {
} else if xml.maybe_open(DAV_URN, "getlastmodified").await?.is_some() {
let datestr = xml.tag_string().await?;
xml.close().await?;
- return Ok(Property::CreationDate(DateTime::parse_from_rfc2822(datestr.as_str())?))
+ return Ok(Property::GetLastModified(DateTime::parse_from_rfc2822(datestr.as_str())?))
} else if xml.maybe_open(DAV_URN, "lockdiscovery").await?.is_some() {
let acc = xml.collect::<ActiveLock>().await?;
xml.close().await?;
@@ -602,6 +602,7 @@ impl QRead<Href> for Href {
#[cfg(test)]
mod tests {
use super::*;
+ use chrono::{FixedOffset, DateTime, TimeZone, Utc};
use crate::dav::realization::Core;
#[tokio::test]
@@ -874,6 +875,74 @@ mod tests {
let mut rdr = Reader::new(NsReader::from_reader(src.as_bytes())).await.unwrap();
let got = rdr.find::<Multistatus::<Core, PropValue<Core>>>().await.unwrap();
+
+ assert_eq!(got, Multistatus {
+ responses: vec![
+ Response {
+ status_or_propstat: StatusOrPropstat::PropStat(
+ Href("/container/".into()),
+ vec![PropStat {
+ prop: PropValue(vec![
+ Property::CreationDate(FixedOffset::west_opt(8 * 3600).unwrap().with_ymd_and_hms(1997, 12, 01, 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 {
+ status_or_propstat: StatusOrPropstat::PropStat(
+ Href("/container/front.html".into()),
+ vec![PropStat {
+ prop: PropValue(vec![
+ Property::CreationDate(FixedOffset::west_opt(8 * 3600).unwrap().with_ymd_and_hms(1997, 12, 01, 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::west_opt(0).unwrap().with_ymd_and_hms(1998, 01, 12, 09, 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,
+ });
}
}