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 bcfe029
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 17 deletions.
12 changes: 8 additions & 4 deletions .github/workflows/zeyple.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,19 @@ jobs:
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
dpkg -L python3-gpg
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 pip setuptools==0.71.0
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 tests/
#run: python -m pytest --cov=zeyple/ --cov-report=html tests/
- name: Upload deb package
uses: actions/upload-artifact@v1
with:
Expand Down
Empty file added tests/__init__.py
Empty file.
4 changes: 2 additions & 2 deletions tests/test_zeyple.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import tempfile
import unittest

from zeyple import zeyple as z
from zeyple import zeyple

KEYS_FNAME = os.path.join(os.path.dirname(__file__), 'keys.gpg')
TEST1_ID = 'D6513C04E24C1F83'
Expand Down Expand Up @@ -54,7 +54,7 @@ def setUp(self):
stderr=open('/dev/null'),
)

self.zeyple = z.Zeyple(self.conffile)
self.zeyple = zeyple.Zeyple(self.conffile)
self.zeyple._send_message = Mock() # don't try to send emails

def tearDown(self):
Expand Down
13 changes: 2 additions & 11 deletions zeyple/zeyple.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
# -*- coding: utf-8 -*-

from configparser import ConfigParser
from io import BytesIO
import copy
import email
import email.encoders
Expand All @@ -16,14 +15,6 @@
import sys


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


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


def encode_string(string):
if isinstance(string, bytes):
return string
Expand Down Expand Up @@ -84,7 +75,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 +181,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 bcfe029

Please sign in to comment.