mirror of
https://github.com/bitwarden/server
synced 2025-12-19 01:33:20 +00:00
* Implement bank account hosted URL verification with webhook handling notification * Fix tests * Run dotnet format * Remove unused VerifyBankAccount operation * Stephon's feedback * Removing unused test * TEMP: Add logging for deployment check * Run dotnet format * fix test * Revert "fix test" This reverts commitb8743ab3b5. * Revert "Run dotnet format" This reverts commit5c861b0b72. * Revert "TEMP: Add logging for deployment check" This reverts commit0a88acd6a1. * Resolve GetPaymentMethodQuery order of operations
85 lines
2.3 KiB
C#
85 lines
2.3 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",
|
|
HostedVerificationUrl = "https://example.com"
|
|
};
|
|
|
|
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_BankAccount_WithOptions_Succeeds()
|
|
{
|
|
MaskedPaymentMethod input = new MaskedBankAccount
|
|
{
|
|
BankName = "Chase",
|
|
Last4 = "9999",
|
|
HostedVerificationUrl = "https://example.com"
|
|
};
|
|
|
|
var jsonSerializerOptions = new JsonSerializerOptions { PropertyNamingPolicy = JsonNamingPolicy.CamelCase };
|
|
|
|
var json = JsonSerializer.Serialize(input, jsonSerializerOptions);
|
|
|
|
var output = JsonSerializer.Deserialize<MaskedPaymentMethod>(json, jsonSerializerOptions);
|
|
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);
|
|
}
|
|
}
|