mirror of
https://github.com/bitwarden/server
synced 2025-12-06 00:03:34 +00:00
* chore: remove ff from PoliciesController, refs PM-26426 * chore: remove ff from public PoliciesController, refs PM-26426 * chore: remove ff from VerifyOrganizationDomainCommands, refs PM-26426 * chore: remove ff from SsoConfigService, refs PM-26426 * chore: remove ff from public PoliciesControllerTests, refs PM-26426 * chore: remove ff from PoliciesControllerTests, refs PM-26426 * chore: remove ff from VerifyOrganizationDomainCommandTests, refs PM-26426 * chore: remove ff from SsoConfigServiceTests, refs PM-26426 * chore: remove ff definition, refs PM-26427 * chore: dotnet format * chore: remove unused constructor parameters, refs PM-26426 * chore: fix failing tests for VerifyOrganizationDomainCommandTests and SsoConfigServiceTests, refs PM-26426
50 lines
1.7 KiB
C#
50 lines
1.7 KiB
C#
using Bit.Api.AdminConsole.Public.Controllers;
|
|
using Bit.Api.AdminConsole.Public.Models.Request;
|
|
using Bit.Core.AdminConsole.Entities;
|
|
using Bit.Core.AdminConsole.Enums;
|
|
using Bit.Core.AdminConsole.Models.Data;
|
|
using Bit.Core.AdminConsole.OrganizationFeatures.Policies.Models;
|
|
using Bit.Core.AdminConsole.OrganizationFeatures.Policies.PolicyUpdateEvents.Interfaces;
|
|
using Bit.Core.Context;
|
|
using Bit.Test.Common.AutoFixture;
|
|
using Bit.Test.Common.AutoFixture.Attributes;
|
|
using NSubstitute;
|
|
using Xunit;
|
|
|
|
namespace Bit.Api.Test.AdminConsole.Public.Controllers;
|
|
|
|
[ControllerCustomize(typeof(PoliciesController))]
|
|
[SutProviderCustomize]
|
|
public class PoliciesControllerTests
|
|
{
|
|
[Theory]
|
|
[BitAutoData]
|
|
public async Task Put_UsesVNextSavePolicyCommand(
|
|
Guid organizationId,
|
|
PolicyType policyType,
|
|
PolicyUpdateRequestModel model,
|
|
Policy policy,
|
|
SutProvider<PoliciesController> sutProvider)
|
|
{
|
|
// Arrange
|
|
policy.Data = null;
|
|
sutProvider.GetDependency<ICurrentContext>()
|
|
.OrganizationId.Returns(organizationId);
|
|
sutProvider.GetDependency<IVNextSavePolicyCommand>()
|
|
.SaveAsync(Arg.Any<SavePolicyModel>())
|
|
.Returns(policy);
|
|
|
|
// Act
|
|
await sutProvider.Sut.Put(policyType, model);
|
|
|
|
// Assert
|
|
await sutProvider.GetDependency<IVNextSavePolicyCommand>()
|
|
.Received(1)
|
|
.SaveAsync(Arg.Is<SavePolicyModel>(m =>
|
|
m.PolicyUpdate.OrganizationId == organizationId &&
|
|
m.PolicyUpdate.Type == policyType &&
|
|
m.PolicyUpdate.Enabled == model.Enabled.GetValueOrDefault() &&
|
|
m.PerformedBy is SystemUser));
|
|
}
|
|
}
|