crypto_tests.py 1.0 KB

1234567891011121314151617181920212223242526272829303132
  1. import pwman.util.config as config
  2. import os
  3. import pwman.data.factory
  4. from pwman.data.nodes import NewNode
  5. from pwman.data.tags import Tag
  6. from pwman.util.crypto import CryptoEngine, CryptoException
  7. # set cls_timout to negative number (e.g. -1) to disable
  8. default_config = {'Global': {'umask': '0100', 'colors': 'yes',
  9. 'cls_timeout': '5'
  10. },
  11. 'Database': {'type': 'SQLite',
  12. 'filename': os.path.join("tests", "pwman.db")},
  13. 'Encryption': {'algorithm': 'AES'},
  14. 'Readline': {'history': os.path.join("tests",
  15. "history")}
  16. }
  17. config.set_defaults(default_config)
  18. import unittest
  19. class CryptoTest(unittest.TestCase):
  20. def test_no_algorithm(self):
  21. config.set_value('Encryption', 'algorithm', '')
  22. self.assertRaises((CryptoException,), CryptoEngine)
  23. # TODO: write a white box test for each
  24. # method in CryptoEngine