-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PM-10314] Auto-enable Single Org when a Domain is Verified (#4897)
Updated domain verification to auto-enable single org policy.
- Loading branch information
1 parent
a128cf1
commit 0c346d6
Showing
11 changed files
with
244 additions
and
62 deletions.
There are no files selected for viewing
6 changes: 6 additions & 0 deletions
6
...ganizationFeatures/OrganizationDomains/Interfaces/IOrganizationHasVerifiedDomainsQuery.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
namespace Bit.Core.AdminConsole.OrganizationFeatures.OrganizationDomains.Interfaces; | ||
|
||
public interface IOrganizationHasVerifiedDomainsQuery | ||
{ | ||
Task<bool> HasVerifiedDomainsAsync(Guid orgId); | ||
} |
10 changes: 10 additions & 0 deletions
10
...inConsole/OrganizationFeatures/OrganizationDomains/OrganizationHasVerifiedDomainsQuery.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using Bit.Core.AdminConsole.OrganizationFeatures.OrganizationDomains.Interfaces; | ||
using Bit.Core.Repositories; | ||
|
||
namespace Bit.Core.AdminConsole.OrganizationFeatures.OrganizationDomains; | ||
|
||
public class OrganizationHasVerifiedDomainsQuery(IOrganizationDomainRepository domainRepository) : IOrganizationHasVerifiedDomainsQuery | ||
{ | ||
public async Task<bool> HasVerifiedDomainsAsync(Guid orgId) => | ||
(await domainRepository.GetDomainsByOrganizationIdAsync(orgId)).Any(od => od.VerifiedDate is not null); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
...sole/OrganizationFeatures/OrganizationDomains/OrganizationHasVerifiedDomainsQueryTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
using Bit.Core.AdminConsole.OrganizationFeatures.OrganizationDomains; | ||
using Bit.Core.Entities; | ||
using Bit.Core.Repositories; | ||
using Bit.Test.Common.AutoFixture; | ||
using Bit.Test.Common.AutoFixture.Attributes; | ||
using NSubstitute; | ||
using Xunit; | ||
|
||
namespace Bit.Core.Test.AdminConsole.OrganizationFeatures.OrganizationDomains; | ||
|
||
[SutProviderCustomize] | ||
public class OrganizationHasVerifiedDomainsQueryTests | ||
{ | ||
[Theory, BitAutoData] | ||
public async Task HasVerifiedDomainsAsync_WithVerifiedDomain_ReturnsTrue( | ||
OrganizationDomain organizationDomain, | ||
SutProvider<OrganizationHasVerifiedDomainsQuery> sutProvider) | ||
{ | ||
organizationDomain.SetVerifiedDate(); // Set the verified date to make it verified | ||
|
||
sutProvider.GetDependency<IOrganizationDomainRepository>() | ||
.GetDomainsByOrganizationIdAsync(organizationDomain.OrganizationId) | ||
.Returns(new List<OrganizationDomain> { organizationDomain }); | ||
|
||
var result = await sutProvider.Sut.HasVerifiedDomainsAsync(organizationDomain.OrganizationId); | ||
|
||
Assert.True(result); | ||
} | ||
|
||
[Theory, BitAutoData] | ||
public async Task HasVerifiedDomainsAsync_WithoutVerifiedDomain_ReturnsFalse( | ||
OrganizationDomain organizationDomain, | ||
SutProvider<OrganizationHasVerifiedDomainsQuery> sutProvider) | ||
{ | ||
sutProvider.GetDependency<IOrganizationDomainRepository>() | ||
.GetDomainsByOrganizationIdAsync(organizationDomain.OrganizationId) | ||
.Returns(new List<OrganizationDomain> { organizationDomain }); | ||
|
||
var result = await sutProvider.Sut.HasVerifiedDomainsAsync(organizationDomain.OrganizationId); | ||
|
||
Assert.False(result); | ||
} | ||
|
||
[Theory, BitAutoData] | ||
public async Task HasVerifiedDomainsAsync_WithoutOrganizationDomains_ReturnsFalse( | ||
Guid organizationId, | ||
SutProvider<OrganizationHasVerifiedDomainsQuery> sutProvider) | ||
{ | ||
sutProvider.GetDependency<IOrganizationDomainRepository>() | ||
.GetDomainsByOrganizationIdAsync(organizationId) | ||
.Returns(new List<OrganizationDomain>()); | ||
|
||
var result = await sutProvider.Sut.HasVerifiedDomainsAsync(organizationId); | ||
|
||
Assert.False(result); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.