Skip to content

Commit 2159046

Browse files
committed
disable and fix errors in test_rest_login_rate_limit
The test is testing functionality that doesn't yet exist. So disable for now. Also with tightening of origin checks in rev: 72a54826ff4f add origin header to options requests.
1 parent ce3441d commit 2159046

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

test/test_liveserver.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -616,18 +616,26 @@ def test_rest_endpoint_attribute_options(self):
616616

617617
self.assertEqual(f.status_code, 404)
618618

619-
def test_rest_login_rate_limit(self):
619+
def DISABLEtest_rest_login_rate_limit(self):
620620
"""login rate limit applies to api endpoints. Only failure
621621
logins count though. So log in 10 times in a row
622622
to verify that valid username/passwords aren't limited.
623+
624+
FIXME: client.py does not implement this. Also need a live
625+
server instance that has
626+
627+
cls.db.config.WEB_LOGIN_ATTEMPTS_MIN = 4
628+
629+
not 0.
623630
"""
624631

625632
for i in range(10):
626633
# use basic auth for rest endpoint
627634

628635
f = requests.options(self.url_base() + '/rest/data',
629636
auth=('admin', 'sekrit'),
630-
headers = {'content-type': ""}
637+
headers = {'content-type': "",
638+
'Origin': "http://localhost:9001",}
631639
)
632640
print(f.status_code)
633641
print(f.headers)
@@ -645,13 +653,17 @@ def test_rest_login_rate_limit(self):
645653

646654
f = requests.options(self.url_base() + '/rest/data',
647655
auth=('admin', 'ekrit'),
648-
headers = {'content-type': ""}
656+
headers = {'content-type': "",
657+
'Origin': "http://localhost:9001",}
649658
)
650659
print(i, f.status_code)
651660
print(f.headers)
652661
print(f.text)
653662

654-
self.assertEqual(f.status_code, 401)
663+
if (i < 3): # assuming limit is 4.
664+
self.assertEqual(f.status_code, 401)
665+
else:
666+
self.assertEqual(f.status_code, 429)
655667

656668
def test_ims(self):
657669
''' retreive the user_utils.js file with old and new

0 commit comments

Comments
 (0)