2023-04-14 19:25:56 +02:00
|
|
|
|
using Bit.Core.Auth.Enums;
|
|
|
|
|
using Bit.Core.Auth.Identity;
|
|
|
|
|
using Bit.Core.Entities;
|
2022-01-21 15:36:25 +01:00
|
|
|
|
using Bit.Test.Common.AutoFixture;
|
|
|
|
|
using Bit.Test.Common.AutoFixture.Attributes;
|
|
|
|
|
using Xunit;
|
|
|
|
|
|
2023-04-14 19:25:56 +02:00
|
|
|
|
namespace Bit.Core.Test.Auth.Identity;
|
2022-08-29 22:06:55 +02:00
|
|
|
|
|
2024-07-11 20:39:27 +02:00
|
|
|
|
public class EmailTwoFactorTokenProviderTests : BaseTokenProviderTests<EmailTwoFactorTokenProvider>
|
2022-01-21 15:36:25 +01:00
|
|
|
|
{
|
|
|
|
|
public override TwoFactorProviderType TwoFactorProviderType => TwoFactorProviderType.Email;
|
|
|
|
|
|
|
|
|
|
public static IEnumerable<object[]> CanGenerateTwoFactorTokenAsyncData
|
|
|
|
|
=> SetupCanGenerateData(
|
|
|
|
|
(
|
|
|
|
|
new Dictionary<string, object>
|
|
|
|
|
{
|
|
|
|
|
["Email"] = "test@email.com",
|
|
|
|
|
},
|
|
|
|
|
true
|
|
|
|
|
),
|
|
|
|
|
(
|
|
|
|
|
new Dictionary<string, object>
|
|
|
|
|
{
|
|
|
|
|
["NotEmail"] = "value",
|
|
|
|
|
},
|
|
|
|
|
false
|
|
|
|
|
),
|
|
|
|
|
(
|
|
|
|
|
new Dictionary<string, object>
|
|
|
|
|
{
|
|
|
|
|
["Email"] = "",
|
|
|
|
|
},
|
|
|
|
|
false
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
[Theory, BitMemberAutoData(nameof(CanGenerateTwoFactorTokenAsyncData))]
|
|
|
|
|
public override async Task RunCanGenerateTwoFactorTokenAsync(Dictionary<string, object> metaData, bool expectedResponse,
|
2024-07-11 20:39:27 +02:00
|
|
|
|
User user, SutProvider<EmailTwoFactorTokenProvider> sutProvider)
|
2022-01-21 15:36:25 +01:00
|
|
|
|
{
|
|
|
|
|
await base.RunCanGenerateTwoFactorTokenAsync(metaData, expectedResponse, user, sutProvider);
|
|
|
|
|
}
|
|
|
|
|
}
|