mirror of
https://github.com/bitwarden/mobile
synced 2025-12-16 00:03:22 +00:00
[PM-5731] feat: add first test
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
using System.Threading.Tasks;
|
||||
using Bit.Core.Abstractions;
|
||||
using Bit.Core.Exceptions;
|
||||
using Bit.Core.Services;
|
||||
using Bit.Core.Test.AutoFixture;
|
||||
using Bit.Core.Utilities.Fido2;
|
||||
using Bit.Test.Common.AutoFixture;
|
||||
using Bit.Test.Common.AutoFixture.Attributes;
|
||||
using NSubstitute;
|
||||
@@ -12,26 +14,23 @@ namespace Bit.Core.Test.Services
|
||||
{
|
||||
public class Fido2AuthenticatorTests
|
||||
{
|
||||
[Theory]
|
||||
public async Task GetAssertionAsync_Throws_InputIsMissingSupportedAlgorithm(Fido2AuthenticatorService sut)
|
||||
// Spec: If credentialOptions is now empty, return an error code equivalent to "NotAllowedError" and terminate the operation.
|
||||
[Theory, SutAutoData]
|
||||
public async Task GetAssertionAsync_Throws_NoCredentialExists(Fido2AuthenticatorService sut)
|
||||
{
|
||||
await Assert.ThrowsAsync<NotFoundException>(async () => await sut.GetAssertionAsync(new Fido2AuthenticatorGetAssertionParams()));
|
||||
var assertionParams = CreateAssertionParams();
|
||||
var exception = await Assert.ThrowsAsync<NotAllowedError>(() => sut.GetAssertionAsync(assertionParams));
|
||||
}
|
||||
|
||||
// it("should throw error when input does not contain any supported algorithms", async () => {
|
||||
// const result = async () =>
|
||||
// await authenticator.makeCredential(invalidParams.unsupportedAlgorithm, tab);
|
||||
|
||||
// await expect(result).rejects.toThrowError(Fido2AuthenticatorErrorCode.NotSupported);
|
||||
// });
|
||||
|
||||
private Fido2AuthenticatorGetAssertionParams GetAssertionParams()
|
||||
private Fido2AuthenticatorGetAssertionParams CreateAssertionParams()
|
||||
{
|
||||
return new Fido2AuthenticatorGetAssertionParams
|
||||
{
|
||||
RpId = "test",
|
||||
Counter = 0,
|
||||
CredentialId = new byte[32]
|
||||
RpId = "bitwarden.com",
|
||||
Hash = new byte[32],
|
||||
AllowCredentialDescriptorList = new PublicKeyCredentialDescriptor[0],
|
||||
RequireUserVerification = true,
|
||||
Extensions = new object()
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user