don't skip tests that don't need Catalyst::Model::LDAP
[catagits/Catalyst-Authentication-Store-LDAP.git] / t / 04-user_class.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 use Storable qw/ freeze /;
10 use Test::Exception;
11
12 my $server = LDAPTest::spawn_server();
13
14 use_ok("Catalyst::Authentication::Store::LDAP::Backend");
15
16 my $back = Catalyst::Authentication::Store::LDAP::Backend->new(
17     {   'ldap_server' => LDAPTest::server_host(),
18         'binddn'      => 'anonymous',
19         'bindpw'      => 'dontcarehow',
20         'start_tls'   => 0,
21         'user_basedn' => 'ou=foobar',
22         'user_filter' => '(&(objectClass=person)(uid=%s))',
23         'user_scope'  => 'one',
24         'user_field'  => 'uid',
25         'use_roles'   => 0,
26         'user_class' => 'UserClass',
27     }
28 );
29
30 isa_ok( $back, "Catalyst::Authentication::Store::LDAP::Backend" );
31 my $user = $back->find_user( { username => 'somebody' } );
32 isa_ok( $user, "Catalyst::Authentication::Store::LDAP::User" );
33 isa_ok( $user, "UserClass");
34
35 is( $user->my_method, 'frobnitz', "methods on user class work" );
36
37 # RT 69615
38 diag("stop() server");
39 $server->stop();
40
41 $server = LDAPTest::spawn_server();
42 ok $user->check_password('foo'), 'Can check password';
43
44 my $frozen_user;
45 lives_ok { $frozen_user = freeze $user } 'Can freeze user with Storable';
46 ok $frozen_user, 'is frozen';
47
48 # RT 69615
49 diag("stop() server");
50 $server->stop();
51
52 done_testing;
53