From 50b90113239d51a38c8aa75f023e2da5d5a316b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Domeradzki?= Date: Wed, 24 Sep 2025 23:17:25 +0200 Subject: [PATCH] Add hashing unit test --- ArchiSteamFarm.Tests/ArchiCryptoHelper.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/ArchiSteamFarm.Tests/ArchiCryptoHelper.cs b/ArchiSteamFarm.Tests/ArchiCryptoHelper.cs index ce77a368d..92c5a546c 100644 --- a/ArchiSteamFarm.Tests/ArchiCryptoHelper.cs +++ b/ArchiSteamFarm.Tests/ArchiCryptoHelper.cs @@ -61,5 +61,21 @@ internal sealed class ArchiCryptoHelper { await CanEncryptDecrypt(ECryptoMethod.ProtectedDataForCurrentUser).ConfigureAwait(false); } + + [DataRow(EHashingMethod.PlainText, TestPassword)] + [DataRow(EHashingMethod.Pbkdf2, "WlS48GNrs1hAhcNHPfV09TPTLhf03gExb6zpaKiwX5A=")] + [DataRow(EHashingMethod.SCrypt, "9LjhjyugakDQ7Haq/ufyTZDfIGeeWbLcE+/9IeKm8gc=")] + [TestMethod] + internal void CanHash(EHashingMethod hashingMethod, string expectedHash) { + if (!Enum.IsDefined(hashingMethod)) { + throw new InvalidEnumArgumentException(nameof(hashingMethod), (int) hashingMethod, typeof(EHashingMethod)); + } + + ArgumentException.ThrowIfNullOrEmpty(expectedHash); + + string hashed = Hash(hashingMethod, TestPassword); + + Assert.AreEqual(expectedHash, hashed); + } } #pragma warning restore CA1812 // False positive, the class is used during MSTest