File: 09ldif-http-url.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 (39 lines) | stat: -rw-r--r-- 917 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
#!perl

use Test::More;
use Net::LDAP::LDIF;
use Net::LDAP::Entry;

BEGIN { require "t/common.pl" }

(eval { require LWP::UserAgent } && $HTTP_JPEG_URL && $HTTP_TEXT_URL)
? plan tests => 4
: plan skip_all => 'LWP::UserAgent module not installed or HTTP_JPEG_URL, HTTP_TEXT_URL not set';


my $ldifdata = <<"LDIF";
dn: cn=Sam One,ou=People,o=University of Michigan,c=US
jpegPhoto:< $HTTP_JPEG_URL
objectclass: OpenLDAPperson
cn: Sam One
uid: sam
sn: One
postalAddress:< $HTTP_TEXT_URL
LDIF

open(my $ldifhandle, '<', \$ldifdata);

my $ldif = Net::LDAP::LDIF->new($ldifhandle);
isa_ok($ldif, Net::LDAP::LDIF, "object");

my $entry = $ldif->read_entry;
isa_ok($entry, Net::LDAP::Entry, "entry");

my $photo = $entry->get_value('jpegPhoto');
ok(length($photo), 'jpegPhoto not empty');

my $address = $entry->get_value('postalAddress');
ok(length($address), 'postalAddress not empty');

#print STDERR $entry->dump ."\n";