Skip to content

Commit

Permalink
adding unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
gvb84 committed Oct 23, 2023
1 parent 5cc2da6 commit 2d123f3
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
Binary file added tests/data/ssfs_npl_dat
Binary file not shown.
Binary file added tests/data/ssfs_npl_key
Binary file not shown.
26 changes: 25 additions & 1 deletion tests/sapssfs_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
# External imports
# Custom imports
from tests.utils import data_filename
from pysap.SAPSSFS import (SAPSSFSKey, SAPSSFSData, SAPSSFSLock)
from pysap.SAPSSFS import (SAPSSFSKey, SAPSSFSKeyE, SAPSSFSData, SAPSSFSLock)


class PySAPSSFSKeyTest(unittest.TestCase):
Expand Down Expand Up @@ -145,6 +145,30 @@ def test_ssfs_data_record_decrypt(self):
self.assertFalse(record.is_stored_as_plaintext)
self.assertTrue(record.valid)

class PySAPSSFSDataDecryptETest(unittest.TestCase):

ENCRYPTED_VALUES = {"RS/CIPHERTEXT_VAL": "hellow0rld"}

def test_ssfs_data_record_decrypt(self):
"""Test decrypting a record with a given key in a SSFS Data file."""

with open(data_filename("ssfs_npl_key"), "rb") as fd:
s = fd.read()
key = SAPSSFSKeyE(s)

with open(data_filename("ssfs_npl_dat"), "rb") as fd:
s = fd.read()
data = SAPSSFSData(s)

for name, value in self.ENCRYPTED_VALUES.items():
self.assertTrue(data.has_record(name))
self.assertIsNotNone(data.get_record(name))
self.assertEqual(data.get_value(name, key), value)

record = data.get_record(name)
self.assertFalse(record.is_stored_as_plaintext)
self.assertTrue(record.valid)


def test_suite():
loader = unittest.TestLoader()
Expand Down

0 comments on commit 2d123f3

Please sign in to comment.