# -*- coding: utf-8 -*- """auth_gate — allowlist parsing (the st.user paths need a live session).""" import auth_gate def test_allowed_users_parsing(monkeypatch): monkeypatch.setenv("ALLOWED_USERS", " Kansak.s@pttplc.com, other@pttplc.com ,, ") assert auth_gate._allowed_users() == {"kansak.s@pttplc.com", "other@pttplc.com"} def test_allowed_users_empty(monkeypatch): monkeypatch.delenv("ALLOWED_USERS", raising=False) assert auth_gate._allowed_users() == set() monkeypatch.setenv("ALLOWED_USERS", " ") assert auth_gate._allowed_users() == set() def test_require_authorized_noop_when_unset(monkeypatch): """Unset allowlist → returns without touching st.user (never locks out).""" monkeypatch.delenv("ALLOWED_USERS", raising=False) auth_gate.require_authorized() # must not raise / st.stop