Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
infertux committed Sep 9, 2024
1 parent 68e699d commit f0bdb58
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
10 changes: 6 additions & 4 deletions .github/workflows/zeyple.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,18 @@ jobs:
sudo apt-get install debconf-utils
sudo debconf-set-selections <<< "postfix postfix/main_mailer_type string 'Local only'"
sudo debconf-set-selections <<< "postfix postfix/mailname string localhost"
sudo apt-get install -y mailutils ruby ruby-dev rubygems build-essential sudo gnupg python3-gpg
sudo apt-get install -y mailutils ruby ruby-dev rubygems build-essential sudo gnupg python3-gpg libgpgme11 libgpgme-dev
sudo gem install --no-document fpm
python -m pip install --upgrade pip setuptools wheel
python -m pip install --upgrade tox
python -m pip install --upgrade mock pycodestyle pytest pytest-cov
- name: Build deb package
run: ./fpm/create
- name: End to end test using deb package
run: sudo bash -ex ./tests/e2e.sh
- name: Test with tox
run: tox
- name: Lint with pycodestyle
run: pycodestyle --show-pep8 --max-line-length=100
- name: Test with pytest
run: env PYTHONPATH=/usr/lib/python3/dist-packages:$PYTHONPATH python -m pytest --cov=zeyple/ --cov-report=html
- name: Upload deb package
uses: actions/upload-artifact@v1
with:
Expand Down
4 changes: 4 additions & 0 deletions tests/test_zeyple.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from __future__ import absolute_import

from configparser import ConfigParser
from textwrap import dedent
from unittest.mock import Mock
Expand All @@ -14,6 +16,8 @@

from zeyple import zeyple as z

del absolute_import

KEYS_FNAME = os.path.join(os.path.dirname(__file__), 'keys.gpg')
TEST1_ID = 'D6513C04E24C1F83'
TEST1_EMAIL = '[email protected]'
Expand Down
14 changes: 5 additions & 9 deletions zeyple/zeyple.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from __future__ import absolute_import

from configparser import ConfigParser
from io import BytesIO
import copy
Expand All @@ -15,13 +17,7 @@
import smtplib
import sys


def message_from_binary(message):
return email.message_from_bytes(message)


def as_binary_string(email):
return email.as_bytes()
del absolute_import


def encode_string(string):
Expand Down Expand Up @@ -84,7 +80,7 @@ def process_message(self, message_data, recipients):
"""Encrypts the message with recipient keys"""
message_data = encode_string(message_data)

in_message = message_from_binary(message_data)
in_message = email.message_from_bytes(message_data)
logging.info(
"Processing outgoing message %s", in_message['Message-id'])

Expand Down Expand Up @@ -190,7 +186,7 @@ def _encrypt_message(self, in_message, key_id):
# remove superfluous header
del mixed['MIME-Version']

payload = as_binary_string(mixed)
payload = mixed.as_bytes()

encrypted_payload = self._encrypt_payload(payload, [key_id])

Expand Down

0 comments on commit f0bdb58

Please sign in to comment.