10 eval "use Catalyst::Model::LDAP";
11 plan skip_all => "Catalyst::Model::LDAP not installed" if $@;
13 my $server = LDAPTest::spawn_server();
15 use_ok("Catalyst::Authentication::Store::LDAP::Backend");
17 my $back = Catalyst::Authentication::Store::LDAP::Backend->new(
18 { 'ldap_server' => LDAPTest::server_host(),
19 'binddn' => 'anonymous',
20 'bindpw' => 'dontcarehow',
22 'user_basedn' => 'ou=foobar',
23 'user_filter' => '(&(objectClass=person)(uid=%s))',
24 'user_scope' => 'one',
25 'user_field' => 'uid',
27 'entry_class' => 'EntryClass',
31 isa_ok( $back, "Catalyst::Authentication::Store::LDAP::Backend" );
32 my $user = $back->find_user( { username => 'somebody' } );
33 isa_ok( $user, "Catalyst::Authentication::Store::LDAP::User" );
36 ok $user->dn,"Get DN from AUTOLOAD"; #THIS ONLY WORKS BECAUSE dn is included as a user attribute in the test LDAP server.
37 ok defined $user->has_attribute('dn'),"Get dn from has_attribute";
40 ok $user->username, "Get username from AUTOLOAD";
41 ok defined $user->has_attribute('username'),"Get username from has_attribute";
43 #Make sure both methods match output
44 ok $user->username eq $user->has_attribute('username'),"username from AUTOLOAD and has_attribute should match";
45 ok $user->dn eq $user->has_attribute('dn'),"dn from AUTOLOAD and has_attribute should match";