Skip to content

Commit

Permalink
fix: add special char for revert_encoding unit tests & update the mig…
Browse files Browse the repository at this point in the history
…rations doc
  • Loading branch information
raghuvar-vijay committed Jan 22, 2025
1 parent 70b4032 commit c72a734
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
21 changes: 11 additions & 10 deletions auditor/scripts/revert_encoding/test_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -43,18 +46,16 @@ 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

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
Expand Down
10 changes: 5 additions & 5 deletions media/website/content/migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit c72a734

Please sign in to comment.