TestUserValidate_GroupInGroups asserts that listing the primary Group inside the supplemental Groups list is rejected. AutoEdges would emit duplicate edges and useradd/usermod treat the primary specially, so this combination is always a config error.
(t *testing.T)
| 586 | // edges and useradd/usermod treat the primary specially, so this combination is |
| 587 | // always a config error. |
| 588 | func TestUserValidate_GroupInGroups(t *testing.T) { |
| 589 | res := mkUser("james", "exists", func(r *UserRes) { |
| 590 | r.Group = strPtr("wheel") |
| 591 | r.Groups = []string{"wheel", "devs"} |
| 592 | }) |
| 593 | if err := res.Validate(); err == nil { |
| 594 | t.Error("expected error when primary Group is also in Groups; got nil") |
| 595 | } |
| 596 | } |
| 597 | |
| 598 | // TestUserValidate_NameInGroups asserts that the user's own name (which is the |
| 599 | // conventional primary-group name on most distros) is rejected from the |