Skip to content

Commit 05c39cf

Browse files
test: add start_server-level no_auth warning regression test (review: suzunn)
Signed-off-by: FugoP <264910004+AgentGymLeader@users.noreply.github.com>
1 parent 8e9f1cc commit 05c39cf

1 file changed

Lines changed: 34 additions & 1 deletion

File tree

sdk/python/tests/unit/test_registry_server.py

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import logging
2+
from types import SimpleNamespace
23

34
import pytest
45

56
from feast.permissions.server.utils import AuthManagerType
6-
from feast.registry_server import _warn_if_auth_disabled
7+
from feast.registry_server import _warn_if_auth_disabled, start_server
78

89

910
def test_warn_if_auth_disabled_emits_warning_for_none(caplog):
@@ -18,3 +19,35 @@ def test_warn_if_auth_disabled_no_warning_for_oidc(caplog):
1819
with caplog.at_level(logging.WARNING, logger="feast.registry_server"):
1920
_warn_if_auth_disabled(AuthManagerType.OIDC)
2021
assert len(caplog.records) == 0
22+
23+
24+
def test_start_server_warns_when_auth_disabled(caplog, monkeypatch):
25+
class Sentinel(Exception):
26+
pass
27+
28+
store = SimpleNamespace(
29+
config=SimpleNamespace(
30+
auth_config=SimpleNamespace(type=AuthManagerType.NONE.value)
31+
)
32+
)
33+
34+
def fail_after_warning(auth_type, fs):
35+
assert auth_type == AuthManagerType.NONE
36+
assert fs is store
37+
assert any(
38+
record.levelno == logging.WARNING and "no_auth" in record.message
39+
for record in caplog.records
40+
)
41+
raise Sentinel
42+
43+
monkeypatch.setattr(
44+
"feast.registry_server.init_security_manager", fail_after_warning
45+
)
46+
47+
with caplog.at_level(logging.WARNING, logger="feast.registry_server"):
48+
with pytest.raises(Sentinel):
49+
start_server(store, port=0)
50+
51+
assert len(caplog.records) == 1
52+
assert caplog.records[0].levelno == logging.WARNING
53+
assert "no_auth" in caplog.records[0].message

0 commit comments

Comments
 (0)