Commit | Line | Data |
405489b5 |
1 | #!/usr/bin/perl |
2 | |
3 | use strict; |
4 | use warnings; |
405489b5 |
5 | |
e385da71 |
6 | use Test::More; |
405489b5 |
7 | use lib 't/lib'; |
8 | use LDAPTest; |
8fe890e6 |
9 | use Storable qw/ freeze /; |
10 | use Test::Exception; |
405489b5 |
11 | |
e385da71 |
12 | eval "use Catalyst::Model::LDAP"; |
13 | plan skip_all => "Catalyst::Model::LDAP not installed" if $@; |
405489b5 |
14 | |
e385da71 |
15 | my $server = LDAPTest::spawn_server(); |
405489b5 |
16 | |
e385da71 |
17 | use_ok("Catalyst::Authentication::Store::LDAP::Backend"); |
405489b5 |
18 | |
e385da71 |
19 | my $back = Catalyst::Authentication::Store::LDAP::Backend->new( |
20 | { 'ldap_server' => LDAPTest::server_host(), |
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 | 'user_class' => 'UserClass', |
30 | } |
31 | ); |
405489b5 |
32 | |
e385da71 |
33 | isa_ok( $back, "Catalyst::Authentication::Store::LDAP::Backend" ); |
34 | my $user = $back->find_user( { username => 'somebody' } ); |
35 | isa_ok( $user, "Catalyst::Authentication::Store::LDAP::User" ); |
36 | isa_ok( $user, "UserClass"); |
405489b5 |
37 | |
e385da71 |
38 | is( $user->my_method, 'frobnitz', "methods on user class work" ); |
405489b5 |
39 | |
e385da71 |
40 | # RT 69615 |
41 | diag("stop() server"); |
42 | $server->stop(); |
195f2f1f |
43 | |
e385da71 |
44 | $server = LDAPTest::spawn_server(); |
45 | ok $user->check_password('foo'), 'Can check password'; |
8fe890e6 |
46 | |
e385da71 |
47 | my $frozen_user; |
48 | lives_ok { $frozen_user = freeze $user } 'Can freeze user with Storable'; |
49 | ok $frozen_user, 'is frozen'; |
8fe890e6 |
50 | |
e385da71 |
51 | # RT 69615 |
52 | diag("stop() server"); |
53 | $server->stop(); |
195f2f1f |
54 | |
e385da71 |
55 | done_testing; |
8fe890e6 |
56 | |