diff --git a/src/Core/AdminConsole/Entities/Policy.cs b/src/Core/AdminConsole/Entities/Policy.cs index 4a84c7cfd..2206b0cf6 100644 --- a/src/Core/AdminConsole/Entities/Policy.cs +++ b/src/Core/AdminConsole/Entities/Policy.cs @@ -10,8 +10,8 @@ namespace Bit.Core.AdminConsole.Entities; public class Policy : ITableObject { public Guid Id { get; set; } - public Guid OrganizationId { get; set; } - public PolicyType Type { get; set; } + public Guid OrganizationId { get; init; } + public PolicyType Type { get; init; } public string? Data { get; set; } public bool Enabled { get; set; } public DateTime CreationDate { get; internal set; } = DateTime.UtcNow; diff --git a/test/Infrastructure.EFIntegration.Test/AdminConsole/Repositories/OrganizationUserRepositoryTests.cs b/test/Infrastructure.EFIntegration.Test/AdminConsole/Repositories/OrganizationUserRepositoryTests.cs index 21d4ca347..64859c847 100644 --- a/test/Infrastructure.EFIntegration.Test/AdminConsole/Repositories/OrganizationUserRepositoryTests.cs +++ b/test/Infrastructure.EFIntegration.Test/AdminConsole/Repositories/OrganizationUserRepositoryTests.cs @@ -15,6 +15,7 @@ using Xunit; using EfAdminConsoleRepo = Bit.Infrastructure.EntityFramework.AdminConsole.Repositories; using EfRepo = Bit.Infrastructure.EntityFramework.Repositories; using OrganizationUser = Bit.Core.Entities.OrganizationUser; +using Policy = Bit.Infrastructure.EntityFramework.AdminConsole.Models.Policy; using SqlAdminConsoleRepo = Bit.Infrastructure.Dapper.AdminConsole.Repositories; using SqlRepo = Bit.Infrastructure.Dapper.Repositories; @@ -175,7 +176,6 @@ public class OrganizationUserRepositoryTests bool isProvider, // Auto data - models - Policy policy, User user, Organization organization, OrganizationUser orgUser, @@ -220,8 +220,6 @@ public class OrganizationUserRepositoryTests providerUserRepos.Add(sqlProviderUserRepo); // Arrange data - var savedPolicyType = PolicyType.SingleOrg; - orgUser.Type = userType; orgUser.Status = orgUserStatus; var permissionsData = new Permissions { ManagePolicies = canManagePolicies }; @@ -230,9 +228,6 @@ public class OrganizationUserRepositoryTests PropertyNamingPolicy = JsonNamingPolicy.CamelCase, }); - policy.Enabled = policyEnabled; - policy.Type = savedPolicyType; - var results = new List(); foreach (var policyRepo in policyRepos) @@ -271,7 +266,11 @@ public class OrganizationUserRepositoryTests await providerUserRepos[i].CreateAsync(providerUser); } - policy.OrganizationId = savedOrg.Id; + var policy = new Core.AdminConsole.Entities.Policy + { + Enabled = policyEnabled, Type = PolicyType.SingleOrg, OrganizationId = savedOrg.Id + }; + await policyRepo.CreateAsync(policy); if (efPolicyRepository.Contains(policyRepo)) {