- config 重写:删 user-ou/inactive-ou/group-root-* / group-object-class / group-member-attr / initial-password;新增 lldap 写通道 + webhook + confirm-base-url + 两套 schedule + guard - ldaplib 收拢为只读:属性常量/DN 归入 attrs.go;删 ops.go 写路径与 internal/password - config.example.yml 重写成 LLDAP 形态 - 组命名修订(呼应 AGENTS.md 约束12):用部门稳定索引 cn=<dept_id> 做组身份, mirror_departments 增 group_id 列并跨快照保留,可读中文名只走 DB 展示
45 lines
1.5 KiB
Go
45 lines
1.5 KiB
Go
package mapping
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
// TestDeptGroupDN 验证部门组 DN 直接用部门稳定索引(dept_id),不编码祖先路径。
|
|
func TestDeptGroupDN(t *testing.T) {
|
|
got := DeptGroupDN("od-yanfa-1", "dc=example,dc=com")
|
|
want := "cn=od-yanfa-1,ou=groups,dc=example,dc=com"
|
|
if got != want {
|
|
t.Errorf("DeptGroupDN = %q, 期望 %q", got, want)
|
|
}
|
|
}
|
|
|
|
// TestDeptGroupDNStableAcrossRename 验证部门改名(中文名变化)不影响组 DN——
|
|
// 组身份绑在索引上,改名不引起身份漂移。
|
|
func TestDeptGroupDNStableAcrossRename(t *testing.T) {
|
|
a := DeptGroupDN("od-123", "dc=example,dc=com")
|
|
// 无论部门叫「研发部」还是「产品部」,索引不变,DN 不变。
|
|
b := DeptGroupDN("od-123", "dc=example,dc=com")
|
|
if a != b {
|
|
t.Errorf("同索引的组 DN 应稳定不变: %q vs %q", a, b)
|
|
}
|
|
}
|
|
|
|
// TestDeptGroupDNDistinct 验证不同部门索引产生不同组 DN。
|
|
func TestDeptGroupDNDistinct(t *testing.T) {
|
|
a := DeptGroupDN("od-1", "dc=example,dc=com")
|
|
b := DeptGroupDN("od-2", "dc=example,dc=com")
|
|
if a == b {
|
|
t.Errorf("不同部门索引的组 DN 不应相同")
|
|
}
|
|
}
|
|
|
|
// TestGroupRootDN 验证组根 OU 固定挂在 ou=groups 下。
|
|
func TestGroupRootDN(t *testing.T) {
|
|
if got := GroupRootDN("dc=example,dc=com"); got != "ou=groups,dc=example,dc=com" {
|
|
t.Errorf("GroupRootDN = %q", got)
|
|
}
|
|
if !strings.HasPrefix(DeptGroupDN("od-1", "dc=example,dc=com"), "cn=") {
|
|
t.Errorf("组 DN 应以 cn= 开头")
|
|
}
|
|
} |