def _doConnect(factory): factory.doStart() client = factory.buildProtocol( address.IPv4Address('TCP', 'localhost', '389')) server = serverFactory.buildProtocol( address.IPv4Address('TCP', 'localhost', '1024')) util.returnConnected(server, client)
def setUp(self): db = inmemory.ReadOnlyInMemoryLDAPEntry("", {}) com = db.addChild("dc=com", {"objectClass": ["dcObject"], "dc": ["com"]}) com.addChild("dc=example", {"objectClass": ["dcObject"], "dc": ["example"], "subschemaSubentry": ["cn=schema"]}) db.addChild( "cn=schema", { "objectClass": ["TODO"], "cn": ["schema"], "attributeTypes": [test_schema.AttributeType_KnownValues.knownValues[0][0]], "objectClasses": [ test_schema.OBJECTCLASSES["organization"], test_schema.OBJECTCLASSES["organizationalUnit"], ], }, ) class LDAPServerFactory(protocol.ServerFactory): protocol = ldapserver.LDAPServer def __init__(self, root): self.root = root components.registerAdapter(lambda x: x.root, LDAPServerFactory, interfaces.IConnectedLDAPEntry) serverFactory = LDAPServerFactory(db) self.client = ldapclient.LDAPClient() server = serverFactory.buildProtocol(address.IPv4Address("TCP", "localhost", "1024")) util.returnConnected(server, self.client)
def setUp(self): db = inmemory.ReadOnlyInMemoryLDAPEntry('', {}) com = db.addChild('dc=com', {'objectClass': ['dcObject'], 'dc': ['com'], }) com.addChild('dc=example', {'objectClass': ['dcObject'], 'dc': ['example'], 'subschemaSubentry': ['cn=schema'], }) db.addChild('cn=schema', {'objectClass': ['TODO'], 'cn': ['schema'], 'attributeTypes': [test_schema.AttributeType_KnownValues.knownValues[0][0]], 'objectClasses': [test_schema.OBJECTCLASSES['organization'], test_schema.OBJECTCLASSES['organizationalUnit'], ], }) class LDAPServerFactory(protocol.ServerFactory): protocol = ldapserver.LDAPServer def __init__(self, root): self.root = root components.registerAdapter(lambda x: x.root, LDAPServerFactory, interfaces.IConnectedLDAPEntry) serverFactory = LDAPServerFactory(db) self.client = ldapclient.LDAPClient() server = serverFactory.buildProtocol(address.IPv4Address('TCP', 'localhost', '1024')) util.returnConnected(server, self.client)
def _getPage_connect(clientFactory, serverAddress, clientAddress): clientProto = clientFactory.buildProtocol(serverAddress) serverProto = clientFactory.site.buildProtocol(clientAddress) pump = util.returnConnected(serverProto, clientProto, serverAddress=serverAddress, clientAddress=clientAddress)
def _createClient(self, factory): class LDAPServerFactory(protocol.ServerFactory): protocol = ldapserver.LDAPServer def __init__(self, root): self.root = root components.registerAdapter(lambda x: x.root, LDAPServerFactory, interfaces.IConnectedLDAPEntry) serverFactory = LDAPServerFactory(self.db) client = ldapclient.LDAPClient() server = serverFactory.buildProtocol(address.IPv4Address('TCP', 'localhost', '1024')) ldaptestutil.returnConnected(server, client) factory.deferred.callback(client)
def setUp(self): db = inmemory.ReadOnlyInMemoryLDAPEntry("", {}) com = db.addChild( "dc=com", { "objectClass": ["dcObject"], "dc": ["com"], }, ) com.addChild( "dc=example", { "objectClass": ["dcObject"], "dc": ["example"], "subschemaSubentry": ["cn=schema"], }, ) db.addChild( "cn=schema", { "objectClass": ["TODO"], "cn": ["schema"], "attributeTypes": [test_schema.AttributeType_KnownValues.knownValues[0][0]], "objectClasses": [ test_schema.OBJECTCLASSES["organization"], test_schema.OBJECTCLASSES["organizationalUnit"], ], }, ) class LDAPServerFactory(protocol.ServerFactory): protocol = ldapserver.LDAPServer def __init__(self, root): self.root = root components.registerAdapter(lambda x: x.root, LDAPServerFactory, interfaces.IConnectedLDAPEntry) serverFactory = LDAPServerFactory(db) self.client = ldapclient.LDAPClient() server = serverFactory.buildProtocol( address.IPv4Address("TCP", "localhost", "1024")) util.returnConnected(server, self.client)
def create_server_and_client(self, *responses, **kwds): client = LDAPClient() server = self.create_server(*responses, **kwds) self.pumps.add(returnConnected(server, client)) return server, client
def _doConnect(factory): factory.doStart() client = factory.buildProtocol(address.IPv4Address('TCP', 'localhost', '389')) server = serverFactory.buildProtocol(address.IPv4Address('TCP', 'localhost', '1024')) util.returnConnected(server, client)