Skip to content

Commit

Permalink
Merge branch 'master' into feature/flexible-collections
Browse files Browse the repository at this point in the history
  • Loading branch information
eliykat authored Oct 13, 2023
2 parents fed3252 + f228dcd commit 6bc38ac
Show file tree
Hide file tree
Showing 34 changed files with 2,401 additions and 286 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,12 @@ public async Task AddOrganization(Guid providerId, Guid organizationId, string k
var organization = await _organizationRepository.GetByIdAsync(organizationId);
ThrowOnInvalidPlanType(organization.PlanType);

if (organization.UseSecretsManager)
{
throw new BadRequestException(
"The organization is subscribed to Secrets Manager. Please contact Customer Support to manage the subscription.");
}

var providerOrganization = new ProviderOrganization
{
ProviderId = providerId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,23 @@ public async Task AddOrganization_OrganizationAlreadyBelongsToAProvider_Throws(P
Assert.Equal("Organization already belongs to a provider.", exception.Message);
}

[Theory, BitAutoData]
public async Task AddOrganization_OrganizationHasSecretsManager_Throws(Provider provider, Organization organization, string key,
SutProvider<ProviderService> sutProvider)
{
organization.PlanType = PlanType.EnterpriseAnnually;
organization.UseSecretsManager = true;

sutProvider.GetDependency<IProviderRepository>().GetByIdAsync(provider.Id).Returns(provider);
var providerOrganizationRepository = sutProvider.GetDependency<IProviderOrganizationRepository>();
providerOrganizationRepository.GetByOrganizationId(organization.Id).ReturnsNull();
sutProvider.GetDependency<IOrganizationRepository>().GetByIdAsync(organization.Id).Returns(organization);

var exception = await Assert.ThrowsAsync<BadRequestException>(
() => sutProvider.Sut.AddOrganization(provider.Id, organization.Id, key));
Assert.Equal("The organization is subscribed to Secrets Manager. Please contact Customer Support to manage the subscription.", exception.Message);
}

[Theory, BitAutoData]
public async Task AddOrganization_Success(Provider provider, Organization organization, string key,
SutProvider<ProviderService> sutProvider)
Expand Down
1 change: 1 addition & 0 deletions src/Billing/Constants/HandledStripeWebhook.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ public static class HandledStripeWebhook
public const string PaymentFailed = "invoice.payment_failed";
public const string InvoiceCreated = "invoice.created";
public const string PaymentMethodAttached = "payment_method.attached";
public const string CustomerUpdated = "customer.updated";
}
Loading

0 comments on commit 6bc38ac

Please sign in to comment.