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