aboutsummaryrefslogtreecommitdiff
path: root/aerogramme/tests/common
diff options
context:
space:
mode:
authorQuentin Dufour <quentin@deuxfleurs.fr>2024-05-22 19:36:27 +0200
committerQuentin Dufour <quentin@deuxfleurs.fr>2024-05-22 19:36:27 +0200
commit649a7b8b1be97a5d43f48ceff0d3f396fadabbbc (patch)
tree0b7e6761d2ef5ac7162e4e3666f66731ecde6e99 /aerogramme/tests/common
parent742beeeafbe46c7677d4af36006f0febd0edb6cd (diff)
downloadaerogramme-649a7b8b1be97a5d43f48ceff0d3f396fadabbbc.tar.gz
aerogramme-649a7b8b1be97a5d43f48ceff0d3f396fadabbbc.zip
webdav propfind integration tests
Diffstat (limited to 'aerogramme/tests/common')
-rw-r--r--aerogramme/tests/common/mod.rs26
1 files changed, 23 insertions, 3 deletions
diff --git a/aerogramme/tests/common/mod.rs b/aerogramme/tests/common/mod.rs
index cbe0271..12f2764 100644
--- a/aerogramme/tests/common/mod.rs
+++ b/aerogramme/tests/common/mod.rs
@@ -8,10 +8,13 @@ use std::net::{Shutdown, TcpStream};
use std::process::Command;
use std::thread;
+use reqwest::blocking::Client;
+use reqwest::header;
+
use constants::SMALL_DELAY;
pub fn aerogramme_provider_daemon_dev(
- mut fx: impl FnMut(&mut TcpStream, &mut TcpStream) -> Result<()>,
+ mut fx: impl FnMut(&mut TcpStream, &mut TcpStream, &mut Client) -> Result<()>,
) -> Result<()> {
// Check port is not used (= free) before starting the test
let mut max_retry = 20;
@@ -53,8 +56,15 @@ pub fn aerogramme_provider_daemon_dev(
let mut lmtp_socket =
TcpStream::connect("[::1]:1025").context("lmtp socket must be connected")?;
- println!("-- ready to test imap features --");
- let result = fx(&mut imap_socket, &mut lmtp_socket);
+ let mut headers = header::HeaderMap::new();
+ headers.insert(
+ header::AUTHORIZATION,
+ header::HeaderValue::from_static("Basic YWxpY2U6aHVudGVyMg=="),
+ );
+ let mut http_client = Client::builder().default_headers(headers).build()?;
+
+ println!("-- ready to test features --");
+ let result = fx(&mut imap_socket, &mut lmtp_socket, &mut http_client);
println!("-- test teardown --");
imap_socket
@@ -97,3 +107,13 @@ pub fn read_first_u32(inp: &str) -> Result<u32> {
.collect::<String>()
.parse::<u32>()?)
}
+
+use aero_dav::xml::{Node, Reader};
+pub fn dav_deserialize<T: Node<T>>(src: &str) -> T {
+ futures::executor::block_on(async {
+ let mut rdr = Reader::new(quick_xml::NsReader::from_reader(src.as_bytes()))
+ .await
+ .expect("build reader");
+ rdr.find().await.expect("parse XML")
+ })
+}