mirror of
https://github.com/bitwarden/server.git
synced 2025-01-07 19:37:51 +01:00
parent
72a47edceb
commit
71629047ad
@ -10,8 +10,8 @@ namespace Bit.Core.AdminConsole.Entities;
|
|||||||
public class Policy : ITableObject<Guid>
|
public class Policy : ITableObject<Guid>
|
||||||
{
|
{
|
||||||
public Guid Id { get; set; }
|
public Guid Id { get; set; }
|
||||||
public Guid OrganizationId { get; init; }
|
public Guid OrganizationId { get; set; }
|
||||||
public PolicyType Type { get; init; }
|
public PolicyType Type { get; set; }
|
||||||
public string? Data { get; set; }
|
public string? Data { get; set; }
|
||||||
public bool Enabled { get; set; }
|
public bool Enabled { get; set; }
|
||||||
public DateTime CreationDate { get; internal set; } = DateTime.UtcNow;
|
public DateTime CreationDate { get; internal set; } = DateTime.UtcNow;
|
||||||
|
@ -15,7 +15,6 @@ using Xunit;
|
|||||||
using EfAdminConsoleRepo = Bit.Infrastructure.EntityFramework.AdminConsole.Repositories;
|
using EfAdminConsoleRepo = Bit.Infrastructure.EntityFramework.AdminConsole.Repositories;
|
||||||
using EfRepo = Bit.Infrastructure.EntityFramework.Repositories;
|
using EfRepo = Bit.Infrastructure.EntityFramework.Repositories;
|
||||||
using OrganizationUser = Bit.Core.Entities.OrganizationUser;
|
using OrganizationUser = Bit.Core.Entities.OrganizationUser;
|
||||||
using Policy = Bit.Infrastructure.EntityFramework.AdminConsole.Models.Policy;
|
|
||||||
using SqlAdminConsoleRepo = Bit.Infrastructure.Dapper.AdminConsole.Repositories;
|
using SqlAdminConsoleRepo = Bit.Infrastructure.Dapper.AdminConsole.Repositories;
|
||||||
using SqlRepo = Bit.Infrastructure.Dapper.Repositories;
|
using SqlRepo = Bit.Infrastructure.Dapper.Repositories;
|
||||||
|
|
||||||
@ -176,6 +175,7 @@ public class OrganizationUserRepositoryTests
|
|||||||
bool isProvider,
|
bool isProvider,
|
||||||
|
|
||||||
// Auto data - models
|
// Auto data - models
|
||||||
|
Policy policy,
|
||||||
User user,
|
User user,
|
||||||
Organization organization,
|
Organization organization,
|
||||||
OrganizationUser orgUser,
|
OrganizationUser orgUser,
|
||||||
@ -220,6 +220,8 @@ public class OrganizationUserRepositoryTests
|
|||||||
providerUserRepos.Add(sqlProviderUserRepo);
|
providerUserRepos.Add(sqlProviderUserRepo);
|
||||||
|
|
||||||
// Arrange data
|
// Arrange data
|
||||||
|
var savedPolicyType = PolicyType.SingleOrg;
|
||||||
|
|
||||||
orgUser.Type = userType;
|
orgUser.Type = userType;
|
||||||
orgUser.Status = orgUserStatus;
|
orgUser.Status = orgUserStatus;
|
||||||
var permissionsData = new Permissions { ManagePolicies = canManagePolicies };
|
var permissionsData = new Permissions { ManagePolicies = canManagePolicies };
|
||||||
@ -228,6 +230,9 @@ public class OrganizationUserRepositoryTests
|
|||||||
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
|
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
policy.Enabled = policyEnabled;
|
||||||
|
policy.Type = savedPolicyType;
|
||||||
|
|
||||||
var results = new List<OrganizationUserPolicyDetails>();
|
var results = new List<OrganizationUserPolicyDetails>();
|
||||||
|
|
||||||
foreach (var policyRepo in policyRepos)
|
foreach (var policyRepo in policyRepos)
|
||||||
@ -266,11 +271,7 @@ public class OrganizationUserRepositoryTests
|
|||||||
await providerUserRepos[i].CreateAsync(providerUser);
|
await providerUserRepos[i].CreateAsync(providerUser);
|
||||||
}
|
}
|
||||||
|
|
||||||
var policy = new Core.AdminConsole.Entities.Policy
|
policy.OrganizationId = savedOrg.Id;
|
||||||
{
|
|
||||||
Enabled = policyEnabled, Type = PolicyType.SingleOrg, OrganizationId = savedOrg.Id
|
|
||||||
};
|
|
||||||
|
|
||||||
await policyRepo.CreateAsync(policy);
|
await policyRepo.CreateAsync(policy);
|
||||||
if (efPolicyRepository.Contains(policyRepo))
|
if (efPolicyRepository.Contains(policyRepo))
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user