forked from IdentityServer/IdentityServer3
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Current claims available in RefreshTokenRefreshDetails IdentityServer…
- Loading branch information
Szymon Gaertig
committed
Sep 4, 2016
1 parent
550cc2e
commit 2d7e028
Showing
4 changed files
with
71 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
source/Tests/UnitTests/Events/RefreshTokenRefreshDetailsTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
using System.Collections.Generic; | ||
using System.Security.Claims; | ||
using System.Threading.Tasks; | ||
using IdentityServer3.Core.Events; | ||
using IdentityServer3.Core.Extensions; | ||
using IdentityServer3.Core.Models; | ||
using IdentityServer3.Core.Services; | ||
using Moq; | ||
using Xunit; | ||
|
||
namespace IdentityServer3.Tests.Events | ||
{ | ||
public class RefreshTokenRefreshDetailsTests | ||
{ | ||
[Fact] | ||
public async Task When_claims_are_provided_then_create_event_with_given_claims() | ||
{ | ||
// Given | ||
var oldHandle = "old_handle"; | ||
var newHandle = "new_handle"; | ||
|
||
var claimsPrincipalMock = new Mock<ClaimsPrincipal>(); | ||
claimsPrincipalMock.Setup(x => x.Claims) | ||
.Returns(new List<Claim>() | ||
{ | ||
new Claim("claim_type_1", "claims_1_value"), | ||
new Claim("claim_type_2", "claims_2_value") | ||
}); | ||
|
||
var refreshToken = new RefreshToken() | ||
{ | ||
AccessToken = new Token() | ||
{ | ||
Client = new Client() | ||
{ | ||
ClientId = "client_id", | ||
AccessTokenLifetime = 10 | ||
}, | ||
}, | ||
Subject = claimsPrincipalMock.Object | ||
}; | ||
var eventServiceMock = new Mock<IEventService>(); | ||
|
||
// When | ||
await eventServiceMock.Object.RaiseSuccessfulRefreshTokenRefreshEventAsync(oldHandle, | ||
newHandle, | ||
refreshToken); | ||
|
||
// Then | ||
eventServiceMock.Verify( | ||
x => x.RaiseAsync( | ||
It.Is<Event<RefreshTokenRefreshDetails>>(rt | ||
=> rt.Details.Claims.ContainsKey("claim_type_1") | ||
&& rt.Details.Claims.ContainsKey("claim_type_2") | ||
&& rt.Details.Claims.Count == 2))); | ||
} | ||
} | ||
} |