use super::authentication_settings::{AuthSetup, IAuthenticationSettings};
use crate::{
acl::AclError,
auth::{GarnetNoAuthAuthenticator, IGarnetAuthenticator},
};
pub struct NoAuthSettings;
impl IAuthenticationSettings for NoAuthSettings {
fn create_authenticator(
&self,
_setup: &AuthSetup,
) -> Result<Box<dyn IGarnetAuthenticator>, AclError> {
Ok(Box::new(GarnetNoAuthAuthenticator))
}
}
#[cfg(test)]
mod tests {
use super::{
super::authentication_settings::{AuthSetup, IAuthenticationSettings},
*,
};
#[test]
fn creates_no_auth_authenticator() {
let settings = NoAuthSettings;
let auth = settings
.create_authenticator(&AuthSetup { acl: None })
.unwrap();
assert!(auth.is_authenticated());
assert!(!auth.can_authenticate());
assert!(!auth.has_acl_support());
}
}