mirror of
https://github.com/pewdiepie-archdaemon/odysseus.git
synced 2026-08-05 02:45:28 +00:00
test(companion): guard auth-disabled model scoping
This commit is contained in:
parent
fa2f2eb5d1
commit
f0bea2b173
1 changed files with 41 additions and 0 deletions
|
|
@ -279,6 +279,47 @@ def test_models_route_unresolved_owner_returns_only_shared_rows(monkeypatch):
|
|||
assert _endpoint_names(endpoints) == ["shared-endpoint"]
|
||||
|
||||
|
||||
def test_models_route_auth_disabled_does_not_widen_ownerless_api_token(monkeypatch):
|
||||
monkeypatch.setenv("AUTH_ENABLED", "false")
|
||||
rows = [
|
||||
_ep(1, "alice-endpoint", "alice"),
|
||||
_ep(2, "shared-endpoint", None),
|
||||
_ep(3, "bob-endpoint", "bob"),
|
||||
]
|
||||
monkeypatch.setattr(companion_routes, "get_current_user", lambda request: None)
|
||||
|
||||
endpoints = _call_models_route(
|
||||
monkeypatch,
|
||||
rows,
|
||||
_request(
|
||||
api_token=True,
|
||||
api_token_owner=None,
|
||||
api_token_scopes=["chat"],
|
||||
current_user="api",
|
||||
),
|
||||
)
|
||||
|
||||
assert _endpoint_names(endpoints) == ["shared-endpoint"]
|
||||
|
||||
|
||||
def test_models_route_auth_disabled_keeps_cookie_owner_scoped(monkeypatch):
|
||||
monkeypatch.setenv("AUTH_ENABLED", "false")
|
||||
rows = [
|
||||
_ep(1, "alice-endpoint", "alice"),
|
||||
_ep(2, "shared-endpoint", None),
|
||||
_ep(3, "bob-endpoint", "bob"),
|
||||
]
|
||||
monkeypatch.setattr(companion_routes, "get_current_user", lambda request: "alice")
|
||||
|
||||
endpoints = _call_models_route(
|
||||
monkeypatch,
|
||||
rows,
|
||||
_request(api_token=False, current_user="alice"),
|
||||
)
|
||||
|
||||
assert _endpoint_names(endpoints) == ["alice-endpoint", "shared-endpoint"]
|
||||
|
||||
|
||||
def test_models_route_auth_enabled_anonymous_returns_only_shared_rows(monkeypatch):
|
||||
monkeypatch.setenv("AUTH_ENABLED", "true")
|
||||
rows = [
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue