File: 03schema.t

package info (click to toggle)
libnet-ldap-perl 1%3A0.6500%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: buster, stretch
  • size: 1,660 kB
  • ctags: 731
  • sloc: perl: 15,059; sh: 76; makefile: 5
file content (60 lines) | stat: -rw-r--r-- 2,459 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!perl -w

use Test::More tests => 14;
use Net::LDAP::Schema;

my $schema = Net::LDAP::Schema->new( "data/schema.in" ) or die "Cannot open schema";
isa_ok($schema, Net::LDAP::Schema, 'load schema file');

my @atts = $schema->all_attributes();
is(@atts, 265, 'number of attribute types in schema');
print "The schema contains ", scalar @atts, " attributes\n";

my @ocs = $schema->all_objectclasses();
is(@ocs, 66, 'number of object classes in schema');
print "The schema contains ", scalar @ocs, " object classes\n";

my @mrs = $schema->all_matchingrules();
is(@mrs, 40, 'number of matching rules in schema');
print "The schema contains ", scalar @mrs, " matching rules\n";

my @mrus = $schema->all_matchingruleuses();
is(@mrus, 34, 'number of matching rule uses in schema');
print "The schema contains ", scalar @mrus, " matching rule uses\n";

my @stxs = $schema->all_syntaxes();
is(@stxs, 32, 'number of LDAP syntaxes in schema');
print "The schema contains ", scalar @stxs, " LDAP syntaxes\n";

%namechildren = map { $_->{name} => 1 }
                    grep { grep(/^name$/i, @{$_->{sup}}) }
                         $schema->all_attributes();
is(scalar(keys(%namechildren)), 13, "attributes derived from 'name'");

@atts = $schema->must( "person" );
is(join(' ', sort map { lc $_->{name} } @atts),
   join(' ', sort map lc, qw(cn sn objectClass)), 'mandatory attributes');
print "The 'person' OC must have these attributes [",
		join(',', map $_->{name}, @atts),
		"]\n";

@atts = $schema->may( "mhsOrganizationalUser" );
ok(!@atts, 'optional attributes');
print "The 'mhsOrganizationalUser' OC may have these attributes [",
		join(',', map $_->{name}, @atts),
		"]\n";

@super = $schema->superclass('OpenLDAPperson');
is(join(' ', sort map lc, @super),
   join(' ', sort map lc, qw(pilotPerson inetOrgPerson)), 'superclass');

$mru = $schema->matchingruleuse('generalizedtimematch');
is(join(' ', sort map lc, @{$mru->{applies}}),
   join(' ', sort map lc, qw(createTimestamp modifyTimestamp)), 'attribute types a matching rule applies to');
   
@binarysyntaxes = map { $_->{name} } grep { $_->{'x-binary-transfer-required'} } $schema->all_syntaxes();
is(scalar(@binarysyntaxes), 5, "number of syntaxes that need ';binary' appended to the attribute type");

ok(! defined($schema->attribute('distinguishedName')->{max_length}), 'infinite length attribute type');

is($schema->attribute('userPassword')->{max_length}, 128, 'attribute type max. length');