aboutsummaryrefslogtreecommitdiff
path: root/aero-dav/src
diff options
context:
space:
mode:
authorQuentin Dufour <quentin@deuxfleurs.fr>2024-03-08 11:42:44 +0100
committerQuentin Dufour <quentin@deuxfleurs.fr>2024-03-08 11:42:44 +0100
commitb786573e08c78b672880cd212db45fc58ab82c4c (patch)
tree0a53a458d343a6f5d12bf521ac58c03194573da2 /aero-dav/src
parent4d65366ff368cc9ea35115cb7e701bfebb166bc6 (diff)
downloadaerogramme-b786573e08c78b672880cd212db45fc58ab82c4c.tar.gz
aerogramme-b786573e08c78b672880cd212db45fc58ab82c4c.zip
Fixed 2 more bugs
Diffstat (limited to 'aero-dav/src')
-rw-r--r--aero-dav/src/decoder.rs6
-rw-r--r--aero-dav/src/encoder.rs89
2 files changed, 49 insertions, 46 deletions
diff --git a/aero-dav/src/decoder.rs b/aero-dav/src/decoder.rs
index 28442a6..766d19c 100644
--- a/aero-dav/src/decoder.rs
+++ b/aero-dav/src/decoder.rs
@@ -473,7 +473,7 @@ impl QRead<Owner> for Owner {
impl QRead<Timeout> for Timeout {
async fn qread(xml: &mut Reader<impl IRead>) -> Result<Self, ParsingError> {
- const SEC_PFX: &str = "SEC_PFX";
+ const SEC_PFX: &str = "Second-";
xml.open(DAV_URN, "timeout").await?;
let timeout = match xml.tag_string().await?.as_str() {
@@ -492,7 +492,7 @@ impl QRead<Timeout> for Timeout {
impl QRead<LockToken> for LockToken {
async fn qread(xml: &mut Reader<impl IRead>) -> Result<Self, ParsingError> {
xml.open(DAV_URN, "locktoken").await?;
- let href = Href::qread(xml).await?;
+ let href = xml.find::<Href>().await?;
xml.close().await?;
Ok(LockToken(href))
}
@@ -501,7 +501,7 @@ impl QRead<LockToken> for LockToken {
impl QRead<LockRoot> for LockRoot {
async fn qread(xml: &mut Reader<impl IRead>) -> Result<Self, ParsingError> {
xml.open(DAV_URN, "lockroot").await?;
- let href = Href::qread(xml).await?;
+ let href = xml.find::<Href>().await?;
xml.close().await?;
Ok(LockRoot(href))
}
diff --git a/aero-dav/src/encoder.rs b/aero-dav/src/encoder.rs
index 813efe6..3b0bfda 100644
--- a/aero-dav/src/encoder.rs
+++ b/aero-dav/src/encoder.rs
@@ -996,16 +996,15 @@ mod tests {
#[tokio::test]
async fn rfc_propertyupdate() {
- let got = serialize(
- &PropertyUpdate::<Core>(vec![
- PropertyUpdateItem::Set(Set(PropValue(vec![
- Property::GetContentLanguage("fr-FR".into()),
- ]))),
- PropertyUpdateItem::Remove(Remove(PropName(vec![
- PropertyRequest::DisplayName,
- ]))),
- ]),
- ).await;
+ let orig = PropertyUpdate::<Core>(vec![
+ PropertyUpdateItem::Set(Set(PropValue(vec![
+ Property::GetContentLanguage("fr-FR".into()),
+ ]))),
+ PropertyUpdateItem::Remove(Remove(PropName(vec![
+ PropertyRequest::DisplayName,
+ ]))),
+ ]);
+ let got = serialize(&orig).await;
let expected = r#"<D:propertyupdate xmlns:D="DAV:">
<D:set>
@@ -1021,24 +1020,25 @@ mod tests {
</D:propertyupdate>"#;
assert_eq!(&got, expected, "\n---GOT---\n{got}\n---EXP---\n{expected}\n");
+ assert_eq!(deserialize::<PropertyUpdate::<Core>>(got.as_str()).await, orig)
}
#[tokio::test]
async fn rfc_delete_locked2() {
- let got = serialize(
- &Multistatus::<Core, PropValue<Core>> {
- responses: vec![Response {
- status_or_propstat: StatusOrPropstat::Status(
- vec![Href("http://www.example.com/container/resource3".into())],
- Status(http::status::StatusCode::from_u16(423).unwrap())
- ),
- error: Some(Error(vec![Violation::LockTokenSubmitted(vec![])])),
- responsedescription: None,
- location: None,
- }],
+ let orig = Multistatus::<Core, PropValue<Core>> {
+ responses: vec![Response {
+ status_or_propstat: StatusOrPropstat::Status(
+ vec![Href("http://www.example.com/container/resource3".into())],
+ Status(http::status::StatusCode::from_u16(423).unwrap())
+ ),
+ error: Some(Error(vec![Violation::LockTokenSubmitted(vec![])])),
responsedescription: None,
- },
- ).await;
+ location: None,
+ }],
+ responsedescription: None,
+ };
+
+ let got = serialize(&orig).await;
let expected = r#"<D:multistatus xmlns:D="DAV:">
<D:response>
@@ -1051,17 +1051,18 @@ mod tests {
</D:multistatus>"#;
assert_eq!(&got, expected, "\n---GOT---\n{got}\n---EXP---\n{expected}\n");
+ assert_eq!(deserialize::<Multistatus::<Core, PropValue<Core>>>(got.as_str()).await, orig)
}
#[tokio::test]
async fn rfc_simple_lock_request() {
- let got = serialize(
- &LockInfo {
- lockscope: LockScope::Exclusive,
- locktype: LockType::Write,
- owner: Some(Owner::Href(Href("http://example.org/~ejw/contact.html".into()))),
- },
- ).await;
+ let orig = LockInfo {
+ lockscope: LockScope::Exclusive,
+ locktype: LockType::Write,
+ owner: Some(Owner::Href(Href("http://example.org/~ejw/contact.html".into()))),
+ };
+
+ let got = serialize(&orig).await;
let expected = r#"<D:lockinfo xmlns:D="DAV:">
<D:lockscope>
@@ -1076,23 +1077,24 @@ mod tests {
</D:lockinfo>"#;
assert_eq!(&got, expected, "\n---GOT---\n{got}\n---EXP---\n{expected}\n");
+ assert_eq!(deserialize::<LockInfo>(got.as_str()).await, orig)
}
#[tokio::test]
async fn rfc_simple_lock_response() {
- let got = serialize(
- &PropValue::<Core>(vec![
- Property::LockDiscovery(vec![ActiveLock {
- lockscope: LockScope::Exclusive,
- locktype: LockType::Write,
- depth: Depth::Infinity,
- owner: Some(Owner::Href(Href("http://example.org/~ejw/contact.html".into()))),
- timeout: Some(Timeout::Seconds(604800)),
- locktoken: Some(LockToken(Href("urn:uuid:e71d4fae-5dec-22d6-fea5-00a0c91e6be4".into()))),
- lockroot: LockRoot(Href("http://example.com/workspace/webdav/proposal.doc".into())),
- }]),
- ]),
- ).await;
+ let orig = PropValue::<Core>(vec![
+ Property::LockDiscovery(vec![ActiveLock {
+ lockscope: LockScope::Exclusive,
+ locktype: LockType::Write,
+ depth: Depth::Infinity,
+ owner: Some(Owner::Href(Href("http://example.org/~ejw/contact.html".into()))),
+ timeout: Some(Timeout::Seconds(604800)),
+ locktoken: Some(LockToken(Href("urn:uuid:e71d4fae-5dec-22d6-fea5-00a0c91e6be4".into()))),
+ lockroot: LockRoot(Href("http://example.com/workspace/webdav/proposal.doc".into())),
+ }]),
+ ]);
+
+ let got = serialize(&orig).await;
let expected = r#"<D:prop xmlns:D="DAV:">
<D:lockdiscovery>
@@ -1119,5 +1121,6 @@ mod tests {
</D:prop>"#;
assert_eq!(&got, expected, "\n---GOT---\n{got}\n---EXP---\n{expected}\n");
+ assert_eq!(deserialize::<PropValue::<Core>>(got.as_str()).await, orig)
}
}