public void SecurityQuestionAnswerSerialisesCorrectly() { var test = new SecurityQuestionAnswer() {QuestionName = "NameOfFavouriteTeacher", QuestionAnswer = "MrsRobinson"}; var xml = Serializer.Create(x => x.PrettyPrint()).Serialize(test); Approvals.Verify(xml); }
public void Register(string planType) { var d = new Data.AccountInfo(); EmailField.SendKeys(planType + d.Email); EmailConfirmField.SendKeys(planType + d.Email); UsernameField.SendKeys(planType + d.username); PasswordField.SendKeys(d.Password); ConfirmPasswordField.SendKeys(d.Password); SelectElement SecurityQuestionDrop = new SelectElement(SecurityQuestionDropdown); SecurityQuestionDrop.SelectByText(d.Securityselection); SecurityQuestionAnswer.SendKeys(d.Securityanswer); NextButton.Click(); if (this._driver.Url == @"https://betacustomeraccess.myfloridaprepaid.com/enrollment/accountowner.aspx") { Tests.successCount++; Console.WriteLine("User: "******" created]"); } else { Tests.failCount++; Console.WriteLine("[FAIL] [RUN #" + Tests.runCount + "]" + "[User: "******" not created]"); } }
public void SecurityCheckCommandSerialisesCorrectly() { var accountId = Guid.Parse("d39b24ca-fe17-4fc6-b504-399764d10406"); var requestId = Guid.Parse("21550455-8a1f-4ca4-bffa-0842bb30fc01"); var qa = new SecurityQuestionAnswer[1]; qa[0] = new SecurityQuestionAnswer() { QuestionName = "NameOfFavouriteTeacher", QuestionAnswer = "MrsRobinson" }; var test = new SecurityCheckCommand() { AccountId = accountId, RequestId = requestId, FirstSecurityQuestion = qa[0] }; var xml = Serializer.Create(x => x.PrettyPrint()).Serialize(test); Approvals.Verify(xml); }
/// <summary> /// Checks the user-supplied question and answer against the stored answer. /// </summary> /// <param name="answer"></param> /// <returns></returns> private bool IsSecurityAnswerCorrect(SecurityQuestionAnswer answer) { var questions = from b in db.USER_SECURITY_QUESTIONS join c in db.USERS on b.UserId equals c.UserId where c.PrimaryEmail.Equals(answer.PrimaryEmail, StringComparison.CurrentCultureIgnoreCase) && ( (b.SecurityQuestion1 == answer.QuestionText && b.SecurityAnswer1.Equals(answer.AnswerText, StringComparison.InvariantCultureIgnoreCase)) || (b.SecurityQuestion2 == answer.QuestionText && b.SecurityAnswer2.Equals(answer.AnswerText, StringComparison.InvariantCultureIgnoreCase)) ) select b; if ((questions != null) && questions.FirstOrDefault() != null) { return(true); } return(false); }
/// <summary> /// Checks the user-supplied question and answer against the stored answer. /// </summary> /// <param name="answer"></param> /// <returns></returns> private bool IsSecurityAnswerCorrect(SecurityQuestionAnswer answer) { var questions = from b in db.USER_SECURITY_QUESTIONS join c in db.USERS on b.UserId equals c.UserId where c.PrimaryEmail == answer.PrimaryEmail && ( (b.SecurityQuestion1 == answer.QuestionText && b.SecurityAnswer1 == answer.AnswerText) || (b.SecurityQuestion2 == answer.QuestionText && b.SecurityAnswer2 == answer.AnswerText) ) select b; if ((questions != null) && questions.FirstOrDefault() != null) { return(true); } return(false); }
public void SimpleSerialisation() { var accountId = Guid.Parse("d39b24ca-fe17-4fc6-b504-399764d10406"); var requestId = Guid.Parse("21550455-8a1f-4ca4-bffa-0842bb30fc01"); var qa = new SecurityQuestionAnswer[1]; qa[0] = new SecurityQuestionAnswer() { QuestionName = "NameOfFavouriteTeacher", QuestionAnswer = "MrsRobinson" }; var test = new SecurityCheckCommand() { AccountId = accountId, RequestId = requestId, FirstSecurityQuestion = qa[0] }; var sb = new StringBuilder(); var serializer = new XmlSerializer(test.GetType()); var settings = new XmlWriterSettings() {OmitXmlDeclaration = true, Indent = true}; var namespaces = new XmlSerializerNamespaces(); namespaces.Add(string.Empty, string.Empty); using (var writer = XmlWriter.Create(sb, settings)) { serializer.Serialize(writer, test, namespaces); } Approvals.Verify(sb.ToString()); }
public async Task <IHttpActionResult> ResetPassword([FromBody] SecurityQuestionAnswer answer) { try { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (!emailvalidator.IsMatch(answer.PrimaryEmail.Trim())) { return(BadRequest()); } if (IsSecurityAnswerCorrect(answer)) { UserAccountSecurityManager resetter = new UserAccountSecurityManager(); bool rval = await resetter.ResetPassword(answer.PrimaryEmail, "Password Reset", answer.AppCode); if (rval) { return(StatusCode(HttpStatusCode.OK)); } else { return(StatusCode(HttpStatusCode.InternalServerError)); } } // return Unauthorized(); // returning a 401 (Unauthorized) gets caught by the JWT interceptor and dumps the user out, which we don't want. return(Conflict()); } catch (Exception e) { return((IHttpActionResult)CSETWeb_Api.Helpers.ElmahWrapper.LogAndReportException(e, Request, HttpContext.Current)); } }