From 30b05549d04ea435d55c5c1fb67107c680aaa14d Mon Sep 17 00:00:00 2001 From: Andrew Ruthven Date: Mon, 22 Jan 2024 02:03:26 +1300 Subject: [PATCH] Remove tests related to memcache, add BPS to copyright I re-used some of the test LDAP logic from the test suite of Request Tracker by BPS. --- .gitlab-ci.yml | 11 ++- .../tests/ldap/0000-clear-memcached.result | 1 - testing/tests/ldap/0000-clear-memcached.test | 3 - testing/tests/ldap/0001-test-ldap.test | 41 +++++++++--- .../0002-NoCachedCredentials-ldap1.result | 2 - .../ldap/0002-NoCachedCredentials-ldap1.test | 4 -- ...r.result => 0002-test-invalid-user.result} | 0 ...-user.test => 0002-test-invalid-user.test} | 0 testing/tests/ldap/0003-test-ldap.result | 67 ------------------- testing/tests/ldap/0003-test-ldap.test | 1 - .../ldap/0004-CachedCredentials-ldap1.result | 1 - .../ldap/0004-CachedCredentials-ldap1.test | 5 -- .../0006-NoCachedCredentials-ldap2.result | 2 - .../ldap/0006-NoCachedCredentials-ldap2.test | 4 -- .../tests/ldap/0007-test-invalid-user.result | 7 -- .../tests/ldap/0007-test-invalid-user.test | 66 ------------------ .../0008-CachedCredentialsFailed-ldap2.result | 1 - .../0008-CachedCredentialsFailed-ldap2.test | 5 -- 18 files changed, 34 insertions(+), 187 deletions(-) delete mode 100644 testing/tests/ldap/0000-clear-memcached.result delete mode 100644 testing/tests/ldap/0000-clear-memcached.test delete mode 100644 testing/tests/ldap/0002-NoCachedCredentials-ldap1.result delete mode 100644 testing/tests/ldap/0002-NoCachedCredentials-ldap1.test rename testing/tests/ldap/{0005-test-invalid-user.result => 0002-test-invalid-user.result} (100%) rename testing/tests/ldap/{0005-test-invalid-user.test => 0002-test-invalid-user.test} (100%) delete mode 100644 testing/tests/ldap/0003-test-ldap.result delete mode 120000 testing/tests/ldap/0003-test-ldap.test delete mode 100644 testing/tests/ldap/0004-CachedCredentials-ldap1.result delete mode 100644 testing/tests/ldap/0004-CachedCredentials-ldap1.test delete mode 100644 testing/tests/ldap/0006-NoCachedCredentials-ldap2.result delete mode 100644 testing/tests/ldap/0006-NoCachedCredentials-ldap2.test delete mode 100644 testing/tests/ldap/0007-test-invalid-user.result delete mode 100644 testing/tests/ldap/0007-test-invalid-user.test delete mode 100644 testing/tests/ldap/0008-CachedCredentialsFailed-ldap2.result delete mode 100644 testing/tests/ldap/0008-CachedCredentialsFailed-ldap2.test diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 844c1289..2dddf24a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -301,8 +301,7 @@ test_memcache: - mkdir -p davical_log - cp -r /var/log/davical davical_log/test_memcache -# Only test if the memcache test passes -test_memcache_and_ldap: +test_ldap: stage: testldap image: debian:unstable artifacts: @@ -321,8 +320,7 @@ test_memcache_and_ldap: - echo "en_NZ.UTF-8 UTF-8" >> /etc/locale.gen - locale-gen - echo "LANG=en_NZ.UTF-8" > /etc/default/locale - - apt-get -y install libdbd-pg-perl libyaml-perl php php-cli php-pgsql php-xml php-memcached php-ldap postgresql-client postgresql libapache2-mod-php curl xmlstarlet memcached libnet-ldap-server-test-perl netcat-openbsd - - phpenmod memcached + - apt-get -y install libdbd-pg-perl libyaml-perl php php-cli php-pgsql php-xml php-ldap postgresql-client postgresql libapache2-mod-php curl xmlstarlet libnet-ldap-server-test-perl netcat-openbsd - phpenmod ldap - curl 'https://gitlab.com/davical-project/awl/-/archive/master/awl-master.tar.gz' | tar zxf - - mv awl-master /usr/share/awl/ @@ -349,14 +347,13 @@ test_memcache_and_ldap: - a2enmod rewrite - a2enmod headers - apache2ctl start - - /etc/init.d/memcached start - useradd testrunner # testrunner needs to be able to read /var/log/apache2/regression-error.log for the ldap tests. - adduser testrunner adm - cd testing && su testrunner -c 'IS_CI=yes ALLSUITES="ldap" ./run_regressions.sh all x' after_script: - mkdir -p apache2_log - - cp -r /var/log/apache2 apache2_log/test_memcache_and_ldap + - cp -r /var/log/apache2 apache2_log/test_ldap - xz apache2_log/test_memcache_and_ldap/* - mkdir -p davical_log - - cp -r /var/log/davical davical_log/test_memcache_and_ldap + - cp -r /var/log/davical davical_log/test_ldap diff --git a/testing/tests/ldap/0000-clear-memcached.result b/testing/tests/ldap/0000-clear-memcached.result deleted file mode 100644 index e178f823..00000000 --- a/testing/tests/ldap/0000-clear-memcached.result +++ /dev/null @@ -1 +0,0 @@ -OK diff --git a/testing/tests/ldap/0000-clear-memcached.test b/testing/tests/ldap/0000-clear-memcached.test deleted file mode 100644 index dd88e094..00000000 --- a/testing/tests/ldap/0000-clear-memcached.test +++ /dev/null @@ -1,3 +0,0 @@ -# Ensure that memcached has nothing cached. - -SCRIPT=echo flush_all | nc -N 127.0.0.1 11211 diff --git a/testing/tests/ldap/0001-test-ldap.test b/testing/tests/ldap/0001-test-ldap.test index b6ee3d2b..bb893ab1 100644 --- a/testing/tests/ldap/0001-test-ldap.test +++ b/testing/tests/ldap/0001-test-ldap.test @@ -1,3 +1,7 @@ +# Copyright (c) 2021-2024 Andrew Ruthven +# Portions Copyright (c) Best Practical Solutions, LLC +# , licensed under the GPL v2. +# BEGINPERL if ($debug) { $ENV{'LDAP_DEBUG'} = 1 }; @@ -21,18 +25,33 @@ $evaled{'ldap_server'} = Net::LDAP::Server::Test->new( $ldap_socket, auto_schema 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,$base"; -my $entry = { - cn => $username, - mail => "$username\@example.com", - uid => $username, - objectClass => 'User', - userPassword => 'ldap1', -}; +my $base = "dc=example,dc=com"; +my $users = "ou=users,$base"; +my $groups = "ou=groups,$base"; $ldap->add( $base ); -$ldap->add( $dn, attr => [%$entry] ); + +for my $username (qw/ldap1 ldap2/) { + my $dn = "uid=$username,$users"; + my $entry = { + cn => $username, + mail => "$username\@example.com", + uid => $username, + objectClass => 'User', + userPassword => $username, + }; + $ldap->add( $dn, attr => [%$entry] ); +} + +for my $group (qw/group1 group2/) { + my $dn = "cn=$group,$groups"; + (my $member = $group) =~ s/group/ldap/; + my $entry = { + cn => $group, + objectClass => 'groupofNames', + member => "cn=$member,$users", + }; + $ldap->add( $dn, attr => [%$entry] ); +} # We need to keep the client around, otherwise the test server will exit. $evaled{'ldap_client'} = $ldap; diff --git a/testing/tests/ldap/0002-NoCachedCredentials-ldap1.result b/testing/tests/ldap/0002-NoCachedCredentials-ldap1.result deleted file mode 100644 index ae4e4709..00000000 --- a/testing/tests/ldap/0002-NoCachedCredentials-ldap1.result +++ /dev/null @@ -1,2 +0,0 @@ -No cached credentials found - no salt -No cached credentials found diff --git a/testing/tests/ldap/0002-NoCachedCredentials-ldap1.test b/testing/tests/ldap/0002-NoCachedCredentials-ldap1.test deleted file mode 100644 index bee35669..00000000 --- a/testing/tests/ldap/0002-NoCachedCredentials-ldap1.test +++ /dev/null @@ -1,4 +0,0 @@ -# Make sure there are no cached credentials present. -SCRIPT=if [ $(grep "HTTPAuthLogin:CheckCache: No salt stored for ldap1" /var/log/apache2/regression-error.log | wc -l) -eq 1 ] ; then echo "No cached credentials found" - no salt; else echo "Cached credentials, salt present, failed"; fi -SCRIPT=if [ $(grep "HTTPAuthLogin:CheckCache: Cached credentials for ldap1 are good" /var/log/apache2/regression-error.log | wc -l) -eq 0 ] ; then echo "No cached credentials found"; else echo "Cached credentials, failed"; fi - diff --git a/testing/tests/ldap/0005-test-invalid-user.result b/testing/tests/ldap/0002-test-invalid-user.result similarity index 100% rename from testing/tests/ldap/0005-test-invalid-user.result rename to testing/tests/ldap/0002-test-invalid-user.result diff --git a/testing/tests/ldap/0005-test-invalid-user.test b/testing/tests/ldap/0002-test-invalid-user.test similarity index 100% rename from testing/tests/ldap/0005-test-invalid-user.test rename to testing/tests/ldap/0002-test-invalid-user.test diff --git a/testing/tests/ldap/0003-test-ldap.result b/testing/tests/ldap/0003-test-ldap.result deleted file mode 100644 index 2fedb1a2..00000000 --- a/testing/tests/ldap/0003-test-ldap.result +++ /dev/null @@ -1,67 +0,0 @@ -HTTP/1.1 207 Multi-Status -Date: Dow, 01 Jan 2000 00:00:00 GMT -DAV: 1, 2, 3, access-control, calendar-access, calendar-schedule -DAV: extended-mkcol, bind, addressbook, calendar-auto-schedule, calendar-proxy -ETag: "ed58709591152964fd4a584af5b55d79" -Content-Length: 942 -Content-Type: text/xml; charset="utf-8" - - - - - /caldav.php/ - - - - - - - HTTP/1.1 200 OK - - - - /caldav.php/resource1/ - - - - - - - - HTTP/1.1 200 OK - - - - /caldav.php/resource2/ - - - - - - - - HTTP/1.1 200 OK - - - - /caldav.php/ldap1/ - - - - - - - - HTTP/1.1 200 OK - - - - - active: >1< - email: >ldap1@example.com< - fullname: >ldap1< - last_used: >NULL< - password: >NULL< - user_no: >1001< - username: >ldap1< - diff --git a/testing/tests/ldap/0003-test-ldap.test b/testing/tests/ldap/0003-test-ldap.test deleted file mode 120000 index 40b0ea5b..00000000 --- a/testing/tests/ldap/0003-test-ldap.test +++ /dev/null @@ -1 +0,0 @@ -0001-test-ldap.test \ No newline at end of file diff --git a/testing/tests/ldap/0004-CachedCredentials-ldap1.result b/testing/tests/ldap/0004-CachedCredentials-ldap1.result deleted file mode 100644 index 3e377816..00000000 --- a/testing/tests/ldap/0004-CachedCredentials-ldap1.result +++ /dev/null @@ -1 +0,0 @@ -Cached credentials found diff --git a/testing/tests/ldap/0004-CachedCredentials-ldap1.test b/testing/tests/ldap/0004-CachedCredentials-ldap1.test deleted file mode 100644 index f9549fd0..00000000 --- a/testing/tests/ldap/0004-CachedCredentials-ldap1.test +++ /dev/null @@ -1,5 +0,0 @@ -# Check to see if the log line for cached credentials being valid is -# present. That is only issued if we're successfully fetch valid credentials -# from our cache. -SCRIPT=if [ $(grep "HTTPAuthLogin:CheckCache: Cached credentials for ldap1 are good" /var/log/apache2/regression-error.log | wc -l) -eq 1 ] ; then echo "Cached credentials found"; else echo "Cached credentials failed"; fi - diff --git a/testing/tests/ldap/0006-NoCachedCredentials-ldap2.result b/testing/tests/ldap/0006-NoCachedCredentials-ldap2.result deleted file mode 100644 index ae4e4709..00000000 --- a/testing/tests/ldap/0006-NoCachedCredentials-ldap2.result +++ /dev/null @@ -1,2 +0,0 @@ -No cached credentials found - no salt -No cached credentials found diff --git a/testing/tests/ldap/0006-NoCachedCredentials-ldap2.test b/testing/tests/ldap/0006-NoCachedCredentials-ldap2.test deleted file mode 100644 index 9991dda1..00000000 --- a/testing/tests/ldap/0006-NoCachedCredentials-ldap2.test +++ /dev/null @@ -1,4 +0,0 @@ -# Make sure there are no cached credentials present. -SCRIPT=if [ $(grep "HTTPAuthLogin:CheckCache: No salt stored for ldap2" /var/log/apache2/regression-error.log | wc -l) -eq 1 ] ; then echo "No cached credentials found - no salt"; else echo "Cached credentials, present, failed"; fi -SCRIPT=if [ $(grep "HTTPAuthLogin:CheckCache: Cached credentials for ldap2" /var/log/apache2/regression-error.log | wc -l) -eq 0 ] ; then echo "No cached credentials found"; else echo "Cached credentials, failed"; fi - diff --git a/testing/tests/ldap/0007-test-invalid-user.result b/testing/tests/ldap/0007-test-invalid-user.result deleted file mode 100644 index d0f20441..00000000 --- a/testing/tests/ldap/0007-test-invalid-user.result +++ /dev/null @@ -1,7 +0,0 @@ -HTTP/1.1 401 Unauthorized -Date: Dow, 01 Jan 2000 00:00:00 GMT -WWW-Authenticate: Basic realm="DAViCal CalDAV Server" -Content-Length: 40 -Content-Type: text/plain; ; charset="utf-8" - -Please log in for access to this system. diff --git a/testing/tests/ldap/0007-test-invalid-user.test b/testing/tests/ldap/0007-test-invalid-user.test deleted file mode 100644 index 2193af40..00000000 --- a/testing/tests/ldap/0007-test-invalid-user.test +++ /dev/null @@ -1,66 +0,0 @@ -# Test again for an invalid user to check that the failed credentials are -# cached. -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,$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 - -TYPE=PROPFIND -URL=http://regression_ldap.host/caldav.php/ -HEADER=Content-Type: text/xml -HEADER=Depth: 1 -AUTH=ldap2:ldap2 -HEAD - -BEGINDATA - - - - - - -ENDDATA - -# 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 - diff --git a/testing/tests/ldap/0008-CachedCredentialsFailed-ldap2.result b/testing/tests/ldap/0008-CachedCredentialsFailed-ldap2.result deleted file mode 100644 index c227af85..00000000 --- a/testing/tests/ldap/0008-CachedCredentialsFailed-ldap2.result +++ /dev/null @@ -1 +0,0 @@ -Cached credentials found, password incorrect diff --git a/testing/tests/ldap/0008-CachedCredentialsFailed-ldap2.test b/testing/tests/ldap/0008-CachedCredentialsFailed-ldap2.test deleted file mode 100644 index 9cd04f25..00000000 --- a/testing/tests/ldap/0008-CachedCredentialsFailed-ldap2.test +++ /dev/null @@ -1,5 +0,0 @@ -# Check to see if the log line for cached credentials being invalid is -# present. That is only issued if we've fetch a fail for the credentials -# from our cache. -SCRIPT=if [ $(grep "HTTPAuthLogin:CheckCache: Cached credentials for ldap2 are good and invalid" /var/log/apache2/regression-error.log | wc -l) -eq 1 ] ; then echo "Cached credentials found, password incorrect"; else echo "Cached credentials failed"; fi -