File size: 916 Bytes
5ec0721
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# -*- 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