Commit graph

256 commits

Author SHA1 Message Date
baf7954270 Use list booleanness instead of comparing with empty list 2022-05-06 19:39:56 +02:00
031c7234f6 Reorder top-level expressions 2022-05-06 19:39:56 +02:00
d90b50f7e7 Extract config, separate logging, split into smaller functions
- Move configuration-processing code to a separate module (lacre.config) and
  provide a simple API to access configuration parameters.
- Prepare to use builtin logging module to log diagnostic data.
- Rework the configuration-processing file to make it cleaner.
- Log additional information while processing configuration.
- Reorder functions.
2022-05-06 19:39:56 +02:00
pfm
7767dfaff9 Merge pull request 'Fix minor cron.py issues' (#64) from fix-cron-script into master
Reviewed-on: Disroot/gpg-lacre#64
2022-05-06 17:25:11 +00:00
55fa0d0601 [GnuPG.confirm_key] Convert email to bytes() before comparison 2022-05-06 19:14:52 +02:00
71afd6ed05 [GnuPG.confirm_key] Set 700 mode for temp. key home 2022-04-26 18:42:48 +02:00
a82ff9f3f1 Use actual keys (RSA and Ed25519) in cron-test 2022-04-24 10:42:51 +02:00
52b31028c5 Fix config key typo 2022-04-24 10:07:52 +02:00
b19a76e297 Update testing documentation 2022-04-23 13:13:57 +02:00
ffc53b935a Finish migration to SQLAlchemy and automate testing cron.py 2022-04-23 13:08:40 +02:00
7aff414fb7 Use SQLAlchemy to access database
- Replace hardcoded MySQLdb package with sqlalchemy to support other RDBMS
backends.

- Provide a script that could eventually replace schema.sql (schema.py).

- Update sample configuration.
2022-04-23 09:39:20 +02:00
86b725349f
added smtp auth to cron.py 2022-04-20 13:01:58 +02:00
ea0e012c04 Use 'open' to open a file 2022-04-19 21:35:22 +02:00
454b519c70 Use bytes in confirm_key's line operations 2022-04-19 21:22:34 +02:00
f472f4ac22 Use isinstance() instead of type() 2022-04-19 21:16:40 +02:00
fdadc89c31 Use bytes in GnuPG.confirm_key too 2022-04-19 20:49:49 +02:00
5a34249090 Fix minor cron.py issues
Related to #63: TypeError: memoryview: a bytes-like object is required, not
'str'.

- Allow GnuPG.add_key accept either 'str' or 'bytes'.
- Import MIMEText from email.mime.text.
2022-04-10 19:03:18 +02:00
c4e9e3e840 compatibility update for php7/8 (#61)
Co-authored-by: muppeth <muppeth@disroot.org>
Reviewed-on: Disroot/gpg-lacre#61
2022-03-23 10:05:11 +00:00
pfm
d1de1f0695 Merge pull request 'Remove support for decrypting emails' (#60) from remove-decryption into master
Reviewed-on: Disroot/gpg-lacre#60
2022-03-10 19:03:41 +00:00
59b932abaa Remove support for decrypting emails 2022-03-08 22:42:13 +01:00
pfm
968677f1ec Merge pull request 'Migrate to Python 3.x' (#58) from py3-migration into master
Reviewed-on: Disroot/gpg-lacre#58
Reviewed-by: muppeth <muppeth@no-reply@disroot.org>
2022-03-08 20:47:25 +00:00
c4927d2722 Avoid unnecessary list creation 2022-02-06 00:29:35 +01:00
9e17726e39 Use f-strings for formatting 2022-02-06 00:27:20 +01:00
67a938c049 GnuPG.add_key: Use build_command 2022-01-25 20:32:17 +01:00
03fc3d138e Update testing documentation
- Explain how to specify Python binary path used during tests.

- Mention test logs.
2022-01-19 22:16:27 +01:00
a201265f87 Rework how E2E tests are executed
Tests kept breaking (not failing) randomly with "Broken pipe" errors.  Rework
how processes are spawned to make sure that it doesn't break them again.
2022-01-19 21:57:46 +01:00
c81c6e6e0d Remove hardcoded python3.8 path
- Let the user overwrite Python binary name while calling make.

- Use environment variable set by make to instruct e2e_test.py which binary it
should call to execute Python code.
2022-01-10 20:22:17 +01:00
5a8d2c0108 Add E2E cases: signed cleartext and multipart/encrypted 2022-01-10 19:48:44 +01:00
435528de43 Add an E2E test case with an already encrypted message 2022-01-10 19:32:46 +01:00
24f0c86d4f Tidy up tests
- Makefile: add 'unittest' to .PHONY targets.
- Remove unnecessary #! line from e2e_test.py.
- Extract Python path to test/e2e.ini file.
2022-01-10 18:39:29 +01:00
1e7d33c1df Handle bytes properly
Fix bytes sequences handling after auto-migration.
2022-01-10 18:21:53 +01:00
b2a01c15b0 Fix auto-migrated code
- Use b'' (byte strings) where appropriate.

- Fix indentation.

- Replace python2.x references with python3.x.
2022-01-10 18:21:40 +01:00
5f02223ec7 Perform automatic migration to Python 3.x
Use lib2to3 automatic migration tool provided by Python 2.x to convert
codebase to new idioms.

Command line:

find . -type f -name '*.py' \
    -exec python2.7 -m lib2to3 \
    -f all -f idioms -f buffer -f set_literal -f ws_comma -w \
    '{}' '+'
2022-01-10 18:21:20 +01:00
pfm
ee0d65f6bb Merge pull request 'Add tests for Python code' (#51) from 39-add-tests into master
Reviewed-on: Disroot/gpg-lacre#51
Reviewed-by: muppeth <muppeth@no-reply@disroot.org>
2022-01-10 17:10:00 +00:00
3b9f714cdb Ignore random_seed
Do not keep test/keyhome/random_seed in repository.
2022-01-10 17:47:23 +01:00
1002da78fa Clean up test messages
Remove unused msgout files, fix addresses in msgin files.
2022-01-09 22:00:06 +01:00
2cf60dec40 Add unit tests for GnuPG command-line generator
Extract a function to calculate GPG commands to be executed and cover it with
unit tests.
2022-01-09 21:37:14 +01:00
fc2779ef7d Improve test code structure
- Move things to configuration file where appropriate (logging format, etc.).

- Rework execute_e2e_test signature to simplify it and get rid of keyword
arguments.

- Simplify output.

- Include a header comment in configuration file.
2022-01-08 13:42:23 +01:00
98c4580775 Document E2E tests 2022-01-07 12:10:30 +01:00
e90a29c9ff Ignore temporary test directory 2022-01-07 12:04:14 +01:00
01377f4dd2 Keep test/certs directory 2022-01-07 12:03:38 +01:00
ff3f6aa793 Add a test overview, extract constants
To let the user know that tests produce logs, include a message at the end of
the test output informing about locations of E2E and Mailgate logs.

Also, extract some constants.
2022-01-07 12:00:50 +01:00
f1a799d864 Adjust E2E tests to work with all scenarios
Since it's not so easy to encrypt a message exactly the same way twice, we
only verify if the message has been encrypted or not.

Introduce minor changes to the library itself, because it doesn't work very
well with modern GnuPG.

Also, include GnuPG directory (pointed at by --homedir option).
2022-01-06 16:34:47 +01:00
f41adc0d53 Configure git to ignore temporary files and Emacs files 2022-01-06 16:34:47 +01:00
27d7481078 Set up ground for E2E tests
- Use an environment variable to point at the configuration file while
  strating gpg-mailgate.py.

- Unify paths: store temporary config, logs and anything else under 'test'
  directory.

- Configure more tests (RSA, Ed25519).

- Add test descriptions to be shown before they're started.
2022-01-06 16:33:21 +01:00
7a063a91b8 Polish E2E testing script and make it configurable 2021-11-09 21:25:41 +01:00
f3f56a47bc Implement an E2E testing script 2021-11-08 22:52:22 +01:00
a9506805fb Write a test mail relay
Provide a simple Python script that would linsten on a given port and print to
standard output any message received via SMTP on that port.

This script will then be used to automatically test gpg-mailgate with different
scenarios (unknown recipient key, RSA key, elliptic curve key).
2021-11-04 22:39:02 +01:00
0fb623c75a Merge pull request 'README file: Few typos fixed.' (#33) from fix_01 into master
Reviewed-on: Disroot/gpg-lacre#33
2021-04-21 06:54:11 +00:00
8095f1507e Few typos fixed. 2021-04-20 17:43:01 -03:00