Spaces:
Sleeping
Sleeping
Download backend/tests/unit/test_security.py from Aynkhn/Face-Expression-Analyzer: direct link, hf CLI and curl.
- Browser
- Download file 1.14 kB
-
https://huggingface.co/spaces/Aynkhn/Face-Expression-Analyzer/resolve/main/backend/tests/unit/test_security.py
- Command line
-
hf download hf://spaces/Aynkhn/Face-Expression-Analyzer/backend/tests/unit/test_security.py
-
curl -L -o test_security.py https://huggingface.co/spaces/Aynkhn/Face-Expression-Analyzer/resolve/main/backend/tests/unit/test_security.py
1.14 kB
| """Key comparison behaviour.""" | |
| from __future__ import annotations | |
| from app.core.security import _keys_match | |
| class TestKeysMatch: | |
| def test_identical_keys_match(self): | |
| assert _keys_match("secret", "secret") is True | |
| def test_different_keys_do_not_match(self): | |
| assert _keys_match("secret", "other") is False | |
| def test_none_does_not_match(self): | |
| assert _keys_match(None, "secret") is False | |
| def test_empty_string_does_not_match(self): | |
| assert _keys_match("", "secret") is False | |
| def test_empty_expected_never_matches(self): | |
| """An unset server-side key must not turn into an open door.""" | |
| assert _keys_match("anything", "") is False | |
| def test_non_ascii_key_returns_false_without_raising(self): | |
| """compare_digest raises on non-ASCII str; encoding first prevents a 500.""" | |
| assert _keys_match("kéy-wîth-ünicode", "secret") is False | |
| def test_non_ascii_on_both_sides_still_compares(self): | |
| assert _keys_match("pässwort", "pässwort") is True | |
| def test_prefix_does_not_match(self): | |
| assert _keys_match("sec", "secret") is False | |