2022-01-10 16:58:16 +01:00
|
|
|
|
using System;
|
|
|
|
|
using AutoFixture.Xunit2;
|
2022-01-11 10:40:51 +01:00
|
|
|
|
using Bit.Core.Entities;
|
2022-01-10 16:58:16 +01:00
|
|
|
|
using Bit.Core.Models.Business.Tokenables;
|
|
|
|
|
using Bit.Core.Tokens;
|
|
|
|
|
using Xunit;
|
|
|
|
|
|
|
|
|
|
namespace Bit.Core.Test.Models.Business.Tokenables
|
|
|
|
|
{
|
|
|
|
|
public class EmergencyAccessInviteTokenableTests
|
|
|
|
|
{
|
|
|
|
|
[Theory, AutoData]
|
|
|
|
|
public void SerializationSetsCorrectDateTime(EmergencyAccess emergencyAccess)
|
|
|
|
|
{
|
|
|
|
|
var token = new EmergencyAccessInviteTokenable(emergencyAccess, 2);
|
|
|
|
|
Assert.Equal(Tokenable.FromToken<EmergencyAccessInviteTokenable>(token.ToToken().ToString()).ExpirationDate,
|
|
|
|
|
token.ExpirationDate,
|
|
|
|
|
TimeSpan.FromMilliseconds(10));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void IsInvalidIfIdentifierIsWrong()
|
|
|
|
|
{
|
|
|
|
|
var token = new EmergencyAccessInviteTokenable(DateTime.MaxValue)
|
|
|
|
|
{
|
|
|
|
|
Email = "email",
|
|
|
|
|
Id = Guid.NewGuid(),
|
|
|
|
|
Identifier = "not correct"
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Assert.False(token.Valid);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|