Beispiel #1
0
 def test_decrypt_dict_invalid_key(self):
     data = {'p1': u'happy', '2': [u'a', u'little', u'blue'], '6': 7}
     encrypted_data = crypt.encrypted_dict(
         data, '767c3ed056cbaa3b9dfedb8c6f825bf0')
     ex = self.assertRaises(exception.InvalidEncryptionKey,
                            crypt.decrypted_dict, encrypted_data,
                            '767c3ed056cbaa3b9dfedb8c6f825bf1')
     self.assertEqual(
         'Can not decrypt data with the auth_encryption_key '
         'in heat config.', str(ex))
Beispiel #2
0
 def test_decrypt_dict_invalid_key(self):
     data = {'p1': u'happy',
             '2': [u'a', u'little', u'blue'],
             '6': 7}
     encrypted_data = crypt.encrypted_dict(
         data, '767c3ed056cbaa3b9dfedb8c6f825bf0')
     ex = self.assertRaises(exception.InvalidEncryptionKey,
                            crypt.decrypted_dict,
                            encrypted_data,
                            '767c3ed056cbaa3b9dfedb8c6f825bf1')
     self.assertEqual('Can not decrypt data with the auth_encryption_key '
                      'in heat config.',
                      six.text_type(ex))
Beispiel #3
0
    def _test_encrypt_decrypt_dict(self, encryption_key=None):
        data = {'p1': u'happy',
                '2': [u'a', u'little', u'blue'],
                'p3': {u'really': u'exited', u'ok int': 9},
                '4': u'',
                'p5': True,
                '6': 7}
        encrypted_data = crypt.encrypted_dict(data, encryption_key)
        for k in encrypted_data:
            self.assertEqual('cryptography_decrypt_v1',
                             encrypted_data[k][0])
            self.assertEqual(2, len(encrypted_data[k]))
        # the keys remain the same
        self.assertEqual(set(data), set(encrypted_data))

        decrypted_data = crypt.decrypted_dict(encrypted_data, encryption_key)
        self.assertEqual(data, decrypted_data)
Beispiel #4
0
    def _test_encrypt_decrypt_dict(self, encryption_key=None):
        data = {'p1': u'happy',
                '2': [u'a', u'little', u'blue'],
                'p3': {u'really': u'exited', u'ok int': 9},
                '4': u'',
                'p5': True,
                '6': 7}
        encrypted_data = crypt.encrypted_dict(data, encryption_key)
        for k in encrypted_data:
            self.assertEqual('cryptography_decrypt_v1',
                             encrypted_data[k][0])
            self.assertEqual(2, len(encrypted_data[k]))
        # the keys remain the same
        self.assertEqual(set(data), set(encrypted_data))

        decrypted_data = crypt.decrypted_dict(encrypted_data, encryption_key)
        self.assertEqual(data, decrypted_data)
Beispiel #5
0
 def encrypt_properties_data(data):
     if cfg.CONF.encrypt_parameters_and_properties and data:
         result = crypt.encrypted_dict(data)
         return (True, result)
     return (False, data)
Beispiel #6
0
 def encrypt_properties_data(data):
     if cfg.CONF.encrypt_parameters_and_properties and data:
         result = crypt.encrypted_dict(data)
         return (True, result)
     return (False, data)