Skip to content

Commit 41c95f0

Browse files
committed
Fix anti_csrf_nonce test
Make the MockDatabase inherit from roundup.backends.sessions_common SessionCommon. This provides the getUniqueKey method. Also the encoding as base64 changed the length, so had to adjust the assert.
1 parent 3dbb734 commit 41c95f0

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

test/test_templating.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@
4242

4343
from roundup.anypy.strings import u2s, s2u
4444

45-
class MockDatabase(MockNull):
45+
from roundup.backends.sessions_common import SessionCommon
46+
47+
class MockDatabase(MockNull, SessionCommon):
4648
def getclass(self, name):
4749
# limit class names
4850
if name not in [ 'issue', 'user', 'status' ]:
@@ -244,7 +246,7 @@ def test_anti_csrf_nonce(self):
244246
'''call the csrf creation function and do basic length test
245247
246248
Store the data in a mock db with the same api as the otk
247-
db. Make sure nonce is 64 chars long. Lookup the nonce in
249+
db. Make sure nonce is 54 chars long. Lookup the nonce in
248250
db and retrieve data. Verify that the nonce lifetime is
249251
correct (within 1 second of 1 week - lifetime), the uid is
250252
correct (1), the dummy sid is correct.
@@ -280,7 +282,7 @@ def test_anti_csrf_nonce(self):
280282
# see above for web nonce lifetime.
281283
greater_than = week_seconds - 10 * 60
282284

283-
self.assertEqual(len(nonce1), 64)
285+
self.assertEqual(len(nonce1), 54)
284286

285287
uid = otks.get(nonce1, 'uid', default=None)
286288
sid = otks.get(nonce1, 'sid', default=None)

0 commit comments

Comments
 (0)