#[cfg(test)]
mod tests {
use rspamd_client::config::{Config, EnvelopeData};
#[cfg(feature = "async")]
use rspamd_client::scan_async;
#[cfg(feature = "sync")]
use rspamd_client::scan_sync;
#[cfg(feature = "sync")]
#[test]
fn test_sync_process() {
let config = Config::builder()
.base_url("http://localhost:11333".to_string())
.encryption_key("k4nz984k36xmcynm1hr9kdbn6jhcxf4ggbrb1quay7f88rpm9kay".to_string())
.build();
let envelope = EnvelopeData::builder()
.from("тест@example.com".to_string())
.build();
let email = "From: user@example.com\nTo: recipient@example.com\nSubject: Test\n\nThis is a test email.";
let response = scan_sync(&config, email, envelope).unwrap();
assert!(!response.symbols.is_empty());
}
#[cfg(feature = "async")]
#[tokio::test]
async fn test_async_encrypted_process() {
let config = Config::builder()
.base_url("http://localhost:11333".to_string())
.encryption_key("k4nz984k36xmcynm1hr9kdbn6jhcxf4ggbrb1quay7f88rpm9kay".to_string())
.build();
let envelope = EnvelopeData::builder()
.from("тест@example.com".to_string())
.build();
let email = "From: user@example.com\nTo: recipient@example.com\nSubject: Test\n\nThis is a test email.";
let response = scan_async(&config, email, envelope).await.unwrap();
assert!(!response.symbols.is_empty());
}
#[cfg(feature = "sync")]
#[test]
fn test_sync_file_header() {
let config = Config::builder()
.base_url("http://localhost:11333".to_string())
.build();
let envelope = EnvelopeData::builder()
.from("user@example.com".to_string())
.file_path("/tmp/test_email.eml".to_string())
.build();
let _response = scan_sync(&config, "", envelope).unwrap();
}
#[cfg(feature = "async")]
#[tokio::test]
async fn test_async_file_header() {
let config = Config::builder()
.base_url("http://localhost:11333".to_string())
.build();
let envelope = EnvelopeData::builder()
.from("user@example.com".to_string())
.file_path("/tmp/test_email.eml".to_string())
.build();
let _response = scan_async(&config, "", envelope).await.unwrap();
}
}