Skip to content

Commit

Permalink
Test PROPFIND requests for unknown properties
Browse files Browse the repository at this point in the history
  • Loading branch information
jwodder committed Jan 30, 2025
1 parent 58bc845 commit 50ecf76
Showing 1 changed file with 117 additions and 1 deletion.
118 changes: 117 additions & 1 deletion src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ impl PropfindResponse {

fn assert_body(self, expected: &str) -> Self {
let body = std::str::from_utf8(self.0.body()).unwrap();
assert_eq!(body, expected);
pretty_assertions::assert_eq!(body, expected);
self
}
}
Expand Down Expand Up @@ -1695,3 +1695,119 @@ async fn propfind_prop() {
]
);
}

#[tokio::test]
async fn propfind_include_unknown_properties() {
let mut app = MockApp::new().await;
app.propfind("/dandisets/000001/draft/dandiset.yaml")
.body(indoc! {r#"
<?xml version="1.0" encoding="utf-8"?>
<propfind xmlns="DAV:">
<allprop />
<include>
<flavor xmlns="https://www.example.com/" />
<unknown-dav />
</include>
</propfind>
"#})
.send()
.await
.success()
.assert_body(indoc! {r#"
<?xml version="1.0" encoding="UTF-8"?>
<multistatus xmlns="DAV:">
<response>
<href>/dandisets/000001/draft/dandiset.yaml</href>
<propstat>
<prop>
<displayname>dandiset.yaml</displayname>
<getcontentlength>410</getcontentlength>
<getcontenttype>text/yaml; charset=utf-8</getcontenttype>
<resourcetype />
</prop>
<status>HTTP/1.1 200 OK</status>
</propstat>
<propstat>
<prop>
<flavor xmlns="https://www.example.com/" />
<unknown-dav />
</prop>
<status>HTTP/1.1 404 NOT FOUND</status>
</propstat>
</response>
</multistatus>
"#});
}

#[tokio::test]
async fn propfind_prop_unknown_properties() {
let mut app = MockApp::new().await;
app.propfind("/dandisets/000001/draft/dandiset.yaml")
.body(indoc! {r#"
<?xml version="1.0" encoding="utf-8"?>
<propfind xmlns="DAV:">
<prop>
<flavor xmlns="https://www.example.com/" />
<unknown-dav />
</prop>
</propfind>
"#})
.send()
.await
.success()
.assert_body(indoc! {r#"
<?xml version="1.0" encoding="UTF-8"?>
<multistatus xmlns="DAV:">
<response>
<href>/dandisets/000001/draft/dandiset.yaml</href>
<propstat>
<prop>
<flavor xmlns="https://www.example.com/" />
<unknown-dav />
</prop>
<status>HTTP/1.1 404 NOT FOUND</status>
</propstat>
</response>
</multistatus>
"#});
}

#[tokio::test]
async fn propfind_prop_with_unknown_properties() {
let mut app = MockApp::new().await;
app.propfind("/dandisets/000001/draft/dandiset.yaml")
.body(indoc! {r#"
<?xml version="1.0" encoding="utf-8"?>
<propfind xmlns="DAV:">
<prop>
<resourcetype />
<flavor xmlns="https://www.example.com/" />
<unknown-dav />
</prop>
</propfind>
"#})
.send()
.await
.success()
.assert_body(indoc! {r#"
<?xml version="1.0" encoding="UTF-8"?>
<multistatus xmlns="DAV:">
<response>
<href>/dandisets/000001/draft/dandiset.yaml</href>
<propstat>
<prop>
<resourcetype />
</prop>
<status>HTTP/1.1 200 OK</status>
</propstat>
<propstat>
<prop>
<flavor xmlns="https://www.example.com/" />
<unknown-dav />
</prop>
<status>HTTP/1.1 404 NOT FOUND</status>
</propstat>
</response>
</multistatus>
"#});
}

0 comments on commit 50ecf76

Please sign in to comment.