using Microsoft.VisualStudio.TestTools.UnitTesting; using Strata.Base.Internal.Encryptors; using System; using System.Configuration; namespace Strata.Base.Internal.Tests.Security { [TestClass] public class UberEncryptionMethodTests { private const string TestOrgPin = "12345"; private const string TestKey = "TestKey123"; private const string TestUsername = "testuser"; private const string TestPassword = "password123"; private static readonly Guid TestUserGuid = Guid.NewGuid(); private const string TestSalt = "testsalt"; [TestInitialize] public void Setup() { // Set up the configuration key for testing var config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); config.AppSettings.Settings.Remove("UberMonetKey"); config.AppSettings.Settings.Add("UberMonetKey", TestKey); config.Save(); ConfigurationManager.RefreshSection("appSettings"); } [TestMethod] public void Encode_ReturnsExpectedLength() { // Arrange var encryptor = new UberEncryptionMethod(); // Act string result = encryptor.Encode(TestUsername, TestOrgPin, TestPassword, TestUserGuid, TestSalt); // Assert Assert.AreEqual(6, result.Length, "UberMonet hash should be 6 characters long"); } [TestMethod] public void Encode_SameInputProducesSameOutput() { // Arrange var encryptor = new UberEncryptionMethod(); // Act string result1 = encryptor.Encode(TestUsername, TestOrgPin, TestPassword, TestUserGuid, TestSalt); string result2 = encryptor.Encode(TestUsername, TestOrgPin, TestPassword, TestUserGuid, TestSalt); // Assert Assert.AreEqual(result1, result2, "Same input should produce same hash"); } [TestMethod] public void Encode_DifferentOrgPinsProduceDifferentOutputs() { // Arrange var encryptor = new UberEncryptionMethod(); string differentOrgPin = "54321"; // Act string result1 = encryptor.Encode(TestUsername, TestOrgPin, TestPassword, TestUserGuid, TestSalt); string result2 = encryptor.Encode(TestUsername, differentOrgPin, TestPassword, TestUserGuid, TestSalt); // Assert Assert.AreNotEqual(result1, result2, "Different OrgPins should produce different hashes"); } } }