fix: scope login audit records by tenant
This commit is contained in:
@@ -8,7 +8,7 @@ import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestEnsureIMAdminGovernanceTablesUsesSelectedTenantDatabase(t *testing.T) {
|
||||
func TestEnsureIMAdminGovernanceTablesDefinesLoginAuditTenantScope(t *testing.T) {
|
||||
exec := &recordingGroupSchemaExecutor{}
|
||||
if err := ensureIMAdminGovernanceTables(exec); err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -27,7 +27,15 @@ func TestEnsureIMAdminGovernanceTablesUsesSelectedTenantDatabase(t *testing.T) {
|
||||
t.Fatalf("hot login state table must not be created: %s", table)
|
||||
}
|
||||
}
|
||||
if strings.Contains(joined, "tinode.") || strings.Contains(joined, "create database") || strings.Contains(joined, "tenant_id") {
|
||||
t.Fatalf("admin governance schema must stay inside the selected tenant database: %s", joined)
|
||||
if strings.Contains(joined, "tinode.") || strings.Contains(joined, "create database") {
|
||||
t.Fatalf("admin governance schema must use the active shared database: %s", joined)
|
||||
}
|
||||
start := strings.Index(joined, "create table if not exists im_user_login_logs")
|
||||
if start < 0 {
|
||||
t.Fatal("missing im_user_login_logs")
|
||||
}
|
||||
end := strings.Index(joined[start:], ") engine=")
|
||||
if end < 0 || !strings.Contains(joined[start:start+end], "tenant_id bigint not null") {
|
||||
t.Fatal("im_user_login_logs must declare tenant_id")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user