예제 #1
0
 def test_modified_cookie(self):
     dct = {'a': 'asdfsafdsdf', 'id': 4}
     name = 'somevalue'
     sign = SignDct(name, dct)
     sign.execute()
     self.assertIsNotNone(sign.result)
     retrieve = RetrieveDct(name, sign.result[1:], 100)
     retrieve.execute()
     self.assertIsNone(retrieve.result)
예제 #2
0
 def test_sign_and_retrive(self):
     dct = {'a': 'asdfsafdsdf', 'id': 4}
     name = 'somevalue'
     sign = SignDct(name, dct)
     sign.execute()
     self.assertIsNotNone(sign.result)
     retrieve = RetrieveDct(name, sign.result, 100)
     retrieve.execute()
     self.assertDictEqual(dct, retrieve.result)
예제 #3
0
 def test_sign_and_retrive(self):
     dct = {'a': 'asdfsafdsdf', 'id': 4}
     name = 'somevalue'
     sign = SignDct(name, dct)
     sign.execute()
     self.assertIsNotNone(sign.result)
     retrieve = RetrieveDct(name, sign.result, 100)
     retrieve.execute()
     self.assertDictEqual(dct, retrieve.result)
예제 #4
0
 def test_modified_cookie(self):
     dct = {'a': 'asdfsafdsdf', 'id': 4}
     name = 'somevalue'
     sign = SignDct(name, dct)
     sign.execute()
     self.assertIsNotNone(sign.result)
     retrieve = RetrieveDct(name, sign.result[1:], 100)
     retrieve.execute()
     self.assertIsNone(retrieve.result)
예제 #5
0
 def test_expired(self):
     dct = {'a': 'asdfsafdsdf', 'id': 4}
     name = 'somevalue'
     sign = SignDct(name, dct)
     sign.execute()
     self.assertIsNotNone(sign.result)
     retrieve = RetrieveDct(name, sign.result, 1)
     time.sleep(2)
     retrieve.execute()
     self.assertIsNone(retrieve.result)
예제 #6
0
 def test_expired(self):
     dct = {'a': 'asdfsafdsdf', 'id': 4}
     name = 'somevalue'
     sign = SignDct(name, dct)
     sign.execute()
     self.assertIsNotNone(sign.result)
     retrieve = RetrieveDct(name, sign.result, 1)
     time.sleep(2)
     retrieve.execute()
     self.assertIsNone(retrieve.result)
예제 #7
0
def retrieve_dct(name, signed, max_age=604800):
    '''
    Returns the dct on result contained on the signed string coded if it is valid.
     The content can be invalid by someone trying to fake it or because it is above mas age.
     max_age in seconds. Default seven days
    '''
    return RetrieveDct(name, signed, max_age)