xline: tell a banned user when the ban expires, not just why
This commit is contained in:
parent
745ddd540e
commit
7cb9256ff5
2 changed files with 34 additions and 4 deletions
|
|
@ -1655,6 +1655,21 @@ mod tests {
|
|||
assert!(joined.contains("XLINE: Z-line on 192.0.2.5 expired"), "expire: {joined}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn banned_user_message_shows_expiry() {
|
||||
let mut s = srv();
|
||||
s.conf_path = std::env::temp_dir().join("echo-ban-expiry-test").display().to_string();
|
||||
// permanent K-line: reason only, no expiry tail
|
||||
s.add_xline(crate::xline::XKind::Kline, "*@perm.example", 0, "op", "spam");
|
||||
let perm = s.matched_xline("bob", "perm.example", "1.2.3.4").unwrap();
|
||||
assert_eq!(perm, "K-lined: spam", "permanent ban shows no expiry: {perm}");
|
||||
// timed Z-line: reason + when it lifts
|
||||
s.add_xline(crate::xline::XKind::Zline, "5.6.7.8", 604800, "op", "botnet");
|
||||
let timed = s.matched_xline("bob", "any.host", "5.6.7.8").unwrap();
|
||||
assert!(timed.starts_with("Z-lined: botnet (expires in "), "timed ban shows expiry: {timed}");
|
||||
assert!(timed.contains(" on ") && timed.ends_with(')'), "with an absolute date: {timed}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn dnsbl_hit_emits_expected_snotices() {
|
||||
use std::net::Ipv4Addr;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue