RateLimit header fields for HTTP

This commit is contained in:
Maurus Decimus
2026-05-23 11:41:43 +02:00
parent 7aa4865a10
commit 777cf1252b
71 changed files with 825 additions and 274 deletions

View File

@@ -19,7 +19,10 @@ use types::TimeRange;
pub async fn test(test: &TestServer) {
println!("Running REPORT calendar-query & free-busy-query tests...");
let client = test.account("john@example.com").webdav_client();
let cal_path = format!("{}/john%40example.com/default/", DavResourceName::Cal.base_path());
let cal_path = format!(
"{}/john%40example.com/default/",
DavResourceName::Cal.base_path()
);
#[allow(clippy::never_loop)]
for (num, ics) in [

View File

@@ -15,7 +15,10 @@ pub async fn test(test: &TestServer) {
let client = test.account("john@example.com").webdav_client();
// Create test data
let default_path = format!("{}/john%40example.com/default/", DavResourceName::Card.base_path());
let default_path = format!(
"{}/john%40example.com/default/",
DavResourceName::Card.base_path()
);
let mut hrefs = Vec::with_capacity(3);
for (i, vcard) in [VCARD1, VCARD2, VCARD3].iter().enumerate() {
let href = format!("{default_path}contact-{i}.vcf",);

View File

@@ -10,7 +10,6 @@ use crate::webdav::{TEST_FILE_1, TEST_ICAL_1, TEST_VCARD_1, TEST_VTIMEZONE_1};
use crate::utils::server::TestServer;
pub async fn test(test: &TestServer) {
println!("Running MKCOL tests...");
let client = test.account("john@example.com").webdav_client();
@@ -42,9 +41,18 @@ pub async fn test(test: &TestServer) {
// Create resources under the newly created collections
for (path, content) in [
("/dav/file/john%40example.com/my-files/file1.txt", TEST_FILE_1),
("/dav/card/john%40example.com/my-cards/card1.vcf", TEST_VCARD_1),
("/dav/cal/john%40example.com/my-events/event1.ics", TEST_ICAL_1),
(
"/dav/file/john%40example.com/my-files/file1.txt",
TEST_FILE_1,
),
(
"/dav/card/john%40example.com/my-cards/card1.vcf",
TEST_VCARD_1,
),
(
"/dav/cal/john%40example.com/my-events/event1.ics",
TEST_ICAL_1,
),
] {
client
.request("PUT", path, content)
@@ -69,7 +77,10 @@ pub async fn test(test: &TestServer) {
// Creating a sub-collections is allowed in FileDAV but in CalDAV and CardDAV
for (path, expected_status) in [
("/dav/file/john%40example.com/my-files/my-sub-files", StatusCode::CREATED),
(
"/dav/file/john%40example.com/my-files/my-sub-files",
StatusCode::CREATED,
),
(
"/dav/card/john%40example.com/my-cards/my-sub-cards",
StatusCode::METHOD_NOT_ALLOWED,
@@ -87,9 +98,15 @@ pub async fn test(test: &TestServer) {
// Extended MKCOL with an unsupported resource types should fail
for (path, resource_type) in [
("/dav/file/john%40example.com/my-named-files", "B:addressbook"),
(
"/dav/file/john%40example.com/my-named-files",
"B:addressbook",
),
("/dav/card/john%40example.com/my-named-cards", "A:calendar"),
("/dav/cal/john%40example.com/my-named-events", "B:addressbook"),
(
"/dav/cal/john%40example.com/my-named-events",
"B:addressbook",
),
] {
client
.mkcol("MKCOL", path, ["D:collection", resource_type], [])

View File

@@ -21,7 +21,11 @@ pub async fn test(test: &TestServer) {
let mut paths = Vec::new();
for name in ["file1", "file2"] {
let contents = resource_type.generate();
let path = format!("{}/john%40example.com/default/{}", resource_type.base_path(), name);
let path = format!(
"{}/john%40example.com/default/{}",
resource_type.base_path(),
name
);
let etag = client
.request("PUT", &path, contents.as_str())
.await