services: assigned bot fronts channel modes, not chanserv
All checks were successful
CI / check (push) Successful in 3m41s

This commit is contained in:
Jean Chevronnet 2026-07-17 01:17:29 +00:00
parent 96654b5e5a
commit 657154e268
No known key found for this signature in database
2 changed files with 59 additions and 3 deletions

View file

@ -486,6 +486,50 @@
assert!(parted, "the assigned bot parts the released channel");
}
// A channel with an assigned bot: the bot (not ChanServ) fronts the in-channel
// auto-op, so it reads as the bot setting the mode.
#[test]
fn assigned_bot_fronts_channel_auto_op() {
use echo_botserv::BotServ;
use echo_chanserv::ChanServ;
use echo_nickserv::NickServ;
let path = std::env::temp_dir().join("echo-botfront.jsonl");
let _ = std::fs::remove_file(&path);
let mut db = Db::open(&path, "test");
db.scram_iterations = 4096;
db.register("alice", "sesame", None).unwrap();
db.register_channel("#room", "alice").unwrap();
let mut e = Engine::new(
vec![
Box::new(NickServ { uid: "42SAAAAAA".into(), guest_nick: "Guest".into(), guest_seq: 0 }),
Box::new(ChanServ { uid: "42SAAAAAB".into() }),
Box::new(BotServ { uid: "42SAAAAAD".into() }),
],
db,
);
e.set_sid("42S".into());
let mut opers = std::collections::HashMap::new();
opers.insert("alice".to_string(), Privs::default().with(echo_api::Priv::Admin));
e.set_opers(opers);
e.handle(NetEvent::UserConnect { uid: "000AAAAAB".into(), nick: "alice".into(), host: "h".into(), ip: "0.0.0.0".into() });
e.handle(NetEvent::Privmsg { from: "000AAAAAB".into(), to: "42SAAAAAA".into(), text: "IDENTIFY sesame".into() });
e.handle(NetEvent::Privmsg { from: "000AAAAAB".into(), to: "42SAAAAAD".into(), text: "BOT ADD Bendy bot serv.host Helper".into() });
let out = e.handle(NetEvent::Privmsg { from: "000AAAAAB".into(), to: "42SAAAAAD".into(), text: "ASSIGN #room Bendy".into() });
let botuid = out.iter().find_map(|a| match a {
NetAction::ServiceJoin { uid, channel } if channel == "#room" => Some(uid.clone()),
_ => None,
}).expect("bot joins #room");
// Founder alice joins: the auto-op is sourced from the bot, not ChanServ.
let join = e.handle(NetEvent::Join { uid: "000AAAAAB".into(), channel: "#room".into(), op: false });
let src = join.iter().find_map(|a| match a {
NetAction::ChannelMode { from, modes, .. } if modes.contains("+o") => Some(from.clone()),
_ => None,
}).expect("alice auto-opped");
assert_eq!(src, botuid, "auto-op fronts as the assigned bot");
assert_ne!(src, "42SAAAAAB", "not sourced from ChanServ");
}
// A server split (SQUIT) forgets exactly the users behind it (uids carrying
// that SID), leaving users on other servers untouched.
#[test]