Adds PBKDF2 protection for account passwords. (#122)

This commit is contained in:
Kamron Batman 2020-04-30 02:33:14 -07:00 committed by GitHub
parent 1ee6830637
commit 29467a3ed9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 209 additions and 172 deletions

View file

@ -0,0 +1,30 @@
using Xunit;
using Server.Accounting;
namespace Server.Tests.Accounting
{
public class PBKDF2PasswordProtectionTest
{
private const string plainPassword = "hello-good-sir";
[Fact]
public void TestValidates()
{
var passwordProtection = new PBKDF2PasswordProtection();
string encryptedPassword = passwordProtection.EncryptPassword(plainPassword);
Assert.True(passwordProtection.ValidatePassword(encryptedPassword, plainPassword));
}
[Fact]
public void TestPasswordDoesNotValidate()
{
var passwordProtection = new PBKDF2PasswordProtection();
string encryptedPassword = passwordProtection.EncryptPassword(plainPassword);
Assert.False(passwordProtection.ValidatePassword(encryptedPassword, "Not the same password"));
}
}
}