rename from ::Plugin and refactor tests
[catagits/Catalyst-Authentication-Store-LDAP.git] / t / 03-entry_class.t
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5 use Catalyst::Exception;
6
7 use Test::More tests => 6;
8 use lib 't/lib';
9 use LDAPTest;
10 my $server = LDAPTest::spawn_server();
11
12 SKIP: {
13
14     eval "use Catalyst::Model::LDAP";
15     if ($@) {
16         skip "Catalyst::Model::LDAP not installed", 6;
17     }
18
19     use_ok("Catalyst::Authentication::Store::LDAP::Backend");
20
21     my $back = Catalyst::Authentication::Store::LDAP::Backend->new(
22         {   'ldap_server' => LDAPTest::server_host(),
23             'binddn'      => 'anonymous',
24             'bindpw'      => 'dontcarehow',
25             'start_tls'   => 0,
26             'user_basedn' => 'ou=foobar',
27             'user_filter' => '(&(objectClass=person)(uid=%s))',
28             'user_scope'  => 'one',
29             'user_field'  => 'uid',
30             'use_roles'   => 0,
31             'entry_class' => 'EntryClass',
32         }
33     );
34
35     isa_ok( $back, "Catalyst::Authentication::Store::LDAP::Backend" );
36     my $user = $back->find_user( { username => 'somebody' } );
37     isa_ok( $user, "Catalyst::Authentication::Store::LDAP::User" );
38     my $displayname = $user->displayname;
39     cmp_ok( $displayname, 'eq', 'Some Body', 'Should be Some Body' );
40
41     isa_ok( $user->ldap_entry, "EntryClass", "entry_class works" );
42     is( $user->ldap_entry->my_method, 1001, "methods on entry_class works" );
43
44 }