2020-11-25 22:40:31 +00:00
|
|
|
using System;
|
2019-10-18 22:22:08 +00:00
|
|
|
using MediaBrowser.Common;
|
2019-09-17 16:07:15 +00:00
|
|
|
using MediaBrowser.Common.Cryptography;
|
|
|
|
using Xunit;
|
|
|
|
|
|
|
|
namespace Jellyfin.Common.Tests
|
|
|
|
{
|
|
|
|
public class PasswordHashTests
|
|
|
|
{
|
|
|
|
[Theory]
|
2020-06-13 11:37:41 +00:00
|
|
|
[InlineData(
|
|
|
|
"$PBKDF2$iterations=1000$62FBA410AFCA5B4475F35137AB2E8596B127E4D927BA23F6CC05C067E897042D",
|
2019-09-17 16:07:15 +00:00
|
|
|
"PBKDF2",
|
|
|
|
"",
|
|
|
|
"62FBA410AFCA5B4475F35137AB2E8596B127E4D927BA23F6CC05C067E897042D")]
|
|
|
|
public void ParseTest(string passwordHash, string id, string salt, string hash)
|
|
|
|
{
|
|
|
|
var pass = PasswordHash.Parse(passwordHash);
|
|
|
|
Assert.Equal(id, pass.Id);
|
2020-11-25 22:40:31 +00:00
|
|
|
Assert.Equal(salt, Convert.ToHexString(pass.Salt));
|
|
|
|
Assert.Equal(hash, Convert.ToHexString(pass.Hash));
|
2019-09-17 16:07:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[Theory]
|
|
|
|
[InlineData("$PBKDF2$iterations=1000$62FBA410AFCA5B4475F35137AB2E8596B127E4D927BA23F6CC05C067E897042D")]
|
|
|
|
public void ToStringTest(string passwordHash)
|
|
|
|
{
|
|
|
|
Assert.Equal(passwordHash, PasswordHash.Parse(passwordHash).ToString());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|