Пример #1
0
 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)
Пример #2
0
    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)
Пример #3
0
    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)
Пример #4
0
def _getPage_connect(clientFactory, serverAddress, clientAddress):
    clientProto = clientFactory.buildProtocol(serverAddress)
    serverProto = clientFactory.site.buildProtocol(clientAddress)
    pump = util.returnConnected(serverProto,
                                clientProto,
                                serverAddress=serverAddress,
                                clientAddress=clientAddress)
Пример #5
0
    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)
Пример #6
0
def _getPage_connect(clientFactory,
                     serverAddress,
                     clientAddress):
    clientProto = clientFactory.buildProtocol(serverAddress)
    serverProto = clientFactory.site.buildProtocol(clientAddress)
    pump = util.returnConnected(serverProto, clientProto,
                                serverAddress=serverAddress,
                                clientAddress=clientAddress)
Пример #7
0
    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
Пример #9
0
 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)