|
Revision 392, 1.0 kB
(checked in by tv, 5 years ago)
|
Move the test LDAP server used in web tests from port 10389 to port 38942.
|
| Line | |
|---|
| 1 |
# -*- python -*- |
|---|
| 2 |
import shutil |
|---|
| 3 |
from twisted.application import service, internet |
|---|
| 4 |
from twisted.internet import protocol |
|---|
| 5 |
from twisted.python import components |
|---|
| 6 |
from twisted.trial import util |
|---|
| 7 |
from ldaptor import ldiftree, interfaces |
|---|
| 8 |
from ldaptor.protocols.ldap import ldapserver |
|---|
| 9 |
|
|---|
| 10 |
DBPATH = 'ldaptor/test/ldif/webtests' |
|---|
| 11 |
TMPDBPATH = '%s.tmp' % DBPATH |
|---|
| 12 |
shutil.rmtree(TMPDBPATH, ignore_errors=True) |
|---|
| 13 |
shutil.copytree(DBPATH, TMPDBPATH) |
|---|
| 14 |
db = ldiftree.LDIFTreeEntry(TMPDBPATH) |
|---|
| 15 |
|
|---|
| 16 |
class LDAPServerFactory(protocol.ServerFactory): |
|---|
| 17 |
protocol = ldapserver.LDAPServer |
|---|
| 18 |
|
|---|
| 19 |
def __init__(self, root): |
|---|
| 20 |
self.root = root |
|---|
| 21 |
|
|---|
| 22 |
ldapserver.LDAPServer.debug = True |
|---|
| 23 |
|
|---|
| 24 |
components.registerAdapter(lambda x: x.root, |
|---|
| 25 |
LDAPServerFactory, |
|---|
| 26 |
interfaces.IConnectedLDAPEntry) |
|---|
| 27 |
|
|---|
| 28 |
|
|---|
| 29 |
application = service.Application("ldaptor-server") |
|---|
| 30 |
myService = service.IServiceCollection(application) |
|---|
| 31 |
|
|---|
| 32 |
factory = LDAPServerFactory(db) |
|---|
| 33 |
|
|---|
| 34 |
myServer = internet.TCPServer(38942, factory) |
|---|
| 35 |
myServer.setServiceParent(myService) |
|---|