Fixed password generation

This commit is contained in:
2025-06-17 21:01:57 +02:00
parent 061ce4cb3d
commit 56a7e76785
8 changed files with 722 additions and 42 deletions

View File

@@ -34,30 +34,7 @@ public class UserService_Tests
Console.WriteLine(ex.InnerException);
Assert.Fail($"An exception was thrown: {ex.Message}");
}
}
[TestMethod]
public async Task GetUserByUsernameAndPassword_Null()
{
try
{
var testString = "test";
if (_userService != null)
{
var user = await _userService.GetUserByUsernameAndPassword(testString, testString);
Assert.IsTrue(user == null);
}
else
{
Assert.Fail($"UserService is null");
}
}
catch (Exception ex)
{
Console.WriteLine(ex.InnerException);
Assert.Fail($"An exception was thrown: {ex}");
}
}
}
[TestMethod]
public async Task CheckIfEmailIsValid_EmailNotExists()
@@ -93,7 +70,8 @@ public class UserService_Tests
{
FirstName = expectedUser.FirstName ?? String.Empty,
LastName = expectedUser.LastName ?? String.Empty,
Email = expectedUser.Email ?? String.Empty
Email = expectedUser.Email ?? String.Empty,
Password = "Password"
};
Role role = new()
@@ -110,6 +88,10 @@ public class UserService_Tests
Assert.IsTrue(expectedUser.LastName == user.LastName);
Assert.IsTrue(expectedUser.Email == user.Email);
Assert.IsTrue(expectedUser.Role?.Name == user.Role?.Name);
Assert.IsTrue(user.PasswordIterations == 10);
Assert.IsNotNull(expectedUser.PasswordSalt);
Assert.IsNotNull(expectedUser.PasswordPepper);
Assert.IsNotNull(expectedUser.Password);
_user = user;
}
@@ -120,6 +102,52 @@ public class UserService_Tests
}
}
[TestMethod]
public async Task GetUserByUsernameAndPassword_Null()
{
try
{
var testString = "test";
if (_userService != null)
{
var user = await _userService.GetUserByUsernameAndPassword(testString, testString);
Assert.IsTrue(user == null);
}
else
{
Assert.Fail($"UserService is null");
}
}
catch (Exception ex)
{
Console.WriteLine(ex.InnerException);
Assert.Fail($"An exception was thrown: {ex}");
}
}
[TestMethod]
public async Task GetUserByUsernameAndPassword_Success()
{
try
{
var password = "Password";
if (_userService != null)
{
var user = await _userService.GetUserByUsernameAndPassword(_user.Email, password);
Assert.IsTrue(user != null);
}
else
{
Assert.Fail($"UserService is null");
}
}
catch (Exception ex)
{
Console.WriteLine(ex.InnerException);
Assert.Fail($"An exception was thrown: {ex}");
}
}
[TestMethod]
public async Task CreateUserAsync_Exception()
{