mirror of
https://github.com/chatmail/core.git
synced 2026-05-07 08:56:30 +03:00
refactor: use super::* in qr::dclogin_scheme
This commit is contained in:
@@ -200,9 +200,7 @@ pub(crate) fn login_param_from_login_qr(
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use anyhow::bail;
|
use super::*;
|
||||||
|
|
||||||
use super::{LoginOptions, decode_login};
|
|
||||||
use crate::{login_param::EnteredCertificateChecks, provider::Socket, qr::Qr};
|
use crate::{login_param::EnteredCertificateChecks, provider::Socket, qr::Qr};
|
||||||
|
|
||||||
macro_rules! login_options_just_pw {
|
macro_rules! login_options_just_pw {
|
||||||
@@ -225,7 +223,7 @@ mod test {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn minimal_no_options() -> anyhow::Result<()> {
|
fn minimal_no_options() -> Result<()> {
|
||||||
let result = decode_login("dclogin://email@host.tld?p=123&v=1")?;
|
let result = decode_login("dclogin://email@host.tld?p=123&v=1")?;
|
||||||
if let Qr::Login { address, options } = result {
|
if let Qr::Login { address, options } = result {
|
||||||
assert_eq!(address, "email@host.tld".to_owned());
|
assert_eq!(address, "email@host.tld".to_owned());
|
||||||
@@ -250,7 +248,7 @@ mod test {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
#[test]
|
#[test]
|
||||||
fn minimal_no_options_no_double_slash() -> anyhow::Result<()> {
|
fn minimal_no_options_no_double_slash() -> Result<()> {
|
||||||
let result = decode_login("dclogin:email@host.tld?p=123&v=1")?;
|
let result = decode_login("dclogin:email@host.tld?p=123&v=1")?;
|
||||||
if let Qr::Login { address, options } = result {
|
if let Qr::Login { address, options } = result {
|
||||||
assert_eq!(address, "email@host.tld".to_owned());
|
assert_eq!(address, "email@host.tld".to_owned());
|
||||||
@@ -289,7 +287,7 @@ mod test {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn version_too_new() -> anyhow::Result<()> {
|
fn version_too_new() -> Result<()> {
|
||||||
let result = decode_login("dclogin:email@host.tld/?p=123456&v=2")?;
|
let result = decode_login("dclogin:email@host.tld/?p=123456&v=2")?;
|
||||||
if let Qr::Login { options, .. } = result {
|
if let Qr::Login { options, .. } = result {
|
||||||
assert_eq!(options, LoginOptions::UnsuportedVersion(2));
|
assert_eq!(options, LoginOptions::UnsuportedVersion(2));
|
||||||
@@ -306,7 +304,7 @@ mod test {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn all_advanced_options() -> anyhow::Result<()> {
|
fn all_advanced_options() -> Result<()> {
|
||||||
let result = decode_login(
|
let result = decode_login(
|
||||||
"dclogin:email@host.tld?p=secret&v=1&ih=imap.host.tld&ip=4000&iu=max&ipw=87654&is=ssl&ic=1&sh=mail.host.tld&sp=3000&su=max@host.tld&spw=3242HS&ss=plain&sc=3",
|
"dclogin:email@host.tld?p=secret&v=1&ih=imap.host.tld&ip=4000&iu=max&ipw=87654&is=ssl&ic=1&sh=mail.host.tld&sp=3000&su=max@host.tld&spw=3242HS&ss=plain&sc=3",
|
||||||
)?;
|
)?;
|
||||||
@@ -336,7 +334,7 @@ mod test {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn uri_encoded_password() -> anyhow::Result<()> {
|
fn uri_encoded_password() -> Result<()> {
|
||||||
let result = decode_login(
|
let result = decode_login(
|
||||||
"dclogin:email@host.tld?p=%7BDaehFl%3B%22as%40%21fhdodn5%24234%22%7B%7Dfg&v=1",
|
"dclogin:email@host.tld?p=%7BDaehFl%3B%22as%40%21fhdodn5%24234%22%7B%7Dfg&v=1",
|
||||||
)?;
|
)?;
|
||||||
@@ -353,7 +351,7 @@ mod test {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn email_with_plus_extension() -> anyhow::Result<()> {
|
fn email_with_plus_extension() -> Result<()> {
|
||||||
let result = decode_login("dclogin:usename+extension@host?p=1234&v=1")?;
|
let result = decode_login("dclogin:usename+extension@host?p=1234&v=1")?;
|
||||||
if let Qr::Login { address, options } = result {
|
if let Qr::Login { address, options } = result {
|
||||||
assert_eq!(address, "usename+extension@host".to_owned());
|
assert_eq!(address, "usename+extension@host".to_owned());
|
||||||
@@ -365,7 +363,7 @@ mod test {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||||
async fn test_decode_dclogin_ipv4() -> anyhow::Result<()> {
|
async fn test_decode_dclogin_ipv4() -> Result<()> {
|
||||||
let result = decode_login("dclogin://test@[127.0.0.1]?p=1234&v=1")?;
|
let result = decode_login("dclogin://test@[127.0.0.1]?p=1234&v=1")?;
|
||||||
if let Qr::Login { address, options } = result {
|
if let Qr::Login { address, options } = result {
|
||||||
assert_eq!(address, "test@[127.0.0.1]".to_owned());
|
assert_eq!(address, "test@[127.0.0.1]".to_owned());
|
||||||
@@ -377,7 +375,7 @@ mod test {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||||
async fn test_decode_dclogin_ipv6() -> anyhow::Result<()> {
|
async fn test_decode_dclogin_ipv6() -> Result<()> {
|
||||||
let result =
|
let result =
|
||||||
decode_login("dclogin://test@[2001:0db8:85a3:0000:0000:8a2e:0370:7334]?p=1234&v=1")?;
|
decode_login("dclogin://test@[2001:0db8:85a3:0000:0000:8a2e:0370:7334]?p=1234&v=1")?;
|
||||||
if let Qr::Login { address, options } = result {
|
if let Qr::Login { address, options } = result {
|
||||||
|
|||||||
Reference in New Issue
Block a user