Test fixes - part 2
This commit is contained in:
@@ -449,6 +449,7 @@ async fn internal_directory() {
|
||||
quota: 1024,
|
||||
typ: Type::Individual,
|
||||
member_of: vec!["list".to_string(), "sales".to_string()],
|
||||
..Default::default()
|
||||
}
|
||||
);
|
||||
assert_eq!(store.get_principal_id("john").await.unwrap(), None);
|
||||
@@ -530,7 +531,14 @@ async fn internal_directory() {
|
||||
// List accounts
|
||||
assert_eq!(
|
||||
store
|
||||
.list_principals(None, None, &[], &[], 0, 0)
|
||||
.list_principals(
|
||||
None,
|
||||
None,
|
||||
&[Type::Individual, Type::Group, Type::List],
|
||||
&[],
|
||||
0,
|
||||
0
|
||||
)
|
||||
.await
|
||||
.unwrap()
|
||||
.items
|
||||
@@ -633,7 +641,14 @@ async fn internal_directory() {
|
||||
assert!(!store.rcpt("john.doe@example.org").await.unwrap());
|
||||
assert_eq!(
|
||||
store
|
||||
.list_principals(None, None, &[], &[], 0, 0)
|
||||
.list_principals(
|
||||
None,
|
||||
None,
|
||||
&[Type::Individual, Type::Group, Type::List],
|
||||
&[],
|
||||
0,
|
||||
0
|
||||
)
|
||||
.await
|
||||
.unwrap()
|
||||
.items
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
use std::fmt::Debug;
|
||||
|
||||
use directory::{backend::internal::manage::ManageDirectory, QueryBy, Type};
|
||||
use directory::{backend::internal::manage::ManageDirectory, QueryBy, Type, ROLE_USER};
|
||||
use mail_send::Credentials;
|
||||
|
||||
use crate::directory::{map_account_ids, DirectoryTest, IntoTestPrincipal, TestPrincipal};
|
||||
@@ -57,6 +57,7 @@ async fn ldap_directory() {
|
||||
"john@example.org".to_string(),
|
||||
"john.doe@example.org".to_string()
|
||||
],
|
||||
roles: vec![ROLE_USER.to_string()],
|
||||
..Default::default()
|
||||
}
|
||||
.into_sorted()
|
||||
@@ -85,6 +86,7 @@ async fn ldap_directory() {
|
||||
typ: Type::Individual,
|
||||
quota: 500000,
|
||||
emails: vec!["bill@example.org".to_string(),],
|
||||
roles: vec![ROLE_USER.to_string()],
|
||||
..Default::default()
|
||||
}
|
||||
.into_sorted()
|
||||
@@ -122,6 +124,7 @@ async fn ldap_directory() {
|
||||
.map(|v| v.to_string())
|
||||
.collect(),
|
||||
emails: vec!["jane@example.org".to_string(),],
|
||||
roles: vec![ROLE_USER.to_string()],
|
||||
..Default::default()
|
||||
}
|
||||
.into_sorted()
|
||||
@@ -140,6 +143,7 @@ async fn ldap_directory() {
|
||||
name: "sales".to_string(),
|
||||
description: "sales".to_string().into(),
|
||||
typ: Type::Group,
|
||||
roles: vec![ROLE_USER.to_string()],
|
||||
..Default::default()
|
||||
}
|
||||
);
|
||||
|
||||
@@ -266,6 +266,7 @@ pub struct TestPrincipal {
|
||||
pub secrets: Vec<String>,
|
||||
pub emails: Vec<String>,
|
||||
pub member_of: Vec<String>,
|
||||
pub roles: Vec<String>,
|
||||
pub description: Option<String>,
|
||||
}
|
||||
|
||||
@@ -457,10 +458,9 @@ impl From<Principal> for TestPrincipal {
|
||||
member_of: value
|
||||
.take_str_array(PrincipalField::MemberOf)
|
||||
.unwrap_or_default(),
|
||||
/*member_of: value
|
||||
.iter_int(PrincipalField::MemberOf)
|
||||
.map(|v| v as u32)
|
||||
.collect(),*/
|
||||
roles: value
|
||||
.take_str_array(PrincipalField::Roles)
|
||||
.unwrap_or_default(),
|
||||
description: value.take_str(PrincipalField::Description),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-SEL
|
||||
*/
|
||||
|
||||
use directory::{backend::internal::manage::ManageDirectory, QueryBy, Type};
|
||||
use directory::{backend::internal::manage::ManageDirectory, QueryBy, Type, ROLE_ADMIN, ROLE_USER};
|
||||
use mail_send::Credentials;
|
||||
use store::{LookupStore, Store};
|
||||
|
||||
@@ -39,6 +39,9 @@ async fn sql_directory() {
|
||||
store.create_test_directory().await;
|
||||
|
||||
// Create test users
|
||||
store
|
||||
.create_test_user("admin", "very_secret", "Administrator")
|
||||
.await;
|
||||
store.create_test_user("john", "12345", "John Doe").await;
|
||||
store.create_test_user("jane", "abcde", "Jane Doe").await;
|
||||
store
|
||||
@@ -128,6 +131,7 @@ async fn sql_directory() {
|
||||
"jdoe@example.org".to_string(),
|
||||
"john.doe@example.org".to_string()
|
||||
],
|
||||
roles: vec![ROLE_USER.to_string()],
|
||||
..Default::default()
|
||||
}
|
||||
);
|
||||
@@ -154,6 +158,30 @@ async fn sql_directory() {
|
||||
typ: Type::Individual,
|
||||
quota: 500000,
|
||||
emails: vec!["bill@example.org".to_string(),],
|
||||
roles: vec![ROLE_USER.to_string()],
|
||||
..Default::default()
|
||||
}
|
||||
);
|
||||
assert_eq!(
|
||||
handle
|
||||
.query(
|
||||
QueryBy::Credentials(&Credentials::Plain {
|
||||
username: "admin".to_string(),
|
||||
secret: "very_secret".to_string()
|
||||
}),
|
||||
true
|
||||
)
|
||||
.await
|
||||
.unwrap()
|
||||
.unwrap()
|
||||
.into_test(),
|
||||
TestPrincipal {
|
||||
id: base_store.get_principal_id("admin").await.unwrap().unwrap(),
|
||||
name: "admin".to_string(),
|
||||
description: "Administrator".to_string().into(),
|
||||
secrets: vec!["very_secret".to_string()],
|
||||
typ: Type::Individual,
|
||||
roles: vec![ROLE_ADMIN.to_string()],
|
||||
..Default::default()
|
||||
}
|
||||
);
|
||||
@@ -189,6 +217,7 @@ async fn sql_directory() {
|
||||
.map(|v| v.to_string())
|
||||
.collect(),
|
||||
emails: vec!["jane@example.org".to_string(),],
|
||||
roles: vec![ROLE_USER.to_string()],
|
||||
..Default::default()
|
||||
}
|
||||
);
|
||||
@@ -206,6 +235,7 @@ async fn sql_directory() {
|
||||
name: "sales".to_string(),
|
||||
description: "Sales Team".to_string().into(),
|
||||
typ: Type::Group,
|
||||
roles: vec![ROLE_USER.to_string()],
|
||||
..Default::default()
|
||||
}
|
||||
);
|
||||
|
||||
@@ -166,7 +166,6 @@ pub async fn test(mut imap_john: &mut ImapConnection, _imap_check: &mut ImapConn
|
||||
.await;
|
||||
imap.assert_read(Type::Tagged, ResponseType::Ok).await;
|
||||
}
|
||||
let c = println!("----cococ");
|
||||
imap_john.send("UID STORE 1 +FLAGS (\\Deleted)").await;
|
||||
imap_john.assert_read(Type::Tagged, ResponseType::No).await;
|
||||
|
||||
|
||||
@@ -9,10 +9,13 @@ use common::Core;
|
||||
use store::Stores;
|
||||
use utils::config::Config;
|
||||
|
||||
use crate::smtp::{
|
||||
build_smtp,
|
||||
session::{TestSession, VerifyResponse},
|
||||
TempDir,
|
||||
use crate::{
|
||||
smtp::{
|
||||
build_smtp,
|
||||
session::{TestSession, VerifyResponse},
|
||||
TempDir,
|
||||
},
|
||||
AssertConfig,
|
||||
};
|
||||
use smtp::core::{Inner, Session, State};
|
||||
|
||||
@@ -22,6 +25,7 @@ data = "sqlite"
|
||||
lookup = "sqlite"
|
||||
blob = "sqlite"
|
||||
fts = "sqlite"
|
||||
directory = "local"
|
||||
|
||||
[store."sqlite"]
|
||||
type = "sqlite"
|
||||
@@ -74,6 +78,7 @@ async fn auth() {
|
||||
let mut config = Config::new(tmp_dir.update_config(CONFIG)).unwrap();
|
||||
let stores = Stores::parse_all(&mut config).await;
|
||||
let core = Core::parse(&mut config, stores, Default::default()).await;
|
||||
config.assert_no_errors();
|
||||
|
||||
// EHLO should not advertise plain text auth without TLS
|
||||
let mut session = Session::test(build_smtp(core, Inner::default()));
|
||||
|
||||
@@ -11,10 +11,13 @@ use utils::config::Config;
|
||||
|
||||
use smtp::core::{Inner, Session};
|
||||
|
||||
use crate::smtp::{
|
||||
build_smtp,
|
||||
session::{TestSession, VerifyResponse},
|
||||
TempDir,
|
||||
use crate::{
|
||||
smtp::{
|
||||
build_smtp,
|
||||
session::{TestSession, VerifyResponse},
|
||||
TempDir,
|
||||
},
|
||||
AssertConfig,
|
||||
};
|
||||
|
||||
const CONFIG: &str = r#"
|
||||
@@ -23,6 +26,7 @@ data = "sqlite"
|
||||
lookup = "sqlite"
|
||||
blob = "sqlite"
|
||||
fts = "sqlite"
|
||||
directory = "local"
|
||||
|
||||
[store."sqlite"]
|
||||
type = "sqlite"
|
||||
@@ -72,6 +76,7 @@ async fn vrfy_expn() {
|
||||
let mut config = Config::new(tmp_dir.update_config(CONFIG)).unwrap();
|
||||
let stores = Stores::parse_all(&mut config).await;
|
||||
let core = Core::parse(&mut config, stores, Default::default()).await;
|
||||
config.assert_no_errors();
|
||||
|
||||
// EHLO should not advertise VRFY/EXPN to 10.0.0.2
|
||||
let mut session = Session::test(build_smtp(core, Inner::default()));
|
||||
|
||||
Reference in New Issue
Block a user