From e78e482c0d7d9157ed84267becc5a49417e8918c Mon Sep 17 00:00:00 2001 From: cyprain-okeke Date: Wed, 14 Jun 2023 14:20:59 +0100 Subject: [PATCH] Fix imports ordering --- .../ValidateUpgradeCommand.cs | 4 +- .../OrganizationSignUpCommand.cs | 10 ++-- .../OrganizationDomainRepository.cs | 4 +- .../SelfHostedOrganizationDetailsTests.cs | 57 ++++++++++++------- .../OrganizationUpgradePlanCommandTests.cs | 4 +- .../OrganizationUpgradeQueryTests.cs | 2 +- .../ValidateUpgradeCommandTests.cs | 4 +- ...ordManagerSignUpValidationStrategyTests.cs | 6 +- util/EfShared/MigrationBuilderExtensions.cs | 2 +- 9 files changed, 56 insertions(+), 37 deletions(-) diff --git a/src/Core/OrganizationFeatures/OrganizationPlanUpgrade/ValidateUpgradeCommand.cs b/src/Core/OrganizationFeatures/OrganizationPlanUpgrade/ValidateUpgradeCommand.cs index 9d3044d6e85d..918543f72299 100644 --- a/src/Core/OrganizationFeatures/OrganizationPlanUpgrade/ValidateUpgradeCommand.cs +++ b/src/Core/OrganizationFeatures/OrganizationPlanUpgrade/ValidateUpgradeCommand.cs @@ -1,11 +1,11 @@ using Bit.Core.AdminConsole.Models.OrganizationConnectionConfigs; using Bit.Core.Auth.Enums; using Bit.Core.Auth.Repositories; -using Bit.Core.Exceptions; -using Bit.Core.Models.StaticStore; using Bit.Core.Entities; using Bit.Core.Enums; +using Bit.Core.Exceptions; using Bit.Core.Models.Business; +using Bit.Core.Models.StaticStore; using Bit.Core.OrganizationFeatures.OrganizationPlanUpgrade.Interface; using Bit.Core.Repositories; diff --git a/src/Core/OrganizationFeatures/OrganizationSignUp/OrganizationSignUpCommand.cs b/src/Core/OrganizationFeatures/OrganizationSignUp/OrganizationSignUpCommand.cs index d605de9547d0..135b4156cd38 100644 --- a/src/Core/OrganizationFeatures/OrganizationSignUp/OrganizationSignUpCommand.cs +++ b/src/Core/OrganizationFeatures/OrganizationSignUp/OrganizationSignUpCommand.cs @@ -1,16 +1,16 @@ using Bit.Core.Context; using Bit.Core.Entities; using Bit.Core.Enums; -using Bit.Core.Models.Business; -using Bit.Core.Services; -using Bit.Core.Tools.Enums; -using Bit.Core.Tools.Models.Business; -using Bit.Core.Utilities; using Bit.Core.Exceptions; +using Bit.Core.Models.Business; using Bit.Core.Models.StaticStore; using Bit.Core.OrganizationFeatures.OrganizationSignUp.Interfaces; using Bit.Core.Repositories; +using Bit.Core.Services; +using Bit.Core.Tools.Enums; +using Bit.Core.Tools.Models.Business; using Bit.Core.Tools.Services; +using Bit.Core.Utilities; namespace Bit.Core.OrganizationFeatures.OrganizationSignUp; diff --git a/src/Infrastructure.EntityFramework/Repositories/OrganizationDomainRepository.cs b/src/Infrastructure.EntityFramework/Repositories/OrganizationDomainRepository.cs index 64438bf70489..08bee361227d 100644 --- a/src/Infrastructure.EntityFramework/Repositories/OrganizationDomainRepository.cs +++ b/src/Infrastructure.EntityFramework/Repositories/OrganizationDomainRepository.cs @@ -105,7 +105,7 @@ from s in sJoin.DefaultIfEmpty() return Mapper.Map(domain); } - public async Task> GetExpiredOrganizationDomainsAsync() + public Task> GetExpiredOrganizationDomainsAsync() { using var scope = ServiceScopeFactory.CreateScope(); var dbContext = GetDatabaseContext(scope); @@ -117,7 +117,7 @@ from s in sJoin.DefaultIfEmpty() && x.VerifiedDate == null) .ToList(); - return Mapper.Map>(domains); + return Task.FromResult(Mapper.Map>(domains)); } public async Task DeleteExpiredAsync(int expirationPeriod) diff --git a/test/Core.Test/Models/Data/SelfHostedOrganizationDetailsTests.cs b/test/Core.Test/Models/Data/SelfHostedOrganizationDetailsTests.cs index c0ab7b9c4014..b69b7e51bef0 100644 --- a/test/Core.Test/Models/Data/SelfHostedOrganizationDetailsTests.cs +++ b/test/Core.Test/Models/Data/SelfHostedOrganizationDetailsTests.cs @@ -17,7 +17,7 @@ public class SelfHostedOrganizationDetailsTests [Theory] [BitAutoData] [OrganizationLicenseCustomize] - public async Task ValidateForOrganization_Success(List orgUsers, + public Task ValidateForOrganization_Success(List orgUsers, List policies, SsoConfig ssoConfig, List> scimConnections, OrganizationLicense license) { var (orgDetails, orgLicense) = GetOrganizationAndLicense(orgUsers, policies, ssoConfig, scimConnections, license); @@ -26,12 +26,13 @@ public async Task ValidateForOrganization_Success(List orgUser Assert.True(result); Assert.True(string.IsNullOrEmpty(exception)); + return Task.CompletedTask; } [Theory] [BitAutoData] [OrganizationLicenseCustomize] - public async Task ValidateForOrganization_OccupiedSeatCount_ExceedsLicense_Fail(List orgUsers, + public Task ValidateForOrganization_OccupiedSeatCount_ExceedsLicense_Fail(List orgUsers, List policies, SsoConfig ssoConfig, List> scimConnections, OrganizationLicense license) { var (orgDetails, orgLicense) = GetOrganizationAndLicense(orgUsers, policies, ssoConfig, scimConnections, license); @@ -41,12 +42,13 @@ public async Task ValidateForOrganization_OccupiedSeatCount_ExceedsLicense_Fail( Assert.False(result); Assert.Contains("Remove some users", exception); + return Task.CompletedTask; } [Theory] [BitAutoData] [OrganizationLicenseCustomize] - public async Task ValidateForOrganization_MaxCollections_ExceedsLicense_Fail(List orgUsers, + public Task ValidateForOrganization_MaxCollections_ExceedsLicense_Fail(List orgUsers, List policies, SsoConfig ssoConfig, List> scimConnections, OrganizationLicense license) { var (orgDetails, orgLicense) = GetOrganizationAndLicense(orgUsers, policies, ssoConfig, scimConnections, license); @@ -56,12 +58,13 @@ public async Task ValidateForOrganization_MaxCollections_ExceedsLicense_Fail(Lis Assert.False(result); Assert.Contains("Remove some collections", exception); + return Task.CompletedTask; } [Theory] [BitAutoData] [OrganizationLicenseCustomize] - public async Task ValidateForOrganization_Groups_NotAllowedByLicense_Fail(List orgUsers, + public Task ValidateForOrganization_Groups_NotAllowedByLicense_Fail(List orgUsers, List policies, SsoConfig ssoConfig, List> scimConnections, OrganizationLicense license) { var (orgDetails, orgLicense) = GetOrganizationAndLicense(orgUsers, policies, ssoConfig, scimConnections, license); @@ -71,12 +74,13 @@ public async Task ValidateForOrganization_Groups_NotAllowedByLicense_Fail(List orgUsers, + public Task ValidateForOrganization_Policies_NotAllowedByLicense_Fail(List orgUsers, List policies, SsoConfig ssoConfig, List> scimConnections, OrganizationLicense license) { var (orgDetails, orgLicense) = GetOrganizationAndLicense(orgUsers, policies, ssoConfig, scimConnections, license); @@ -86,12 +90,13 @@ public async Task ValidateForOrganization_Policies_NotAllowedByLicense_Fail(List Assert.False(result); Assert.Contains("Your new license does not allow for the use of policies", exception); + return Task.CompletedTask; } [Theory] [BitAutoData] [OrganizationLicenseCustomize] - public async Task ValidateForOrganization_DisabledPolicies_NotAllowedByLicense_Success(List orgUsers, + public Task ValidateForOrganization_DisabledPolicies_NotAllowedByLicense_Success(List orgUsers, List policies, SsoConfig ssoConfig, List> scimConnections, OrganizationLicense license) { var (orgDetails, orgLicense) = GetOrganizationAndLicense(orgUsers, policies, ssoConfig, scimConnections, license); @@ -102,12 +107,13 @@ public async Task ValidateForOrganization_DisabledPolicies_NotAllowedByLicense_S Assert.True(result); Assert.True(string.IsNullOrEmpty(exception)); + return Task.CompletedTask; } [Theory] [BitAutoData] [OrganizationLicenseCustomize] - public async Task ValidateForOrganization_Sso_NotAllowedByLicense_Fail(List orgUsers, + public Task ValidateForOrganization_Sso_NotAllowedByLicense_Fail(List orgUsers, List policies, SsoConfig ssoConfig, List> scimConnections, OrganizationLicense license) { var (orgDetails, orgLicense) = GetOrganizationAndLicense(orgUsers, policies, ssoConfig, scimConnections, license); @@ -117,12 +123,13 @@ public async Task ValidateForOrganization_Sso_NotAllowedByLicense_Fail(List orgUsers, + public Task ValidateForOrganization_DisabledSso_NotAllowedByLicense_Success(List orgUsers, List policies, SsoConfig ssoConfig, List> scimConnections, OrganizationLicense license) { var (orgDetails, orgLicense) = GetOrganizationAndLicense(orgUsers, policies, ssoConfig, scimConnections, license); @@ -133,12 +140,13 @@ public async Task ValidateForOrganization_DisabledSso_NotAllowedByLicense_Succes Assert.True(result); Assert.True(string.IsNullOrEmpty(exception)); + return Task.CompletedTask; } [Theory] [BitAutoData] [OrganizationLicenseCustomize] - public async Task ValidateForOrganization_NoSso_NotAllowedByLicense_Success(List orgUsers, + public Task ValidateForOrganization_NoSso_NotAllowedByLicense_Success(List orgUsers, List policies, SsoConfig ssoConfig, List> scimConnections, OrganizationLicense license) { var (orgDetails, orgLicense) = GetOrganizationAndLicense(orgUsers, policies, ssoConfig, scimConnections, license); @@ -149,12 +157,13 @@ public async Task ValidateForOrganization_NoSso_NotAllowedByLicense_Success(List Assert.True(result); Assert.True(string.IsNullOrEmpty(exception)); + return Task.CompletedTask; } [Theory] [BitAutoData] [OrganizationLicenseCustomize] - public async Task ValidateForOrganization_KeyConnector_NotAllowedByLicense_Fail(List orgUsers, + public Task ValidateForOrganization_KeyConnector_NotAllowedByLicense_Fail(List orgUsers, List policies, SsoConfig ssoConfig, List> scimConnections, OrganizationLicense license) { var (orgDetails, orgLicense) = GetOrganizationAndLicense(orgUsers, policies, ssoConfig, scimConnections, license); @@ -164,12 +173,13 @@ public async Task ValidateForOrganization_KeyConnector_NotAllowedByLicense_Fail( Assert.False(result); Assert.Contains("Your new license does not allow for the use of Key Connector", exception); + return Task.CompletedTask; } [Theory] [BitAutoData] [OrganizationLicenseCustomize] - public async Task ValidateForOrganization_DisabledKeyConnector_NotAllowedByLicense_Success(List orgUsers, + public Task ValidateForOrganization_DisabledKeyConnector_NotAllowedByLicense_Success(List orgUsers, List policies, SsoConfig ssoConfig, List> scimConnections, OrganizationLicense license) { var (orgDetails, orgLicense) = GetOrganizationAndLicense(orgUsers, policies, ssoConfig, scimConnections, license); @@ -180,12 +190,13 @@ public async Task ValidateForOrganization_DisabledKeyConnector_NotAllowedByLicen Assert.True(result); Assert.True(string.IsNullOrEmpty(exception)); + return Task.CompletedTask; } [Theory] [BitAutoData] [OrganizationLicenseCustomize] - public async Task ValidateForOrganization_NoSsoKeyConnector_NotAllowedByLicense_Success(List orgUsers, + public Task ValidateForOrganization_NoSsoKeyConnector_NotAllowedByLicense_Success(List orgUsers, List policies, SsoConfig ssoConfig, List> scimConnections, OrganizationLicense license) { var (orgDetails, orgLicense) = GetOrganizationAndLicense(orgUsers, policies, ssoConfig, scimConnections, license); @@ -196,12 +207,13 @@ public async Task ValidateForOrganization_NoSsoKeyConnector_NotAllowedByLicense_ Assert.True(result); Assert.True(string.IsNullOrEmpty(exception)); + return Task.CompletedTask; } [Theory] [BitAutoData] [OrganizationLicenseCustomize] - public async Task ValidateForOrganization_Scim_NotAllowedByLicense_Fail(List orgUsers, + public Task ValidateForOrganization_Scim_NotAllowedByLicense_Fail(List orgUsers, List policies, SsoConfig ssoConfig, List> scimConnections, OrganizationLicense license) { var (orgDetails, orgLicense) = GetOrganizationAndLicense(orgUsers, policies, ssoConfig, scimConnections, license); @@ -211,12 +223,13 @@ public async Task ValidateForOrganization_Scim_NotAllowedByLicense_Fail(List orgUsers, + public Task ValidateForOrganization_DisabledScim_NotAllowedByLicense_Success(List orgUsers, List policies, SsoConfig ssoConfig, List> scimConnections, OrganizationLicense license) { var (orgDetails, orgLicense) = GetOrganizationAndLicense(orgUsers, policies, ssoConfig, scimConnections, license); @@ -228,12 +241,13 @@ public async Task ValidateForOrganization_DisabledScim_NotAllowedByLicense_Succe Assert.True(result); Assert.True(string.IsNullOrEmpty(exception)); + return Task.CompletedTask; } [Theory] [BitAutoData] [OrganizationLicenseCustomize] - public async Task ValidateForOrganization_NoScimConfig_NotAllowedByLicense_Success(List orgUsers, + public Task ValidateForOrganization_NoScimConfig_NotAllowedByLicense_Success(List orgUsers, List policies, SsoConfig ssoConfig, List> scimConnections, OrganizationLicense license) { var (orgDetails, orgLicense) = GetOrganizationAndLicense(orgUsers, policies, ssoConfig, scimConnections, license); @@ -244,12 +258,13 @@ public async Task ValidateForOrganization_NoScimConfig_NotAllowedByLicense_Succe Assert.True(result); Assert.True(string.IsNullOrEmpty(exception)); + return Task.CompletedTask; } [Theory] [BitAutoData] [OrganizationLicenseCustomize] - public async Task ValidateForOrganization_CustomPermissions_NotAllowedByLicense_Fail(List orgUsers, + public Task ValidateForOrganization_CustomPermissions_NotAllowedByLicense_Fail(List orgUsers, List policies, SsoConfig ssoConfig, List> scimConnections, OrganizationLicense license) { var (orgDetails, orgLicense) = GetOrganizationAndLicense(orgUsers, policies, ssoConfig, scimConnections, license); @@ -259,12 +274,13 @@ public async Task ValidateForOrganization_CustomPermissions_NotAllowedByLicense_ Assert.False(result); Assert.Contains("Your new plan does not allow the Custom Permissions feature", exception); + return Task.CompletedTask; } [Theory] [BitAutoData] [OrganizationLicenseCustomize] - public async Task ValidateForOrganization_NoCustomPermissions_NotAllowedByLicense_Success(List orgUsers, + public Task ValidateForOrganization_NoCustomPermissions_NotAllowedByLicense_Success(List orgUsers, List policies, SsoConfig ssoConfig, List> scimConnections, OrganizationLicense license) { var (orgDetails, orgLicense) = GetOrganizationAndLicense(orgUsers, policies, ssoConfig, scimConnections, license); @@ -275,12 +291,13 @@ public async Task ValidateForOrganization_NoCustomPermissions_NotAllowedByLicens Assert.True(result); Assert.True(string.IsNullOrEmpty(exception)); + return Task.CompletedTask; } [Theory] [BitAutoData] [OrganizationLicenseCustomize] - public async Task ValidateForOrganization_ResetPassword_NotAllowedByLicense_Fail(List orgUsers, + public Task ValidateForOrganization_ResetPassword_NotAllowedByLicense_Fail(List orgUsers, List policies, SsoConfig ssoConfig, List> scimConnections, OrganizationLicense license) { var (orgDetails, orgLicense) = GetOrganizationAndLicense(orgUsers, policies, ssoConfig, scimConnections, license); @@ -290,12 +307,13 @@ public async Task ValidateForOrganization_ResetPassword_NotAllowedByLicense_Fail Assert.False(result); Assert.Contains("Your new license does not allow the Password Reset feature", exception); + return Task.CompletedTask; } [Theory] [BitAutoData] [OrganizationLicenseCustomize] - public async Task ValidateForOrganization_DisabledResetPassword_NotAllowedByLicense_Success(List orgUsers, + public Task ValidateForOrganization_DisabledResetPassword_NotAllowedByLicense_Success(List orgUsers, List policies, SsoConfig ssoConfig, List> scimConnections, OrganizationLicense license) { var (orgDetails, orgLicense) = GetOrganizationAndLicense(orgUsers, policies, ssoConfig, scimConnections, license); @@ -306,6 +324,7 @@ public async Task ValidateForOrganization_DisabledResetPassword_NotAllowedByLice Assert.True(result); Assert.True(string.IsNullOrEmpty(exception)); + return Task.CompletedTask; } private (SelfHostedOrganizationDetails organization, OrganizationLicense license) GetOrganizationAndLicense(List orgUsers, diff --git a/test/Core.Test/OrganizationFeatures/OrganizationPlanUpgrade/OrganizationUpgradePlanCommandTests.cs b/test/Core.Test/OrganizationFeatures/OrganizationPlanUpgrade/OrganizationUpgradePlanCommandTests.cs index ede730427b1f..f2411400df52 100644 --- a/test/Core.Test/OrganizationFeatures/OrganizationPlanUpgrade/OrganizationUpgradePlanCommandTests.cs +++ b/test/Core.Test/OrganizationFeatures/OrganizationPlanUpgrade/OrganizationUpgradePlanCommandTests.cs @@ -1,14 +1,14 @@ using Bit.Core.Context; using Bit.Core.Entities; using Bit.Core.Enums; +using Bit.Core.Exceptions; using Bit.Core.Models.Business; +using Bit.Core.Models.StaticStore; using Bit.Core.OrganizationFeatures.OrganizationPlanUpgrade; using Bit.Core.OrganizationFeatures.OrganizationPlanUpgrade.Interface; using Bit.Core.OrganizationFeatures.OrganizationSignUp.Interfaces; using Bit.Core.Services; -using Bit.Core.Models.StaticStore; using Bit.Core.Tools.Services; -using Bit.Core.Exceptions; using Bit.Test.Common.AutoFixture; using Bit.Test.Common.AutoFixture.Attributes; using NSubstitute; diff --git a/test/Core.Test/OrganizationFeatures/OrganizationPlanUpgrade/OrganizationUpgradeQueryTests.cs b/test/Core.Test/OrganizationFeatures/OrganizationPlanUpgrade/OrganizationUpgradeQueryTests.cs index 9ffb336958eb..914906f19be9 100644 --- a/test/Core.Test/OrganizationFeatures/OrganizationPlanUpgrade/OrganizationUpgradeQueryTests.cs +++ b/test/Core.Test/OrganizationFeatures/OrganizationPlanUpgrade/OrganizationUpgradeQueryTests.cs @@ -1,8 +1,8 @@ using Bit.Core.Entities; using Bit.Core.Enums; +using Bit.Core.Models.StaticStore; using Bit.Core.OrganizationFeatures.OrganizationPlanUpgrade; using Bit.Core.Repositories; -using Bit.Core.Models.StaticStore; using Bit.Core.Utilities; using Bit.Test.Common.AutoFixture; using Bit.Test.Common.AutoFixture.Attributes; diff --git a/test/Core.Test/OrganizationFeatures/OrganizationPlanUpgrade/ValidateUpgradeCommandTests.cs b/test/Core.Test/OrganizationFeatures/OrganizationPlanUpgrade/ValidateUpgradeCommandTests.cs index 0ccaaa2be3c1..2cef5743e880 100644 --- a/test/Core.Test/OrganizationFeatures/OrganizationPlanUpgrade/ValidateUpgradeCommandTests.cs +++ b/test/Core.Test/OrganizationFeatures/OrganizationPlanUpgrade/ValidateUpgradeCommandTests.cs @@ -2,11 +2,11 @@ using Bit.Core.Auth.Repositories; using Bit.Core.Entities; using Bit.Core.Enums; -using Bit.Core.OrganizationFeatures.OrganizationPlanUpgrade; -using Bit.Core.Repositories; using Bit.Core.Exceptions; using Bit.Core.Models.Business; using Bit.Core.Models.StaticStore; +using Bit.Core.OrganizationFeatures.OrganizationPlanUpgrade; +using Bit.Core.Repositories; using Bit.Test.Common.AutoFixture; using Bit.Test.Common.AutoFixture.Attributes; using NSubstitute; diff --git a/test/Core.Test/OrganizationFeatures/OrganizationSignUp/PasswordManagerSignUpValidationStrategyTests.cs b/test/Core.Test/OrganizationFeatures/OrganizationSignUp/PasswordManagerSignUpValidationStrategyTests.cs index f12f1c4e9cce..44ba81ad9f80 100644 --- a/test/Core.Test/OrganizationFeatures/OrganizationSignUp/PasswordManagerSignUpValidationStrategyTests.cs +++ b/test/Core.Test/OrganizationFeatures/OrganizationSignUp/PasswordManagerSignUpValidationStrategyTests.cs @@ -1,11 +1,11 @@ -using Bit.Core.Exceptions; -using Bit.Core.Enums; +using Bit.Core.Enums; +using Bit.Core.Exceptions; using Bit.Core.Models.Business; using Bit.Core.Models.StaticStore; using Bit.Core.OrganizationFeatures.OrganizationSignUp; -using Xunit; using Bit.Test.Common.AutoFixture; using Bit.Test.Common.AutoFixture.Attributes; +using Xunit; namespace Bit.Core.Test.OrganizationFeatures.OrganizationSignUp; diff --git a/util/EfShared/MigrationBuilderExtensions.cs b/util/EfShared/MigrationBuilderExtensions.cs index b59ad207fb6e..0ad02f74c479 100644 --- a/util/EfShared/MigrationBuilderExtensions.cs +++ b/util/EfShared/MigrationBuilderExtensions.cs @@ -19,7 +19,7 @@ public static class MigrationBuilderExtensions /// The MigrationBuilder instance the sql should be applied to /// The file name portion of the resource name, it is assumed to be in a Scripts folder /// The direction of the migration taking place - public static void SqlResource(this MigrationBuilder migrationBuilder, string resourceName, [CallerMemberName] string dir = null) + public static void SqlResource(this MigrationBuilder migrationBuilder, string resourceName, [CallerMemberName] string? dir = null) { var formattedResourceName = string.IsNullOrEmpty(dir) ? resourceName : string.Format(resourceName, dir);