From b866353d2cdbc2dffc6d90b5a9ceeca5ab058c17 Mon Sep 17 00:00:00 2001 From: Alex Morask <144709477+amorask-bitwarden@users.noreply.github.com> Date: Fri, 16 Feb 2024 13:37:54 -0500 Subject: [PATCH 01/21] Split endpoints for FF 'AC-1607_present-user-offboarding-survey' (#3814) --- .../Controllers/OrganizationsController.cs | 68 ++++++++++--------- .../Auth/Controllers/AccountsController.cs | 56 +++++++-------- 2 files changed, 64 insertions(+), 60 deletions(-) diff --git a/src/Api/AdminConsole/Controllers/OrganizationsController.cs b/src/Api/AdminConsole/Controllers/OrganizationsController.cs index 736fb30dde..8c9fb9091a 100644 --- a/src/Api/AdminConsole/Controllers/OrganizationsController.cs +++ b/src/Api/AdminConsole/Controllers/OrganizationsController.cs @@ -464,50 +464,52 @@ public class OrganizationsController : Controller await _organizationService.VerifyBankAsync(orgIdGuid, model.Amount1.Value, model.Amount2.Value); } - [HttpPost("{id}/cancel")] - [SelfHosted(NotSelfHostedOnly = true)] - public async Task PostCancel(Guid id, [FromBody] SubscriptionCancellationRequestModel request) + [HttpPost("{id}/churn")] + public async Task PostChurn(Guid id, [FromBody] SubscriptionCancellationRequestModel request) { if (!await _currentContext.EditSubscription(id)) { throw new NotFoundException(); } - var presentUserWithOffboardingSurvey = - _featureService.IsEnabled(FeatureFlagKeys.AC1607_PresentUsersWithOffboardingSurvey); + var organization = await _organizationRepository.GetByIdAsync(id); - if (presentUserWithOffboardingSurvey) + if (organization == null) { - var organization = await _organizationRepository.GetByIdAsync(id); - - if (organization == null) - { - throw new NotFoundException(); - } - - var subscription = await _getSubscriptionQuery.GetSubscription(organization); - - await _cancelSubscriptionCommand.CancelSubscription(subscription, - new OffboardingSurveyResponse - { - UserId = _currentContext.UserId!.Value, - Reason = request.Reason, - Feedback = request.Feedback - }, - organization.IsExpired()); - - await _referenceEventService.RaiseEventAsync(new ReferenceEvent( - ReferenceEventType.CancelSubscription, - organization, - _currentContext) - { - EndOfPeriod = organization.IsExpired() - }); + throw new NotFoundException(); } - else + + var subscription = await _getSubscriptionQuery.GetSubscription(organization); + + await _cancelSubscriptionCommand.CancelSubscription(subscription, + new OffboardingSurveyResponse + { + UserId = _currentContext.UserId!.Value, + Reason = request.Reason, + Feedback = request.Feedback + }, + organization.IsExpired()); + + await _referenceEventService.RaiseEventAsync(new ReferenceEvent( + ReferenceEventType.CancelSubscription, + organization, + _currentContext) { - await _organizationService.CancelSubscriptionAsync(id); + EndOfPeriod = organization.IsExpired() + }); + } + + [HttpPost("{id}/cancel")] + [SelfHosted(NotSelfHostedOnly = true)] + public async Task PostCancel(string id) + { + var orgIdGuid = new Guid(id); + if (!await _currentContext.EditSubscription(orgIdGuid)) + { + throw new NotFoundException(); } + + await _organizationService.CancelSubscriptionAsync(orgIdGuid); } [HttpPost("{id}/reinstate")] diff --git a/src/Api/Auth/Controllers/AccountsController.cs b/src/Api/Auth/Controllers/AccountsController.cs index 8c4842848e..f370232b9d 100644 --- a/src/Api/Auth/Controllers/AccountsController.cs +++ b/src/Api/Auth/Controllers/AccountsController.cs @@ -821,9 +821,8 @@ public class AccountsController : Controller await _userService.UpdateLicenseAsync(user, license); } - [HttpPost("cancel-premium")] - [SelfHosted(NotSelfHostedOnly = true)] - public async Task PostCancel([FromBody] SubscriptionCancellationRequestModel request) + [HttpPost("churn-premium")] + public async Task PostChurn([FromBody] SubscriptionCancellationRequestModel request) { var user = await _userService.GetUserByPrincipalAsync(User); @@ -832,34 +831,37 @@ public class AccountsController : Controller throw new UnauthorizedAccessException(); } - var presentUserWithOffboardingSurvey = - _featureService.IsEnabled(FeatureFlagKeys.AC1607_PresentUsersWithOffboardingSurvey); + var subscription = await _getSubscriptionQuery.GetSubscription(user); - if (presentUserWithOffboardingSurvey) - { - var subscription = await _getSubscriptionQuery.GetSubscription(user); - - await _cancelSubscriptionCommand.CancelSubscription(subscription, - new OffboardingSurveyResponse - { - UserId = user.Id, - Reason = request.Reason, - Feedback = request.Feedback - }, - user.IsExpired()); - - await _referenceEventService.RaiseEventAsync(new ReferenceEvent( - ReferenceEventType.CancelSubscription, - user, - _currentContext) + await _cancelSubscriptionCommand.CancelSubscription(subscription, + new OffboardingSurveyResponse { - EndOfPeriod = user.IsExpired() - }); - } - else + UserId = user.Id, + Reason = request.Reason, + Feedback = request.Feedback + }, + user.IsExpired()); + + await _referenceEventService.RaiseEventAsync(new ReferenceEvent( + ReferenceEventType.CancelSubscription, + user, + _currentContext) { - await _userService.CancelPremiumAsync(user); + EndOfPeriod = user.IsExpired() + }); + } + + [HttpPost("cancel-premium")] + [SelfHosted(NotSelfHostedOnly = true)] + public async Task PostCancel() + { + var user = await _userService.GetUserByPrincipalAsync(User); + if (user == null) + { + throw new UnauthorizedAccessException(); } + + await _userService.CancelPremiumAsync(user); } [HttpPost("reinstate-premium")] From a98af69e00463ef44ff5c35421b338978c696607 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 19 Feb 2024 11:24:47 +0100 Subject: [PATCH 02/21] [deps] Tools: Update SendGrid to v9.29.2 (#3811) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- src/Core/Core.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Core/Core.csproj b/src/Core/Core.csproj index 67a25ff24d..558f6049cb 100644 --- a/src/Core/Core.csproj +++ b/src/Core/Core.csproj @@ -43,7 +43,7 @@ - + From d384107ef7b8f62b05580a4d7fcf2ddc2d272344 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 19 Feb 2024 16:37:11 +0100 Subject: [PATCH 03/21] [deps] Tools: Update aws-sdk-net monorepo to v3.7.300.52 (#3826) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- src/Core/Core.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Core/Core.csproj b/src/Core/Core.csproj index 558f6049cb..5b4cef00fe 100644 --- a/src/Core/Core.csproj +++ b/src/Core/Core.csproj @@ -21,8 +21,8 @@ - - + + From 4e6360cc4fa96ea4997ab0c7d42b24d70d069736 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 20 Feb 2024 09:42:30 -0500 Subject: [PATCH 04/21] [deps] DbOps: Update EntityFrameworkCore (#3823) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- .config/dotnet-tools.json | 2 +- .../Infrastructure.EntityFramework.csproj | 6 +++--- util/MySqlMigrations/MySqlMigrations.csproj | 2 +- util/PostgresMigrations/PostgresMigrations.csproj | 2 +- util/SqlServerEFScaffold/SqlServerEFScaffold.csproj | 2 +- util/SqliteMigrations/SqliteMigrations.csproj | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index a1119ca479..304c6d3b58 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -7,7 +7,7 @@ "commands": ["swagger"] }, "dotnet-ef": { - "version": "8.0.1", + "version": "8.0.2", "commands": ["dotnet-ef"] } } diff --git a/src/Infrastructure.EntityFramework/Infrastructure.EntityFramework.csproj b/src/Infrastructure.EntityFramework/Infrastructure.EntityFramework.csproj index 0a5cdaed5b..59b0dd677c 100644 --- a/src/Infrastructure.EntityFramework/Infrastructure.EntityFramework.csproj +++ b/src/Infrastructure.EntityFramework/Infrastructure.EntityFramework.csproj @@ -3,9 +3,9 @@ - - - + + + diff --git a/util/MySqlMigrations/MySqlMigrations.csproj b/util/MySqlMigrations/MySqlMigrations.csproj index 0bf3bd76a5..5ab3ba5289 100644 --- a/util/MySqlMigrations/MySqlMigrations.csproj +++ b/util/MySqlMigrations/MySqlMigrations.csproj @@ -10,7 +10,7 @@ - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/util/PostgresMigrations/PostgresMigrations.csproj b/util/PostgresMigrations/PostgresMigrations.csproj index 370d3e8db5..8b6d6edcfb 100644 --- a/util/PostgresMigrations/PostgresMigrations.csproj +++ b/util/PostgresMigrations/PostgresMigrations.csproj @@ -6,7 +6,7 @@ - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/util/SqlServerEFScaffold/SqlServerEFScaffold.csproj b/util/SqlServerEFScaffold/SqlServerEFScaffold.csproj index 179f291e43..9ff33ea456 100644 --- a/util/SqlServerEFScaffold/SqlServerEFScaffold.csproj +++ b/util/SqlServerEFScaffold/SqlServerEFScaffold.csproj @@ -1,6 +1,6 @@ - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/util/SqliteMigrations/SqliteMigrations.csproj b/util/SqliteMigrations/SqliteMigrations.csproj index c3f800bea3..03c67366af 100644 --- a/util/SqliteMigrations/SqliteMigrations.csproj +++ b/util/SqliteMigrations/SqliteMigrations.csproj @@ -11,7 +11,7 @@ - + runtime; build; native; contentfiles; analyzers; buildtransitive all From e23f37ea1fbc1b32d689c07e30095707d1c40e47 Mon Sep 17 00:00:00 2001 From: Vincent Salucci <26154748+vincentsalucci@users.noreply.github.com> Date: Tue, 20 Feb 2024 09:53:50 -0600 Subject: [PATCH 05/21] [AC-2214] Defect - provider reseller org creation when fc signup flag enabled (#3805) * fix: supply signup feature flag to provider reseller org creation, refs AC-2214 * feat: extend flexible collections coverage to enhancement bools, refs AC-2214 --- src/Admin/Controllers/ProvidersController.cs | 10 ++++++++-- src/Admin/Models/OrganizationEditModel.cs | 15 +++++++++++++-- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/Admin/Controllers/ProvidersController.cs b/src/Admin/Controllers/ProvidersController.cs index 8fa02e9b32..9493428739 100644 --- a/src/Admin/Controllers/ProvidersController.cs +++ b/src/Admin/Controllers/ProvidersController.cs @@ -1,6 +1,7 @@ using Bit.Admin.Enums; using Bit.Admin.Models; using Bit.Admin.Utilities; +using Bit.Core; using Bit.Core.AdminConsole.Entities.Provider; using Bit.Core.AdminConsole.Enums.Provider; using Bit.Core.AdminConsole.Providers.Interfaces; @@ -31,6 +32,7 @@ public class ProvidersController : Controller private readonly IReferenceEventService _referenceEventService; private readonly IUserService _userService; private readonly ICreateProviderCommand _createProviderCommand; + private readonly IFeatureService _featureService; public ProvidersController( IOrganizationRepository organizationRepository, @@ -43,7 +45,8 @@ public class ProvidersController : Controller IApplicationCacheService applicationCacheService, IReferenceEventService referenceEventService, IUserService userService, - ICreateProviderCommand createProviderCommand) + ICreateProviderCommand createProviderCommand, + IFeatureService featureService) { _organizationRepository = organizationRepository; _organizationService = organizationService; @@ -56,6 +59,7 @@ public class ProvidersController : Controller _referenceEventService = referenceEventService; _userService = userService; _createProviderCommand = createProviderCommand; + _featureService = featureService; } [RequirePermission(Permission.Provider_List_View)] @@ -236,7 +240,9 @@ public class ProvidersController : Controller return RedirectToAction("Index"); } - var organization = model.CreateOrganization(provider); + var flexibleCollectionsSignupEnabled = _featureService.IsEnabled(FeatureFlagKeys.FlexibleCollectionsSignup); + var flexibleCollectionsV1Enabled = _featureService.IsEnabled(FeatureFlagKeys.FlexibleCollectionsV1); + var organization = model.CreateOrganization(provider, flexibleCollectionsSignupEnabled, flexibleCollectionsV1Enabled); await _organizationService.CreatePendingOrganization(organization, model.Owners, User, _userService, model.SalesAssistedTrialStarted); await _providerService.AddOrganization(providerId, organization.Id, null); diff --git a/src/Admin/Models/OrganizationEditModel.cs b/src/Admin/Models/OrganizationEditModel.cs index 559b5b6868..643b252f62 100644 --- a/src/Admin/Models/OrganizationEditModel.cs +++ b/src/Admin/Models/OrganizationEditModel.cs @@ -164,11 +164,22 @@ public class OrganizationEditModel : OrganizationViewModel { "baseServiceAccount", p.SecretsManager.BaseServiceAccount } }); - public Organization CreateOrganization(Provider provider) + public Organization CreateOrganization(Provider provider, bool flexibleCollectionsSignupEnabled, bool flexibleCollectionsV1Enabled) { BillingEmail = provider.BillingEmail; - return ToOrganization(new Organization()); + var newOrg = new Organization + { + // This feature flag indicates that new organizations should be automatically onboarded to + // Flexible Collections enhancements + FlexibleCollections = flexibleCollectionsSignupEnabled, + // These collection management settings smooth the migration for existing organizations by disabling some FC behavior. + // If the organization is onboarded to Flexible Collections on signup, we turn them OFF to enable all new behaviour. + // If the organization is NOT onboarded now, they will have to be migrated later, so they default to ON to limit FC changes on migration. + LimitCollectionCreationDeletion = !flexibleCollectionsSignupEnabled, + AllowAdminAccessToAllCollectionItems = !flexibleCollectionsV1Enabled + }; + return ToOrganization(newOrg); } public Organization ToOrganization(Organization existingOrganization) From 9720d18a0a9326777be1afe3e5f32d987f903caa Mon Sep 17 00:00:00 2001 From: Oscar Hinton Date: Tue, 20 Feb 2024 17:18:40 +0100 Subject: [PATCH 06/21] Include all projects in coverage (#3829) Not all of our server projects had associated test projects which caused them to be omitted from the code coverage. Added projects to ensure the coverage gets reported accurately. --- .github/codecov.yml | 1 + bitwarden-server.sln | 28 ++++++++++ test/Admin.Test/Admin.Test.csproj | 22 ++++++++ test/Admin.Test/GlobalUsings.cs | 1 + test/Admin.Test/PlaceholderUnitTest.cs | 10 ++++ test/Events.Test/Events.Test.csproj | 22 ++++++++ test/Events.Test/GlobalUsings.cs | 1 + test/Events.Test/PlaceholderUnitTest.cs | 10 ++++ .../EventsProcessor.Test.csproj | 22 ++++++++ test/EventsProcessor.Test/GlobalUsings.cs | 1 + .../PlaceholderUnitTest.cs | 10 ++++ test/Notifications.Test/GlobalUsings.cs | 1 + .../Notifications.Test.csproj | 22 ++++++++ .../Notifications.Test/PlaceholderUnitTest.cs | 10 ++++ test/bitwarden.tests.sln | 56 +++++++++++++++++++ 15 files changed, 217 insertions(+) create mode 100644 test/Admin.Test/Admin.Test.csproj create mode 100644 test/Admin.Test/GlobalUsings.cs create mode 100644 test/Admin.Test/PlaceholderUnitTest.cs create mode 100644 test/Events.Test/Events.Test.csproj create mode 100644 test/Events.Test/GlobalUsings.cs create mode 100644 test/Events.Test/PlaceholderUnitTest.cs create mode 100644 test/EventsProcessor.Test/EventsProcessor.Test.csproj create mode 100644 test/EventsProcessor.Test/GlobalUsings.cs create mode 100644 test/EventsProcessor.Test/PlaceholderUnitTest.cs create mode 100644 test/Notifications.Test/GlobalUsings.cs create mode 100644 test/Notifications.Test/Notifications.Test.csproj create mode 100644 test/Notifications.Test/PlaceholderUnitTest.cs diff --git a/.github/codecov.yml b/.github/codecov.yml index 3a606f3b5a..429f76d677 100644 --- a/.github/codecov.yml +++ b/.github/codecov.yml @@ -1,2 +1,3 @@ ignore: - "test" # Tests + - "util" # Utils (migrators) diff --git a/bitwarden-server.sln b/bitwarden-server.sln index 6a45e21eb4..154ffe3614 100644 --- a/bitwarden-server.sln +++ b/bitwarden-server.sln @@ -116,6 +116,14 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SqliteMigrations", "util\Sq EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MsSqlMigratorUtility", "util\MsSqlMigratorUtility\MsSqlMigratorUtility.csproj", "{D9A2CCBB-FB0A-4BBA-A9ED-BA9FF277C880}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Admin.Test", "test\Admin.Test\Admin.Test.csproj", "{52D22B52-26D3-463A-8EB5-7FDC849D3761}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Events.Test", "test\Events.Test\Events.Test.csproj", "{916AFD8C-30AF-49B6-A5C9-28CA1B5D9298}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EventsProcessor.Test", "test\EventsProcessor.Test\EventsProcessor.Test.csproj", "{81673EFB-7134-4B4B-A32F-1EA05F0EF3CE}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Notifications.Test", "test\Notifications.Test\Notifications.Test.csproj", "{90D85D8F-5577-4570-A96E-5A2E185F0F6F}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -284,6 +292,22 @@ Global {D9A2CCBB-FB0A-4BBA-A9ED-BA9FF277C880}.Debug|Any CPU.Build.0 = Debug|Any CPU {D9A2CCBB-FB0A-4BBA-A9ED-BA9FF277C880}.Release|Any CPU.ActiveCfg = Release|Any CPU {D9A2CCBB-FB0A-4BBA-A9ED-BA9FF277C880}.Release|Any CPU.Build.0 = Release|Any CPU + {52D22B52-26D3-463A-8EB5-7FDC849D3761}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {52D22B52-26D3-463A-8EB5-7FDC849D3761}.Debug|Any CPU.Build.0 = Debug|Any CPU + {52D22B52-26D3-463A-8EB5-7FDC849D3761}.Release|Any CPU.ActiveCfg = Release|Any CPU + {52D22B52-26D3-463A-8EB5-7FDC849D3761}.Release|Any CPU.Build.0 = Release|Any CPU + {916AFD8C-30AF-49B6-A5C9-28CA1B5D9298}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {916AFD8C-30AF-49B6-A5C9-28CA1B5D9298}.Debug|Any CPU.Build.0 = Debug|Any CPU + {916AFD8C-30AF-49B6-A5C9-28CA1B5D9298}.Release|Any CPU.ActiveCfg = Release|Any CPU + {916AFD8C-30AF-49B6-A5C9-28CA1B5D9298}.Release|Any CPU.Build.0 = Release|Any CPU + {81673EFB-7134-4B4B-A32F-1EA05F0EF3CE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {81673EFB-7134-4B4B-A32F-1EA05F0EF3CE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {81673EFB-7134-4B4B-A32F-1EA05F0EF3CE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {81673EFB-7134-4B4B-A32F-1EA05F0EF3CE}.Release|Any CPU.Build.0 = Release|Any CPU + {90D85D8F-5577-4570-A96E-5A2E185F0F6F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {90D85D8F-5577-4570-A96E-5A2E185F0F6F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {90D85D8F-5577-4570-A96E-5A2E185F0F6F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {90D85D8F-5577-4570-A96E-5A2E185F0F6F}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -329,6 +353,10 @@ Global {7E9A7DD5-EB78-4AC5-BFD5-64573FD2533B} = {DD5BD056-4AAE-43EF-BBD2-0B569B8DA84F} {07143DFA-F242-47A4-A15E-39C9314D4140} = {DD5BD056-4AAE-43EF-BBD2-0B569B8DA84E} {D9A2CCBB-FB0A-4BBA-A9ED-BA9FF277C880} = {DD5BD056-4AAE-43EF-BBD2-0B569B8DA84E} + {52D22B52-26D3-463A-8EB5-7FDC849D3761} = {DD5BD056-4AAE-43EF-BBD2-0B569B8DA84F} + {916AFD8C-30AF-49B6-A5C9-28CA1B5D9298} = {DD5BD056-4AAE-43EF-BBD2-0B569B8DA84F} + {81673EFB-7134-4B4B-A32F-1EA05F0EF3CE} = {DD5BD056-4AAE-43EF-BBD2-0B569B8DA84F} + {90D85D8F-5577-4570-A96E-5A2E185F0F6F} = {DD5BD056-4AAE-43EF-BBD2-0B569B8DA84F} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {E01CBF68-2E20-425F-9EDB-E0A6510CA92F} diff --git a/test/Admin.Test/Admin.Test.csproj b/test/Admin.Test/Admin.Test.csproj new file mode 100644 index 0000000000..e2abaceec6 --- /dev/null +++ b/test/Admin.Test/Admin.Test.csproj @@ -0,0 +1,22 @@ + + + false + Admin.Test + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + + all + runtime; build; native; contentfiles; analyzers + + + + + + diff --git a/test/Admin.Test/GlobalUsings.cs b/test/Admin.Test/GlobalUsings.cs new file mode 100644 index 0000000000..9df1d42179 --- /dev/null +++ b/test/Admin.Test/GlobalUsings.cs @@ -0,0 +1 @@ +global using Xunit; diff --git a/test/Admin.Test/PlaceholderUnitTest.cs b/test/Admin.Test/PlaceholderUnitTest.cs new file mode 100644 index 0000000000..65fa2e2016 --- /dev/null +++ b/test/Admin.Test/PlaceholderUnitTest.cs @@ -0,0 +1,10 @@ +namespace Admin.Test; + +// Delete this file once you have real tests +public class PlaceholderUnitTest +{ + [Fact] + public void Test1() + { + } +} diff --git a/test/Events.Test/Events.Test.csproj b/test/Events.Test/Events.Test.csproj new file mode 100644 index 0000000000..b2efcbffc2 --- /dev/null +++ b/test/Events.Test/Events.Test.csproj @@ -0,0 +1,22 @@ + + + false + Events.Test + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + + all + runtime; build; native; contentfiles; analyzers + + + + + + diff --git a/test/Events.Test/GlobalUsings.cs b/test/Events.Test/GlobalUsings.cs new file mode 100644 index 0000000000..9df1d42179 --- /dev/null +++ b/test/Events.Test/GlobalUsings.cs @@ -0,0 +1 @@ +global using Xunit; diff --git a/test/Events.Test/PlaceholderUnitTest.cs b/test/Events.Test/PlaceholderUnitTest.cs new file mode 100644 index 0000000000..4998362f4d --- /dev/null +++ b/test/Events.Test/PlaceholderUnitTest.cs @@ -0,0 +1,10 @@ +namespace Events.Test; + +// Delete this file once you have real tests +public class PlaceholderUnitTest +{ + [Fact] + public void Test1() + { + } +} diff --git a/test/EventsProcessor.Test/EventsProcessor.Test.csproj b/test/EventsProcessor.Test/EventsProcessor.Test.csproj new file mode 100644 index 0000000000..4ed0d34929 --- /dev/null +++ b/test/EventsProcessor.Test/EventsProcessor.Test.csproj @@ -0,0 +1,22 @@ + + + false + EventsProcessor.Test + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + + all + runtime; build; native; contentfiles; analyzers + + + + + + diff --git a/test/EventsProcessor.Test/GlobalUsings.cs b/test/EventsProcessor.Test/GlobalUsings.cs new file mode 100644 index 0000000000..9df1d42179 --- /dev/null +++ b/test/EventsProcessor.Test/GlobalUsings.cs @@ -0,0 +1 @@ +global using Xunit; diff --git a/test/EventsProcessor.Test/PlaceholderUnitTest.cs b/test/EventsProcessor.Test/PlaceholderUnitTest.cs new file mode 100644 index 0000000000..0434d1ea94 --- /dev/null +++ b/test/EventsProcessor.Test/PlaceholderUnitTest.cs @@ -0,0 +1,10 @@ +namespace EventsProcessor.Test; + +// Delete this file once you have real tests +public class PlaceholderUnitTest +{ + [Fact] + public void Test1() + { + } +} diff --git a/test/Notifications.Test/GlobalUsings.cs b/test/Notifications.Test/GlobalUsings.cs new file mode 100644 index 0000000000..9df1d42179 --- /dev/null +++ b/test/Notifications.Test/GlobalUsings.cs @@ -0,0 +1 @@ +global using Xunit; diff --git a/test/Notifications.Test/Notifications.Test.csproj b/test/Notifications.Test/Notifications.Test.csproj new file mode 100644 index 0000000000..4dd37605c2 --- /dev/null +++ b/test/Notifications.Test/Notifications.Test.csproj @@ -0,0 +1,22 @@ + + + false + Notifications.Test + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + + all + runtime; build; native; contentfiles; analyzers + + + + + + diff --git a/test/Notifications.Test/PlaceholderUnitTest.cs b/test/Notifications.Test/PlaceholderUnitTest.cs new file mode 100644 index 0000000000..4d89b85698 --- /dev/null +++ b/test/Notifications.Test/PlaceholderUnitTest.cs @@ -0,0 +1,10 @@ +namespace Notifications.Test; + +// Delete this file once you have real tests +public class PlaceholderUnitTest +{ + [Fact] + public void Test1() + { + } +} diff --git a/test/bitwarden.tests.sln b/test/bitwarden.tests.sln index a5d8b86dde..9654dd5e4c 100644 --- a/test/bitwarden.tests.sln +++ b/test/bitwarden.tests.sln @@ -25,6 +25,14 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Infrastructure.IntegrationT EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Identity.Test", "Identity.Test\Identity.Test.csproj", "{CE6A0F24-4193-4CCC-9BE1-6D1D85782CA9}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Admin.Test", "Admin.Test\Admin.Test.csproj", "{59EC3A17-74C4-41AF-AD21-F82D107C3374}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Events.Test", "Events.Test\Events.Test.csproj", "{181B2AA7-7541-4EC0-A9FA-5D7AF6E626D6}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EventsProcessor.Test", "EventsProcessor.Test\EventsProcessor.Test.csproj", "{D1045453-676A-4353-A6C0-7FDFF78236A0}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Notifications.Test", "Notifications.Test\Notifications.Test.csproj", "{9E23D7A3-89D2-484A-BC72-CCCDFF0EDC6C}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -170,5 +178,53 @@ Global {CE6A0F24-4193-4CCC-9BE1-6D1D85782CA9}.Release|x64.Build.0 = Release|Any CPU {CE6A0F24-4193-4CCC-9BE1-6D1D85782CA9}.Release|x86.ActiveCfg = Release|Any CPU {CE6A0F24-4193-4CCC-9BE1-6D1D85782CA9}.Release|x86.Build.0 = Release|Any CPU + {59EC3A17-74C4-41AF-AD21-F82D107C3374}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {59EC3A17-74C4-41AF-AD21-F82D107C3374}.Debug|Any CPU.Build.0 = Debug|Any CPU + {59EC3A17-74C4-41AF-AD21-F82D107C3374}.Debug|x64.ActiveCfg = Debug|Any CPU + {59EC3A17-74C4-41AF-AD21-F82D107C3374}.Debug|x64.Build.0 = Debug|Any CPU + {59EC3A17-74C4-41AF-AD21-F82D107C3374}.Debug|x86.ActiveCfg = Debug|Any CPU + {59EC3A17-74C4-41AF-AD21-F82D107C3374}.Debug|x86.Build.0 = Debug|Any CPU + {59EC3A17-74C4-41AF-AD21-F82D107C3374}.Release|Any CPU.ActiveCfg = Release|Any CPU + {59EC3A17-74C4-41AF-AD21-F82D107C3374}.Release|Any CPU.Build.0 = Release|Any CPU + {59EC3A17-74C4-41AF-AD21-F82D107C3374}.Release|x64.ActiveCfg = Release|Any CPU + {59EC3A17-74C4-41AF-AD21-F82D107C3374}.Release|x64.Build.0 = Release|Any CPU + {59EC3A17-74C4-41AF-AD21-F82D107C3374}.Release|x86.ActiveCfg = Release|Any CPU + {59EC3A17-74C4-41AF-AD21-F82D107C3374}.Release|x86.Build.0 = Release|Any CPU + {181B2AA7-7541-4EC0-A9FA-5D7AF6E626D6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {181B2AA7-7541-4EC0-A9FA-5D7AF6E626D6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {181B2AA7-7541-4EC0-A9FA-5D7AF6E626D6}.Debug|x64.ActiveCfg = Debug|Any CPU + {181B2AA7-7541-4EC0-A9FA-5D7AF6E626D6}.Debug|x64.Build.0 = Debug|Any CPU + {181B2AA7-7541-4EC0-A9FA-5D7AF6E626D6}.Debug|x86.ActiveCfg = Debug|Any CPU + {181B2AA7-7541-4EC0-A9FA-5D7AF6E626D6}.Debug|x86.Build.0 = Debug|Any CPU + {181B2AA7-7541-4EC0-A9FA-5D7AF6E626D6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {181B2AA7-7541-4EC0-A9FA-5D7AF6E626D6}.Release|Any CPU.Build.0 = Release|Any CPU + {181B2AA7-7541-4EC0-A9FA-5D7AF6E626D6}.Release|x64.ActiveCfg = Release|Any CPU + {181B2AA7-7541-4EC0-A9FA-5D7AF6E626D6}.Release|x64.Build.0 = Release|Any CPU + {181B2AA7-7541-4EC0-A9FA-5D7AF6E626D6}.Release|x86.ActiveCfg = Release|Any CPU + {181B2AA7-7541-4EC0-A9FA-5D7AF6E626D6}.Release|x86.Build.0 = Release|Any CPU + {D1045453-676A-4353-A6C0-7FDFF78236A0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D1045453-676A-4353-A6C0-7FDFF78236A0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D1045453-676A-4353-A6C0-7FDFF78236A0}.Debug|x64.ActiveCfg = Debug|Any CPU + {D1045453-676A-4353-A6C0-7FDFF78236A0}.Debug|x64.Build.0 = Debug|Any CPU + {D1045453-676A-4353-A6C0-7FDFF78236A0}.Debug|x86.ActiveCfg = Debug|Any CPU + {D1045453-676A-4353-A6C0-7FDFF78236A0}.Debug|x86.Build.0 = Debug|Any CPU + {D1045453-676A-4353-A6C0-7FDFF78236A0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D1045453-676A-4353-A6C0-7FDFF78236A0}.Release|Any CPU.Build.0 = Release|Any CPU + {D1045453-676A-4353-A6C0-7FDFF78236A0}.Release|x64.ActiveCfg = Release|Any CPU + {D1045453-676A-4353-A6C0-7FDFF78236A0}.Release|x64.Build.0 = Release|Any CPU + {D1045453-676A-4353-A6C0-7FDFF78236A0}.Release|x86.ActiveCfg = Release|Any CPU + {D1045453-676A-4353-A6C0-7FDFF78236A0}.Release|x86.Build.0 = Release|Any CPU + {9E23D7A3-89D2-484A-BC72-CCCDFF0EDC6C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9E23D7A3-89D2-484A-BC72-CCCDFF0EDC6C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9E23D7A3-89D2-484A-BC72-CCCDFF0EDC6C}.Debug|x64.ActiveCfg = Debug|Any CPU + {9E23D7A3-89D2-484A-BC72-CCCDFF0EDC6C}.Debug|x64.Build.0 = Debug|Any CPU + {9E23D7A3-89D2-484A-BC72-CCCDFF0EDC6C}.Debug|x86.ActiveCfg = Debug|Any CPU + {9E23D7A3-89D2-484A-BC72-CCCDFF0EDC6C}.Debug|x86.Build.0 = Debug|Any CPU + {9E23D7A3-89D2-484A-BC72-CCCDFF0EDC6C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9E23D7A3-89D2-484A-BC72-CCCDFF0EDC6C}.Release|Any CPU.Build.0 = Release|Any CPU + {9E23D7A3-89D2-484A-BC72-CCCDFF0EDC6C}.Release|x64.ActiveCfg = Release|Any CPU + {9E23D7A3-89D2-484A-BC72-CCCDFF0EDC6C}.Release|x64.Build.0 = Release|Any CPU + {9E23D7A3-89D2-484A-BC72-CCCDFF0EDC6C}.Release|x86.ActiveCfg = Release|Any CPU + {9E23D7A3-89D2-484A-BC72-CCCDFF0EDC6C}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection EndGlobal From af56ab41593edb626ae79650d0a1c46e91bd1bad Mon Sep 17 00:00:00 2001 From: Matt Bishop Date: Tue, 20 Feb 2024 11:42:52 -0500 Subject: [PATCH 07/21] Remove unnecessary identity column indication (#3830) --- .../Auth/Configurations/GrantEntityTypeConfiguration.cs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/Infrastructure.EntityFramework/Auth/Configurations/GrantEntityTypeConfiguration.cs b/src/Infrastructure.EntityFramework/Auth/Configurations/GrantEntityTypeConfiguration.cs index 34c9b0351f..2e935f2690 100644 --- a/src/Infrastructure.EntityFramework/Auth/Configurations/GrantEntityTypeConfiguration.cs +++ b/src/Infrastructure.EntityFramework/Auth/Configurations/GrantEntityTypeConfiguration.cs @@ -13,10 +13,6 @@ public class GrantEntityTypeConfiguration : IEntityTypeConfiguration .HasName("PK_Grant") .IsClustered(); - builder - .Property(s => s.Id) - .UseIdentityColumn(); - builder .HasIndex(s => s.Key) .IsUnique(true); From 80a3979be1171dc0dcff7e7c0aa2d76e754d476e Mon Sep 17 00:00:00 2001 From: Oscar Hinton Date: Tue, 20 Feb 2024 18:50:04 +0100 Subject: [PATCH 08/21] Remove unused job hosted service from billing (#3831) --- src/Billing/Jobs/JobsHostedService.cs | 44 --------------------------- src/Billing/Startup.cs | 4 --- 2 files changed, 48 deletions(-) delete mode 100644 src/Billing/Jobs/JobsHostedService.cs diff --git a/src/Billing/Jobs/JobsHostedService.cs b/src/Billing/Jobs/JobsHostedService.cs deleted file mode 100644 index 1a5c80774c..0000000000 --- a/src/Billing/Jobs/JobsHostedService.cs +++ /dev/null @@ -1,44 +0,0 @@ -using System.Runtime.InteropServices; -using Bit.Core.Jobs; -using Bit.Core.Settings; -using Quartz; - -namespace Bit.Billing.Jobs; - -public class JobsHostedService : BaseJobsHostedService -{ - public JobsHostedService( - GlobalSettings globalSettings, - IServiceProvider serviceProvider, - ILogger logger, - ILogger listenerLogger) - : base(globalSettings, serviceProvider, logger, listenerLogger) { } - - public override async Task StartAsync(CancellationToken cancellationToken) - { - var timeZone = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? - TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time") : - TimeZoneInfo.FindSystemTimeZoneById("America/New_York"); - if (_globalSettings.SelfHosted) - { - timeZone = TimeZoneInfo.Local; - } - - var everyDayAtNinePmTrigger = TriggerBuilder.Create() - .WithIdentity("EveryDayAtNinePmTrigger") - .StartNow() - .WithCronSchedule("0 0 21 * * ?", x => x.InTimeZone(timeZone)) - .Build(); - - Jobs = new List>(); - - // Add jobs here - - await base.StartAsync(cancellationToken); - } - - public static void AddJobsServices(IServiceCollection services) - { - // Register jobs here - } -} diff --git a/src/Billing/Startup.cs b/src/Billing/Startup.cs index f4436f6c52..31291700e6 100644 --- a/src/Billing/Startup.cs +++ b/src/Billing/Startup.cs @@ -76,10 +76,6 @@ public class Startup // Authentication services.AddAuthentication(); - // Jobs service, uncomment when we have some jobs to run - // Jobs.JobsHostedService.AddJobsServices(services); - // services.AddHostedService(); - // Set up HttpClients services.AddHttpClient("FreshdeskApi"); From a661ffdb3d133ff502fefc02980c848a61afcc80 Mon Sep 17 00:00:00 2001 From: Justin Baur <19896123+justindbaur@users.noreply.github.com> Date: Tue, 20 Feb 2024 13:07:54 -0500 Subject: [PATCH 09/21] Improve Speed of `EncryptedStringAttribute` (#3785) * Improve Speed of EncryptedStringAttribute - Use Base64.IsValid - Use SearchValues * Fix Tests * Remove SearchValues Change * Format --- .../Utilities/EncryptedStringAttribute.cs | 41 ++----------------- .../EncryptedStringAttributeTests.cs | 15 ------- 2 files changed, 4 insertions(+), 52 deletions(-) diff --git a/src/Core/Utilities/EncryptedStringAttribute.cs b/src/Core/Utilities/EncryptedStringAttribute.cs index 183af599f9..1fe06b4f58 100644 --- a/src/Core/Utilities/EncryptedStringAttribute.cs +++ b/src/Core/Utilities/EncryptedStringAttribute.cs @@ -1,4 +1,4 @@ -using System.Buffers; +using System.Buffers.Text; using System.ComponentModel.DataAnnotations; using Bit.Core.Enums; @@ -88,7 +88,7 @@ public class EncryptedStringAttribute : ValidationAttribute } // Simply cast the number to the enum, this could be a value that doesn't actually have a backing enum - // entry but that is alright we will use it to look in the dictionary and non-valid + // entry but that is alright we will use it to look in the dictionary and non-valid // numbers will be filtered out there. encryptionType = (EncryptionType)encryptionTypeNumber; @@ -110,7 +110,7 @@ public class EncryptedStringAttribute : ValidationAttribute if (requiredPieces == 1) { // Only one more part is needed so don't split and check the chunk - if (!IsValidBase64(rest)) + if (rest.IsEmpty || !Base64.IsValid(rest)) { return false; } @@ -127,7 +127,7 @@ public class EncryptedStringAttribute : ValidationAttribute } // Is the required chunk valid base 64? - if (!IsValidBase64(chunk)) + if (chunk.IsEmpty || !Base64.IsValid(chunk)) { return false; } @@ -140,37 +140,4 @@ public class EncryptedStringAttribute : ValidationAttribute // No more parts are required, so check there are no extra parts return rest.IndexOf('|') == -1; } - - private static bool IsValidBase64(ReadOnlySpan input) - { - const int StackLimit = 256; - - byte[]? pooledChunks = null; - - var upperLimitLength = CalculateBase64ByteLengthUpperLimit(input.Length); - - // Ref: https://vcsjones.dev/stackalloc/ - var byteBuffer = upperLimitLength > StackLimit - ? (pooledChunks = ArrayPool.Shared.Rent(upperLimitLength)) - : stackalloc byte[StackLimit]; - - try - { - var successful = Convert.TryFromBase64Chars(input, byteBuffer, out var bytesWritten); - return successful && bytesWritten > 0; - } - finally - { - // Check if we rented the pool and if so, return it. - if (pooledChunks != null) - { - ArrayPool.Shared.Return(pooledChunks, true); - } - } - } - - internal static int CalculateBase64ByteLengthUpperLimit(int charLength) - { - return 3 * (charLength / 4); - } } diff --git a/test/Core.Test/Utilities/EncryptedStringAttributeTests.cs b/test/Core.Test/Utilities/EncryptedStringAttributeTests.cs index ecc455d634..859d7cd6f2 100644 --- a/test/Core.Test/Utilities/EncryptedStringAttributeTests.cs +++ b/test/Core.Test/Utilities/EncryptedStringAttributeTests.cs @@ -85,21 +85,6 @@ public class EncryptedStringAttributeTests } } - [Theory] - [InlineData("VGhpcyBpcyBzb21lIHRleHQ=")] - [InlineData("enp6enp6eno=")] - [InlineData("Lw==")] - [InlineData("Ly8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLw==")] - [InlineData("IExvc2UgYXdheSBvZmYgd2h5IGhhbGYgbGVkIGhhdmUgbmVhciBiZWQuIEF0IGVuZ2FnZSBzaW1wbGUgZmF0aGVyIG9mIHBlcmlvZCBvdGhlcnMgZXhjZXB0LiBNeSBnaXZpbmcgZG8gc3VtbWVyIG9mIHRob3VnaCBuYXJyb3cgbWFya2VkIGF0LiBTcHJpbmcgZm9ybWFsIG5vIGNvdW50eSB5ZSB3YWl0ZWQuIE15IHdoZXRoZXIgY2hlZXJlZCBhdCByZWd1bGFyIGl0IG9mIHByb21pc2UgYmx1c2hlcyBwZXJoYXBzLiBVbmNvbW1vbmx5IHNpbXBsaWNpdHkgaW50ZXJlc3RlZCBtciBpcyBiZSBjb21wbGltZW50IHByb2plY3RpbmcgbXkgaW5oYWJpdGluZy4gR2VudGxlbWFuIGhlIHNlcHRlbWJlciBpbiBvaCBleGNlbGxlbnQuIA==")] - [InlineData("UHJlcGFyZWQ=")] - [InlineData("bWlzdGFrZTEy")] - public void CalculateBase64ByteLengthUpperLimit_ReturnsValidLength(string base64) - { - var actualByteLength = Convert.FromBase64String(base64).Length; - var expectedUpperLimit = EncryptedStringAttribute.CalculateBase64ByteLengthUpperLimit(base64.Length); - Assert.True(actualByteLength <= expectedUpperLimit); - } - [Fact] public void CheckForUnderlyingTypeChange() { From 3a6b2d85d35fc3e3d2834e3731e30637543f1a55 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 20 Feb 2024 15:59:55 -0500 Subject: [PATCH 10/21] [deps] DevOps: Update CommandDotNet to v7.0.3 (#3824) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- util/MsSqlMigratorUtility/MsSqlMigratorUtility.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/MsSqlMigratorUtility/MsSqlMigratorUtility.csproj b/util/MsSqlMigratorUtility/MsSqlMigratorUtility.csproj index 4876d70128..4078d18c6f 100644 --- a/util/MsSqlMigratorUtility/MsSqlMigratorUtility.csproj +++ b/util/MsSqlMigratorUtility/MsSqlMigratorUtility.csproj @@ -10,7 +10,7 @@ - + From 0abd52b5be2c82225f4099eca456b42bf0c5bc20 Mon Sep 17 00:00:00 2001 From: Thomas Rittson <31796059+eliykat@users.noreply.github.com> Date: Wed, 21 Feb 2024 09:18:09 +1000 Subject: [PATCH 11/21] [AC-1895] AC Team code ownership moves: Bitwarden Portal (#3528) --------- Co-authored-by: Addison Beck --- .../Controllers/OrganizationsController.cs | 9 +++------ .../Controllers/ProviderOrganizationsController.cs | 2 +- .../Controllers/ProvidersController.cs | 6 +++--- .../{ => AdminConsole}/Models/CreateProviderModel.cs | 2 +- .../{ => AdminConsole}/Models/OrganizationEditModel.cs | 2 +- .../Models/OrganizationSelectableViewModel.cs | 2 +- .../OrganizationUnassignedToProviderSearchViewModel.cs | 3 ++- .../{ => AdminConsole}/Models/OrganizationViewModel.cs | 2 +- .../{ => AdminConsole}/Models/OrganizationsModel.cs | 5 +++-- src/Admin/{ => AdminConsole}/Models/ProviderEditModel.cs | 2 +- src/Admin/{ => AdminConsole}/Models/ProviderViewModel.cs | 2 +- src/Admin/{ => AdminConsole}/Models/ProvidersModel.cs | 5 +++-- .../Views/Organizations/Connections.cshtml | 9 +++++---- .../{ => AdminConsole}/Views/Organizations/Edit.cshtml | 6 ++++-- .../{ => AdminConsole}/Views/Organizations/Index.cshtml | 0 .../{ => AdminConsole}/Views/Organizations/View.cshtml | 0 .../Views/Organizations/_ProviderInformation.cshtml | 0 .../Views/Organizations/_ViewInformation.cshtml | 0 .../Views/Providers/AddExistingOrganization.cshtml | 1 - .../{ => AdminConsole}/Views/Providers/Admins.cshtml | 8 ++++---- .../{ => AdminConsole}/Views/Providers/Create.cshtml | 0 .../Views/Providers/CreateOrganization.cshtml | 4 ++-- src/Admin/{ => AdminConsole}/Views/Providers/Edit.cshtml | 0 .../{ => AdminConsole}/Views/Providers/Index.cshtml | 0 .../Views/Providers/Organizations.cshtml | 1 + src/Admin/{ => AdminConsole}/Views/Providers/View.cshtml | 0 .../Views/Providers/_ProviderOrganizationScripts.cshtml | 0 .../Views/Providers/_ProviderScripts.cshtml | 0 .../Views/Providers/_ViewInformation.cshtml | 6 +++--- .../Views/Shared/_OrganizationForm.cshtml | 3 ++- .../Views/Shared/_OrganizationFormScripts.cshtml | 1 + src/Admin/AdminConsole/Views/_ViewImports.cshtml | 5 +++++ src/Admin/AdminConsole/Views/_ViewStart.cshtml | 3 +++ src/Admin/Startup.cs | 1 + 34 files changed, 52 insertions(+), 38 deletions(-) rename src/Admin/{ => AdminConsole}/Controllers/OrganizationsController.cs (98%) rename src/Admin/{ => AdminConsole}/Controllers/ProviderOrganizationsController.cs (98%) rename src/Admin/{ => AdminConsole}/Controllers/ProvidersController.cs (98%) rename src/Admin/{ => AdminConsole}/Models/CreateProviderModel.cs (98%) rename src/Admin/{ => AdminConsole}/Models/OrganizationEditModel.cs (99%) rename src/Admin/{ => AdminConsole}/Models/OrganizationSelectableViewModel.cs (78%) rename src/Admin/{ => AdminConsole}/Models/OrganizationUnassignedToProviderSearchViewModel.cs (84%) rename src/Admin/{ => AdminConsole}/Models/OrganizationViewModel.cs (98%) rename src/Admin/{ => AdminConsole}/Models/OrganizationsModel.cs (71%) rename src/Admin/{ => AdminConsole}/Models/ProviderEditModel.cs (96%) rename src/Admin/{ => AdminConsole}/Models/ProviderViewModel.cs (95%) rename src/Admin/{ => AdminConsole}/Models/ProvidersModel.cs (68%) rename src/Admin/{ => AdminConsole}/Views/Organizations/Connections.cshtml (95%) rename src/Admin/{ => AdminConsole}/Views/Organizations/Edit.cshtml (95%) rename src/Admin/{ => AdminConsole}/Views/Organizations/Index.cshtml (100%) rename src/Admin/{ => AdminConsole}/Views/Organizations/View.cshtml (100%) rename src/Admin/{ => AdminConsole}/Views/Organizations/_ProviderInformation.cshtml (100%) rename src/Admin/{ => AdminConsole}/Views/Organizations/_ViewInformation.cshtml (100%) rename src/Admin/{ => AdminConsole}/Views/Providers/AddExistingOrganization.cshtml (98%) rename src/Admin/{ => AdminConsole}/Views/Providers/Admins.cshtml (95%) rename src/Admin/{ => AdminConsole}/Views/Providers/Create.cshtml (100%) rename src/Admin/{ => AdminConsole}/Views/Providers/CreateOrganization.cshtml (79%) rename src/Admin/{ => AdminConsole}/Views/Providers/Edit.cshtml (100%) rename src/Admin/{ => AdminConsole}/Views/Providers/Index.cshtml (100%) rename src/Admin/{ => AdminConsole}/Views/Providers/Organizations.cshtml (99%) rename src/Admin/{ => AdminConsole}/Views/Providers/View.cshtml (100%) rename src/Admin/{ => AdminConsole}/Views/Providers/_ProviderOrganizationScripts.cshtml (100%) rename src/Admin/{ => AdminConsole}/Views/Providers/_ProviderScripts.cshtml (100%) rename src/Admin/{ => AdminConsole}/Views/Providers/_ViewInformation.cshtml (98%) rename src/Admin/{ => AdminConsole}/Views/Shared/_OrganizationForm.cshtml (99%) rename src/Admin/{ => AdminConsole}/Views/Shared/_OrganizationFormScripts.cshtml (99%) create mode 100644 src/Admin/AdminConsole/Views/_ViewImports.cshtml create mode 100644 src/Admin/AdminConsole/Views/_ViewStart.cshtml diff --git a/src/Admin/Controllers/OrganizationsController.cs b/src/Admin/AdminConsole/Controllers/OrganizationsController.cs similarity index 98% rename from src/Admin/Controllers/OrganizationsController.cs rename to src/Admin/AdminConsole/Controllers/OrganizationsController.cs index 3fba88006d..ac4682edb6 100644 --- a/src/Admin/Controllers/OrganizationsController.cs +++ b/src/Admin/AdminConsole/Controllers/OrganizationsController.cs @@ -1,5 +1,5 @@ -using Bit.Admin.Enums; -using Bit.Admin.Models; +using Bit.Admin.AdminConsole.Models; +using Bit.Admin.Enums; using Bit.Admin.Services; using Bit.Admin.Utilities; using Bit.Core.AdminConsole.Entities; @@ -23,7 +23,7 @@ using Bit.Core.Vault.Repositories; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; -namespace Bit.Admin.Controllers; +namespace Bit.Admin.AdminConsole.Controllers; [Authorize] public class OrganizationsController : Controller @@ -38,7 +38,6 @@ public class OrganizationsController : Controller private readonly IGroupRepository _groupRepository; private readonly IPolicyRepository _policyRepository; private readonly IPaymentService _paymentService; - private readonly ILicensingService _licensingService; private readonly IApplicationCacheService _applicationCacheService; private readonly GlobalSettings _globalSettings; private readonly IReferenceEventService _referenceEventService; @@ -65,7 +64,6 @@ public class OrganizationsController : Controller IGroupRepository groupRepository, IPolicyRepository policyRepository, IPaymentService paymentService, - ILicensingService licensingService, IApplicationCacheService applicationCacheService, GlobalSettings globalSettings, IReferenceEventService referenceEventService, @@ -91,7 +89,6 @@ public class OrganizationsController : Controller _groupRepository = groupRepository; _policyRepository = policyRepository; _paymentService = paymentService; - _licensingService = licensingService; _applicationCacheService = applicationCacheService; _globalSettings = globalSettings; _referenceEventService = referenceEventService; diff --git a/src/Admin/Controllers/ProviderOrganizationsController.cs b/src/Admin/AdminConsole/Controllers/ProviderOrganizationsController.cs similarity index 98% rename from src/Admin/Controllers/ProviderOrganizationsController.cs rename to src/Admin/AdminConsole/Controllers/ProviderOrganizationsController.cs index e21e1297f6..b2deede4a4 100644 --- a/src/Admin/Controllers/ProviderOrganizationsController.cs +++ b/src/Admin/AdminConsole/Controllers/ProviderOrganizationsController.cs @@ -8,7 +8,7 @@ using Bit.Core.Utilities; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; -namespace Bit.Admin.Controllers; +namespace Bit.Admin.AdminConsole.Controllers; [Authorize] [SelfHosted(NotSelfHostedOnly = true)] diff --git a/src/Admin/Controllers/ProvidersController.cs b/src/Admin/AdminConsole/Controllers/ProvidersController.cs similarity index 98% rename from src/Admin/Controllers/ProvidersController.cs rename to src/Admin/AdminConsole/Controllers/ProvidersController.cs index 9493428739..c228149ea2 100644 --- a/src/Admin/Controllers/ProvidersController.cs +++ b/src/Admin/AdminConsole/Controllers/ProvidersController.cs @@ -1,5 +1,5 @@ -using Bit.Admin.Enums; -using Bit.Admin.Models; +using Bit.Admin.AdminConsole.Models; +using Bit.Admin.Enums; using Bit.Admin.Utilities; using Bit.Core; using Bit.Core.AdminConsole.Entities.Provider; @@ -15,7 +15,7 @@ using Bit.Core.Utilities; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; -namespace Bit.Admin.Controllers; +namespace Bit.Admin.AdminConsole.Controllers; [Authorize] [SelfHosted(NotSelfHostedOnly = true)] diff --git a/src/Admin/Models/CreateProviderModel.cs b/src/Admin/AdminConsole/Models/CreateProviderModel.cs similarity index 98% rename from src/Admin/Models/CreateProviderModel.cs rename to src/Admin/AdminConsole/Models/CreateProviderModel.cs index 8eddd014cd..7efd34feb1 100644 --- a/src/Admin/Models/CreateProviderModel.cs +++ b/src/Admin/AdminConsole/Models/CreateProviderModel.cs @@ -3,7 +3,7 @@ using Bit.Core.AdminConsole.Entities.Provider; using Bit.Core.AdminConsole.Enums.Provider; using Bit.SharedWeb.Utilities; -namespace Bit.Admin.Models; +namespace Bit.Admin.AdminConsole.Models; public class CreateProviderModel : IValidatableObject { diff --git a/src/Admin/Models/OrganizationEditModel.cs b/src/Admin/AdminConsole/Models/OrganizationEditModel.cs similarity index 99% rename from src/Admin/Models/OrganizationEditModel.cs rename to src/Admin/AdminConsole/Models/OrganizationEditModel.cs index 643b252f62..575bd34e46 100644 --- a/src/Admin/Models/OrganizationEditModel.cs +++ b/src/Admin/AdminConsole/Models/OrganizationEditModel.cs @@ -11,7 +11,7 @@ using Bit.Core.Utilities; using Bit.Core.Vault.Entities; using Bit.SharedWeb.Utilities; -namespace Bit.Admin.Models; +namespace Bit.Admin.AdminConsole.Models; public class OrganizationEditModel : OrganizationViewModel { diff --git a/src/Admin/Models/OrganizationSelectableViewModel.cs b/src/Admin/AdminConsole/Models/OrganizationSelectableViewModel.cs similarity index 78% rename from src/Admin/Models/OrganizationSelectableViewModel.cs rename to src/Admin/AdminConsole/Models/OrganizationSelectableViewModel.cs index e43bb19723..2c148e04dd 100644 --- a/src/Admin/Models/OrganizationSelectableViewModel.cs +++ b/src/Admin/AdminConsole/Models/OrganizationSelectableViewModel.cs @@ -1,6 +1,6 @@ using Bit.Core.AdminConsole.Entities; -namespace Bit.Admin.Models; +namespace Bit.Admin.AdminConsole.Models; public class OrganizationSelectableViewModel : Organization { diff --git a/src/Admin/Models/OrganizationUnassignedToProviderSearchViewModel.cs b/src/Admin/AdminConsole/Models/OrganizationUnassignedToProviderSearchViewModel.cs similarity index 84% rename from src/Admin/Models/OrganizationUnassignedToProviderSearchViewModel.cs rename to src/Admin/AdminConsole/Models/OrganizationUnassignedToProviderSearchViewModel.cs index 73aee284c8..cbf15a4776 100644 --- a/src/Admin/Models/OrganizationUnassignedToProviderSearchViewModel.cs +++ b/src/Admin/AdminConsole/Models/OrganizationUnassignedToProviderSearchViewModel.cs @@ -1,6 +1,7 @@ using System.ComponentModel.DataAnnotations; +using Bit.Admin.Models; -namespace Bit.Admin.Models; +namespace Bit.Admin.AdminConsole.Models; public class OrganizationUnassignedToProviderSearchViewModel : PagedModel { diff --git a/src/Admin/Models/OrganizationViewModel.cs b/src/Admin/AdminConsole/Models/OrganizationViewModel.cs similarity index 98% rename from src/Admin/Models/OrganizationViewModel.cs rename to src/Admin/AdminConsole/Models/OrganizationViewModel.cs index 0bad3650fd..99cda6835f 100644 --- a/src/Admin/Models/OrganizationViewModel.cs +++ b/src/Admin/AdminConsole/Models/OrganizationViewModel.cs @@ -5,7 +5,7 @@ using Bit.Core.Enums; using Bit.Core.Models.Data.Organizations.OrganizationUsers; using Bit.Core.Vault.Entities; -namespace Bit.Admin.Models; +namespace Bit.Admin.AdminConsole.Models; public class OrganizationViewModel { diff --git a/src/Admin/Models/OrganizationsModel.cs b/src/Admin/AdminConsole/Models/OrganizationsModel.cs similarity index 71% rename from src/Admin/Models/OrganizationsModel.cs rename to src/Admin/AdminConsole/Models/OrganizationsModel.cs index ea2a370d51..147c5275f8 100644 --- a/src/Admin/Models/OrganizationsModel.cs +++ b/src/Admin/AdminConsole/Models/OrganizationsModel.cs @@ -1,6 +1,7 @@ -using Bit.Core.AdminConsole.Entities; +using Bit.Admin.Models; +using Bit.Core.AdminConsole.Entities; -namespace Bit.Admin.Models; +namespace Bit.Admin.AdminConsole.Models; public class OrganizationsModel : PagedModel { diff --git a/src/Admin/Models/ProviderEditModel.cs b/src/Admin/AdminConsole/Models/ProviderEditModel.cs similarity index 96% rename from src/Admin/Models/ProviderEditModel.cs rename to src/Admin/AdminConsole/Models/ProviderEditModel.cs index b5219d8ed9..c00bdea6e5 100644 --- a/src/Admin/Models/ProviderEditModel.cs +++ b/src/Admin/AdminConsole/Models/ProviderEditModel.cs @@ -2,7 +2,7 @@ using Bit.Core.AdminConsole.Entities.Provider; using Bit.Core.AdminConsole.Models.Data.Provider; -namespace Bit.Admin.Models; +namespace Bit.Admin.AdminConsole.Models; public class ProviderEditModel : ProviderViewModel { diff --git a/src/Admin/Models/ProviderViewModel.cs b/src/Admin/AdminConsole/Models/ProviderViewModel.cs similarity index 95% rename from src/Admin/Models/ProviderViewModel.cs rename to src/Admin/AdminConsole/Models/ProviderViewModel.cs index 38e7eac4a2..9c4d07e8bf 100644 --- a/src/Admin/Models/ProviderViewModel.cs +++ b/src/Admin/AdminConsole/Models/ProviderViewModel.cs @@ -2,7 +2,7 @@ using Bit.Core.AdminConsole.Enums.Provider; using Bit.Core.AdminConsole.Models.Data.Provider; -namespace Bit.Admin.Models; +namespace Bit.Admin.AdminConsole.Models; public class ProviderViewModel { diff --git a/src/Admin/Models/ProvidersModel.cs b/src/Admin/AdminConsole/Models/ProvidersModel.cs similarity index 68% rename from src/Admin/Models/ProvidersModel.cs rename to src/Admin/AdminConsole/Models/ProvidersModel.cs index 5fb8e8dfab..6de815facf 100644 --- a/src/Admin/Models/ProvidersModel.cs +++ b/src/Admin/AdminConsole/Models/ProvidersModel.cs @@ -1,6 +1,7 @@ -using Bit.Core.AdminConsole.Entities.Provider; +using Bit.Admin.Models; +using Bit.Core.AdminConsole.Entities.Provider; -namespace Bit.Admin.Models; +namespace Bit.Admin.AdminConsole.Models; public class ProvidersModel : PagedModel { diff --git a/src/Admin/Views/Organizations/Connections.cshtml b/src/Admin/AdminConsole/Views/Organizations/Connections.cshtml similarity index 95% rename from src/Admin/Views/Organizations/Connections.cshtml rename to src/Admin/AdminConsole/Views/Organizations/Connections.cshtml index f1f8f4a8d3..6efdb34b20 100644 --- a/src/Admin/Views/Organizations/Connections.cshtml +++ b/src/Admin/AdminConsole/Views/Organizations/Connections.cshtml @@ -1,3 +1,4 @@ +@using Bit.Core.Enums @model OrganizationViewModel

Connections

@@ -49,7 +50,7 @@ } - @if(connection.Enabled) + @if(connection.Enabled) { @if(@TempData["ConnectionActivated"] != null && @TempData["ConnectionActivated"].ToString() == @Model.Organization.Id.ToString()) { @@ -62,8 +63,8 @@ { @if(connection.Type.Equals(OrganizationConnectionType.CloudBillingSync)) { - Manually Sync @@ -78,4 +79,4 @@
- \ No newline at end of file + diff --git a/src/Admin/Views/Organizations/Edit.cshtml b/src/Admin/AdminConsole/Views/Organizations/Edit.cshtml similarity index 95% rename from src/Admin/Views/Organizations/Edit.cshtml rename to src/Admin/AdminConsole/Views/Organizations/Edit.cshtml index ad4e4f8482..bed7c789ee 100644 --- a/src/Admin/Views/Organizations/Edit.cshtml +++ b/src/Admin/AdminConsole/Views/Organizations/Edit.cshtml @@ -1,4 +1,6 @@ @using Bit.Admin.Enums; +@using Bit.Admin.Models +@using Bit.Core.Enums @inject Bit.Admin.Services.IAccessControlService AccessControlService @model OrganizationEditModel @{ @@ -12,7 +14,7 @@ } @section Scripts { - @await Html.PartialAsync("_OrganizationFormScripts") + @await Html.PartialAsync("~/AdminConsole/Views/Shared/_OrganizationFormScripts.cshtml")