use crate::has_leaf;
use asterust::config::ConfigLine;
#[derive(Clone, Debug, PartialEq, Eq)]
#[non_exhaustive]
pub struct PasswordOptions {
pub tacplus_authorization: bool,
}
pub(super) fn parse_password_options(options: &ConfigLine) -> PasswordOptions {
PasswordOptions {
tacplus_authorization: has_leaf(options, "tacplus-authorization"),
}
}
#[cfg(test)]
mod tests {
use crate::system::system;
use asterust::config::juniper;
#[test]
fn extracts_password_options() {
let options = system(&juniper::parse_braces(
"system {\n password-options {\n tacplus-authorization;\n }\n}\n",
))
.unwrap()
.password_options
.unwrap();
assert!(options.tacplus_authorization);
}
#[test]
fn no_password_options_is_none() {
let system = system(&juniper::parse_braces("system {\n host-name pe1;\n}\n")).unwrap();
assert!(system.password_options.is_none());
}
}