1
0
mirror of https://github.com/bitwarden/server.git synced 2025-07-13 05:38:25 -05:00
Files
bitwarden/test/Core.Test/Billing/Payment/Models/MaskedPaymentMethodTests.cs
Alex Morask 7f65a655d4 [PM-21881] Manage payment details outside of checkout (#6032)
* Add feature flag

* Further establish billing command pattern and use in PreviewTaxAmountCommand

* Add billing address models/commands/queries/tests

* Update TypeReadingJsonConverter to account for new union types

* Add payment method models/commands/queries/tests

* Add credit models/commands/queries/tests

* Add command/query registrations

* Add new endpoints to support new command model and payment functionality

* Run dotnet format

* Add InjectUserAttribute for easier AccountBillilngVNextController handling

* Add InjectOrganizationAttribute for easier OrganizationBillingVNextController handling

* Add InjectProviderAttribute for easier ProviderBillingVNextController handling

* Add XML documentation for billing command pipeline

* Fix StripeConstants post-nullability

* More nullability cleanup

* Run dotnet format
2025-07-10 08:32:25 -05:00

64 lines
1.5 KiB
C#

using System.Text.Json;
using Bit.Core.Billing.Payment.Models;
using Xunit;
namespace Bit.Core.Test.Billing.Payment.Models;
public class MaskedPaymentMethodTests
{
[Fact]
public void Write_Read_BankAccount_Succeeds()
{
MaskedPaymentMethod input = new MaskedBankAccount
{
BankName = "Chase",
Last4 = "9999",
Verified = true
};
var json = JsonSerializer.Serialize(input);
var output = JsonSerializer.Deserialize<MaskedPaymentMethod>(json);
Assert.NotNull(output);
Assert.True(output.IsT0);
Assert.Equivalent(input.AsT0, output.AsT0);
}
[Fact]
public void Write_Read_Card_Succeeds()
{
MaskedPaymentMethod input = new MaskedCard
{
Brand = "visa",
Last4 = "9999",
Expiration = "01/2028"
};
var json = JsonSerializer.Serialize(input);
var output = JsonSerializer.Deserialize<MaskedPaymentMethod>(json);
Assert.NotNull(output);
Assert.True(output.IsT1);
Assert.Equivalent(input.AsT1, output.AsT1);
}
[Fact]
public void Write_Read_PayPal_Succeeds()
{
MaskedPaymentMethod input = new MaskedPayPalAccount
{
Email = "paypal-user@gmail.com"
};
var json = JsonSerializer.Serialize(input);
var output = JsonSerializer.Deserialize<MaskedPaymentMethod>(json);
Assert.NotNull(output);
Assert.True(output.IsT2);
Assert.Equivalent(input.AsT2, output.AsT2);
}
}