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