crypto_tests.py 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  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, CryptoNoCallbackException
  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. def test_getcipher(self):
  24. crypto = CryptoEngine()
  25. self.assertRaises((CryptoNoCallbackException,), crypto._getcipher)
  26. def test_prepare_data(self):
  27. obj='dummy_data'
  28. self.assertTrue(True)