mirror of
https://github.com/bitwarden/server.git
synced 2024-11-21 12:05:42 +01:00
Resolve the unhandled error unlink org (#4141)
* Resolve the unhandled error unlink org Signed-off-by: Cy Okeke <cokeke@bitwarden.com> * Resolve a failing unit test Signed-off-by: Cy Okeke <cokeke@bitwarden.com> --------- Signed-off-by: Cy Okeke <cokeke@bitwarden.com>
This commit is contained in:
parent
357ac4f40a
commit
21a02054af
@ -137,6 +137,12 @@ public class RemoveOrganizationFromProviderCommand : IRemoveOrganizationFromProv
|
|||||||
}
|
}
|
||||||
else if (organization.IsStripeEnabled())
|
else if (organization.IsStripeEnabled())
|
||||||
{
|
{
|
||||||
|
var subscription = await _stripeAdapter.SubscriptionGetAsync(organization.GatewaySubscriptionId);
|
||||||
|
if (subscription.Status is StripeConstants.SubscriptionStatus.Canceled or StripeConstants.SubscriptionStatus.IncompleteExpired)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
await _stripeAdapter.CustomerUpdateAsync(organization.GatewayCustomerId, new CustomerUpdateOptions
|
await _stripeAdapter.CustomerUpdateAsync(organization.GatewayCustomerId, new CustomerUpdateOptions
|
||||||
{
|
{
|
||||||
Coupon = string.Empty,
|
Coupon = string.Empty,
|
||||||
|
@ -156,6 +156,9 @@ public class RemoveOrganizationFromProviderCommandTests
|
|||||||
sutProvider.GetDependency<IFeatureService>().IsEnabled(FeatureFlagKeys.EnableConsolidatedBilling)
|
sutProvider.GetDependency<IFeatureService>().IsEnabled(FeatureFlagKeys.EnableConsolidatedBilling)
|
||||||
.Returns(false);
|
.Returns(false);
|
||||||
|
|
||||||
|
sutProvider.GetDependency<IStripeAdapter>().SubscriptionGetAsync(organization.GatewaySubscriptionId)
|
||||||
|
.Returns(GetSubscription(organization.GatewaySubscriptionId));
|
||||||
|
|
||||||
await sutProvider.Sut.RemoveOrganizationFromProvider(provider, providerOrganization, organization);
|
await sutProvider.Sut.RemoveOrganizationFromProvider(provider, providerOrganization, organization);
|
||||||
|
|
||||||
var stripeAdapter = sutProvider.GetDependency<IStripeAdapter>();
|
var stripeAdapter = sutProvider.GetDependency<IStripeAdapter>();
|
||||||
@ -262,4 +265,25 @@ public class RemoveOrganizationFromProviderCommandTests
|
|||||||
provider.Name,
|
provider.Name,
|
||||||
Arg.Is<IEnumerable<string>>(emails => emails.FirstOrDefault() == "a@example.com"));
|
Arg.Is<IEnumerable<string>>(emails => emails.FirstOrDefault() == "a@example.com"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static Subscription GetSubscription(string subscriptionId) =>
|
||||||
|
new()
|
||||||
|
{
|
||||||
|
Id = subscriptionId,
|
||||||
|
Status = StripeConstants.SubscriptionStatus.Active,
|
||||||
|
Items = new StripeList<SubscriptionItem>
|
||||||
|
{
|
||||||
|
Data = new List<SubscriptionItem>
|
||||||
|
{
|
||||||
|
new()
|
||||||
|
{
|
||||||
|
Id = "sub_item_123",
|
||||||
|
Price = new Price()
|
||||||
|
{
|
||||||
|
Id = "2023-enterprise-org-seat-annually"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user