spec/omniauth/strategies/ldap_spec.rb in omniauth-ldap-1.0.3 vs spec/omniauth/strategies/ldap_spec.rb in omniauth-ldap-1.0.4
- old
+ new
@@ -47,11 +47,11 @@
end
end
describe 'post /auth/ldap/callback' do
before(:each) do
- @adaptor = mock(OmniAuth::LDAP::Adaptor, {:uid => 'ping'})
+ @adaptor = double(OmniAuth::LDAP::Adaptor, {:uid => 'ping'})
OmniAuth::LDAP::Adaptor.stub(:new).and_return(@adaptor)
end
context 'failure' do
before(:each) do
@@ -123,23 +123,28 @@
context 'success' 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
it 'should not redirect to error page' do
last_response.should_not be_redirect