From dca566cbf679b4137cddfe798b8f14c3abaa864d Mon Sep 17 00:00:00 2001 From: alex289 Date: Wed, 24 Apr 2024 22:10:56 +0200 Subject: [PATCH] fix: Seeding test data --- .../Fixtures/TestFixtureBase.cs | 23 ++++++++++++++++++- .../Auth/TestAuthenticationOptions.cs | 1 + 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/CleanArchitecture.IntegrationTests/Fixtures/TestFixtureBase.cs b/CleanArchitecture.IntegrationTests/Fixtures/TestFixtureBase.cs index c193326..c0311a5 100644 --- a/CleanArchitecture.IntegrationTests/Fixtures/TestFixtureBase.cs +++ b/CleanArchitecture.IntegrationTests/Fixtures/TestFixtureBase.cs @@ -7,7 +7,6 @@ using CleanArchitecture.Domain.Enums; using CleanArchitecture.Infrastructure.Database; using CleanArchitecture.IntegrationTests.Infrastructure; using CleanArchitecture.IntegrationTests.Infrastructure.Auth; -using Microsoft.AspNetCore.Mvc.Testing; using Microsoft.Extensions.DependencyInjection; using Xunit; @@ -40,6 +39,28 @@ public class TestFixtureBase : IAsyncLifetime using var scope = Factory.Services.CreateScope(); await using var dbContext = scope.ServiceProvider.GetRequiredService(); + dbContext.Tenants.Add(new Tenant( + Ids.Seed.TenantId, + "Admin Tenant")); + + dbContext.Users.Add(new User( + Ids.Seed.UserId, + Ids.Seed.TenantId, + "admin@email.com", + "Admin", + "User", + "$2a$12$Blal/uiFIJdYsCLTMUik/egLbfg3XhbnxBC6Sb5IKz2ZYhiU/MzL2", + UserRole.Admin)); + + dbContext.Users.Add(new User( + TestAuthenticationOptions.TestUserId, + Ids.Seed.TenantId, + TestAuthenticationOptions.Email, + TestAuthenticationOptions.FirstName, + TestAuthenticationOptions.LastName, + TestAuthenticationOptions.Password, + UserRole.Admin)); + SeedTestData(dbContext); await dbContext.SaveChangesAsync(); } diff --git a/CleanArchitecture.IntegrationTests/Infrastructure/Auth/TestAuthenticationOptions.cs b/CleanArchitecture.IntegrationTests/Infrastructure/Auth/TestAuthenticationOptions.cs index 1eb58b4..967f8bf 100644 --- a/CleanArchitecture.IntegrationTests/Infrastructure/Auth/TestAuthenticationOptions.cs +++ b/CleanArchitecture.IntegrationTests/Infrastructure/Auth/TestAuthenticationOptions.cs @@ -10,6 +10,7 @@ public sealed class TestAuthenticationOptions : AuthenticationSchemeOptions public const string Email = "integration@tests.com"; public const string FirstName = "Integration"; public const string LastName = "Tests"; + public const string Password = "$2a$12$Blal/uiFIJdYsCLTMUik/egLbfg3XhbnxBC6Sb5IKz2ZYhiU/MzL2"; public static Guid TestUserId = new("561e4300-94d6-4c3f-adf5-31c1bdbc64df"); public ClaimsIdentity Identity { get; } = new(