示例#1
0
 def rekey_setup(self):
     self.crusher.store_identity_info(self.US, 'nothing-enforced',
                                      {'name': 'Crusher'})
     self.db.run(
         "UPDATE participant_identities "
         "SET _info_last_keyed=_info_last_keyed - '6 months'::interval")
     old_key = str(self.client.website.env.crypto_keys)
     return EncryptingPacker(Fernet.generate_key(), old_key)
示例#2
0
 def test_can_unpack_if_old_key_is_provided(self):
     old_key = str(self.client.website.env.crypto_keys)
     encrypting_packer = EncryptingPacker(Fernet.generate_key(), old_key)
     assert encrypting_packer.unpack(self.packed) == {"foo": "bar"}
示例#3
0
 def test_fails_to_unpack_old_data_with_a_new_key(self):
     encrypting_packer = EncryptingPacker(Fernet.generate_key())
     raises(InvalidToken, encrypting_packer.unpack, self.packed)
示例#4
0
def crypto(env):
    keys = [k.encode('ASCII') for k in env.crypto_keys.split()]
    out = Identity.encrypting_packer = EncryptingPacker(*keys)
    return out
 def test_ep_can_unpack_if_old_key_is_provided(self):
     old_key = str(self.client.website.env.crypto_keys)
     encrypting_packer = EncryptingPacker(Fernet.generate_key(), old_key)
     assert encrypting_packer.unpack(self.packed) == {"foo": "bar"}