7a0da7932b
OSV-Scanner (Scheduled) / scan-scheduled (push) Failing after 0s
Create Release / test-gate (push) Has been cancelled
Create Release / release-gate (push) Has been cancelled
Create Release / ci-gate (push) Has been cancelled
Create Release / version-check (push) Has been cancelled
Create Release / e2e-test-gate (push) Has been cancelled
Create Release / responsive-test-gate (push) Has been cancelled
Create Release / compat-test-gate (push) Has been cancelled
Create Release / compose-integration-gate (push) Has been cancelled
Create Release / vulture-gate (push) Has been cancelled
Create Release / build (push) Has been cancelled
Create Release / provenance (push) Has been cancelled
Create Release / prerelease-docker (push) Has been cancelled
Create Release / publish-docker (push) Has been cancelled
Create Release / create-release (push) Has been cancelled
Create Release / cleanup-changelog (push) Has been cancelled
Create Release / trigger-pypi (push) Has been cancelled
Create Release / monitor-pypi (push) Has been cancelled
Create Release / Clean up orphan prerelease tags and signatures (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [research-form] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [research-metrics] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [research-workflow] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [settings-core] (push) Has been cancelled
CodeQL Advanced / Analyze (javascript-typescript) (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [history-news] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [library] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [link-analytics] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [chat-core] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [chat-lifecycle] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [error-benchmark] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [settings-pages] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) (push) Has been cancelled
Docker Tests (Consolidated) / Accessibility Tests (push) Has been cancelled
Docker Tests (Consolidated) / LLM Unit Tests (push) Has been cancelled
Docker Tests (Consolidated) / LLM Example Tests (push) Has been cancelled
Docker Tests (Consolidated) / Production Image Smoke Test (push) Has been cancelled
Docker Tests (Consolidated) / Infrastructure Tests (push) Has been cancelled
OSSF Scorecard / OSSF Security Scorecard Analysis (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [mobile] (push) Has been cancelled
Backwards Compatibility / Verify Encryption Constants (push) Has been cancelled
Backwards Compatibility / PyPI Version Compatibility (push) Has been cancelled
Backwards Compatibility / Database Migration Tests (push) Has been cancelled
CodeQL Advanced / Analyze (python) (push) Has been cancelled
Docker Tests (Consolidated) / detect-changes (push) Has been cancelled
Docker Tests (Consolidated) / Build Test Image (push) Has been cancelled
Docker Tests (Consolidated) / All Pytest Tests + Coverage (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [accessibility] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [api-crud] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [auth-login] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [auth-pages] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [auth-register] (push) Has been cancelled
59 lines
2.2 KiB
Python
59 lines
2.2 KiB
Python
"""Tests for password strength validation."""
|
|
|
|
from local_deep_research.security.password_validator import PasswordValidator
|
|
|
|
|
|
class TestPasswordValidator:
|
|
"""Unit tests for PasswordValidator.validate_strength."""
|
|
|
|
def test_valid_password(self):
|
|
errors = PasswordValidator.validate_strength("strongp4ss")
|
|
assert errors == []
|
|
|
|
def test_too_short(self):
|
|
errors = PasswordValidator.validate_strength("ab1")
|
|
assert any("8 characters" in e for e in errors)
|
|
|
|
def test_missing_lowercase(self):
|
|
errors = PasswordValidator.validate_strength("UPPERCASE1")
|
|
assert any("lowercase" in e for e in errors)
|
|
|
|
def test_missing_digit(self):
|
|
errors = PasswordValidator.validate_strength("nodigitshere")
|
|
assert any("digit" in e for e in errors)
|
|
|
|
def test_multiple_errors_for_weak_password(self):
|
|
errors = PasswordValidator.validate_strength("abc")
|
|
# Should flag: too short, no digit
|
|
assert len(errors) >= 2
|
|
|
|
def test_exactly_8_chars_valid(self):
|
|
errors = PasswordValidator.validate_strength("abcdef1x")
|
|
assert errors == []
|
|
|
|
def test_7_chars_invalid(self):
|
|
errors = PasswordValidator.validate_strength("abcde1x")
|
|
assert any("8 characters" in e for e in errors)
|
|
|
|
def test_special_chars_allowed(self):
|
|
errors = PasswordValidator.validate_strength("p@ssw0rd!")
|
|
assert errors == []
|
|
|
|
def test_very_long_password_valid(self):
|
|
errors = PasswordValidator.validate_strength("a1" + "a" * 200)
|
|
assert errors == []
|
|
|
|
def test_get_requirements_returns_non_empty_list(self):
|
|
reqs = PasswordValidator.get_requirements()
|
|
assert isinstance(reqs, list)
|
|
assert len(reqs) > 0
|
|
assert all(isinstance(r, str) for r in reqs)
|
|
|
|
def test_get_requirements_count_matches_validate_strength_checks(self):
|
|
"""The number of requirements should match the number of checks
|
|
in validate_strength (one error per check when all fail)."""
|
|
reqs = PasswordValidator.get_requirements()
|
|
# Empty string fails every check
|
|
errors = PasswordValidator.validate_strength("")
|
|
assert len(reqs) == len(errors)
|