1
0
mirror of https://blitiri.com.ar/repos/chasquid synced 2025-12-17 14:37:02 +00:00

test: Add a new integration test with minor dialogs

This patch adds a new integration test, which executes various small
dialogs, to cover corner cases that are not well covered (according to
our coverage report).

For example, "EHLO" without domain, or invalid DATA.

While we could do them via Go tests, this way is more realistic, and the
tests are easier to write.
This commit is contained in:
Alberto Bertogli
2018-02-25 02:50:39 +00:00
parent 5ce4ff2602
commit 61d2961ee9
15 changed files with 247 additions and 0 deletions

View File

@@ -12,6 +12,7 @@ interactive command-line tools.
import argparse
import os
import re
import ssl
import socket
import subprocess
import sys
@@ -97,6 +98,19 @@ class TCPSock (Sock):
self.has_conn.set()
class TLSSock (Sock):
def __init__(self, addr):
host, port = addr.rsplit(":", 1)
Sock.__init__(self, (host, int(port)))
plain_sock = socket.create_connection(self.addr)
self.sock = ssl.wrap_socket(plain_sock)
def connect(self):
self.connr = self.sock.makefile(mode="r")
self.connw = self.sock.makefile(mode="w")
self.has_conn.set()
class Interpreter (object):
"""Interpreter for chamuyero scripts."""
def __init__(self):
@@ -175,6 +189,11 @@ class Interpreter (object):
sock.connect()
self.procs[proc] = sock
elif op == "tls_connect":
sock = TLSSock(params)
sock.connect()
self.procs[proc] = sock
# -> Send to a process stdin, with a \n at the end.
# .> Send to a process stdin, no \n at the end.
elif op == "->":