From: Graham B. <gb...@us...> - 2003-05-21 08:10:57
|
Update of /cvsroot/perl-ldap/ldap/t In directory sc8-pr-cvs1:/tmp/cvs-serv9297/t Modified Files: 53schema.t Added Files: 03schema.t Log Message: Rename the existing schema test to 03schema.t as it does not require a server. Add new 53schema.t which obtains a schema from a server --- NEW FILE: 03schema.t --- #!perl -w use Net::LDAP::Schema; print "1..7\n"; my $schema = Net::LDAP::Schema->new( "data/schema.in" ) or die "Cannot open schema"; print "ok 1\n"; my @atts = $schema->all_attributes(); print "not " unless @atts == 55; print "ok 2\n"; print "The schema contains ", scalar @atts, " attributes\n"; my @ocs = $schema->all_objectclasses(); print "not " unless @ocs == 22; print "ok 3\n"; print "The schema contains ", scalar @ocs, " object classes\n"; @atts = $schema->must( "person" ); print "not " unless join(' ', sort map $_->{name}, @atts) eq join(' ',sort qw(cn sn objectClass)); print "ok 4\n"; print "The 'person' OC must have these attributes [", join( ",", map $_->{name}, @atts ), "]\n"; @atts = $schema->may( "mhsOrganizationalUser" ); print "not " if @atts; print "ok 5\n"; print "The 'mhsOrganizationalUser' OC may have these attributes [", join( ",", map $_->{name}, @atts ), "]\n"; print "not " if defined $schema->attribute('distinguishedName')->{max_length}; print "ok 6\n"; print "not " unless $schema->attribute('userPassword')->{max_length} == 128; print "ok 7\n"; use Data::Dumper; print Dumper($schema); Index: 53schema.t =================================================================== RCS file: /cvsroot/perl-ldap/ldap/t/53schema.t,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- 53schema.t 4 Feb 2002 18:59:02 -0000 1.4 +++ 53schema.t 21 May 2003 08:10:54 -0000 1.5 @@ -1,40 +1,19 @@ -#!perl -w -use Net::LDAP::Schema; - -print "1..7\n"; - -my $schema = Net::LDAP::Schema->new( "data/schema.in" ) or die "Cannot open schema"; -print "ok 1\n"; - -my @atts = $schema->all_attributes(); -print "not " unless @atts == 55; -print "ok 2\n"; +#!perl -print "The schema contains ", scalar @atts, " attributes\n"; +BEGIN { + require "t/common.pl"; + start_server(version => 3); +} -my @ocs = $schema->all_objectclasses(); -print "not " unless @ocs == 22; -print "ok 3\n"; -print "The schema contains ", scalar @ocs, " object classes\n"; +print "1..4\n"; -@atts = $schema->must( "person" ); -print "not " unless join(' ', sort map $_->{name}, @atts) eq join(' ',sort qw(cn sn objectClass)); -print "ok 4\n"; -print "The 'person' OC must have these attributes [", - join( ",", map $_->{name}, @atts ), - "]\n"; -@atts = $schema->may( "mhsOrganizationalUser" ); -print "not " if @atts; -print "ok 5\n"; -print "The 'mhsOrganizationalUser' OC may have these attributes [", - join( ",", map $_->{name}, @atts ), - "]\n"; +$ldap = client(); +ok($ldap, "client"); -print "not " if defined $schema->attribute('distinguishedName')->{max_length}; -print "ok 6\n"; +$schema = $ldap->schema; +ok($schema, "schema"); -print "not " unless $schema->attribute('userPassword')->{max_length} == 128; -print "ok 7\n"; +$ob = $schema->attribute('objectClass'); +ok($ob, 'objectClass'); -use Data::Dumper; -print Dumper($schema); +ok($ob->{syntax} eq '1.3.6.1.4.1.1466.115.121.1.38', 'syntax'); |