users: Avoid test error if ldapsearch is not available

ldapsearch is provided by ldap-utils, which is not a build dependency.

Test: Build package using `gbp buildpackage`.

Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
This commit is contained in:
James Valleroy authored and Veiko Aasa committed 2021-01-06 08:36:18 +02:00
1 parent 7cf166e558
commit d69a36c25f
1 file changed
+7 -4
+7 -4
View File
@@ -24,10 +24,13 @@ _cleanup_groups = None
def _is_ldap_set_up():
"""Return whether LDAP is set up."""
return subprocess.call([
'ldapsearch', '-Y', 'EXTERNAL', '-H', 'ldapi:///', '-b',
'ou=groups,dc=thisbox'
]) == 0
try:
return subprocess.call([
'ldapsearch', '-Y', 'EXTERNAL', '-H', 'ldapi:///', '-b',
'ou=groups,dc=thisbox'
]) == 0
except FileNotFoundError:
return False
pytestmark = [