3918 Commits

Author SHA1 Message Date
Andrew Ruthven
eb4d120bbf Honour do_not_sync_from_ldap when sync'ing group members
This had been working as a side effect of the way the SQL insert
statement was working, but better to be explict about skipping them.
2024-02-17 02:25:25 +00:00
Andrew Ruthven
9494256f03 Extend LDAP sync tests, test for DNs in member fields. 2024-02-17 02:25:25 +00:00
Andrew Ruthven
8a6274e6cf Rather than look for a flag, if a member is a DN, modify/fetch the record.
This changes 48c6512a70740c403027b66e9d609e9b871d29c0, in Eric's commit it
needs a flag to go fetch the record and apply the mapping to find the
username field. This approach looks for a telltale that this is DN (naively
an "=") and then either grabs the first element from the DN if the username
attr matches or fetches the entry from LDAP.

There have also been attempts in the past to special case uniqueMember and
to add a group_member_dnfix config option.

This should handle the cases where people use uid/cn/whatever for the
username.
2024-02-17 02:25:25 +00:00
Andrew Ruthven
03d0e66b39 Handle there being no one in the group in the database 2024-02-17 02:25:25 +00:00
Andrew Ruthven
ef6bd9a7e9 fullname is a better default than group 2024-02-17 02:25:25 +00:00
Andrew Ruthven
98d9925241 Always update groups from LDAP
The logic actually handled updated group details, but only new groups were
being passed in. This will cause changes to what is being used for the
fullname to flow through.
2024-02-17 02:25:25 +00:00
Andrew Ruthven
b77b2640f8 The displayname can be unset, test for that 2024-02-17 02:25:25 +00:00
Andrew Ruthven
cb287c5abf Use filterUsers from the config 2024-02-17 02:25:25 +00:00
Andrew Ruthven
b0d01264e0 Various tidyups, show some more defaults, make a bit more current. 2024-02-17 02:25:25 +00:00
Andrew Ruthven
146ab4d068 Update test results for database creation.
I've rebased onto master which has a new DB version.
2024-02-17 02:25:25 +00:00
Andrew Ruthven
56d7d22d86 Rename mapping_field to user_mapping_field
This is to be consistent with group_mapping_field. The code is backwards
compatible with mapping_field.

In sync_LDAP_groups assign user_mapping once, not for every group.
2024-02-17 02:25:25 +00:00
Andrew Ruthven
3d28433b5b Fix the comments 2024-02-17 02:25:25 +00:00
Andrew Ruthven
9d40ae1aa7 Simplify the code by assigning the array after we've cleaned it up.
This allows shorter lines which means easier to understand code.
2024-02-17 02:25:25 +00:00
Andrew Ruthven
2a30a9646c Have some sane defaults for LDAP group mappings 2024-02-17 02:25:25 +00:00
Andrew Ruthven
13083b07e8 Rename username to name in group mappings, drop unused fullname from example
Usinger "username" for the group name is confusing and misleading. Just
use name, but support our users who still have username.

We don't use fullname, drop it from the example.
2024-02-17 02:25:25 +00:00
Andrew Ruthven
bb713137fd memberUid is deprecated, make member default 2024-02-17 02:25:25 +00:00
Andrew Ruthven
a7fc46a848 Add whitespace to sync_LDAP_groups
Make the function more readable.
2024-02-17 02:25:25 +00:00
Andrew Ruthven
820d0992eb Allow running from the root 2024-02-17 02:25:25 +00:00
Andrew Ruthven
995fe296c4 All debug output goes to STDERR so not combined with test results 2024-02-17 02:25:25 +00:00
Andrew Ruthven
86cb62f404 is_head_request is only used once, simplify 2024-02-17 02:25:25 +00:00
Andrew Ruthven
b15c99fe1b Add tests for LDAP sync of users and groups. 2024-02-17 02:25:25 +00:00
Andrew Ruthven
dc2991666a Allow the LDAP group to have no members 2024-02-17 02:25:25 +00:00
Andrew Ruthven
3846d31664 Handle there being no group members in the DB 2024-02-17 02:25:25 +00:00
Andrew Ruthven
1db3663302 We're using a baseDN, not querying a DN 2024-02-17 02:25:25 +00:00
Andrew Ruthven
775ecb8f3b Ensure that users_nothing_done is created as an array
This is likely only going to generate an error on the first time you
sync from LDAP, but still, let's not spit an unncessary error out.
2024-02-17 02:25:25 +00:00
Andrew Ruthven
ed7f308b87 Add default filters for users and groups
Some (all?) LDAP servers will just not respond if there is no filter,
provide a sensible default.
2024-02-17 02:25:25 +00:00
Andrew Ruthven
bacf08fea6 Wrap doc lines at 76 characters. 2024-02-17 02:25:25 +00:00
Andrew Ruthven
702fc05b57 Bail out early to prevent bogus errors if baseDNGroups isn't set 2024-02-17 02:25:25 +00:00
Andrew Ruthven
e73f2d73d4 Better handle when we can't talk to the server, log that 2024-02-17 02:25:25 +00:00
Andrew Ruthven
15e5a89675 Log better information about the connection to the server 2024-02-17 02:25:25 +00:00
Andrew Ruthven
30b05549d0 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.
2024-02-17 02:25:25 +00:00
Andrew Ruthven
353a2d1b13 Add testing for LDAP with memcache 2024-02-17 02:25:25 +00:00
Andrew Ruthven
7898efdfda Add the ability to run Perl snippets
This allows for more complicated test suites, which I'll use in the next commit...
2024-02-17 02:25:25 +00:00
Eric Wagner
016e51b4ac use username attr for matching group members 2024-02-17 02:25:25 +00:00
Andrew Ruthven
c75e7aee29 If curl is missing, complain, loudly
As requested on #175,
2024-02-04 01:40:08 +13:00
Andrew Ruthven
0a4471ab06 Wrap most lines in config file to 76 characters
This makes it a lot more readable on an 80 character wide terminal.
2024-02-03 06:24:50 +00:00
Andrew Ruthven
9dc52a5e25 Updates to other tests as side effects of adding room1 and room2 principals 2024-01-21 19:12:42 +13:00
Andrew Ruthven
1ca8284bdc Add ROOM as a principal type
This hopefully resolves #282.
2024-01-21 19:12:42 +13:00
Andrew Ruthven
bc33199083 Run patches when creating the database
From now on we should only provide patches, not a patch and modify
the initial SQL and data. Otherwise we never test the patches.
2024-01-21 17:47:23 +13:00
Andrew Ruthven
27f19cb3b3 Fix typo 2024-01-21 16:41:34 +13:00
Andrew Ruthven
39d0cd5837 Don't change passwords to $pwstars
The password input boxes are supposed to contain the value of $pwstars,
not the string '$pwstars'.
2024-01-21 13:34:30 +13:00
Andrew Ruthven
dabe01657d Bump the AWL version here as well 2024-01-20 15:27:51 +13:00
Andrew Ruthven
216c253ad9 Set a sane timeout for fetching the current DAViCal version
Without this it takes 90 seconds to timeout.
2024-01-20 15:27:51 +13:00
Andrew Ruthven
d42c3dc186 Add PHP version check to setup.php 2024-01-20 15:27:51 +13:00
Andrew Ruthven
3bf44378fa Fix checking if the session is active
The phpversion check was backwards. For PHP >= 5.4.0 we should be
using session_status() === PHP_SESSION_ACTIVE not < 5.4.0.

But in fact, we only support >= 5.4.0, so this check is now redundant.
2024-01-20 02:21:40 +00:00
Andrew Ruthven
ecda4395e8 Update to reflect change in tests 2024-01-19 19:49:02 +13:00
Andrew Ruthven
f137dd788e Update test to straddle the DST change
As pointed out in
https://gitlab.com/davical-project/davical/-/merge_requests/86#note_1209576949
the issue is when events straddle the DST change.
2024-01-19 19:48:03 +13:00
Andrew Ruthven
ff403b84a9 Update ETag, why?! 2024-01-19 19:13:07 +13:00
Chris S
069445579c Fix conversion to UTC for DST changes
The RepeatRuleDateTime constructor extracts the date's time zone then
passes it to the parent class DateTime. Because PHP's DateTime has full
support for time zones, it compensates for them when parsing a string.
Normally this isn't a problem, because the opposite occurs when a
DateTime is converted back into a string; the two adjustments cancel
each other.

Davical often converts a time to UTC by negating the time zone offset
and adding it to the underlying DateTime (keeping the time zone intact).
A problem occurs when the result is on the other side of a daylight-
saving-time transition. In that case the adjustments do not cancel and
an incorrect time string is returned.

This bug is tricky because the problem doesn't manifest during the DST
transition iself, but hours earlier or later depending on the original
time zone. For example, 2022-03-12T18:30:00-08:00 (America/Los_Angeles)
is 2022-03-13T02:30:00Z. Since 2022-03-13 is a 23-hour day in the Los
Angeles time zone (the 2AM-3AM hour is skipped) this becomes
2022-03-13T03:30:00-07:00 after adding the negated offset. FloatOrUTC()
would strip the new offset and simply return "20220313T033000".
2024-01-19 19:13:07 +13:00
Andrew Ruthven
5ef5c756f8 Tests to try and tickle an issue raised in MR 86
However, the result is what it should be? Interesting.

https://gitlab.com/davical-project/davical/-/merge_requests/86
2024-01-19 19:13:07 +13:00