Beispiel #1
0
        public void UpdatePasswordInvalid(Fields field, InvalidPasswordTestCases inputType)
        {
            var request           = GetParameters(inputType, field);
            var updatePassHandler = new UpdatePasswordManager();
            var response          = updatePassHandler.UpdatePassword(request, System.Net.Http.HttpMethod.Put);

            LastPassword = Common.CheckUpdatedPassword(response) ? request["newPassword"].ToString() : string.Empty;
            PrAssert.That(response, PrIs.ErrorResponse()
                          .And.HttpCode(InvalidPasswordTestCases.CurrentPassword == inputType || InvalidPasswordTestCases.PreviousPassword == inputType ? System.Net.HttpStatusCode.Conflict : System.Net.HttpStatusCode.BadRequest));
        }
Beispiel #2
0
        private Dictionary <string, object> GetParameters(InvalidPasswordTestCases inputType, Fields field)
        {
            var parameterRequest = new Dictionary <string, object>(Common.UpdatePasswordParameters);
            var fieldName        = Char.ToLowerInvariant(field.ToString()[0]) + field.ToString().Substring(1);

            var creds           = AuthenticationInfoProvider.GetAuthSpecForCurrentTest();
            var defaultPassword = creds.Users.Values.Single().Password.ToString();

            parameterRequest["oldPassword"] = defaultPassword;
            parameterRequest[fieldName]     = PasswordMappingValues[inputType];

            switch (inputType)
            {
            case InvalidPasswordTestCases.Array:
                parameterRequest[fieldName] = new List <int>()
                {
                    123, 456, 789
                };
                break;

            case InvalidPasswordTestCases.CurrentPassword:
                parameterRequest[fieldName] = defaultPassword;
                break;

            case InvalidPasswordTestCases.PreviousPassword:
                Common.UpdateNewPassword(NewPassword, defaultPassword);
                parameterRequest[fieldName] = defaultPassword;
                break;

            case InvalidPasswordTestCases.Missing:
                parameterRequest.Remove(fieldName);
                break;

            case InvalidPasswordTestCases.NoneExistField:
                if (field != Fields.CheckOldPasswords)
                {
                    parameterRequest["oldPassword"] = defaultPassword;
                    parameterRequest["newPassword"] = NewPassword;
                }
                else
                {
                    parameterRequest["checkOldPasswords"] = 5;
                }
                parameterRequest["my" + field.ToString()] = "23";
                break;
            }
            return(parameterRequest);
        }