Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 68 lines (46 sloc) 1.799 kb
455ad0f @gbarr Initial revision
gbarr authored
1 #!perl
2
3 BEGIN {
4 require "t/common.pl";
5 }
6
7
d35350c @gbarr *** empty log message ***
gbarr authored
8 print "1..8\n";
455ad0f @gbarr Initial revision
gbarr authored
9
10 use Net::LDAP::LDIF;
11
12 my $infile = "data/00-in.ldif";
13 my $outfile = "$TEMPDIR/00-out1.ldif";
14 my $cmpfile = $infile;
15
16 @entry = Net::LDAP::LDIF->new($infile,"r")->read;
17
18 Net::LDAP::LDIF->new($outfile,"w")->write(@entry);
19
20 print "not " if compare($cmpfile,$outfile);
21 print "ok 1\n";
22
23 $e = $entry[0];
24
25 $e->changetype('modify');
26 $e->delete('objectclass');
27 $e->delete('o',['UM']);
28 $e->add('counting',[qw(one two three)]);
29 $e->replace('telephonenumber' => ['911']);
30
31 $outfile = "$TEMPDIR/00-out2.ldif";
32 $cmpfile = "data/00-cmp2.ldif";
33
34 $ldif = Net::LDAP::LDIF->new($outfile,"w");
35 $ldif->write($e);
36 $ldif->write_cmd($e);
37 $ldif->done;
38 print "not " if compare($cmpfile,$outfile);
39 print "ok 2\n";
d35350c @gbarr *** empty log message ***
gbarr authored
40
41 $e->add('name' => 'Graham Barr');
42 $e->add('name;en-us' => 'Bob');
43
44 print "not " unless join(":",sort $e->attributes) eq "associateddomain:counting:description:l:lastmodifiedby:lastmodifiedtime:name:name;en-us:o:postaladdress:st:streetaddress:telephonenumber";
45 print "ok 3\n";
46
47 print "not " unless join(":",sort $e->attributes(nooptions => 1)) eq "associateddomain:counting:description:l:lastmodifiedby:lastmodifiedtime:name:o:postaladdress:st:streetaddress:telephonenumber";
48 print "ok 4\n";
49
50 $r = $e->get('name');
51 print "not " unless $r and @$r == 1 and $r->[0] eq 'Graham Barr';
52 print "ok 5\n";
53
54 $r = $e->get('name;en-us');
55 print "not " unless $r and @$r == 1 and $r->[0] eq 'Bob';
56 print "ok 6\n";
57
58 $r = $e->get('name', alloptions => 1);
59 print "not " unless $r and join("*", sort keys %$r) eq "*;en-us";
60 print "ok 6\n";
61
62 print "not " unless $r and $r->{''} and @{$r->{''}} == 1 and $r->{''}[0] eq 'Graham Barr';
63 print "ok 7\n";
64
65 print "not " unless $r and $r->{';en-us'} and @{$r->{';en-us'}} == 1 and $r->{';en-us'}[0] eq 'Bob';
66 print "ok 8\n";
67
Something went wrong with that request. Please try again.