def test_add_header_encryption_layer_post_no_oaep_algo(self):
        self._set_header_params_config()
        del self._json_config["oaepPaddingDigestAlgorithmFieldName"]

        secret1 = 435
        secret2 = 746
        test_client = MockApiClient()
        to_test.add_encryption_layer(test_client, self._json_config)
        response = MockService(test_client).do_something_post_use_headers(
            body={
                "data": {
                    "secret1": secret1,
                    "secret2": secret2
                },
                "encryptedData": {}
            },
            headers={"Content-Type": "application/json"})

        self.assertIn("data", json.loads(response.data))
        self.assertIn("secret", json.loads(response.data)["data"])
        self.assertEqual(secret2 - secret1,
                         json.loads(response.data)["data"]["secret"])
        self.assertDictEqual(
            {
                "Content-Type": "application/json",
                "x-oaep-digest": "SHA256"
            }, response.getheaders())
Exemplo n.º 2
0
    def test_add_encryption_layer_get(self):
        test_client = MockApiClient()
        to_test.add_encryption_layer(test_client, self._json_config)
        response = MockService(test_client).do_something_get(
            headers={"Content-Type": "application/json"})

        self.assertIn("data", response.data)
        self.assertIn("secret", response.data["data"])
        self.assertEqual([53, 84, 75], response.data["data"]["secret"])
        self.assertDictEqual({"Content-Type": "application/json"},
                             response.getheaders())
    def test_add_encryption_layer_delete(self):
        secret1 = 394
        secret2 = 394
        test_client = MockApiClient()
        to_test.add_encryption_layer(test_client, self._json_config)
        response = MockService(test_client).do_something_delete(
            body={"data": {
                "secret1": secret1,
                "secret2": secret2
            }},
            headers={"Content-Type": "application/json"})

        self.assertEqual("OK", json.loads(response.data))
        self.assertDictEqual({"Content-Type": "application/json"},
                             response.getheaders())
Exemplo n.º 4
0
    def test_add_encryption_layer_post(self):
        secret1 = 435
        secret2 = 746
        test_client = MockApiClient()
        to_test.add_encryption_layer(test_client, self._json_config)
        response = MockService(test_client).do_something_post(
            body={"data": {
                "secret1": secret1,
                "secret2": secret2
            }},
            headers={"Content-Type": "application/json"})

        self.assertIn("data", response.data)
        self.assertIn("secret", response.data["data"])
        self.assertEqual(secret2 - secret1, response.data["data"]["secret"])
        self.assertDictEqual({"Content-Type": "application/json"},
                             response.getheaders())
    def test_add_header_encryption_layer_delete(self):
        self._set_header_params_config()

        secret1 = 783
        secret2 = 783
        test_client = MockApiClient()
        to_test.add_encryption_layer(test_client, self._json_config)
        response = MockService(test_client).do_something_delete_use_headers(
            body={
                "data": {
                    "secret1": secret1,
                    "secret2": secret2
                },
                "encryptedData": {}
            },
            headers={"Content-Type": "application/json"})

        self.assertEqual("OK", response.data)
        self.assertDictEqual({"Content-Type": "application/json"},
                             response.getheaders())
    def test_add_header_encryption_layer_post(self):
        self._set_header_params_config()

        secret1 = 445
        secret2 = 497
        test_client = MockApiClient()
        to_test.add_encryption_layer(test_client, self._json_config)
        response = MockService(test_client).do_something_post_use_headers(
            body={
                "data": {
                    "secret1": secret1,
                    "secret2": secret2
                },
                "encryptedData": {}
            },
            headers={"Content-Type": "application/json"})

        self.assertIn("data", json.loads(response.data))
        self.assertIn("secret", json.loads(response.data)["data"])
        self.assertEqual(secret2 - secret1,
                         json.loads(response.data)["data"]["secret"])
        self.assertDictEqual({"Content-Type": "application/json"},
                             response.getheaders())
Exemplo n.º 7
0
    def test_add_header_encryption_layer_post_no_pubkey_fingerprint(self):
        self._set_header_params_config()
        del self._json_config["encryptionKeyFingerprintFieldName"]

        secret1 = 245
        secret2 = 854
        test_client = MockApiClient()
        to_test.add_encryption_layer(test_client, self._json_config)
        response = MockService(test_client).do_something_post_use_headers(
            body={
                "data": {
                    "secret1": secret1,
                    "secret2": secret2
                },
                "encryptedData": {}
            },
            headers={"Content-Type": "application/json"})

        self.assertIn("data", response.data)
        self.assertIn("secret", response.data["data"])
        self.assertEqual(secret2 - secret1, response.data["data"]["secret"])
        self.assertDictEqual({"Content-Type": "application/json"},
                             response.getheaders())