Commit 937a4b12 authored by Alexander Meißner's avatar Alexander Meißner

Added timing test (simulate silly window syndrome)

Updated README
parent b8cca557
Pipeline #6588 failed with stage
in 5 minutes and 39 seconds
# We want to break it!
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`
......@@ -24,7 +24,7 @@ def main():
test_server = None
try:
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):
if method[:5] == 'test_':
suite.addTest(clazz(test_server, method))
......
import socket
import random
import time
from util import BaseTest
class TestDrops(BaseTest):
def assertResponse(self, expectedCode, message): # pylint: disable=invalid-name
if isinstance(message, str):
message = message.encode('ASCII')
while len(message) > 0:
slice = random.randint(1, len(message))
self.client.send(message[0:slice])
message = message[slice:]
time.sleep(random.uniform(0.01, 0.1))
self.assertResponse(expectedCode)
def test_mail(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')
......@@ -18,7 +18,6 @@ class TestFuzzing(BaseTest):
'VRFY',
''
]
random.seed(42)
for _ in range(0, 1337):
command = random.choice(possible_commands)+' '
command += ''.join(chr(random.randint(1, 127)) for x in range(random.randint(0, 127)))
......@@ -33,8 +32,7 @@ class TestFuzzing(BaseTest):
self.assertResponse(500, 'FAIL\r\n')
def test_fuzzing(self):
random.seed(42)
def test_unrecognized_command(self):
self.assertResponse(500, 'FAIL\r\n')
def test_sentry_issue_49(self):
......
import socket
import unittest
import random
class BaseTest(unittest.TestCase):
......@@ -11,6 +12,7 @@ class BaseTest(unittest.TestCase):
def setUp(self):
self.client = self.test_server.create_client()
self.assertResponse(220)
random.seed(42)
def tearDown(self):
self.client.close()
......@@ -19,17 +21,14 @@ class BaseTest(unittest.TestCase):
def format_message(message):
if not message or isinstance(message, bytes):
return message
if message[-2:] == '\r\n':
return message[:-2]
return message
if message:
if isinstance(message, str):
self.client.send(message.encode('ASCII'))
else:
self.client.send(message)
message = message.encode('ASCII')
self.client.send(message)
response = ''
while not response.endswith('\r\n'):
try:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment