-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[AC-2471] Prevent calls to Stripe when unlinking client org has no St…
…ripe objects (#3999) * Prevent calls to Stripe when unlinking client org has no Stripe objects * Thomas' feedback * Check for stripe when org unlinked from org page --------- Co-authored-by: Conner Turnbull <[email protected]>
- Loading branch information
1 parent
fa7b00a
commit ac4ccaf
Showing
6 changed files
with
103 additions
and
13 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ | |
using NSubstitute; | ||
using Stripe; | ||
using Xunit; | ||
using IMailService = Bit.Core.Services.IMailService; | ||
|
||
namespace Bit.Commercial.Core.Test.AdminConsole.ProviderFeatures; | ||
|
||
|
@@ -83,6 +84,55 @@ public class RemoveOrganizationFromProviderCommandTests | |
Assert.Equal("Organization must have at least one confirmed owner.", exception.Message); | ||
} | ||
|
||
[Theory, BitAutoData] | ||
public async Task RemoveOrganizationFromProvider_NoStripeObjects_MakesCorrectInvocations( | ||
Provider provider, | ||
ProviderOrganization providerOrganization, | ||
Organization organization, | ||
SutProvider<RemoveOrganizationFromProviderCommand> sutProvider) | ||
{ | ||
organization.GatewayCustomerId = null; | ||
organization.GatewaySubscriptionId = null; | ||
|
||
providerOrganization.ProviderId = provider.Id; | ||
|
||
var organizationRepository = sutProvider.GetDependency<IOrganizationRepository>(); | ||
|
||
sutProvider.GetDependency<IOrganizationService>().HasConfirmedOwnersExceptAsync( | ||
providerOrganization.OrganizationId, | ||
Array.Empty<Guid>(), | ||
includeProvider: false) | ||
.Returns(true); | ||
|
||
var organizationOwnerEmails = new List<string> { "[email protected]", "[email protected]" }; | ||
|
||
organizationRepository.GetOwnerEmailAddressesById(organization.Id).Returns(organizationOwnerEmails); | ||
|
||
await sutProvider.Sut.RemoveOrganizationFromProvider(provider, providerOrganization, organization); | ||
|
||
await organizationRepository.Received(1).ReplaceAsync(Arg.Is<Organization>( | ||
org => org.Id == organization.Id && org.BillingEmail == "[email protected]")); | ||
|
||
var stripeAdapter = sutProvider.GetDependency<IStripeAdapter>(); | ||
|
||
await stripeAdapter.DidNotReceiveWithAnyArgs().CustomerUpdateAsync(Arg.Any<string>(), Arg.Any<CustomerUpdateOptions>()); | ||
|
||
await stripeAdapter.DidNotReceiveWithAnyArgs().SubscriptionUpdateAsync(Arg.Any<string>(), Arg.Any<SubscriptionUpdateOptions>()); | ||
|
||
await sutProvider.GetDependency<IMailService>().DidNotReceiveWithAnyArgs().SendProviderUpdatePaymentMethod( | ||
Arg.Any<Guid>(), | ||
Arg.Any<string>(), | ||
Arg.Any<string>(), | ||
Arg.Any<IEnumerable<string>>()); | ||
|
||
await sutProvider.GetDependency<IProviderOrganizationRepository>().Received(1) | ||
.DeleteAsync(providerOrganization); | ||
|
||
await sutProvider.GetDependency<IEventService>().Received(1).LogProviderOrganizationEventAsync( | ||
providerOrganization, | ||
EventType.ProviderOrganization_Removed); | ||
} | ||
|
||
[Theory, BitAutoData] | ||
public async Task RemoveOrganizationFromProvider_MakesCorrectInvocations__FeatureFlagOff( | ||
Provider provider, | ||
|
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