mirror of
https://github.com/mjl-/mox.git
synced 2024-12-25 16:03:48 +03:00
c57aeac7f0
an é (e with accent) can also be written as e+\u0301. the first form is NFC, the second NFD. when logging in, we transform usernames (email addresses) to NFC. so both forms will be accepted. if a client is using NFD, they can log in too. for passwords, we apply the PRECIS "opaquestring", which (despite the name) transforms the value too: unicode spaces are replaced with ascii spaces. the string is also normalized to NFC. PRECIS may reject confusing passwords when you set a password.
52 lines
1 KiB
Go
52 lines
1 KiB
Go
package imapserver
|
|
|
|
import (
|
|
"fmt"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/mjl-/mox/imapclient"
|
|
)
|
|
|
|
func TestIdle(t *testing.T) {
|
|
tc1 := start(t)
|
|
defer tc1.close()
|
|
tc1.client.Login("mjl@mox.example", password0)
|
|
|
|
tc2 := startNoSwitchboard(t)
|
|
defer tc2.close()
|
|
tc2.client.Login("mjl@mox.example", password0)
|
|
|
|
tc1.transactf("ok", "select inbox")
|
|
tc2.transactf("ok", "select inbox")
|
|
|
|
// todo: test with delivery through smtp
|
|
|
|
tc2.cmdf("", "idle")
|
|
tc2.readprefixline("+ ")
|
|
done := make(chan error)
|
|
go func() {
|
|
defer func() {
|
|
x := recover()
|
|
if x != nil {
|
|
done <- fmt.Errorf("%v", x)
|
|
}
|
|
}()
|
|
untagged, _ := tc2.client.ReadUntagged()
|
|
var exists imapclient.UntaggedExists
|
|
tuntagged(tc2.t, untagged, &exists)
|
|
// todo: validate the data we got back.
|
|
tc2.writelinef("done")
|
|
done <- nil
|
|
}()
|
|
|
|
tc1.transactf("ok", "append inbox () {%d+}\r\n%s", len(exampleMsg), exampleMsg)
|
|
timer := time.NewTimer(time.Second)
|
|
defer timer.Stop()
|
|
select {
|
|
case err := <-done:
|
|
tc1.check(err, "idle")
|
|
case <-timer.C:
|
|
t.Fatalf("idle did not finish")
|
|
}
|
|
}
|