mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-06-10 08:32:09 +00:00
fix: guard role_authorized check against MagicMock test sources
Compare source.role_authorized with 'is True' so a MagicMock source (test fixtures that build bare runners via object.__new__) doesn't auto-truthy through the gate. The real SessionSource field is a bool, so production behavior is unchanged. Fixes test_signal_in_allowlist_maps.
This commit is contained in:
parent
099146fedd
commit
4eadef18a9
1 changed files with 4 additions and 1 deletions
|
|
@ -209,7 +209,10 @@ class GatewayAuthorizationMixin:
|
|||
|
||||
# Adapter-verified role auth: the Discord adapter already confirmed the
|
||||
# user holds a role in DISCORD_ALLOWED_ROLES before dispatching the message.
|
||||
if getattr(source, "role_authorized", False):
|
||||
# Compare with ``is True`` so the real bool field authorizes while a
|
||||
# MagicMock source (test fixtures using ``object.__new__`` runners with
|
||||
# mock sources) does not auto-truthy through this gate (see pitfall #13).
|
||||
if getattr(source, "role_authorized", False) is True:
|
||||
return True
|
||||
|
||||
if getattr(source, "is_bot", False):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue