| 114 | } |
| 115 | |
| 116 | func TestImapsqlDeliveryMap(tt *testing.T) { |
| 117 | tt.Parallel() |
| 118 | t := tests.NewT(tt) |
| 119 | |
| 120 | t.DNS(nil) |
| 121 | t.Port("imap") |
| 122 | t.Port("smtp") |
| 123 | t.Config(` |
| 124 | storage.imapsql test_store { |
| 125 | delivery_map email_localpart |
| 126 | auth_normalize precis |
| 127 | |
| 128 | driver sqlite3 |
| 129 | dsn imapsql.db |
| 130 | } |
| 131 | |
| 132 | imap tcp://127.0.0.1:{env:TEST_PORT_imap} { |
| 133 | tls off |
| 134 | |
| 135 | auth dummy |
| 136 | storage &test_store |
| 137 | } |
| 138 | |
| 139 | smtp tcp://127.0.0.1:{env:TEST_PORT_smtp} { |
| 140 | hostname maddy.test |
| 141 | tls off |
| 142 | |
| 143 | deliver_to &test_store |
| 144 | } |
| 145 | `) |
| 146 | t.Run(2) |
| 147 | defer t.Close() |
| 148 | |
| 149 | imapConn := t.Conn("imap") |
| 150 | defer imapConn.Close() |
| 151 | imapConn.ExpectPattern(`\* OK *`) |
| 152 | imapConn.Writeln(". LOGIN testusr 1234") |
| 153 | imapConn.ExpectPattern(". OK *") |
| 154 | imapConn.Writeln(". SELECT INBOX") |
| 155 | imapConn.ExpectPattern(`\* *`) |
| 156 | imapConn.ExpectPattern(`\* *`) |
| 157 | imapConn.ExpectPattern(`\* *`) |
| 158 | imapConn.ExpectPattern(`\* *`) |
| 159 | imapConn.ExpectPattern(`\* *`) |
| 160 | imapConn.ExpectPattern(`\* *`) |
| 161 | imapConn.ExpectPattern(`. OK *`) |
| 162 | |
| 163 | smtpConn := t.Conn("smtp") |
| 164 | defer smtpConn.Close() |
| 165 | smtpConn.SMTPNegotation("localhost", nil, nil) |
| 166 | smtpConn.Writeln("MAIL FROM:<sender@maddy.test>") |
| 167 | smtpConn.ExpectPattern("2*") |
| 168 | smtpConn.Writeln("RCPT TO:<testusr@maddy.test>") |
| 169 | smtpConn.ExpectPattern("2*") |
| 170 | smtpConn.Writeln("DATA") |
| 171 | smtpConn.ExpectPattern("354 *") |
| 172 | smtpConn.Writeln("From: <sender@maddy.test>") |
| 173 | smtpConn.Writeln("To: <testusr@maddy.test>") |