Commit b8cca557 authored by Pawel Boening's avatar Pawel Boening

Merge branch 'add_old_tests' into 'master'

Add old tests

See merge request sre18/break-it!8
parents 3933f2e2 bcaabb7d
Pipeline #6599 passed with stage
in 5 minutes and 35 seconds
import subprocess
from util import BaseTest
......@@ -61,3 +62,44 @@ class TestMail(BaseTest):
'BR\r\n')
self.assertResponse(250, '.\r\n')
self.assertResponse(221, 'quIT\r\n')
def test_multiple_mail(self):
for _ in range(2):
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')
def test_mail_save(self):
self.assertResponse(250, b'HELO localDomain\r\n')
self.assertResponse(250, b'MAIL FROM:<user0@test.de>\r\n')
self.assertResponse(250, b'RCPT TO:<user1@localhost>\r\n')
self.assertResponse(250, b'RCPT TO:<user2@localhost>\r\n')
self.assertResponse(354, b'DATA\r\n')
self.client.send(b'SOME_RANDOM_TEXT\r\n')
self.client.send(b'SOME_RANDOM_TEXT\r\n')
self.assertResponse(250, b'.\r\n')
subprocess.check_output(['docker',
'exec',
'{}'.format(self.test_server.docker_id.decode('utf-8')),
'grep',
'-r',
'SOME_RANDOM_TEXT'])
self.assertResponse(221, 'QUIT\r\n')
......@@ -9,3 +9,91 @@ class TestSession(BaseTest):
self.assertResponse(250, 'EHLO marschke.me\r\n')
self.assertResponse(500, 'FAIL\r\n')
def test_post_invalid_parameter_stability_0(self):
self.assertResponse(250, b'EHLO localhost\r\n')
self.assertResponse(500, b'MAIL wrong input blabla\r\n')
self.assertResponse(250, b'MAIL FROM:<correct.mail@test.de>\r\n')
def test_post_invalid_parameter_stability_1(self):
self.assertResponse(250, b'EHLO localhost\r\n')
self.assertResponse(250, b'MAIL FROM:<correct.mail@test.de>\r\n')
self.assertResponse(500, b'RCPT wrong input blabla\r\n')
self.assertResponse(250, b'RCPT TO:<correct@localhost>\r\n')
def test_help(self):
self.assertResponse(250, b'HELP\r\n')
def test_helo(self):
self.assertResponse(250, b'HELO localDomain\r\n')
def test_helo_dot(self):
self.assertResponse(250, b'HELO localDomain.de\r\n')
def test_helo_no_domain(self):
self.assertResponse(501, b'HELO\r\n')
def test_ehlo_dot(self):
self.assertResponse(250, b'EHLO localDomain.de\r\n')
def test_ehlo_no_domain(self):
self.assertResponse(501, b'EHLO\r\n')
def test_mail_no_ehlo(self):
self.assertResponse(503, b'MAIL FROM:<correct.mail@test.de>\r\n')
def test_mail_double_send(self):
self.assertResponse(250, b'EHLO localDomain\r\n')
self.assertResponse(250, b'MAIL FROM:<correct.mail@test.de>\r\n')
self.assertResponse(503, b'MAIL FROM:<correct2.mail@test.de>\r\n')
def test_invalid_state_transition_03(self):
self.assertResponse(250, b'EHLO localhost\r\n')
self.assertResponse(250, b'MAIL FROM:<leonard@marschke.me>\r\n')
self.assertResponse(503, b'DATA\r\n')
self.assertResponse(250, b'RSET\r\n')
def test_invalid_state_transition_04(self):
self.assertResponse(250, b'RSET\r\n')
def test_reset_operation(self):
self.assertResponse(250, b'EHLO localhost\r\n')
self.assertResponse(250, b'MAIL FROM:<leonard@marschke.me>\r\n')
self.assertResponse(250, b'RCPT TO:<firstAddress@localhost>\r\n')
self.assertResponse(250, b'RSET\r\n')
self.assertResponse(503, b'DATA\r\n')
def test_reset_operation_parameter(self):
self.assertResponse(250, b'EHLO localhost\r\n')
self.assertResponse(250, b'MAIL FROM:<leonard@marschke.me>\r\n')
self.assertResponse(250, b'RCPT TO:<firstAddress@localhost>\r\n')
self.assertResponse(250, b'RSET MAIL FROM:<leonard@marschke.me>\r\n')
self.assertResponse(503, b'DATA\r\n')
def test_noop_operation(self):
self.assertResponse(250, b'NOOP\r\n')
def test_noop_parameter_operation(self):
self.assertResponse(250, b'NOOP MAIL FROM:<leonard@marschke.me>\r\n')
self.assertResponse(503, b'DATA\r\n')
def test_vrfy(self):
self.assertResponse(252, b'VRFY leonard@marschke.me\r\n')
def test_multiple_token_wrong(self):
self.assertResponse(500, b'VERFY BLA BLUB')
def test_token_wrong(self):
self.assertResponse(500, b'VRFZ\r\n')
self.assertResponse(250, b'NOOP\r\n')
def test_quit_operation(self):
pass
def test_parse_helo_correct(self):
self.assertResponse(250, b'HELO marschke.me\r\n')
def test_invalid_state_transition_01(self):
self.assertResponse(503, b'RCPT TO:<firstAddress@localhost>\r\n')
def test_invalid_state_transition_02(self):
self.assertResponse(503, b'DATA\r\n')
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