1
0
mirror of https://github.com/bitwarden/server.git synced 2025-06-30 07:36:14 -05:00

[AC-2959] ACH Direct Debit POC (#4703)

* Refactor: Rename some methods and models for consistency

This commit contains no logic changes at all. It's entirely comprised of renames of existing models and methods to bring our codebase more in line with our app's functionality and terminology.

* Add feature flag: AC-2476-deprecate-stripe-sources-api

* Standardize error responses from applicable billing controllers

During my work on CB, I found that just using the built-in TypedResults errors results in the client choking on the response because it's looking for the ErrroResponseModel. The new BaseBillingController provides Error utilities to return TypedResults wrapping that model so the client can process it.

* Add feature flagged payment method endoints to OrganizationBillingController

* Run dotnet format
This commit is contained in:
Alex Morask
2024-08-28 10:48:14 -04:00
committed by GitHub
parent 20478949d8
commit 3c86ec6a35
31 changed files with 391 additions and 197 deletions

View File

@ -12,6 +12,8 @@ using Microsoft.AspNetCore.Http.HttpResults;
using NSubstitute;
using Xunit;
using static Bit.Api.Test.Billing.Utilities;
namespace Bit.Api.Test.Billing.Controllers;
[ControllerCustomize(typeof(OrganizationBillingController))]
@ -27,7 +29,7 @@ public class OrganizationBillingControllerTests
var result = await sutProvider.Sut.GetMetadataAsync(organizationId);
Assert.IsType<UnauthorizedHttpResult>(result);
AssertUnauthorized(result);
}
[Theory, BitAutoData]
@ -36,11 +38,11 @@ public class OrganizationBillingControllerTests
SutProvider<OrganizationBillingController> sutProvider)
{
sutProvider.GetDependency<ICurrentContext>().AccessMembersTab(organizationId).Returns(true);
sutProvider.GetDependency<IOrganizationBillingService>().GetMetadata(organizationId).Returns((OrganizationMetadataDTO)null);
sutProvider.GetDependency<IOrganizationBillingService>().GetMetadata(organizationId).Returns((OrganizationMetadata)null);
var result = await sutProvider.Sut.GetMetadataAsync(organizationId);
Assert.IsType<NotFound>(result);
AssertNotFound(result);
}
[Theory, BitAutoData]
@ -50,7 +52,7 @@ public class OrganizationBillingControllerTests
{
sutProvider.GetDependency<ICurrentContext>().AccessMembersTab(organizationId).Returns(true);
sutProvider.GetDependency<IOrganizationBillingService>().GetMetadata(organizationId)
.Returns(new OrganizationMetadataDTO(true));
.Returns(new OrganizationMetadata(true));
var result = await sutProvider.Sut.GetMetadataAsync(organizationId);
@ -70,7 +72,7 @@ public class OrganizationBillingControllerTests
var result = await sutProvider.Sut.GetHistoryAsync(organizationId);
Assert.IsType<UnauthorizedHttpResult>(result);
AssertUnauthorized(result);
}
[Theory, BitAutoData]
@ -83,7 +85,7 @@ public class OrganizationBillingControllerTests
var result = await sutProvider.Sut.GetHistoryAsync(organizationId);
Assert.IsType<NotFound>(result);
AssertNotFound(result);
}
[Theory]

View File

@ -107,7 +107,7 @@ public class ProviderBillingControllerTests
Provider provider,
SutProvider<ProviderBillingController> sutProvider)
{
ConfigureStableAdminInputs(provider, sutProvider);
ConfigureStableProviderAdminInputs(provider, sutProvider);
var invoices = new List<Invoice>
{
@ -187,7 +187,7 @@ public class ProviderBillingControllerTests
string invoiceId,
SutProvider<ProviderBillingController> sutProvider)
{
ConfigureStableAdminInputs(provider, sutProvider);
ConfigureStableProviderAdminInputs(provider, sutProvider);
sutProvider.GetDependency<IProviderBillingService>().GenerateClientInvoiceReport(invoiceId)
.ReturnsNull();
@ -208,7 +208,7 @@ public class ProviderBillingControllerTests
string invoiceId,
SutProvider<ProviderBillingController> sutProvider)
{
ConfigureStableAdminInputs(provider, sutProvider);
ConfigureStableProviderAdminInputs(provider, sutProvider);
var reportContent = "Report"u8.ToArray();
@ -301,7 +301,7 @@ public class ProviderBillingControllerTests
Provider provider,
SutProvider<ProviderBillingController> sutProvider)
{
ConfigureStableServiceUserInputs(provider, sutProvider);
ConfigureStableProviderServiceUserInputs(provider, sutProvider);
var stripeAdapter = sutProvider.GetDependency<IStripeAdapter>();
@ -432,7 +432,7 @@ public class ProviderBillingControllerTests
TaxInformationRequestBody requestBody,
SutProvider<ProviderBillingController> sutProvider)
{
ConfigureStableAdminInputs(provider, sutProvider);
ConfigureStableProviderAdminInputs(provider, sutProvider);
requestBody.Country = null;
@ -451,7 +451,7 @@ public class ProviderBillingControllerTests
TaxInformationRequestBody requestBody,
SutProvider<ProviderBillingController> sutProvider)
{
ConfigureStableAdminInputs(provider, sutProvider);
ConfigureStableProviderAdminInputs(provider, sutProvider);
await sutProvider.Sut.UpdateTaxInformationAsync(provider.Id, requestBody);

View File

@ -33,7 +33,7 @@ public class ProviderClientsControllerTests
CreateClientOrganizationRequestBody requestBody,
SutProvider<ProviderClientsController> sutProvider)
{
ConfigureStableAdminInputs(provider, sutProvider);
ConfigureStableProviderAdminInputs(provider, sutProvider);
sutProvider.GetDependency<IUserService>().GetUserByPrincipalAsync(Arg.Any<ClaimsPrincipal>()).ReturnsNull();
@ -48,7 +48,7 @@ public class ProviderClientsControllerTests
CreateClientOrganizationRequestBody requestBody,
SutProvider<ProviderClientsController> sutProvider)
{
ConfigureStableAdminInputs(provider, sutProvider);
ConfigureStableProviderAdminInputs(provider, sutProvider);
var user = new User();
@ -99,7 +99,7 @@ public class ProviderClientsControllerTests
UpdateClientOrganizationRequestBody requestBody,
SutProvider<ProviderClientsController> sutProvider)
{
ConfigureStableServiceUserInputs(provider, sutProvider);
ConfigureStableProviderServiceUserInputs(provider, sutProvider);
sutProvider.GetDependency<IProviderOrganizationRepository>().GetByIdAsync(providerOrganizationId)
.ReturnsNull();
@ -118,7 +118,7 @@ public class ProviderClientsControllerTests
Organization organization,
SutProvider<ProviderClientsController> sutProvider)
{
ConfigureStableServiceUserInputs(provider, sutProvider);
ConfigureStableProviderServiceUserInputs(provider, sutProvider);
sutProvider.GetDependency<IProviderOrganizationRepository>().GetByIdAsync(providerOrganizationId)
.Returns(providerOrganization);
@ -149,7 +149,7 @@ public class ProviderClientsControllerTests
Organization organization,
SutProvider<ProviderClientsController> sutProvider)
{
ConfigureStableServiceUserInputs(provider, sutProvider);
ConfigureStableProviderServiceUserInputs(provider, sutProvider);
sutProvider.GetDependency<IProviderOrganizationRepository>().GetByIdAsync(providerOrganizationId)
.Returns(providerOrganization);