|
|
|
@ -4,21 +4,31 @@ use strict;
|
|
|
|
|
use warnings; |
|
|
|
|
use utf8; |
|
|
|
|
|
|
|
|
|
use Test; |
|
|
|
|
use LDV::LDAP; |
|
|
|
|
use File::Slurp; |
|
|
|
|
use Data::Dumper; |
|
|
|
|
use Test::More tests => 8; |
|
|
|
|
|
|
|
|
|
BEGIN { plan test => 2 }; |
|
|
|
|
my $hash = read_file('conf/ldv.conf'); |
|
|
|
|
my $config = eval "$hash"; |
|
|
|
|
SKIP: { |
|
|
|
|
skip "Can't load config", 8 unless (ref($config) eq 'HASH'); |
|
|
|
|
|
|
|
|
|
my $ldap = LDV::LDAP->new({ |
|
|
|
|
server => '127.0.0.1', |
|
|
|
|
binddn => undef, |
|
|
|
|
bindpass => undef, |
|
|
|
|
userbase => undef, |
|
|
|
|
}); |
|
|
|
|
my $ldap = LDV::LDAP->new($config->{ldap}); |
|
|
|
|
isa_ok($ldap, "LDV::LDAP", "LDV::LDAP->new"); |
|
|
|
|
can_ok($ldap, qw(create delete get update)); |
|
|
|
|
|
|
|
|
|
print Dumper $ldap->get("ad_user"); |
|
|
|
|
#print Dumper $ldap->create("test20"); |
|
|
|
|
#print Dumper $ldap->get("test20"); |
|
|
|
|
#print Dumper $ldap->delete("test20"); |
|
|
|
|
print Dumper $ldap->get("test20"); |
|
|
|
|
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_deeply($ldap->get("test20"), $attrs, "getting data of updated user"); |
|
|
|
|
|
|
|
|
|
is($ldap->delete("test20"), undef, "deleting user"); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
exit 0; |
|
|
|
|