def __init__(self, config): """Create a password context for hashing and verification. :param config: The `IConfiguration` instance. """ config_string = load_external(config.passwords.configuration) self._context = CryptContext.from_string(config_string)
def test_load_external_by_path(self): contents = load_external('python:mailman.config.postfix') self.assertEqual(contents[:9], '[postfix]')
def test_load_external_by_filename(self): filename = resource_filename('mailman.config', 'postfix.cfg') contents = load_external(filename) self.assertEqual(contents[:9], '[postfix]')
def test_load_external_by_path_as_string(self): contents = load_external('python:mailman.config.postfix', 'utf-8') self.assertIsInstance(contents, unicode) self.assertEqual(contents[:9], '[postfix]')
def test_load_external_by_filename_as_string(self): filename = resource_filename('mailman.config', 'postfix.cfg') contents = load_external(filename, encoding='utf-8') self.assertIsInstance(contents, unicode) self.assertEqual(contents[:9], '[postfix]')
def test_load_external_by_path_as_bytes(self): contents = load_external('python:mailman.config.postfix') self.assertIsInstance(contents, bytes) self.assertEqual(contents[:9], b'[postfix]')
def test_load_external_by_filename_as_bytes(self): filename = resource_filename('mailman.config', 'postfix.cfg') contents = load_external(filename) self.assertIsInstance(contents, bytes) self.assertEqual(contents[:9], b'[postfix]')
def test_load_external_by_filename(self): with path('mailman.config', 'postfix.cfg') as filename: contents = load_external(str(filename)) self.assertEqual(contents[:9], '[postfix]')