Commit 98a7ce12 authored by Pawel Boening's avatar Pawel Boening
Browse files

Merge branch 'drop-tests' into 'master'

Drops test

See merge request sre18/break-it!10
parents ee3269f6 5af99cc3
Loading
Loading
Loading
Loading
Loading
+8 −0
Changes for README.md: 8 added lines, 0 removed lines.
Original line number Original line Diff line number Diff line
# We want to break it!
# We want to break it!


at least the smtp servers of the other groups..
at least the smtp servers of the other groups..


## Run Tests
`python3 run.py testing.marschke.me 9001 smtp-server-group-a 6666
python3 run.py testing.marschke.me 9001 smtp-server-group-b 8008
python3 run.py testing.marschke.me 9001 smtp-server-group-c 5555
python3 run.py testing.marschke.me 9001 smtp-server-group-d 25
python3 run.py testing.marschke.me 9001 julianweise/simplesmtp 4431 --ssl --wait-up 2`
+2 −2
Changes for run.py: 2 added lines, 2 removed lines.
Original line number Original line Diff line number Diff line
@@ -2,7 +2,7 @@ import argparse
import sys
import sys
import unittest
import unittest


from tests import TestFuzzing, TestMail, TestSession
from tests import TestDrops, TestFuzzing, TestMail, TestSession
from util import TestServer
from util import TestServer




@@ -24,7 +24,7 @@ def main():
    test_server = None
    test_server = None
    try:
    try:
        test_server = TestServer(args.domain, args.port, args.docker_template, args.docker_port, args.ssl, args.wait_up)
        test_server = TestServer(args.domain, args.port, args.docker_template, args.docker_port, args.ssl, args.wait_up)
        for clazz in [TestFuzzing, TestMail, TestSession]:
        for clazz in [TestDrops, TestFuzzing, TestMail, TestSession]:
            for method in dir(clazz):
            for method in dir(clazz):
                if method[:5] == 'test_':
                if method[:5] == 'test_':
                    suite.addTest(clazz(test_server, method))
                    suite.addTest(clazz(test_server, method))

tests/TestDrops.py

0 → 100644
+36 −0
Changes for tests/TestDrops.py: 36 added lines, 0 removed lines.
Original line number Original line Diff line number Diff line
import random
import time

from util import BaseTest


class TestDrops(BaseTest):
    def assertResponse(self, expected_code, message=None):  # pylint: disable=invalid-name
        if isinstance(message, str):
            message = message.encode('ASCII')
        while message:
            sliceLen = random.randint(1, len(message))
            self.client.send(message[0:sliceLen])
            message = message[sliceLen:]
            time.sleep(random.uniform(0.01, 0.1))
        super(TestDrops, self).assertResponse(expected_code)

    def test_silly_window_syndrome(self):
        self.assertResponse(250, 'HELO marschke.me\r\n')
        self.assertResponse(250, 'MAIL FROM:<leonard@marschke.me>\r\n')
        self.assertResponse(250, 'RCPT TO:<firstAddress@{}>\r\n'.format(self.test_server.domain))
        self.assertResponse(250, 'RCPT TO:<secondAddress@{}>\r\n'.format(self.test_server.domain))
        self.assertResponse(354, 'DATA\r\n' + \
                                 'Date: Thu, 10 May 2018 10:33:29 -0100\r\n' + \
                                 'FROM: Leonard Marschke<leonard@marschke.me>\r\n' + \
                                 'Subject: Testmail\r\n' + \
                                 'To: firstaddress@{}\r\n'.format(self.test_server.domain) + \
                                 '\r\n' + \
                                 'Hi all, this is\r\n' + \
                                 'a second line.\r\n' + \
                                 'And a third.\r\n' + \
                                 'Single point incoming.\r\n' + \
                                 '..\r\n' + \
                                 'BR\r\n')
        self.assertResponse(250, '.\r\n')
        self.assertResponse(221, 'QUIT\r\n')
+1 −3
Changes for tests/TestFuzzing.py: 1 added line, 3 removed lines.
Original line number Original line Diff line number Diff line
@@ -18,7 +18,6 @@ class TestFuzzing(BaseTest):
            'VRFY',
            'VRFY',
            ''
            ''
        ]
        ]
        random.seed(42)
        for _ in range(0, 1337):
        for _ in range(0, 1337):
            command = random.choice(possible_commands)+' '
            command = random.choice(possible_commands)+' '
            command += ''.join(chr(random.randint(1, 127)) for x in range(random.randint(0, 127)))
            command += ''.join(chr(random.randint(1, 127)) for x in range(random.randint(0, 127)))
@@ -33,8 +32,7 @@ class TestFuzzing(BaseTest):


        self.assertResponse([x for x in range(500, 510)], 'FAIL\r\n')
        self.assertResponse([x for x in range(500, 510)], 'FAIL\r\n')


    def test_fuzzing(self):
    def test_unrecognized_command(self):
        random.seed(42)
        self.assertResponse(500, 'FAIL\r\n')
        self.assertResponse(500, 'FAIL\r\n')


    def test_sentry_issue_49(self):
    def test_sentry_issue_49(self):
+1 −0
Changes for tests/__init__.py: 1 added line, 0 removed lines.
Original line number Original line Diff line number Diff line
from .TestDrops import TestDrops
from .TestFuzzing import TestFuzzing
from .TestFuzzing import TestFuzzing
from .TestMail import TestMail
from .TestMail import TestMail
from .TestSession import TestSession
from .TestSession import TestSession
Loading