Commit Graph

520 Commits

Author SHA1 Message Date
Piotr F. Mieszkowski addb119b3e Update INSTALL.md
- Explain requirements files are used now.
- Mention recommended Python version.
- Refresh instructions after splitting Lacre into components.
2023-06-25 22:31:34 +02:00
Piotr F. Mieszkowski bcd0284eac Update README
- Simplify where possible.
- Remove outdated parts.
- Explain that only Python 3.9 is tested and supported.
- Link to Lacre Webgate repository.
2023-06-18 21:31:47 +02:00
pfm c8f6743768 Merge pull request 'Handle missing Content-Type properly' (#125) from 124-missing-ct into main
Reviewed-on: #125
2023-05-19 18:38:17 +00:00
Piotr F. Mieszkowski a30b5e7577 Handle missing Content-Type properly
- ContentManager sets default Content-Type even if it was missing in the
  original message.

- Make sure that when Content-Type is missing, copying parameters doesn't
  raise an error.

- Add a unit-test to check that.
2023-05-19 20:30:00 +02:00
pfm 07fb8d6ae8 Merge pull request 'Fix encoding issues' (#123) from post-test-fixes into main
Reviewed-on: #123
2023-05-11 20:22:23 +00:00
Piotr F. Mieszkowski 5a5b6c27a4 Fix tests after rebase 2023-05-08 22:32:19 +02:00
Piotr F. Mieszkowski 3297bbfcca Clean up and document Advanced Mail Filter E2E test
- Remove unused code.
- Add docstrings.
2023-05-08 22:17:02 +02:00
Piotr F. Mieszkowski b3c0235486 Make case-discovery code cleaner and more flexible 2023-05-08 22:17:02 +02:00
Piotr F. Mieszkowski 0cdbf5ba7d Add emoji test 2023-05-08 22:17:02 +02:00
Piotr F. Mieszkowski c08d66ac80 Migrate daemon E2E tests to unittest framework 2023-05-08 22:17:02 +02:00
Piotr F. Mieszkowski 518b823b5c Fix simple filter: pass policy to as_bytes()
Also: adjust expected test output because it's now Base64-encoded.
2023-05-08 22:17:02 +02:00
Piotr F. Mieszkowski 459779bea6 Add more test cases 2023-05-08 22:17:02 +02:00
Piotr F. Mieszkowski 61cf50effe Fix MIME content sub-type handling for non-plain text messages 2023-05-08 22:17:02 +02:00
Piotr F. Mieszkowski bc92d7a31c [e2e_test] Identify test cases by iteracting config sections 2023-05-08 22:17:02 +02:00
Piotr F. Mieszkowski da0ffb4a51 Add a test message with Emoji 2023-05-08 22:17:02 +02:00
Piotr F. Mieszkowski 34e8b6a4eb Move the last key-related function to keyring module 2023-05-08 22:17:02 +02:00
Piotr F. Mieszkowski 285f5dbf18 Don't overwrite CTE
We rely on Content Manager to select the right Content-Transfer-Encoding.
2023-05-08 22:17:02 +02:00
Piotr F. Mieszkowski 1acb330c02 Rewrite e2e_test to use unittest framework 2023-05-08 22:17:02 +02:00
Piotr F. Mieszkowski fdd11dba14 Log more information about FS events while reloading keys 2023-05-08 22:17:02 +02:00
Piotr F. Mieszkowski 682de14630 Split the code into smaller modules
Introduce modules:
- lacre.transport - for actual delivery via SMTP
- lacre.smime - to take care of S/MIME stuff

Implement lacre.transport.SendFrom class that does a almost exactly the same
thing as the original send_msg function, but without using global variable to
store original message sender.
2023-05-08 22:17:02 +02:00
Piotr F. Mieszkowski ff6e0bfbdd Move recipient-processing code to a dedicated module 2023-05-08 22:17:02 +02:00
Piotr F. Mieszkowski 5f5b374f84 Unify send_msg, add more type hints 2023-05-08 22:17:02 +02:00
Piotr F. Mieszkowski 67e6df17fb Move success flag before 'try' 2023-05-08 22:17:02 +02:00
Piotr F. Mieszkowski 0da169ae61 Log exceptions from failover delivery 2023-05-08 22:17:02 +02:00
Piotr F. Mieszkowski f4e21217c2 [simple-filter] Retry delivery recoding text parts 2023-05-08 22:17:02 +02:00
Piotr F. Mieszkowski 1f1fe1dadb Add lots of log messages 2023-05-08 22:17:02 +02:00
Piotr F. Mieszkowski 8a42f3fea1 Improve error-handling for simple filter and test relay 2023-05-08 22:17:02 +02:00
Piotr F. Mieszkowski 8def4b40dc Correct sample message in contract tests 2023-05-08 22:17:02 +02:00
Piotr F. Mieszkowski e595e8baf4 Fix contract tests 2023-05-08 22:17:02 +02:00
Piotr F. Mieszkowski a5f79c1ae7 Wrap recipient lists
Instead of passing pairs of lists (emails and keys) separately, implement a
class RecipientList to wrap such pair of lists.
2023-05-08 22:17:02 +02:00
Piotr F. Mieszkowski c5e788b2a0 Add more contract tests for email module 2023-05-08 22:17:02 +02:00
Piotr F. Mieszkowski 12b7c3394d Make test relay slightly cleaner 2023-05-08 22:17:02 +02:00
Piotr F. Mieszkowski b2bd6a9926 Encapsulate recipient lists
Implement RecipientList class with:
- recipient (email) list,
- key (identity) list.

Cover with basic unit test.
2023-05-08 22:17:02 +02:00
Piotr F. Mieszkowski 86a3e0031b Adjust gpg-mailgate.py script to use SMTPUTF8 policy 2023-05-08 22:17:02 +02:00
Piotr F. Mieszkowski 54ee9d9875 Add minor E2E test improvements 2023-05-08 22:17:02 +02:00
Piotr F. Mieszkowski 603a88489e Polish the code 2023-05-08 22:17:02 +02:00
Piotr F. Mieszkowski ffd5f08ad9 Make PGP message recognition more thorough 2023-05-08 22:17:02 +02:00
Piotr F. Mieszkowski d342f206de Handle messages as EmailMessage
In the daemon, specify policy as SMTPUTF8.  That sets the deafult message type
to EmailMessage.

EmailMessage class is richer, including support for Content Managers, giving
it the capability to properly handle textual data and its encodings.

Also: add another contract test.
2023-05-08 22:17:02 +02:00
Piotr F. Mieszkowski ace2ce6b06 Add more email-parsing contract tests 2023-05-08 22:17:01 +02:00
Piotr F. Mieszkowski 509aac6de3 Improve command-generation, logging and readability 2023-05-08 22:17:01 +02:00
Piotr F. Mieszkowski ea8b246538 Clean up PGP/MIME flow
- Use MIMEPart instead of Message when encrypting in PGP/MIME mode.

- Wrap text/plain messages in MIMEPart, instead of manipulating payloads
  manually.

- Add a test for wrapping.
2023-05-08 22:17:01 +02:00
Piotr F. Mieszkowski 765637fd3a Fix logging initialisation by fixing import order 2023-05-08 22:17:01 +02:00
Piotr F. Mieszkowski 1a3ce89ce5 Always encrypt decoded payload 2023-05-08 22:17:01 +02:00
Piotr F. Mieszkowski 3c8b792203 Fix line-discarding bug 2023-05-08 22:17:01 +02:00
Piotr F. Mieszkowski 56101b86c0 Clean up the code after refactor
- Clean up PGP/MIME flow by using API instead of explicit/manual generation of
  headers.
- Fix E2E test configuration for PGP/MIME case.
- Add first lacre.core unit tests.
- Add another Contract Test.
2023-05-08 22:17:01 +02:00
Piotr F. Mieszkowski 27b07e672d Rework PGP/MIME flow 2023-05-08 22:17:01 +02:00
Piotr F. Mieszkowski 5e408259c0 Start using Content Manager
Also:
- Pass text to Popen in GnuPG (used to be bytes).
- Make is_payload_pgp_inline type-agnostic (str / bytes).
2023-05-08 22:17:01 +02:00
Piotr F. Mieszkowski d2ed4a9cee Make test reports more readable 2023-05-08 22:17:01 +02:00
Piotr F. Mieszkowski 94e22caf8e When encryption fails, revert to cleartext delivery
When GnuPG refuses to encrypt a message (e.g. when key has expired), record
information about the failure and send to logs, then deliver cleartext.  This
way we won't bounce email that could be delivered without encryption.

Also: add more E2E tests.
2023-05-08 22:16:41 +02:00
Piotr F. Mieszkowski 1cdca1d06d Log up to 2,5kB of message headers 2023-05-08 22:14:24 +02:00