aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBond-009 <bond.009@outlook.com>2019-09-17 18:07:15 +0200
committerAnthony Lavado <anthony@lavado.ca>2019-09-17 12:07:15 -0400
commit6f17a0b7af5775386e554f2e2e2a4a6829d2895d (patch)
treece792d21af0f8e5d0208aec1aba55e8047f2f439 /tests
parentadc2a68a98a572e6541ffac587fd9f6247aec6d5 (diff)
Remove legacy auth code (#1677)
* Remove legacy auth code * Adds tests so we don't break PasswordHash (again) * Clean up interfaces * Remove duplicate code * Use auto properties * static using * Don't use 'this' * Fix build
Diffstat (limited to 'tests')
-rw-r--r--tests/Jellyfin.Common.Tests/Jellyfin.Common.Tests.csproj19
-rw-r--r--tests/Jellyfin.Common.Tests/PasswordHashTests.cs29
2 files changed, 48 insertions, 0 deletions
diff --git a/tests/Jellyfin.Common.Tests/Jellyfin.Common.Tests.csproj b/tests/Jellyfin.Common.Tests/Jellyfin.Common.Tests.csproj
new file mode 100644
index 000000000..449aaa1a5
--- /dev/null
+++ b/tests/Jellyfin.Common.Tests/Jellyfin.Common.Tests.csproj
@@ -0,0 +1,19 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+ <PropertyGroup>
+ <TargetFramework>netcoreapp2.2</TargetFramework>
+
+ <IsPackable>false</IsPackable>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
+ <PackageReference Include="xunit" Version="2.4.1" />
+ <PackageReference Include="xunit.runner.visualstudio" Version="2.4.1" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <ProjectReference Include="../../MediaBrowser.Common/MediaBrowser.Common.csproj" />
+ </ItemGroup>
+
+</Project>
diff --git a/tests/Jellyfin.Common.Tests/PasswordHashTests.cs b/tests/Jellyfin.Common.Tests/PasswordHashTests.cs
new file mode 100644
index 000000000..5fa86f3bd
--- /dev/null
+++ b/tests/Jellyfin.Common.Tests/PasswordHashTests.cs
@@ -0,0 +1,29 @@
+using MediaBrowser.Common.Cryptography;
+using Xunit;
+using static MediaBrowser.Common.HexHelper;
+
+namespace Jellyfin.Common.Tests
+{
+ public class PasswordHashTests
+ {
+ [Theory]
+ [InlineData("$PBKDF2$iterations=1000$62FBA410AFCA5B4475F35137AB2E8596B127E4D927BA23F6CC05C067E897042D",
+ "PBKDF2",
+ "",
+ "62FBA410AFCA5B4475F35137AB2E8596B127E4D927BA23F6CC05C067E897042D")]
+ public void ParseTest(string passwordHash, string id, string salt, string hash)
+ {
+ var pass = PasswordHash.Parse(passwordHash);
+ Assert.Equal(id, pass.Id);
+ Assert.Equal(salt, ToHexString(pass.Salt));
+ Assert.Equal(hash, ToHexString(pass.Hash));
+ }
+
+ [Theory]
+ [InlineData("$PBKDF2$iterations=1000$62FBA410AFCA5B4475F35137AB2E8596B127E4D927BA23F6CC05C067E897042D")]
+ public void ToStringTest(string passwordHash)
+ {
+ Assert.Equal(passwordHash, PasswordHash.Parse(passwordHash).ToString());
+ }
+ }
+}