feat: 增加 SafeW 已监控群列表接口
通过 getUpdates 将群写入 Redis,供创建/编辑渠道时选择 chat_id,避免前端重复传递 token。
This commit is contained in:
Vendored
+22
@@ -0,0 +1,22 @@
|
||||
package cache
|
||||
|
||||
import (
|
||||
"encoding/hex"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestTokenHashStableAndNotPlainToken(t *testing.T) {
|
||||
h := TokenHash("secret-token")
|
||||
if h == "secret-token" || h == "" {
|
||||
t.Fatalf("hash=%q", h)
|
||||
}
|
||||
if _, err := hex.DecodeString(h); err != nil {
|
||||
t.Fatalf("not hex: %v", err)
|
||||
}
|
||||
if TokenHash("secret-token") != h {
|
||||
t.Fatal("not stable")
|
||||
}
|
||||
if TokenHash("other") == h {
|
||||
t.Fatal("collision")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user