31 lines
1.1 KiB
Go
31 lines
1.1 KiB
Go
package qaopsorg
|
|
|
|
import (
|
|
"encoding/json"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestMembersKeepNamedAndUnnamedRosterPeopleWithoutRawIdentifiers(t *testing.T) {
|
|
d := Directory{Departments: []Department{{ID: "root", Name: "fixture"}}, People: []Person{{ID: "private-a", Name: "<源端姓名>", UnionID: "private-union", DepartmentIDs: []string{"root"}}, {ID: "private-zero", DepartmentIDs: []string{"root"}}}}
|
|
p, err := BuildAttribution(State{State: "ready", DirectoryID: "directory"}, d)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
members := p.Members()
|
|
if len(members) != 2 {
|
|
t.Fatal("zero-use roster member omitted")
|
|
}
|
|
if p.Resolve("private-a", "").Name != "<源端姓名>" || p.Resolve("private-zero", "").Name != "" {
|
|
t.Fatal("display name lost or guessed")
|
|
}
|
|
raw, _ := json.Marshal(members)
|
|
if strings.Contains(string(raw), "private-") || strings.Contains(string(raw), "department_ids") {
|
|
t.Fatal("internal identifiers serialized")
|
|
}
|
|
d.People[0].Name = "bad\x00name"
|
|
if _, err = BuildAttribution(State{State: "ready", DirectoryID: "directory"}, d); err == nil {
|
|
t.Fatal("invalid display name accepted")
|
|
}
|
|
}
|