mirror of
https://github.com/soywod/himalaya.git
synced 2024-07-05 17:15:12 +00:00
fix config unit tests
This commit is contained in:
parent
54ea9a3302
commit
f4facd1761
|
@ -119,12 +119,15 @@ impl DeserializedConfig {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use pimalaya_email::{EmailSender, MaildirConfig, SendmailConfig, SmtpConfig};
|
use pimalaya_email::{EmailSender, MaildirConfig, PasswdConfig, SendmailConfig};
|
||||||
|
use pimalaya_secret::Secret;
|
||||||
|
|
||||||
#[cfg(feature = "notmuch-backend")]
|
#[cfg(feature = "notmuch-backend")]
|
||||||
use pimalaya_email::NotmuchConfig;
|
use pimalaya_email::NotmuchConfig;
|
||||||
#[cfg(feature = "imap-backend")]
|
#[cfg(feature = "imap-backend")]
|
||||||
use pimalaya_email::{ImapAuthConfig, ImapConfig};
|
use pimalaya_email::{ImapAuthConfig, ImapConfig};
|
||||||
|
#[cfg(feature = "smtp-sender")]
|
||||||
|
use pimalaya_email::{SmtpAuthConfig, SmtpConfig};
|
||||||
|
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
use tempfile::NamedTempFile;
|
use tempfile::NamedTempFile;
|
||||||
|
@ -380,7 +383,7 @@ mod tests {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn account_smtp_sender_missing_passwd_cmd_field() {
|
fn account_smtp_sender_missing_auth_field() {
|
||||||
let config = make_config(
|
let config = make_config(
|
||||||
"[account]
|
"[account]
|
||||||
email = \"test@localhost\"
|
email = \"test@localhost\"
|
||||||
|
@ -395,7 +398,7 @@ mod tests {
|
||||||
.unwrap_err()
|
.unwrap_err()
|
||||||
.root_cause()
|
.root_cause()
|
||||||
.to_string()
|
.to_string()
|
||||||
.contains("missing field `smtp-passwd-cmd`"));
|
.contains("missing field `smtp-auth`"));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -414,6 +417,7 @@ mod tests {
|
||||||
.contains("missing field `sendmail-cmd`"));
|
.contains("missing field `sendmail-cmd`"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "smtp-sender")]
|
||||||
#[test]
|
#[test]
|
||||||
fn account_smtp_sender_minimum_config() {
|
fn account_smtp_sender_minimum_config() {
|
||||||
let config = make_config(
|
let config = make_config(
|
||||||
|
@ -424,7 +428,8 @@ mod tests {
|
||||||
smtp-host = \"localhost\"
|
smtp-host = \"localhost\"
|
||||||
smtp-port = 25
|
smtp-port = 25
|
||||||
smtp-login = \"login\"
|
smtp-login = \"login\"
|
||||||
smtp-passwd-cmd = \"echo password\"",
|
smtp-auth = \"passwd\"
|
||||||
|
smtp-passwd = { cmd = \"echo password\" }",
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
@ -438,7 +443,9 @@ mod tests {
|
||||||
host: "localhost".into(),
|
host: "localhost".into(),
|
||||||
port: 25,
|
port: 25,
|
||||||
login: "login".into(),
|
login: "login".into(),
|
||||||
passwd_cmd: "echo password".into(),
|
auth: SmtpAuthConfig::Passwd(PasswdConfig {
|
||||||
|
passwd: Secret::new_cmd(String::from("echo password"))
|
||||||
|
}),
|
||||||
..SmtpConfig::default()
|
..SmtpConfig::default()
|
||||||
}),
|
}),
|
||||||
..DeserializedBaseAccountConfig::default()
|
..DeserializedBaseAccountConfig::default()
|
||||||
|
@ -487,7 +494,8 @@ mod tests {
|
||||||
imap-host = \"localhost\"
|
imap-host = \"localhost\"
|
||||||
imap-port = 993
|
imap-port = 993
|
||||||
imap-login = \"login\"
|
imap-login = \"login\"
|
||||||
imap-auth = { raw-passwd = \"password\" }",
|
imap-auth = \"passwd\"
|
||||||
|
imap-passwd = { cmd = \"echo password\" }",
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
@ -504,7 +512,9 @@ mod tests {
|
||||||
host: "localhost".into(),
|
host: "localhost".into(),
|
||||||
port: 993,
|
port: 993,
|
||||||
login: "login".into(),
|
login: "login".into(),
|
||||||
auth: ImapAuthConfig::RawPasswd("password".into()),
|
auth: ImapAuthConfig::Passwd(PasswdConfig {
|
||||||
|
passwd: Secret::new_cmd(String::from("echo password"))
|
||||||
|
}),
|
||||||
..ImapConfig::default()
|
..ImapConfig::default()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue