1#!/usr/bin/perl 2 3use strict; 4use warnings; 5 6use Test::More; 7use lib 't/lib'; 8use LDAPTest; 9my $server = LDAPTest::spawn_server(); 10 11use_ok("Catalyst::Authentication::Store::LDAP::Backend"); 12 13my $back = Catalyst::Authentication::Store::LDAP::Backend->new( 14 { 'ldap_server' => LDAPTest::server_host(), 15 16 # can test the timeout SKIP with this 17 'ldap_server_options' => 18 { timeout => -1, debug => $ENV{PERL_DEBUG} || 0 }, 19 20 'binddn' => 'anonymous', 21 'bindpw' => 'dontcarehow', 22 'start_tls' => 0, 23 'user_basedn' => 'ou=foobar', 24 'user_filter' => '(&(objectClass=person)(uid=%s))', 25 'user_scope' => 'one', 26 'user_field' => 'uid', 27 'use_roles' => 0, 28 } 29); 30 31isa_ok( $back, "Catalyst::Authentication::Store::LDAP::Backend", 'LDAP backed' ); 32 33foreach ( 34 ['somebody', 'Some Body'], 35 ['sunnO)))', 'Sunn O)))'], 36 ['some*', 'Some Star'], 37) { 38 my ($username, $name) = @$_; 39 40 my $user = $back->find_user( { username => $username } ); 41 isa_ok( $user, "Catalyst::Authentication::Store::LDAP::User", "find_user('$username') result" ); 42 my $displayname = $user->displayname; 43 is( $displayname, $name, 'Display name' ); 44 45} 46 47done_testing; 48