/[virtual-ldap]/t/ldap-koha.t
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /t/ldap-koha.t

Parent Directory Parent Directory | Revision Log Revision Log


Revision 89 - (show annotations)
Thu May 6 06:22:09 2010 UTC (13 years, 11 months ago) by dpavlin
File MIME type: application/x-troff
File size: 1325 byte(s)
dump config and don't re-use $search for results of search

1 #!/usr/bin/perl
2
3 use warnings;
4 use strict;
5
6 use Test::More tests => 76;
7 use Data::Dump qw(dump);
8
9 BEGIN {
10 use_ok 'Net::LDAP';
11 }
12
13 our $config;
14 ok( require( ( shift @ARGV || 't/config.pl' ) ), 'config.pl' );
15
16 diag "config ",dump($config);
17
18 sub ldap_check_error {
19 my $o = shift;
20 ok( ! $o->code, 'no errror' );
21 diag $o->error if $o->code;
22 }
23
24 ok( my $ldap = Net::LDAP->new( 'localhost:2389' ), 'new Net::LDAP' );
25
26 ok( my $bind = $ldap->bind, 'bind' );
27 ldap_check_error $bind;
28
29 sub check_search_attributes {
30 my $search = shift;
31
32 foreach my $entry ( $search->entries ) {
33 diag dump $entry;
34 map { ok( $_, "attribute $_" ) } grep { /^\Q$_\E$/i } $entry->attributes;
35 }
36 }
37
38 sub search {
39 my ($ldap,$search) = @_;
40 ok( my $result = $ldap->search( filter => $search ), "search $search" );
41 ldap_check_error $result;
42 ok( $result->entries, 'have results' );
43 return $result;
44 }
45
46 foreach my $search ( qw/
47 uid=dpavlin@ffzg.hr
48 pager=E00401001F77E218
49 / ) {
50 my $entries = search $ldap => $search;
51 check_search_attributes $entries => 'uid', 'mail', 'pager', 'memberOf';
52
53 $entries = search $ldap => "(&(objectclass=HrEduPerson)($search))";
54 check_search_attributes $entries => 'uid', 'mail', 'pager', 'memberOf';
55 }
56
57 search $ldap => $_ foreach ( qw/
58 objectclass=organizationalUnit
59 objectclass=group
60 / );
61
62 ok( $ldap->unbind, 'unbind' );

Properties

Name Value
svn:executable *
svn:mergeinfo

  ViewVC Help
Powered by ViewVC 1.1.26