1//go:build integration && cgo && !nosqlite32// +build integration,cgo,!nosqlite334package tests_test56import (7 "testing"89 "github.com/foxcpp/maddy/tests"10)1112func TestIMAPEndpointAuthMap(tt *testing.T) {13 tt.Parallel()14 t := tests.NewT(tt)1516 t.DNS(nil)17 t.Port("imap")18 t.Config(`19 storage.imapsql test_store {20 driver sqlite321 dsn imapsql.db22 }2324 imap tcp://127.0.0.1:{env:TEST_PORT_imap} {25 tls off2627 auth_map email_localpart28 auth pass_table static {29 entry "user" "bcrypt:$2a$10$E.AuCH3oYbaRrETXfXwc0.4jRAQBbanpZiCfudsJz9bHzLr/qj6ti" # password: 12330 }31 storage &test_store32 }33 `)34 t.Run(1)35 defer t.Close()3637 imapConn := t.Conn("imap")38 defer imapConn.Close()39 imapConn.ExpectPattern(`\* OK *`)40 imapConn.Writeln(". LOGIN user@example.org 123")41 imapConn.ExpectPattern(". OK *")42 imapConn.Writeln(". SELECT INBOX")43 imapConn.ExpectPattern(`\* *`)44 imapConn.ExpectPattern(`\* *`)45 imapConn.ExpectPattern(`\* *`)46 imapConn.ExpectPattern(`\* *`)47 imapConn.ExpectPattern(`\* *`)48 imapConn.ExpectPattern(`\* *`)49 imapConn.ExpectPattern(`. OK *`)50}5152func TestIMAPEndpointStorageMap(tt *testing.T) {53 tt.Parallel()54 t := tests.NewT(tt)5556 t.DNS(nil)57 t.Port("imap")58 t.Config(`59 storage.imapsql test_store {60 driver sqlite361 dsn imapsql.db62 }6364 imap tcp://127.0.0.1:{env:TEST_PORT_imap} {65 tls off6667 storage_map email_localpart6869 auth_map email_localpart70 auth pass_table static {71 entry "user" "bcrypt:$2a$10$z9SvUwUjkY8wKOWd9IbISeEmbJua2cXRPqw7s2BnLXJuc6pIMPncK" # password: 12372 }73 storage &test_store74 }75 `)76 t.Run(1)77 defer t.Close()7879 imapConn := t.Conn("imap")80 defer imapConn.Close()81 imapConn.ExpectPattern(`\* OK *`)82 imapConn.Writeln(". LOGIN user@example.org 123")83 imapConn.ExpectPattern(". OK *")84 imapConn.Writeln(". CREATE testbox")85 imapConn.ExpectPattern(". OK *")8687 imapConn2 := t.Conn("imap")88 defer imapConn2.Close()89 imapConn2.ExpectPattern(`\* OK *`)90 imapConn2.Writeln(". LOGIN user@example.com 123")91 imapConn2.ExpectPattern(". OK *")92 imapConn2.Writeln(`. LIST "" "*"`)93 imapConn2.Expect(`* LIST (\HasNoChildren) "." INBOX`)94 imapConn2.Expect(`* LIST (\HasNoChildren) "." "testbox"`)95 imapConn2.ExpectPattern(". OK *")96}