simplefe

Log | Files | Refs

test_auth.py (646B)


      1 import pytest
      2 
      3 
      4 from simplefe.auth import AuthConfigError, check_token, load_token
      5 
      6 
      7 def test_check_token_matching():
      8     assert check_token("secret", "secret") is True
      9 
     10 
     11 def test_check_token_mismatch():
     12     assert check_token("secret", "wrong") is False
     13 
     14 
     15 def test_load_token_explicit_arg():
     16     assert load_token("explicit") == "explicit"
     17 
     18 
     19 def test_load_token_from_env(monkeypatch):
     20     monkeypatch.setenv("SIMPLEFE_TOKEN", "from-env")
     21     assert load_token() == "from-env"
     22 
     23 
     24 def test_load_token_missing_raises(monkeypatch):
     25     monkeypatch.delenv("SIMPLEFE_TOKEN", raising=False)
     26     with pytest.raises(AuthConfigError):
     27         load_token()