Skip to content

Commit a9182c8

Browse files
committed
WIP
1 parent 68e699d commit a9182c8

File tree

3 files changed

+16
-13
lines changed

3 files changed

+16
-13
lines changed

.github/workflows/zeyple.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,18 @@ jobs:
2828
sudo apt-get install debconf-utils
2929
sudo debconf-set-selections <<< "postfix postfix/main_mailer_type string 'Local only'"
3030
sudo debconf-set-selections <<< "postfix postfix/mailname string localhost"
31-
sudo apt-get install -y mailutils ruby ruby-dev rubygems build-essential sudo gnupg python3-gpg
31+
sudo apt-get install -y mailutils ruby ruby-dev rubygems build-essential sudo gnupg python3-gpg libgpgme11 libgpgme-dev
3232
sudo gem install --no-document fpm
3333
python -m pip install --upgrade pip setuptools wheel
34-
python -m pip install --upgrade tox
34+
python -m pip install --upgrade mock pycodestyle pytest pytest-cov
3535
- name: Build deb package
3636
run: ./fpm/create
3737
- name: End to end test using deb package
3838
run: sudo bash -ex ./tests/e2e.sh
39-
- name: Test with tox
40-
run: tox
39+
- name: Lint with pycodestyle
40+
run: pycodestyle --show-pep8 --max-line-length=100
41+
- name: Test with pytest
42+
run: env PYTHONPATH=$PYTHONPATH:/usr/lib/python3/dist-packages python -m pytest --cov=zeyple/ --cov-report=html
4143
- name: Upload deb package
4244
uses: actions/upload-artifact@v1
4345
with:

tests/test_zeyple.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
#!/usr/bin/env python
22
# -*- coding: utf-8 -*-
33

4+
from __future__ import absolute_import
5+
46
from configparser import ConfigParser
57
from textwrap import dedent
68
from unittest.mock import Mock
9+
from gpg import _gpgme
710
import gpg
811
import os
912
import re
@@ -14,6 +17,8 @@
1417

1518
from zeyple import zeyple as z
1619

20+
del absolute_import
21+
1722
KEYS_FNAME = os.path.join(os.path.dirname(__file__), 'keys.gpg')
1823
TEST1_ID = 'D6513C04E24C1F83'
1924
TEST1_EMAIL = '[email protected]'

zeyple/zeyple.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#!/usr/bin/env python
22
# -*- coding: utf-8 -*-
33

4+
from __future__ import absolute_import
5+
46
from configparser import ConfigParser
57
from io import BytesIO
68
import copy
@@ -15,13 +17,7 @@
1517
import smtplib
1618
import sys
1719

18-
19-
def message_from_binary(message):
20-
return email.message_from_bytes(message)
21-
22-
23-
def as_binary_string(email):
24-
return email.as_bytes()
20+
del absolute_import
2521

2622

2723
def encode_string(string):
@@ -84,7 +80,7 @@ def process_message(self, message_data, recipients):
8480
"""Encrypts the message with recipient keys"""
8581
message_data = encode_string(message_data)
8682

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

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

193-
payload = as_binary_string(mixed)
189+
payload = mixed.as_bytes()
194190

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

0 commit comments

Comments
 (0)