Commit Graph
141 Commits
Author SHA1 Message Date
Justin Warren 2469e045d8 Add 'description' field to alias and alias_domain tables. (#1042)
Adds a `description` field to the `alias` and `alias_domain` tables, so you can add a comment explaining why the alias exists.

Partially addresses #1036

thanks @jpwarren
2026-06-08 09:08:02 +01:00
Copilot ae7339afd4 Use native booleans for prepared SQL params; stop binding db_get_boolean() values (#1019)
Prepared statements were binding DB-specific boolean literals (`'t'/'f'`) produced by `db_get_boolean()`, which breaks PostgreSQL parameter typing in some paths (notably mailbox creation via handler flows). 

This change standardizes bound boolean parameters to native PHP `true`/`false` (which are then cast to 0/1 which seems to work fine within PDO/PostgreSQL).

fixes https://github.com/postfixadmin/postfixadmin/issues/1017
2026-04-23 19:28:01 +01:00
Kent Riboe 2cce49a657 Add tests for db_where_clause() and db_delete() with additional params (#1021)
Adds test coverage for the core query-building functions refactored in #1004:
 - db_where_clause()
 - db_delete()
2026-04-22 13:41:47 +01:00
David Goodwin b420341083 let down by formatting again :( 2026-04-21 09:17:57 +01:00
David Goodwin a762682d7c token test of PFAHandler::col() and 9th param rename from $options to $not_in_db 2026-04-21 09:15:20 +01:00
David Goodwin ca4dae3ffe Phpunit updates (fix phpunit run, should fix build) (#1016)
should fix build, which is currently failing due to a stale phpunit config and poor choice of class name
2026-04-18 10:42:02 +01:00
Kent Riboe 2c0a06f932 Add Exec class to help refactor/reduce duplication of proc_open calls, update phpunit (see note) (#1009)
* code refactoring (adds Exec class to centralise proc_open like calls). 
* bump phpunit to ^11.0, as this is the last release that supports php8.2. Note, there is not (yet?) a phpunit release for php8.2 that fixes PKSA-z3gr-8qht-p93v or PKSA-5jz8-6tcw-pbk4, so ignore them for now in composer.json
2026-04-18 10:05:35 +01:00
Kent Riboe c376b56029 Add regression tests for global admin TOTP exception privileges (#1015)
* Add regression tests for global admin privilege check in TOTP exceptions (#1012)

Verifies that global admins with both 'admin' and 'global-admin' roles
can add TOTP exceptions for any domain, while regular admins are
restricted to their managed domains.

* Add tests for db_in_clause(): placeholders, empty array, unique keys, real query

Covers the parameterized query refactor from PR #1004.

* Move test cleanup to tearDown: add admin table delete and session unset

Prevents state leaking between tests, especially when expectException()
aborts the method before inline cleanup runs.

* Use assertEquals with exact expected SQL per review
2026-04-15 21:12:01 +01:00
David Goodwin f88236bf66 fix unit tests - handle booleans in postgresql being different from mysql etc 2026-04-06 20:29:16 +01:00
Kent Riboe 291609ae6f Add phpstan, MySQL and PostgreSQL test jobs to CI (#1005)
* Add phpstan for static analysis.
* Run unit tests against MySQL and PostgreSQL databases

Thanks @knofte
2026-04-06 09:01:44 +01:00
David Goodwin f20d12c16c use db specific boolean in sql (TotpPfTest) 2026-04-03 09:55:49 +01:00
David Goodwin 8a1f9a11af CSRF protection - support multiple tokens (#985)
possible fix for https://github.com/postfixadmin/postfixadmin/issues/967

CSRF Token changes : rather than have one PFA_Token value in $_SESSION, store a list of them, where each value has a time stamp it was issued on. The aim is to allow the user to have multiple browser tabs open at once - and not have the last tab that loaded trample on others. Tokens expire after 1 hour.

Adds a Smarty helper function `{CSRF_Token}` which will output `<input type=hidden name=CSRF_Token value=asdf123>` or `{CSRF_Token type=url}` which outputs a literal string like 'asdf123' suitable for placing in a URL.

Adds a PHP exception handler in public/common.php, which could be used to display a more friendly error message/response (but at the moment is fairly minimal).

Removes most uses of `die()` within the codebase, and instead moves to throw an exception
2026-03-01 19:30:16 +00:00
David Goodwin 0e3aa33207 fix test (removal of invalid namespace) 2026-02-28 16:45:34 +00:00
David Goodwin 8ef6bfe603 php 8.2 does not support array const things 2026-01-28 09:50:26 +00:00
David Goodwin ff0a3d7636 psalm stuff, add Languages class, token refactor 2026-01-28 09:50:26 +00:00
David Goodwin 7f175f9da8 remove reference to _pacrypt_crypt (deadcode) 2025-06-01 15:57:58 +01:00
David Goodwin 830160303f format 2025-06-01 15:52:25 +01:00
David Goodwin 6086cebacf remove more dead tests/code 2025-06-01 15:48:57 +01:00
David Goodwin 999bfcfc54 drop support for mysql_encrypt, given MySQL after 5.7 has dropped it and we had not wired it into the pacrypt() function anyway, try and improve docs in config.inc.php 2025-05-28 09:41:22 +01:00
David Goodwin 798e8b269c Topt app passwords fixes (WIP) (#805)
various improvements to the TOTP code see also:  #802
2025-05-16 20:31:20 +01:00
David Goodwin 759304ecb8 apparently these all need reformatting 2024-12-05 14:33:41 +00:00
David Goodwin 24b3b12581 MailboxHandler: change mailbox_postcreation_hook and maildir_name_hook CONF callable check to use is_callable() and not is_string() && function_exists() - this should allow someone to define a PHP 7+ style anonymous function within their config, add unit test to illustrate behaviour etc
see also #869 and #812
2024-11-12 20:12:53 +00:00
David Goodwin 476b203c0d tidy up unit tests (phpunit warnings) 2024-11-12 20:10:09 +00:00
David Goodwin b726c7aba8 ensure {MD5-CRYPT}$1$ and $1$... are treated the same .. see also #843 2024-07-16 11:16:48 +01:00
David Goodwin 2eb7f34844 try and fix phpunit deprecation warning - assertRegExp => assertMatchesRegularExpression 2024-04-22 21:08:57 +01:00
David Goodwin f01274ec94 try relaxing composer dependencies to allow php8.2 dev support, reformat so composer format passes 2024-04-22 21:02:01 +01:00
Shao Yu-Lung (Allen) 0876c368e4 feat: support Dovecot DIGEST-MD5 (#816)
Add support for dovecot DIGEST-MD5 auth (using : $CONF['pacrypt'] = 'dovecot:DIGEST-MD5') 

This also changes the pacrypt() function to take an optional 3rd argument (username). 
Thanks @bestlong
2024-04-12 09:57:19 +01:00
David Goodwin dc792a0222 add unit test to cover some of Login::addAppPassword() 2023-12-27 16:17:55 +00:00
David Goodwin 2ee4b3832e formatting 2023-12-24 19:40:49 +00:00
David Goodwin a368104fad token test 2023-12-24 19:39:47 +00:00
David Goodwin 605a019a24 better test coverage - make sure pacrypt() respects php_crypt:MD5 and makes something like $1$..... 2023-03-09 21:57:58 +00:00
David Goodwin 6f3c5a73ad add unit test for https://github.com/postfixadmin/postfixadmin/issues/647 2022-08-11 20:21:16 +01:00
David Goodwin d3e101e9d8 Merge remote-tracking branch 'origin/master' into feature/dkim 2022-07-18 08:55:07 +01:00
David Goodwin 2d6ded2786 PSR2 -> PSR12 formatting 2022-06-28 13:46:11 +01:00
David Goodwin bed0300fae fix tests (pacrypt/{md5raw} etc) 2022-06-23 22:18:16 +01:00
Fredrik Falk 9e73025058 Add Domain Key handling 2022-06-23 20:40:06 +02:00
David Goodwin 35486a2ca9 remove dead code 2022-06-06 20:35:53 +01:00
David Goodwin 760600cb56 one or more of something needs {1,} not {1} ... 2022-02-13 20:32:39 +00:00
Oliver Cooper 35ecb62730 Add password special character support 2022-02-13 17:21:20 +00:00
David Goodwin 4bc3e1464c make sure php_crypt:BLOWFISH works 2021-11-14 20:50:41 +00:00
David Goodwin 598f7db2e7 skip ARGON2ID* things if using an old PHP variant 2021-09-29 21:27:28 +01:00
David Goodwin 91a3dde446 older php variants do not have argon2i 2021-09-29 21:23:18 +01:00
David Goodwin 40101c84d4 fix formatting 2021-09-29 21:10:43 +01:00
David Goodwin ac13219894 improve test coverage / compatability 2021-09-29 21:05:19 +01:00
David Goodwin 309b4a84aa get legacy test case to pass 2021-09-29 18:32:46 +01:00
David Goodwin 0b9b7db917 Merge remote-tracking branch 'origin/master' into feature-improve-pacrypt 2021-09-29 18:04:49 +01:00
David Goodwin 561216c83d composer format 2021-09-25 20:34:32 +01:00
David Goodwin 55e7515c9c more testings (pacrypt() related) 2021-09-25 20:33:15 +01:00
David Goodwin 284e1f7eb2 fix test after language change 2021-07-08 19:44:11 +01:00
David Goodwin 179dd4c6e2 try and improve hashing, remove duplicate code, try and cope with the algorithm/method in $pw_db being different from the configured one; add tests 2021-05-11 21:56:48 +01:00