Ensure that propfind for access is deterministic.

I noticed that the ordering of principals returned wasn't deterministic
for tests. Ensure it is.
This commit is contained in:
Andrew Ruthven 2022-12-10 01:07:52 +13:00 committed by Andrew Ruthven
parent c904ef5551
commit 8162b9f850
8 changed files with 52 additions and 48 deletions

View File

@ -205,6 +205,8 @@ class DAVPrincipal extends Principal
// whom are we a proxy for? who is a proxy for us?
// (as per Caldav Proxy section 5.1 Paragraph 7 and 5)
$sql = 'SELECT principal_id, username, pprivs(:request_principal::int8,principal_id,:scan_depth::int) FROM principal JOIN usr USING(user_no) WHERE usr.active=true AND principal_id IN (SELECT * from p_has_proxy_access_to(:request_principal,:scan_depth))';
if ( isset($c->strict_result_ordering) && $c->strict_result_ordering ) $sql .= " ORDER BY username";
$params = array( ':request_principal' => $this->principal_id, ':scan_depth' => $c->permission_scan_depth );
$qry = new AwlQuery($sql, $params);
if ( $qry->Exec('DAVPrincipal') && $qry->rows() > 0 ) {
@ -224,6 +226,8 @@ class DAVPrincipal extends Principal
$sql = 'SELECT principal_id, username, pprivs(principal_id,:request_principal::int8,:scan_depth::int) FROM principal JOIN usr USING(user_no) WHERE usr.active=true AND principal_id IN (SELECT * from grants_proxy_access_from_p(:request_principal,:scan_depth))';
*/
$sql = 'SELECT principal_id, username, pprivs(principal_id,:request_principal::int8,:scan_depth::int) FROM principal JOIN usr USING(user_no) WHERE usr.active=true AND principal_id IN (SELECT to_principal FROM grants WHERE by_principal = :request_principal AND (privileges & 5::BIT(24)) != 0::BIT(24) AND by_collection IS NULL AND to_principal != :request_principal )';
if ( isset($c->strict_result_ordering) && $c->strict_result_ordering ) $sql .= " ORDER BY username";
$qry = new AwlQuery($sql, $params ); // reuse $params assigned for earlier query
if ( $qry->Exec('DAVPrincipal') && $qry->rows() > 0 ) {
while( $relationship = $qry->Fetch() ) {

View File

@ -2,7 +2,7 @@ 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: "e8e214ead69e04c9895f54796a53e3ab"
ETag: "91baeafae14b1d363e1fe221e2eec6ba"
Content-Length: 5449
Content-Type: text/xml; charset="utf-8"
@ -22,16 +22,16 @@ Content-Type: text/xml; charset="utf-8"
<href>/caldav.php/assistant1/</href>
<href>/caldav.php/teamclient1/</href>
<href>/caldav.php/user1/</href>
<href>/caldav.php/user1/calendar-proxy-read/</href>
<href>/caldav.php/assistant1/calendar-proxy-read/</href>
<href>/caldav.php/resource1/calendar-proxy-read/</href>
<href>/caldav.php/resource2/calendar-proxy-read/</href>
<href>/caldav.php/user1/calendar-proxy-read/</href>
</group-membership>
<C:calendar-proxy-read-for>
<href>/caldav.php/user1/</href>
<href>/caldav.php/assistant1/</href>
<href>/caldav.php/resource1/</href>
<href>/caldav.php/resource2/</href>
<href>/caldav.php/user1/</href>
</C:calendar-proxy-read-for>
<C:calendar-proxy-write-for/>
</prop>
@ -59,16 +59,16 @@ Content-Type: text/xml; charset="utf-8"
<href>/caldav.php/assistant1/</href>
<href>/caldav.php/teamclient1/</href>
<href>/caldav.php/user1/</href>
<href>/caldav.php/user1/calendar-proxy-read/</href>
<href>/caldav.php/assistant1/calendar-proxy-read/</href>
<href>/caldav.php/resource1/calendar-proxy-read/</href>
<href>/caldav.php/resource2/calendar-proxy-read/</href>
<href>/caldav.php/user1/calendar-proxy-read/</href>
</group-membership>
<C:calendar-proxy-read-for>
<href>/caldav.php/user1/</href>
<href>/caldav.php/assistant1/</href>
<href>/caldav.php/resource1/</href>
<href>/caldav.php/resource2/</href>
<href>/caldav.php/user1/</href>
</C:calendar-proxy-read-for>
<C:calendar-proxy-write-for/>
</prop>
@ -96,16 +96,16 @@ Content-Type: text/xml; charset="utf-8"
<href>/caldav.php/assistant1/</href>
<href>/caldav.php/teamclient1/</href>
<href>/caldav.php/user1/</href>
<href>/caldav.php/user1/calendar-proxy-read/</href>
<href>/caldav.php/assistant1/calendar-proxy-read/</href>
<href>/caldav.php/resource1/calendar-proxy-read/</href>
<href>/caldav.php/resource2/calendar-proxy-read/</href>
<href>/caldav.php/user1/calendar-proxy-read/</href>
</group-membership>
<C:calendar-proxy-read-for>
<href>/caldav.php/user1/</href>
<href>/caldav.php/assistant1/</href>
<href>/caldav.php/resource1/</href>
<href>/caldav.php/resource2/</href>
<href>/caldav.php/user1/</href>
</C:calendar-proxy-read-for>
<C:calendar-proxy-write-for/>
</prop>
@ -135,10 +135,10 @@ Content-Type: text/xml; charset="utf-8"
</group-member-set>
<group-membership/>
<C:calendar-proxy-read-for>
<href>/caldav.php/user1/</href>
<href>/caldav.php/assistant1/</href>
<href>/caldav.php/resource1/</href>
<href>/caldav.php/resource2/</href>
<href>/caldav.php/user1/</href>
</C:calendar-proxy-read-for>
<C:calendar-proxy-write-for/>
</prop>
@ -167,10 +167,10 @@ Content-Type: text/xml; charset="utf-8"
</group-member-set>
<group-membership/>
<C:calendar-proxy-read-for>
<href>/caldav.php/user1/</href>
<href>/caldav.php/assistant1/</href>
<href>/caldav.php/resource1/</href>
<href>/caldav.php/resource2/</href>
<href>/caldav.php/user1/</href>
</C:calendar-proxy-read-for>
<C:calendar-proxy-write-for/>
</prop>

View File

@ -2,7 +2,7 @@ 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: "68b03f180d5f9046907a86251de16246"
ETag: "4c111185c0195e4661052bf3bc3dee43"
Content-Length: 1055
Content-Type: text/xml; charset="utf-8"
@ -24,10 +24,10 @@ Content-Type: text/xml; charset="utf-8"
</group-member-set>
<group-membership/>
<C:calendar-proxy-read-for>
<href>/caldav.php/user1/</href>
<href>/caldav.php/assistant1/</href>
<href>/caldav.php/resource1/</href>
<href>/caldav.php/resource2/</href>
<href>/caldav.php/user1/</href>
</C:calendar-proxy-read-for>
<C:calendar-proxy-write-for/>
</prop>

View File

@ -2,7 +2,7 @@ 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: "fc0f5539296edf051d8a53d6a2bfe8cc"
ETag: "be931b7b477402614832b2eaad980adc"
Content-Length: 764
Content-Type: text/xml; charset="utf-8"
@ -19,8 +19,8 @@ Content-Type: text/xml; charset="utf-8"
<href>/caldav.php/resource1/</href>
<href>/caldav.php/resource2/</href>
<href>/caldav.php/teamclient1/</href>
<href>/caldav.php/manager1/calendar-proxy-read/</href>
<href>/caldav.php/assistant1/calendar-proxy-read/</href>
<href>/caldav.php/manager1/calendar-proxy-read/</href>
<href>/caldav.php/resource1/calendar-proxy-write/</href>
<href>/caldav.php/resource2/calendar-proxy-write/</href>
</group-membership>

View File

@ -2,7 +2,7 @@ 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: "dc8a8dd8d55f610adb87fb0f9c1705cf"
ETag: "a1828a06d1da7b4133011c0675c22285"
Content-Length: 2405
Content-Type: text/xml; charset="utf-8"
@ -47,22 +47,6 @@ Content-Type: text/xml; charset="utf-8"
</response>
</A:calendar-proxy-write-for>
<A:calendar-proxy-read-for>
<response>
<href>/caldav.php/manager1/</href>
<propstat>
<prop>
<displayname>Manager 1</displayname>
<principal-URL>
<href>/caldav.php/manager1/</href>
</principal-URL>
<C:calendar-user-address-set>
<href>mailto:manager1@example.net</href>
<href>/caldav.php/manager1/</href>
</C:calendar-user-address-set>
</prop>
<status>HTTP/1.1 200 OK</status>
</propstat>
</response>
<response>
<href>/caldav.php/assistant1/</href>
<propstat>
@ -79,6 +63,22 @@ Content-Type: text/xml; charset="utf-8"
<status>HTTP/1.1 200 OK</status>
</propstat>
</response>
<response>
<href>/caldav.php/manager1/</href>
<propstat>
<prop>
<displayname>Manager 1</displayname>
<principal-URL>
<href>/caldav.php/manager1/</href>
</principal-URL>
<C:calendar-user-address-set>
<href>mailto:manager1@example.net</href>
<href>/caldav.php/manager1/</href>
</C:calendar-user-address-set>
</prop>
<status>HTTP/1.1 200 OK</status>
</propstat>
</response>
</A:calendar-proxy-read-for>
</prop>
<status>HTTP/1.1 200 OK</status>

View File

@ -2,7 +2,7 @@ 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: "0f4b3456426720dea03e25482da4057d"
ETag: "bd146c1ce543b0e0629c6df6abcccf96"
Content-Length: 1226
Content-Type: text/xml; charset="utf-8"
@ -31,8 +31,8 @@ Content-Type: text/xml; charset="utf-8"
<href>/caldav.php/resource1/</href>
<href>/caldav.php/resource2/</href>
<href>/caldav.php/teamclient1/</href>
<href>/caldav.php/manager1/calendar-proxy-read/</href>
<href>/caldav.php/assistant1/calendar-proxy-read/</href>
<href>/caldav.php/manager1/calendar-proxy-read/</href>
<href>/caldav.php/resource1/calendar-proxy-write/</href>
<href>/caldav.php/resource2/calendar-proxy-write/</href>
</group-membership>

View File

@ -2,7 +2,7 @@ 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: "3fc7af8b9dcea1aa7ead9fa8cfeb7efd"
ETag: "db22b03fc81436f25020e05135b0a710"
Content-Length: 3601
Content-Type: text/xml; charset="utf-8"
@ -92,7 +92,7 @@ Content-Type: text/xml; charset="utf-8"
</propstat>
</response>
<response>
<href>/caldav.php/manager1/calendar-proxy-read/</href>
<href>/caldav.php/assistant1/calendar-proxy-read/</href>
<propstat>
<prop>
<getcontenttype>httpd/unix-directory</getcontenttype>
@ -104,7 +104,7 @@ Content-Type: text/xml; charset="utf-8"
</propstat>
</response>
<response>
<href>/caldav.php/assistant1/calendar-proxy-read/</href>
<href>/caldav.php/manager1/calendar-proxy-read/</href>
<propstat>
<prop>
<getcontenttype>httpd/unix-directory</getcontenttype>

View File

@ -2,7 +2,7 @@ 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: "0d81b1b934eb738f04a8d9aee626b2f4"
ETag: "73b04fc52615d8c9cef678503931ad5f"
Content-Length: 3759
Content-Type: text/xml; charset="utf-8"
@ -85,18 +85,6 @@ Content-Type: text/xml; charset="utf-8"
<status>HTTP/1.1 200 OK</status>
</propstat>
</response>
<response>
<href>/caldav.php/manager1/calendar-proxy-read/</href>
<propstat>
<prop>
<displayname>manager1 proxy read</displayname>
<C:calendar-home-set>
<href>/caldav.php/manager1/</href>
</C:calendar-home-set>
</prop>
<status>HTTP/1.1 200 OK</status>
</propstat>
</response>
<response>
<href>/caldav.php/assistant1/calendar-proxy-read/</href>
<propstat>
@ -109,6 +97,18 @@ Content-Type: text/xml; charset="utf-8"
<status>HTTP/1.1 200 OK</status>
</propstat>
</response>
<response>
<href>/caldav.php/manager1/calendar-proxy-read/</href>
<propstat>
<prop>
<displayname>manager1 proxy read</displayname>
<C:calendar-home-set>
<href>/caldav.php/manager1/</href>
</C:calendar-home-set>
</prop>
<status>HTTP/1.1 200 OK</status>
</propstat>
</response>
<response>
<href>/caldav.php/resource1/calendar-proxy-write/</href>
<propstat>