maddy

Fork https://github.com/foxcpp/maddy

git clone git://git.lin.moe/go/maddy.git

 1//go:build integration
 2// +build integration
 3
 4/*
 5Maddy Mail Server - Composable all-in-one email server.
 6Copyright © 2019-2020 Max Mazurov <fox.cpp@disroot.org>, Maddy Mail Server contributors
 7
 8This program is free software: you can redistribute it and/or modify
 9it under the terms of the GNU General Public License as published by
10the Free Software Foundation, either version 3 of the License, or
11(at your option) any later version.
12
13This program is distributed in the hope that it will be useful,
14but WITHOUT ANY WARRANTY; without even the implied warranty of
15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16GNU General Public License for more details.
17
18You should have received a copy of the GNU General Public License
19along with this program.  If not, see <https://www.gnu.org/licenses/>.
20*/
21
22package tests_test
23
24import (
25	"testing"
26
27	"github.com/foxcpp/maddy/tests"
28)
29
30func TestBasic(tt *testing.T) {
31	tt.Parallel()
32
33	// This test is mostly intended to test whether the integration testing
34	// library is working as expected.
35
36	t := tests.NewT(tt)
37	t.DNS(nil)
38	t.Port("smtp")
39	t.Config(`
40		smtp tcp://127.0.0.1:{env:TEST_PORT_smtp} {
41			hostname mx.maddy.test
42			tls off
43
44			deliver_to dummy
45		}`)
46	t.Run(1)
47	defer t.Close()
48
49	conn := t.Conn("smtp")
50	defer conn.Close()
51	conn.ExpectPattern("220 mx.maddy.test *")
52	conn.Writeln("EHLO localhost")
53	conn.ExpectPattern("250-*")
54	conn.ExpectPattern("250-PIPELINING")
55	conn.ExpectPattern("250-8BITMIME")
56	conn.ExpectPattern("250-ENHANCEDSTATUSCODES")
57	conn.ExpectPattern("250-CHUNKING")
58	conn.ExpectPattern("250-SMTPUTF8")
59	conn.ExpectPattern("250-SIZE *")
60	conn.ExpectPattern("250 LIMITS RCPTMAX=20000")
61	conn.Writeln("QUIT")
62	conn.ExpectPattern("221 *")
63}