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 2021-01-05 19:13:29 -05:00 committed by Veiko Aasa
parent 7cf166e558
commit d69a36c25f
No known key found for this signature in database
GPG Key ID: 478539CAE680674E

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 = [