mirror of
https://github.com/Sea-Haven-Industries/open-swe.git
synced 2026-09-30 20:53:15 +00:00
Applies the plan's C5 step: git mv every test per the domain-reorg
move-map (movemap-m50.txt) into tests/{agent,analyzer,auth,dashboard,
github,middleware,models,reviewer,sandbox,slack,tools,webhooks}/, plus
the 13 fork-only placements from the scoping report §2c (Atlassian
webhook tests -> tests/webhooks/, test_atlassian_connect.py and
test_auth_error_leak.py -> tests/auth/, jira/confluence util tests ->
tests/tools/, test_repo_binding_isolation.py -> tests/sandbox/,
bot-identity/autofix tests -> tests/github/).
Path-only move: the only content edits are parents[1] -> parents[2]
fixes in test_e2b_integration.py and test_daytona_integration.py,
required because their __file__-relative ROOT path gained one more
directory level in the move.
Monkeypatch retargets for these files were already completed in C4;
none remained outstanding here.
39 lines
1.5 KiB
Python
39 lines
1.5 KiB
Python
from __future__ import annotations
|
|
|
|
import pytest
|
|
|
|
from agent.dashboard.admin import is_admin, is_observability_authorized
|
|
|
|
|
|
def test_is_admin_accepts_email_or_github_login(monkeypatch: pytest.MonkeyPatch) -> None:
|
|
monkeypatch.setenv("CONFIGURED_ADMINS", "Alice, bob@langchain.dev")
|
|
|
|
assert is_admin("bob@langchain.dev", login="not-bob") is True
|
|
assert is_admin("other@langchain.dev", login="alice") is True
|
|
assert is_admin("other@langchain.dev", login="ALICE") is True
|
|
assert is_admin("other@langchain.dev", login="mallory") is False
|
|
|
|
|
|
def test_is_admin_rejects_blank_identities(monkeypatch: pytest.MonkeyPatch) -> None:
|
|
monkeypatch.setenv("CONFIGURED_ADMINS", "alice")
|
|
|
|
assert is_admin(None, login=None) is False
|
|
assert is_admin("", login=" ") is False
|
|
|
|
|
|
def test_observability_authorized_treats_admin_login_as_admin(
|
|
monkeypatch: pytest.MonkeyPatch,
|
|
) -> None:
|
|
monkeypatch.setenv("CONFIGURED_ADMINS", "alice")
|
|
monkeypatch.delenv("OBSERVABILITY_AUTHORIZED_EMAILS", raising=False)
|
|
|
|
assert is_observability_authorized(None, login="alice") is True
|
|
assert is_observability_authorized("other@langchain.dev", login="mallory") is False
|
|
|
|
|
|
def test_observability_allowlist_still_uses_email(monkeypatch: pytest.MonkeyPatch) -> None:
|
|
monkeypatch.setenv("CONFIGURED_ADMINS", "")
|
|
monkeypatch.setenv("OBSERVABILITY_AUTHORIZED_EMAILS", "trusted@langchain.dev")
|
|
|
|
assert is_observability_authorized("trusted@langchain.dev", login="mallory") is True
|
|
assert is_observability_authorized("other@langchain.dev", login="trusted") is False
|