Commit Graph

114 Commits

Author SHA1 Message Date
Piotr F. Mieszkowski bc005161c1
Add header-only parser and minor test improvements 2024-05-24 14:23:33 +02:00
Piotr F. Mieszkowski 21a9021d41
Add contract tests for headers-only parsing of email messages 2024-04-19 13:17:04 +02:00
Piotr F. Mieszkowski 9ecdb17e42
Upgrade SQLAlchemy, enable warning capturing 2024-04-12 18:13:42 +02:00
Piotr F. Mieszkowski e28d3ecfae
Extract expiry calculation from KeyConfirmationQueue 2024-04-12 11:47:05 +02:00
Piotr F. Mieszkowski 110ea885f2
Deliver cleartext if Unicode encoding or message serialisation fail 2024-03-02 18:36:41 +01:00
Piotr F. Mieszkowski 3138864d32
Include exception in ExecutionTimeLogger log record
Also: cover ExecutionTimeLogger with a unit test.
2024-03-02 18:06:51 +01:00
Piotr F. Mieszkowski 04ca103494
Fix unencrypted delivery in case of message generation failure
When we fail to produce byte representation of the email message being
processed, we may end up bouncing a message.  An example of such case would be
a message with a Message-Id header that Python's email parser library cannot
process.

In such cases, just take whatever original content we have received and pass
it to the destination without touching it to minimise any chances of breaking
the overall flow.
2024-03-01 20:14:09 +01:00
Piotr F. Mieszkowski bfd3541b18 Retrieve data from db result before returning from Context Manager
SQLAlchemy's connection is a Context Manager and if we return a result from
code wrapped in a Context Manager, its cursor might already be closed.
2024-01-20 18:52:47 +01:00
Piotr F. Mieszkowski 276e0d0cd4 Use one config for cron and daemon tests 2024-01-07 21:52:52 +01:00
Piotr F. Mieszkowski 260a3f3e9c Configure pooling for cron tests 2024-01-06 15:26:18 +01:00
Piotr F. Mieszkowski a943b50adb Update test configuration after renaming 2024-01-06 15:06:36 +01:00
Piotr F. Mieszkowski a98ff611ee Continue renaming: config files, tests, docs 2024-01-06 14:45:09 +01:00
Piotr F. Mieszkowski ad3a54fcd7 Rename GPG-Mailgate to Lacre
Update naming in documentation and the source code.
2024-01-06 14:34:54 +01:00
Piotr F. Mieszkowski a09fd67a59 Make keys unexpirable 2024-01-05 22:11:14 +01:00
Piotr F. Mieszkowski 90da933bf9 Make disconnect handling configuration explicit
- Provide a new reuqired parameter: [database]pooling_mode and use it during
  SQLAlchemy engine initialisation.

- Update tests and configuration (including sample configuration).

- Adjust repository unit test to load config during setup.

- Pass an engine instance to repository constructors instead of connections.
  Engine keeps a connection pool and we rely on it.
2023-12-17 14:03:20 +01:00
Piotr F. Mieszkowski 23a05c11ac Remove EncryptionException formatting test 2023-12-10 21:35:35 +01:00
Piotr F. Mieszkowski 75c48282b0 Rework encryption exception handling
Also: remove misleading comment about message.defects.
2023-12-09 20:38:46 +01:00
Piotr F. Mieszkowski ac5dddfa98 Remove configuration options no longer used 2023-12-02 21:48:17 +01:00
Piotr F. Mieszkowski 052551072e Change table prefix from 'gpgmw' to 'lacre' 2023-12-02 20:02:59 +01:00
Piotr F. Mieszkowski 9b5c43b769 Fix crontest config, polish Makefile 2023-11-25 15:05:27 +01:00
Piotr F. Mieszkowski becb39f139 Clean up database access
- Don't pass table definitions to repository constructors.

- Keep an internal reference to Engine in lacre.repository.

- Implement KeyConfirmationQueue.count_keys.
2023-11-25 14:04:32 +01:00
Piotr F. Mieszkowski 4950e0b9c3 Keep secondary keyring for test purposes 2023-11-25 01:13:43 +01:00
Piotr F. Mieszkowski 72217e38ea GnuPG module: make key-listing more thorough
- Flush key-collecting structures each time a new public key entry is found.
  This will avoid adding sub-keys and overwriting main keys with them.

- Use parseaddr from email.utils to parse emails (and drop realname part).

- Record logs produced during unit tests.

- Fix a small bug in test code.

Also: add basic information about available test identities to testing
documentation.
2023-11-25 01:08:15 +01:00
Piotr F. Mieszkowski 7c2d32bf3c Make IdentityRepository a KeyRing
- Keep only one class to provide access to identities stored in the database.

- Remove old code and its tests.

- Align KeyRing and IdentityRepository APIs.

- Implement a (very) simple unit test for IdentityRepository.
2023-11-24 22:59:21 +01:00
Piotr F. Mieszkowski 89affde0d5 Add tests for GnuPG parsing routines 2023-11-20 22:11:37 +01:00
Piotr F. Mieszkowski bfa2643dc7 Implement identity repository
Also: rename key_id to fingerprint.
2023-11-20 22:11:25 +01:00
Piotr F. Mieszkowski 7ac928af76 Handle gpg-mailgate.py missing params better 2023-11-17 22:51:09 +01:00
Piotr F. Mieszkowski 5e108c189a Replace file-based identity store with a dedicated db table 2023-10-29 19:39:08 +01:00
Piotr F. Mieszkowski 3dd6913599 Initialise db connection lazily, use isolated asyncio test case 2023-10-23 22:44:53 +02:00
Piotr F. Mieszkowski 43f43a4137 Fix DatabaseKeyring tests 2023-10-23 20:26:23 +02:00
Piotr F. Mieszkowski 41442e5b59 Add basic support for RDBMS-based keyring 2023-09-30 22:38:33 +02:00
Piotr F. Mieszkowski c570bcd383 Update Alice's key expiry date 2023-09-25 19:44:37 +02:00
Piotr F. Mieszkowski 624a335a41 GnuPG: clean up and collect more diagnostic info
- Use regular expressions instead of finding particular characters in gnupg
  output to decide whether confirmation line was found.

- Use tempfile.mkdtemp to create secure temporary directories.

- Record information about the key considered by GnuPG. When missing in
  exception, it means no key was found.
2023-09-21 20:21:01 +02: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
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 1acb330c02 Rewrite e2e_test to use unittest framework 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 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 c5e788b2a0 Add more contract tests for email module 2023-05-08 22:17:02 +02:00