-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PM-14245] Remove policy definitions feature flag (#5095)
* Remove PolicyService.SaveAsync and use command instead * Delete feature flag definition * Add public api integration tests
- Loading branch information
Showing
17 changed files
with
292 additions
and
1,128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 10 additions & 17 deletions
27
src/Api/AdminConsole/Public/Models/Request/PolicyUpdateRequestModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,19 @@ | ||
using System.Text.Json; | ||
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.Enums; | ||
|
||
namespace Bit.Api.AdminConsole.Public.Models.Request; | ||
|
||
public class PolicyUpdateRequestModel : PolicyBaseModel | ||
{ | ||
public Policy ToPolicy(Guid orgId, PolicyType type) | ||
public PolicyUpdate ToPolicyUpdate(Guid organizationId, PolicyType type) => new() | ||
{ | ||
return ToPolicy(new Policy | ||
{ | ||
OrganizationId = orgId, | ||
Enabled = Enabled.GetValueOrDefault(), | ||
Data = Data != null ? JsonSerializer.Serialize(Data) : null, | ||
Type = type | ||
}); | ||
} | ||
|
||
public virtual Policy ToPolicy(Policy existingPolicy) | ||
{ | ||
existingPolicy.Enabled = Enabled.GetValueOrDefault(); | ||
existingPolicy.Data = Data != null ? JsonSerializer.Serialize(Data) : null; | ||
return existingPolicy; | ||
} | ||
Type = type, | ||
OrganizationId = organizationId, | ||
Data = Data != null ? JsonSerializer.Serialize(Data) : null, | ||
Enabled = Enabled.GetValueOrDefault(), | ||
PerformedBy = new SystemUser(EventSystemUser.PublicApi) | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 3 additions & 2 deletions
5
src/Core/AdminConsole/OrganizationFeatures/Policies/ISavePolicyCommand.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
using Bit.Core.AdminConsole.OrganizationFeatures.Policies.Models; | ||
using Bit.Core.AdminConsole.Entities; | ||
using Bit.Core.AdminConsole.OrganizationFeatures.Policies.Models; | ||
|
||
namespace Bit.Core.AdminConsole.OrganizationFeatures.Policies; | ||
|
||
public interface ISavePolicyCommand | ||
{ | ||
Task SaveAsync(PolicyUpdate policy); | ||
Task<Policy> SaveAsync(PolicyUpdate policy); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.