Ejemplo n.º 1
0
 def test_modified_cookie(self):
     dct = {'a': 'asdfsafdsdf', 'id': 4}
     name = 'somevalue'
     sign = SignCmd(name, dct)
     sign.execute()
     self.assertIsNotNone(sign.result)
     retrieve = RetrieveCmd(name, sign.result[1:], 100)
     retrieve.execute()
     self.assertIsNone(retrieve.result)
Ejemplo n.º 2
0
 def test_sign_and_retrive(self):
     dct = {'a': 'asdfsafdsdf', 'id': 4}
     name = 'somevalue'
     sign = SignCmd(name, dct)
     sign.execute()
     self.assertIsNotNone(sign.result)
     retrieve = RetrieveCmd(name, sign.result, 100)
     retrieve.execute()
     self.assertDictEqual(dct, retrieve.result)
Ejemplo n.º 3
0
 def test_expired(self):
     dct = {'a': 'asdfsafdsdf', 'id': 4}
     name = 'somevalue'
     sign = SignCmd(name, dct)
     sign.execute()
     self.assertIsNotNone(sign.result)
     retrieve = RetrieveCmd(name, sign.result, 1)
     time.sleep(2)
     retrieve.execute()
     self.assertIsNone(retrieve.result)
Ejemplo n.º 4
0
def retrieve(name, signed, max_age=604800):
    '''
    Returns the obj on result contained on the signed json string coded if it is valid.
     The content can be invalid by someone trying to fake it or because it is above max age.
     max_age in seconds. Default seven days
    '''
    return RetrieveCmd(name, signed, max_age)