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