Skip to content
Snippets Groups Projects
Commit b4af89c4 authored by Ping Yu's avatar Ping Yu
Browse files

Merge branch 'map-userinfo-fix' of github.com:syndicut/omniauth-ldap into syndicut-map-userinfo-fix

Conflicts:
	spec/omniauth/strategies/ldap_spec.rb
parents 77e842e9 b524feb6
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -64,14 +64,14 @@ module OmniAuth
mapper.each do |key, value|
case value
when String
user[key] = object[value.downcase.to_sym].first if object[value.downcase.to_sym]
user[key] = object[value.downcase.to_sym].first if object.respond_to? value.downcase.to_sym
when Array
value.each {|v| (user[key] = object[v.downcase.to_sym].first; break;) if object[v.downcase.to_sym]}
value.each {|v| (user[key] = object[v.downcase.to_sym].first; break;) if object.respond_to? v.downcase.to_sym}
when Hash
value.map do |key1, value1|
pattern = key1.dup
value1.each_with_index do |v,i|
part = ''; v.collect(&:downcase).collect(&:to_sym).each {|v1| (part = object[v1].first; break;) if object[v1]}
part = ''; v.collect(&:downcase).collect(&:to_sym).each {|v1| (part = object[v1].first; break;) if object.respond_to? v1}
pattern.gsub!("%#{i}",part||'')
end
user[key] = pattern
Loading
Loading
Loading
Loading
@@ -125,20 +125,25 @@ describe "OmniAuth::Strategies::LDAP" do
let(:auth_hash){ last_request.env['omniauth.auth'] }
 
before(:each) do
@adaptor.stub(:bind_as).and_return({
:dn => ['cn=ping, dc=intridea, dc=com'],
:mail => ['ping@intridea.com'],
:givenname => ['Ping'], :sn => ['Yu'],
:telephonenumber => ['555-555-5555'],
:mobile => ['444-444-4444'],
:uid => ['ping'],
:title => ['dev'],
:address =>[ 'k street'],
:l => ['Washington'], :st => ['DC'], :co => ["U.S.A"], :postofficebox => ['20001'],
:wwwhomepage => ['www.intridea.com'],
:jpegphoto => ['http://www.intridea.com/ping.jpg'],
:description => ['omniauth-ldap']})
@adaptor.stub(:bind_as).and_return(Net::LDAP::Entry.from_single_ldif_string(
%Q{dn: cn=ping, dc=intridea, dc=com
mail: ping@intridea.com
givenname: Ping
sn: Yu
telephonenumber: 555-555-5555
mobile: 444-444-4444
uid: ping
title: dev
address: k street
l: Washington
st: DC
co: U.S.A
postofficebox: 20001
wwwhomepage: www.intridea.com
jpegphoto: http://www.intridea.com/ping.jpg
description: omniauth-ldap
}
))
post('/auth/ldap/callback', {:username => 'ping', :password => 'password'})
end
 
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment