Add mid-session quota enforcement with 6 tests
New enforcer.rs module runs alongside active tests: - Periodic quota checks (default every 10s, configurable --quota-check-interval) - Max duration enforcement — forcefully stops test after limit - User quotas: daily/weekly/monthly checked against DB + current session - IP quotas: daily/weekly/monthly checked against DB + current session - Flush session bytes to DB for accurate cross-session tracking - Sets state.running=false to gracefully terminate on quota breach StopReason enum tracks why a test was stopped: MaxDuration, UserDailyQuota, UserWeeklyQuota, UserMonthlyQuota, IpDailyQuota, IpWeeklyQuota, IpMonthlyQuota, ClientDisconnected Tests (6 new, all passing): - test_enforcer_max_duration: stops after max_duration seconds - test_enforcer_client_disconnect: detects normal client exit - test_enforcer_user_daily_quota_exceeded: stops when user quota hit - test_enforcer_ip_daily_quota_exceeded: stops when IP quota hit - test_enforcer_under_quota_runs_normally: doesn't stop if under limits - test_enforcer_flush_records_usage: verifies DB persistence 64 total tests (58 standard + 6 enforcer), all passing. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
|
||||
mod user_db;
|
||||
mod quota;
|
||||
mod enforcer;
|
||||
mod ldap_auth;
|
||||
|
||||
use clap::Parser;
|
||||
@@ -86,6 +87,10 @@ struct Cli {
|
||||
#[arg(long = "max-duration", default_value_t = 300)]
|
||||
max_duration: u64,
|
||||
|
||||
/// How often to check quotas during a test in seconds
|
||||
#[arg(long = "quota-check-interval", default_value_t = 10)]
|
||||
quota_check_interval: u64,
|
||||
|
||||
/// Use EC-SRP5 authentication
|
||||
#[arg(long = "ecsrp5")]
|
||||
ecsrp5: bool,
|
||||
|
||||
Reference in New Issue
Block a user