mirror of
https://gitlab.com/davical-project/davical.git
synced 2026-01-27 00:33:34 +00:00
96 lines
2.2 KiB
Plaintext
96 lines
2.2 KiB
Plaintext
BEGINPERL
|
|
if ($debug) { $ENV{'LDAP_DEBUG'} = 1 };
|
|
|
|
use Net::LDAP::Server::Test;
|
|
use Net::LDAP;
|
|
use IO::Socket::INET;
|
|
|
|
#my $port = find_idle_port();
|
|
|
|
#my $ldap_port = RT::Test->find_idle_port;
|
|
my $ldap_port = 21394;
|
|
my $ldap_socket = IO::Socket::INET->new(
|
|
Listen => 5,
|
|
Proto => 'tcp',
|
|
Reuse => 1,
|
|
LocalPort => $ldap_port,
|
|
);
|
|
|
|
# Keep it around after this block exits.
|
|
$evaled{'ldap_server'} = Net::LDAP::Server::Test->new( $ldap_socket, auto_schema => 1 );
|
|
|
|
my $ldap = Net::LDAP->new("localhost:$ldap_port") || die "Failed to instantiate Net::LDAP: $!";
|
|
$ldap->bind();
|
|
my $username = "ldap1";
|
|
my $base = "dc=example,dc=com";
|
|
my $dn = "uid=$username,ou=users,$base";
|
|
my $entry = {
|
|
cn => $username,
|
|
mail => "$username\@example.com",
|
|
uid => $username,
|
|
objectClass => 'User',
|
|
userPassword => 'ldap1',
|
|
};
|
|
$ldap->add( $base );
|
|
$ldap->add( $dn, attr => [%$entry] );
|
|
|
|
# We need to keep the client around, otherwise the test server will exit.
|
|
$evaled{'ldap_client'} = $ldap;
|
|
#sleep 100;
|
|
ENDPERL
|
|
|
|
APPCONF=common
|
|
|
|
TYPE=PROPFIND
|
|
HEADER=Content-Type: text/xml
|
|
HEADER=Depth: 1
|
|
AUTH=ldap2:ldap2
|
|
HEAD
|
|
|
|
BEGINDATA
|
|
<?xml version="1.0" encoding="utf-8" ?>
|
|
<D:propfind xmlns:D="DAV:">
|
|
<D:prop>
|
|
<D:resourcetype/>
|
|
</D:prop>
|
|
</D:propfind>
|
|
ENDDATA
|
|
|
|
URL=http://regression_ldap.host/caldav.php/
|
|
|
|
# Check that no usr record has been created.
|
|
QUERY
|
|
SELECT active, email, fullname, last_used, password, username, user_no
|
|
FROM usr
|
|
WHERE username = 'ldap2';
|
|
ENDQUERY
|
|
|
|
# Make sure there are no cached credentials present.
|
|
BEGINPERL
|
|
my $log_file = '/var/log/apache2/regression-error.log';
|
|
open(my $log, "< $log_file")
|
|
|| die "Failed to open $log_file for reading: $!";
|
|
|
|
my $cached_creds = 0;
|
|
|
|
if (defined $request_id) {
|
|
while (<$log>) {
|
|
if (/davical: $request_id: ALL: HTTPAuth:CheckCache: (.*)/) {
|
|
my $msg = $1;
|
|
|
|
if ($msg =~ /^Cached credentials for ldap2/) {
|
|
$cached_creds = 1;
|
|
}
|
|
}
|
|
}
|
|
|
|
if ($cached_creds) {
|
|
print "Cached credentials found, unexpected, failed\n";
|
|
} else {
|
|
print "No cached credentials found, passed\n";
|
|
}
|
|
} else {
|
|
print "No request_id found, can't check log file, failed\n";
|
|
}
|
|
ENDPERL
|