Spaces:
Sleeping
Sleeping
Download tests/test_auth_gate.py from procurement-tools/auto-form: direct link, hf CLI and curl.
- Browser
- Download file 916 Bytes
-
https://huggingface.co/spaces/procurement-tools/auto-form/resolve/main/tests/test_auth_gate.py
- Command line
-
hf download hf://spaces/procurement-tools/auto-form/tests/test_auth_gate.py
-
curl -L -o test_auth_gate.py https://huggingface.co/spaces/procurement-tools/auto-form/resolve/main/tests/test_auth_gate.py
916 Bytes
| # -*- 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 | |