From 6448a4efa7bbb430d188a2ce09c8c9cba691ac41 Mon Sep 17 00:00:00 2001 From: Akshay Karle <1443108+akshaykarle@users.noreply.github.com> Date: Mon, 14 Oct 2024 14:51:56 +0100 Subject: [PATCH] remove /deanonymize and its tests --- src/app.py | 21 --------------------- tests/app_test.py | 18 ------------------ 2 files changed, 39 deletions(-) diff --git a/src/app.py b/src/app.py index aed6dcc..b6953ae 100644 --- a/src/app.py +++ b/src/app.py @@ -146,27 +146,6 @@ def anonymize() -> Response: ) return jsonify(error=e.args[0]), 500 - @self.app.route("/deanonymize", methods=["POST"]) - def deanonymize() -> Response: - """Execute the deanonymizer function.""" - try: - file = request.files['file'] - if file.filename == '': - return jsonify({'error': 'No selected file'}), 400 - - filepath = f'{UPLOAD_DIR}/{uuid.uuid4()}' - file.save(filepath) - self.logger.info(f"Successfully saved file: {filepath}") - - anonymizer_results = json.loads(request.form['anonymizer_results']) - return jsonify(anonymizer_results) - except Exception as e: - self.logger.error( - f"A fatal error occurred during execution of " - f"deanonymize. {e}" - ) - return jsonify(error=e.args[0]), 500 - if __name__ == "__main__": port = int(os.environ.get("PORT", DEFAULT_PORT)) diff --git a/tests/app_test.py b/tests/app_test.py index a6e5683..82a9b37 100644 --- a/tests/app_test.py +++ b/tests/app_test.py @@ -132,21 +132,3 @@ def test_vault_anonymize_csv_pii(client): "./tests/sample_data/vault_encrypted.csv", "r" ).read() assert anonymizer_data.replace("\r", "") == expected_anonymized_data - -def test_vault_deanonymize_csv(client): - with mock.patch.object(hvac, "Client"): - expected_plain_text = "text" - fake_client = mock.MagicMock() - fake_client.secrets.transit.decrypt_data.return_value = {"data": {"plaintext": expected_plain_text}} - hvac.Client.return_value = fake_client - - deanonymizer_response = client.post("/deanonymize", data={ - "file": open('./tests/sample_data/vault_encrypted.csv', 'rb'), - "vault_config": '{"url": "http://127.0.0.1:8200", "key": "foobar"}', - "anonymizer_results": '{}' - }) - - assert deanonymizer_response.status_code == 200 - deanonymizer_data = deanonymizer_response.get_data(as_text=True) - expected_deanonymized_data = open('./tests/sample_data/sample_data.csv', 'r').read() - assert deanonymizer_data.replace("\r", "") == expected_deanonymized_data