Beispiel #1
0
    def test_decrypt_invalid_key_msg(self):
        msg = 'test-string'
        msg_encrypted, key = utils.encrypt(msg)

        invalid_key = 'fake-key'
        self.assertRaises(fernet.InvalidToken, utils.decrypt, msg_encrypted,
                          invalid_key)

        invalid_msg = 'fake-msg'
        self.assertRaises(ValueError, utils.decrypt, invalid_msg, key)

        invalid_msg = fernet.Fernet.generate_key()
        self.assertRaises(fernet.InvalidToken, utils.decrypt, invalid_msg, key)
Beispiel #2
0
    def test_decrypt_invalid_key_msg(self):
        msg = 'test-string'
        msg_encrypted, key = utils.encrypt(msg)

        invalid_key = 'fake-key'
        self.assertRaises(fernet.InvalidToken, utils.decrypt,
                          msg_encrypted, invalid_key)

        invalid_msg = 'fake-msg'
        self.assertRaises(ValueError, utils.decrypt,
                          invalid_msg, key)

        invalid_msg = fernet.Fernet.generate_key()
        self.assertRaises(fernet.InvalidToken, utils.decrypt,
                          invalid_msg, key)
Beispiel #3
0
 def encrypt_credential(self):
     cipher, key = utils.encrypt(self.credential)
     self.credential = cipher
     return key
Beispiel #4
0
    def test_decrypt(self):
        msg = 'test-string'
        msg_encrypted, key = utils.encrypt(msg)

        msg_decrypted = utils.decrypt(msg_encrypted, key)
        self.assertEqual(msg, msg_decrypted)
Beispiel #5
0
    def test_encrypt(self):
        msg = 'test-string'
        msg_encrypted, key = utils.encrypt(msg)

        self.assertIsInstance(msg_encrypted, six.string_types)
        self.assertIsInstance(key, six.string_types)
Beispiel #6
0
 def encrypt_credential(self):
     cipher, key = utils.encrypt(self.credential)
     self.credential = cipher
     return key
Beispiel #7
0
    def test_decrypt(self):
        msg = 'test-string'
        msg_encrypted, key = utils.encrypt(msg)

        msg_decrypted = utils.decrypt(msg_encrypted, key)
        self.assertEqual(msg, msg_decrypted)
Beispiel #8
0
    def test_encrypt(self):
        msg = 'test-string'
        msg_encrypted, key = utils.encrypt(msg)

        self.assertIsInstance(msg_encrypted, six.string_types)
        self.assertIsInstance(key, six.string_types)