SEBWIN-296: Added missing unit tests for password encryption.

This commit is contained in:
dbuechel 2019-02-15 16:04:24 +01:00
parent 86e494e611
commit 44df65e67a

View file

@ -49,5 +49,24 @@ namespace SafeExamBrowser.Configuration.UnitTests.Cryptography
Assert.AreEqual(SaveStatus.Success, saveStatus);
Assert.AreEqual(LoadStatus.Success, loadStatus);
}
[TestMethod]
public void MustRequestPasswordForDecryption()
{
var status = sut.Decrypt(new MemoryStream(), null, out _);
Assert.AreEqual(LoadStatus.PasswordNeeded, status);
}
[TestMethod]
public void MustRequestPasswordIfInvalid()
{
var password = "test1234";
var saveStatus = sut.Encrypt(new MemoryStream(Encoding.UTF8.GetBytes("A super secret message!")), password, out var encrypted);
var loadStatus = sut.Decrypt(encrypted, "not the correct password", out _);
Assert.AreEqual(SaveStatus.Success, saveStatus);
Assert.AreEqual(LoadStatus.PasswordNeeded, loadStatus);
}
}
}