summaryrefslogtreecommitdiff
path: root/test/tests/protocols
blob: 52209d7e4d076b242678b6a2a1e03d17894f4469 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
. functions
export HELOHOST=f.q.d.n

make-testmail

for p in smtp qmqp
do
	start server "tcpserver -1 ::0 0 sh $srcdir/test/accept-$p.sh"
	catch-port server

	echo "Testing protocol success with $p (command-line)"
	protocol $p --host=localhost --port=$port 3<$testmail

	echo "Testing protocol success with $p (stdin)"
	protocol $p -- host=localhost port=$port 3<$testmail

	echo "Testing protocol success with $p (stdin, IPv6)"
	protocol $p -- host=::1 port=$port 3<$testmail

	echo "Testing protocol success with $p (source addr)"
	protocol $p -- host=::1 port=$port source=::1 3<$testmail

	echo "Testing protocol failure with $p (bad source addr 1)"
	error 19 protocol $p -- host=::1 port=$port source=127.0.0.1 3<$testmail

	echo "Testing protocol failure with $p (bad source addr 2)"
	error 19 protocol $p -- host=127.0.0.1 port=$port source=::1 3<$testmail

	stop server

	echo "Testing host not found error with $p."
	error 2 protocol $p --host=this.host.can.not.exist 3<$testmail

	echo "Testing connection refused error with $p."
	error 7 protocol $p -p $port --host=localhost 3<$testmail

	echo "Testing connection refused error with $p (IPv6)."
	error 7 protocol $p -p $port --host=::1 3<$testmail
	
	echo "Testing usage error with $p (zero args)."
	error 1 protocol $p 3<$testmail
	
	echo "Testing usage error with $p (two args)."
	error 1 protocol $p --host=localhost foobar 3<$testmail
	
	echo "Testing usage error with $p (unknown option)."
	error 1 protocol $p -x --host=localhost 3<$testmail
	
	echo "Testing usage error with $p (invalid integer)."
	error 1 protocol $p -p foo --host=localhost 3<$testmail

	start server tcpserver -1 0 0 date
	port=$( head -n 1 $tmpdir/service/server-log )
	echo "Testing protocol failure with $p."
	error 11 protocol $p -p $port --host=localhost 3<$testmail
	stop server
	wait
done

stop server