Groupware caching improvements
This commit is contained in:
@@ -8,11 +8,11 @@ use super::WebDavTest;
|
||||
|
||||
pub async fn test(test: &WebDavTest) {
|
||||
println!("Running basic tests...");
|
||||
let client = test.client("john");
|
||||
let john = test.client("john");
|
||||
let jane = test.client("jane");
|
||||
|
||||
// Test OPTIONS request
|
||||
client
|
||||
.request("OPTIONS", "/dav/file", "")
|
||||
john.request("OPTIONS", "/dav/file", "")
|
||||
.await
|
||||
.with_header(
|
||||
"dav",
|
||||
@@ -27,18 +27,21 @@ pub async fn test(test: &WebDavTest) {
|
||||
);
|
||||
|
||||
// Test Discovery
|
||||
client
|
||||
.request("PROPFIND", "/.well-known/carddav", "")
|
||||
john.request("PROPFIND", "/.well-known/carddav", "")
|
||||
.await
|
||||
.with_values(
|
||||
"D:multistatus.D:response.D:href",
|
||||
["/dav/card/", "/dav/card/john/"],
|
||||
);
|
||||
test.client("jane")
|
||||
.request("PROPFIND", "/.well-known/caldav", "")
|
||||
jane.request("PROPFIND", "/.well-known/caldav", "")
|
||||
.await
|
||||
.with_values(
|
||||
"D:multistatus.D:response.D:href",
|
||||
["/dav/cal/", "/dav/cal/jane/", "/dav/cal/support/"],
|
||||
);
|
||||
|
||||
john.delete_default_containers().await;
|
||||
jane.delete_default_containers().await;
|
||||
jane.delete_default_containers_by_account("support").await;
|
||||
test.assert_is_empty().await;
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ use common::{
|
||||
manager::boot::build_ipc,
|
||||
};
|
||||
use dav_proto::schema::property::{DavProperty, WebDavProperty};
|
||||
use groupware::{DavResourceName, hierarchy::DavHierarchy};
|
||||
use groupware::{DavResourceName, cache::GroupwareCache};
|
||||
use http::HttpSessionManager;
|
||||
use hyper::{HeaderMap, Method, StatusCode, header::AUTHORIZATION};
|
||||
use imap::core::ImapSessionManager;
|
||||
@@ -227,17 +227,25 @@ impl WebDavTest {
|
||||
let account_id = self.client(name).account_id;
|
||||
let access_token = self.server.get_access_token(account_id).await.unwrap();
|
||||
self.server
|
||||
.fetch_dav_resources(&access_token, account_id, collection)
|
||||
.fetch_dav_resources(&access_token, account_id, collection.into())
|
||||
.await
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
pub async fn assert_is_empty(&self) {
|
||||
assert_is_empty(self.server.clone()).await;
|
||||
for cache in [
|
||||
&self.server.inner.cache.events,
|
||||
&self.server.inner.cache.contacts,
|
||||
&self.server.inner.cache.files,
|
||||
] {
|
||||
cache.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[derive(Debug)]
|
||||
pub struct DummyWebDavClient {
|
||||
account_id: u32,
|
||||
name: &'static str,
|
||||
@@ -653,7 +661,7 @@ pub trait DavResourcesTest {
|
||||
|
||||
impl DavResourcesTest for DavResources {
|
||||
fn items(&self) -> Vec<DavResource> {
|
||||
self.paths.iter().cloned().collect()
|
||||
self.resources.clone()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -328,6 +328,7 @@ pub async fn test(test: &WebDavTest) {
|
||||
.with_hrefs([format!("{}/support/", DavResourceName::Principal.base_path()).as_str()]);
|
||||
|
||||
client.delete_default_containers().await;
|
||||
client.delete_default_containers_by_account("support").await;
|
||||
test.assert_is_empty().await;
|
||||
}
|
||||
|
||||
|
||||
@@ -197,9 +197,15 @@ pub async fn test(test: &WebDavTest) {
|
||||
|
||||
// PUT precondition enforcement
|
||||
let modseq = [
|
||||
test.resources("john", Collection::FileNode).await.modseq,
|
||||
test.resources("john", Collection::Calendar).await.modseq,
|
||||
test.resources("john", Collection::AddressBook).await.modseq,
|
||||
test.resources("john", Collection::FileNode)
|
||||
.await
|
||||
.highest_change_id,
|
||||
test.resources("john", Collection::Calendar)
|
||||
.await
|
||||
.highest_change_id,
|
||||
test.resources("john", Collection::AddressBook)
|
||||
.await
|
||||
.highest_change_id,
|
||||
];
|
||||
for (path, ct, content) in [
|
||||
("/dav/file/john/file1.txt", "text/plain", TEST_FILE_1),
|
||||
@@ -263,9 +269,15 @@ pub async fn test(test: &WebDavTest) {
|
||||
}
|
||||
assert_eq!(
|
||||
[
|
||||
test.resources("john", Collection::FileNode).await.modseq,
|
||||
test.resources("john", Collection::Calendar).await.modseq,
|
||||
test.resources("john", Collection::AddressBook).await.modseq,
|
||||
test.resources("john", Collection::FileNode)
|
||||
.await
|
||||
.highest_change_id,
|
||||
test.resources("john", Collection::Calendar)
|
||||
.await
|
||||
.highest_change_id,
|
||||
test.resources("john", Collection::AddressBook)
|
||||
.await
|
||||
.highest_change_id,
|
||||
],
|
||||
modseq
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user