diff options
Diffstat (limited to 'src/leap')
-rw-r--r-- | src/leap/mx/tests/test_alias_resolver.py | 53 |
1 files changed, 38 insertions, 15 deletions
diff --git a/src/leap/mx/tests/test_alias_resolver.py b/src/leap/mx/tests/test_alias_resolver.py index c8d7952..e5f4221 100644 --- a/src/leap/mx/tests/test_alias_resolver.py +++ b/src/leap/mx/tests/test_alias_resolver.py @@ -10,26 +10,49 @@ Unittests for /leap/mx/alias_resolver.py. @copyright: copyright 2013 Isis Agora Lovecruft ''' -from twisted.internet import address +import os +import socket +import stat + +from twisted.internet import address, defer, reactor from twisted.mail import maildir, alias from twisted.protocols import postfix +from twisted.trial import unittest from leap.mx import alias_resolver from leap.mx.util import config, log, net +config.filename = 'mx.conf.private' +config.loadConfig() + +user = config.couch.user +pswd = config.couch.passwd +host = config.couch.host +port = config.couch.port + +## xxx dbName should be a config setting +connection = alias_resolver.ConnectedCouchDB(host, port, + dbName="users", + username=user, + password=pswd) +connection.listDB() +print connection + +class TestAliasResolverServer(unittest.TestCase): + def setUp(self, *args, **kwargs): + self.factory = alias_resolver.AliasResolverFactory( + data={'isis@leap.se': '0x2cdbb35'}) + self.protocol = self.factory.buildProtocol() + + client_socket = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) + if (os.path.exists(client_socket) and + os.stat(socket).st_mode & ( + stat.S_IRGP | stat.S_IRUSR | stat.S_IROTH)): + self.client_connection = (reactor, client_socket) + self.client = UnixClientEndpoint(self.client_connection) + + if __name__ == "__main__": - config.filename = 'mx.conf.private' - config.loadConfig() - - user = config.couch.user - pswd = config.couch.passwd - host = config.couch.host - port = config.couch.port - - connection = alias_resolver.ConnectedCouchDB(host, port, - dbName="users", - username=user, - password=pswd) - connection.listDB() - print connection + + tars = TestAliasResolverServer() |