Commit 1723e4dbd0fb676fa92606c85b3cb9cd5fb12839

Authored by Samir Aguiar
1 parent faa9bc53

oleid: unit test for encrypted files detection

tests/oleid/__init__.py 0 โ†’ 100644
tests/oleid/test_issue_166.py 0 โ†’ 100644
  1 +"""
  2 +Test if oleid detects encrypted documents
  3 +"""
  4 +
  5 +import unittest, sys, os
  6 +
  7 +from tests.test_utils import DATA_BASE_DIR
  8 +from os.path import join
  9 +
  10 +from oletools import oleid
  11 +
  12 +class TestEncryptedDocumentDetection(unittest.TestCase):
  13 + def test_encrypted_document_detection(self):
  14 + """ Run oleid and check if the document is flagged as encrypted """
  15 + filename = join(DATA_BASE_DIR, 'basic/encrypted.docx')
  16 +
  17 + oleid_instance = oleid.OleID(filename)
  18 + indicators = oleid_instance.check()
  19 +
  20 + is_encrypted = next(i.value for i in indicators if i.id == 'encrypted')
  21 +
  22 + self.assertEqual(is_encrypted, True)
  23 +
  24 +# just in case somebody calls this file as a script
  25 +if __name__ == '__main__':
  26 + unittest.main()
0 27 \ No newline at end of file
... ...
tests/test-data/basic/encrypted.docx 0 โ†’ 100644
No preview for this file type