Sha256: 59c9d5a12dca7caee92d94ce84a24013cfabd5cdbd6b4ebb45d8f66a0e7e89d8
Contents?: true
Size: 1.58 KB
Versions: 6
Compression:
Stored size: 1.58 KB
Contents
# encoding: UTF-8 require 'spec_helper' describe "CASServer::Authenticators::LDAP" do before do pending("Skip LDAP test due to missing gems") unless gem_available?("net-ldap") if $LOG.nil? load_server('default_config') # a lazy way to make sure the logger is set up end # Trigger autoload to load net ldap CASServer::Authenticators::LDAP @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
6 entries across 6 versions & 1 rubygems