LDAP now returns bytes, fix another comparison in ud-mailgate
We seem to be playing whack-a-mole here, maybe a better fix would be to fix the LDAP connection to properly decode bytes for all calls, but for now let's just fix this one issue, hopefully.
This was tested by manually reproducing part of the code in production, with:
import ldap
lc = ldap.initialize('ldap://db.torproject.org')
lc.simple_bind_s("", "")
HostBaseDn = "ou=hosts,dc=torproject,dc=org"
Res = lc.search_s(HostBaseDn, ldap.SCOPE_SUBTREE, '(objectClass=debianServer)', ['hostname'])
ValidHostNames = []
for _, value in Res:
for s in value.get("hostname", []):
ValidHostNames.append(s.decode('utf-8'))
'perdulce.torproject.org' in ValidHostNames
It would be pretty neat to have a mockup for the LDAP server that would allow us to unit-test this, but for now we're just scratching this painful itch, again.
Closes: team#41357 (closed)