Skip to content

Commit

Permalink
Added PGP example builder, outputs mbox
Browse files Browse the repository at this point in the history
  • Loading branch information
Smári McCarthy committed Oct 14, 2014
1 parent f25bd41 commit 2969b61
Show file tree
Hide file tree
Showing 12 changed files with 55 additions and 0 deletions.
44 changes: 44 additions & 0 deletions testing/pgp-data/buildexamples.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import os
import email
import mailbox
from subprocess import Popen, PIPE

def getSourceFiles():
return os.listdir("sources")

def getProcesses():
return ["--armor --sign", "--armor --clearsign", "--recipient 0x5AB5B329 --armor --encrypt",
"--sign", "--recipient 0x5AB5B329 --encrypt"]

def runPGP(input, params):
print "Running PGP"
params = params.split(" ")
params.insert(0, "../gpg-keyring/")
params.insert(0, "--home")
params.insert(0, "gpg")
pr = Popen(params, stdin=PIPE, stdout=PIPE)
pr.stdin.write(input)
pr.stdin.close()
pr.wait()
m = pr.stdout.read()
return m

def genExamples():
output = mailbox.mbox("output.mbox")
for source in getSourceFiles():
contents = open("sources/" + source, "r").read()
language, charset = source.split(".")
for process in getProcesses():
print "Creating %s mail with %s encoding and %s PGP" % (language,
charset, process)
string = runPGP(contents, process)
e = email.message_from_string(string)
e.set_charset(charset)
e["from"] = "sender@test.mailpile.is"
e["to"] = "recipient@test.mailpile.is"
output.add(e)

output.close()

if __name__ == "__main__":
genExamples()
1 change: 1 addition & 0 deletions testing/pgp-data/sources/ar.iso-8859-6
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
���� ���� ����� ������� ������� �� ������� �������. ��� ����� ����� ������� ������ �� ����� ����� ����� ���� ������.
1 change: 1 addition & 0 deletions testing/pgp-data/sources/ar.utf-8
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
يولد جميع الناس أحرارًا متساوين في الكرامة والحقوق. وقد وهبوا عقلاً وضميرًا وعليهم أن يعامل بعضهم بعضًا بروح الإخاء.
1 change: 1 addition & 0 deletions testing/pgp-data/sources/ar.windows-1256
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
���� ���� ����� ������� ������� �� ������� �������. ��� ����� ����� ������� ������ �� ����� ����� ����� ���� ������.
1 change: 1 addition & 0 deletions testing/pgp-data/sources/cn.utf-8
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
人人生而自由,在尊严和权利上一律平等。他们赋有理性和良心,并应以兄弟关系的精神相对待。
1 change: 1 addition & 0 deletions testing/pgp-data/sources/gr.iso-8859-7
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
���� �� �������� ����������� ��� ���� ���� ����������� ��� ��� ����������. ����� ������������ �� ������ ��� ���������, ��� �������� �� ��������������� ������ ���� �� ������ �����������.
1 change: 1 addition & 0 deletions testing/pgp-data/sources/gr.utf-8
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Ολοι οι άνθρωποι γεννιούνται και ίσοι στην αξιοπρέπεια και στα δικαιώματα. Είναι προικισμένοι με λογική και συνείδηση, και οφείλουν να συμπεριφέρονται μεταξύ τους με πνεύμα αδελφοσύνης.
1 change: 1 addition & 0 deletions testing/pgp-data/sources/gr.windows-1253
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
���� �� �������� ����������� ��� ���� ���� ����������� ��� ��� ����������. ����� ������������ �� ������ ��� ���������, ��� �������� �� ��������������� ������ ���� �� ������ �����������.
1 change: 1 addition & 0 deletions testing/pgp-data/sources/ru.koi8-ru
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
��� ���� ��������� ���������� � ������� � ����� ����������� � ������. ��� �������� ������� � �������� � ������ ��������� � ��������� ���� ����� � ���� ��������.
1 change: 1 addition & 0 deletions testing/pgp-data/sources/ru.utf-8
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Все люди рождаются свободными и равными в своем достоинстве и правах. Они наделены разумом и совестью и должны поступать в отношении друг друга в духе братства.
1 change: 1 addition & 0 deletions testing/pgp-data/sources/ru.windows-1251
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
��� ���� ��������� ���������� � ������� � ����� ����������� � ������. ��� �������� ������� � �������� � ������ ��������� � ��������� ���� ����� � ���� ��������.
1 change: 1 addition & 0 deletions testing/pgp-data/sources/vi.utf-8
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Tất cả mọi người sinh ra đều được tự do và bình đẳng về nhân phẩm và quyền. Mọi con người đều được tạo hóa ban cho lý trí và lương tâm và cần phải đối xử với nhau trong tình bằng hữu.

0 comments on commit 2969b61

Please sign in to comment.