Ejemplo n.º 1
0
    def test_load_config_SHA512_oaep_padding_algorithm(self):
        oaep_algo_test = "sha-512"
        json_conf = json.loads(self._test_config_file)
        json_conf["oaepPaddingDigestAlgorithm"] = oaep_algo_test

        conf = to_test.FieldLevelEncryptionConfig(json_conf)
        self.__check_configuration(conf, oaep_algo="SHA512")
Ejemplo n.º 2
0
    def test_load_config_with_key_password(self):
        json_conf = json.loads(self._test_config_file)
        json_conf["decryptionKey"] = resource_path("keys/test_key.p12")
        json_conf["decryptionKeyPassword"] = "******"

        conf = to_test.FieldLevelEncryptionConfig(json_conf)
        self.assertIsNotNone(conf.decryption_key, "No key password set")
Ejemplo n.º 3
0
    def test_load_config_missing_optional_param(self):
        json_conf = json.loads(self._test_config_file)
        del json_conf["encryptionCertificateFingerprintFieldName"]

        conf = to_test.FieldLevelEncryptionConfig(json_conf)

        self.assertIsNotNone(conf.encryption_certificate_fingerprint)  # fingerprint is always calculated
        self.assertIsNone(conf.encryption_certificate_fingerprint_field_name)
Ejemplo n.º 4
0
    def test_load_config_missing_encryption_certificate(self):
        json_conf = json.loads(self._test_config_file)
        del json_conf["encryptionCertificate"]

        conf = to_test.FieldLevelEncryptionConfig(json_conf)
        self.assertIsNone(conf.encryption_certificate)
        self.assertIsNone(conf.encryption_certificate_fingerprint)
        self.assertIsNone(conf.encryption_key_fingerprint)
 def __init__(self,
              configuration=None,
              header_name=None,
              header_value=None,
              cookie=None):
     json_config = json.loads(get_config_for_test())
     json_config["paths"]["$"]["toEncrypt"] = {"data": "encryptedData"}
     json_config["paths"]["$"]["toDecrypt"] = {"encryptedData": "data"}
     self._config = encryption_config.FieldLevelEncryptionConfig(
         json_config)
Ejemplo n.º 6
0
    def test_load_config_as_json(self):
        json_conf = json.loads(self._test_config_file)

        conf = to_test.FieldLevelEncryptionConfig(json_conf)
        self.__check_configuration(conf)
Ejemplo n.º 7
0
 def test_load_config_as_string(self):
     conf = to_test.FieldLevelEncryptionConfig(self._test_config_file)
     self.__check_configuration(conf)
Ejemplo n.º 8
0
    def test_load_config_missing_decryption_key(self):
        json_conf = json.loads(self._test_config_file)
        del json_conf["decryptionKey"]

        conf = to_test.FieldLevelEncryptionConfig(json_conf)
        self.assertIsNone(conf.decryption_key)
Ejemplo n.º 9
0
    def test_load_config_hex_data_encoding(self):
        json_conf = json.loads(self._test_config_file)
        json_conf["dataEncoding"] = "hex"

        conf = to_test.FieldLevelEncryptionConfig(json_conf)
        self.__check_configuration(conf, encoding=Encoding.HEX)