From: Stefan Sterz <s.sterz@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox 1/2] ldap: add an integration test for `check_connection`
Date: Fri, 21 Jul 2023 16:34:02 +0200 [thread overview]
Message-ID: <20230721143403.1288116-1-s.sterz@proxmox.com> (raw)
Signed-off-by: Stefan Sterz <s.sterz@proxmox.com>
---
proxmox-ldap/tests/glauth.rs | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/proxmox-ldap/tests/glauth.rs b/proxmox-ldap/tests/glauth.rs
index 8c0480e..88875d2 100644
--- a/proxmox-ldap/tests/glauth.rs
+++ b/proxmox-ldap/tests/glauth.rs
@@ -40,6 +40,11 @@ fn authenticate(con: &Connection, user: &str, pass: &str) -> Result<(), Error> {
proxmox_async::runtime::block_on(con.authenticate_user(user, pass))
}
+fn check_connection(config: &Config) -> Result<(), Error> {
+ let connection = Connection::new(config.clone());
+ proxmox_async::runtime::block_on(connection.check_connection())
+}
+
fn default_config() -> Config {
Config {
servers: vec!["localhost".into()],
@@ -164,3 +169,25 @@ fn test_search() -> Result<(), Error> {
Ok(())
}
+
+#[test]
+#[ignore]
+fn test_check_connection() -> Result<(), Error> {
+ let _glauth = GlauthServer::new("tests/assets/glauth.cfg")?;
+
+ let mut config = default_config();
+ assert!(check_connection(&config).is_ok());
+
+ config.base_dn = "dc=invalid,dc=com".into();
+ assert!(check_connection(&config).is_err());
+ config.base_dn = "dc=example,dc=com".into();
+
+ config.bind_password = Some("invalid".into());
+ assert!(check_connection(&config).is_err());
+ config.bind_password = Some("password".into());
+
+ config.bind_password = None;
+ assert!(check_connection(&config).is_err());
+
+ Ok(())
+}
--
2.39.2
next reply other threads:[~2023-07-21 14:34 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-21 14:34 Stefan Sterz [this message]
2023-07-21 14:34 ` [pbs-devel] [PATCH proxmox 2/2] ldap: only search base of base_dn when checking connection Stefan Sterz
2023-07-25 8:56 ` Lukas Wagner
2023-08-08 12:03 ` [pbs-devel] applied: " Wolfgang Bumiller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230721143403.1288116-1-s.sterz@proxmox.com \
--to=s.sterz@proxmox.com \
--cc=pbs-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox