Mercurial > p > roundup > code
comparison test/test_config.py @ 7556:273c8c2b5042
fix(api): - issue2551063 - Rest/Xmlrpc interfaces needs failed login protection.
Failed API login rate limiting with expiring lockout added.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Wed, 19 Jul 2023 20:37:45 -0400 |
| parents | 89a59e46b3af |
| children | a5629f6e7ec2 |
comparison
equal
deleted
inserted
replaced
| 7555:451232f83244 | 7556:273c8c2b5042 |
|---|---|
| 299 config._get_option('WEB_LOGIN_ATTEMPTS_MIN').set("3.0")) | 299 config._get_option('WEB_LOGIN_ATTEMPTS_MIN').set("3.0")) |
| 300 | 300 |
| 301 self.assertEqual("3", | 301 self.assertEqual("3", |
| 302 config._get_option('WEB_LOGIN_ATTEMPTS_MIN')._value2str(3.00)) | 302 config._get_option('WEB_LOGIN_ATTEMPTS_MIN')._value2str(3.00)) |
| 303 | 303 |
| 304 def testIntegerNumberGtZeroOption(self): | |
| 305 | |
| 306 config = configuration.CoreConfig() | |
| 307 | |
| 308 # Update existing IntegerNumberGeqZeroOption to IntegerNumberOption | |
| 309 config.update_option('WEB_LOGIN_ATTEMPTS_MIN', | |
| 310 configuration.IntegerNumberGtZeroOption, | |
| 311 "1", description="new desc") | |
| 312 | |
| 313 self.assertEqual(None, | |
| 314 config._get_option('WEB_LOGIN_ATTEMPTS_MIN').set("1")) | |
| 315 | |
| 316 # -1 is not allowed | |
| 317 self.assertRaises(configuration.OptionValueError, | |
| 318 config._get_option('WEB_LOGIN_ATTEMPTS_MIN').set, "-1") | |
| 319 | |
| 320 # but can't float this | |
| 321 self.assertRaises(configuration.OptionValueError, | |
| 322 config._get_option('WEB_LOGIN_ATTEMPTS_MIN').set, "2.4") | |
| 323 | |
| 324 # but can't float this | |
| 325 self.assertRaises(configuration.OptionValueError, | |
| 326 config._get_option('WEB_LOGIN_ATTEMPTS_MIN').set, "0.5") | |
| 327 | |
| 328 | |
| 304 def testOriginHeader(self): | 329 def testOriginHeader(self): |
| 305 config = configuration.CoreConfig() | 330 config = configuration.CoreConfig() |
| 306 | 331 |
| 307 with self.assertRaises(configuration.OptionValueError) as cm: | 332 with self.assertRaises(configuration.OptionValueError) as cm: |
| 308 config._get_option('WEB_ALLOWED_API_ORIGINS').set("https://foo.edu *") | 333 config._get_option('WEB_ALLOWED_API_ORIGINS').set("https://foo.edu *") |
