From 80c02a79ec522240b8e2b5f5954005aaa9e9c45f Mon Sep 17 00:00:00 2001 From: Sven Date: Thu, 15 Jan 2026 00:18:00 -0600 Subject: [PATCH] Fix broken test, delete inapplicable test --- .../Data/Organizations/Policies/PolicyData.cs | 8 ++-- .../Controllers/PoliciesControllerTests.cs | 39 ++++--------------- 2 files changed, 12 insertions(+), 35 deletions(-) diff --git a/src/Core/AdminConsole/Models/Data/Organizations/Policies/PolicyData.cs b/src/Core/AdminConsole/Models/Data/Organizations/Policies/PolicyData.cs index 00fd744b07..49a20c2a80 100644 --- a/src/Core/AdminConsole/Models/Data/Organizations/Policies/PolicyData.cs +++ b/src/Core/AdminConsole/Models/Data/Organizations/Policies/PolicyData.cs @@ -5,10 +5,10 @@ namespace Bit.Core.AdminConsole.Models.Data.Organizations.Policies; public class PolicyData { - public Guid OrganizationId { get; init; } - public PolicyType Type { get; init; } - public bool Enabled { get; init; } - public string? Data { get; init; } + public Guid OrganizationId { get; set; } + public PolicyType Type { get; set; } + public bool Enabled { get; set; } + public string? Data { get; set; } public T GetDataModel() where T : IPolicyDataModel, new() { diff --git a/test/Api.Test/Controllers/PoliciesControllerTests.cs b/test/Api.Test/Controllers/PoliciesControllerTests.cs index 84e74dd30e..d21b92b733 100644 --- a/test/Api.Test/Controllers/PoliciesControllerTests.cs +++ b/test/Api.Test/Controllers/PoliciesControllerTests.cs @@ -49,7 +49,7 @@ public class PoliciesControllerTests sutProvider.GetDependency() .GetProperUserId(Arg.Any()) - .Returns((Guid?)userId); + .Returns(userId); sutProvider.GetDependency() .GetByOrganizationAsync(orgId, userId) @@ -95,7 +95,7 @@ public class PoliciesControllerTests // Arrange sutProvider.GetDependency() .GetProperUserId(Arg.Any()) - .Returns((Guid?)userId); + .Returns(userId); sutProvider.GetDependency() .GetByOrganizationAsync(orgId, userId) @@ -113,7 +113,7 @@ public class PoliciesControllerTests // Arrange sutProvider.GetDependency() .GetProperUserId(Arg.Any()) - .Returns((Guid?)userId); + .Returns(userId); sutProvider.GetDependency() .GetByOrganizationAsync(orgId, userId) @@ -135,7 +135,7 @@ public class PoliciesControllerTests // Arrange sutProvider.GetDependency() .GetProperUserId(Arg.Any()) - .Returns((Guid?)userId); + .Returns(userId); sutProvider.GetDependency() .GetByOrganizationAsync(orgId, userId) @@ -186,19 +186,19 @@ public class PoliciesControllerTests [Theory] [BitAutoData] public async Task Get_WhenUserCanManagePolicies_WithExistingType_ReturnsExistingPolicy( - SutProvider sutProvider, Guid orgId, Policy policy, PolicyType type) + SutProvider sutProvider, Guid orgId, PolicyData policy, PolicyType type) { // Arrange sutProvider.GetDependency() .ManagePolicies(orgId) .Returns(true); - policy.Type = (PolicyType)type; + policy.Type = type; policy.Enabled = true; policy.Data = null; - sutProvider.GetDependency() - .GetByOrganizationIdTypeAsync(orgId, (PolicyType)type) + sutProvider.GetDependency() + .RunAsync(orgId, type) .Returns(policy); // Act @@ -211,29 +211,6 @@ public class PoliciesControllerTests Assert.Equal(policy.OrganizationId, result.OrganizationId); } - [Theory] - [BitAutoData] - public async Task Get_WhenUserCanManagePolicies_WithNonExistingType_ReturnsDefaultPolicy( - SutProvider sutProvider, Guid orgId, PolicyType type) - { - // Arrange - sutProvider.GetDependency() - .ManagePolicies(orgId) - .Returns(true); - - sutProvider.GetDependency() - .GetByOrganizationIdTypeAsync(orgId, (PolicyType)type) - .Returns((Policy)null); - - // Act - var result = await sutProvider.Sut.Get(orgId, type); - - // Assert - Assert.IsType(result); - Assert.Equal(result.Type, (PolicyType)type); - Assert.False(result.Enabled); - } - [Theory] [BitAutoData] public async Task Get_WhenUserCannotManagePolicies_ThrowsNotFoundException(