mirror of https://github.com/Squidex/squidex.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
1.8 KiB
54 lines
1.8 KiB
// ==========================================================================
|
|
// ClaimsPrincipalConverterTests.cs
|
|
// Squidex Headless CMS
|
|
// ==========================================================================
|
|
// Copyright (c) Squidex Group
|
|
// All rights reserved.
|
|
// ==========================================================================
|
|
|
|
using System.Linq;
|
|
using System.Security.Claims;
|
|
using Squidex.Infrastructure.TestHelpers;
|
|
using Xunit;
|
|
|
|
namespace Squidex.Infrastructure.Json
|
|
{
|
|
public class ClaimsPrincipalConverterTests
|
|
{
|
|
[Fact]
|
|
public void Should_serialize_and_deserialize()
|
|
{
|
|
var value = new ClaimsPrincipal(
|
|
new[]
|
|
{
|
|
new ClaimsIdentity(
|
|
new[]
|
|
{
|
|
new Claim("email", "me@email.de"),
|
|
new Claim("username", "me@email.de")
|
|
},
|
|
"Cookie"),
|
|
new ClaimsIdentity(
|
|
new[]
|
|
{
|
|
new Claim("user_id", "12345"),
|
|
new Claim("login", "me")
|
|
},
|
|
"Google")
|
|
});
|
|
|
|
var result = value.SerializeAndDeserializeAndReturn(new ClaimsPrincipalConverter());
|
|
|
|
Assert.Equal(value.Identities.ElementAt(0).AuthenticationType, result.Identities.ElementAt(0).AuthenticationType);
|
|
Assert.Equal(value.Identities.ElementAt(1).AuthenticationType, result.Identities.ElementAt(1).AuthenticationType);
|
|
}
|
|
|
|
[Fact]
|
|
public void Should_serialize_and_deserialize_null_principal()
|
|
{
|
|
ClaimsPrincipal value = null;
|
|
|
|
value.SerializeAndDeserialize(new ClaimsPrincipalConverter());
|
|
}
|
|
}
|
|
}
|
|
|