test(gateway): activate multiplex flag in cross-profile env isolation test

The test installs a secret scope and asserts a scope miss does NOT fall
back to the default profile's env — that isolation guarantee only holds
under multiplexing, which the real gateway activates at startup via
set_multiplex_active().  With the #67827 overlay fallthrough (scope miss
→ os.environ when multiplex is OFF), the test needs to model the
multiplexed runtime it is actually testing.
This commit is contained in:
Teknium 2026-07-21 19:45:22 -07:00
parent c758ded6d2
commit e66e02dc83

View file

@ -7,7 +7,11 @@ from unittest.mock import patch
import pytest
from agent.secret_scope import reset_secret_scope, set_secret_scope
from agent.secret_scope import (
reset_secret_scope,
set_multiplex_active,
set_secret_scope,
)
from hermes_constants import reset_hermes_home_override, set_hermes_home_override
from gateway.config import (
ChannelOverride,
@ -1831,6 +1835,12 @@ class TestLoadGatewayConfig:
monkeypatch.setenv("API_SERVER_ENABLED", "true")
monkeypatch.setenv("DISCORD_BOT_TOKEN", "default-token")
# Model the real multiplexed gateway: run.py flips the runtime flag at
# startup (set_multiplex_active) BEFORE any secondary-profile config
# loads. Without the flag, a scope miss legitimately falls through to
# os.environ (single-profile overlay semantics, #67827) and this test
# would no longer exercise the cross-profile isolation it's about.
set_multiplex_active(True)
home_token = set_hermes_home_override(str(secondary_home))
secret_token = set_secret_scope({"DISCORD_BOT_TOKEN": "worker-token"})
try:
@ -1838,6 +1848,7 @@ class TestLoadGatewayConfig:
finally:
reset_secret_scope(secret_token)
reset_hermes_home_override(home_token)
set_multiplex_active(False)
assert config.multiplex_profiles is True
assert config.platforms[Platform.DISCORD].token == "worker-token"