Esempio n. 1
0
        protected override void ProcessRecord()
        {
            var addableUser = new UpdatableUserObject()
            {
                UserName   = UserName,
                FamilyName = FamilyName,
                GivenName  = GivenName,
                EMail      = EMail,
                Language   = Language,
                Role       = Role,
                MaxSpace   = MaxSpace
            };

            try
            {
                var request = UserRequestFactory.CreateAddUserRequest(addableUser);
                if (ShouldProcess("Add user"))
                {
                    WriteObject(RequestHandler.ExecuteAndUnpack <UserObject>(request));
                }
            }
            catch (ReportableException e)
            {
                WriteError(e.ErrorRecord);
            }
        }
Esempio n. 2
0
        private UserObject AddRandomUser()
        {
            var data    = GetRandomUserData();
            var request = UserRequestFactory.CreateAddUserRequest(data);
            var user    = RequestHandler.ExecuteAndUnpack <UserObject>(request);

            _addedUsers.Add(user.Id);
            return(user);
        }
Esempio n. 3
0
        public void AddUser()
        {
            var addable = GetRandomUserData();
            var request = UserRequestFactory.CreateAddUserRequest(addable);
            var added   = RequestHandler.ExecuteAndUnpack <UserObject>(request);

            Assert.Greater(added.Id, 0, "User has no proper ID");
            Assert.True(addable.EqualsCompletely(added), "Added users has incorrect information");
            RemoveUser(added.Id);
        }
Esempio n. 4
0
        public void RemoveUser()
        {
            var addable    = GetRandomUserData();
            var addRequest = UserRequestFactory.CreateAddUserRequest(addable);
            var added      = RequestHandler.ExecuteAndUnpack <UserObject>(addRequest);
            var request    = UserRequestFactory.CreateDeleteUserRequest(added.Id);
            var response   = RequestHandler.Execute <DataspaceResponse>(request);

            Assert.True(response.Success, response.Message);

            var getRequest = UserRequestFactory.CreateGetUserRequest(added.Id);
            var result     = RequestHandler.ExecuteAndUnpack <UserObject>(getRequest);

            added.Locked = true;
            added.EqualsCompletely(result);
        }
Esempio n. 5
0
        public void EditUser()
        {
            var addable    = GetRandomUserData();
            var addRequest = UserRequestFactory.CreateAddUserRequest(addable);
            var added      = RequestHandler.ExecuteAndUnpack <UserObject>(addRequest);

            var updates = GetRandomUserData();
            var request = UserRequestFactory.CreateEditUserRequest(added.Id, updates);
            var updated = RequestHandler.ExecuteAndUnpack <UserObject>(request);

            Assert.AreEqual(added, updated);
            Assert.False(updated.EqualsCompletely(added));
            // notice that the UserName never changes, this is intended
            updates.UserName = added.UserName;
            Assert.True(updates.EqualsCompletely(updated));
            RemoveUser(updated.Id);
        }