Add Users list/detail with ACL toggles and library people update/status APIs. Fix project table layout and ANSI-safe cell rendering, and decode array responses from people/status so saves no longer fail on JSON unmarshal. Co-authored-by: Cursor <cursoragent@cursor.com>
44 lines
950 B
Go
44 lines
950 B
Go
package model
|
|
|
|
import "testing"
|
|
|
|
func TestUserACLFromRawFullAccess(t *testing.T) {
|
|
raw := map[string]any{
|
|
"isAdmin": true,
|
|
"listAdminModules": []any{"crm"},
|
|
}
|
|
acl := UserACLFromRaw(raw)
|
|
if !acl.FullAccess {
|
|
t.Fatal("expected full access")
|
|
}
|
|
if !acl.ACLModuleOn("documents") {
|
|
t.Fatal("full access should show all modules on")
|
|
}
|
|
}
|
|
|
|
func TestUserACLAPIPayloadPartial(t *testing.T) {
|
|
acl := UserACLState{
|
|
FullAccess: false,
|
|
Modules: map[string]bool{
|
|
"documents": true,
|
|
"projects": true,
|
|
},
|
|
}
|
|
isAdmin, mods := acl.APIPayload()
|
|
if isAdmin {
|
|
t.Fatal("expected partial admin")
|
|
}
|
|
if len(mods) != 2 {
|
|
t.Fatalf("mods=%v", mods)
|
|
}
|
|
}
|
|
|
|
func TestUserIsEnabled(t *testing.T) {
|
|
if !UserIsEnabled(map[string]any{"status": EmployeeStatusActive}) {
|
|
t.Fatal("active user should be enabled")
|
|
}
|
|
if UserIsEnabled(map[string]any{"status": EmployeeStatusTerminated}) {
|
|
t.Fatal("terminated user should be disabled")
|
|
}
|
|
}
|