changeset 604:6b926426e3d2 pytest2

added test to check the stamp value in valid_token in util/crypto.py
author pkumar <contactprashantat@gmail.com>
date Thu, 30 Jun 2011 23:33:58 +0530
parents 7fe35e3453a6
children 04b90498ea47
files MoinMoin/util/_tests/test_crypto.py
diffstat 1 files changed, 9 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/util/_tests/test_crypto.py	Wed Jun 29 16:40:04 2011 +0530
+++ b/MoinMoin/util/_tests/test_crypto.py	Thu Jun 30 23:33:58 2011 +0530
@@ -74,9 +74,16 @@
         test_key, test_token = crypto.generate_token() # key value is none
         result = crypto.valid_token(test_key, test_token)
         assert result
+        
+        test_parts = test_token.split('-')
+        test_parts[0] = 'not_valid'
+        # changed value of the first part, should not be string
+        test_token_changed = '-'.join(test_parts)
+        result = crypto.valid_token(test_key, test_token_changed)
+        assert result == False
 
-        key, token = 'MoinMoin', 'incorrect_token'
-        result = crypto.valid_token(key, token)
+        test_key, test_token = 'MoinMoin', 'incorrect_token'
+        result = crypto.valid_token(test_key, test_token)
         assert result == False
 
     def testcache_key(self):