mirror of
https://github.com/bitwarden/server.git
synced 2024-12-01 13:43:23 +01:00
35 lines
1.0 KiB
C#
35 lines
1.0 KiB
C#
using System;
|
|
using AutoFixture.Xunit2;
|
|
using Bit.Core.Entities;
|
|
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);
|
|
}
|
|
}
|
|
}
|