多租户更改

This commit is contained in:
richjohnrambo
2026-08-11 15:59:57 +08:00
parent 6c800de67d
commit c2076721fc
453 changed files with 102349 additions and 47 deletions
+25
View File
@@ -0,0 +1,25 @@
package auth
import (
"testing"
"github.com/tinode/chat/server/store/types"
)
func TestBindRecord(t *testing.T) {
ctx := AuthContext{TenantID: 7, RemoteAddr: "127.0.0.1"}
rec := &Rec{}
if err := BindRecord(ctx, rec); err != nil {
t.Fatalf("BindRecord failed: %v", err)
}
if rec.TenantID != ctx.TenantID {
t.Fatalf("unexpected tenant: got %d, want %d", rec.TenantID, ctx.TenantID)
}
if err := BindRecord(AuthContext{}, &Rec{}); err != types.ErrMalformed {
t.Fatalf("zero tenant: got %v, want %v", err, types.ErrMalformed)
}
if err := BindRecord(ctx, &Rec{TenantID: 8}); err != types.ErrFailed {
t.Fatalf("tenant mismatch: got %v, want %v", err, types.ErrFailed)
}
}