Smail/backend/services/list/imap_snapshot_test.go
smail 7fc0e1ca8f
Some checks are pending
Security Checks / security (push) Waiting to run
修复邮件协议整数边界并补充事务回滚回归
2026-09-21 00:39:26 +08:00

28 lines
819 B
Go

package list
import (
"math"
"strconv"
"testing"
)
func TestIMAPSnapshotCountRejectsInvalidUIDBeforeDatabaseRead(t *testing.T) {
for _, snapshot := range [][]int{{0}, {-1}, {1, 0}} {
if _, err := SearchEmails(nil, "INBOX", nil, snapshot); err == nil {
t.Fatal("非法快照必须在查询数据库之前拒绝")
}
}
if count, err := imapSnapshotCount(nil); err != nil || count != 0 {
t.Fatalf("空快照验证失败:%d %v", count, err)
}
if strconv.IntSize >= 64 {
limit := uint64(math.MaxUint32)
if count, err := imapSnapshotCount([]int{int(limit)}); err != nil || count != 1 {
t.Fatalf("最大合法 UID 被拒绝:%d %v", count, err)
}
if _, err := SearchEmails(nil, "INBOX", nil, []int{int(limit + 1)}); err == nil {
t.Fatal("越界 UID 不应被截断为搜索结果")
}
}
}