diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2dddf24a..f665ebb8 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -50,7 +50,7 @@ test: - 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 postgresql-client postgresql libapache2-mod-php curl xmlstarlet + - apt-get -y install libdbd-pg-perl libyaml-perl php php-cli php-pgsql php-xml php-curl postgresql-client postgresql libapache2-mod-php curl xmlstarlet - curl 'https://gitlab.com/davical-project/awl/-/archive/master/awl-master.tar.gz' | tar zxf - - mv awl-master /usr/share/awl/ - chown -R www-data /usr/share/awl/ @@ -61,6 +61,8 @@ test: - sed -i 's/\/path\/to/\/usr\/share/g' /etc/apache2/sites-enabled/davical-regression.conf - mkdir /usr/share/davical/testing/ - cp testing/*.php /usr/share/davical/testing/ + - mkdir /usr/share/davical/htdocs/testfiles + - ln -s /usr/share/davical/htdocs/testfiles htdocs - rm /etc/davical/config.php - cat testing/regression-conf.php.example | sed 's.//$c->dbg.$c->dbg.' > /etc/davical/regression-conf.php - ln -s /etc/davical/regression-conf.php /etc/davical/mycaldav-conf.php @@ -216,6 +218,8 @@ test_bullseye_latestphp: - sed -i 's/\/path\/to/\/usr\/share/g' /etc/apache2/sites-enabled/davical-regression.conf - mkdir /usr/share/davical/testing/ - cp testing/*.php /usr/share/davical/testing/ + - mkdir /usr/share/davical/htdocs/testfiles + - ln -s /usr/share/davical/htdocs/testfiles htdocs - rm /etc/davical/config.php - cat testing/regression-conf.php.example | sed 's.//$c->dbg.$c->dbg.' > /etc/davical/regression-conf.php - ln -s /etc/davical/regression-conf.php /etc/davical/mycaldav-conf.php @@ -261,7 +265,7 @@ test_memcache: - 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 postgresql-client postgresql libapache2-mod-php curl xmlstarlet memcached netcat-openbsd + - apt-get -y install libdbd-pg-perl libyaml-perl php php-cli php-pgsql php-xml php-memcached php-curl postgresql-client postgresql libapache2-mod-php curl xmlstarlet memcached netcat-openbsd - phpenmod memcached - curl 'https://gitlab.com/davical-project/awl/-/archive/master/awl-master.tar.gz' | tar zxf - - mv awl-master /usr/share/awl/ @@ -273,6 +277,8 @@ test_memcache: - sed -i 's/\/path\/to/\/usr\/share/g' /etc/apache2/sites-enabled/davical-regression.conf - mkdir /usr/share/davical/testing/ - cp testing/*.php /usr/share/davical/testing/ + - mkdir /usr/share/davical/htdocs/testfiles + - ln -s /usr/share/davical/htdocs/testfiles htdocs - rm /etc/davical/config.php - cat testing/regression-conf.php.example | sed 's.//$c->dbg.$c->dbg.' | sed 's.//memcache ..g' > /etc/davical/regression-conf.php - ln -s /etc/davical/regression-conf.php /etc/davical/mycaldav-conf.php @@ -320,7 +326,7 @@ test_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-ldap postgresql-client postgresql libapache2-mod-php curl xmlstarlet libnet-ldap-server-test-perl netcat-openbsd + - apt-get -y install libdbd-pg-perl libyaml-perl php php-cli php-pgsql php-xml php-ldap php-curl 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/ @@ -332,6 +338,8 @@ test_ldap: - sed -i 's/\/path\/to/\/usr\/share/g' /etc/apache2/sites-enabled/davical-regression.conf - mkdir /usr/share/davical/testing/ - cp testing/*.php /usr/share/davical/testing/ + - mkdir /usr/share/davical/htdocs/testfiles + - ln -s /usr/share/davical/htdocs/testfiles htdocs - rm /etc/davical/config.php - cat testing/regression-conf.php.example | sed 's.//$c->dbg.$c->dbg.' | sed -E 's.//(memcache|ldap) ..g' > /etc/davical/regression-conf.php - ln -s /etc/davical/regression-conf.php /etc/davical/mycaldav_ldap-conf.php diff --git a/inc/Principal.php b/inc/Principal.php index ee4be223..f9775d0c 100644 --- a/inc/Principal.php +++ b/inc/Principal.php @@ -414,6 +414,9 @@ class Principal { protected function FetchCollections() { if ( isset($this->collections) ) return; + // If this is an external binding, then user_no will most likely be empty. + if ( ! isset($this->user_no) ) return; + $this->collections = array(); $qry = new AwlQuery('SELECT * FROM collection WHERE user_no= :user_no', array(':user_no' => $this->user_no()) ); if ( $qry->Exec('Principal') ) { @@ -448,7 +451,7 @@ class Principal { if ( isset($this->collections[$dav_name]) && ($this->collections[$dav_name]->is_calendar == 't') ) { $this->default_calendar = $dav_name; } - else { + else if ( isset($this->collections) ) { foreach( $this->collections AS $dav_name => $collection ) { if ( $collection->is_calendar == 't' ) { $this->default_calendar = $dav_name; diff --git a/testing/apache-site.conf.example b/testing/apache-site.conf.example index 48eb8849..16c685f3 100644 --- a/testing/apache-site.conf.example +++ b/testing/apache-site.conf.example @@ -29,5 +29,6 @@ Listen 127.0.1.1:80 # let caldav.php handle "anything else" RewriteCond %{REQUEST_URI} !^/$ RewriteCond %{REQUEST_URI} !\.(php|css|png|gif|js|jpg|ico) + RewriteCond %{REQUEST_URI} !/testfiles/.*$ RewriteRule ^(.*)$ /caldav.php$1 [NC,L] diff --git a/testing/tests/binding/1300-BIND-external.result b/testing/tests/binding/1300-BIND-external.result index 6216b840..058d1981 100644 --- a/testing/tests/binding/1300-BIND-external.result +++ b/testing/tests/binding/1300-BIND-external.result @@ -9,7 +9,7 @@ Content-Type: text/plain; charset="utf-8" bind_id: >1058< bound_source_id: >1057< dav_displayname: >Moon< - dav_name: >/user4/Moon/< - external_url: >http://regression.host/testfiles/mooncal.ics?lang=de&phases%5Bfull%5D=true&phases%5Bnew%5D=true&phases%5Bquarter%5D=true&phases%5Bdaily%5D=false&events%5Blunareclipse%5D=true&events%5Bsolareclipse%5D=true&events%5Bmoonlanding%5D=false&before=P6M&after=P2Y&zone=CET< - parent_container: >/user4/< + dav_name: >/teamclient1/Moon/< + external_url: >http://regression/testfiles/mooncal.ics?lang=de&phases%5Bfull%5D=true&phases%5Bnew%5D=true&phases%5Bquarter%5D=true&phases%5Bdaily%5D=false&events%5Blunareclipse%5D=true&events%5Bsolareclipse%5D=true&events%5Bmoonlanding%5D=false&before=P6M&after=P2Y&zone=CET< + parent_container: >/teamclient1/< diff --git a/testing/tests/binding/1300-BIND-external.test b/testing/tests/binding/1300-BIND-external.test index 8c50f45e..05a0600d 100644 --- a/testing/tests/binding/1300-BIND-external.test +++ b/testing/tests/binding/1300-BIND-external.test @@ -3,8 +3,8 @@ # TYPE=BIND -URL=http://regression.host/caldav.php/user4/ -AUTH=user4:user4 +URL=http://regression.host/caldav.php/teamclient1/ +AUTH=admin:nimda HEADER=User-Agent: Test external bind HEADER=Content-Type: text/xml; charset="UTF-8" @@ -16,7 +16,7 @@ BEGINDATA Moon - http://regression.host/testfiles/mooncal.ics?lang=de&phases%5Bfull%5D=true&phases%5Bnew%5D=true&phases%5Bquarter%5D=true&phases%5Bdaily%5D=false&events%5Blunareclipse%5D=true&events%5Bsolareclipse%5D=true&events%5Bmoonlanding%5D=false&before=P6M&after=P2Y&zone=CET + http://regression/testfiles/mooncal.ics?lang=de&phases%5Bfull%5D=true&phases%5Bnew%5D=true&phases%5Bquarter%5D=true&phases%5Bdaily%5D=false&events%5Blunareclipse%5D=true&events%5Bsolareclipse%5D=true&events%5Bmoonlanding%5D=false&before=P6M&after=P2Y&zone=CET ENDDATA diff --git a/testing/tests/binding/1301-GET-fetch-external.test b/testing/tests/binding/1301-GET-fetch-external.test index 2de5eeb7..0e205976 100644 --- a/testing/tests/binding/1301-GET-fetch-external.test +++ b/testing/tests/binding/1301-GET-fetch-external.test @@ -5,8 +5,8 @@ # TYPE=GET -URL=http://regression.host/caldav.php/user4/Moon -AUTH=user4:user4 +URL=http://regression.host/caldav.php/teamclient1/Moon +AUTH=user1:user1 HEADER=User-Agent: DAViCalTester/public HEAD diff --git a/testing/tests/binding/1302-PROPFIND-external.result b/testing/tests/binding/1302-PROPFIND-external.result index e69de29b..cca87a5c 100644 --- a/testing/tests/binding/1302-PROPFIND-external.result +++ b/testing/tests/binding/1302-PROPFIND-external.result @@ -0,0 +1,487 @@ +HTTP/1.1 207 Multi-Status +Date: Dow, 01 Jan 2000 00:00:00 GMT +Content-Location: /caldav.php/teamclient1/ +DAV: 1, 2, 3, access-control, calendar-access, calendar-schedule +DAV: extended-mkcol, bind, addressbook, calendar-auto-schedule, calendar-proxy +ETag: "ac625cb5a5ff728cc50520d0aaae27dd" +Content-Length: 11956 +Content-Type: text/xml; charset="utf-8" + + + + + /caldav.php/teamclient1/ + + + + + + + + + + + Team for Client1 + "002aad3bf49fc30b841eedc6eb9d4206" + + /caldav.php/teamclient1/ + + + /caldav.php/.resources/1013 + + + + + + + /caldav.php/teamclient1/home/ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + HTTP/1.1 200 OK + + + + /caldav.php/teamclient1/Moon/ + + + + /caldav.php/teamclient1/Moon/?add_member + + + + + + + + + + + + + Moon + "4998d2df79f8f730e2f56f4d715bdba8" + + /caldav.php/.external/127bf0002abfcecbe9203a3015c9b54f + + + /caldav.php/.resources/1057 + + + + + + + + /caldav.php/ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + data:,7 + + HTTP/1.1 200 OK + + + + /caldav.php/teamclient1/home/ + + + + /caldav.php/teamclient1/home/?add_member + + + + + + + + + + + + + teamclient1 home + "edc1a74f98499d4a547a7c23125cabf2" + + /caldav.php/teamclient1/ + + + /caldav.php/.resources/450 + + + + + + + /caldav.php/teamclient1/home/ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + data:,8 + + HTTP/1.1 200 OK + + + + /caldav.php/teamclient1/addresses/ + + + + /caldav.php/teamclient1/addresses/?add_member + + + + + + + + + + teamclient1 addresses + "edc1a74f98499d4a547a7c23125cabf2" + + /caldav.php/teamclient1/ + + + /caldav.php/.resources/750 + + + + + + + /caldav.php/teamclient1/home/ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + data:,9 + + HTTP/1.1 200 OK + + + + /caldav.php/teamclient1/calendar-proxy-read/ + + + + /caldav.php/teamclient1/calendar-proxy-read/?add_member + + + + + + + + + + + + + /teamclient1/calendar-proxy-read/ + "bfc43198a490f445e8676ca22863d1f1" + + /caldav.php/teamclient1/ + + + + + + + + /caldav.php/teamclient1/home/ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + HTTP/1.1 200 OK + + + + /caldav.php/teamclient1/calendar-proxy-write/ + + + + /caldav.php/teamclient1/calendar-proxy-write/?add_member + + + + + + + + + + + + + /teamclient1/calendar-proxy-write/ + "f869e3b42c47170cd27adae8494859f3" + + /caldav.php/teamclient1/ + + + + + + + + /caldav.php/teamclient1/home/ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + HTTP/1.1 200 OK + + + diff --git a/testing/tests/binding/1302-PROPFIND-external.test b/testing/tests/binding/1302-PROPFIND-external.test index ab9863b2..5b58c8f6 100644 --- a/testing/tests/binding/1302-PROPFIND-external.test +++ b/testing/tests/binding/1302-PROPFIND-external.test @@ -6,10 +6,13 @@ # TYPE=PROPFIND -URL=http://regression.host/caldav.php/user4 -AUTH=user4:user4 +URL=http://regression.host/caldav.php/teamclient1 +AUTH=user1:user1 HEADER=User-Agent: DAViCalTester/public +HEADER=Brief: t +HEADER=Depth: 1 +HEADER=Prefer: return=minimal HEAD BEGINDATA