mirror of
https://github.com/pewdiepie-archdaemon/odysseus.git
synced 2026-06-17 02:05:22 -04:00
refactor(tests): reuse import-state helper in auth manager tests
Test-only refactor continuing #2523. Replaces inline core.auth cache eviction in two _fresh_auth_manager tests with clear_module, preserving behavior.
This commit is contained in:
committed by
GitHub
parent
4f0133b8c3
commit
65231f2ba1
@@ -6,18 +6,17 @@ with missing users or assertion errors.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import json
|
import json
|
||||||
import sys
|
|
||||||
import threading
|
import threading
|
||||||
import time
|
import time
|
||||||
from concurrent.futures import ThreadPoolExecutor, as_completed
|
from concurrent.futures import ThreadPoolExecutor, as_completed
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
from tests.helpers.import_state import clear_module
|
||||||
|
|
||||||
|
|
||||||
def _fresh_auth_manager(tmp_path):
|
def _fresh_auth_manager(tmp_path):
|
||||||
sys.modules.pop("core.auth", None)
|
clear_module("core.auth")
|
||||||
if "core" in sys.modules and hasattr(sys.modules["core"], "auth"):
|
|
||||||
delattr(sys.modules["core"], "auth")
|
|
||||||
from core.auth import AuthManager
|
from core.auth import AuthManager
|
||||||
|
|
||||||
return AuthManager(str(tmp_path / "auth.json"))
|
return AuthManager(str(tmp_path / "auth.json"))
|
||||||
|
|||||||
@@ -11,17 +11,15 @@ is reserved for the same reason (bearer-token owner attribution collision).
|
|||||||
See the privilege-escalation finding from the 2026-06 code review.
|
See the privilege-escalation finding from the 2026-06 code review.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import sys
|
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
from tests.helpers.import_state import clear_module
|
||||||
|
|
||||||
|
|
||||||
def _fresh_auth_manager(tmp_path):
|
def _fresh_auth_manager(tmp_path):
|
||||||
# Same import dance as test_security_regressions: drop any cached stub so
|
# Same import dance as test_security_regressions: drop any cached stub so
|
||||||
# we exercise the real module from disk rather than a conftest mock.
|
# we exercise the real module from disk rather than a conftest mock.
|
||||||
sys.modules.pop("core.auth", None)
|
clear_module("core.auth")
|
||||||
if "core" in sys.modules and hasattr(sys.modules["core"], "auth"):
|
|
||||||
delattr(sys.modules["core"], "auth")
|
|
||||||
from core.auth import AuthManager
|
from core.auth import AuthManager
|
||||||
|
|
||||||
return AuthManager(str(tmp_path / "auth.json"))
|
return AuthManager(str(tmp_path / "auth.json"))
|
||||||
|
|||||||
Reference in New Issue
Block a user