X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F05-user_attributes.t;fp=t%2F05-user_attributes.t;h=54d79c9cbd6342de9329674de0be00c13a213270;hb=e385da713da3f03f39bc2a43121ca9334e39155c;hp=88d3ac39086b7f63023760cbeb3cb8331e7dfec2;hpb=a6a8f29d3a4b04fc10e12e522380f0a1f8016a04;p=catagits%2FCatalyst-Authentication-Store-LDAP.git diff --git a/t/05-user_attributes.t b/t/05-user_attributes.t index 88d3ac3..54d79c9 100644 --- a/t/05-user_attributes.t +++ b/t/05-user_attributes.t @@ -4,50 +4,45 @@ use strict; use warnings; use Catalyst::Exception; -use Test::More tests => 9; +use Test::More; use lib 't/lib'; use LDAPTest; -SKIP: { +eval "use Catalyst::Model::LDAP"; +plan skip_all => "Catalyst::Model::LDAP not installed" if $@; - eval "use Catalyst::Model::LDAP"; - if ($@) { - skip "Catalyst::Model::LDAP not installed", 9; - } - - my $server = LDAPTest::spawn_server(); +my $server = LDAPTest::spawn_server(); - use_ok("Catalyst::Authentication::Store::LDAP::Backend"); +use_ok("Catalyst::Authentication::Store::LDAP::Backend"); - my $back = Catalyst::Authentication::Store::LDAP::Backend->new( - { 'ldap_server' => LDAPTest::server_host(), - 'binddn' => 'anonymous', - 'bindpw' => 'dontcarehow', - 'start_tls' => 0, - 'user_basedn' => 'ou=foobar', - 'user_filter' => '(&(objectClass=person)(uid=%s))', - 'user_scope' => 'one', - 'user_field' => 'uid', - 'use_roles' => 0, - 'entry_class' => 'EntryClass', - } - ); - - isa_ok( $back, "Catalyst::Authentication::Store::LDAP::Backend" ); - my $user = $back->find_user( { username => 'somebody' } ); - isa_ok( $user, "Catalyst::Authentication::Store::LDAP::User" ); +my $back = Catalyst::Authentication::Store::LDAP::Backend->new( + { 'ldap_server' => LDAPTest::server_host(), + 'binddn' => 'anonymous', + 'bindpw' => 'dontcarehow', + 'start_tls' => 0, + 'user_basedn' => 'ou=foobar', + 'user_filter' => '(&(objectClass=person)(uid=%s))', + 'user_scope' => 'one', + 'user_field' => 'uid', + 'use_roles' => 0, + 'entry_class' => 'EntryClass', + } +); - #Check DN - ok $user->dn,"Get DN from AUTOLOAD"; #THIS ONLY WORKS BECAUSE dn is included as a user attribute in the test LDAP server. - ok defined $user->has_attribute('dn'),"Get dn from has_attribute"; +isa_ok( $back, "Catalyst::Authentication::Store::LDAP::Backend" ); +my $user = $back->find_user( { username => 'somebody' } ); +isa_ok( $user, "Catalyst::Authentication::Store::LDAP::User" ); - #Check Username - ok $user->username, "Get username from AUTOLOAD"; - ok defined $user->has_attribute('username'),"Get username from has_attribute"; +#Check DN +ok $user->dn,"Get DN from AUTOLOAD"; #THIS ONLY WORKS BECAUSE dn is included as a user attribute in the test LDAP server. +ok defined $user->has_attribute('dn'),"Get dn from has_attribute"; - #Make sure both methods match output - ok $user->username eq $user->has_attribute('username'),"username from AUTOLOAD and has_attribute should match"; - ok $user->dn eq $user->has_attribute('dn'),"dn from AUTOLOAD and has_attribute should match"; +#Check Username +ok $user->username, "Get username from AUTOLOAD"; +ok defined $user->has_attribute('username'),"Get username from has_attribute"; +#Make sure both methods match output +ok $user->username eq $user->has_attribute('username'),"username from AUTOLOAD and has_attribute should match"; +ok $user->dn eq $user->has_attribute('dn'),"dn from AUTOLOAD and has_attribute should match"; -} +done_testing;