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