Skip to content

Commit

Permalink
Fix imports ordering
Browse files Browse the repository at this point in the history
  • Loading branch information
cyprain-okeke committed Jun 14, 2023
1 parent aa6cdb4 commit e78e482
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 37 deletions.
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ from s in sJoin.DefaultIfEmpty()
return Mapper.Map<Core.Entities.OrganizationDomain>(domain);
}

public async Task<ICollection<Core.Entities.OrganizationDomain>> GetExpiredOrganizationDomainsAsync()
public Task<ICollection<Core.Entities.OrganizationDomain>> GetExpiredOrganizationDomainsAsync()
{
using var scope = ServiceScopeFactory.CreateScope();
var dbContext = GetDatabaseContext(scope);
Expand All @@ -117,7 +117,7 @@ from s in sJoin.DefaultIfEmpty()
&& x.VerifiedDate == null)
.ToList();

return Mapper.Map<List<Core.Entities.OrganizationDomain>>(domains);
return Task.FromResult(Mapper.Map<List<Core.Entities.OrganizationDomain>>(domains));
}

public async Task<bool> DeleteExpiredAsync(int expirationPeriod)
Expand Down
57 changes: 38 additions & 19 deletions test/Core.Test/Models/Data/SelfHostedOrganizationDetailsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class SelfHostedOrganizationDetailsTests
[Theory]
[BitAutoData]
[OrganizationLicenseCustomize]
public async Task ValidateForOrganization_Success(List<OrganizationUser> orgUsers,
public Task ValidateForOrganization_Success(List<OrganizationUser> orgUsers,
List<Policy> policies, SsoConfig ssoConfig, List<OrganizationConnection<ScimConfig>> scimConnections, OrganizationLicense license)
{
var (orgDetails, orgLicense) = GetOrganizationAndLicense(orgUsers, policies, ssoConfig, scimConnections, license);
Expand All @@ -26,12 +26,13 @@ public async Task ValidateForOrganization_Success(List<OrganizationUser> orgUser

Assert.True(result);
Assert.True(string.IsNullOrEmpty(exception));
return Task.CompletedTask;
}

[Theory]
[BitAutoData]
[OrganizationLicenseCustomize]
public async Task ValidateForOrganization_OccupiedSeatCount_ExceedsLicense_Fail(List<OrganizationUser> orgUsers,
public Task ValidateForOrganization_OccupiedSeatCount_ExceedsLicense_Fail(List<OrganizationUser> orgUsers,
List<Policy> policies, SsoConfig ssoConfig, List<OrganizationConnection<ScimConfig>> scimConnections, OrganizationLicense license)
{
var (orgDetails, orgLicense) = GetOrganizationAndLicense(orgUsers, policies, ssoConfig, scimConnections, license);
Expand All @@ -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<OrganizationUser> orgUsers,
public Task ValidateForOrganization_MaxCollections_ExceedsLicense_Fail(List<OrganizationUser> orgUsers,
List<Policy> policies, SsoConfig ssoConfig, List<OrganizationConnection<ScimConfig>> scimConnections, OrganizationLicense license)
{
var (orgDetails, orgLicense) = GetOrganizationAndLicense(orgUsers, policies, ssoConfig, scimConnections, license);
Expand All @@ -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<OrganizationUser> orgUsers,
public Task ValidateForOrganization_Groups_NotAllowedByLicense_Fail(List<OrganizationUser> orgUsers,
List<Policy> policies, SsoConfig ssoConfig, List<OrganizationConnection<ScimConfig>> scimConnections, OrganizationLicense license)
{
var (orgDetails, orgLicense) = GetOrganizationAndLicense(orgUsers, policies, ssoConfig, scimConnections, license);
Expand All @@ -71,12 +74,13 @@ public async Task ValidateForOrganization_Groups_NotAllowedByLicense_Fail(List<O

Assert.False(result);
Assert.Contains("Your new license does not allow for the use of groups", exception);
return Task.CompletedTask;
}

[Theory]
[BitAutoData]
[OrganizationLicenseCustomize]
public async Task ValidateForOrganization_Policies_NotAllowedByLicense_Fail(List<OrganizationUser> orgUsers,
public Task ValidateForOrganization_Policies_NotAllowedByLicense_Fail(List<OrganizationUser> orgUsers,
List<Policy> policies, SsoConfig ssoConfig, List<OrganizationConnection<ScimConfig>> scimConnections, OrganizationLicense license)
{
var (orgDetails, orgLicense) = GetOrganizationAndLicense(orgUsers, policies, ssoConfig, scimConnections, license);
Expand All @@ -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<OrganizationUser> orgUsers,
public Task ValidateForOrganization_DisabledPolicies_NotAllowedByLicense_Success(List<OrganizationUser> orgUsers,
List<Policy> policies, SsoConfig ssoConfig, List<OrganizationConnection<ScimConfig>> scimConnections, OrganizationLicense license)
{
var (orgDetails, orgLicense) = GetOrganizationAndLicense(orgUsers, policies, ssoConfig, scimConnections, license);
Expand All @@ -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<OrganizationUser> orgUsers,
public Task ValidateForOrganization_Sso_NotAllowedByLicense_Fail(List<OrganizationUser> orgUsers,
List<Policy> policies, SsoConfig ssoConfig, List<OrganizationConnection<ScimConfig>> scimConnections, OrganizationLicense license)
{
var (orgDetails, orgLicense) = GetOrganizationAndLicense(orgUsers, policies, ssoConfig, scimConnections, license);
Expand All @@ -117,12 +123,13 @@ public async Task ValidateForOrganization_Sso_NotAllowedByLicense_Fail(List<Orga

Assert.False(result);
Assert.Contains("Your new license does not allow for the use of SSO", exception);
return Task.CompletedTask;
}

[Theory]
[BitAutoData]
[OrganizationLicenseCustomize]
public async Task ValidateForOrganization_DisabledSso_NotAllowedByLicense_Success(List<OrganizationUser> orgUsers,
public Task ValidateForOrganization_DisabledSso_NotAllowedByLicense_Success(List<OrganizationUser> orgUsers,
List<Policy> policies, SsoConfig ssoConfig, List<OrganizationConnection<ScimConfig>> scimConnections, OrganizationLicense license)
{
var (orgDetails, orgLicense) = GetOrganizationAndLicense(orgUsers, policies, ssoConfig, scimConnections, license);
Expand All @@ -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<OrganizationUser> orgUsers,
public Task ValidateForOrganization_NoSso_NotAllowedByLicense_Success(List<OrganizationUser> orgUsers,
List<Policy> policies, SsoConfig ssoConfig, List<OrganizationConnection<ScimConfig>> scimConnections, OrganizationLicense license)
{
var (orgDetails, orgLicense) = GetOrganizationAndLicense(orgUsers, policies, ssoConfig, scimConnections, license);
Expand All @@ -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<OrganizationUser> orgUsers,
public Task ValidateForOrganization_KeyConnector_NotAllowedByLicense_Fail(List<OrganizationUser> orgUsers,
List<Policy> policies, SsoConfig ssoConfig, List<OrganizationConnection<ScimConfig>> scimConnections, OrganizationLicense license)
{
var (orgDetails, orgLicense) = GetOrganizationAndLicense(orgUsers, policies, ssoConfig, scimConnections, license);
Expand All @@ -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<OrganizationUser> orgUsers,
public Task ValidateForOrganization_DisabledKeyConnector_NotAllowedByLicense_Success(List<OrganizationUser> orgUsers,
List<Policy> policies, SsoConfig ssoConfig, List<OrganizationConnection<ScimConfig>> scimConnections, OrganizationLicense license)
{
var (orgDetails, orgLicense) = GetOrganizationAndLicense(orgUsers, policies, ssoConfig, scimConnections, license);
Expand All @@ -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<OrganizationUser> orgUsers,
public Task ValidateForOrganization_NoSsoKeyConnector_NotAllowedByLicense_Success(List<OrganizationUser> orgUsers,
List<Policy> policies, SsoConfig ssoConfig, List<OrganizationConnection<ScimConfig>> scimConnections, OrganizationLicense license)
{
var (orgDetails, orgLicense) = GetOrganizationAndLicense(orgUsers, policies, ssoConfig, scimConnections, license);
Expand All @@ -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<OrganizationUser> orgUsers,
public Task ValidateForOrganization_Scim_NotAllowedByLicense_Fail(List<OrganizationUser> orgUsers,
List<Policy> policies, SsoConfig ssoConfig, List<OrganizationConnection<ScimConfig>> scimConnections, OrganizationLicense license)
{
var (orgDetails, orgLicense) = GetOrganizationAndLicense(orgUsers, policies, ssoConfig, scimConnections, license);
Expand All @@ -211,12 +223,13 @@ public async Task ValidateForOrganization_Scim_NotAllowedByLicense_Fail(List<Org

Assert.False(result);
Assert.Contains("Your new plan does not allow the SCIM feature", exception);
return Task.CompletedTask;
}

[Theory]
[BitAutoData]
[OrganizationLicenseCustomize]
public async Task ValidateForOrganization_DisabledScim_NotAllowedByLicense_Success(List<OrganizationUser> orgUsers,
public Task ValidateForOrganization_DisabledScim_NotAllowedByLicense_Success(List<OrganizationUser> orgUsers,
List<Policy> policies, SsoConfig ssoConfig, List<OrganizationConnection<ScimConfig>> scimConnections, OrganizationLicense license)
{
var (orgDetails, orgLicense) = GetOrganizationAndLicense(orgUsers, policies, ssoConfig, scimConnections, license);
Expand All @@ -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<OrganizationUser> orgUsers,
public Task ValidateForOrganization_NoScimConfig_NotAllowedByLicense_Success(List<OrganizationUser> orgUsers,
List<Policy> policies, SsoConfig ssoConfig, List<OrganizationConnection<ScimConfig>> scimConnections, OrganizationLicense license)
{
var (orgDetails, orgLicense) = GetOrganizationAndLicense(orgUsers, policies, ssoConfig, scimConnections, license);
Expand All @@ -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<OrganizationUser> orgUsers,
public Task ValidateForOrganization_CustomPermissions_NotAllowedByLicense_Fail(List<OrganizationUser> orgUsers,
List<Policy> policies, SsoConfig ssoConfig, List<OrganizationConnection<ScimConfig>> scimConnections, OrganizationLicense license)
{
var (orgDetails, orgLicense) = GetOrganizationAndLicense(orgUsers, policies, ssoConfig, scimConnections, license);
Expand All @@ -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<OrganizationUser> orgUsers,
public Task ValidateForOrganization_NoCustomPermissions_NotAllowedByLicense_Success(List<OrganizationUser> orgUsers,
List<Policy> policies, SsoConfig ssoConfig, List<OrganizationConnection<ScimConfig>> scimConnections, OrganizationLicense license)
{
var (orgDetails, orgLicense) = GetOrganizationAndLicense(orgUsers, policies, ssoConfig, scimConnections, license);
Expand All @@ -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<OrganizationUser> orgUsers,
public Task ValidateForOrganization_ResetPassword_NotAllowedByLicense_Fail(List<OrganizationUser> orgUsers,
List<Policy> policies, SsoConfig ssoConfig, List<OrganizationConnection<ScimConfig>> scimConnections, OrganizationLicense license)
{
var (orgDetails, orgLicense) = GetOrganizationAndLicense(orgUsers, policies, ssoConfig, scimConnections, license);
Expand All @@ -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<OrganizationUser> orgUsers,
public Task ValidateForOrganization_DisabledResetPassword_NotAllowedByLicense_Success(List<OrganizationUser> orgUsers,
List<Policy> policies, SsoConfig ssoConfig, List<OrganizationConnection<ScimConfig>> scimConnections, OrganizationLicense license)
{
var (orgDetails, orgLicense) = GetOrganizationAndLicense(orgUsers, policies, ssoConfig, scimConnections, license);
Expand All @@ -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<OrganizationUser> orgUsers,
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
Loading

0 comments on commit e78e482

Please sign in to comment.