Version 1.017
[catagits/Catalyst-Authentication-Store-LDAP.git] / t / 02-realms_api.t
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5
6 use Test::More;
7 use lib 't/lib';
8 use LDAPTest;
9 my $server = LDAPTest::spawn_server();
10
11 use_ok("Catalyst::Authentication::Store::LDAP::Backend");
12
13 my $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
31 isa_ok( $back, "Catalyst::Authentication::Store::LDAP::Backend", 'LDAP backed' );
32
33 foreach (
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
47 done_testing;