use crate::helpers::{TestInfoBuilder, EMPTY_MESSAGE};
use lettre::{transport::smtp::client::Tls, Transport};
#[test]
fn server_should_support_client_requiring_tls() {
let test_info = TestInfoBuilder::new().default_auth_user().build();
let mailer = test_info
.mailer_builder
.tls(Tls::Required(test_info.tls_params))
.build();
assert!(mailer.send(&EMPTY_MESSAGE).is_ok());
}
#[test]
fn server_should_support_client_with_opportunistic_tls() {
let test_info = TestInfoBuilder::new().default_auth_user().build();
let mailer = test_info
.mailer_builder
.tls(Tls::Opportunistic(test_info.tls_params))
.build();
assert!(mailer.send(&EMPTY_MESSAGE).is_ok());
}
#[test]
fn server_requiring_tls_should_support_client_with_opportunistic_tls() {
let test_info = TestInfoBuilder::new()
.set_require_tls()
.default_auth_user()
.build();
let mailer = test_info
.mailer_builder
.tls(Tls::Opportunistic(test_info.tls_params))
.build();
assert!(mailer.send(&EMPTY_MESSAGE).is_ok());
}
#[test]
fn server_requiring_tls_should_decline_client_without_tls() {
let test_info = TestInfoBuilder::new()
.set_require_tls()
.default_auth_user()
.build();
let mailer = test_info.mailer_builder.tls(Tls::None).build();
assert!(mailer.send(&EMPTY_MESSAGE).is_err());
}