You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
1.1 KiB

10 years ago
#!/usr/bin/perl
use strict;
use warnings;
use utf8;
use LDV::LDAP;
use File::Slurp;
10 years ago
use Data::Dumper;
use Test::More tests => 9;
10 years ago
my $hash = read_file('conf/ldv.conf');
my $config = eval "$hash";
SKIP: {
skip "Can't load config", 9 unless (ref($config) eq 'HASH');
10 years ago
my $ldap = LDV::LDAP->new($config->{ldap});
isa_ok($ldap, "LDV::LDAP", "LDV::LDAP->new");
can_ok($ldap, qw(create delete get update));
10 years ago
is($ldap->get("test20"), undef, "get non-existing user");
is($ldap->create("test20"), undef, "creating user");
my $attrs = {uid => 'test20', cn => 'just', sn => 'created'};
is_deeply($ldap->get("test20"), $attrs, "getting data of newly created user");
$attrs = {uid => 'test20', cn => 'Полиграф', sn => 'Шариков'};
is($ldap->update("test20", $attrs), undef, "updating user data");
is($ldap->update("test20", {mail => 'abigvalg@example.com'}), undef, "updating user data");
$attrs->{mail} = 'abigvalg@example.com';
is_deeply($ldap->get("test20"), $attrs, "getting data of updated user");
is($ldap->delete("test20"), undef, "deleting user");
};
exit 0;