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