\Tests\FeatureLoginThrottleTest

登录锁定指数退避

被测对象:LoginThrottleService(直连 Redis db0,Mockery mock 阈值) 守护约定:首次锁定基础时长、重复锁定指数退避、成功登录重置锁级、注册表缺行限流照常可用、 失败窗口与单次锁定封顶由配置驱动。

Summary

Methods
Properties
Constants
test_first_lockout_uses_base_duration()
test_repeated_lockouts_escalate_duration()
test_successful_login_resets_lock_level()
test_throttle_works_when_registry_rows_missing()
test_failure_window_driven_by_config()
test_lock_cap_driven_by_config()
No public properties found
No constants found
requireRedis()
buildCacheRegistry()
setUp()
tearDown()
No protected properties found
N/A
No private methods found
$username
$ip
N/A

Properties

$username

$username : string

Type

string

$ip

$ip : string

Type

string

Methods

test_first_lockout_uses_base_duration()

test_first_lockout_uses_base_duration() : void

验证首次锁定使用基础时长(15 分钟档)。

test_repeated_lockouts_escalate_duration()

test_repeated_lockouts_escalate_duration() : void

验证重复锁定指数退避(第二轮时长翻倍)。

test_successful_login_resets_lock_level()

test_successful_login_resets_lock_level() : void

验证成功登录(clear)重置锁级。

test_throttle_works_when_registry_rows_missing()

test_throttle_works_when_registry_rows_missing() : void

验证注册表缺行时限流链路照常可用(自动登记/临时模板兜底)。

test_failure_window_driven_by_config()

test_failure_window_driven_by_config() : void

失败计数窗口由 auth.login_failure_window_seconds 配置驱动(默认 3600 行为不变)

test_lock_cap_driven_by_config()

test_lock_cap_driven_by_config() : void

单次锁定封顶由 auth.login_max_lock_hours 配置驱动(默认 24h 行为不变)

requireRedis()

requireRedis() : void

Redis 依赖探针:直连 Redis 的测试(限流/会话/验证码)在无 Redis 环境(如 CI) 跳过而非失败——其余用例不受影响。CI 可设 TEST_REQUIRE_REDIS=1 强制模式: Redis 不可达即失败而非跳过,安全回归套件不允许静默消失。

buildCacheRegistry()

buildCacheRegistry(array  $items) : void

建缓存注册表最小 schema(td_sys_cache)并灌入注册项。

测试跑 sqlite :memory:,生产迁移含 PostgreSQL 专属 DDL 跑不通(DataScopeServiceTest 同因自建 schema); 而 CacheManager::registry() 现已从数据库表读取——凡走注册表的测试(remember/get/key/失效推导) 必须在 setUp 先调用本方法,否则注册表为空、remember 未登记名会走「自动登记」路径。

Parameters

array $items

setUp()

setUp() : void

tearDown()

tearDown() : void