Back to index

moin  1.9.0~rc2
Public Member Functions | Public Attributes
MoinMoin._tests.ldap_testbase.Slapd Class Reference

List of all members.

Public Member Functions

def __init__
def start
def stop

Public Attributes

 executable
 config
 debug_flags
 proto
 ip
 port
 url
 service_name
 process

Detailed Description

Manage a slapd process for testing purposes 

Definition at line 77 of file ldap_testbase.py.


Constructor & Destructor Documentation

def MoinMoin._tests.ldap_testbase.Slapd.__init__ (   self,
  config = None,
  executable = SLAPD_EXECUTABLE,
  debug_flags = '',
  proto = 'ldap',
  ip = '127.0.0.1',
  port = 3890,
  service_name = ''  # defaults to -n executable:port,
  use,
  None,
  to,
  not,
  use,
  n 
)

Definition at line 85 of file ldap_testbase.py.

00085 
00086                 ):
00087         self.executable = executable
00088         self.config = config
00089         self.debug_flags = debug_flags
00090         self.proto = proto
00091         self.ip = ip
00092         self.port = port
00093         self.url = '%s://%s:%d' % (proto, ip, port) # can be used for ldap.initialize() call
00094         if service_name == '':
00095             self.service_name = '%s:%d' % (executable, port)
00096         else:
00097             self.service_name = service_name


Member Function Documentation

def MoinMoin._tests.ldap_testbase.Slapd.start (   self,
  timeout = 0 
)
start a slapd process and optionally wait up to timeout seconds until it responds 

Definition at line 98 of file ldap_testbase.py.

00098 
00099     def start(self, timeout=0):
00100         """ start a slapd process and optionally wait up to timeout seconds until it responds """
00101         args = [self.executable, '-h', self.url, ]
00102         if self.config is not None:
00103             args.extend(['-f', self.config])
00104         if self.debug_flags is not None:
00105             args.extend(['-d', self.debug_flags])
00106         if self.service_name:
00107             args.extend(['-n', self.service_name])
00108         self.process = subprocess.Popen(args)
00109         started = None
00110         if timeout:
00111             lo = ldap.initialize(self.url)
00112             ldap.set_option(ldap.OPT_PROTOCOL_VERSION, ldap.VERSION3) # ldap v2 is outdated
00113             started = False
00114             wait_until = time.time() + timeout
00115             while time.time() < wait_until:
00116                 try:
00117                     lo.simple_bind_s('', '')
00118                     started = True
00119                 except ldap.SERVER_DOWN, err:
00120                     time.sleep(0.1)
00121                 else:
00122                     break
00123         return started

stop this slapd process and wait until it has terminated 

Definition at line 124 of file ldap_testbase.py.

00124 
00125     def stop(self):
00126         """ stop this slapd process and wait until it has terminated """
00127         pid = self.process.pid
00128         os.kill(pid, signal.SIGTERM)
00129         os.waitpid(pid, 0)
00130 


Member Data Documentation

Definition at line 87 of file ldap_testbase.py.

Definition at line 88 of file ldap_testbase.py.

Definition at line 86 of file ldap_testbase.py.

Definition at line 90 of file ldap_testbase.py.

Definition at line 91 of file ldap_testbase.py.

Definition at line 107 of file ldap_testbase.py.

Definition at line 89 of file ldap_testbase.py.

Definition at line 94 of file ldap_testbase.py.

Definition at line 92 of file ldap_testbase.py.


The documentation for this class was generated from the following file: