Skip to content

Commit 648fd78

Browse files
committed
fix tests WIP
1 parent b7cab63 commit 648fd78

File tree

5 files changed

+207
-202
lines changed

5 files changed

+207
-202
lines changed

.github/workflows/run-unittest.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ jobs:
1515
- name: Install dependencies
1616
run: |
1717
python -m pip install --upgrade pip
18-
pip install M2Crypto
18+
pip install M2Crypto # TODO remove when tests are updated
19+
pip install cryptography
1920
pip install -e .
2021
- name: Run tests
2122
run: python3 test_.py

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Envelope
22

3-
[![Build Status](https://github.com/CZ-NIC/envelope/actions/workflows/run-unittest.yml/badge.svg)](https://github.com/CZ-NIC/envelope/actions) [![Downloads](https://pepy.tech/badge/envelope)](https://pepy.tech/project/envelope)
3+
[![Build Status](https://github.com/CZ-NIC/envelope/actions/workflows/run-unittest.yml/badge.svg)](https://github.com/CZ-NIC/envelope/actions) [![Downloads](https://static.pepy.tech/badge/envelope)](https://pepy.tech/project/envelope)
44

55
Quick layer over [python-gnupg](https://bitbucket.org/vinay.sajip/python-gnupg/src), [M2Crypto](https://m2crypto.readthedocs.io/), [smtplib](https://docs.python.org/3/library/smtplib.html), [magic](https://pypi.org/project/python-magic/) and [email](https://docs.python.org/3/library/email.html?highlight=email#module-email) handling packages. Their common use cases merged into a single function. Want to sign a text and tired of forgetting how to do it right? You do not need to know everything about GPG or S/MIME, you do not have to bother with importing keys. Do not hassle with reconnecting to an SMTP server. Do not study various headers meanings to let your users unsubscribe via a URL.
66
You insert a message, attachments and inline images and receive signed and/or encrypted output to the file or to your recipients' e-mail.
@@ -77,7 +77,7 @@ Envelope.load(path="message.eml").attachments()
7777
```
7878
* Or just download the project and launch `python3 -m envelope`
7979
* If planning to sign/encrypt with GPG, assure you have it on the system with `sudo apt install gpg` and possibly see [Configure your GPG](#configure-your-gpg) tutorial.
80-
* If planning to use S/MIME, you should ensure some prerequisites: `sudo apt install swig build-essential python3-dev libssl-dev && pip3 install M2Crypto`
80+
* If planning to use S/MIME, you might be required to ensure some [prerequisites](https://cryptography.io/en/latest/installation/), ex: `sudo apt install build-essential libssl-dev libffi-dev python3-dev cargo pkg-config`
8181
* If planning to send e-mails, prepare SMTP credentials or visit [Configure your SMTP](#configure-your-smtp) tutorial.
8282
* If your e-mails are to be received outside your local domain, visit [DMARC](#dmarc) section.
8383
* Package [python-magic](https://pypi.org/project/python-magic/) is used as a dependency. Due to a [well-known](https://github.com/ahupp/python-magic/blob/master/COMPAT.md) name clash with the [file-magic](https://pypi.org/project/file-magic/) package, in case you need to use the latter, don't worry to run `pip uninstall python-magic && pip install file-magic` after installing envelope which is fully compatible with both projects. Both use `libmagic` under the hood which is probably already installed. However, if it is not, [install](https://github.com/ahupp/python-magic?tab=readme-ov-file#installation) `sudo apt install libmagic1`.

envelope/envelope.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -1127,14 +1127,16 @@ def _send_now(self, email, encrypt, encrypted_subject, send):
11271127
email["Message-ID"] = make_msgid()
11281128

11291129
if send and send != SIMULATION:
1130+
recipients = list(map(str, set(self._to + self._cc + self._bcc)))
11301131
with mock.patch.object(Generator, '_handle_multipart_signed', Generator._handle_multipart):
11311132
# https://github.com/python/cpython/issues/99533 and #19
11321133
failures = self._smtp.send_message(email,
11331134
from_addr=self._from_addr,
1134-
to_addrs=list(map(str, set(self._to + self._cc + self._bcc))))
1135+
to_addrs=recipients)
11351136
if failures:
11361137
logger.warning(f"Unable to send to all recipients: {repr(failures)}.")
11371138
elif failures is False:
1139+
# TODO add here and test, logger.warning(f"Sending {recipients}, Message-ID: {email["Message-ID"]}")
11381140
return False
11391141
else:
11401142
if send != SIMULATION:

setup.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@
3232
long_description_content_type="text/markdown",
3333
install_requires=install_requires,
3434
extras_require={
35-
"smime": ["M2Crypto", # need to have: `sudo apt install swig`
36-
"cryptography>=43"]
35+
"smime": ["cryptography>=43"]
3736
},
3837
entry_points={
3938
'console_scripts': [

0 commit comments

Comments
 (0)