Fix some logic on locked
This commit is contained in:
parent
4490afb1bf
commit
9200b44941
1 changed files with 35 additions and 0 deletions
|
@ -647,6 +647,9 @@ impl<C: Context> QuickWritable<C> for Violation<C> {
|
||||||
async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: C) -> Result<(), QError> {
|
async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: C) -> Result<(), QError> {
|
||||||
match self {
|
match self {
|
||||||
Violation::LockTokenMatchesRequestUri => xml.write_event_async(Event::Empty(ctx.create_dav_element("lock-token-matches-request-uri"))).await?,
|
Violation::LockTokenMatchesRequestUri => xml.write_event_async(Event::Empty(ctx.create_dav_element("lock-token-matches-request-uri"))).await?,
|
||||||
|
Violation::LockTokenSubmitted(hrefs) if hrefs.is_empty() => {
|
||||||
|
xml.write_event_async(Event::Empty(ctx.create_dav_element("lock-token-submitted"))).await?
|
||||||
|
},
|
||||||
Violation::LockTokenSubmitted(hrefs) => {
|
Violation::LockTokenSubmitted(hrefs) => {
|
||||||
let start = ctx.create_dav_element("lock-token-submitted");
|
let start = ctx.create_dav_element("lock-token-submitted");
|
||||||
let end = start.to_end();
|
let end = start.to_end();
|
||||||
|
@ -657,6 +660,9 @@ impl<C: Context> QuickWritable<C> for Violation<C> {
|
||||||
}
|
}
|
||||||
xml.write_event_async(Event::End(end)).await?;
|
xml.write_event_async(Event::End(end)).await?;
|
||||||
},
|
},
|
||||||
|
Violation::NoConflictingLock(hrefs) if hrefs.is_empty() => {
|
||||||
|
xml.write_event_async(Event::Empty(ctx.create_dav_element("no-conflicting-lock"))).await?
|
||||||
|
},
|
||||||
Violation::NoConflictingLock(hrefs) => {
|
Violation::NoConflictingLock(hrefs) => {
|
||||||
let start = ctx.create_dav_element("no-conflicting-lock");
|
let start = ctx.create_dav_element("no-conflicting-lock");
|
||||||
let end = start.to_end();
|
let end = start.to_end();
|
||||||
|
@ -1059,4 +1065,33 @@ mod tests {
|
||||||
|
|
||||||
assert_eq!(&got, expected, "\n---GOT---\n{got}\n---EXP---\n{expected}\n");
|
assert_eq!(&got, expected, "\n---GOT---\n{got}\n---EXP---\n{expected}\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn rfc_delete_locked2() {
|
||||||
|
let got = serialize(
|
||||||
|
NoExtension { root: true },
|
||||||
|
&Multistatus {
|
||||||
|
responses: vec![Response {
|
||||||
|
href: Href("http://www.example.com/container/resource3".into()),
|
||||||
|
status_or_propstat: StatusOrPropstat::Status(Status(http::status::StatusCode::from_u16(423).unwrap())),
|
||||||
|
error: Some(Error(vec![Violation::LockTokenSubmitted(vec![])])),
|
||||||
|
responsedescription: None,
|
||||||
|
location: None,
|
||||||
|
}],
|
||||||
|
responsedescription: None,
|
||||||
|
},
|
||||||
|
).await;
|
||||||
|
|
||||||
|
let expected = r#"<D:multistatus xmlns:D="DAV:">
|
||||||
|
<D:response>
|
||||||
|
<D:href>http://www.example.com/container/resource3</D:href>
|
||||||
|
<D:status>HTTP/1.1 423 Locked</D:status>
|
||||||
|
<D:error>
|
||||||
|
<D:lock-token-submitted/>
|
||||||
|
</D:error>
|
||||||
|
</D:response>
|
||||||
|
</D:multistatus>"#;
|
||||||
|
|
||||||
|
assert_eq!(&got, expected, "\n---GOT---\n{got}\n---EXP---\n{expected}\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue