diff --git a/API_SQLuedo/API_SQLuedo.sln b/API_SQLuedo/API_SQLuedo.sln index 58f87a2..fbefbe6 100644 --- a/API_SQLuedo/API_SQLuedo.sln +++ b/API_SQLuedo/API_SQLuedo.sln @@ -19,6 +19,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Services", "Services\Servic EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestConsoleAPI", "TestConsoleAPI\TestConsoleAPI.csproj", "{46376AEF-4093-4AE9-AD2F-F51B541F9C6A}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StubbedContextLib", "StubbedContextLib\StubbedContextLib.csproj", "{B64941C9-0550-4C47-89B6-396F6DB0486D}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -57,6 +59,10 @@ Global {46376AEF-4093-4AE9-AD2F-F51B541F9C6A}.Debug|Any CPU.Build.0 = Debug|Any CPU {46376AEF-4093-4AE9-AD2F-F51B541F9C6A}.Release|Any CPU.ActiveCfg = Release|Any CPU {46376AEF-4093-4AE9-AD2F-F51B541F9C6A}.Release|Any CPU.Build.0 = Release|Any CPU + {B64941C9-0550-4C47-89B6-396F6DB0486D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B64941C9-0550-4C47-89B6-396F6DB0486D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B64941C9-0550-4C47-89B6-396F6DB0486D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B64941C9-0550-4C47-89B6-396F6DB0486D}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/API_SQLuedo/DbContextLib/UserDbContext.cs b/API_SQLuedo/DbContextLib/UserDbContext.cs index 019d33c..487359a 100644 --- a/API_SQLuedo/DbContextLib/UserDbContext.cs +++ b/API_SQLuedo/DbContextLib/UserDbContext.cs @@ -32,37 +32,6 @@ namespace DbContextLib protected override void OnModelCreating(ModelBuilder modelBuilder) { modelBuilder.Entity().ToTable("user"); - modelBuilder.Entity().HasData( - new UserEntity(1, "johnny", Convert.ToBase64String(KeyDerivation.Pbkdf2( - password: "motdepasse", - salt: RandomNumberGenerator.GetBytes(128 / 8), - prf: KeyDerivationPrf.HMACSHA256, - iterationCount: 100000, - numBytesRequested: 256 / 8)), "Johnny.RATTON@etu.uca.fr", true), - new UserEntity(2, "maxime", Convert.ToBase64String(KeyDerivation.Pbkdf2( - password: "motdepasse", - salt: RandomNumberGenerator.GetBytes(128 / 8), - prf: KeyDerivationPrf.HMACSHA256, - iterationCount: 100000, - numBytesRequested: 256 / 8)), "Maxime.SAPOUNTZIS@etu.uca.fr", true), - new UserEntity(3, "clement", Convert.ToBase64String(KeyDerivation.Pbkdf2( - password: "motdepasse", - salt: RandomNumberGenerator.GetBytes(128 / 8), - prf: KeyDerivationPrf.HMACSHA256, - iterationCount: 100000, - numBytesRequested: 256 / 8)), "Clement.CHIEU@etu.uca.fr", true), - new UserEntity(4, "erwan", Convert.ToBase64String(KeyDerivation.Pbkdf2( - password: "motdepasse", - salt: RandomNumberGenerator.GetBytes(128 / 8), - prf: KeyDerivationPrf.HMACSHA256, - iterationCount: 100000, - numBytesRequested: 256 / 8)), "Erwan.MENAGER@etu.uca.fr", true), - new UserEntity(5, "victor", Convert.ToBase64String(KeyDerivation.Pbkdf2( - password: "motdepasse", - salt: RandomNumberGenerator.GetBytes(128 / 8), - prf: KeyDerivationPrf.HMACSHA256, - iterationCount: 100000, - numBytesRequested: 256 / 8)), "Victor.GABORIT@etu.uca.fr", true)); modelBuilder.Entity().HasKey(c => c.LessonId); modelBuilder.Entity().HasKey(c => c.LessonPartId); modelBuilder.Entity().HasKey(s => s.UserId); diff --git a/API_SQLuedo/StubbedContextLib/StubbedContext.cs b/API_SQLuedo/StubbedContextLib/StubbedContext.cs new file mode 100644 index 0000000..52a845f --- /dev/null +++ b/API_SQLuedo/StubbedContextLib/StubbedContext.cs @@ -0,0 +1,50 @@ +using System.Security.Cryptography; +using DbContextLib; +using Entities.SQLuedoDB; +using Microsoft.AspNetCore.Cryptography.KeyDerivation; +using Microsoft.EntityFrameworkCore; + +namespace StubbedContextLib; + +public class StubbedContext : UserDbContext +{ + public StubbedContext(DbContextOptions options) : base(options) + { + } + + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + base.OnModelCreating(modelBuilder); + modelBuilder.Entity().HasData( + new UserEntity(1, "johnny", Convert.ToBase64String(KeyDerivation.Pbkdf2( + password: "motdepasse", + salt: RandomNumberGenerator.GetBytes(128 / 8), + prf: KeyDerivationPrf.HMACSHA256, + iterationCount: 100000, + numBytesRequested: 256 / 8)), "Johnny.RATTON@etu.uca.fr", true), + new UserEntity(2, "maxime", Convert.ToBase64String(KeyDerivation.Pbkdf2( + password: "motdepasse", + salt: RandomNumberGenerator.GetBytes(128 / 8), + prf: KeyDerivationPrf.HMACSHA256, + iterationCount: 100000, + numBytesRequested: 256 / 8)), "Maxime.SAPOUNTZIS@etu.uca.fr", true), + new UserEntity(3, "clement", Convert.ToBase64String(KeyDerivation.Pbkdf2( + password: "motdepasse", + salt: RandomNumberGenerator.GetBytes(128 / 8), + prf: KeyDerivationPrf.HMACSHA256, + iterationCount: 100000, + numBytesRequested: 256 / 8)), "Clement.CHIEU@etu.uca.fr", true), + new UserEntity(4, "erwan", Convert.ToBase64String(KeyDerivation.Pbkdf2( + password: "motdepasse", + salt: RandomNumberGenerator.GetBytes(128 / 8), + prf: KeyDerivationPrf.HMACSHA256, + iterationCount: 100000, + numBytesRequested: 256 / 8)), "Erwan.MENAGER@etu.uca.fr", true), + new UserEntity(5, "victor", Convert.ToBase64String(KeyDerivation.Pbkdf2( + password: "motdepasse", + salt: RandomNumberGenerator.GetBytes(128 / 8), + prf: KeyDerivationPrf.HMACSHA256, + iterationCount: 100000, + numBytesRequested: 256 / 8)), "Victor.GABORIT@etu.uca.fr", true)); + } +} \ No newline at end of file diff --git a/API_SQLuedo/StubbedContextLib/StubbedContextLib.csproj b/API_SQLuedo/StubbedContextLib/StubbedContextLib.csproj new file mode 100644 index 0000000..19a69a6 --- /dev/null +++ b/API_SQLuedo/StubbedContextLib/StubbedContextLib.csproj @@ -0,0 +1,13 @@ + + + + net8.0 + enable + enable + + + + + + +