chore: import upstream snapshot with attribution
docs / deploy (push) Has been cancelled
docs / changes (push) Has been cancelled
docs / check-and-build (push) Has been cancelled
build container image / cpu (push) Has been cancelled
build container image / cuda (push) Has been cancelled
build container image / rocm (push) Has been cancelled
frontend checks / frontend-checks (push) Has been cancelled
frontend tests / frontend-tests (push) Has been cancelled
lfs checks / lfs-check (push) Has been cancelled
python checks / python-checks (push) Has been cancelled
python tests / py3.12: macos-default (push) Has been cancelled
python tests / py3.11: windows-cpu (push) Has been cancelled
python tests / py3.12: windows-cpu (push) Has been cancelled
python tests / py3.11: linux-cpu (push) Has been cancelled
typegen checks / typegen-checks (push) Has been cancelled
uv lock checks / uv-lock-checks (push) Has been cancelled
openapi checks / openapi-checks (push) Has been cancelled
python tests / py3.11: macos-default (push) Has been cancelled
python tests / py3.12: linux-cpu (push) Has been cancelled
docs / deploy (push) Has been cancelled
docs / changes (push) Has been cancelled
docs / check-and-build (push) Has been cancelled
build container image / cpu (push) Has been cancelled
build container image / cuda (push) Has been cancelled
build container image / rocm (push) Has been cancelled
frontend checks / frontend-checks (push) Has been cancelled
frontend tests / frontend-tests (push) Has been cancelled
lfs checks / lfs-check (push) Has been cancelled
python checks / python-checks (push) Has been cancelled
python tests / py3.12: macos-default (push) Has been cancelled
python tests / py3.11: windows-cpu (push) Has been cancelled
python tests / py3.12: windows-cpu (push) Has been cancelled
python tests / py3.11: linux-cpu (push) Has been cancelled
typegen checks / typegen-checks (push) Has been cancelled
uv lock checks / uv-lock-checks (push) Has been cancelled
openapi checks / openapi-checks (push) Has been cancelled
python tests / py3.11: macos-default (push) Has been cancelled
python tests / py3.12: linux-cpu (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
"""Tests for password utilities."""
|
||||
|
||||
from invokeai.app.services.auth.password_utils import hash_password, validate_password_strength, verify_password
|
||||
|
||||
|
||||
def test_hash_password():
|
||||
"""Test password hashing."""
|
||||
password = "TestPassword123"
|
||||
hashed = hash_password(password)
|
||||
|
||||
assert hashed != password
|
||||
assert len(hashed) > 0
|
||||
|
||||
|
||||
def test_verify_password():
|
||||
"""Test password verification."""
|
||||
password = "TestPassword123"
|
||||
hashed = hash_password(password)
|
||||
|
||||
assert verify_password(password, hashed)
|
||||
assert not verify_password("WrongPassword", hashed)
|
||||
|
||||
|
||||
def test_validate_password_strength_valid():
|
||||
"""Test password strength validation with valid passwords."""
|
||||
valid, msg = validate_password_strength("ValidPass123")
|
||||
assert valid
|
||||
assert msg == ""
|
||||
|
||||
|
||||
def test_validate_password_strength_too_short():
|
||||
"""Test password strength validation with short password."""
|
||||
valid, msg = validate_password_strength("Pass1")
|
||||
assert not valid
|
||||
assert "at least 8 characters" in msg
|
||||
|
||||
|
||||
def test_validate_password_strength_no_uppercase():
|
||||
"""Test password strength validation without uppercase."""
|
||||
valid, msg = validate_password_strength("password123")
|
||||
assert not valid
|
||||
assert "uppercase" in msg.lower()
|
||||
|
||||
|
||||
def test_validate_password_strength_no_lowercase():
|
||||
"""Test password strength validation without lowercase."""
|
||||
valid, msg = validate_password_strength("PASSWORD123")
|
||||
assert not valid
|
||||
assert "lowercase" in msg.lower()
|
||||
|
||||
|
||||
def test_validate_password_strength_no_digit():
|
||||
"""Test password strength validation without digit."""
|
||||
valid, msg = validate_password_strength("PasswordTest")
|
||||
assert not valid
|
||||
assert "number" in msg.lower()
|
||||
Reference in New Issue
Block a user