This repository has been archived by the owner on Dec 14, 2017. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 150
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
30 changed files
with
849 additions
and
147 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<packages> | ||
<package id="psake" version="4.4.1" /> | ||
<package id="xunit.runners" version="1.9.2" /> | ||
<package id="xunit.runner.console" version="2.0.0" /> | ||
</packages> |
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
87 changes: 87 additions & 0 deletions
87
source/AccessTokenValidation.Tests/Integration Tests/DynamicBoth.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,87 @@ | ||
using AccessTokenValidation.Tests.Util; | ||
using FluentAssertions; | ||
using IdentityServer3.AccessTokenValidation; | ||
using System.Net; | ||
using System.Net.Http; | ||
using System.Threading.Tasks; | ||
using Xunit; | ||
|
||
namespace AccessTokenValidation.Tests.Integration_Tests | ||
{ | ||
public class DynamicBoth | ||
{ | ||
IdentityServerBearerTokenAuthenticationOptions _options = new IdentityServerBearerTokenAuthenticationOptions | ||
{ | ||
Authority = "https://discodoc", | ||
ValidationMode = ValidationMode.Both | ||
}; | ||
|
||
[Fact] | ||
public async Task No_Token_Sent() | ||
{ | ||
_options.BackchannelHttpHandler = new DiscoveryEndpointHandler(); | ||
|
||
var client = PipelineFactory.CreateHttpClient(_options); | ||
|
||
var result = await client.GetAsync("http://test"); | ||
result.StatusCode.Should().Be(HttpStatusCode.Unauthorized); | ||
} | ||
|
||
[Fact] | ||
public async Task JWT_Invalid_Token_Sent() | ||
{ | ||
_options.BackchannelHttpHandler = new DiscoveryEndpointHandler(); | ||
|
||
var client = PipelineFactory.CreateHttpClient(_options); | ||
client.SetBearerToken("in.valid"); | ||
|
||
var result = await client.GetAsync("http://test"); | ||
result.StatusCode.Should().Be(HttpStatusCode.Unauthorized); | ||
} | ||
|
||
[Fact] | ||
public async Task JWT_Sent_No_Scope_No_ScopeRequirements() | ||
{ | ||
_options.BackchannelHttpHandler = new DiscoveryEndpointHandler(); | ||
|
||
var client = PipelineFactory.CreateHttpClient(_options); | ||
var token = TokenFactory.CreateTokenString(TokenFactory.CreateToken()); | ||
|
||
client.SetBearerToken(token); | ||
|
||
var result = await client.GetAsync("http://test"); | ||
result.StatusCode.Should().Be(HttpStatusCode.OK); | ||
} | ||
|
||
[Fact] | ||
public async Task JWT_Sent_No_Scope_Api1_ScopeRequirements() | ||
{ | ||
_options.BackchannelHttpHandler = new DiscoveryEndpointHandler(); | ||
_options.RequiredScopes = new[] { TokenFactory.Api1Scope }; | ||
|
||
var client = PipelineFactory.CreateHttpClient(_options); | ||
var token = TokenFactory.CreateTokenString(TokenFactory.CreateToken()); | ||
|
||
client.SetBearerToken(token); | ||
|
||
var result = await client.GetAsync("http://test"); | ||
result.StatusCode.Should().Be(HttpStatusCode.Forbidden); | ||
} | ||
|
||
[Fact] | ||
public async Task JWT_Sent_Api1_Scope_Api1_ScopeRequirements() | ||
{ | ||
_options.BackchannelHttpHandler = new DiscoveryEndpointHandler(); | ||
_options.RequiredScopes = new[] { TokenFactory.Api1Scope }; | ||
|
||
var client = PipelineFactory.CreateHttpClient(_options); | ||
var token = TokenFactory.CreateTokenString( | ||
TokenFactory.CreateToken(scope: new[] { TokenFactory.Api1Scope })); | ||
|
||
client.SetBearerToken(token); | ||
|
||
var result = await client.GetAsync("http://test"); | ||
result.StatusCode.Should().Be(HttpStatusCode.OK); | ||
} | ||
} | ||
} |
Oops, something went wrong.