aboutsummaryrefslogtreecommitdiff
path: root/src/test.rs
diff options
context:
space:
mode:
authorKunoiSayami <[email protected]>2021-11-10 20:28:13 +0800
committerKunoiSayami <[email protected]>2021-11-10 20:28:13 +0800
commitc64151e929cea76be5553cdeeeaf90de2ca75d89 (patch)
tree343d8ee53fc1f2c6544fc113118e01c97f8980dd /src/test.rs
parent28c0cee02dc8fd49af84dd42af76f31f43f267da (diff)
feat(core): Support use PAM to provide verification
Signed-off-by: KunoiSayami <[email protected]>
Diffstat (limited to 'src/test.rs')
-rw-r--r--src/test.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/test.rs b/src/test.rs
index 100954c..ee9bc03 100644
--- a/src/test.rs
+++ b/src/test.rs
@@ -20,6 +20,7 @@
#[cfg(test)]
mod core {
+ use std::borrow::BorrowMut;
use crate::datastructures::{rand_str, Config, TestSuite};
use crate::{cmd_add_user, cmd_authenticate_cookie, cmd_init, cmd_repo_user_control};
use crate::{get_arg_matches, IOModule};
@@ -366,4 +367,15 @@ mod core {
.block_on(clear_redis_setting())
.unwrap();
}
+
+ #[test]
+ fn test_pam() {
+ let service = "system-login";
+ let user = option_env!("pam_user").unwrap_or("user");
+ let password = option_env!("pam_password").unwrap_or("password");
+
+ let mut auth = pam::Authenticator::with_password(service).unwrap();
+ auth.get_handler().borrow_mut().set_credentials(user, password);
+ assert!(auth.authenticate().is_ok() && auth.open_session().is_ok())
+ }
}