This is an automated email from the ASF dual-hosted git repository.
sebb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/whimsy.git
The following commit(s) were added to refs/heads/master by this push:
new a45e9af2 Fix for Person#method_missing
a45e9af2 is described below
commit a45e9af261c7ffa4233eccefe1e5e69751f0367e
Author: Sebb <[email protected]>
AuthorDate: Thu Jan 12 23:51:22 2023 +0000
Fix for Person#method_missing
This fixes #180
---
lib/whimsy/asf/ldap.rb | 43 ++++++++++++++++++++++++++++++++++++++-----
1 file changed, 38 insertions(+), 5 deletions(-)
diff --git a/lib/whimsy/asf/ldap.rb b/lib/whimsy/asf/ldap.rb
index 0e43bf6a..ae342a25 100644
--- a/lib/whimsy/asf/ldap.rb
+++ b/lib/whimsy/asf/ldap.rb
@@ -873,19 +873,52 @@ module ASF
"uid=#{name},#{ASF::Person.base}"
end
+ VALID_ATTRS = %w[
+ asf-altEmail
+ asf-committer-email
+ asf-member-activeprojects
+ asf-member-status
+ asf-pgpKeyFingerprint
+ asf-sascore
+ cn
+ createTimestamp
+ creatorsName
+ dn
+ entryCSN
+ entryDN
+ entryUUID
+ gidNumber
+ githubUsername
+ hasSubordinates
+ homeDirectory
+ host
+ loginShell
+ mail
+ modifiersName
+ modifyTimestamp
+ objectClass
+ sn
+ sshPublicKey
+ structuralObjectClass
+ subschemaSubentry
+ uid
+ uidNumber
+ ]
+
# Allow arbitrary LDAP attributes to be referenced as object properties.
# Example: <tt>ASF::Person.find('rubys').cn</tt>. Can also be used
# to modify an LDAP attribute.
def method_missing(name, *args)
- if name.to_s.end_with? '=' and args.length == 1
- return modify(name.to_s[0..-2], args)
+ sname = name.to_s
+ if sname.end_with? '=' and args.length == 1
+ return modify(name[0..-2], args)
end
return super unless args.empty?
- result = self.attrs[name.to_s]
- return super unless result
+ return super unless VALID_ATTRS.include? sname
+ result = self.attrs[sname]
- if result.empty?
+ if result.nil? || result.empty?
return nil
else
result.map! do |value|