Commit | Line | Data |
f66d606b |
1 | #!/usr/bin/perl |
2 | |
3 | use strict; |
4 | use warnings; |
5 | use Catalyst::Exception; |
6 | |
e385da71 |
7 | use Test::More; |
f66d606b |
8 | use lib 't/lib'; |
9 | use LDAPTest; |
f66d606b |
10 | |
e385da71 |
11 | eval "use Catalyst::Model::LDAP"; |
12 | plan skip_all => "Catalyst::Model::LDAP not installed" if $@; |
f66d606b |
13 | |
e385da71 |
14 | my $server = LDAPTest::spawn_server(); |
15 | |
16 | use_ok("Catalyst::Authentication::Store::LDAP::Backend"); |
17 | |
18 | my $back = Catalyst::Authentication::Store::LDAP::Backend->new( |
19 | { 'ldap_server' => LDAPTest::server_host(), |
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 | 'entry_class' => 'EntryClass', |
f66d606b |
29 | } |
e385da71 |
30 | ); |
31 | |
32 | isa_ok( $back, "Catalyst::Authentication::Store::LDAP::Backend" ); |
33 | my $user = $back->find_user( { username => 'somebody' } ); |
34 | isa_ok( $user, "Catalyst::Authentication::Store::LDAP::User" ); |
35 | my $displayname = $user->displayname; |
36 | cmp_ok( $displayname, 'eq', 'Some Body', 'Should be Some Body' ); |
37 | |
38 | isa_ok( $user->ldap_entry, "EntryClass", "entry_class works" ); |
39 | is( $user->ldap_entry->my_method, 1001, "methods on entry_class works" ); |
f66d606b |
40 | |
e385da71 |
41 | done_testing; |