WebDAV: Assisted discovery v2
This commit is contained in:
@@ -11,7 +11,7 @@ use dav_proto::Depth;
|
||||
use groupware::DavResourceName;
|
||||
use hyper::StatusCode;
|
||||
|
||||
pub async fn test(test: &WebDavTest) {
|
||||
pub async fn test(test: &WebDavTest, assisted_discovery: bool) {
|
||||
let client = test.client("jane");
|
||||
let mike_noquota = test.client("mike");
|
||||
|
||||
@@ -33,12 +33,14 @@ pub async fn test(test: &WebDavTest) {
|
||||
let response = client
|
||||
.sync_collection(&user_base_path, "", Depth::Infinity, None, ["D:getetag"])
|
||||
.await;
|
||||
|
||||
// TODO: Fix tests for assisted discovery
|
||||
assert_eq!(
|
||||
response.hrefs().len(),
|
||||
if resource_type == DavResourceName::File {
|
||||
1
|
||||
} else {
|
||||
2
|
||||
2 + usize::from(assisted_discovery)
|
||||
},
|
||||
"{:?}",
|
||||
response.hrefs()
|
||||
|
||||
@@ -73,11 +73,13 @@ fn webdav_tests() {
|
||||
.unwrap()
|
||||
.block_on(async {
|
||||
// Prepare settings
|
||||
let assisted_discovery = std::env::var("ASSISTED_DISCOVERY").unwrap_or_default() == "1";
|
||||
let start_time = Instant::now();
|
||||
let delete = true;
|
||||
let handle = init_webdav_tests(
|
||||
&std::env::var("STORE")
|
||||
.expect("Missing store type. Try running `STORE=<store_type> cargo test`"),
|
||||
assisted_discovery,
|
||||
delete,
|
||||
)
|
||||
.await;
|
||||
@@ -85,12 +87,12 @@ fn webdav_tests() {
|
||||
basic::test(&handle).await;
|
||||
put_get::test(&handle).await;
|
||||
mkcol::test(&handle).await;
|
||||
copy_move::test(&handle).await;
|
||||
prop::test(&handle).await;
|
||||
copy_move::test(&handle, assisted_discovery).await;
|
||||
prop::test(&handle, assisted_discovery).await;
|
||||
multiget::test(&handle).await;
|
||||
sync::test(&handle).await;
|
||||
lock::test(&handle).await;
|
||||
principals::test(&handle).await;
|
||||
principals::test(&handle, assisted_discovery).await;
|
||||
acl::test(&handle).await;
|
||||
card_query::test(&handle).await;
|
||||
cal_query::test(&handle).await;
|
||||
@@ -121,13 +123,18 @@ pub struct WebDavTest {
|
||||
shutdown_tx: watch::Sender<bool>,
|
||||
}
|
||||
|
||||
async fn init_webdav_tests(store_id: &str, delete_if_exists: bool) -> WebDavTest {
|
||||
async fn init_webdav_tests(
|
||||
store_id: &str,
|
||||
assisted_discovery: bool,
|
||||
delete_if_exists: bool,
|
||||
) -> WebDavTest {
|
||||
// Load and parse config
|
||||
let temp_dir = TempDir::new("webdav_tests", delete_if_exists);
|
||||
let mut config = Config::new(
|
||||
add_test_certs(SERVER)
|
||||
.replace("{STORE}", store_id)
|
||||
.replace("{TMP}", &temp_dir.path.display().to_string())
|
||||
.replace("{ASSISTED_DISCOVERY}", &assisted_discovery.to_string())
|
||||
.replace(
|
||||
"{LEVEL}",
|
||||
&std::env::var("LOG").unwrap_or_else(|_| "disable".to_string()),
|
||||
@@ -1190,7 +1197,7 @@ minimum-interval = "1s"
|
||||
auto-add = true
|
||||
|
||||
[dav.collection]
|
||||
assisted-discovery = false
|
||||
assisted-discovery = {ASSISTED_DISCOVERY}
|
||||
|
||||
[store."auth"]
|
||||
type = "sqlite"
|
||||
|
||||
@@ -10,7 +10,7 @@ use dav_proto::schema::property::{DavProperty, PrincipalProperty, WebDavProperty
|
||||
use groupware::DavResourceName;
|
||||
use hyper::StatusCode;
|
||||
|
||||
pub async fn test(test: &WebDavTest) {
|
||||
pub async fn test(test: &WebDavTest, assisted_discovery: bool) {
|
||||
println!("Running principals tests...");
|
||||
let client = test.client("jane");
|
||||
let principal_path = format!("D:href:{}/", DavResourceName::Principal.base_path());
|
||||
@@ -55,7 +55,7 @@ pub async fn test(test: &WebDavTest) {
|
||||
.get(DavProperty::WebDav(WebDavProperty::Owner))
|
||||
.with_values([path_pal.as_str()])
|
||||
.with_status(StatusCode::OK);
|
||||
if *account == "jane" {
|
||||
if *account == "jane" && !assisted_discovery {
|
||||
props
|
||||
.get(DavProperty::Principal(PrincipalProperty::CalendarHomeSet))
|
||||
.with_values([path_cal.as_str(), path_support_cal.as_str()])
|
||||
@@ -207,22 +207,39 @@ pub async fn test(test: &WebDavTest) {
|
||||
.get(DavProperty::WebDav(WebDavProperty::CurrentUserPrincipal))
|
||||
.with_values([jane_principal_path.as_str()])
|
||||
.with_status(StatusCode::OK);
|
||||
props
|
||||
.get(DavProperty::Principal(PrincipalProperty::CalendarHomeSet))
|
||||
.with_values([
|
||||
format!("D:href:{}/jane/", DavResourceName::Cal.base_path()).as_str(),
|
||||
format!("D:href:{}/support/", DavResourceName::Cal.base_path()).as_str(),
|
||||
])
|
||||
.with_status(StatusCode::OK);
|
||||
props
|
||||
.get(DavProperty::Principal(
|
||||
PrincipalProperty::AddressbookHomeSet,
|
||||
))
|
||||
.with_values([
|
||||
format!("D:href:{}/jane/", DavResourceName::Card.base_path()).as_str(),
|
||||
format!("D:href:{}/support/", DavResourceName::Card.base_path()).as_str(),
|
||||
])
|
||||
.with_status(StatusCode::OK);
|
||||
if assisted_discovery {
|
||||
props
|
||||
.get(DavProperty::Principal(PrincipalProperty::CalendarHomeSet))
|
||||
.with_values(
|
||||
[format!("D:href:{}/jane/", DavResourceName::Cal.base_path()).as_str()],
|
||||
)
|
||||
.with_status(StatusCode::OK);
|
||||
props
|
||||
.get(DavProperty::Principal(
|
||||
PrincipalProperty::AddressbookHomeSet,
|
||||
))
|
||||
.with_values([
|
||||
format!("D:href:{}/jane/", DavResourceName::Card.base_path()).as_str(),
|
||||
])
|
||||
.with_status(StatusCode::OK);
|
||||
} else {
|
||||
props
|
||||
.get(DavProperty::Principal(PrincipalProperty::CalendarHomeSet))
|
||||
.with_values([
|
||||
format!("D:href:{}/jane/", DavResourceName::Cal.base_path()).as_str(),
|
||||
format!("D:href:{}/support/", DavResourceName::Cal.base_path()).as_str(),
|
||||
])
|
||||
.with_status(StatusCode::OK);
|
||||
props
|
||||
.get(DavProperty::Principal(
|
||||
PrincipalProperty::AddressbookHomeSet,
|
||||
))
|
||||
.with_values([
|
||||
format!("D:href:{}/jane/", DavResourceName::Card.base_path()).as_str(),
|
||||
format!("D:href:{}/support/", DavResourceName::Card.base_path()).as_str(),
|
||||
])
|
||||
.with_status(StatusCode::OK);
|
||||
}
|
||||
|
||||
for (account, _, name, _) in TEST_USERS
|
||||
.iter()
|
||||
@@ -269,7 +286,7 @@ pub async fn test(test: &WebDavTest) {
|
||||
.get(DavProperty::WebDav(WebDavProperty::Owner))
|
||||
.with_values([path_pal.as_str()])
|
||||
.with_status(StatusCode::OK);
|
||||
if *account == "jane" {
|
||||
if *account == "jane" && !assisted_discovery {
|
||||
props
|
||||
.get(DavProperty::Principal(PrincipalProperty::CalendarHomeSet))
|
||||
.with_values([path_cal.as_str(), path_support_cal.as_str()])
|
||||
|
||||
@@ -14,7 +14,7 @@ use dav_proto::schema::{
|
||||
use groupware::DavResourceName;
|
||||
use hyper::StatusCode;
|
||||
|
||||
pub async fn test(test: &WebDavTest) {
|
||||
pub async fn test(test: &WebDavTest, assisted_discovery: bool) {
|
||||
let client = test.client("jane");
|
||||
|
||||
for resource_type in [
|
||||
@@ -91,12 +91,15 @@ pub async fn test(test: &WebDavTest) {
|
||||
.with_status(StatusCode::MULTI_STATUS)
|
||||
.with_hrefs(
|
||||
[
|
||||
format!("{group_base_path}/default/").as_str(),
|
||||
format!("{user_base_path}/default/").as_str(),
|
||||
format!("{user_base_path}/").as_str(),
|
||||
&test_base_path,
|
||||
]
|
||||
.into_iter()
|
||||
.skip(if resource_type == DavResourceName::File {
|
||||
2
|
||||
} else if !assisted_discovery {
|
||||
1
|
||||
} else {
|
||||
0
|
||||
@@ -132,11 +135,14 @@ pub async fn test(test: &WebDavTest) {
|
||||
.with_status(StatusCode::MULTI_STATUS)
|
||||
.with_hrefs(
|
||||
[
|
||||
format!("{group_base_path}/default/").as_str(),
|
||||
format!("{user_base_path}/default/").as_str(),
|
||||
&test_base_path,
|
||||
]
|
||||
.into_iter()
|
||||
.skip(if resource_type == DavResourceName::File {
|
||||
2
|
||||
} else if !assisted_discovery {
|
||||
1
|
||||
} else {
|
||||
0
|
||||
|
||||
Reference in New Issue
Block a user