diff --git a/bitwarden_license/src/Sso/Controllers/AccountController.cs b/bitwarden_license/src/Sso/Controllers/AccountController.cs index 0df6894175..11a42e3cb1 100644 --- a/bitwarden_license/src/Sso/Controllers/AccountController.cs +++ b/bitwarden_license/src/Sso/Controllers/AccountController.cs @@ -1,5 +1,7 @@ using System.Security.Claims; using Bit.Core; +using Bit.Core.AdminConsole.Enums; +using Bit.Core.AdminConsole.Repositories; using Bit.Core.Auth.Entities; using Bit.Core.Auth.Enums; using Bit.Core.Auth.Models; diff --git a/src/Api/AdminConsole/Controllers/OrganizationUsersController.cs b/src/Api/AdminConsole/Controllers/OrganizationUsersController.cs index 73140cea4e..5ca1003fd4 100644 --- a/src/Api/AdminConsole/Controllers/OrganizationUsersController.cs +++ b/src/Api/AdminConsole/Controllers/OrganizationUsersController.cs @@ -2,6 +2,8 @@ using Bit.Api.AdminConsole.Models.Response.Organizations; using Bit.Api.Models.Request.Organizations; using Bit.Api.Models.Response; +using Bit.Core.AdminConsole.Enums; +using Bit.Core.AdminConsole.Models.Data.Organizations.Policies; using Bit.Core.AdminConsole.OrganizationFeatures.OrganizationUsers.Interfaces; using Bit.Core.AdminConsole.Repositories; using Bit.Core.Context; @@ -9,7 +11,6 @@ using Bit.Core.Enums; using Bit.Core.Exceptions; using Bit.Core.Models.Business; using Bit.Core.Models.Data.Organizations.OrganizationUsers; -using Bit.Core.Models.Data.Organizations.Policies; using Bit.Core.OrganizationFeatures.OrganizationSubscriptions.Interface; using Bit.Core.OrganizationFeatures.OrganizationUsers.Interfaces; using Bit.Core.Repositories; diff --git a/src/Api/AdminConsole/Controllers/OrganizationsController.cs b/src/Api/AdminConsole/Controllers/OrganizationsController.cs index aa5efd12cb..db02097421 100644 --- a/src/Api/AdminConsole/Controllers/OrganizationsController.cs +++ b/src/Api/AdminConsole/Controllers/OrganizationsController.cs @@ -11,6 +11,8 @@ using Bit.Api.Models.Request.Accounts; using Bit.Api.Models.Request.Organizations; using Bit.Api.Models.Response; using Bit.Core; +using Bit.Core.AdminConsole.Enums; +using Bit.Core.AdminConsole.Models.Data.Organizations.Policies; using Bit.Core.AdminConsole.OrganizationFeatures.OrganizationApiKeys.Interfaces; using Bit.Core.AdminConsole.Repositories; using Bit.Core.Auth.Enums; @@ -20,7 +22,6 @@ using Bit.Core.Context; using Bit.Core.Enums; using Bit.Core.Exceptions; using Bit.Core.Models.Business; -using Bit.Core.Models.Data.Organizations.Policies; using Bit.Core.OrganizationFeatures.OrganizationLicenses.Interfaces; using Bit.Core.OrganizationFeatures.OrganizationSubscriptions.Interface; using Bit.Core.Repositories; diff --git a/src/Api/AdminConsole/Controllers/PoliciesController.cs b/src/Api/AdminConsole/Controllers/PoliciesController.cs index 60257814e9..5668031d24 100644 --- a/src/Api/AdminConsole/Controllers/PoliciesController.cs +++ b/src/Api/AdminConsole/Controllers/PoliciesController.cs @@ -1,10 +1,13 @@ using Bit.Api.AdminConsole.Models.Request; using Bit.Api.Models.Response; +using Bit.Core.AdminConsole.Enums; +using Bit.Core.AdminConsole.Models.Api.Response; +using Bit.Core.AdminConsole.Repositories; +using Bit.Core.AdminConsole.Services; using Bit.Core.Auth.Models.Business.Tokenables; using Bit.Core.Context; using Bit.Core.Enums; using Bit.Core.Exceptions; -using Bit.Core.Models.Api.Response; using Bit.Core.Repositories; using Bit.Core.Services; using Bit.Core.Settings; diff --git a/src/Api/AdminConsole/Models/Request/PolicyRequestModel.cs b/src/Api/AdminConsole/Models/Request/PolicyRequestModel.cs index b3ba3a6bca..db191194d7 100644 --- a/src/Api/AdminConsole/Models/Request/PolicyRequestModel.cs +++ b/src/Api/AdminConsole/Models/Request/PolicyRequestModel.cs @@ -1,7 +1,7 @@ using System.ComponentModel.DataAnnotations; using System.Text.Json; -using Bit.Core.Entities; -using Bit.Core.Enums; +using Bit.Core.AdminConsole.Entities; +using Bit.Core.AdminConsole.Enums; namespace Bit.Api.AdminConsole.Models.Request; diff --git a/src/Api/AdminConsole/Public/Controllers/PoliciesController.cs b/src/Api/AdminConsole/Public/Controllers/PoliciesController.cs index bcabb969c6..1d7eb65185 100644 --- a/src/Api/AdminConsole/Public/Controllers/PoliciesController.cs +++ b/src/Api/AdminConsole/Public/Controllers/PoliciesController.cs @@ -2,9 +2,10 @@ using Bit.Api.AdminConsole.Public.Models.Request; using Bit.Api.AdminConsole.Public.Models.Response; using Bit.Api.Models.Public.Response; +using Bit.Core.AdminConsole.Enums; +using Bit.Core.AdminConsole.Repositories; +using Bit.Core.AdminConsole.Services; using Bit.Core.Context; -using Bit.Core.Enums; -using Bit.Core.Repositories; using Bit.Core.Services; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; diff --git a/src/Api/AdminConsole/Public/Models/Request/PolicyUpdateRequestModel.cs b/src/Api/AdminConsole/Public/Models/Request/PolicyUpdateRequestModel.cs index 1866da6eca..80b7874a0b 100644 --- a/src/Api/AdminConsole/Public/Models/Request/PolicyUpdateRequestModel.cs +++ b/src/Api/AdminConsole/Public/Models/Request/PolicyUpdateRequestModel.cs @@ -1,5 +1,5 @@ using System.Text.Json; -using Bit.Core.Entities; +using Bit.Core.AdminConsole.Entities; namespace Bit.Api.AdminConsole.Public.Models.Request; diff --git a/src/Api/AdminConsole/Public/Models/Response/PolicyResponseModel.cs b/src/Api/AdminConsole/Public/Models/Response/PolicyResponseModel.cs index 3b196874d5..27da5cc561 100644 --- a/src/Api/AdminConsole/Public/Models/Response/PolicyResponseModel.cs +++ b/src/Api/AdminConsole/Public/Models/Response/PolicyResponseModel.cs @@ -1,8 +1,8 @@ using System.ComponentModel.DataAnnotations; using System.Text.Json; using Bit.Api.Models.Public.Response; -using Bit.Core.Entities; -using Bit.Core.Enums; +using Bit.Core.AdminConsole.Entities; +using Bit.Core.AdminConsole.Enums; namespace Bit.Api.AdminConsole.Public.Models.Response; diff --git a/src/Api/Auth/Controllers/EmergencyAccessController.cs b/src/Api/Auth/Controllers/EmergencyAccessController.cs index ec2a9fc6b7..95fac234c8 100644 --- a/src/Api/Auth/Controllers/EmergencyAccessController.cs +++ b/src/Api/Auth/Controllers/EmergencyAccessController.cs @@ -3,10 +3,10 @@ using Bit.Api.Auth.Models.Request; using Bit.Api.Auth.Models.Response; using Bit.Api.Models.Response; using Bit.Api.Vault.Models.Response; +using Bit.Core.AdminConsole.Entities; +using Bit.Core.AdminConsole.Models.Api.Response; using Bit.Core.Auth.Services; -using Bit.Core.Entities; using Bit.Core.Exceptions; -using Bit.Core.Models.Api.Response; using Bit.Core.Repositories; using Bit.Core.Services; using Bit.Core.Settings; diff --git a/src/Api/Auth/Controllers/WebAuthnController.cs b/src/Api/Auth/Controllers/WebAuthnController.cs index e62d1a95ba..a30e83a5e0 100644 --- a/src/Api/Auth/Controllers/WebAuthnController.cs +++ b/src/Api/Auth/Controllers/WebAuthnController.cs @@ -3,9 +3,10 @@ using Bit.Api.Auth.Models.Request.Webauthn; using Bit.Api.Auth.Models.Response.WebAuthn; using Bit.Api.Models.Response; using Bit.Core; +using Bit.Core.AdminConsole.Enums; +using Bit.Core.AdminConsole.Services; using Bit.Core.Auth.Models.Business.Tokenables; using Bit.Core.Auth.Repositories; -using Bit.Core.Enums; using Bit.Core.Exceptions; using Bit.Core.Services; using Bit.Core.Tokens; diff --git a/src/Api/Controllers/AccountsController.cs b/src/Api/Controllers/AccountsController.cs index 7dbcf07d06..d699f09ec6 100644 --- a/src/Api/Controllers/AccountsController.cs +++ b/src/Api/Controllers/AccountsController.cs @@ -7,6 +7,7 @@ using Bit.Api.Utilities; using Bit.Core; using Bit.Core.AdminConsole.Enums.Provider; using Bit.Core.AdminConsole.Repositories; +using Bit.Core.AdminConsole.Services; using Bit.Core.Auth.Models.Api.Request.Accounts; using Bit.Core.Auth.Models.Api.Response.Accounts; using Bit.Core.Auth.Models.Data; diff --git a/src/Api/Vault/Controllers/SyncController.cs b/src/Api/Vault/Controllers/SyncController.cs index ac7ef9acdc..0d75235111 100644 --- a/src/Api/Vault/Controllers/SyncController.cs +++ b/src/Api/Vault/Controllers/SyncController.cs @@ -1,4 +1,5 @@ using Bit.Api.Vault.Models.Response; +using Bit.Core.AdminConsole.Entities; using Bit.Core.AdminConsole.Enums.Provider; using Bit.Core.AdminConsole.Repositories; using Bit.Core.Entities; diff --git a/src/Api/Vault/Models/Response/SyncResponseModel.cs b/src/Api/Vault/Models/Response/SyncResponseModel.cs index 817f233e11..ca833738a1 100644 --- a/src/Api/Vault/Models/Response/SyncResponseModel.cs +++ b/src/Api/Vault/Models/Response/SyncResponseModel.cs @@ -1,9 +1,10 @@ using Bit.Api.Models.Response; using Bit.Api.Tools.Models.Response; +using Bit.Core.AdminConsole.Entities; +using Bit.Core.AdminConsole.Models.Api.Response; using Bit.Core.AdminConsole.Models.Data.Provider; using Bit.Core.Entities; using Bit.Core.Models.Api; -using Bit.Core.Models.Api.Response; using Bit.Core.Models.Data; using Bit.Core.Models.Data.Organizations.OrganizationUsers; using Bit.Core.Settings; diff --git a/src/Core/Entities/Policy.cs b/src/Core/AdminConsole/Entities/Policy.cs similarity index 88% rename from src/Core/Entities/Policy.cs rename to src/Core/AdminConsole/Entities/Policy.cs index 4863b8ccc8..75d67c1021 100644 --- a/src/Core/Entities/Policy.cs +++ b/src/Core/AdminConsole/Entities/Policy.cs @@ -1,8 +1,9 @@ -using Bit.Core.Enums; +using Bit.Core.AdminConsole.Enums; +using Bit.Core.Entities; using Bit.Core.Models.Data.Organizations.Policies; using Bit.Core.Utilities; -namespace Bit.Core.Entities; +namespace Bit.Core.AdminConsole.Entities; public class Policy : ITableObject { diff --git a/src/Core/Enums/PolicyType.cs b/src/Core/AdminConsole/Enums/PolicyType.cs similarity index 89% rename from src/Core/Enums/PolicyType.cs rename to src/Core/AdminConsole/Enums/PolicyType.cs index 30dac3d917..583d1187e8 100644 --- a/src/Core/Enums/PolicyType.cs +++ b/src/Core/AdminConsole/Enums/PolicyType.cs @@ -1,4 +1,4 @@ -namespace Bit.Core.Enums; +namespace Bit.Core.AdminConsole.Enums; public enum PolicyType : byte { diff --git a/src/Core/Models/Api/Response/PolicyResponseModel.cs b/src/Core/AdminConsole/Models/Api/Response/PolicyResponseModel.cs similarity index 83% rename from src/Core/Models/Api/Response/PolicyResponseModel.cs rename to src/Core/AdminConsole/Models/Api/Response/PolicyResponseModel.cs index 997e918d09..7ef6b15737 100644 --- a/src/Core/Models/Api/Response/PolicyResponseModel.cs +++ b/src/Core/AdminConsole/Models/Api/Response/PolicyResponseModel.cs @@ -1,8 +1,9 @@ using System.Text.Json; -using Bit.Core.Entities; -using Bit.Core.Enums; +using Bit.Core.AdminConsole.Entities; +using Bit.Core.AdminConsole.Enums; +using Bit.Core.Models.Api; -namespace Bit.Core.Models.Api.Response; +namespace Bit.Core.AdminConsole.Models.Api.Response; public class PolicyResponseModel : ResponseModel { diff --git a/src/Core/Models/Data/Organizations/Policies/IPolicyDataModel.cs b/src/Core/AdminConsole/Models/Data/Organizations/Policies/IPolicyDataModel.cs similarity index 100% rename from src/Core/Models/Data/Organizations/Policies/IPolicyDataModel.cs rename to src/Core/AdminConsole/Models/Data/Organizations/Policies/IPolicyDataModel.cs diff --git a/src/Core/Models/Data/Organizations/Policies/MasterPasswordPolicyData.cs b/src/Core/AdminConsole/Models/Data/Organizations/Policies/MasterPasswordPolicyData.cs similarity index 92% rename from src/Core/Models/Data/Organizations/Policies/MasterPasswordPolicyData.cs rename to src/Core/AdminConsole/Models/Data/Organizations/Policies/MasterPasswordPolicyData.cs index 30294620bf..1ace6204df 100644 --- a/src/Core/Models/Data/Organizations/Policies/MasterPasswordPolicyData.cs +++ b/src/Core/AdminConsole/Models/Data/Organizations/Policies/MasterPasswordPolicyData.cs @@ -1,4 +1,6 @@ -namespace Bit.Core.Models.Data.Organizations.Policies; +using Bit.Core.Models.Data.Organizations.Policies; + +namespace Bit.Core.AdminConsole.Models.Data.Organizations.Policies; public class MasterPasswordPolicyData : IPolicyDataModel { diff --git a/src/Core/Models/Data/Organizations/Policies/ResetPasswordDataModel.cs b/src/Core/AdminConsole/Models/Data/Organizations/Policies/ResetPasswordDataModel.cs similarity index 64% rename from src/Core/Models/Data/Organizations/Policies/ResetPasswordDataModel.cs rename to src/Core/AdminConsole/Models/Data/Organizations/Policies/ResetPasswordDataModel.cs index 1931cc5b79..e3a921d87c 100644 --- a/src/Core/Models/Data/Organizations/Policies/ResetPasswordDataModel.cs +++ b/src/Core/AdminConsole/Models/Data/Organizations/Policies/ResetPasswordDataModel.cs @@ -1,6 +1,7 @@ using System.ComponentModel.DataAnnotations; +using Bit.Core.Models.Data.Organizations.Policies; -namespace Bit.Core.Models.Data.Organizations.Policies; +namespace Bit.Core.AdminConsole.Models.Data.Organizations.Policies; public class ResetPasswordDataModel : IPolicyDataModel { diff --git a/src/Core/Models/Data/Organizations/Policies/SendOptionsPolicyData.cs b/src/Core/AdminConsole/Models/Data/Organizations/Policies/SendOptionsPolicyData.cs similarity index 62% rename from src/Core/Models/Data/Organizations/Policies/SendOptionsPolicyData.cs rename to src/Core/AdminConsole/Models/Data/Organizations/Policies/SendOptionsPolicyData.cs index aa9f651665..903d63176d 100644 --- a/src/Core/Models/Data/Organizations/Policies/SendOptionsPolicyData.cs +++ b/src/Core/AdminConsole/Models/Data/Organizations/Policies/SendOptionsPolicyData.cs @@ -1,6 +1,7 @@ using System.ComponentModel.DataAnnotations; +using Bit.Core.Models.Data.Organizations.Policies; -namespace Bit.Core.Models.Data.Organizations.Policies; +namespace Bit.Core.AdminConsole.Models.Data.Organizations.Policies; public class SendOptionsPolicyData : IPolicyDataModel { diff --git a/src/Core/Repositories/IPolicyRepository.cs b/src/Core/AdminConsole/Repositories/IPolicyRepository.cs similarity index 66% rename from src/Core/Repositories/IPolicyRepository.cs rename to src/Core/AdminConsole/Repositories/IPolicyRepository.cs index 389d116c40..6050a7f69f 100644 --- a/src/Core/Repositories/IPolicyRepository.cs +++ b/src/Core/AdminConsole/Repositories/IPolicyRepository.cs @@ -1,7 +1,8 @@ -using Bit.Core.Entities; -using Bit.Core.Enums; +using Bit.Core.AdminConsole.Entities; +using Bit.Core.AdminConsole.Enums; +using Bit.Core.Repositories; -namespace Bit.Core.Repositories; +namespace Bit.Core.AdminConsole.Repositories; public interface IPolicyRepository : IRepository { diff --git a/src/Core/Services/IPolicyService.cs b/src/Core/AdminConsole/Services/IPolicyService.cs similarity index 77% rename from src/Core/Services/IPolicyService.cs rename to src/Core/AdminConsole/Services/IPolicyService.cs index 51867ec966..e2f2fa7942 100644 --- a/src/Core/Services/IPolicyService.cs +++ b/src/Core/AdminConsole/Services/IPolicyService.cs @@ -1,9 +1,12 @@ -using Bit.Core.Entities; +using Bit.Core.AdminConsole.Entities; +using Bit.Core.AdminConsole.Enums; +using Bit.Core.AdminConsole.Models.Data.Organizations.Policies; +using Bit.Core.Entities; using Bit.Core.Enums; using Bit.Core.Models.Data.Organizations.OrganizationUsers; -using Bit.Core.Models.Data.Organizations.Policies; +using Bit.Core.Services; -namespace Bit.Core.Services; +namespace Bit.Core.AdminConsole.Services; public interface IPolicyService { diff --git a/src/Core/Services/Implementations/PolicyService.cs b/src/Core/AdminConsole/Services/Implementations/PolicyService.cs similarity index 93% rename from src/Core/Services/Implementations/PolicyService.cs rename to src/Core/AdminConsole/Services/Implementations/PolicyService.cs index 2c9b6c73e1..4726de0160 100644 --- a/src/Core/Services/Implementations/PolicyService.cs +++ b/src/Core/AdminConsole/Services/Implementations/PolicyService.cs @@ -1,14 +1,18 @@ -using Bit.Core.Auth.Enums; +using Bit.Core.AdminConsole.Entities; +using Bit.Core.AdminConsole.Enums; +using Bit.Core.AdminConsole.Models.Data.Organizations.Policies; +using Bit.Core.AdminConsole.Repositories; +using Bit.Core.Auth.Enums; using Bit.Core.Auth.Repositories; using Bit.Core.Entities; using Bit.Core.Enums; using Bit.Core.Exceptions; using Bit.Core.Models.Data.Organizations.OrganizationUsers; -using Bit.Core.Models.Data.Organizations.Policies; using Bit.Core.Repositories; +using Bit.Core.Services; using Bit.Core.Settings; -namespace Bit.Core.Services; +namespace Bit.Core.AdminConsole.Services.Implementations; public class PolicyService : IPolicyService { @@ -114,12 +118,12 @@ public class PolicyService : IPolicyService var orgUsers = await _organizationUserRepository.GetManyDetailsByOrganizationAsync( policy.OrganizationId); var removableOrgUsers = orgUsers.Where(ou => - ou.Status != Enums.OrganizationUserStatusType.Invited && ou.Status != Enums.OrganizationUserStatusType.Revoked && - ou.Type != Enums.OrganizationUserType.Owner && ou.Type != Enums.OrganizationUserType.Admin && + ou.Status != OrganizationUserStatusType.Invited && ou.Status != OrganizationUserStatusType.Revoked && + ou.Type != OrganizationUserType.Owner && ou.Type != OrganizationUserType.Admin && ou.UserId != savingUserId); switch (policy.Type) { - case Enums.PolicyType.TwoFactorAuthentication: + case PolicyType.TwoFactorAuthentication: foreach (var orgUser in removableOrgUsers) { if (!await userService.TwoFactorIsEnabledAsync(orgUser)) @@ -131,7 +135,7 @@ public class PolicyService : IPolicyService } } break; - case Enums.PolicyType.SingleOrg: + case PolicyType.SingleOrg: var userOrgs = await _organizationUserRepository.GetManyByManyUsersAsync( removableOrgUsers.Select(ou => ou.UserId.Value)); foreach (var orgUser in removableOrgUsers) @@ -154,7 +158,7 @@ public class PolicyService : IPolicyService } policy.RevisionDate = now; await _policyRepository.UpsertAsync(policy); - await _eventService.LogPolicyEventAsync(policy, Enums.EventType.Policy_Updated); + await _eventService.LogPolicyEventAsync(policy, EventType.Policy_Updated); } public async Task GetMasterPasswordPolicyForUserAsync(User user) diff --git a/src/Core/Auth/Services/IEmergencyAccessService.cs b/src/Core/Auth/Services/IEmergencyAccessService.cs index d8abedb37f..2c94632510 100644 --- a/src/Core/Auth/Services/IEmergencyAccessService.cs +++ b/src/Core/Auth/Services/IEmergencyAccessService.cs @@ -1,4 +1,5 @@ -using Bit.Core.Auth.Entities; +using Bit.Core.AdminConsole.Entities; +using Bit.Core.Auth.Entities; using Bit.Core.Auth.Enums; using Bit.Core.Auth.Models.Data; using Bit.Core.Entities; diff --git a/src/Core/Auth/Services/Implementations/EmergencyAccessService.cs b/src/Core/Auth/Services/Implementations/EmergencyAccessService.cs index c992bb9f13..98db32bbdd 100644 --- a/src/Core/Auth/Services/Implementations/EmergencyAccessService.cs +++ b/src/Core/Auth/Services/Implementations/EmergencyAccessService.cs @@ -1,4 +1,6 @@ -using Bit.Core.Auth.Entities; +using Bit.Core.AdminConsole.Entities; +using Bit.Core.AdminConsole.Repositories; +using Bit.Core.Auth.Entities; using Bit.Core.Auth.Enums; using Bit.Core.Auth.Models; using Bit.Core.Auth.Models.Business.Tokenables; diff --git a/src/Core/Auth/Services/Implementations/SsoConfigService.cs b/src/Core/Auth/Services/Implementations/SsoConfigService.cs index a7e4784f49..aac77613f6 100644 --- a/src/Core/Auth/Services/Implementations/SsoConfigService.cs +++ b/src/Core/Auth/Services/Implementations/SsoConfigService.cs @@ -1,10 +1,14 @@ -using Bit.Core.Auth.Entities; +using Bit.Core.AdminConsole.Entities; +using Bit.Core.AdminConsole.Enums; +using Bit.Core.AdminConsole.Models.Data.Organizations.Policies; +using Bit.Core.AdminConsole.Repositories; +using Bit.Core.AdminConsole.Services; +using Bit.Core.Auth.Entities; using Bit.Core.Auth.Enums; using Bit.Core.Auth.Repositories; using Bit.Core.Entities; using Bit.Core.Enums; using Bit.Core.Exceptions; -using Bit.Core.Models.Data.Organizations.Policies; using Bit.Core.Repositories; using Bit.Core.Services; diff --git a/src/Core/Models/Api/Response/MasterPasswordPolicyResponseModel.cs b/src/Core/Models/Api/Response/MasterPasswordPolicyResponseModel.cs index 6a2753e769..0f45bc8e86 100644 --- a/src/Core/Models/Api/Response/MasterPasswordPolicyResponseModel.cs +++ b/src/Core/Models/Api/Response/MasterPasswordPolicyResponseModel.cs @@ -1,4 +1,4 @@ -using Bit.Core.Models.Data.Organizations.Policies; +using Bit.Core.AdminConsole.Models.Data.Organizations.Policies; namespace Bit.Core.Models.Api.Response; diff --git a/src/Core/Models/Data/Organizations/OrganizationUsers/OrganizationUserPolicyDetails.cs b/src/Core/Models/Data/Organizations/OrganizationUsers/OrganizationUserPolicyDetails.cs index 1ae93ccf53..84939ecf79 100644 --- a/src/Core/Models/Data/Organizations/OrganizationUsers/OrganizationUserPolicyDetails.cs +++ b/src/Core/Models/Data/Organizations/OrganizationUsers/OrganizationUserPolicyDetails.cs @@ -1,4 +1,5 @@ -using Bit.Core.Enums; +using Bit.Core.AdminConsole.Enums; +using Bit.Core.Enums; namespace Bit.Core.Models.Data.Organizations.OrganizationUsers; diff --git a/src/Core/Models/Data/Organizations/SelfHostedOrganizationDetails.cs b/src/Core/Models/Data/Organizations/SelfHostedOrganizationDetails.cs index d501263f4e..b0498e6c89 100644 --- a/src/Core/Models/Data/Organizations/SelfHostedOrganizationDetails.cs +++ b/src/Core/Models/Data/Organizations/SelfHostedOrganizationDetails.cs @@ -1,4 +1,6 @@ -using Bit.Core.AdminConsole.Models.OrganizationConnectionConfigs; +using Bit.Core.AdminConsole.Entities; +using Bit.Core.AdminConsole.Enums; +using Bit.Core.AdminConsole.Models.OrganizationConnectionConfigs; using Bit.Core.Auth.Entities; using Bit.Core.Auth.Enums; using Bit.Core.Entities; diff --git a/src/Core/OrganizationFeatures/OrganizationSubscriptions/UpgradeOrganizationPlanCommand.cs b/src/Core/OrganizationFeatures/OrganizationSubscriptions/UpgradeOrganizationPlanCommand.cs index b9e3c74da7..8486807c46 100644 --- a/src/Core/OrganizationFeatures/OrganizationSubscriptions/UpgradeOrganizationPlanCommand.cs +++ b/src/Core/OrganizationFeatures/OrganizationSubscriptions/UpgradeOrganizationPlanCommand.cs @@ -1,4 +1,5 @@ -using Bit.Core.AdminConsole.Models.OrganizationConnectionConfigs; +using Bit.Core.AdminConsole.Enums; +using Bit.Core.AdminConsole.Models.OrganizationConnectionConfigs; using Bit.Core.AdminConsole.Repositories; using Bit.Core.Auth.Enums; using Bit.Core.Auth.Repositories; diff --git a/src/Core/OrganizationFeatures/OrganizationUsers/AcceptOrgUserCommand.cs b/src/Core/OrganizationFeatures/OrganizationUsers/AcceptOrgUserCommand.cs index 5baff54634..e0c2bada48 100644 --- a/src/Core/OrganizationFeatures/OrganizationUsers/AcceptOrgUserCommand.cs +++ b/src/Core/OrganizationFeatures/OrganizationUsers/AcceptOrgUserCommand.cs @@ -1,4 +1,6 @@ -using Bit.Core.Auth.Models.Business.Tokenables; +using Bit.Core.AdminConsole.Enums; +using Bit.Core.AdminConsole.Services; +using Bit.Core.Auth.Models.Business.Tokenables; using Bit.Core.Entities; using Bit.Core.Enums; using Bit.Core.Exceptions; diff --git a/src/Core/Repositories/IOrganizationUserRepository.cs b/src/Core/Repositories/IOrganizationUserRepository.cs index f9dfa12c2c..751bfdc4aa 100644 --- a/src/Core/Repositories/IOrganizationUserRepository.cs +++ b/src/Core/Repositories/IOrganizationUserRepository.cs @@ -1,4 +1,5 @@ -using Bit.Core.Entities; +using Bit.Core.AdminConsole.Enums; +using Bit.Core.Entities; using Bit.Core.Enums; using Bit.Core.Models.Data; using Bit.Core.Models.Data.Organizations.OrganizationUsers; diff --git a/src/Core/Services/Implementations/OrganizationService.cs b/src/Core/Services/Implementations/OrganizationService.cs index 60e2cd1f68..51caf4c316 100644 --- a/src/Core/Services/Implementations/OrganizationService.cs +++ b/src/Core/Services/Implementations/OrganizationService.cs @@ -1,10 +1,13 @@ using System.Security.Claims; using System.Text.Json; using Bit.Core.AdminConsole.Entities; +using Bit.Core.AdminConsole.Enums; using Bit.Core.AdminConsole.Enums.Provider; using Bit.Core.AdminConsole.Models.Business; +using Bit.Core.AdminConsole.Models.Data.Organizations.Policies; using Bit.Core.AdminConsole.OrganizationFeatures.OrganizationUsers.Interfaces; using Bit.Core.AdminConsole.Repositories; +using Bit.Core.AdminConsole.Services; using Bit.Core.Auth.Enums; using Bit.Core.Auth.Models.Business; using Bit.Core.Auth.Models.Business.Tokenables; @@ -15,7 +18,6 @@ using Bit.Core.Enums; using Bit.Core.Exceptions; using Bit.Core.Models.Business; using Bit.Core.Models.Data; -using Bit.Core.Models.Data.Organizations.Policies; using Bit.Core.OrganizationFeatures.OrganizationSubscriptions.Interface; using Bit.Core.Repositories; using Bit.Core.Settings; diff --git a/src/Core/Services/Implementations/UserService.cs b/src/Core/Services/Implementations/UserService.cs index 1d7f95f1f9..81ce697622 100644 --- a/src/Core/Services/Implementations/UserService.cs +++ b/src/Core/Services/Implementations/UserService.cs @@ -1,6 +1,8 @@ using System.Security.Claims; using System.Text.Json; +using Bit.Core.AdminConsole.Enums; using Bit.Core.AdminConsole.Repositories; +using Bit.Core.AdminConsole.Services; using Bit.Core.Auth.Entities; using Bit.Core.Auth.Enums; using Bit.Core.Auth.Models; diff --git a/src/Core/Tools/Services/Implementations/SendService.cs b/src/Core/Tools/Services/Implementations/SendService.cs index 1c1cfab4e6..fad941362b 100644 --- a/src/Core/Tools/Services/Implementations/SendService.cs +++ b/src/Core/Tools/Services/Implementations/SendService.cs @@ -1,9 +1,11 @@ using System.Text.Json; +using Bit.Core.AdminConsole.Enums; +using Bit.Core.AdminConsole.Models.Data.Organizations.Policies; +using Bit.Core.AdminConsole.Repositories; +using Bit.Core.AdminConsole.Services; using Bit.Core.Context; using Bit.Core.Entities; -using Bit.Core.Enums; using Bit.Core.Exceptions; -using Bit.Core.Models.Data.Organizations.Policies; using Bit.Core.Repositories; using Bit.Core.Services; using Bit.Core.Settings; diff --git a/src/Core/Vault/Services/Implementations/CipherService.cs b/src/Core/Vault/Services/Implementations/CipherService.cs index 82a6753a9d..72437ec1b6 100644 --- a/src/Core/Vault/Services/Implementations/CipherService.cs +++ b/src/Core/Vault/Services/Implementations/CipherService.cs @@ -1,4 +1,6 @@ using System.Text.Json; +using Bit.Core.AdminConsole.Enums; +using Bit.Core.AdminConsole.Services; using Bit.Core.Context; using Bit.Core.Entities; using Bit.Core.Enums; diff --git a/src/Identity/IdentityServer/BaseRequestValidator.cs b/src/Identity/IdentityServer/BaseRequestValidator.cs index 40db804be3..0f319fbc84 100644 --- a/src/Identity/IdentityServer/BaseRequestValidator.cs +++ b/src/Identity/IdentityServer/BaseRequestValidator.cs @@ -3,6 +3,8 @@ using System.Reflection; using System.Security.Claims; using System.Text.Json; using Bit.Core; +using Bit.Core.AdminConsole.Enums; +using Bit.Core.AdminConsole.Services; using Bit.Core.Auth.Entities; using Bit.Core.Auth.Enums; using Bit.Core.Auth.Identity; diff --git a/src/Identity/IdentityServer/CustomTokenRequestValidator.cs b/src/Identity/IdentityServer/CustomTokenRequestValidator.cs index 0ebd6f8ae7..4710184f78 100644 --- a/src/Identity/IdentityServer/CustomTokenRequestValidator.cs +++ b/src/Identity/IdentityServer/CustomTokenRequestValidator.cs @@ -1,4 +1,5 @@ using System.Security.Claims; +using Bit.Core.AdminConsole.Services; using Bit.Core.Auth.Identity; using Bit.Core.Auth.Models.Api.Response; using Bit.Core.Auth.Models.Business.Tokenables; diff --git a/src/Identity/IdentityServer/ResourceOwnerPasswordValidator.cs b/src/Identity/IdentityServer/ResourceOwnerPasswordValidator.cs index 8db6aab7cd..1d71508519 100644 --- a/src/Identity/IdentityServer/ResourceOwnerPasswordValidator.cs +++ b/src/Identity/IdentityServer/ResourceOwnerPasswordValidator.cs @@ -1,5 +1,6 @@ using System.Security.Claims; using Bit.Core; +using Bit.Core.AdminConsole.Services; using Bit.Core.Auth.Identity; using Bit.Core.Auth.Models.Business.Tokenables; using Bit.Core.Auth.Repositories; diff --git a/src/Identity/IdentityServer/WebAuthnGrantValidator.cs b/src/Identity/IdentityServer/WebAuthnGrantValidator.cs index a959b63840..f11ebea111 100644 --- a/src/Identity/IdentityServer/WebAuthnGrantValidator.cs +++ b/src/Identity/IdentityServer/WebAuthnGrantValidator.cs @@ -1,6 +1,7 @@ using System.Security.Claims; using System.Text.Json; using Bit.Core; +using Bit.Core.AdminConsole.Services; using Bit.Core.Auth.Enums; using Bit.Core.Auth.Identity; using Bit.Core.Auth.Models.Business.Tokenables; diff --git a/src/Infrastructure.Dapper/Repositories/PolicyRepository.cs b/src/Infrastructure.Dapper/AdminConsole/Repositories/PolicyRepository.cs similarity index 89% rename from src/Infrastructure.Dapper/Repositories/PolicyRepository.cs rename to src/Infrastructure.Dapper/AdminConsole/Repositories/PolicyRepository.cs index 8329a8a82b..1a59c501af 100644 --- a/src/Infrastructure.Dapper/Repositories/PolicyRepository.cs +++ b/src/Infrastructure.Dapper/AdminConsole/Repositories/PolicyRepository.cs @@ -1,12 +1,13 @@ using System.Data; -using Bit.Core.Entities; -using Bit.Core.Enums; -using Bit.Core.Repositories; +using Bit.Core.AdminConsole.Entities; +using Bit.Core.AdminConsole.Enums; +using Bit.Core.AdminConsole.Repositories; using Bit.Core.Settings; +using Bit.Infrastructure.Dapper.Repositories; using Dapper; using Microsoft.Data.SqlClient; -namespace Bit.Infrastructure.Dapper.Repositories; +namespace Bit.Infrastructure.Dapper.AdminConsole.Repositories; public class PolicyRepository : Repository, IPolicyRepository { diff --git a/src/Infrastructure.Dapper/Repositories/OrganizationRepository.cs b/src/Infrastructure.Dapper/Repositories/OrganizationRepository.cs index 9329e23790..467fb8f8a8 100644 --- a/src/Infrastructure.Dapper/Repositories/OrganizationRepository.cs +++ b/src/Infrastructure.Dapper/Repositories/OrganizationRepository.cs @@ -1,4 +1,5 @@ using System.Data; +using Bit.Core.AdminConsole.Entities; using Bit.Core.Auth.Entities; using Bit.Core.Entities; using Bit.Core.Models.Data.Organizations; diff --git a/src/Infrastructure.Dapper/Repositories/OrganizationUserRepository.cs b/src/Infrastructure.Dapper/Repositories/OrganizationUserRepository.cs index 2a2f0e340a..517b737ee3 100644 --- a/src/Infrastructure.Dapper/Repositories/OrganizationUserRepository.cs +++ b/src/Infrastructure.Dapper/Repositories/OrganizationUserRepository.cs @@ -1,6 +1,7 @@ using System.Data; using System.Text.Json; using Bit.Core.AdminConsole.Entities; +using Bit.Core.AdminConsole.Enums; using Bit.Core.Entities; using Bit.Core.Enums; using Bit.Core.Models.Data; diff --git a/src/Infrastructure.EntityFramework/Models/Policy.cs b/src/Infrastructure.EntityFramework/AdminConsole/Models/Policy.cs similarity index 63% rename from src/Infrastructure.EntityFramework/Models/Policy.cs rename to src/Infrastructure.EntityFramework/AdminConsole/Models/Policy.cs index 22b17c6f6d..d5213f8827 100644 --- a/src/Infrastructure.EntityFramework/Models/Policy.cs +++ b/src/Infrastructure.EntityFramework/AdminConsole/Models/Policy.cs @@ -2,7 +2,7 @@ namespace Bit.Infrastructure.EntityFramework.Models; -public class Policy : Core.Entities.Policy +public class Policy : Core.AdminConsole.Entities.Policy { public virtual Organization Organization { get; set; } } @@ -11,6 +11,6 @@ public class PolicyMapperProfile : Profile { public PolicyMapperProfile() { - CreateMap().ReverseMap(); + CreateMap().ReverseMap(); } } diff --git a/src/Infrastructure.EntityFramework/Repositories/PolicyRepository.cs b/src/Infrastructure.EntityFramework/AdminConsole/Repositories/PolicyRepository.cs similarity index 55% rename from src/Infrastructure.EntityFramework/Repositories/PolicyRepository.cs rename to src/Infrastructure.EntityFramework/AdminConsole/Repositories/PolicyRepository.cs index 5dfe2b3bbb..ffcb7bdd19 100644 --- a/src/Infrastructure.EntityFramework/Repositories/PolicyRepository.cs +++ b/src/Infrastructure.EntityFramework/AdminConsole/Repositories/PolicyRepository.cs @@ -1,31 +1,33 @@ using AutoMapper; -using Bit.Core.Enums; -using Bit.Core.Repositories; +using Bit.Core.AdminConsole.Enums; +using Bit.Core.AdminConsole.Repositories; +using Bit.Infrastructure.EntityFramework.AdminConsole.Repositories.Queries; using Bit.Infrastructure.EntityFramework.Models; -using Bit.Infrastructure.EntityFramework.Repositories.Queries; +using Bit.Infrastructure.EntityFramework.Repositories; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.DependencyInjection; +using AdminConsoleEntities = Bit.Core.AdminConsole.Entities; -namespace Bit.Infrastructure.EntityFramework.Repositories; +namespace Bit.Infrastructure.EntityFramework.AdminConsole.Repositories; -public class PolicyRepository : Repository, IPolicyRepository +public class PolicyRepository : Repository, IPolicyRepository { public PolicyRepository(IServiceScopeFactory serviceScopeFactory, IMapper mapper) : base(serviceScopeFactory, mapper, (DatabaseContext context) => context.Policies) { } - public async Task GetByOrganizationIdTypeAsync(Guid organizationId, PolicyType type) + public async Task GetByOrganizationIdTypeAsync(Guid organizationId, PolicyType type) { using (var scope = ServiceScopeFactory.CreateScope()) { var dbContext = GetDatabaseContext(scope); var results = await dbContext.Policies .FirstOrDefaultAsync(p => p.OrganizationId == organizationId && p.Type == type); - return Mapper.Map(results); + return Mapper.Map(results); } } - public async Task> GetManyByOrganizationIdAsync(Guid organizationId) + public async Task> GetManyByOrganizationIdAsync(Guid organizationId) { using (var scope = ServiceScopeFactory.CreateScope()) { @@ -33,11 +35,11 @@ public class PolicyRepository : Repository, var results = await dbContext.Policies .Where(p => p.OrganizationId == organizationId) .ToListAsync(); - return Mapper.Map>(results); + return Mapper.Map>(results); } } - public async Task> GetManyByUserIdAsync(Guid userId) + public async Task> GetManyByUserIdAsync(Guid userId) { using (var scope = ServiceScopeFactory.CreateScope()) { @@ -45,7 +47,7 @@ public class PolicyRepository : Repository, var query = new PolicyReadByUserIdQuery(userId); var results = await query.Run(dbContext).ToListAsync(); - return Mapper.Map>(results); + return Mapper.Map>(results); } } } diff --git a/src/Infrastructure.EntityFramework/Repositories/Queries/PolicyReadByUserIdQuery.cs b/src/Infrastructure.EntityFramework/AdminConsole/Repositories/Queries/PolicyReadByUserIdQuery.cs similarity index 80% rename from src/Infrastructure.EntityFramework/Repositories/Queries/PolicyReadByUserIdQuery.cs rename to src/Infrastructure.EntityFramework/AdminConsole/Repositories/Queries/PolicyReadByUserIdQuery.cs index 9da530b01b..fc9e067999 100644 --- a/src/Infrastructure.EntityFramework/Repositories/Queries/PolicyReadByUserIdQuery.cs +++ b/src/Infrastructure.EntityFramework/AdminConsole/Repositories/Queries/PolicyReadByUserIdQuery.cs @@ -1,7 +1,9 @@ using Bit.Core.Enums; using Bit.Infrastructure.EntityFramework.Models; +using Bit.Infrastructure.EntityFramework.Repositories; +using Bit.Infrastructure.EntityFramework.Repositories.Queries; -namespace Bit.Infrastructure.EntityFramework.Repositories.Queries; +namespace Bit.Infrastructure.EntityFramework.AdminConsole.Repositories.Queries; public class PolicyReadByUserIdQuery : IQuery { diff --git a/src/Infrastructure.EntityFramework/Repositories/OrganizationUserRepository.cs b/src/Infrastructure.EntityFramework/Repositories/OrganizationUserRepository.cs index 5e005a5593..ed86bae040 100644 --- a/src/Infrastructure.EntityFramework/Repositories/OrganizationUserRepository.cs +++ b/src/Infrastructure.EntityFramework/Repositories/OrganizationUserRepository.cs @@ -1,4 +1,5 @@ using AutoMapper; +using Bit.Core.AdminConsole.Enums; using Bit.Core.Enums; using Bit.Core.Models.Data; using Bit.Core.Models.Data.Organizations.OrganizationUsers; diff --git a/test/Api.Test/AdminConsole/Controllers/OrganizationUsersControllerTests.cs b/test/Api.Test/AdminConsole/Controllers/OrganizationUsersControllerTests.cs index b62027919c..baf23bb9c1 100644 --- a/test/Api.Test/AdminConsole/Controllers/OrganizationUsersControllerTests.cs +++ b/test/Api.Test/AdminConsole/Controllers/OrganizationUsersControllerTests.cs @@ -1,7 +1,10 @@ using Bit.Api.AdminConsole.Controllers; using Bit.Api.AdminConsole.Models.Request.Organizations; +using Bit.Core.AdminConsole.Entities; +using Bit.Core.AdminConsole.Enums; +using Bit.Core.AdminConsole.Models.Data.Organizations.Policies; +using Bit.Core.AdminConsole.Repositories; using Bit.Core.Entities; -using Bit.Core.Models.Data.Organizations.Policies; using Bit.Core.OrganizationFeatures.OrganizationUsers.Interfaces; using Bit.Core.Repositories; using Bit.Core.Services; @@ -82,7 +85,7 @@ public class OrganizationUsersControllerTests }; sutProvider.GetDependency().GetUserByPrincipalAsync(default).ReturnsForAnyArgs(user); sutProvider.GetDependency().GetByOrganizationIdTypeAsync(orgId, - Core.Enums.PolicyType.ResetPassword).Returns(policy); + PolicyType.ResetPassword).Returns(policy); await sutProvider.Sut.Accept(orgId, orgUserId, model); diff --git a/test/Api.Test/Auth/Controllers/WebAuthnControllerTests.cs b/test/Api.Test/Auth/Controllers/WebAuthnControllerTests.cs index 26265f5c41..c8d2ea905c 100644 --- a/test/Api.Test/Auth/Controllers/WebAuthnControllerTests.cs +++ b/test/Api.Test/Auth/Controllers/WebAuthnControllerTests.cs @@ -1,9 +1,10 @@ using Bit.Api.Auth.Controllers; using Bit.Api.Auth.Models.Request.Accounts; using Bit.Api.Auth.Models.Request.Webauthn; +using Bit.Core.AdminConsole.Enums; +using Bit.Core.AdminConsole.Services; using Bit.Core.Auth.Models.Business.Tokenables; using Bit.Core.Entities; -using Bit.Core.Enums; using Bit.Core.Exceptions; using Bit.Core.Services; using Bit.Core.Tokens; diff --git a/test/Api.Test/Controllers/AccountsControllerTests.cs b/test/Api.Test/Controllers/AccountsControllerTests.cs index aa3cca0b4f..d6e8cacbe6 100644 --- a/test/Api.Test/Controllers/AccountsControllerTests.cs +++ b/test/Api.Test/Controllers/AccountsControllerTests.cs @@ -2,6 +2,7 @@ using Bit.Api.Auth.Models.Request.Accounts; using Bit.Api.Controllers; using Bit.Core.AdminConsole.Repositories; +using Bit.Core.AdminConsole.Services; using Bit.Core.Auth.Models.Api.Request.Accounts; using Bit.Core.Auth.Services; using Bit.Core.Auth.UserFeatures.UserKey; diff --git a/test/Api.Test/Controllers/PoliciesControllerTests.cs b/test/Api.Test/Controllers/PoliciesControllerTests.cs index 0d2f004b17..ec69104e52 100644 --- a/test/Api.Test/Controllers/PoliciesControllerTests.cs +++ b/test/Api.Test/Controllers/PoliciesControllerTests.cs @@ -1,10 +1,12 @@ using System.Security.Claims; using System.Text.Json; using Bit.Api.AdminConsole.Controllers; +using Bit.Core.AdminConsole.Entities; +using Bit.Core.AdminConsole.Enums; +using Bit.Core.AdminConsole.Models.Data.Organizations.Policies; +using Bit.Core.AdminConsole.Repositories; using Bit.Core.Entities; -using Bit.Core.Enums; using Bit.Core.Exceptions; -using Bit.Core.Models.Data.Organizations.Policies; using Bit.Core.Repositories; using Bit.Core.Services; using Bit.Test.Common.AutoFixture; diff --git a/test/Api.Test/Vault/Controllers/SyncControllerTests.cs b/test/Api.Test/Vault/Controllers/SyncControllerTests.cs index e1a9c15629..2f29ba6109 100644 --- a/test/Api.Test/Vault/Controllers/SyncControllerTests.cs +++ b/test/Api.Test/Vault/Controllers/SyncControllerTests.cs @@ -3,6 +3,7 @@ using System.Text.Json; using AutoFixture; using Bit.Api.Vault.Controllers; using Bit.Api.Vault.Models.Response; +using Bit.Core.AdminConsole.Entities; using Bit.Core.AdminConsole.Enums.Provider; using Bit.Core.AdminConsole.Models.Data.Provider; using Bit.Core.AdminConsole.Repositories; diff --git a/test/Core.Test/AutoFixture/PolicyFixtures.cs b/test/Core.Test/AdminConsole/AutoFixture/PolicyFixtures.cs similarity index 86% rename from test/Core.Test/AutoFixture/PolicyFixtures.cs rename to test/Core.Test/AdminConsole/AutoFixture/PolicyFixtures.cs index fb8109baf9..f70fd579e3 100644 --- a/test/Core.Test/AutoFixture/PolicyFixtures.cs +++ b/test/Core.Test/AdminConsole/AutoFixture/PolicyFixtures.cs @@ -1,10 +1,10 @@ using System.Reflection; using AutoFixture; using AutoFixture.Xunit2; -using Bit.Core.Entities; -using Bit.Core.Enums; +using Bit.Core.AdminConsole.Entities; +using Bit.Core.AdminConsole.Enums; -namespace Bit.Core.Test.AutoFixture.PolicyFixtures; +namespace Bit.Core.Test.AdminConsole.AutoFixture; internal class PolicyCustomization : ICustomization { diff --git a/test/Core.Test/Services/PolicyServiceTests.cs b/test/Core.Test/AdminConsole/Services/PolicyServiceTests.cs similarity index 93% rename from test/Core.Test/Services/PolicyServiceTests.cs rename to test/Core.Test/AdminConsole/Services/PolicyServiceTests.cs index aedc3cc587..65e0815cc9 100644 --- a/test/Core.Test/Services/PolicyServiceTests.cs +++ b/test/Core.Test/AdminConsole/Services/PolicyServiceTests.cs @@ -1,4 +1,9 @@ -using Bit.Core.Auth.Entities; +using Bit.Core.AdminConsole.Entities; +using Bit.Core.AdminConsole.Enums; +using Bit.Core.AdminConsole.Models.Data.Organizations.Policies; +using Bit.Core.AdminConsole.Repositories; +using Bit.Core.AdminConsole.Services.Implementations; +using Bit.Core.Auth.Entities; using Bit.Core.Auth.Enums; using Bit.Core.Auth.Models.Data; using Bit.Core.Auth.Repositories; @@ -6,24 +11,23 @@ using Bit.Core.Entities; using Bit.Core.Enums; using Bit.Core.Exceptions; using Bit.Core.Models.Data.Organizations.OrganizationUsers; -using Bit.Core.Models.Data.Organizations.Policies; using Bit.Core.Repositories; using Bit.Core.Services; using Bit.Test.Common.AutoFixture; using Bit.Test.Common.AutoFixture.Attributes; using NSubstitute; using Xunit; +using AdminConsoleFixtures = Bit.Core.Test.AdminConsole.AutoFixture; using GlobalSettings = Bit.Core.Settings.GlobalSettings; -using PolicyFixtures = Bit.Core.Test.AutoFixture.PolicyFixtures; -namespace Bit.Core.Test.Services; +namespace Bit.Core.Test.AdminConsole.Services; [SutProviderCustomize] public class PolicyServiceTests { [Theory, BitAutoData] public async Task SaveAsync_OrganizationDoesNotExist_ThrowsBadRequest( - [PolicyFixtures.Policy(PolicyType.DisableSend)] Policy policy, SutProvider sutProvider) + [AdminConsoleFixtures.Policy(PolicyType.DisableSend)] Policy policy, SutProvider sutProvider) { SetupOrg(sutProvider, policy.OrganizationId, null); @@ -46,7 +50,7 @@ public class PolicyServiceTests [Theory, BitAutoData] public async Task SaveAsync_OrganizationCannotUsePolicies_ThrowsBadRequest( - [PolicyFixtures.Policy(PolicyType.DisableSend)] Policy policy, SutProvider sutProvider) + [AdminConsoleFixtures.Policy(PolicyType.DisableSend)] Policy policy, SutProvider sutProvider) { var orgId = Guid.NewGuid(); @@ -74,7 +78,7 @@ public class PolicyServiceTests [Theory, BitAutoData] public async Task SaveAsync_SingleOrg_RequireSsoEnabled_ThrowsBadRequest( - [PolicyFixtures.Policy(PolicyType.SingleOrg)] Policy policy, SutProvider sutProvider) + [AdminConsoleFixtures.Policy(PolicyType.SingleOrg)] Policy policy, SutProvider sutProvider) { policy.Enabled = false; @@ -106,7 +110,7 @@ public class PolicyServiceTests } [Theory, BitAutoData] - public async Task SaveAsync_SingleOrg_VaultTimeoutEnabled_ThrowsBadRequest([PolicyFixtures.Policy(Enums.PolicyType.SingleOrg)] Policy policy, SutProvider sutProvider) + public async Task SaveAsync_SingleOrg_VaultTimeoutEnabled_ThrowsBadRequest([AdminConsoleFixtures.Policy(PolicyType.SingleOrg)] Policy policy, SutProvider sutProvider) { policy.Enabled = false; @@ -117,7 +121,7 @@ public class PolicyServiceTests }); sutProvider.GetDependency() - .GetByOrganizationIdTypeAsync(policy.OrganizationId, Enums.PolicyType.MaximumVaultTimeout) + .GetByOrganizationIdTypeAsync(policy.OrganizationId, PolicyType.MaximumVaultTimeout) .Returns(new Policy { Enabled = true }); var badRequestException = await Assert.ThrowsAsync( @@ -137,7 +141,7 @@ public class PolicyServiceTests [BitAutoData(PolicyType.SingleOrg)] [BitAutoData(PolicyType.RequireSso)] public async Task SaveAsync_PolicyRequiredByKeyConnector_DisablePolicy_ThrowsBadRequest( - Enums.PolicyType policyType, + PolicyType policyType, Policy policy, SutProvider sutProvider) { @@ -173,7 +177,7 @@ public class PolicyServiceTests [Theory, BitAutoData] public async Task SaveAsync_RequireSsoPolicy_NotEnabled_ThrowsBadRequestAsync( - [PolicyFixtures.Policy(Enums.PolicyType.RequireSso)] Policy policy, SutProvider sutProvider) + [AdminConsoleFixtures.Policy(PolicyType.RequireSso)] Policy policy, SutProvider sutProvider) { policy.Enabled = true; @@ -206,7 +210,7 @@ public class PolicyServiceTests [Theory, BitAutoData] public async Task SaveAsync_NewPolicy_Created( - [PolicyFixtures.Policy(PolicyType.ResetPassword)] Policy policy, SutProvider sutProvider) + [AdminConsoleFixtures.Policy(PolicyType.ResetPassword)] Policy policy, SutProvider sutProvider) { policy.Id = default; policy.Data = null; @@ -218,7 +222,7 @@ public class PolicyServiceTests }); sutProvider.GetDependency() - .GetByOrganizationIdTypeAsync(policy.OrganizationId, Enums.PolicyType.SingleOrg) + .GetByOrganizationIdTypeAsync(policy.OrganizationId, PolicyType.SingleOrg) .Returns(Task.FromResult(new Policy { Enabled = true })); var utcNow = DateTime.UtcNow; @@ -237,7 +241,7 @@ public class PolicyServiceTests [Theory, BitAutoData] public async Task SaveAsync_VaultTimeoutPolicy_NotEnabled_ThrowsBadRequestAsync( - [PolicyFixtures.Policy(PolicyType.MaximumVaultTimeout)] Policy policy, SutProvider sutProvider) + [AdminConsoleFixtures.Policy(PolicyType.MaximumVaultTimeout)] Policy policy, SutProvider sutProvider) { policy.Enabled = true; @@ -248,7 +252,7 @@ public class PolicyServiceTests }); sutProvider.GetDependency() - .GetByOrganizationIdTypeAsync(policy.OrganizationId, Enums.PolicyType.SingleOrg) + .GetByOrganizationIdTypeAsync(policy.OrganizationId, PolicyType.SingleOrg) .Returns(Task.FromResult(new Policy { Enabled = false })); var badRequestException = await Assert.ThrowsAsync( @@ -270,7 +274,7 @@ public class PolicyServiceTests [Theory, BitAutoData] public async Task SaveAsync_ExistingPolicy_UpdateTwoFactor( - [PolicyFixtures.Policy(PolicyType.TwoFactorAuthentication)] Policy policy, SutProvider sutProvider) + [AdminConsoleFixtures.Policy(PolicyType.TwoFactorAuthentication)] Policy policy, SutProvider sutProvider) { // If the policy that this is updating isn't enabled then do some work now that the current one is enabled @@ -340,7 +344,7 @@ public class PolicyServiceTests [Theory, BitAutoData] public async Task SaveAsync_ExistingPolicy_UpdateSingleOrg( - [PolicyFixtures.Policy(PolicyType.TwoFactorAuthentication)] Policy policy, SutProvider sutProvider) + [AdminConsoleFixtures.Policy(PolicyType.TwoFactorAuthentication)] Policy policy, SutProvider sutProvider) { // If the policy that this is updating isn't enabled then do some work now that the current one is enabled @@ -409,7 +413,7 @@ public class PolicyServiceTests public async Task SaveAsync_ResetPasswordPolicyRequiredByTrustedDeviceEncryption_DisablePolicyOrDisableAutomaticEnrollment_ThrowsBadRequest( bool policyEnabled, bool autoEnrollEnabled, - [PolicyFixtures.Policy(PolicyType.ResetPassword)] Policy policy, + [AdminConsoleFixtures.Policy(PolicyType.ResetPassword)] Policy policy, SutProvider sutProvider) { policy.Enabled = policyEnabled; @@ -450,7 +454,7 @@ public class PolicyServiceTests [Theory, BitAutoData] public async Task SaveAsync_RequireSsoPolicyRequiredByTrustedDeviceEncryption_DisablePolicy_ThrowsBadRequest( - [PolicyFixtures.Policy(PolicyType.RequireSso)] Policy policy, + [AdminConsoleFixtures.Policy(PolicyType.RequireSso)] Policy policy, SutProvider sutProvider) { policy.Enabled = false; @@ -487,7 +491,7 @@ public class PolicyServiceTests [Theory, BitAutoData] public async Task SaveAsync_PolicyRequiredForAccountRecovery_NotEnabled_ThrowsBadRequestAsync( - [PolicyFixtures.Policy(Enums.PolicyType.ResetPassword)] Policy policy, SutProvider sutProvider) + [AdminConsoleFixtures.Policy(PolicyType.ResetPassword)] Policy policy, SutProvider sutProvider) { policy.Enabled = true; policy.SetDataModel(new ResetPasswordDataModel()); @@ -522,7 +526,7 @@ public class PolicyServiceTests [Theory, BitAutoData] public async Task SaveAsync_SingleOrg_AccountRecoveryEnabled_ThrowsBadRequest( - [PolicyFixtures.Policy(Enums.PolicyType.SingleOrg)] Policy policy, SutProvider sutProvider) + [AdminConsoleFixtures.Policy(PolicyType.SingleOrg)] Policy policy, SutProvider sutProvider) { policy.Enabled = false; @@ -533,7 +537,7 @@ public class PolicyServiceTests }); sutProvider.GetDependency() - .GetByOrganizationIdTypeAsync(policy.OrganizationId, Enums.PolicyType.ResetPassword) + .GetByOrganizationIdTypeAsync(policy.OrganizationId, PolicyType.ResetPassword) .Returns(new Policy { Enabled = true }); var badRequestException = await Assert.ThrowsAsync( diff --git a/test/Core.Test/Auth/Services/SsoConfigServiceTests.cs b/test/Core.Test/Auth/Services/SsoConfigServiceTests.cs index 7886d6f9e8..c4324ff227 100644 --- a/test/Core.Test/Auth/Services/SsoConfigServiceTests.cs +++ b/test/Core.Test/Auth/Services/SsoConfigServiceTests.cs @@ -1,4 +1,9 @@ -using Bit.Core.Auth.Entities; +using Bit.Core.AdminConsole.Entities; +using Bit.Core.AdminConsole.Enums; +using Bit.Core.AdminConsole.Models.Data.Organizations.Policies; +using Bit.Core.AdminConsole.Repositories; +using Bit.Core.AdminConsole.Services; +using Bit.Core.Auth.Entities; using Bit.Core.Auth.Enums; using Bit.Core.Auth.Models.Data; using Bit.Core.Auth.Repositories; @@ -6,7 +11,6 @@ using Bit.Core.Auth.Services; using Bit.Core.Entities; using Bit.Core.Exceptions; using Bit.Core.Models.Data.Organizations.OrganizationUsers; -using Bit.Core.Models.Data.Organizations.Policies; using Bit.Core.Repositories; using Bit.Core.Services; using Bit.Test.Common.AutoFixture; @@ -205,7 +209,7 @@ public class SsoConfigServiceTests }; sutProvider.GetDependency().GetByOrganizationIdTypeAsync( - Arg.Any(), Enums.PolicyType.SingleOrg).Returns(new Policy + Arg.Any(), PolicyType.SingleOrg).Returns(new Policy { Enabled = true }); @@ -239,7 +243,7 @@ public class SsoConfigServiceTests }; sutProvider.GetDependency().GetByOrganizationIdTypeAsync( - Arg.Any(), Arg.Any()).Returns(new Policy + Arg.Any(), Arg.Any()).Returns(new Policy { Enabled = true }); @@ -274,7 +278,7 @@ public class SsoConfigServiceTests }; sutProvider.GetDependency().GetByOrganizationIdTypeAsync( - Arg.Any(), Arg.Any()).Returns(new Policy + Arg.Any(), Arg.Any()).Returns(new Policy { Enabled = true, }); @@ -309,7 +313,7 @@ public class SsoConfigServiceTests }; sutProvider.GetDependency().GetByOrganizationIdTypeAsync( - Arg.Any(), Arg.Any()).Returns(new Policy + Arg.Any(), Arg.Any()).Returns(new Policy { Enabled = true, }); @@ -338,7 +342,7 @@ public class SsoConfigServiceTests await sutProvider.GetDependency().Received(1) .SaveAsync( - Arg.Is(t => t.Type == Enums.PolicyType.SingleOrg), + Arg.Is(t => t.Type == PolicyType.SingleOrg), Arg.Any(), Arg.Any(), null @@ -346,7 +350,7 @@ public class SsoConfigServiceTests await sutProvider.GetDependency().Received(1) .SaveAsync( - Arg.Is(t => t.Type == Enums.PolicyType.ResetPassword && t.GetDataModel().AutoEnrollEnabled), + Arg.Is(t => t.Type == PolicyType.ResetPassword && t.GetDataModel().AutoEnrollEnabled), Arg.Any(), Arg.Any(), null diff --git a/test/Core.Test/Models/Data/SelfHostedOrganizationDetailsTests.cs b/test/Core.Test/Models/Data/SelfHostedOrganizationDetailsTests.cs index a46981ee9b..4d961bef35 100644 --- a/test/Core.Test/Models/Data/SelfHostedOrganizationDetailsTests.cs +++ b/test/Core.Test/Models/Data/SelfHostedOrganizationDetailsTests.cs @@ -1,4 +1,6 @@ -using Bit.Core.AdminConsole.Models.OrganizationConnectionConfigs; +using Bit.Core.AdminConsole.Entities; +using Bit.Core.AdminConsole.Enums; +using Bit.Core.AdminConsole.Models.OrganizationConnectionConfigs; using Bit.Core.Auth.Entities; using Bit.Core.Auth.Enums; using Bit.Core.Auth.Models.Data; diff --git a/test/Core.Test/OrganizationFeatures/OrganizationUsers/AcceptOrgUserCommandTests.cs b/test/Core.Test/OrganizationFeatures/OrganizationUsers/AcceptOrgUserCommandTests.cs index 33ad63d02e..0d2d7b56e8 100644 --- a/test/Core.Test/OrganizationFeatures/OrganizationUsers/AcceptOrgUserCommandTests.cs +++ b/test/Core.Test/OrganizationFeatures/OrganizationUsers/AcceptOrgUserCommandTests.cs @@ -1,4 +1,6 @@ -using Bit.Core.Auth.Models.Business.Tokenables; +using Bit.Core.AdminConsole.Enums; +using Bit.Core.AdminConsole.Services; +using Bit.Core.Auth.Models.Business.Tokenables; using Bit.Core.Entities; using Bit.Core.Enums; using Bit.Core.Exceptions; diff --git a/test/Core.Test/Services/OrganizationServiceTests.cs b/test/Core.Test/Services/OrganizationServiceTests.cs index a169a0093e..9e25a2bcbe 100644 --- a/test/Core.Test/Services/OrganizationServiceTests.cs +++ b/test/Core.Test/Services/OrganizationServiceTests.cs @@ -1,5 +1,6 @@ using System.Text.Json; using Bit.Core.AdminConsole.Entities.Provider; +using Bit.Core.AdminConsole.Enums; using Bit.Core.AdminConsole.Enums.Provider; using Bit.Core.AdminConsole.OrganizationFeatures.OrganizationUsers.Interfaces; using Bit.Core.AdminConsole.Repositories; @@ -21,9 +22,9 @@ using Bit.Core.OrganizationFeatures.OrganizationSubscriptions.Interface; using Bit.Core.Repositories; using Bit.Core.Services; using Bit.Core.Settings; +using Bit.Core.Test.AdminConsole.AutoFixture; using Bit.Core.Test.AutoFixture.OrganizationFixtures; using Bit.Core.Test.AutoFixture.OrganizationUserFixtures; -using Bit.Core.Test.AutoFixture.PolicyFixtures; using Bit.Core.Tokens; using Bit.Core.Tools.Enums; using Bit.Core.Tools.Models.Business; @@ -38,7 +39,7 @@ using NSubstitute.ReturnsExtensions; using Xunit; using Organization = Bit.Core.Entities.Organization; using OrganizationUser = Bit.Core.Entities.OrganizationUser; -using Policy = Bit.Core.Entities.Policy; +using Policy = Bit.Core.AdminConsole.Entities.Policy; namespace Bit.Core.Test.Services; diff --git a/test/Core.Test/Services/UserServiceTests.cs b/test/Core.Test/Services/UserServiceTests.cs index c3bd1b2830..e95aa9d28a 100644 --- a/test/Core.Test/Services/UserServiceTests.cs +++ b/test/Core.Test/Services/UserServiceTests.cs @@ -2,6 +2,7 @@ using System.Text.Json; using AutoFixture; using Bit.Core.AdminConsole.Repositories; +using Bit.Core.AdminConsole.Services; using Bit.Core.Auth.Entities; using Bit.Core.Auth.Enums; using Bit.Core.Auth.Models; diff --git a/test/Core.Test/Tools/Services/SendServiceTests.cs b/test/Core.Test/Tools/Services/SendServiceTests.cs index 6b59429cd8..d3a4159a59 100644 --- a/test/Core.Test/Tools/Services/SendServiceTests.cs +++ b/test/Core.Test/Tools/Services/SendServiceTests.cs @@ -1,10 +1,12 @@ using System.Text; using System.Text.Json; +using Bit.Core.AdminConsole.Entities; +using Bit.Core.AdminConsole.Enums; +using Bit.Core.AdminConsole.Models.Data.Organizations.Policies; +using Bit.Core.AdminConsole.Services; using Bit.Core.Entities; -using Bit.Core.Enums; using Bit.Core.Exceptions; using Bit.Core.Models.Data.Organizations.OrganizationUsers; -using Bit.Core.Models.Data.Organizations.Policies; using Bit.Core.Repositories; using Bit.Core.Services; using Bit.Core.Test.AutoFixture.CurrentContextFixtures; diff --git a/test/Identity.IntegrationTest/Endpoints/IdentityServerTests.cs b/test/Identity.IntegrationTest/Endpoints/IdentityServerTests.cs index cae6ed172c..6a8a5db361 100644 --- a/test/Identity.IntegrationTest/Endpoints/IdentityServerTests.cs +++ b/test/Identity.IntegrationTest/Endpoints/IdentityServerTests.cs @@ -1,4 +1,7 @@ using System.Text.Json; +using Bit.Core.AdminConsole.Entities; +using Bit.Core.AdminConsole.Enums; +using Bit.Core.AdminConsole.Repositories; using Bit.Core.Auth.Models.Api.Request.Accounts; using Bit.Core.Enums; using Bit.Core.Repositories; @@ -569,7 +572,7 @@ public class IdentityServerTests : IClassFixture }; await organizationUserRepository.CreateAsync(organizationUser); - var ssoPolicy = new Bit.Core.Entities.Policy { OrganizationId = organization.Id, Type = PolicyType.RequireSso, Enabled = ssoPolicyEnabled }; + var ssoPolicy = new Policy { OrganizationId = organization.Id, Type = PolicyType.RequireSso, Enabled = ssoPolicyEnabled }; await policyRepository.CreateAsync(ssoPolicy); } diff --git a/test/Infrastructure.EFIntegration.Test/Repositories/PolicyRepositoryTests.cs b/test/Infrastructure.EFIntegration.Test/AdminConsole/Repositories/PolicyRepositoryTests.cs similarity index 80% rename from test/Infrastructure.EFIntegration.Test/Repositories/PolicyRepositoryTests.cs rename to test/Infrastructure.EFIntegration.Test/AdminConsole/Repositories/PolicyRepositoryTests.cs index db05c52a32..d398284c28 100644 --- a/test/Infrastructure.EFIntegration.Test/Repositories/PolicyRepositoryTests.cs +++ b/test/Infrastructure.EFIntegration.Test/AdminConsole/Repositories/PolicyRepositoryTests.cs @@ -3,11 +3,13 @@ using Bit.Core.Test.AutoFixture.Attributes; using Bit.Infrastructure.EFIntegration.Test.AutoFixture; using Bit.Infrastructure.EFIntegration.Test.Repositories.EqualityComparers; using Xunit; +using EfAdminConsoleRepo = Bit.Infrastructure.EntityFramework.AdminConsole.Repositories; using EfRepo = Bit.Infrastructure.EntityFramework.Repositories; -using Policy = Bit.Core.Entities.Policy; +using Policy = Bit.Core.AdminConsole.Entities.Policy; +using SqlAdminConsoleRepo = Bit.Infrastructure.Dapper.AdminConsole.Repositories; using SqlRepo = Bit.Infrastructure.Dapper.Repositories; -namespace Bit.Infrastructure.EFIntegration.Test.Repositories; +namespace Bit.Infrastructure.EFIntegration.Test.AdminConsole.Repositories; public class PolicyRepositoryTests { @@ -16,9 +18,9 @@ public class PolicyRepositoryTests Policy policy, Organization organization, PolicyCompare equalityComparer, - List suts, + List suts, List efOrganizationRepos, - SqlRepo.PolicyRepository sqlPolicyRepo, + SqlAdminConsoleRepo.PolicyRepository sqlPolicyRepo, SqlRepo.OrganizationRepository sqlOrganizationRepo ) { diff --git a/test/Infrastructure.EFIntegration.Test/AutoFixture/PolicyFixtures.cs b/test/Infrastructure.EFIntegration.Test/AutoFixture/PolicyFixtures.cs index 5ecd31f9c6..8ca48190cd 100644 --- a/test/Infrastructure.EFIntegration.Test/AutoFixture/PolicyFixtures.cs +++ b/test/Infrastructure.EFIntegration.Test/AutoFixture/PolicyFixtures.cs @@ -1,6 +1,6 @@ using AutoFixture; using AutoFixture.Kernel; -using Bit.Core.Entities; +using Bit.Core.AdminConsole.Entities; using Bit.Infrastructure.EntityFramework.AdminConsole.Repositories; using Bit.Infrastructure.EntityFramework.Repositories; using Bit.Test.Common.AutoFixture; diff --git a/test/Infrastructure.EFIntegration.Test/Repositories/EqualityComparers/PolicyCompare.cs b/test/Infrastructure.EFIntegration.Test/Repositories/EqualityComparers/PolicyCompare.cs index f3bd7dc7a9..2cd01d1396 100644 --- a/test/Infrastructure.EFIntegration.Test/Repositories/EqualityComparers/PolicyCompare.cs +++ b/test/Infrastructure.EFIntegration.Test/Repositories/EqualityComparers/PolicyCompare.cs @@ -1,5 +1,5 @@ using System.Diagnostics.CodeAnalysis; -using Bit.Core.Entities; +using Bit.Core.AdminConsole.Entities; namespace Bit.Infrastructure.EFIntegration.Test.Repositories.EqualityComparers; diff --git a/test/Infrastructure.EFIntegration.Test/Repositories/OrganizationUserRepositoryTests.cs b/test/Infrastructure.EFIntegration.Test/Repositories/OrganizationUserRepositoryTests.cs index 67b199b35a..c29fd28b22 100644 --- a/test/Infrastructure.EFIntegration.Test/Repositories/OrganizationUserRepositoryTests.cs +++ b/test/Infrastructure.EFIntegration.Test/Repositories/OrganizationUserRepositoryTests.cs @@ -1,5 +1,7 @@ using System.Text.Json; +using Bit.Core.AdminConsole.Entities; using Bit.Core.AdminConsole.Entities.Provider; +using Bit.Core.AdminConsole.Enums; using Bit.Core.AdminConsole.Repositories; using Bit.Core.Entities; using Bit.Core.Enums; @@ -13,6 +15,7 @@ using Xunit; using EfAdminConsoleRepo = Bit.Infrastructure.EntityFramework.AdminConsole.Repositories; using EfRepo = Bit.Infrastructure.EntityFramework.Repositories; using OrganizationUser = Bit.Core.Entities.OrganizationUser; +using SqlAdminConsoleRepo = Bit.Infrastructure.Dapper.AdminConsole.Repositories; using SqlRepo = Bit.Infrastructure.Dapper.Repositories; namespace Bit.Infrastructure.EFIntegration.Test.Repositories; @@ -182,7 +185,7 @@ public class OrganizationUserRepositoryTests OrganizationUserPolicyDetailsCompare equalityComparer, // Auto data - EF repos - List efPolicyRepository, + List efPolicyRepository, List efUserRepository, List efOrganizationRepository, List suts, @@ -191,7 +194,7 @@ public class OrganizationUserRepositoryTests List efProviderUserRepository, // Auto data - SQL repos - SqlRepo.PolicyRepository sqlPolicyRepo, + SqlAdminConsoleRepo.PolicyRepository sqlPolicyRepo, SqlRepo.UserRepository sqlUserRepo, SqlRepo.OrganizationRepository sqlOrganizationRepo, EfAdminConsoleRepo.ProviderRepository sqlProviderRepo,