예제 #1
0
        public async Task CreateUserAndDelete()
        {
            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
            };

            response = await besteUser.DeleteUser(JsonConvert.SerializeObject(loginUser, Formatting.None, new JsonSerializerSettings {
                NullValueHandling = NullValueHandling.Ignore
            }));

            ValiateResponse(response, ModifyUserResult.SUCCESS);
        }
예제 #2
0
        public async Task CreateUserAndChangePasswortBreakRules()
        {
            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 = "******"
            };

            response = await besteUser.ChangePasswordByUser(JsonConvert.SerializeObject(loginUser, Formatting.None, new JsonSerializerSettings {
                NullValueHandling = NullValueHandling.Ignore
            }));

            ValiateResponse(response, ModifyUserResult.PASSWORD_GUIDELINES_ERROR);
        }
예제 #3
0
        internal async static Task CreateUser(WebSocketHandler webSocketHandler)
        {
            Command resonseCommand = await ModifyUser(async() => {
                return(await BesteUser.CreateUser(webSocketHandler.ReceivedCommand.CommandData.ToString()));
            },
                                                      "CreateUser",
                                                      webSocketHandler);

            await webSocketHandler.Send(resonseCommand);
        }
예제 #4
0
        public async Task CreateUserMissingParams()
        {
            BesteUser besteUser = new BesteUser();
            User      user      = new User();

            user.Username = "******";
            user.Password = "******";
            ModifyUserResponse response = await besteUser.CreateUser(JsonConvert.SerializeObject(user, Formatting.None, new JsonSerializerSettings {
                NullValueHandling = NullValueHandling.Ignore
            }));

            ValiateResponse(response, ModifyUserResult.MISSING_USER_PARAMS);
        }
예제 #5
0
        public async Task CreateDuplicateUser()
        {
            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);

            response = await besteUser.CreateUser(JsonConvert.SerializeObject(user, Formatting.None, new JsonSerializerSettings {
                NullValueHandling = NullValueHandling.Ignore
            }));

            ValiateResponse(response, ModifyUserResult.USER_ALREADY_EXISTS);
        }
예제 #6
0
        public async Task CreateUserWrongPasswordGuidelines()
        {
            BesteUser besteUser = new BesteUser();
            User      user      = new User();

            user.Username  = "******";
            user.Lastname  = "Lastname";
            user.Firstname = "Firstname";
            user.Email     = "Email";
            user.Password  = "******";
            ModifyUserResponse response = await besteUser.CreateUser(JsonConvert.SerializeObject(user, Formatting.None, new JsonSerializerSettings {
                NullValueHandling = NullValueHandling.Ignore
            }));

            ValiateResponse(response, ModifyUserResult.PASSWORD_GUIDELINES_ERROR);
        }
예제 #7
0
        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);
        }
예제 #8
0
        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);
        }
예제 #9
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);
        }
예제 #10
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);
        }
예제 #11
0
        public async Task GetUsers()
        {
            BesteUser besteUser = new BesteUser();
            User      user      = new User
            {
                Username  = "******",
                Lastname  = "Lastname",
                Firstname = "Firstname",
                Email     = "A_C_Email",
                Password  = "******"
            };
            ModifyUserResponse response = await besteUser.CreateUser(JsonConvert.SerializeObject(user, Formatting.None, new JsonSerializerSettings {
                NullValueHandling = NullValueHandling.Ignore
            }));

            ValiateResponse(response, ModifyUserResult.SUCCESS);

            user.Username = "******";
            user.Email    = "A_B_Email";
            response      = await besteUser.CreateUser(JsonConvert.SerializeObject(user, Formatting.None, new JsonSerializerSettings {
                NullValueHandling = NullValueHandling.Ignore
            }));

            ValiateResponse(response, ModifyUserResult.SUCCESS);

            user.Username = "******";
            user.Email    = "A_A_Email";
            response      = await besteUser.CreateUser(JsonConvert.SerializeObject(user, Formatting.None, new JsonSerializerSettings {
                NullValueHandling = NullValueHandling.Ignore
            }));

            ValiateResponse(response, ModifyUserResult.SUCCESS);

            GetUsersParams   getUsersParams  = new GetUsersParams(10, 0, SortUsersBy.USERNAME);
            GetUsersResponse getUserResponse = await besteUser.GetUsers(JsonConvert.SerializeObject(getUsersParams, Formatting.None, new JsonSerializerSettings {
                NullValueHandling = NullValueHandling.Ignore
            }));

            ValiateResponse(getUserResponse, GetUsersResult.SUCCESS);
            if (getUserResponse.Users.Count < 3)
            {
                Assert.Fail("getUserResponse.Users.Count < 3");
            }
            if (getUserResponse.Users[0].Username != "A_A_User")
            {
                Assert.Fail("getUserResponse.Users[0].Username != 'A_A_User'");
            }

            getUsersParams  = new GetUsersParams(10, 1, SortUsersBy.USERNAME);
            getUserResponse = await besteUser.GetUsers(JsonConvert.SerializeObject(getUsersParams, Formatting.None, new JsonSerializerSettings {
                NullValueHandling = NullValueHandling.Ignore
            }));

            ValiateResponse(getUserResponse, GetUsersResult.SUCCESS);
            if (getUserResponse.Users.Count < 2)
            {
                Assert.Fail("getUserResponse.Users.Count < 2");
            }
            if (getUserResponse.Users[0].Username != "A_B_User")
            {
                Assert.Fail("getUserResponse.Users[0].Username != 'A_B_User'");
            }

            getUsersParams  = new GetUsersParams(1, 1, SortUsersBy.USERNAME);
            getUserResponse = await besteUser.GetUsers(JsonConvert.SerializeObject(getUsersParams, Formatting.None, new JsonSerializerSettings {
                NullValueHandling = NullValueHandling.Ignore
            }));

            ValiateResponse(getUserResponse, GetUsersResult.SUCCESS);
            if (getUserResponse.Users.Count != 1)
            {
                Assert.Fail("getUserResponse.Users.Count != 1");
            }
            if (getUserResponse.Users[0].Username != "A_B_User")
            {
                Assert.Fail("getUserResponse.Users[0].Username != 'A_B_User'");
            }

            getUsersParams  = new GetUsersParams(10, 2, SortUsersBy.EMAIL);
            getUserResponse = await besteUser.GetUsers(JsonConvert.SerializeObject(getUsersParams, Formatting.None, new JsonSerializerSettings {
                NullValueHandling = NullValueHandling.Ignore
            }));

            ValiateResponse(getUserResponse, GetUsersResult.SUCCESS);

            if (getUserResponse.Users[0].Email != "A_C_Email")
            {
                Assert.Fail("getUserResponse.Users[0].Email != 'A_C_Email'");
            }

            getUserResponse = await besteUser.GetUser(JsonConvert.SerializeObject(user, Formatting.None, new JsonSerializerSettings {
                NullValueHandling = NullValueHandling.Ignore
            }));

            ValiateResponse(getUserResponse, GetUsersResult.SUCCESS);
            if (getUserResponse.Users[0].Email != "A_A_Email")
            {
                Assert.Fail("getUserResponse.Users[0].Email != 'A_A_Email'");
            }
        }