diff 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
line wrap: on
line diff
--- a/test/test_config.py	Tue Jul 18 23:18:09 2023 -0400
+++ b/test/test_config.py	Wed Jul 19 20:37:45 2023 -0400
@@ -301,6 +301,31 @@
        self.assertEqual("3", 
             config._get_option('WEB_LOGIN_ATTEMPTS_MIN')._value2str(3.00))
 
+    def testIntegerNumberGtZeroOption(self):
+
+       config = configuration.CoreConfig()
+
+       # Update existing IntegerNumberGeqZeroOption to IntegerNumberOption
+       config.update_option('WEB_LOGIN_ATTEMPTS_MIN',
+                            configuration.IntegerNumberGtZeroOption,
+                            "1", description="new desc")
+
+       self.assertEqual(None,
+                    config._get_option('WEB_LOGIN_ATTEMPTS_MIN').set("1"))
+
+       # -1 is not allowed
+       self.assertRaises(configuration.OptionValueError,
+                    config._get_option('WEB_LOGIN_ATTEMPTS_MIN').set, "-1")
+
+       # but can't float this
+       self.assertRaises(configuration.OptionValueError,
+                    config._get_option('WEB_LOGIN_ATTEMPTS_MIN').set, "2.4")
+
+       # but can't float this
+       self.assertRaises(configuration.OptionValueError,
+                    config._get_option('WEB_LOGIN_ATTEMPTS_MIN').set, "0.5")
+
+
     def testOriginHeader(self):
         config = configuration.CoreConfig()
 

Roundup Issue Tracker: http://roundup-tracker.org/