//パスワード変更 public static bool Change(string user, string pass, MailBox mailBox, Conf conf) { if (pass == null) { //無効なパスワードの指定は失敗する return(false); } var dat = (Dat)conf.Get("user"); foreach (var o in dat) { if (o.StrList[0] == user) { o.StrList[1] = Crypt.Encrypt(pass); conf.Set("user", dat); //データ変更 if (mailBox.SetPass(user, pass)) { if (mailBox.Auth(user, pass)) { return(true); } } return(false); } } return(false); }
[TestCase("user1", null, false)] //パスワードが無効(不正) public void Authによる認証(string user, string pass, bool expected) { //exercise var actual = sut.Auth(user, pass); //verify Assert.That(actual, Is.EqualTo(expected)); }
[TestCase("user3", "123")] //user3のパスワードを123に変更する public void Changeによるパスワード変更_変更確認(string user, string pass) { //setUp var expected = true; Chps.Change(user, pass, _mailBox, _conf); //exercise var actual = _mailBox.Auth(user, pass); //verify Assert.That(actual, Is.EqualTo(expected)); }
public void AuthTest(string user, string pass, bool expected) { //setUp var dir = (String)_conf.Get("dir"); var datUser = (Dat)_conf.Get("user"); var sut = new MailBox(new Logger(), datUser, dir); //var expected = true; //exercise var actual = sut.Auth(user, pass); //verify Assert.That(actual, Is.EqualTo(expected)); }