Update Readme Files
This commit is contained in:
BIN
tests/__pycache__/test_cli2.cpython-312-pytest-9.0.1.pyc
Normal file
BIN
tests/__pycache__/test_cli2.cpython-312-pytest-9.0.1.pyc
Normal file
Binary file not shown.
Binary file not shown.
BIN
tests/__pycache__/test_integration.cpython-312-pytest-9.0.1.pyc
Normal file
BIN
tests/__pycache__/test_integration.cpython-312-pytest-9.0.1.pyc
Normal file
Binary file not shown.
18
tests/test_cli2.py
Normal file
18
tests/test_cli2.py
Normal file
@@ -0,0 +1,18 @@
|
||||
from salt import hash_password
|
||||
from salt2 import main
|
||||
|
||||
|
||||
def test_main_generate_with_algorithm_flag():
|
||||
"""Verify salt2 CLI accepts --algorithm flag."""
|
||||
assert main(["generate", "--algorithm", "pbkdf2", "secret"]) == 0
|
||||
|
||||
|
||||
def test_main_verify_with_algorithm_flag():
|
||||
"""Verify salt2 CLI verify accepts --algorithm flag."""
|
||||
salt, hashed = hash_password("secret", algorithm="pbkdf2")
|
||||
assert main(["verify", "--algorithm", "pbkdf2", "secret", salt, hashed]) == 0
|
||||
|
||||
|
||||
def test_main_list_algorithms_command():
|
||||
"""Verify salt2 CLI has list-algorithms command."""
|
||||
assert main(["list-algorithms"]) == 0
|
||||
@@ -24,3 +24,16 @@ def test_hash_password_with_algorithm_parameter():
|
||||
"""Verify hash_password accepts algorithm parameter."""
|
||||
salt, hashed = hash_password("test", algorithm="pbkdf2")
|
||||
assert verify_password("test", salt, hashed, algorithm="pbkdf2")
|
||||
|
||||
|
||||
def test_backward_compatibility_with_old_pbkdf2_hashes():
|
||||
"""Verify existing PBKDF2 hashes still work without algorithm parameter."""
|
||||
# Simulate old hash created before algorithm parameter existed
|
||||
salt, hashed = hash_password("legacy-password")
|
||||
|
||||
# Verify using old API (no algorithm parameter)
|
||||
assert verify_password("legacy-password", salt, hashed)
|
||||
assert not verify_password("wrong", salt, hashed)
|
||||
|
||||
# Verify using new API with explicit pbkdf2
|
||||
assert verify_password("legacy-password", salt, hashed, algorithm="pbkdf2")
|
||||
|
||||
51
tests/test_integration.py
Normal file
51
tests/test_integration.py
Normal file
@@ -0,0 +1,51 @@
|
||||
"""Integration tests for multi-algorithm password hashing."""
|
||||
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
|
||||
def test_pbkdf2_cli_integration():
|
||||
"""Test PBKDF2 end-to-end via CLI."""
|
||||
result = subprocess.run(
|
||||
[sys.executable, "salt.py", "hash", "--algorithm", "pbkdf2", "test123"],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
)
|
||||
assert result.returncode == 0
|
||||
assert "Salt:" in result.stdout
|
||||
assert "Hash:" in result.stdout
|
||||
|
||||
|
||||
def test_argon2_cli_integration():
|
||||
"""Test Argon2 end-to-end via CLI."""
|
||||
result = subprocess.run(
|
||||
[sys.executable, "salt.py", "hash", "--algorithm", "argon2", "test123"],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
)
|
||||
assert result.returncode == 0
|
||||
assert "Hash:" in result.stdout
|
||||
|
||||
|
||||
def test_bcrypt_cli_integration():
|
||||
"""Test bcrypt end-to-end via CLI."""
|
||||
result = subprocess.run(
|
||||
[sys.executable, "salt.py", "hash", "--algorithm", "bcrypt", "test123"],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
)
|
||||
assert result.returncode == 0
|
||||
assert "Hash:" in result.stdout
|
||||
|
||||
|
||||
def test_list_algorithms_integration():
|
||||
"""Test list-algorithms command."""
|
||||
result = subprocess.run(
|
||||
[sys.executable, "salt.py", "list-algorithms"],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
)
|
||||
assert result.returncode == 0
|
||||
assert "argon2" in result.stdout
|
||||
assert "bcrypt" in result.stdout
|
||||
assert "pbkdf2" in result.stdout
|
||||
Reference in New Issue
Block a user