fix: resolve bound im tenant for company admins
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user