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.
55 lines
1.9 KiB
55 lines
1.9 KiB
// ==========================================================================
|
|
// Squidex Headless CMS
|
|
// ==========================================================================
|
|
// Copyright (c) Squidex UG (haftungsbeschränkt)
|
|
// All rights reserved. Licensed under the MIT license.
|
|
// ==========================================================================
|
|
|
|
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.com"),
|
|
new Claim("username", "me@email.com")
|
|
},
|
|
"Cookie"),
|
|
new ClaimsIdentity(
|
|
new[]
|
|
{
|
|
new Claim("user_id", "12345"),
|
|
new Claim("login", "me")
|
|
},
|
|
"Google")
|
|
});
|
|
|
|
var serialized = value.SerializeAndDeserialize();
|
|
|
|
Assert.Equal(value.Identities.ElementAt(0).AuthenticationType, serialized.Identities.ElementAt(0).AuthenticationType);
|
|
Assert.Equal(value.Identities.ElementAt(1).AuthenticationType, serialized.Identities.ElementAt(1).AuthenticationType);
|
|
}
|
|
|
|
[Fact]
|
|
public void Should_serialize_and_deserialize_null_principal()
|
|
{
|
|
ClaimsPrincipal value = null;
|
|
|
|
var serialized = value.SerializeAndDeserialize();
|
|
|
|
Assert.Null(serialized);
|
|
}
|
|
}
|
|
}
|
|
|