add tests for persist_in_session
[catagits/Catalyst-Authentication-Store-LDAP.git] / t / 05-user_attributes.t
CommitLineData
a4427384 1#!/usr/bin/perl
2
3use strict;
4use warnings;
a4427384 5
e385da71 6use Test::More;
a4427384 7use lib 't/lib';
8use LDAPTest;
9
e385da71 10eval "use Catalyst::Model::LDAP";
11plan skip_all => "Catalyst::Model::LDAP not installed" if $@;
a4427384 12
e385da71 13my $server = LDAPTest::spawn_server();
a4427384 14
e385da71 15use_ok("Catalyst::Authentication::Store::LDAP::Backend");
a4427384 16
e385da71 17my $back = Catalyst::Authentication::Store::LDAP::Backend->new(
18 { 'ldap_server' => LDAPTest::server_host(),
19 'binddn' => 'anonymous',
20 'bindpw' => 'dontcarehow',
21 'start_tls' => 0,
22 'user_basedn' => 'ou=foobar',
23 'user_filter' => '(&(objectClass=person)(uid=%s))',
24 'user_scope' => 'one',
25 'user_field' => 'uid',
26 'use_roles' => 0,
27 'entry_class' => 'EntryClass',
28 }
29);
a4427384 30
e385da71 31isa_ok( $back, "Catalyst::Authentication::Store::LDAP::Backend" );
32my $user = $back->find_user( { username => 'somebody' } );
33isa_ok( $user, "Catalyst::Authentication::Store::LDAP::User" );
a4427384 34
e385da71 35#Check DN
36ok $user->dn,"Get DN from AUTOLOAD"; #THIS ONLY WORKS BECAUSE dn is included as a user attribute in the test LDAP server.
37ok defined $user->has_attribute('dn'),"Get dn from has_attribute";
a4427384 38
e385da71 39#Check Username
40ok $user->username, "Get username from AUTOLOAD";
41ok defined $user->has_attribute('username'),"Get username from has_attribute";
a4427384 42
e385da71 43#Make sure both methods match output
44ok $user->username eq $user->has_attribute('username'),"username from AUTOLOAD and has_attribute should match";
45ok $user->dn eq $user->has_attribute('dn'),"dn from AUTOLOAD and has_attribute should match";
a4427384 46
e385da71 47done_testing;