diff --git a/auditor/scripts/revert_encoding/test_script.py b/auditor/scripts/revert_encoding/test_script.py index 64bd30ef4..719369c76 100644 --- a/auditor/scripts/revert_encoding/test_script.py +++ b/auditor/scripts/revert_encoding/test_script.py @@ -3,17 +3,20 @@ from unittest.mock import MagicMock, patch from urllib.parse import quote -from htcondor_revert_encodings import decode_record, main +from revert_encodings import decode_record, main class TestDecodeRecord(unittest.TestCase): def test_decode_record_success(self): # Test for successful decoding - record_id = quote("test_record_id") - meta = {"key1": [quote("value1"), quote("value2")], "key2": [quote("value3")]} + record_id = quote("test_record_id/") + meta = { + "key1": [quote("value1*"), quote("value2%")], + "key2": [quote("value3!")], + } - expected_record_id = "test_record_id" - expected_meta = {"key1": ["value1", "value2"], "key2": ["value3"]} + expected_record_id = "test_record_id/" + expected_meta = {"key1": ["value1*", "value2%"], "key2": ["value3!"]} decoded_record_id, decoded_meta = decode_record(record_id, meta) @@ -43,8 +46,8 @@ def test_main(mock_connect): # Mock database rows rows = [ - (1, quote("record1"), {"key1": [quote("value1")]}), - (2, quote("record2"), {"key2": [quote("value2")]}), + (1, quote("record1/"), {"key1": [quote("value1/")]}), + (2, quote("record2/"), {"key2": [quote("value2/")]}), ] mock_cursor.fetchall.side_effect = [rows, []] # Return rows and then stop @@ -52,9 +55,7 @@ def test_main(mock_connect): def mock_decode_record(record_id, meta): return record_id.replace("%20", " "), json.dumps(meta) - with patch( - "htcondor_revert_encodings.decode_record", side_effect=mock_decode_record - ): + with patch("revert_encodings.decode_record", side_effect=mock_decode_record): main() # Assertions diff --git a/media/website/content/migration.md b/media/website/content/migration.md index dbc7e5291..10fdb5412 100644 --- a/media/website/content/migration.md +++ b/media/website/content/migration.md @@ -9,14 +9,14 @@ weight = 3 Please backup your db before proceeding with any changes that are listed below. ## Remove forbidden characters: -The following changes only apply to users who are either using HTCondor collector (v0.6.3 and earlier) or slurm collector (v0.6.3 and earlier). +The following changes only apply to users who are either using HTCondor collector (v0.6.3 and earlier) or slurm collector (v0.6.3 and earlier), follow these steps to revert the encodings in your database records: ### HTCondor collector v0.6.3 and earlier or Slurm collector v0.6.3 and earlier -- If you are running HTCondor collector (v0.6.3 and earlier) or Slurm collector v0.6.3 and earlier, you have to run the python script which reverts the encodings for the records in the db. -- The script is in the following directory `auditor/scripts/revert_encoding`. -- You can install the required dependencies with `pip install -r requirements.txt` +- Clone the github repository [git_repo](https://github.com/ALU-Schumacher/AUDITOR). +- The script for reverting encodings is located at: `auditor/scripts/revert_encoding`. +- Install the required dependencies with `pip install -r requirements.txt` +- Replace the placeholder values in the .env file with the values corresponding to your database config. - Run `python revert_encodings.py` -- Please replace your database config to the .env file which is present in this directory `auditor/scripts/revert_encoding` ### New feature - TLS