mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-03 01:40:21 +08:00
feat: Provider 异步删除、可配置密码策略、Hub 超时优化及多项改进
- 新增 Provider 异步删除任务系统,后台分阶段删除子资源并清理残留引用 - 新增可配置密码策略等级(weak/medium/strong),支持系统设置面板调整 - aether-hub 升级至 0.1.4,idle timeout 支持禁用(设为 0),worker 默认超时调整为 120s - OAuth 手动续期增加 Redis 分布式锁,防止并发刷新冲突 - ProxyNode 心跳检测改为 asyncio.to_thread,避免阻塞事件循环 - 删除 ModelMultiSelect 和 useInvalidModels,MultiSelect 组件通用化 - 明确 allowed_providers/allowed_api_formats 的 NULL 与空数组语义 - 前端 StandaloneKeyFormDialog、UserFormDialog 等多处 UI 优化 - 新增 Alembic 迁移脚本清理 Provider 删除后的残留引用 - 补充相关测试用例
This commit is contained in:
54
tests/unit/test_password_policy.py
Normal file
54
tests/unit/test_password_policy.py
Normal file
@@ -0,0 +1,54 @@
|
||||
import pytest
|
||||
|
||||
from src.core.validators import PasswordPolicyLevel, PasswordValidator
|
||||
|
||||
|
||||
class TestPasswordPolicy:
|
||||
def test_default_policy_is_weak(self) -> None:
|
||||
valid, error = PasswordValidator.validate("123456")
|
||||
|
||||
assert valid is True
|
||||
assert error is None
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("password", "expected_error"),
|
||||
[
|
||||
("1234567", "密码长度至少为8个字符"),
|
||||
("12345678", "密码必须包含至少一个字母"),
|
||||
("abcdefgh", "密码必须包含至少一个数字"),
|
||||
],
|
||||
)
|
||||
def test_medium_policy_rejects_weak_patterns(self, password: str, expected_error: str) -> None:
|
||||
valid, error = PasswordValidator.validate(password, policy=PasswordPolicyLevel.MEDIUM)
|
||||
|
||||
assert valid is False
|
||||
assert error == expected_error
|
||||
|
||||
def test_medium_policy_accepts_letters_and_digits(self) -> None:
|
||||
valid, error = PasswordValidator.validate("abc12345", policy=PasswordPolicyLevel.MEDIUM)
|
||||
|
||||
assert valid is True
|
||||
assert error is None
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("password", "expected_error"),
|
||||
[
|
||||
("abc12345", "密码必须包含至少一个大写字母"),
|
||||
("ABC12345", "密码必须包含至少一个小写字母"),
|
||||
("Abcdefgh", "密码必须包含至少一个数字"),
|
||||
("Abcd1234", "密码必须包含至少一个特殊字符"),
|
||||
],
|
||||
)
|
||||
def test_strong_policy_requires_upper_lower_and_digit(
|
||||
self, password: str, expected_error: str
|
||||
) -> None:
|
||||
valid, error = PasswordValidator.validate(password, policy=PasswordPolicyLevel.STRONG)
|
||||
|
||||
assert valid is False
|
||||
assert error == expected_error
|
||||
|
||||
def test_strong_policy_accepts_mixed_password(self) -> None:
|
||||
valid, error = PasswordValidator.validate("Abcd1234!", policy="strong")
|
||||
|
||||
assert valid is True
|
||||
assert error is None
|
||||
Reference in New Issue
Block a user