|
|
|
@ -1,5 +1,3 @@
|
|
|
|
|
using Moq;
|
|
|
|
|
|
|
|
|
|
namespace TestVeraxShield.factoriesTests;
|
|
|
|
|
|
|
|
|
|
using Xunit;
|
|
|
|
@ -34,21 +32,5 @@ public class UtilisateursFactoryTests
|
|
|
|
|
// Assert
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void ToUtilisateur_HashesPassword_WhenSelectedUserPasswordDiffers()
|
|
|
|
|
{
|
|
|
|
|
// Setup the context or service to provide a selected user with a different password
|
|
|
|
|
var selectedUserService = new Mock<ISelectedUserService>();
|
|
|
|
|
selectedUserService.Setup(s => s.GetSelectedUser()).Returns(new Utilisateur { Mdp = "differentPassword" });
|
|
|
|
|
UtilisateursFactory.SetSelectedUserService(selectedUserService.Object);
|
|
|
|
|
|
|
|
|
|
var modele = new FormulaireAjoutModele("user", "First", "Last", "email@test.com", "newPassword", "role", false);
|
|
|
|
|
|
|
|
|
|
// Act
|
|
|
|
|
var result = UtilisateursFactory.toUtilisateur(modele);
|
|
|
|
|
|
|
|
|
|
// Assert
|
|
|
|
|
Assert.NotEqual("newPassword", result.Mdp); // Assert password is hashed
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|