diff options
author | Kali Kaneko (leap communications) <kali@leap.se> | 2016-12-22 15:40:52 +0100 |
---|---|---|
committer | Kali Kaneko (leap communications) <kali@leap.se> | 2016-12-26 14:55:42 +0100 |
commit | 0f5eb825c5654a718c1f4f2fd3a9ac2f0efad395 (patch) | |
tree | 3272464139945bfea30211ad4410c886dc99b36b | |
parent | b225824648af4bb69356ed70969eb59fa203d5e6 (diff) |
[test] add script for checking the mail
-rwxr-xr-x | tests/e2e/e2e-test.sh | 7 | ||||
-rwxr-xr-x | tests/e2e/getmail (renamed from tests/integration/mail/imap/getmail) | 20 |
2 files changed, 22 insertions, 5 deletions
diff --git a/tests/e2e/e2e-test.sh b/tests/e2e/e2e-test.sh index 3e6d2bb..96c211d 100755 --- a/tests/e2e/e2e-test.sh +++ b/tests/e2e/e2e-test.sh @@ -52,9 +52,12 @@ while [[ $imap_pw == *"None"* ]]; do imap_pw=$(echo "$response" | head -n 1 | sed 's/ */ /g' | cut -d' ' -f 2) done -#echo "IMAP/SMTP PASSWD: $imap_pw" - $SWAKS $FROM_EXTERNAL_OPTS +echo "IMAP/SMTP PASSWD: $imap_pw" + + +# XXX get mail we just sent. +./getmail --mailbox INBOX --subject "my_unique_subject" $user $imap_pw diff --git a/tests/integration/mail/imap/getmail b/tests/e2e/getmail index dd3fa0b..367d79d 100755 --- a/tests/integration/mail/imap/getmail +++ b/tests/e2e/getmail @@ -13,9 +13,10 @@ particular mailbox. import os import sys +from twisted.internet import defer from twisted.internet import protocol +from twisted.internet import reactor from twisted.internet import ssl -from twisted.internet import defer from twisted.internet import stdio from twisted.mail import imap4 from twisted.protocols import basic @@ -24,6 +25,8 @@ from twisted.python import log # Global options stored here from main _opts = {} +EXITCODE = 0 + class TrivialPrompter(basic.LineReceiver): from os import linesep as delimiter @@ -230,6 +233,12 @@ def cbFetch(result, proto): print "Hey, an empty mailbox!" if not index: + if selected_subject: + global EXITCODE + EXITCODE=42 + print "NO SUCH MAIL" + return reactor.stop() + return proto.prompt("\nWhich message? [1] (Q quits) " ).addCallback(cbPickMessage, proto) else: @@ -280,6 +289,8 @@ def main(): import sys from twisted.internet import reactor + global EXITCODE + description = ( 'Get messages from a LEAP IMAP Proxy.\nThis is a ' 'debugging tool, do not use this to retrieve any sensitive ' @@ -306,9 +317,11 @@ def main(): parser.add_argument('username', type=str) parser.add_argument('password', type=str) - parser.add_argument('--mailbox', dest='mailbox', default=None, + parser.add_argument( + '--mailbox', dest='mailbox', default=None, help='Which mailbox to retrieve. Empty for interactive prompt.') - parser.add_argument('--subject', dest='subject', default=None, + parser.add_argument( + '--subject', dest='subject', default=None, help='A subject for retrieve a mail that matches. Empty for interactive prompt.') ns = parser.parse_args() @@ -338,6 +351,7 @@ def main(): port = 143 reactor.connectTCP(hostname, int(port), factory) reactor.run() + sys.exit(EXITCODE) if __name__ == '__main__': |