chore: initial commit with existing codebase
This commit is contained in:
BIN
tests/__pycache__/test_cli.cpython-312-pytest-9.0.1.pyc
Normal file
BIN
tests/__pycache__/test_cli.cpython-312-pytest-9.0.1.pyc
Normal file
Binary file not shown.
BIN
tests/__pycache__/test_hashing.cpython-312-pytest-9.0.1.pyc
Normal file
BIN
tests/__pycache__/test_hashing.cpython-312-pytest-9.0.1.pyc
Normal file
Binary file not shown.
11
tests/test_cli.py
Normal file
11
tests/test_cli.py
Normal file
@@ -0,0 +1,11 @@
|
||||
from salt import hash_password, main
|
||||
|
||||
|
||||
def test_main_supports_hash_shortcut() -> None:
|
||||
assert main(["secret"]) == 0
|
||||
|
||||
|
||||
def test_main_verify_round_trip() -> None:
|
||||
salt, hashed = hash_password("secret-value")
|
||||
assert main(["verify", "secret-value", salt, hashed]) == 0
|
||||
assert main(["verify", "wrong", salt, hashed]) == 1
|
||||
20
tests/test_hashing.py
Normal file
20
tests/test_hashing.py
Normal file
@@ -0,0 +1,20 @@
|
||||
import re
|
||||
|
||||
from salt import hash_password, verify_password
|
||||
|
||||
|
||||
def test_hash_password_round_trip() -> None:
|
||||
salt, hashed = hash_password("correct horse battery staple")
|
||||
assert verify_password("correct horse battery staple", salt, hashed)
|
||||
assert not verify_password("wrong", salt, hashed)
|
||||
|
||||
|
||||
def test_hash_password_returns_base64() -> None:
|
||||
salt, hashed = hash_password("secret")
|
||||
base64_pattern = re.compile(r"^[A-Za-z0-9+/]+={0,2}$")
|
||||
assert base64_pattern.fullmatch(salt)
|
||||
assert base64_pattern.fullmatch(hashed)
|
||||
|
||||
|
||||
def test_verify_password_handles_invalid_base64() -> None:
|
||||
assert verify_password("secret", "**invalid**", "???") is False
|
||||
Reference in New Issue
Block a user