Compare commits
No commits in common. 'master' and 'pageIndex' have entirely different histories.
@ -1,79 +0,0 @@
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: default
|
||||
|
||||
trigger:
|
||||
event:
|
||||
- push
|
||||
|
||||
steps:
|
||||
- name: build
|
||||
image: mcr.microsoft.com/dotnet/sdk:8.0
|
||||
commands:
|
||||
- cd VeraxShield
|
||||
- dotnet restore VeraxShield.sln
|
||||
- dotnet build VeraxShield.sln -c Release --no-restore
|
||||
- dotnet publish VeraxShield.sln -c Release --no-restore -o $CI_PROJECT_DIR/build/release
|
||||
|
||||
- name: tests
|
||||
image: mcr.microsoft.com/dotnet/sdk:8.0
|
||||
commands:
|
||||
- cd VeraxShield
|
||||
- dotnet restore VeraxShield.sln
|
||||
- dotnet test VeraxShield.sln --no-restore
|
||||
depends_on: [build]
|
||||
|
||||
- name: code-inspection
|
||||
image: hub.codefirst.iut.uca.fr/marc.chevaldonne/codefirst-dronesonarplugin-dotnet8
|
||||
secrets: [ SECRET_SONAR_LOGIN ]
|
||||
environment:
|
||||
sonar_host: https://codefirst.iut.uca.fr/sonar/
|
||||
sonar_token:
|
||||
from_secret: SECRET_SONAR_LOGIN # Secret de Drone
|
||||
project_key: VeraxShield
|
||||
|
||||
commands:
|
||||
- cd VeraxShield/
|
||||
- dotnet restore VeraxShield.sln
|
||||
- dotnet sonarscanner begin /k:$${project_key} /d:sonar.host.url=$${sonar_host} /d:sonar.coverageReportPaths="coveragereport/SonarQube.xml" /d:sonar.coverage.exclusions="VeraxShield/wwwroot/**","VeraxShield/composants/**","VeraxShield/pages/**","VeraxShield/Properties/**","TestVeraxShield/**","VeraxShield/Program.cs","VeraxShield/services/UtilisateursDataService/UtilisateursDataServiceApi.cs","VeraxShield/services/UtilisateursDataService/UtilisateursDataServiceFactice.cs" /d:sonar.login=$${sonar_token}
|
||||
- dotnet build VeraxShield.sln -c Release --no-restore
|
||||
- dotnet test VeraxShield.sln --logger trx --no-restore /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura --collect "XPlat Code Coverage"
|
||||
- reportgenerator -reports:"**/coverage.cobertura.xml" -reporttypes:SonarQube -targetdir:"coveragereport"
|
||||
- dotnet publish VeraxShield.sln -c Release --no-restore -o $CI_PROJECT_DIR/build/release
|
||||
- dotnet sonarscanner end /d:sonar.login=$${sonar_token}
|
||||
when:
|
||||
branch:
|
||||
- master
|
||||
event:
|
||||
- push
|
||||
- pull_request
|
||||
depends_on: [build,tests]
|
||||
|
||||
|
||||
- name: docker-build-and-push
|
||||
image: plugins/docker
|
||||
settings:
|
||||
dockerfile: dockerfile
|
||||
context: .
|
||||
registry: hub.codefirst.iut.uca.fr
|
||||
repo: hub.codefirst.iut.uca.fr/louis.laborie/sae_2a_blazor
|
||||
username:
|
||||
from_secret: SECRET_REGISTRY_USERNAME
|
||||
password:
|
||||
from_secret: SECRET_REGISTRY_PASSWORD
|
||||
when:
|
||||
branch:
|
||||
- master
|
||||
- rebase
|
||||
|
||||
- name: deploy-container
|
||||
image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dockerproxy-clientdrone:latest
|
||||
environment:
|
||||
IMAGENAME: hub.codefirst.iut.uca.fr/louis.laborie/sae_2a_blazor:latest
|
||||
CONTAINERNAME: verax-blazor
|
||||
COMMAND: create
|
||||
OVERWRITE: true
|
||||
CODEFIRST_CLIENTDRONE_ENV_ASPNETCORE_HTTP_PORTS: 80
|
||||
ADMINS: louislaborie,tonyfages,noasillard,jeanmarcillac,shanacascarra
|
||||
depends_on:
|
||||
- docker-build-and-push
|
@ -1,15 +0,0 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Rider ignored files
|
||||
/.idea.VeraxShield.iml
|
||||
/contentModel.xml
|
||||
/modules.xml
|
||||
/projectSettingsUpdater.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
||||
# GitHub Copilot persisted chat sessions
|
||||
/copilot/chatSessions
|
@ -1,10 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="UserContentModel">
|
||||
<attachedFolders>
|
||||
<Path>../../Blazor_SAE</Path>
|
||||
</attachedFolders>
|
||||
<explicitIncludes />
|
||||
<explicitExcludes />
|
||||
</component>
|
||||
</project>
|
@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
|
||||
</component>
|
||||
</project>
|
@ -1,105 +0,0 @@
|
||||
using System.Security.Claims;
|
||||
using Moq;
|
||||
using VeraxShield.composants.formulaires.modeles;
|
||||
using VeraxShield.modele.utilisateurs;
|
||||
using VeraxShield.services.UtilisateursDataService;
|
||||
|
||||
namespace TestVeraxShield;
|
||||
|
||||
public class AuthentificationServiceTests
|
||||
{
|
||||
private readonly AuthentificationService _authService;
|
||||
private readonly Mock<IUtilisateursDataService> _mockDataService = new Mock<IUtilisateursDataService>();
|
||||
|
||||
public AuthentificationServiceTests()
|
||||
{
|
||||
_authService = new AuthentificationService(_mockDataService.Object);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Connexion_WithValidCredentials_ShouldSucceed()
|
||||
{
|
||||
// Arrange
|
||||
var testUser = new Utilisateur("testUser", "Test", "User", "test@user.com", BCrypt.Net.BCrypt.HashPassword("password"), "User", false);
|
||||
|
||||
_mockDataService.Setup(s => s.getAllUtilisateurs())
|
||||
.ReturnsAsync(new List<Utilisateur> { testUser });
|
||||
|
||||
var requete = new RequeteConnexion
|
||||
{
|
||||
Pseudo = "testUser",
|
||||
MotDePasse = "password"
|
||||
};
|
||||
|
||||
// Act & Assert
|
||||
await _authService.Connexion(requete);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Connexion_WithInvalidCredentials_ShouldThrowException()
|
||||
{
|
||||
// Arrange
|
||||
_mockDataService.Setup(s => s.getAllUtilisateurs())
|
||||
.ReturnsAsync(new List<Utilisateur>());
|
||||
|
||||
var requete = new RequeteConnexion
|
||||
{
|
||||
Pseudo = "nonExistentUser",
|
||||
MotDePasse = "wrongPassword"
|
||||
};
|
||||
|
||||
// Act & Assert
|
||||
await Assert.ThrowsAsync<Exception>(() => _authService.Connexion(requete));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Inscription_ShouldCreateNewUser()
|
||||
{
|
||||
// Arrange
|
||||
var requete = new RequeteInscription
|
||||
{
|
||||
Pseudo = "newUser",
|
||||
Nom = "New",
|
||||
Prenom = "User",
|
||||
Mail = "new@user.com",
|
||||
MotDePasse = "newPassword"
|
||||
};
|
||||
|
||||
// Setup the mock to verify that AjouterUtilisateur is called with a Utilisateur that matches the inscription details
|
||||
_mockDataService.Setup(s => s.AjouterUtilisateur(It.IsAny<Utilisateur>()))
|
||||
.Returns(Task.CompletedTask)
|
||||
.Callback<Utilisateur>(u =>
|
||||
{
|
||||
Assert.Equal(requete.Pseudo, u.Pseudo);
|
||||
Assert.True(BCrypt.Net.BCrypt.Verify(requete.MotDePasse, u.Mdp));
|
||||
});
|
||||
|
||||
// Act
|
||||
await _authService.Inscription(requete);
|
||||
|
||||
}
|
||||
[Fact]
|
||||
public async Task GetUtilisateur_ReturnsCorrectUser_WithClaims()
|
||||
{
|
||||
// Arrange
|
||||
var expectedPseudo = "testUser";
|
||||
var expectedRole = "User";
|
||||
var testUser = new Utilisateur("testUser", "Test", "User", "test@user.com", BCrypt.Net.BCrypt.HashPassword("password"), "User", false);
|
||||
var mockDataService = new Mock<IUtilisateursDataService>();
|
||||
mockDataService.Setup(s => s.getAllUtilisateurs())
|
||||
.ReturnsAsync(new List<Utilisateur> { testUser });
|
||||
|
||||
var authService = new AuthentificationService(mockDataService.Object);
|
||||
|
||||
// Act
|
||||
var utilisateurCourant = await authService.GetUtilisateur(expectedPseudo);
|
||||
utilisateurCourant.Claims.Add(ClaimTypes.Email, "test@user.com");
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(utilisateurCourant);
|
||||
Assert.True(utilisateurCourant.EstAuthentifie);
|
||||
Assert.Equal(expectedPseudo, utilisateurCourant.Pseudo);
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,85 +0,0 @@
|
||||
using Moq;
|
||||
using System.Collections.Generic;
|
||||
using System.Security.Claims;
|
||||
using System.Threading.Tasks;
|
||||
using VeraxShield.composants.formulaires.modeles;
|
||||
using VeraxShield.modele.utilisateurs;
|
||||
using VeraxShield.services.UtilisateursDataService;
|
||||
using Xunit;
|
||||
|
||||
namespace VeraxShield.UnitTests
|
||||
{
|
||||
public class DonneurEtatTests
|
||||
{
|
||||
private readonly DonneurEtat _donneurEtat;
|
||||
private readonly Mock<IAuthentificationService> _mockAuthService;
|
||||
private readonly Mock<IUtilisateursDataService> _mockUserDataService;
|
||||
|
||||
public DonneurEtatTests()
|
||||
{
|
||||
_mockAuthService = new Mock<IAuthentificationService>();
|
||||
_mockUserDataService = new Mock<IUtilisateursDataService>();
|
||||
_donneurEtat = new DonneurEtat(_mockAuthService.Object, _mockUserDataService.Object);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Connexion_ValidCredentials_SetsCurrentUser()
|
||||
{
|
||||
// Arrange
|
||||
var requeteConnexion = new RequeteConnexion { Pseudo = "testUser", MotDePasse = "testPass" };
|
||||
var utilisateurCourant = new UtilisateurCourant
|
||||
{
|
||||
Pseudo = "testUser",
|
||||
EstAuthentifie = true,
|
||||
Claims = new Dictionary<string, string> { { ClaimTypes.Role, "User" } }
|
||||
};
|
||||
|
||||
_mockAuthService.Setup(x => x.GetUtilisateur(requeteConnexion.Pseudo)).ReturnsAsync(utilisateurCourant);
|
||||
_mockAuthService.Setup(x => x.Connexion(requeteConnexion)).Returns(Task.CompletedTask);
|
||||
|
||||
// Act
|
||||
await _donneurEtat.Connexion(requeteConnexion);
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(_donneurEtat._utilisateurCourant);
|
||||
Assert.True(_donneurEtat._utilisateurCourant.EstAuthentifie);
|
||||
_mockAuthService.Verify(x => x.Connexion(requeteConnexion), Times.Once);
|
||||
_mockAuthService.Verify(x => x.GetUtilisateur(requeteConnexion.Pseudo), Times.Once);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Deconnexion_ClearsCurrentUser()
|
||||
{
|
||||
// Arrange - assume user is logged in
|
||||
_donneurEtat._utilisateurCourant = new UtilisateurCourant { EstAuthentifie = true };
|
||||
|
||||
// Act
|
||||
await _donneurEtat.Deconnexion();
|
||||
|
||||
// Assert
|
||||
Assert.Null(_donneurEtat._utilisateurCourant);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Inscription_ValidData_RegistersUser()
|
||||
{
|
||||
// Arrange
|
||||
var requeteInscription = new RequeteInscription
|
||||
{
|
||||
Pseudo = "newUser",
|
||||
MotDePasse = "newPass",
|
||||
Mail = "newUser@test.com",
|
||||
Nom = "New",
|
||||
Prenom = "User"
|
||||
};
|
||||
|
||||
_mockAuthService.Setup(x => x.Inscription(requeteInscription)).Returns(Task.CompletedTask);
|
||||
|
||||
// Act
|
||||
await _donneurEtat.Inscription(requeteInscription);
|
||||
|
||||
// Assert - Since Inscription does not automatically log in the user, we check if the method was called.
|
||||
_mockAuthService.Verify(x => x.Inscription(requeteInscription), Times.Once);
|
||||
}
|
||||
}
|
||||
}
|
@ -1 +0,0 @@
|
||||
global using Xunit;
|
@ -1,45 +0,0 @@
|
||||
using Moq;
|
||||
using VeraxShield.modele.utilisateurs;
|
||||
using VeraxShield.services.UtilisateursDataService;
|
||||
|
||||
namespace TestVeraxShield;
|
||||
|
||||
public class IAuthentificationServiceTests
|
||||
{
|
||||
private readonly Mock<IUtilisateursDataService> _mockDataService;
|
||||
private readonly AuthentificationService _authService;
|
||||
|
||||
public IAuthentificationServiceTests()
|
||||
{
|
||||
_mockDataService = new Mock<IUtilisateursDataService>();
|
||||
_authService = new AuthentificationService(_mockDataService.Object);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task GetUtilisateur_ValidUser_ReturnsUser()
|
||||
{
|
||||
// Arrange
|
||||
var expectedUser = new UtilisateurCourant { Pseudo = "user1", EstAuthentifie = true };
|
||||
_mockDataService.Setup(x => x.getAllUtilisateurs()).ReturnsAsync(new List<Utilisateur>
|
||||
{
|
||||
new Utilisateur("user1", "Name", "Surname", "user1@example.com", "password", "User", false)
|
||||
});
|
||||
|
||||
// Act
|
||||
var result = await _authService.GetUtilisateur("user1");
|
||||
|
||||
// Assert
|
||||
Assert.Equal(expectedUser.Pseudo, result.Pseudo);
|
||||
Assert.True(result.EstAuthentifie);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task GetUtilisateur_NonExistentUser_ThrowsException()
|
||||
{
|
||||
// Arrange
|
||||
_mockDataService.Setup(x => x.getAllUtilisateurs()).ReturnsAsync(new List<Utilisateur>());
|
||||
|
||||
// Act & Assert
|
||||
await Assert.ThrowsAsync<Exception>(() => _authService.GetUtilisateur("user2"));
|
||||
}
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
using Moq;
|
||||
using VeraxShield.modele.utilisateurs;
|
||||
using VeraxShield.services.UtilisateursDataService;
|
||||
|
||||
namespace TestVeraxShield;
|
||||
|
||||
public class IUtilisateursDataServiceTests
|
||||
{
|
||||
private readonly Mock<IUtilisateursDataService> _service = new Mock<IUtilisateursDataService>();
|
||||
|
||||
[Fact]
|
||||
public async Task AjouterUtilisateur_AddsUserSuccessfully()
|
||||
{
|
||||
// Arrange
|
||||
var user = new Utilisateur("testUser", "User", "Test", "dez", "password", "User", false);
|
||||
_service.Setup(s => s.AjouterUtilisateur(It.IsAny<Utilisateur>()))
|
||||
.Returns(Task.CompletedTask)
|
||||
.Callback<Utilisateur>(u => Assert.Equal("testUser", u.Pseudo));
|
||||
|
||||
// Act
|
||||
await _service.Object.AjouterUtilisateur(user);
|
||||
|
||||
// Assert is handled by the Callback
|
||||
}
|
||||
}
|
@ -1,47 +0,0 @@
|
||||
namespace TestVeraxShield;
|
||||
|
||||
public class ModeleAppUtilisateurTests
|
||||
{
|
||||
|
||||
[Fact]
|
||||
public void Constructeur_DoitInitialiserProprietes()
|
||||
{
|
||||
// Arrange & Act
|
||||
var utilisateur = new ModeleAppUtilisateur("pseudoTest", "NomTest", "PrenomTest", "email@test.com", "motdepasse", "RoleTest");
|
||||
|
||||
// Assert
|
||||
Assert.Equal("pseudoTest", utilisateur.Pseudo);
|
||||
Assert.Equal("NomTest", utilisateur.Nom);
|
||||
Assert.Equal("PrenomTest", utilisateur.Prenom);
|
||||
Assert.Equal("email@test.com", utilisateur.Mail);
|
||||
Assert.Equal("motdepasse", utilisateur.MotDePasse);
|
||||
Assert.Contains("RoleTest", utilisateur.Roles);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AjouterRole_DoItAjouterNouveauRole()
|
||||
{
|
||||
// Arrange
|
||||
var utilisateur = new ModeleAppUtilisateur("pseudoTest", "NomTest", "PrenomTest", "email@test.com", "motdepasse", "RoleTest");
|
||||
|
||||
// Act
|
||||
utilisateur.ajouterRole("NouveauRole");
|
||||
|
||||
// Assert
|
||||
Assert.Contains("NouveauRole", utilisateur.Roles);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SupprimerRole_DoItSupprimerRoleExistant()
|
||||
{
|
||||
// Arrange
|
||||
var utilisateur = new ModeleAppUtilisateur("pseudoTest", "NomTest", "PrenomTest", "email@test.com", "motdepasse", "RoleTest");
|
||||
utilisateur.ajouterRole("NouveauRole");
|
||||
|
||||
// Act
|
||||
utilisateur.supprimerRole("RoleTest");
|
||||
|
||||
// Assert
|
||||
Assert.DoesNotContain("RoleTest", utilisateur.Roles);
|
||||
}
|
||||
}
|
@ -1,57 +0,0 @@
|
||||
namespace TestVeraxShield;
|
||||
|
||||
public class ModeleCurrentUserTests
|
||||
{
|
||||
[Fact]
|
||||
public void InitializesCorrectly()
|
||||
{
|
||||
var utilisateur = new UtilisateurCourant();
|
||||
|
||||
Assert.Null(utilisateur.Claims);
|
||||
Assert.False(utilisateur.EstAuthentifie);
|
||||
Assert.Null(utilisateur.Pseudo);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AddsAndUpdatesClaimsCorrectly()
|
||||
{
|
||||
var utilisateur = new UtilisateurCourant { Claims = new Dictionary<string, string>() };
|
||||
utilisateur.Claims.Add("role", "user");
|
||||
|
||||
Assert.Equal("user", utilisateur.Claims["role"]);
|
||||
|
||||
utilisateur.Claims["role"] = "admin";
|
||||
Assert.Equal("admin", utilisateur.Claims["role"]);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RemovesClaimsCorrectly()
|
||||
{
|
||||
var utilisateur = new UtilisateurCourant { Claims = new Dictionary<string, string>() };
|
||||
utilisateur.Claims.Add("role", "user");
|
||||
utilisateur.Claims.Remove("role");
|
||||
|
||||
Assert.False(utilisateur.Claims.ContainsKey("role"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TogglesAuthenticationState()
|
||||
{
|
||||
var utilisateur = new UtilisateurCourant();
|
||||
utilisateur.EstAuthentifie = true;
|
||||
|
||||
Assert.True(utilisateur.EstAuthentifie);
|
||||
|
||||
utilisateur.EstAuthentifie = false;
|
||||
Assert.False(utilisateur.EstAuthentifie);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void UpdatesPseudoCorrectly()
|
||||
{
|
||||
var utilisateur = new UtilisateurCourant();
|
||||
utilisateur.Pseudo = "TestUser";
|
||||
|
||||
Assert.Equal("TestUser", utilisateur.Pseudo);
|
||||
}
|
||||
}
|
@ -1,66 +0,0 @@
|
||||
using VeraxShield.modele.utilisateurs;
|
||||
|
||||
namespace TestVeraxShield;
|
||||
|
||||
public class ModeleUtilisateurTests
|
||||
{
|
||||
[Fact]
|
||||
public void ConstructorAssignsPropertiesCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
string expectedPseudo = "TestPseudo";
|
||||
string expectedNom = "TestNom";
|
||||
string expectedPrenom = "TestPrenom";
|
||||
string expectedRole = "TestRole";
|
||||
string expectedMdp = "TestMdp";
|
||||
string expectedMail = "test@mail.com";
|
||||
bool expectedIsBan = true;
|
||||
|
||||
// Act
|
||||
Utilisateur utilisateur = new Utilisateur(expectedPseudo, expectedNom, expectedPrenom, expectedRole, expectedMdp, expectedMail, expectedIsBan);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(expectedPseudo, utilisateur.Pseudo);
|
||||
Assert.Equal(expectedNom, utilisateur.Nom);
|
||||
Assert.Equal(expectedPrenom, utilisateur.Prenom);
|
||||
Assert.Equal(expectedRole, utilisateur.Role);
|
||||
Assert.Equal(expectedMdp, utilisateur.Mdp);
|
||||
Assert.Equal(expectedMail, utilisateur.Mail);
|
||||
Assert.Equal(expectedIsBan, utilisateur.IsBan);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("NewPseudo", "NewNom", "NewPrenom", "NewRole", "NewMdp", "new@mail.com", false)]
|
||||
[InlineData("AnotherPseudo", "AnotherNom", "AnotherPrenom", "AnotherRole", "AnotherMdp", "another@mail.com", true)]
|
||||
public void PropertiesUpdateCorrectly(string pseudo, string nom, string prenom, string role, string mdp, string mail, bool isBan)
|
||||
{
|
||||
// Arrange
|
||||
Utilisateur utilisateur = new Utilisateur(pseudo, nom, prenom, role, mdp, mail, isBan);
|
||||
|
||||
// Act - changing values to test setter
|
||||
string updatedPseudo = pseudo + "Update";
|
||||
string updatedNom = nom + "Update";
|
||||
string updatedPrenom = prenom + "Update";
|
||||
string updatedRole = role + "Update";
|
||||
string updatedMdp = mdp + "Update";
|
||||
string updatedMail = "updated@" + mail;
|
||||
bool updatedIsBan = !isBan;
|
||||
|
||||
utilisateur.Pseudo = updatedPseudo;
|
||||
utilisateur.Nom = updatedNom;
|
||||
utilisateur.Prenom = updatedPrenom;
|
||||
utilisateur.Role = updatedRole;
|
||||
utilisateur.Mdp = updatedMdp;
|
||||
utilisateur.Mail = updatedMail;
|
||||
utilisateur.IsBan = updatedIsBan;
|
||||
|
||||
// Assert
|
||||
Assert.Equal(updatedPseudo, utilisateur.Pseudo);
|
||||
Assert.Equal(updatedNom, utilisateur.Nom);
|
||||
Assert.Equal(updatedPrenom, utilisateur.Prenom);
|
||||
Assert.Equal(updatedRole, utilisateur.Role);
|
||||
Assert.Equal(updatedMdp, utilisateur.Mdp);
|
||||
Assert.Equal(updatedMail, utilisateur.Mail);
|
||||
Assert.Equal(updatedIsBan, utilisateur.IsBan);
|
||||
}
|
||||
}
|
@ -1,47 +0,0 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
|
||||
<IsPackable>false</IsPackable>
|
||||
<IsTestProject>true</IsTestProject>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="bunit.web" Version="1.27.17" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.0"/>
|
||||
<PackageReference Include="Moq" Version="4.20.70" />
|
||||
<PackageReference Include="RichardSzalay.MockHttp" Version="7.0.0" />
|
||||
<PackageReference Include="xunit" Version="2.4.2"/>
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="coverlet.collector" Version="6.0.0">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\VeraxShield\VeraxShield.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="factoriesTests\**" />
|
||||
<Compile Remove="ModeleTests\**" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Remove="factoriesTests\**" />
|
||||
<EmbeddedResource Remove="ModeleTests\**" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Remove="factoriesTests\**" />
|
||||
<None Remove="ModeleTests\**" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
@ -1,56 +0,0 @@
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Moq;
|
||||
using Newtonsoft.Json;
|
||||
using RichardSzalay.MockHttp;
|
||||
using VeraxShield.modele.utilisateurs;
|
||||
using VeraxShield.services.UtilisateursDataService;
|
||||
|
||||
namespace TestVeraxShield;
|
||||
|
||||
public class UtilisateursDataServiceApiTests
|
||||
{
|
||||
private readonly MockHttpMessageHandler _mockHttp;
|
||||
private readonly HttpClient _clientHttp;
|
||||
private readonly Mock<NavigationManager> _mockNavigationManager;
|
||||
private readonly UtilisateursDataServiceApi _service;
|
||||
|
||||
public UtilisateursDataServiceApiTests()
|
||||
{
|
||||
_mockHttp = new MockHttpMessageHandler();
|
||||
|
||||
// Mock the response for the API call
|
||||
_mockHttp.When("https://Verax.com/api/utilisateurs/recuperer")
|
||||
.Respond("application/json", JsonConvert.SerializeObject(new List<Utilisateur>
|
||||
{
|
||||
new Utilisateur("testUser", "User", "Test", "dez", "password", "User", false)
|
||||
}));
|
||||
|
||||
_clientHttp = _mockHttp.ToHttpClient();
|
||||
_clientHttp.BaseAddress = new System.Uri("https://Verax.com");
|
||||
|
||||
_mockNavigationManager = new Mock<NavigationManager>();
|
||||
_service = new UtilisateursDataServiceApi(_clientHttp, _mockNavigationManager.Object);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task GetAllUtilisateurs_ReturnsUsers()
|
||||
{
|
||||
// Act
|
||||
var users = await _service.getAllUtilisateurs();
|
||||
|
||||
// Assert
|
||||
Assert.Single(users);
|
||||
Assert.Equal("testUser", users[0].Pseudo);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task GetUtilisateurFromPseudo_ReturnsUser()
|
||||
{
|
||||
// Act
|
||||
var user = await _service.getUtilisateurFromPseudo("testUser");
|
||||
|
||||
// Assert
|
||||
Assert.Equal("testUser", user.Pseudo);
|
||||
}
|
||||
|
||||
}
|
@ -1,56 +0,0 @@
|
||||
namespace TestVeraxShield.factoriesTests;
|
||||
|
||||
using Xunit;
|
||||
using VeraxShield.factories;
|
||||
using VeraxShield.composants.formulaires.modeles;
|
||||
using VeraxShield.modele.utilisateurs;
|
||||
|
||||
public class UtilisateursFactoryTests
|
||||
{
|
||||
[Fact]
|
||||
public void ConvertsToUtilisateur_WithNewPasswordHashing()
|
||||
{
|
||||
// Arrange
|
||||
var modele = new FormulaireAjoutModele { Mdp = "newPassword", /* other properties */ };
|
||||
|
||||
// Act
|
||||
var utilisateur = UtilisateursFactory.toUtilisateur(modele);
|
||||
|
||||
// Assert
|
||||
Assert.NotEqual("newPassword", utilisateur.Mdp);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ConvertsToModele_FromUtilisateur()
|
||||
{
|
||||
// Arrange
|
||||
var utilisateur = new Utilisateur("pseudo", "nom", "prenom", "role", "mdp", "mail", false);
|
||||
|
||||
// Act
|
||||
var modele = UtilisateursFactory.toModele(utilisateur);
|
||||
|
||||
// Assert
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
[Fact]
|
||||
public void ConvertsToModele_FromUtilisateurs()
|
||||
{
|
||||
// Arrange
|
||||
var utilisateur = new Utilisateur("pseudo", "nom", "prenom", "role", "mdp", "mail", false);
|
||||
|
||||
// Act
|
||||
var modele = UtilisateursFactory.toModele(utilisateur);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(utilisateur.Pseudo, modele.Pseudo);
|
||||
Assert.Equal(utilisateur.Nom, modele.Nom);
|
||||
Assert.Equal(utilisateur.Prenom, modele.Prenom);
|
||||
Assert.Equal(utilisateur.Role, modele.Role);
|
||||
Assert.Equal(utilisateur.Mail, modele.Mail);
|
||||
Assert.Equal(utilisateur.IsBan, modele.IsBan);
|
||||
}
|
||||
|
||||
}
|
@ -1,33 +0,0 @@
|
||||
@inherits LayoutComponentBase
|
||||
|
||||
<head>
|
||||
<link rel="stylesheet" href="css/composants/navBar/NavBarPrincipale.css" />
|
||||
</head>
|
||||
|
||||
<Bar Breakpoint="Breakpoint.Desktop" class="bar-container">
|
||||
<BarBrand>
|
||||
<img class="logo" src="/ressources/images/logo/logo.png" Text="Logo de Verax" Fluid @onclick="@NavAccueil"/>
|
||||
</BarBrand>
|
||||
<BarToggler />
|
||||
<BarMenu class="bar-menu">
|
||||
<BarItem>
|
||||
<BarLink class="bar-link" @onclick="@NavUtilisateurs">Utilisateurs</BarLink>
|
||||
</BarItem>
|
||||
<BarItem>
|
||||
<BarLink class="bar-link" @onclick="@NavArticles">Articles</BarLink>
|
||||
</BarItem>
|
||||
<BarItem>
|
||||
<BarLink class="bar-link" @onclick="@NavModerateurs">Modérateurs</BarLink>
|
||||
</BarItem>
|
||||
</BarMenu>
|
||||
<BarEnd>
|
||||
<BarItem class="bar-role">
|
||||
@DonneurEtat.getUtilisateurCourant().Pseudo
|
||||
</BarItem>
|
||||
<BarItem>
|
||||
<Button Color="Color.Primary" @onclick="@Deconnecter">Deconnexion</Button>
|
||||
</BarItem>
|
||||
</BarEnd>
|
||||
</Bar>
|
||||
|
||||
@Body
|
@ -1,119 +1,58 @@
|
||||
<head>
|
||||
<link rel="stylesheet" href="css/composants/formulaires/FormulaireModification.css">
|
||||
</head>
|
||||
|
||||
<div class="formulaire-conteneur">
|
||||
|
||||
<h1 class="title-spacing"> Modifier l'utilisateur</h1>
|
||||
|
||||
<Validations @ref="Validations" Mode="ValidationMode.Manual" Model="Modele">
|
||||
|
||||
<div class="field-container">
|
||||
<Validation>
|
||||
<Field Horizontal>
|
||||
<FieldLabel ColumnSize="ColumnSize.Is2">Pseudo</FieldLabel>
|
||||
<FieldBody ColumnSize="ColumnSize.Is10">
|
||||
<TextEdit Placeholder="Entrez votre pseudo" @bind-Text="@Modele.Pseudo">
|
||||
<Feedback>
|
||||
<ValidationError />
|
||||
</Feedback>
|
||||
</TextEdit>
|
||||
</FieldBody>
|
||||
</Field>
|
||||
</Validation>
|
||||
</div>
|
||||
|
||||
<div class="field-container">
|
||||
<Validation>
|
||||
<Field Horizontal>
|
||||
<FieldLabel ColumnSize="ColumnSize.Is2">Prenom</FieldLabel>
|
||||
<FieldBody ColumnSize="ColumnSize.Is10">
|
||||
<TextEdit Placeholder="Entrez votre prenom" @bind-Text="@Modele.Prenom">
|
||||
<Feedback>
|
||||
<ValidationError />
|
||||
</Feedback>
|
||||
</TextEdit>
|
||||
</FieldBody>
|
||||
</Field>
|
||||
</Validation>
|
||||
</div>
|
||||
|
||||
<div class="field-container">
|
||||
<Validation>
|
||||
<Field Horizontal>
|
||||
<FieldLabel ColumnSize="ColumnSize.Is2">Nom</FieldLabel>
|
||||
<FieldBody ColumnSize="ColumnSize.Is10">
|
||||
<TextEdit Placeholder="Entrez votre nom" @bind-Text="@Modele.Nom">
|
||||
<Feedback>
|
||||
<ValidationError />
|
||||
</Feedback>
|
||||
</TextEdit>
|
||||
</FieldBody>
|
||||
</Field>
|
||||
</Validation>
|
||||
</div>
|
||||
|
||||
<div class="field-container">
|
||||
<Validation>
|
||||
<Field Horizontal>
|
||||
<FieldLabel ColumnSize="ColumnSize.Is2">Mail</FieldLabel>
|
||||
<FieldBody ColumnSize="ColumnSize.Is10">
|
||||
<TextEdit Placeholder="Entrez votre mail" @bind-Text="@Modele.Mail">
|
||||
<Feedback>
|
||||
<ValidationError />
|
||||
</Feedback>
|
||||
</TextEdit>
|
||||
</FieldBody>
|
||||
</Field>
|
||||
</Validation>
|
||||
</div>
|
||||
|
||||
<div class="field-container">
|
||||
<Validation>
|
||||
<Field Horizontal>
|
||||
<FieldLabel ColumnSize="ColumnSize.Is2">Role</FieldLabel>
|
||||
<FieldBody ColumnSize="ColumnSize.Is10">
|
||||
<TextEdit Placeholder="Entrez le role" @bind-Text="@Modele.Role">
|
||||
<Feedback>
|
||||
<ValidationError />
|
||||
</Feedback>
|
||||
</TextEdit>
|
||||
</FieldBody>
|
||||
</Field>
|
||||
</Validation>
|
||||
</div>
|
||||
|
||||
<div class="field-container">
|
||||
<Validation>
|
||||
<Field Horizontal>
|
||||
<FieldLabel ColumnSize="ColumnSize.Is2">Modifier Mot de passe</FieldLabel>
|
||||
<FieldBody ColumnSize="ColumnSize.Is10">
|
||||
<TextEdit Placeholder="Nouveau mot de passe (facultatif)" @bind-Text="@Modele.Mdp">
|
||||
<Feedback>
|
||||
<ValidationError />
|
||||
</Feedback>
|
||||
</TextEdit>
|
||||
</FieldBody>
|
||||
</Field>
|
||||
</Validation>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<Validation>
|
||||
<Switch TValue="bool" @bind-Checked="@Modele.IsBan" Color="Color.Primary">Utilisateur banni</Switch>
|
||||
</Validation>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="btn-container">
|
||||
<Button Class="btn-se-connecter" Clicked="@modifierUtilisateur">
|
||||
<Icon Name="Blazorise.Icons.FontAwesome.FontAwesomeIcons.CheckCircle" />
|
||||
Modifier</Button>
|
||||
<Button Class="btn-s-inscrire" Clicked="@OnAnnulation">
|
||||
<Icon Name="Blazorise.Icons.FontAwesome.FontAwesomeIcons.Reply" />
|
||||
Annuler</Button>
|
||||
</div>
|
||||
|
||||
</Validations>
|
||||
</div>
|
||||
<EditForm Model="@Modele" OnValidSubmit="@modifierUtilisateur">
|
||||
|
||||
<DataAnnotationsValidator />
|
||||
<Microsoft.AspNetCore.Components.Forms.ValidationSummary />
|
||||
|
||||
<p>
|
||||
<label for="pseudo">
|
||||
Pseudo :
|
||||
<InputText id="pseudo" @bind-Value="Modele.Pseudo" />
|
||||
</label>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<label for="prenom">
|
||||
Prénom :
|
||||
<InputText id="prenom" @bind-Value="Modele.Prenom" />
|
||||
</label>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<label for="nom">
|
||||
Nom :
|
||||
<InputText id="nom" @bind-Value="Modele.Nom" />
|
||||
</label>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<label for="role">
|
||||
Role :
|
||||
<InputText id="role" @bind-Value="Modele.Role" />
|
||||
</label>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<label for="mail">
|
||||
Email :
|
||||
<InputText id="mail" @bind-Value="Modele.Mail" />
|
||||
</label>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<label for="mdp">
|
||||
Mot de passe :
|
||||
<InputText id="mdp" @bind-Value="Modele.Mdp" />
|
||||
</label>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<label>
|
||||
Utilisateur banni :
|
||||
<InputCheckbox @bind-Value="Modele.IsBan" />
|
||||
</label>
|
||||
</p>
|
||||
|
||||
<button Type="Submit">Valider la modification </button>
|
||||
|
||||
</EditForm>
|
@ -1,37 +0,0 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using VeraxShield.composants.affichages.utilisateurs;
|
||||
using VeraxShield.modele.utilisateurs;
|
||||
using VeraxShield.services.UtilisateursDataService;
|
||||
|
||||
namespace VeraxShield.composants.formulaires.modeles.attributsValidationCustoms
|
||||
{
|
||||
public class PseudoCorrectAttribute : ValidationAttribute
|
||||
{
|
||||
protected override ValidationResult? IsValid(object? value, ValidationContext validationContext)
|
||||
{
|
||||
bool pseudoExisteDeja = false;
|
||||
var pseudo = (string)value;
|
||||
|
||||
foreach (Utilisateur u in DatagridUtilisateurs.Utilisateurs)
|
||||
{
|
||||
if ((u.Pseudo == pseudo))
|
||||
{
|
||||
if (DatagridUtilisateurs.UtilisateurSelectionne == null) {
|
||||
return new ValidationResult("Le pseudo existe deja, choississez en un autre.");
|
||||
}
|
||||
|
||||
if (DatagridUtilisateurs.UtilisateurSelectionne != null)
|
||||
{
|
||||
if (u.Pseudo != DatagridUtilisateurs.UtilisateurSelectionne.Pseudo)
|
||||
{
|
||||
return new ValidationResult("Le pseudo existe deja, choississez en un autre.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ValidationResult.Success;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,33 +0,0 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace VeraxShield.composants.formulaires.modeles.attributsValidationCustoms
|
||||
{
|
||||
public class RoleExistantAttribute : ValidationAttribute
|
||||
{
|
||||
private List<string> RolesExistants {get; set;}
|
||||
|
||||
public RoleExistantAttribute()
|
||||
{
|
||||
this.RolesExistants = new List<string>();
|
||||
this.RolesExistants.Add("admin");
|
||||
this.RolesExistants.Add("modo");
|
||||
this.RolesExistants.Add("invite");
|
||||
this.RolesExistants.Add("redacteur");
|
||||
}
|
||||
|
||||
protected override ValidationResult? IsValid(object? value, ValidationContext validationContext)
|
||||
{
|
||||
var role = (string)value;
|
||||
|
||||
foreach (string roleListe in this.RolesExistants)
|
||||
{
|
||||
if (roleListe == role)
|
||||
{
|
||||
return ValidationResult.Success;;
|
||||
}
|
||||
}
|
||||
|
||||
return new ValidationResult("Le role n'existe pas.");
|
||||
}
|
||||
}
|
||||
}
|
@ -1,32 +1,32 @@
|
||||
public class ModeleAppUtilisateur
|
||||
{
|
||||
public string MotDePasse { get; set; }
|
||||
public List<string> Roles { get; set; }
|
||||
public string Pseudo { get; set; }
|
||||
public string Prenom { get; set; }
|
||||
public string Nom { get; set; }
|
||||
public string Mail { get; set; }
|
||||
|
||||
|
||||
public ModeleAppUtilisateur(string pseudo,string nom, string prenom, string mail, string mdp, String premierRole)
|
||||
{
|
||||
this.MotDePasse = mdp;
|
||||
this.Pseudo = pseudo;
|
||||
this.Mail = mail;
|
||||
this.Prenom = prenom;
|
||||
this.Nom = nom;
|
||||
|
||||
this.Roles = new List<string>();
|
||||
this.Roles.Add(premierRole);
|
||||
}
|
||||
|
||||
public void ajouterRole(string nouveauRole)
|
||||
{
|
||||
this.Roles.Add(nouveauRole);
|
||||
}
|
||||
|
||||
public void supprimerRole(string ancienRole)
|
||||
{
|
||||
this.Roles.Remove(ancienRole);
|
||||
}
|
||||
public class AppUtilisateur
|
||||
{
|
||||
public string MotDePasse { get; set; }
|
||||
public List<string> Roles { get; set; }
|
||||
public string Pseudo { get; set; }
|
||||
public string Prenom { get; set; }
|
||||
public string Nom { get; set; }
|
||||
public string Mail { get; set; }
|
||||
|
||||
|
||||
public AppUtilisateur(string pseudo,string nom, string prenom, string mail, string mdp, String premierRole)
|
||||
{
|
||||
this.MotDePasse = mdp;
|
||||
this.Pseudo = pseudo;
|
||||
this.Mail = mail;
|
||||
this.Prenom = prenom;
|
||||
this.Nom = nom;
|
||||
|
||||
this.Roles = new List<string>();
|
||||
this.Roles.Add(premierRole);
|
||||
}
|
||||
|
||||
public void ajouterRole(string nouveauRole)
|
||||
{
|
||||
this.Roles.Add(nouveauRole);
|
||||
}
|
||||
|
||||
public void supprimerRole(string ancienRole)
|
||||
{
|
||||
this.Roles.Remove(ancienRole);
|
||||
}
|
||||
}
|
@ -1,12 +1,18 @@
|
||||
@page "/utilisateurs/modifier/{pseudo}"
|
||||
|
||||
<h1> Modifier l'utilisateur </h1>
|
||||
|
||||
<head>
|
||||
<link rel="stylesheet" href="css/pages/utilisateurs/ModifierUtilisateur.css">
|
||||
</head>
|
||||
|
||||
<div class="container">
|
||||
<div class="formulaire-modification">
|
||||
<FormulaireModification Utilisateur="@Utilisateur"/>
|
||||
</div>
|
||||
|
||||
<FormulaireModification Utilisateur="@Utilisateur" />
|
||||
|
||||
<div class="test">
|
||||
<VeraxShield.composants.authentification.FormulaireInscription>
|
||||
|
||||
</VeraxShield.composants.authentification.FormulaireInscription>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
@ -1,3 +0,0 @@
|
||||
@using VeraxShield.composants.affichages.navBar;
|
||||
|
||||
@layout NavBarPrincipale
|
@ -1,102 +0,0 @@
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using VeraxShield.modele.utilisateurs;
|
||||
|
||||
namespace VeraxShield.services.UtilisateursDataService
|
||||
{
|
||||
public class UtilisateursDataServiceApi : IUtilisateursDataService
|
||||
{
|
||||
[Inject]
|
||||
private HttpClient _clientHttp { get; set; }
|
||||
|
||||
[Inject]
|
||||
public NavigationManager _navigationManager { get; set; }
|
||||
|
||||
private string EmplacementModification {get; set;}
|
||||
private string EmplacementRecuperation {get; set;}
|
||||
|
||||
public UtilisateursDataServiceApi(HttpClient clientHttp, NavigationManager navigationManager)
|
||||
{
|
||||
this._clientHttp = clientHttp;
|
||||
this._navigationManager = navigationManager;
|
||||
|
||||
// Le site PHP n'étant pas encore mis en ligne. Ces urls n'existent pas encore à l'heure actuelle...
|
||||
this.EmplacementModification = "https://Verax.com/api/utilisateurs/modifier";
|
||||
this.EmplacementRecuperation = "https://Verax.com/api/utilisateurs/recuperer";
|
||||
}
|
||||
|
||||
|
||||
public async Task AjouterUtilisateur(Utilisateur u)
|
||||
{
|
||||
List<Utilisateur> data = await this.getAllUtilisateurs();
|
||||
data.Add(u);
|
||||
await this.SaveAllUtilisateurs(data);
|
||||
}
|
||||
|
||||
public async Task<List<Utilisateur>> getAllUtilisateurs()
|
||||
{
|
||||
List<Utilisateur> lUtilisateurs = new List<Utilisateur>();
|
||||
var data = await this._clientHttp.GetFromJsonAsync<Utilisateur[]>(this.EmplacementRecuperation);
|
||||
|
||||
if (data != null)
|
||||
{
|
||||
lUtilisateurs = data.ToList();
|
||||
}
|
||||
|
||||
return lUtilisateurs;
|
||||
}
|
||||
|
||||
public async Task<Utilisateur> getUtilisateurFromPseudo(string pseudo)
|
||||
{
|
||||
List<Utilisateur> utilisateurs = await this.getAllUtilisateurs();
|
||||
Utilisateur utilisateurTemporaire = null;
|
||||
|
||||
foreach (Utilisateur u in utilisateurs)
|
||||
{
|
||||
if (u.Pseudo == pseudo)
|
||||
{
|
||||
utilisateurTemporaire = u;
|
||||
}
|
||||
}
|
||||
|
||||
return utilisateurTemporaire;
|
||||
}
|
||||
|
||||
public async Task MettreAJourUtilisateur(Utilisateur u)
|
||||
{
|
||||
await this.SupprimerUtilisateur(u);
|
||||
await this.AjouterUtilisateur(u);
|
||||
}
|
||||
|
||||
public async Task MettreAJourUtilisateur(Utilisateur ancienneVersion, Utilisateur nouvelleVersion)
|
||||
{
|
||||
await this.SupprimerUtilisateur(ancienneVersion);
|
||||
await this.AjouterUtilisateur(nouvelleVersion);
|
||||
}
|
||||
|
||||
public async Task SaveAllUtilisateurs(List<Utilisateur> list)
|
||||
{
|
||||
await this._clientHttp.PutAsJsonAsync(this.EmplacementModification, list);
|
||||
}
|
||||
|
||||
public async Task SupprimerUtilisateur(Utilisateur u)
|
||||
{
|
||||
List<Utilisateur> data = await this.getAllUtilisateurs();
|
||||
int index = -1;
|
||||
|
||||
foreach(Utilisateur temp in data)
|
||||
{
|
||||
if (temp.Pseudo == u.Pseudo)
|
||||
{
|
||||
index = data.IndexOf(temp);
|
||||
}
|
||||
}
|
||||
|
||||
if (index != -1)
|
||||
{
|
||||
data.RemoveAt(index);
|
||||
}
|
||||
|
||||
await this.SaveAllUtilisateurs(data);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
@inherits LayoutComponentBase
|
||||
|
||||
<div class="main">
|
||||
<div class="content px-4">
|
||||
@Body
|
||||
</div>
|
||||
</div>
|
@ -1,51 +0,0 @@
|
||||
|
||||
.formulaire-conteneur {
|
||||
|
||||
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); /* Ajoute une ombre au formulaire */
|
||||
border-radius: 10px; /* Ajoute des bords arrondis au formulaire */
|
||||
|
||||
/* background-color: black; */
|
||||
background-color: #8BC6EC;
|
||||
background-image: linear-gradient(135deg, #8BC6EC 0%, #9599E2 100%);
|
||||
|
||||
color: white; /* Définit la couleur du texte à blanc */
|
||||
padding: 20px; /* Ajoute une marge intérieure pour plus de lisibilité */
|
||||
}
|
||||
|
||||
.title-spacing {
|
||||
margin-bottom: 20px; /* Ajoute une séparation entre le titre et le reste du contenu */
|
||||
}
|
||||
|
||||
.field-container {
|
||||
margin-bottom: 15px; /* Ajoute une séparation entre chaque champ */
|
||||
}
|
||||
|
||||
/* Rend les labels en gras et blancs */
|
||||
.field-label {
|
||||
font-weight: bold;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.btn-container {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
margin-top: 20px; /* Ajoute une séparation entre les champs et les boutons */
|
||||
}
|
||||
|
||||
.btn-se-connecter {
|
||||
/* background-color: darkblue; */
|
||||
|
||||
/*background: #F3904F; fallback for old browsers */
|
||||
/*background: -webkit-linear-gradient(to right, #3B4371, #F3904F); Chrome 10-25, Safari 5.1-6 */
|
||||
/*background: linear-gradient(to right, #3B4371, #F3904F); W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */
|
||||
|
||||
background: white;
|
||||
color: black;
|
||||
margin-right: 10px; /* Ajoute un espace entre les deux boutons */
|
||||
}
|
||||
|
||||
.btn-s-inscrire {
|
||||
background-color: white;
|
||||
/* color: white; */
|
||||
color: black;
|
||||
}
|
@ -1,52 +0,0 @@
|
||||
/* Ajoutez ces styles à votre fichier CSS associé au composant (FormulaireModification.css) */
|
||||
|
||||
.formulaire-conteneur {
|
||||
|
||||
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); /* Ajoute une ombre au formulaire */
|
||||
border-radius: 10px; /* Ajoute des bords arrondis au formulaire */
|
||||
|
||||
/* background-color: black; */
|
||||
background-color: #8BC6EC;
|
||||
background-image: linear-gradient(135deg, #8BC6EC 0%, #9599E2 100%);
|
||||
|
||||
color: white; /* Définit la couleur du texte à blanc */
|
||||
padding: 20px; /* Ajoute une marge intérieure pour plus de lisibilité */
|
||||
}
|
||||
|
||||
.title-spacing {
|
||||
margin-bottom: 20px; /* Ajoute une séparation entre le titre et le reste du contenu */
|
||||
}
|
||||
|
||||
.field-container {
|
||||
margin-bottom: 15px; /* Ajoute une séparation entre chaque champ */
|
||||
}
|
||||
|
||||
/* Rend les labels en gras et blancs */
|
||||
.field-label {
|
||||
font-weight: bold;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.btn-container {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
margin-top: 20px; /* Ajoute une séparation entre les champs et les boutons */
|
||||
}
|
||||
|
||||
.btn-se-connecter {
|
||||
/* background-color: darkblue; */
|
||||
|
||||
/*background: #F3904F; fallback for old browsers */
|
||||
/*background: -webkit-linear-gradient(to right, #3B4371, #F3904F); Chrome 10-25, Safari 5.1-6 */
|
||||
/*background: linear-gradient(to right, #3B4371, #F3904F); W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */
|
||||
|
||||
background: white;
|
||||
color: black;
|
||||
margin-right: 10px; /* Ajoute un espace entre les deux boutons */
|
||||
}
|
||||
|
||||
.btn-s-inscrire {
|
||||
background-color: white;
|
||||
/* color: white; */
|
||||
color: black;
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
.container {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
height: 100vh; /* 100% de la hauteur de la vue */
|
||||
}
|
||||
|
||||
.formulaire-modification {
|
||||
width: 50%;
|
||||
/* background-color: green;
|
||||
padding: 20px; */
|
||||
/*box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); Ajoute une ombre au formulaire */
|
||||
/* border-radius: 10px; Ajoute des bords arrondis au formulaire */
|
||||
}
|
@ -1,14 +1,9 @@
|
||||
.container {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
height: 100vh; /* 100% de la hauteur de la vue */
|
||||
}
|
||||
.test {
|
||||
/* background-color: white; */
|
||||
background-color: #8EC5FC;
|
||||
background-image: linear-gradient(62deg, #8EC5FC 0%, #E0C3FC 100%);
|
||||
|
||||
.formulaire-modification {
|
||||
width: 50%;
|
||||
/* background-color: green;
|
||||
padding: 20px; */
|
||||
/*box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); Ajoute une ombre au formulaire */
|
||||
/* border-radius: 10px; Ajoute des bords arrondis au formulaire */
|
||||
padding: 20px;
|
||||
border-radius: 10px;
|
||||
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); /* Ajoute une ombre légère */
|
||||
}
|
Before Width: | Height: | Size: 98 KiB |
@ -1,34 +0,0 @@
|
||||
# Première étape : Créer l'image de base
|
||||
FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base
|
||||
WORKDIR /app
|
||||
EXPOSE 80
|
||||
EXPOSE 443
|
||||
|
||||
# Deuxième étape : Construire l'application
|
||||
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build
|
||||
WORKDIR /src
|
||||
|
||||
# Copier les fichiers nécessaires pour la restauration des dépendances
|
||||
COPY ["dockerfile", "."]
|
||||
COPY ["VeraxShield/VeraxShield/VeraxShield.csproj", "VeraxShield/"]
|
||||
RUN dotnet restore "VeraxShield/VeraxShield.csproj"
|
||||
|
||||
# Copier le reste des fichiers
|
||||
COPY . .
|
||||
|
||||
WORKDIR "/src/VeraxShield/VeraxShield"
|
||||
RUN dotnet build "VeraxShield.csproj" -c Release -o /app/build
|
||||
|
||||
# Troisième étape : Publier l'application
|
||||
FROM build AS publish
|
||||
RUN dotnet publish "VeraxShield.csproj" -c Release -o /app/publish
|
||||
|
||||
# Quatrième étape : Créer l'image finale
|
||||
FROM base AS final
|
||||
WORKDIR /app
|
||||
|
||||
# Copier les fichiers publiés dans l'image finale
|
||||
COPY --from=publish /app/publish .
|
||||
|
||||
# Définir le point d'entrée de l'application
|
||||
ENTRYPOINT ["dotnet", "VeraxShield.dll"]
|
Before Width: | Height: | Size: 15 KiB |
Before Width: | Height: | Size: 10 KiB |
Before Width: | Height: | Size: 8.7 KiB |
Before Width: | Height: | Size: 77 KiB |
Before Width: | Height: | Size: 78 KiB |
Loading…
Reference in new issue