mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
test_ldap: drop redundant URI argument
Use the default LDAP URI from api.env.ldap_uri instead of specifying a custom URI in the argument. The default URI might be ldapi://, so make sure autobind is not attempted where the custom URI was ldap://. Reviewed-By: Martin Babinsky <mbabinsk@redhat.com> Reviewed-By: Christian Heimes <cheimes@redhat.com>
This commit is contained in:
committed by
Martin Basti
parent
935fcaea2e
commit
8f849a77f5
@@ -34,7 +34,7 @@ from nose.tools import assert_raises # pylint: disable=E0611
|
|||||||
import six
|
import six
|
||||||
|
|
||||||
from ipaplatform.paths import paths
|
from ipaplatform.paths import paths
|
||||||
from ipaserver.plugins.ldap2 import ldap2
|
from ipaserver.plugins.ldap2 import ldap2, AUTOBIND_DISABLED
|
||||||
from ipalib import api, x509, create_api, errors
|
from ipalib import api, x509, create_api, errors
|
||||||
from ipapython import ipautil
|
from ipapython import ipautil
|
||||||
from ipapython.dn import DN
|
from ipapython.dn import DN
|
||||||
@@ -51,7 +51,7 @@ class test_ldap(object):
|
|||||||
|
|
||||||
def setup(self):
|
def setup(self):
|
||||||
self.conn = None
|
self.conn = None
|
||||||
self.ldapuri = 'ldap://%s' % ipautil.format_netloc(api.env.host)
|
self.ldapuri = api.env.ldap_uri
|
||||||
self.dn = DN(('krbprincipalname','ldap/%s@%s' % (api.env.host, api.env.realm)),
|
self.dn = DN(('krbprincipalname','ldap/%s@%s' % (api.env.host, api.env.realm)),
|
||||||
('cn','services'),('cn','accounts'),api.env.basedn)
|
('cn','services'),('cn','accounts'),api.env.basedn)
|
||||||
|
|
||||||
@@ -63,8 +63,8 @@ class test_ldap(object):
|
|||||||
"""
|
"""
|
||||||
Test an anonymous LDAP bind using ldap2
|
Test an anonymous LDAP bind using ldap2
|
||||||
"""
|
"""
|
||||||
self.conn = ldap2(api, ldap_uri=self.ldapuri)
|
self.conn = ldap2(api)
|
||||||
self.conn.connect()
|
self.conn.connect(autobind=AUTOBIND_DISABLED)
|
||||||
dn = api.env.basedn
|
dn = api.env.basedn
|
||||||
entry_attrs = self.conn.get_entry(dn, ['associateddomain'])
|
entry_attrs = self.conn.get_entry(dn, ['associateddomain'])
|
||||||
domain = entry_attrs.single_value['associateddomain']
|
domain = entry_attrs.single_value['associateddomain']
|
||||||
@@ -74,8 +74,8 @@ class test_ldap(object):
|
|||||||
"""
|
"""
|
||||||
Test a GSSAPI LDAP bind using ldap2
|
Test a GSSAPI LDAP bind using ldap2
|
||||||
"""
|
"""
|
||||||
self.conn = ldap2(api, ldap_uri=self.ldapuri)
|
self.conn = ldap2(api)
|
||||||
self.conn.connect()
|
self.conn.connect(autobind=AUTOBIND_DISABLED)
|
||||||
entry_attrs = self.conn.get_entry(self.dn, ['usercertificate'])
|
entry_attrs = self.conn.get_entry(self.dn, ['usercertificate'])
|
||||||
cert = entry_attrs.get('usercertificate')
|
cert = entry_attrs.get('usercertificate')
|
||||||
cert = cert[0]
|
cert = cert[0]
|
||||||
@@ -92,7 +92,7 @@ class test_ldap(object):
|
|||||||
dm_password = fp.read().rstrip()
|
dm_password = fp.read().rstrip()
|
||||||
else:
|
else:
|
||||||
raise nose.SkipTest("No directory manager password in %s" % pwfile)
|
raise nose.SkipTest("No directory manager password in %s" % pwfile)
|
||||||
self.conn = ldap2(api, ldap_uri=self.ldapuri)
|
self.conn = ldap2(api)
|
||||||
self.conn.connect(bind_dn=DN(('cn', 'directory manager')), bind_pw=dm_password)
|
self.conn.connect(bind_dn=DN(('cn', 'directory manager')), bind_pw=dm_password)
|
||||||
entry_attrs = self.conn.get_entry(self.dn, ['usercertificate'])
|
entry_attrs = self.conn.get_entry(self.dn, ['usercertificate'])
|
||||||
cert = entry_attrs.get('usercertificate')
|
cert = entry_attrs.get('usercertificate')
|
||||||
@@ -131,8 +131,7 @@ class test_ldap(object):
|
|||||||
"""
|
"""
|
||||||
Test an autobind LDAP bind using ldap2
|
Test an autobind LDAP bind using ldap2
|
||||||
"""
|
"""
|
||||||
ldapuri = 'ldapi://%%2fvar%%2frun%%2fslapd-%s.socket' % api.env.realm.replace('.','-')
|
self.conn = ldap2(api)
|
||||||
self.conn = ldap2(api, ldap_uri=ldapuri)
|
|
||||||
try:
|
try:
|
||||||
self.conn.connect(autobind=True)
|
self.conn.connect(autobind=True)
|
||||||
except errors.ACIError:
|
except errors.ACIError:
|
||||||
@@ -155,9 +154,9 @@ class test_LDAPEntry(object):
|
|||||||
dn2 = DN(('cn', cn2[0]))
|
dn2 = DN(('cn', cn2[0]))
|
||||||
|
|
||||||
def setup(self):
|
def setup(self):
|
||||||
self.ldapuri = 'ldap://%s' % ipautil.format_netloc(api.env.host)
|
self.ldapuri = api.env.ldap_uri
|
||||||
self.conn = ldap2(api, ldap_uri=self.ldapuri)
|
self.conn = ldap2(api)
|
||||||
self.conn.connect()
|
self.conn.connect(autobind=AUTOBIND_DISABLED)
|
||||||
|
|
||||||
self.entry = self.conn.make_entry(self.dn1, cn=self.cn1)
|
self.entry = self.conn.make_entry(self.dn1, cn=self.cn1)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user