committed by
GitHub
5 changed files with 170 additions and 1 deletions
@ -0,0 +1,22 @@ |
|||||
|
<Project Sdk="Microsoft.NET.Sdk"> |
||||
|
|
||||
|
<PropertyGroup> |
||||
|
<TargetFrameworks>net461;net472;netcoreapp3.1;net6.0</TargetFrameworks> |
||||
|
</PropertyGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<PackageReference Include="Moq" /> |
||||
|
<PackageReference Include="Microsoft.Extensions.DependencyInjection" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<ProjectReference Include="..\..\src\OpenIddict.Server.DataProtection\OpenIddict.Server.DataProtection.csproj" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<Using Include="OpenIddict.Abstractions" /> |
||||
|
<Using Include="OpenIddict.Abstractions.OpenIddictConstants" Static="true" /> |
||||
|
<Using Include="OpenIddict.Abstractions.OpenIddictResources" Alias="SR" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
</Project> |
||||
@ -0,0 +1,30 @@ |
|||||
|
using System.Security.Claims; |
||||
|
using Xunit; |
||||
|
|
||||
|
namespace OpenIddict.Server.DataProtection.Tests; |
||||
|
|
||||
|
public class OpenIddictServerDataProtectionFormatterTests |
||||
|
{ |
||||
|
[Fact] |
||||
|
public void WriteToken_ReadToken_WithEmptyClaimsPrincipal() |
||||
|
{ |
||||
|
// Arrange
|
||||
|
var services = new OpenIddictServerDataProtectionFormatter(); |
||||
|
|
||||
|
using var buffer = new MemoryStream(); |
||||
|
using var writer = new BinaryWriter(buffer); |
||||
|
|
||||
|
var principal = new ClaimsPrincipal(); |
||||
|
|
||||
|
// Act and assert
|
||||
|
services.WriteToken(writer, principal); |
||||
|
|
||||
|
buffer.Seek(0, SeekOrigin.Begin); |
||||
|
|
||||
|
using var reader = new BinaryReader(buffer); |
||||
|
|
||||
|
var deserializedClaimsPrincipal = services.ReadToken(reader); |
||||
|
|
||||
|
Assert.NotNull(deserializedClaimsPrincipal); |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue