MCPcopy
hub / github.com/purpleidea/mgmt / TestUserValidate_GroupInGroups

Function TestUserValidate_GroupInGroups

engine/resources/user_test.go:588–596  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

586// edges and useradd/usermod treat the primary specially, so this combination is
587// always a config error.
588func 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

Callers

nothing calls this directly

Calls 4

mkUserFunction · 0.85
strPtrFunction · 0.85
ValidateMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected