fix: resolve bound im tenant for company admins

This commit is contained in:
richjohnrambo
2026-09-16 13:19:55 +08:00
parent 5dbbf39cce
commit c258e0473b
2 changed files with 22 additions and 5 deletions
@@ -8,12 +8,21 @@ import (
"hotgo/internal/model"
)
func TestCompanyDepartmentIsImPlatformAdmin(t *testing.T) {
func TestBoundCompanyDepartmentUsesBoundTenant(t *testing.T) {
ctx := context.WithValue(context.Background(), consts.ContextHTTPKey, &model.Context{
User: &model.Identity{Id: 14, TenantId: 1, DeptType: consts.DeptTypeCompany, RoleKey: "imManage"},
})
if isImPlatformAdmin(ctx, 14) {
t.Fatal("expected bound company department IM manager to use its bound tenant")
}
}
func TestUnboundCompanyDepartmentIsImPlatformAdmin(t *testing.T) {
ctx := context.WithValue(context.Background(), consts.ContextHTTPKey, &model.Context{
User: &model.Identity{Id: 14, DeptType: consts.DeptTypeCompany, RoleKey: "imManage"},
})
if !isImPlatformAdmin(ctx, 14) {
t.Fatal("expected company department IM manager to use platform tenant selection")
t.Fatal("expected unbound company department IM manager to use platform tenant selection")
}
}
@@ -31,6 +40,14 @@ func TestResolveImAdminBoundTenant(t *testing.T) {
},
want: 2,
},
{
name: "company department with tenant binding",
identity: &model.Identity{
TenantId: 1,
DeptType: consts.DeptTypeCompany,
},
want: 1,
},
}
for _, tt := range tests {