mirror of
https://github.com/bitwarden/server
synced 2025-12-22 11:13:27 +00:00
Add validation to URI Match Default Policy for Single Org prerequisite (#6454)
* Add validation to URI Match Default Policy for Single Org prerequisite Signed-off-by: Ben Brooks <bbrooks@bitwarden.com> * Remove nullable enable; Replace Task.FromResult(0) with Task.CompletedTask Signed-off-by: Ben Brooks <bbrooks@bitwarden.com> * Add unit test for our new validator Signed-off-by: Ben Brooks <bbrooks@bitwarden.com> * Improve comments and whitespace for unit test Signed-off-by: Ben Brooks <bbrooks@bitwarden.com> * Remove unnecessary whitespace in unit test Signed-off-by: Ben Brooks <bbrooks@bitwarden.com> * Remove unneccessary unit tets Signed-off-by: Ben Brooks <bbrooks@bitwarden.com> * Re-add using NSubstitute Signed-off-by: Ben Brooks <bbrooks@bitwarden.com> * Revert unintended changes to AccountControllerTest.cs Signed-off-by: Ben Brooks <bbrooks@bitwarden.com> * Revert unintended changes to AccountControllerTest.cs Signed-off-by: Ben Brooks <bbrooks@bitwarden.com> * Revert unintended changes to HubHelpersTest.cs Signed-off-by: Ben Brooks <bbrooks@bitwarden.com> * Add IEnforceDependentPoliciesEvent interface to UriMatchDefaultPolicyValidator Signed-off-by: Ben Brooks <bbrooks@bitwarden.com> --------- Signed-off-by: Ben Brooks <bbrooks@bitwarden.com>
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
using Bit.Core.AdminConsole.Enums;
|
||||
using Bit.Core.AdminConsole.OrganizationFeatures.Policies.PolicyValidators;
|
||||
using Xunit;
|
||||
|
||||
namespace Bit.Core.Test.AdminConsole.OrganizationFeatures.Policies.PolicyValidators;
|
||||
|
||||
public class UriMatchDefaultPolicyValidatorTests
|
||||
{
|
||||
private readonly UriMatchDefaultPolicyValidator _validator = new();
|
||||
|
||||
[Fact]
|
||||
// Test that the Type property returns the correct PolicyType for this validator
|
||||
public void Type_ReturnsUriMatchDefaults()
|
||||
{
|
||||
Assert.Equal(PolicyType.UriMatchDefaults, _validator.Type);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
// Test that the RequiredPolicies property returns exactly one policy (SingleOrg) as a prerequisite
|
||||
// for enabling the UriMatchDefaults policy, ensuring proper policy dependency enforcement
|
||||
public void RequiredPolicies_ReturnsSingleOrgPolicy()
|
||||
{
|
||||
var requiredPolicies = _validator.RequiredPolicies.ToList();
|
||||
|
||||
Assert.Single(requiredPolicies);
|
||||
Assert.Contains(PolicyType.SingleOrg, requiredPolicies);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user