mirror of
https://github.com/bitwarden/server.git
synced 2025-04-04 20:50:21 -05:00
Merge branch 'main' into experiment/authorize-attribute
This commit is contained in:
commit
6905844034
@ -13,7 +13,17 @@ public static class PolicyDetailResponses
|
||||
{
|
||||
throw new ArgumentException($"'{nameof(policy)}' must be of type '{nameof(PolicyType.SingleOrg)}'.", nameof(policy));
|
||||
}
|
||||
return new PolicyDetailResponseModel(policy, await CanToggleState());
|
||||
|
||||
return new PolicyDetailResponseModel(policy, !await hasVerifiedDomainsQuery.HasVerifiedDomainsAsync(policy.OrganizationId));
|
||||
async Task<bool> CanToggleState()
|
||||
{
|
||||
if (!await hasVerifiedDomainsQuery.HasVerifiedDomainsAsync(policy.OrganizationId))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return !policy.Enabled;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -575,6 +575,7 @@ public class OrganizationService : IOrganizationService
|
||||
UseSecretsManager = license.UseSecretsManager,
|
||||
SmSeats = license.SmSeats,
|
||||
SmServiceAccounts = license.SmServiceAccounts,
|
||||
UseRiskInsights = license.UseRiskInsights,
|
||||
};
|
||||
|
||||
var result = await SignUpAsync(organization, owner.Id, ownerKey, collectionName, false);
|
||||
|
@ -14,5 +14,7 @@ public enum ClientType : byte
|
||||
[Display(Name = "Desktop App")]
|
||||
Desktop = 3,
|
||||
[Display(Name = "Mobile App")]
|
||||
Mobile = 4
|
||||
Mobile = 4,
|
||||
[Display(Name = "CLI")]
|
||||
Cli = 5
|
||||
}
|
||||
|
@ -55,6 +55,7 @@ public class OrganizationLicense : ILicense
|
||||
UseSecretsManager = org.UseSecretsManager;
|
||||
SmSeats = org.SmSeats;
|
||||
SmServiceAccounts = org.SmServiceAccounts;
|
||||
UseRiskInsights = org.UseRiskInsights;
|
||||
|
||||
// Deprecated. Left for backwards compatibility with old license versions.
|
||||
LimitCollectionCreationDeletion = org.LimitCollectionCreation || org.LimitCollectionDeletion;
|
||||
@ -143,6 +144,7 @@ public class OrganizationLicense : ILicense
|
||||
public bool UseSecretsManager { get; set; }
|
||||
public int? SmSeats { get; set; }
|
||||
public int? SmServiceAccounts { get; set; }
|
||||
public bool UseRiskInsights { get; set; }
|
||||
|
||||
// Deprecated. Left for backwards compatibility with old license versions.
|
||||
public bool LimitCollectionCreationDeletion { get; set; } = true;
|
||||
@ -218,7 +220,8 @@ public class OrganizationLicense : ILicense
|
||||
!p.Name.Equals(nameof(Issued)) &&
|
||||
!p.Name.Equals(nameof(Refresh))
|
||||
)
|
||||
))
|
||||
) &&
|
||||
!p.Name.Equals(nameof(UseRiskInsights)))
|
||||
.OrderBy(p => p.Name)
|
||||
.Select(p => $"{p.Name}:{Utilities.CoreHelpers.FormatLicenseSignatureValue(p.GetValue(this, null))}")
|
||||
.Aggregate((c, n) => $"{c}|{n}");
|
||||
|
@ -16,7 +16,11 @@ public static class DeviceTypes
|
||||
DeviceType.LinuxDesktop,
|
||||
DeviceType.MacOsDesktop,
|
||||
DeviceType.WindowsDesktop,
|
||||
DeviceType.UWP,
|
||||
DeviceType.UWP
|
||||
];
|
||||
|
||||
public static IReadOnlyCollection<DeviceType> CliTypes { get; } =
|
||||
[
|
||||
DeviceType.WindowsCLI,
|
||||
DeviceType.MacOsCLI,
|
||||
DeviceType.LinuxCLI
|
||||
@ -50,6 +54,7 @@ public static class DeviceTypes
|
||||
{
|
||||
not null when MobileTypes.Contains(deviceType.Value) => ClientType.Mobile,
|
||||
not null when DesktopTypes.Contains(deviceType.Value) => ClientType.Desktop,
|
||||
not null when CliTypes.Contains(deviceType.Value) => ClientType.Cli,
|
||||
not null when BrowserExtensionTypes.Contains(deviceType.Value) => ClientType.Browser,
|
||||
not null when BrowserTypes.Contains(deviceType.Value) => ClientType.Web,
|
||||
_ => ClientType.All
|
||||
|
@ -10,14 +10,19 @@ namespace Bit.Api.Test.AdminConsole.Models.Response.Helpers;
|
||||
|
||||
public class PolicyDetailResponsesTests
|
||||
{
|
||||
[Fact]
|
||||
public async Task GetSingleOrgPolicyDetailResponseAsync_GivenPolicyEntity_WhenIsSingleOrgTypeAndHasVerifiedDomains_ThenShouldNotBeAbleToToggle()
|
||||
[Theory]
|
||||
[InlineData(true, false)]
|
||||
[InlineData(false, true)]
|
||||
public async Task GetSingleOrgPolicyDetailResponseAsync_WhenIsSingleOrgTypeAndHasVerifiedDomains_ShouldReturnExpectedToggleState(
|
||||
bool policyEnabled,
|
||||
bool expectedCanToggle)
|
||||
{
|
||||
var fixture = new Fixture();
|
||||
|
||||
var policy = fixture.Build<Policy>()
|
||||
.Without(p => p.Data)
|
||||
.With(p => p.Type, PolicyType.SingleOrg)
|
||||
.With(p => p.Enabled, policyEnabled)
|
||||
.Create();
|
||||
|
||||
var querySub = Substitute.For<IOrganizationHasVerifiedDomainsQuery>();
|
||||
@ -26,11 +31,11 @@ public class PolicyDetailResponsesTests
|
||||
|
||||
var result = await policy.GetSingleOrgPolicyDetailResponseAsync(querySub);
|
||||
|
||||
Assert.False(result.CanToggleState);
|
||||
Assert.Equal(expectedCanToggle, result.CanToggleState);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task GetSingleOrgPolicyDetailResponseAsync_GivenPolicyEntity_WhenIsNotSingleOrgType_ThenShouldThrowArgumentException()
|
||||
public async Task GetSingleOrgPolicyDetailResponseAsync_WhenIsNotSingleOrgType_ThenShouldThrowArgumentException()
|
||||
{
|
||||
var fixture = new Fixture();
|
||||
|
||||
@ -49,7 +54,7 @@ public class PolicyDetailResponsesTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task GetSingleOrgPolicyDetailResponseAsync_GivenPolicyEntity_WhenIsSingleOrgTypeAndDoesNotHaveVerifiedDomains_ThenShouldBeAbleToToggle()
|
||||
public async Task GetSingleOrgPolicyDetailResponseAsync_WhenIsSingleOrgTypeAndDoesNotHaveVerifiedDomains_ThenShouldBeAbleToToggle()
|
||||
{
|
||||
var fixture = new Fixture();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user