Sha256: 1c392e681795bb01065b6af22cd7de2caa7c945f69c053b6d1ae5bb6bb56ad8a

Contents?: true

Size: 1.41 KB

Versions: 23

Compression:

Stored size: 1.41 KB

Contents

# encoding: UTF-8
require File.dirname(__FILE__) + '/../spec_helper'

require 'casserver/authenticators/ldap'

describe CASServer::Authenticators::LDAP do
  before do
    @ldap_entry = mock(Net::LDAP::Entry.new)
    @ldap_entry.stub!(:[]).and_return("Test")
    
    @ldap = mock(Net::LDAP)
    @ldap.stub!(:host=)
    @ldap.stub!(:port=)
    @ldap.stub!(:encryption)
    @ldap.stub!(:bind_as).and_return(true)
    @ldap.stub!(:authenticate).and_return(true)
    @ldap.stub!(:search).and_return([@ldap_entry])
    
    Net::LDAP.stub!(:new).and_return(@ldap)
  end
  
  describe '#validate' do

    it 'validate with preauthentication and with extra attributes' do
      auth = CASServer::Authenticators::LDAP.new

      auth_config = HashWithIndifferentAccess.new(
        :ldap => {
          :host => "ad.example.net",
          :port => 389,
          :base => "dc=example,dc=net",
          :filter => "(objectClass=person)",
          :auth_user => "authenticator",
          :auth_password => "itsasecret"
        },
        :extra_attributes => [:full_name, :address]
      )
      
      auth.configure(auth_config.merge('auth_index' => 0))
      auth.validate(
        :username => 'validusername',
        :password => 'validpassword',
        :service =>  'test.service',
        :request => {}
      ).should == true
      
      auth.extra_attributes.should == {:full_name => 'Test', :address => 'Test'}
    end
    
  end
end


Version data entries

23 entries across 23 versions & 4 rubygems

Version Path
synapses-cas-0.1.11 spec/authenticators/ldap_spec.rb
synapses-cas-0.1.10 spec/authenticators/ldap_spec.rb
synapses-cas-0.1.9 spec/authenticators/ldap_spec.rb
ror-rubycas-server-1.0.c spec/authenticators/ldap_spec.rb
ror-rubycas-server-1.0.b spec/authenticators/ldap_spec.rb
ror-rubycas-server-1.0.a spec/authenticators/ldap_spec.rb
rubycas-server-1.1.2 spec/authenticators/ldap_spec.rb
synapses-cas-0.1.8 spec/authenticators/ldap_spec.rb
synapses-cas-0.1.7 spec/authenticators/ldap_spec.rb
rubycas-server-1.1.1 spec/authenticators/ldap_spec.rb
synapses-cas-0.1.6 spec/authenticators/ldap_spec.rb
synapses-cas-0.1.5 spec/authenticators/ldap_spec.rb
synapses-cas-0.1.4 spec/authenticators/ldap_spec.rb
synapses-cas-0.1.3 spec/authenticators/ldap_spec.rb
synapses-cas-0.1.2 spec/authenticators/ldap_spec.rb
synapses-cas-0.1.1 spec/authenticators/ldap_spec.rb
synapses-cas-0.1.0 spec/authenticators/ldap_spec.rb
bmedia-casserver-1.1.3 spec/authenticators/ldap_spec.rb
bmedia-casserver-1.1.2 spec/authenticators/ldap_spec.rb
bmedia-casserver-1.1.1 spec/authenticators/ldap_spec.rb