MCPcopy Create free account
hub / github.com/pydio/cells / TestDestructiveCreateUser

Function TestDestructiveCreateUser

idm/user/dao/sql/sql_test.go:732–794  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

730}
731
732func TestDestructiveCreateUser(t *testing.T) {
733 test.RunStorageTests(testcases, t, func(ctx context.Context) {
734 mockDAO, err := manager.Resolve[user.DAO](ctx)
735 if err != nil {
736 panic(err)
737 }
738
739 Convey("Test bug with create user", t, func() {
740
741 _, _, err := mockDAO.Add(context.TODO(), &idm.User{
742 Login: "username",
743 Password: "xxxxxxx",
744 GroupPath: "/path/to/group",
745 Attributes: map[string]string{
746 idm.UserAttrDisplayName: "John Doe",
747 idm.UserAttrHidden: "false",
748 "active": "true",
749 },
750 Roles: []*idm.Role{
751 {Uuid: "1", Label: "Role1"},
752 {Uuid: "2", Label: "Role2"},
753 },
754 })
755
756 So(err, ShouldBeNil)
757
758 _, _, err = mockDAO.Add(context.TODO(), &idm.User{
759 Uuid: "fixed-uuid",
760 Login: "",
761 Password: "hashed",
762 })
763
764 So(err, ShouldNotBeNil)
765
766 var target []interface{}
767 ch := mockDAO.GetNodeTree(context.Background(), tree.NewMPath(1))
768 for n := range ch {
769 tn := n.(*user_model.User)
770 t.Logf("Got node %s (%s)", tn.MPath.ToString(), tn.GetName())
771 target = append(target, n)
772 }
773 So(target, ShouldNotBeEmpty)
774
775 _, _, err = mockDAO.Add(context.TODO(), &idm.User{
776 Uuid: "fixed-uuid",
777 Login: "",
778 Password: "hashed",
779 })
780
781 //So(err, ShouldNotBeNil)
782
783 var target2 []interface{}
784 ch2 := mockDAO.GetNodeTree(context.Background(), tree.NewMPath(1))
785 for n := range ch2 {
786 tn := n.(*user_model.User)
787 t.Logf("Got node %s (%s)", tn.MPath.ToString(), tn.GetName())
788 target2 = append(target2, n)
789 }

Callers

nothing calls this directly

Calls 6

RunStorageTestsFunction · 0.92
NewMPathFunction · 0.92
ToStringMethod · 0.80
AddMethod · 0.65
GetNodeTreeMethod · 0.65
GetNameMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…