mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-20 04:39:37 +00:00
50 lines
1.5 KiB
Rust
50 lines
1.5 KiB
Rust
use crate::{CardDavPrincipalUri, addressbook::resource::AddressbookResource};
|
|
use rustical_dav::resource::Resource;
|
|
use rustical_store::{Addressbook, auth::Principal};
|
|
use rustical_xml::XmlSerializeRoot;
|
|
|
|
#[test]
|
|
fn test_propfind() {
|
|
let propfind = AddressbookResource::parse_propfind(
|
|
r#"<?xml version="1.0" encoding="UTF-8"?><propfind xmlns="DAV:"><allprop/></propfind>"#,
|
|
)
|
|
.unwrap();
|
|
|
|
insta::assert_debug_snapshot!(propfind);
|
|
|
|
let principal = Principal {
|
|
id: "user".to_string(),
|
|
displayname: None,
|
|
principal_type: rustical_store::auth::PrincipalType::Individual,
|
|
password: None,
|
|
memberships: vec!["group".to_string()],
|
|
};
|
|
|
|
let addressbook = Addressbook {
|
|
id: "yeet".to_string(),
|
|
principal: "user".to_string(),
|
|
displayname: None,
|
|
description: None,
|
|
deleted_at: None,
|
|
synctoken: 0,
|
|
push_topic: "asdasd".to_string(),
|
|
};
|
|
|
|
let resource = AddressbookResource(addressbook.clone());
|
|
let response = resource
|
|
.propfind(
|
|
&format!(
|
|
"/carddav/principal/{}/{}",
|
|
addressbook.principal, addressbook.id
|
|
),
|
|
&propfind.prop,
|
|
propfind.include.as_ref(),
|
|
&CardDavPrincipalUri("/carddav"),
|
|
&principal,
|
|
)
|
|
.unwrap();
|
|
|
|
insta::assert_debug_snapshot!(response);
|
|
insta::assert_snapshot!(response.serialize_to_string().unwrap());
|
|
}
|