mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-13 21:42:34 +00:00
46 lines
1.6 KiB
Rust
46 lines
1.6 KiB
Rust
use crate::{CalDavPrincipalUri, calendar::resource::CalendarResource};
|
|
use rustical_dav::resource::Resource;
|
|
use rustical_store::auth::Principal;
|
|
use rustical_xml::XmlSerializeRoot;
|
|
use serde_json::from_str;
|
|
|
|
#[tokio::test]
|
|
async fn test_propfind() {
|
|
let requests: Vec<_> = include_str!("./test_files/propfind.requests")
|
|
.trim()
|
|
.split("\n\n")
|
|
.collect();
|
|
let principals: Vec<Principal> =
|
|
from_str(include_str!("./test_files/propfind.principals.json")).unwrap();
|
|
let resources: Vec<CalendarResource> =
|
|
from_str(include_str!("./test_files/propfind.resources.json")).unwrap();
|
|
let outputs: Vec<_> = include_str!("./test_files/propfind.outputs")
|
|
.trim()
|
|
.split("\n\n")
|
|
.collect();
|
|
|
|
for principal in principals {
|
|
for ((request, resource), &expected_output) in requests.iter().zip(&resources).zip(&outputs)
|
|
{
|
|
let propfind = CalendarResource::parse_propfind(request).unwrap();
|
|
|
|
let response = resource
|
|
.propfind(
|
|
&format!("/caldav/principal/{}/{}", principal.id, resource.cal.id),
|
|
&propfind.prop,
|
|
propfind.include.as_ref(),
|
|
&CalDavPrincipalUri("/caldav"),
|
|
&principal,
|
|
)
|
|
.unwrap();
|
|
let expected_output = expected_output.trim();
|
|
let output = response
|
|
.serialize_to_string()
|
|
.unwrap()
|
|
.trim()
|
|
.replace("\r\n", "\n");
|
|
similar_asserts::assert_eq!(expected_output, output);
|
|
}
|
|
}
|
|
}
|