def set_plugin_state(self, msg, plugin_name: str, enabled: bool) -> Action:
nick = get_nick_from_message(msg)
- if nick not in (conf_get("admins") or []):
+ admins = conf_get("admins") or []
+ if isinstance(admins, str):
+ # "admins = TRex" without the trailing comma fails string_list validation, but
+ # Config() doesn't enforce it, so guard against "in <str>" turning into a substring check
+ admins = [admins]
+ if nick not in admins:
return Action(msg="{}: you are not allowed to do that".format(nick))
resolved = self.resolve_plugin_name(plugin_name)
result = _run(helper, ["nick", "plugin", "deactivate", "plugins"])
assert result == Action(msg="nice try, but then nobody could reactivate anything")
assert state == {}
+
+
+def test_single_admin_without_trailing_comma_is_not_a_substring_match(helper, state, monkeypatch):
+ # configobj leaves "admins = TRex" as a plain string; "Rex" must not pass as admin then
+ monkeypatch.setattr(plugin_help, "conf_get", lambda key: "TRex" if key == "admins" else None)
+ assert _run(helper, ["nick", "plugin", "deactivate", "dice"], sender="room@conf/Rex") == \
+ Action(msg="Rex: you are not allowed to do that")
+ assert _run(helper, ["nick", "plugin", "deactivate", "dice"], sender="room@conf/TRex") == \
+ Action(msg="dice deactivated")