Rate-limit report ingestion per host
Reports arriving sooner than report_min_interval_seconds (default 30) after the host's previous one are refused with 429 and a Retry-After header. The check shares the insert's transaction so concurrent requests can't bypass it. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
8cb7ef5e8b
commit
a6a43b142f
6 files changed
+71
-3
No files matched your search
@@ -67,6 +67,14 @@ class ConfigTest(unittest.TestCase):
|
||||
with self.assertRaises(SystemExit):
|
||||
config.load(self.write(tmp, "secure_cookies = 1\n"))
|
||||
|
||||
def test_report_min_interval_validated(self):
|
||||
with tempdir() as tmp:
|
||||
self.assertEqual(config.load(self.write(tmp, "report_min_interval_seconds = 0\n"))
|
||||
.report_min_interval_seconds, 0)
|
||||
for bad in ("-1", "1.5", '"30"'):
|
||||
with self.subTest(bad=bad), self.assertRaises(SystemExit):
|
||||
config.load(self.write(tmp, f"report_min_interval_seconds = {bad}\n"))
|
||||
|
||||
def test_status_alert_hours_validated(self):
|
||||
with tempdir() as tmp:
|
||||
self.assertEqual(config.load(self.write(tmp, "status_alert_after_hours = 0\n"))
|
||||
|
||||
Reference in new issue
Block a user