Version 1.017
[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 10my $server = LDAPTest::spawn_server();
a4427384 11
e385da71 12use_ok("Catalyst::Authentication::Store::LDAP::Backend");
a4427384 13
e385da71 14my $back = Catalyst::Authentication::Store::LDAP::Backend->new(
15 { 'ldap_server' => LDAPTest::server_host(),
16 'binddn' => 'anonymous',
17 'bindpw' => 'dontcarehow',
18 'start_tls' => 0,
19 'user_basedn' => 'ou=foobar',
20 'user_filter' => '(&(objectClass=person)(uid=%s))',
21 'user_scope' => 'one',
22 'user_field' => 'uid',
23 'use_roles' => 0,
24 'entry_class' => 'EntryClass',
25 }
26);
a4427384 27
e385da71 28isa_ok( $back, "Catalyst::Authentication::Store::LDAP::Backend" );
29my $user = $back->find_user( { username => 'somebody' } );
30isa_ok( $user, "Catalyst::Authentication::Store::LDAP::User" );
a4427384 31
e385da71 32#Check DN
33ok $user->dn,"Get DN from AUTOLOAD"; #THIS ONLY WORKS BECAUSE dn is included as a user attribute in the test LDAP server.
34ok defined $user->has_attribute('dn'),"Get dn from has_attribute";
a4427384 35
e385da71 36#Check Username
37ok $user->username, "Get username from AUTOLOAD";
38ok defined $user->has_attribute('username'),"Get username from has_attribute";
a4427384 39
e385da71 40#Make sure both methods match output
41ok $user->username eq $user->has_attribute('username'),"username from AUTOLOAD and has_attribute should match";
42ok $user->dn eq $user->has_attribute('dn'),"dn from AUTOLOAD and has_attribute should match";
a4427384 43
e385da71 44done_testing;