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); } }
// TODO: using an arbitrary user is a workaround, because we can't delete and // therefore not add a user with known properties internal UserObject GetAbritraryUser() { var listRequest = UserRequestFactory.CreateQueryUserRequest(0, 1, "", "", "", ""); var list = RequestHandler.ExecuteAndUnpack <List <UserObject> >(listRequest); return(list[0]); }
private UserObject AddRandomUser() { var data = GetRandomUserData(); var request = UserRequestFactory.CreateAddUserRequest(data); var user = RequestHandler.ExecuteAndUnpack <UserObject>(request); _addedUsers.Add(user.Id); return(user); }
public void RemoveAddedUsers() { foreach (var curId in _addedUsers) { var request = UserRequestFactory.CreateDeleteUserRequest(curId); RequestHandler.ExecuteSuccessfully <DataspaceResponse>(request); } _addedUsers.Clear(); }
public void GetUserbyId() { var user = GetAbritraryUser(); var request = UserRequestFactory.CreateGetUserRequest(user.Id); var getUser = RequestHandler.ExecuteAndUnpack <UserObject>(request); Assert.True(user.Equals(getUser)); Assert.True(user.EqualsCompletely(getUser)); }
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); }
public static User GetByUsername(string gameId, string privateKey, string username) { var request = UserRequestFactory.CreateGetRequest(gameId, privateKey, username); var results = request.Process(null); if (results == null || results.Length == 0) { return(null); } return(results[0]); }
public void QueryAllUsers() { var request = UserRequestFactory.CreateQueryUserRequest(0, 10, "", "", "", ""); var list = RequestHandler.ExecuteAndUnpack <List <UserObject> >(request); // we have user, at least the one that is used for log in is always there Assert.Greater(list.Count, 0); var user = list[0] as UserObject; // make sure we have data that makes sense // TODO: once we know what the user really provides, check that email, name, etc arent null Assert.NotNull(user); Assert.IsNotNullOrEmpty(user.UserName); }
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); }
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); }
protected override void ProcessRecord() { foreach (var curId in Id) { try { var request = UserRequestFactory.CreateDeleteUserRequest(curId); if (ShouldProcess(curId.ToString())) { RequestHandler.ExecuteSuccessfully(request); } } catch (ReportableException e) { WriteError(e.ErrorRecord); } } }
protected override void ProcessRecord() { if (Id != null) { foreach (long curId in Id) { try { var request = UserRequestFactory.CreateGetUserRequest(curId); WriteObject(RequestHandler.ExecuteAndUnpack <UserObject>(request)); } catch (ReportableException e) { WriteError(e.ErrorRecord); } } return; } // otherwise we want to query users! try { int limit = Limit ?? _defaultLimit; var request = UserRequestFactory.CreateQueryUserRequest(Start, Limit ?? _defaultLimit, UserName, FamilyName, GivenName, EMail); var users = RequestHandler.ExecuteAndUnpack <List <UserObject> >(request); foreach (var curUser in users) { if (!Exact.IsPresent || CheckExactMatch(curUser)) { WriteObject(curUser); } } } catch (ReportableException e) { WriteError(e.ErrorRecord); } }
public static IAsyncResult BeginAuthenticateUser(string gameId, string privateKey, string username, string userToken, AsyncCallback callback = null, object asyncState = null) { var request = UserRequestFactory.CreateAuthRequest(gameId, privateKey, username, userToken); return(request.Begin(callback, asyncState)); }
// TODO: better cleanup for added users! private void RemoveUser(long id) { var request = UserRequestFactory.CreateDeleteUserRequest(id); RequestHandler.ExecuteSuccessfully <DataspaceResponse>(request); }
public static User[] GetByUserIds(string gameId, string privateKey, params string[] userIds) { var request = UserRequestFactory.CreateGetRequest(gameId, privateKey, userIds); return(request.Process(null)); }
public static string AuthenticateUser(string gameId, string privateKey, string username, string userToken) { var request = UserRequestFactory.CreateAuthRequest(gameId, privateKey, username, userToken); return(request.Process(null)); }
public static IAsyncResult BeginGetByUsername(string gameId, string privateKey, string username, AsyncCallback callback = null, object asyncState = null) { var request = UserRequestFactory.CreateGetRequest(gameId, privateKey, username); return(request.Begin(callback, asyncState)); }