Mercurial > p > roundup > code
diff test/test_templating.py @ 6826:28b906a237d8
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.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Sun, 07 Aug 2022 04:18:20 -0400 |
| parents | 38b73f7495f8 |
| children | 234fefd7568a |
line wrap: on
line diff
--- a/test/test_templating.py Sun Aug 07 03:33:35 2022 -0400 +++ b/test/test_templating.py Sun Aug 07 04:18:20 2022 -0400 @@ -42,7 +42,9 @@ from roundup.anypy.strings import u2s, s2u -class MockDatabase(MockNull): +from roundup.backends.sessions_common import SessionCommon + +class MockDatabase(MockNull, SessionCommon): def getclass(self, name): # limit class names if name not in [ 'issue', 'user', 'status' ]: @@ -244,7 +246,7 @@ '''call the csrf creation function and do basic length test Store the data in a mock db with the same api as the otk - db. Make sure nonce is 64 chars long. Lookup the nonce in + db. Make sure nonce is 54 chars long. Lookup the nonce in db and retrieve data. Verify that the nonce lifetime is correct (within 1 second of 1 week - lifetime), the uid is correct (1), the dummy sid is correct. @@ -280,7 +282,7 @@ # see above for web nonce lifetime. greater_than = week_seconds - 10 * 60 - self.assertEqual(len(nonce1), 64) + self.assertEqual(len(nonce1), 54) uid = otks.get(nonce1, 'uid', default=None) sid = otks.get(nonce1, 'sid', default=None)
