Back to index

moin  1.9.0~rc2
Public Member Functions | Public Attributes | Static Public Attributes
test_ldap_login.TestTwoLdapServers Class Reference

List of all members.

Public Member Functions

def setup_class
def teardown_class
def testLDAP

Public Attributes

 ldap_envs

Static Public Attributes

 basedn = BASEDN
 rootdn = ROOTDN
 rootpw = ROOTPW
 slapd_config = SLAPD_CONFIG
 ldif_content = LDIF_CONTENT

Detailed Description

Definition at line 137 of file test_ldap_login.py.


Member Function Documentation

Create LDAP servers environment, start slapds 

Definition at line 144 of file test_ldap_login.py.

00144 
00145     def setup_class(self):
00146         """ Create LDAP servers environment, start slapds """
00147         self.ldap_envs = []
00148         for instance in range(2):
00149             ldap_env = LdapEnvironment(self.basedn, self.rootdn, self.rootpw, instance=instance)
00150             ldap_env.create_env(slapd_config=self.slapd_config)
00151             started = ldap_env.start_slapd()
00152             if not started:
00153                 py.test.skip("Failed to start %s process, please see your syslog / log files"
00154                              " (and check if stopping apparmor helps, in case you use it)." % SLAPD_EXECUTABLE)
00155             ldap_env.load_directory(ldif_content=self.ldif_content)
00156             self.ldap_envs.append(ldap_env)

Stop slapd, remove LDAP server environment 

Definition at line 157 of file test_ldap_login.py.

00157 
00158     def teardown_class(self):
00159         """ Stop slapd, remove LDAP server environment """
00160         for ldap_env in self.ldap_envs:
00161             ldap_env.stop_slapd()
00162             ldap_env.destroy_env()

Just try accessing the LDAP servers and see if usera and userb are in LDAP. 

Definition at line 163 of file test_ldap_login.py.

00163 
00164     def testLDAP(self):
00165         """ Just try accessing the LDAP servers and see if usera and userb are in LDAP. """
00166         for ldap_env in self.ldap_envs:
00167             server_uri = ldap_env.slapd.url
00168             base_dn = ldap_env.basedn
00169             lo = ldap.initialize(server_uri)
00170             ldap.set_option(ldap.OPT_PROTOCOL_VERSION, ldap.VERSION3) # ldap v2 is outdated
00171             lo.simple_bind_s('', '')
00172             lusers = lo.search_st(base_dn, ldap.SCOPE_SUBTREE, '(uid=*)')
00173             uids = [ldap_dict['uid'][0] for dn, ldap_dict in lusers]
00174             assert 'usera' in uids
00175             assert 'userb' in uids
00176 


Member Data Documentation

Definition at line 138 of file test_ldap_login.py.

Definition at line 146 of file test_ldap_login.py.

Definition at line 142 of file test_ldap_login.py.

Definition at line 139 of file test_ldap_login.py.

Definition at line 140 of file test_ldap_login.py.

Definition at line 141 of file test_ldap_login.py.


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