public async Task UnknownUser() { BesteUser besteUser = new BesteUser(); User user = new User { Username = "******", Password = "******" }; BesteUserAuthentificationResponse authResponse = await besteUser.Authenticate(JsonConvert.SerializeObject(user, Formatting.None, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore })); ValiateResponse(authResponse, BesteUserAuthentificationResult.USER_UNKNOWN); ModifyUserResponse response = await besteUser.EditUser(JsonConvert.SerializeObject(user, Formatting.None, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore })); ValiateResponse(response, ModifyUserResult.USER_UNKNOWN); response = await besteUser.ChangePasswordByUser(JsonConvert.SerializeObject(user, Formatting.None, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore })); ValiateResponse(response, ModifyUserResult.USER_UNKNOWN); response = await besteUser.DeleteUser(JsonConvert.SerializeObject(user, Formatting.None, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore })); ValiateResponse(response, ModifyUserResult.USER_UNKNOWN); }
public async Task CreateUserAndLogin() { BesteUser besteUser = new BesteUser(); User user = new User { Username = "******", Lastname = "Lastname", Firstname = "Firstname", Email = "Email", Password = "******" }; ModifyUserResponse response = await besteUser.CreateUser(JsonConvert.SerializeObject(user, Formatting.None, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore })); ValiateResponse(response, ModifyUserResult.SUCCESS); User loginUser = new User { Username = user.Username, Password = user.Password }; BesteUserAuthentificationResponse authResponse = await besteUser.Authenticate(JsonConvert.SerializeObject(loginUser, Formatting.None, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore })); ValiateResponse(authResponse, BesteUserAuthentificationResult.MUST_CHANGE_PASSWORT); response = await besteUser.ChangePasswordByUser(JsonConvert.SerializeObject(loginUser, Formatting.None, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore })); ValiateResponse(response, ModifyUserResult.SUCCESS); authResponse = await besteUser.Authenticate(JsonConvert.SerializeObject(loginUser, Formatting.None, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore })); ValiateResponse(authResponse, BesteUserAuthentificationResult.SUCCESS); }
public async Task CreateUserAndWrongPasswortCounter() { BesteUser besteUser = new BesteUser(); User user = new User { Username = "******", Lastname = "Lastname", Firstname = "Firstname", Email = "Email", Password = "******" }; ModifyUserResponse response = await besteUser.CreateUser(JsonConvert.SerializeObject(user, Formatting.None, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore })); ValiateResponse(response, ModifyUserResult.SUCCESS); User loginUser = new User(); loginUser.Username = user.Username; loginUser.Password = user.Password + "1"; BesteUserAuthentificationResponse authResponse; for (int i = 0; i < 13; i++) { authResponse = await besteUser.Authenticate(JsonConvert.SerializeObject(loginUser, Formatting.None, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore })); ValiateResponse(authResponse, BesteUserAuthentificationResult.WRONG_PASSWORD); } loginUser.Password = user.Password; authResponse = await besteUser.Authenticate(JsonConvert.SerializeObject(loginUser, Formatting.None, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore })); ValiateResponse(authResponse, BesteUserAuthentificationResult.WRONG_PASSWORD_COUNTER_TOO_HIGH); }
public async Task WrongParameters() { BesteUser besteUser = new BesteUser(); User user = new User { Username = "", Password = "" }; BesteUserAuthentificationResponse authResponse = await besteUser.Authenticate(JsonConvert.SerializeObject(user, Formatting.None, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore })); ValiateResponse(authResponse, BesteUserAuthentificationResult.WRONG_PARAMETER); }
public async Task CreateUserAndEdit() { BesteUser besteUser = new BesteUser(); User user = new User { Username = "******", Lastname = "Lastname", Firstname = "Firstname", Email = "Email", Password = "******" }; ModifyUserResponse response = await besteUser.CreateUser(JsonConvert.SerializeObject(user, Formatting.None, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore })); ValiateResponse(response, ModifyUserResult.SUCCESS); User loginUser = new User { Username = "******", Lastname = "Lastname", Firstname = "Firstname", Email = "Email", Password = "******", MustChangePassword = false }; response = await besteUser.EditUser(JsonConvert.SerializeObject(loginUser, Formatting.None, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore })); ValiateResponse(response, ModifyUserResult.SUCCESS); BesteUserAuthentificationResponse authResponse = await besteUser.Authenticate(JsonConvert.SerializeObject(loginUser, Formatting.None, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore })); ValiateResponse(authResponse, BesteUserAuthentificationResult.SUCCESS); }
internal async static Task HandleLogin(WebSocketHandler webSocketHandler) { User user = JsonConvert.DeserializeObject <User>(webSocketHandler.ReceivedCommand.CommandData.ToString()); BesteUserAuthentificationResponse response = await BesteUser.Authenticate(webSocketHandler.ReceivedCommand.CommandData.ToString()); if (response.Result == BesteUserAuthentificationResult.SUCCESS || response.Result == BesteUserAuthentificationResult.MUST_CHANGE_PASSWORT) { webSocketHandler.User = response.UserData; List <PureRight> pureRights = new List <PureRight>(); pureRights.Add(new PureRight { Authorized = true, Operation = "ChangePassword_" + webSocketHandler.User.Username, RecourceModule = "User" }); pureRights.Add(new PureRight { Authorized = true, Operation = "EditUser_" + webSocketHandler.User.Username, RecourceModule = "User" }); pureRights.Add(new PureRight { Authorized = true, Operation = "DeleteUser_" + webSocketHandler.User.Username, RecourceModule = "User" }); pureRights.Add(new PureRight { Authorized = true, Operation = "GetUser_" + webSocketHandler.User.Username, RecourceModule = "User" }); webSocketHandler.ConnectedUserToken = await RightControl.Register(webSocketHandler.User.Uuid, pureRights); } Command resonseCommand = new Command("AuthentificationResponse", response); await webSocketHandler.Send(resonseCommand); }
public async Task ForcedJsonSerializationErrors() { BesteUser besteUser = new BesteUser(); ModifyUserResponse response = await besteUser.CreateUser("no json]"); ValiateResponse(response, ModifyUserResult.JSON_ERROR); response = await besteUser.ChangePasswordByUser("no json]"); ValiateResponse(response, ModifyUserResult.JSON_ERROR); response = await besteUser.DeleteUser("no json]"); ValiateResponse(response, ModifyUserResult.JSON_ERROR); response = await besteUser.EditUser("no json]"); ValiateResponse(response, ModifyUserResult.JSON_ERROR); BesteUserAuthentificationResponse authResponse = await besteUser.Authenticate("no json]"); ValiateResponse(authResponse, BesteUserAuthentificationResult.JSON_ERROR); }