Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

beaker-refresh-ldap fails - user lacks email addr #243

Merged
merged 1 commit into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions IntegrationTests/src/bkr/inttest/ldap-data.ldif
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,20 @@ gidNumber: 15554
homeDirectory: /home/lol
mail: [email protected]

dn: uid=nomailattr,ou=users,dc=example,dc=invalid
objectClass: top
objectClass: person
objectClass: organizationalperson
objectClass: inetorgperson
objectClass: posixAccount
cn: NoMail Attribute
givenName: NoMail
sn: nomailattr
uid: nomailattr
uidNumber: 15555
gidNumber: 15555
homeDirectory: /home/nomailattr

dn: cn=my_ldap_group,ou=groups,dc=example,dc=invalid
objectClass: top
objectClass: posixGroup
Expand All @@ -124,6 +138,7 @@ objectClass: posixGroup
gidNumber: 5519
cn: alp
memberUid: jgillard
memberUid: nomailattr

dn: cn=wyfp,ou=groups,dc=example,dc=invalid
objectClass: top
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ def test_version(self):
self.assertEquals(out.strip(), __version__)

def test_refresh_ldap_group_membership(self):
"""
Testing two things with this test. That jgillard is
learned AND user 'nomailattr' is NOT learned since it is
missing the 'mail' attribute.
"""
with session.begin():
group = Group(group_name=u'alp',
display_name=u'Australian Labor Party',
Expand Down
6 changes: 6 additions & 0 deletions Server/bkr/server/model/identity.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,9 +291,15 @@ def by_user_name(cls, user_name):
elif(len(objects) > 1):
return None
attrs = objects[0][1]
if ('uid' not in attrs.keys() or 'cn' not in attrs.keys() or
'mail' not in attrs.keys()):
jchristi marked this conversation as resolved.
Show resolved Hide resolved
JohnVillalovos marked this conversation as resolved.
Show resolved Hide resolved
log.debug('Missing attribute for this LDAP user %s ', user_name)
return None
# LDAP normalization rules means that we might have found a user
# who doesn't actually match the username we were given.
if attrs['uid'][0].decode('utf8') != user_name:
log.debug('UserID attribute does not match this LDAP user %s ',
user_name)
return None
user = User()
user.user_name = attrs['uid'][0].decode('utf8')
Expand Down
Loading