Esempio n. 1
0
        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);
        }
        internal async static Task EditUser(WebSocketHandler webSocketHandler)
        {
            Command resonseCommand = await ModifyUser(async() =>
            {
                return(await BesteUser.EditUser(webSocketHandler.ReceivedCommand.CommandData.ToString()));
            },
                                                      "EditUser",
                                                      webSocketHandler);

            await webSocketHandler.Send(resonseCommand);
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        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);
        }