Skip to content

Commit b4af89c

Browse files
author
Ping Yu
committed
Merge branch 'map-userinfo-fix' of github.com:syndicut/omniauth-ldap into syndicut-map-userinfo-fix
Conflicts: spec/omniauth/strategies/ldap_spec.rb
2 parents 77e842e + b524feb commit b4af89c

File tree

2 files changed

+22
-17
lines changed

2 files changed

+22
-17
lines changed

lib/omniauth/strategies/ldap.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,14 @@ def self.map_user(mapper, object)
6464
mapper.each do |key, value|
6565
case value
6666
when String
67-
user[key] = object[value.downcase.to_sym].first if object[value.downcase.to_sym]
67+
user[key] = object[value.downcase.to_sym].first if object.respond_to? value.downcase.to_sym
6868
when Array
69-
value.each {|v| (user[key] = object[v.downcase.to_sym].first; break;) if object[v.downcase.to_sym]}
69+
value.each {|v| (user[key] = object[v.downcase.to_sym].first; break;) if object.respond_to? v.downcase.to_sym}
7070
when Hash
7171
value.map do |key1, value1|
7272
pattern = key1.dup
7373
value1.each_with_index do |v,i|
74-
part = ''; v.collect(&:downcase).collect(&:to_sym).each {|v1| (part = object[v1].first; break;) if object[v1]}
74+
part = ''; v.collect(&:downcase).collect(&:to_sym).each {|v1| (part = object[v1].first; break;) if object.respond_to? v1}
7575
pattern.gsub!("%#{i}",part||'')
7676
end
7777
user[key] = pattern

spec/omniauth/strategies/ldap_spec.rb

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -125,20 +125,25 @@ class MyLdapProvider < OmniAuth::Strategies::LDAP; end
125125
let(:auth_hash){ last_request.env['omniauth.auth'] }
126126

127127
before(:each) do
128-
@adaptor.stub(:bind_as).and_return({
129-
:dn => ['cn=ping, dc=intridea, dc=com'],
130-
:mail => ['[email protected]'],
131-
:givenname => ['Ping'], :sn => ['Yu'],
132-
:telephonenumber => ['555-555-5555'],
133-
:mobile => ['444-444-4444'],
134-
:uid => ['ping'],
135-
:title => ['dev'],
136-
:address =>[ 'k street'],
137-
:l => ['Washington'], :st => ['DC'], :co => ["U.S.A"], :postofficebox => ['20001'],
138-
:wwwhomepage => ['www.intridea.com'],
139-
:jpegphoto => ['http://www.intridea.com/ping.jpg'],
140-
:description => ['omniauth-ldap']})
141-
128+
@adaptor.stub(:bind_as).and_return(Net::LDAP::Entry.from_single_ldif_string(
129+
%Q{dn: cn=ping, dc=intridea, dc=com
130+
131+
givenname: Ping
132+
sn: Yu
133+
telephonenumber: 555-555-5555
134+
mobile: 444-444-4444
135+
uid: ping
136+
title: dev
137+
address: k street
138+
l: Washington
139+
st: DC
140+
co: U.S.A
141+
postofficebox: 20001
142+
wwwhomepage: www.intridea.com
143+
jpegphoto: http://www.intridea.com/ping.jpg
144+
description: omniauth-ldap
145+
}
146+
))
142147
post('/auth/ldap/callback', {:username => 'ping', :password => 'password'})
143148
end
144149

0 commit comments

Comments
 (0)