public void PractitionerLoginAccountFound() { //Positive Case PractitionerData controller = new PractitionerData(); LoginInfo sampleUser = new LoginInfo(); sampleUser.EmailAddress = "*****@*****.**"; sampleUser.Password = "******"; string expectedPassword = "******"; //copied from database LoginInfo result = new LoginInfo(); result = controller.PractitionerLogin(sampleUser); Assert.AreNotEqual(Guid.Empty, result.AccountNo); Assert.AreEqual(expectedPassword, result.Password); Assert.IsNotNull(result.Salt); Assert.IsNotNull(result.AccountStatus); //Negative Case - Wrong Email LoginInfo sampleUser2 = new LoginInfo(); sampleUser2.EmailAddress = "*****@*****.**"; sampleUser2.Password = "******"; result = new LoginInfo(); result = controller.PractitionerLogin(sampleUser2); Assert.AreEqual(Guid.Empty, result.AccountNo); Assert.IsNull(result.AccountStatus); Assert.IsNull(result.Salt); //Negative Case - Wrong Password LoginInfo sampleUser3 = new LoginInfo(); sampleUser3.EmailAddress = "*****@*****.**"; sampleUser3.Password = "******"; result = new LoginInfo(); result = controller.PractitionerLogin(sampleUser3); Assert.AreNotEqual(Guid.Empty, result.AccountNo); Assert.AreEqual(expectedPassword, result.Password); Assert.IsNotNull(result.AccountStatus); Assert.IsNotNull(result.Salt); }
public LoginInfo PractitionerLogin(LoginInfo loginInfo) { LoginInfo result = new LoginInfo(); result = loginInfo; try { PractitionerData dataLayer = new PractitionerData(); //hashing password result = dataLayer.PractitionerLogin(loginInfo); var hashedPassword = HashingHelper.ComputeHMAC_SHA256(Encoding.UTF8.GetBytes(loginInfo.Password), result.Salt); loginInfo.Password = Convert.ToBase64String(hashedPassword); if (loginInfo.Password.Equals(result.Password)) { result.Salt = null; return(result); } } catch (Exception err) { new LogHelper().LogMessage("PractitionerBusiness.PractitionerLogin : " + err); } return(result); }