2022-06-30 01:46:41 +02:00
|
|
|
|
using System.Security.Claims;
|
2022-06-06 19:52:50 +02:00
|
|
|
|
using Bit.Core.Utilities;
|
|
|
|
|
using Xunit;
|
|
|
|
|
|
2022-08-29 22:06:55 +02:00
|
|
|
|
namespace Bit.Core.Test.Utilities;
|
|
|
|
|
|
|
|
|
|
public class ClaimsExtensionsTests
|
2022-06-06 19:52:50 +02:00
|
|
|
|
{
|
2022-08-29 22:06:55 +02:00
|
|
|
|
[Fact]
|
|
|
|
|
public void HasSSOIdP_Returns_True_When_The_Claims_Has_One_Of_Type_IdP_And_Value_Sso()
|
2022-06-06 19:52:50 +02:00
|
|
|
|
{
|
2022-08-29 22:06:55 +02:00
|
|
|
|
var claims = new List<Claim> { new Claim("idp", "sso") };
|
|
|
|
|
Assert.True(claims.HasSsoIdP());
|
|
|
|
|
}
|
2022-06-06 19:52:50 +02:00
|
|
|
|
|
2022-08-29 22:06:55 +02:00
|
|
|
|
[Fact]
|
|
|
|
|
public void HasSSOIdP_Returns_False_When_The_Claims_Has_One_Of_Type_IdP_And_Value_Is_Not_Sso()
|
|
|
|
|
{
|
|
|
|
|
var claims = new List<Claim> { new Claim("idp", "asdfasfd") };
|
|
|
|
|
Assert.False(claims.HasSsoIdP());
|
|
|
|
|
}
|
2022-06-06 19:52:50 +02:00
|
|
|
|
|
2022-08-29 22:06:55 +02:00
|
|
|
|
[Fact]
|
|
|
|
|
public void HasSSOIdP_Returns_False_When_The_Claims_Has_No_One_Of_Type_IdP()
|
|
|
|
|
{
|
|
|
|
|
var claims = new List<Claim> { new Claim("qweqweq", "sso") };
|
|
|
|
|
Assert.False(claims.HasSsoIdP());
|
|
|
|
|
}
|
2022-06-06 19:52:50 +02:00
|
|
|
|
|
2022-08-29 22:06:55 +02:00
|
|
|
|
[Fact]
|
|
|
|
|
public void HasSSOIdP_Returns_False_When_The_Claims_Are_Empty()
|
|
|
|
|
{
|
|
|
|
|
var claims = new List<Claim>();
|
|
|
|
|
Assert.False(claims.HasSsoIdP());
|
2022-06-06 19:52:50 +02:00
|
|
|
|
}
|
|
|
|
|
}
|