crypto_tests.py 1.1 KB

1234567891011121314151617181920212223242526272829303132
  1. import pwman.util.config as config
  2. import os
  3. from pwman.util.crypto import (CryptoEngine, CryptoException,
  4. CryptoNoCallbackException)
  5. # set cls_timout to negative number (e.g. -1) to disable
  6. default_config = {'Global': {'umask': '0100', 'colors': 'yes',
  7. 'cls_timeout': '5'
  8. },
  9. 'Database': {'type': 'SQLite',
  10. 'filename': os.path.join("tests", "pwman.db")},
  11. 'Encryption': {'algorithm': 'AES'},
  12. 'Readline': {'history': os.path.join("tests",
  13. "history")}
  14. }
  15. config.set_defaults(default_config)
  16. import unittest
  17. class CryptoTest(unittest.TestCase):
  18. def test_no_algorithm(self):
  19. config.set_value('Encryption', 'algorithm', '')
  20. self.assertRaises((CryptoException,), CryptoEngine)
  21. def test_getcipher(self):
  22. crypto = CryptoEngine()
  23. self.assertRaises((CryptoNoCallbackException,), crypto._getcipher)
  24. def test_prepare_data(self):
  25. obj = 'dummy_data'
  26. self.assertTrue(True)