|
|
|
@ -33,7 +33,7 @@ public class IdentityServerTests : IClassFixture<IdentityApplicationFactory> |
|
|
|
using var body = await AssertHelper.AssertResponseTypeIs<JsonDocument>(context); |
|
|
|
using var body = await AssertHelper.AssertResponseTypeIs<JsonDocument>(context); |
|
|
|
var endpointRoot = body.RootElement; |
|
|
|
var endpointRoot = body.RootElement; |
|
|
|
|
|
|
|
|
|
|
|
// WARNING: Edits to this file should NOT just be made to "get the test to work" they should be made when intentional |
|
|
|
// WARNING: Edits to this file should NOT just be made to "get the test to work" they should be made when intentional |
|
|
|
// changes were made to this endpoint and proper testing will take place to ensure clients are backwards compatible |
|
|
|
// changes were made to this endpoint and proper testing will take place to ensure clients are backwards compatible |
|
|
|
// or loss of functionality is properly noted. |
|
|
|
// or loss of functionality is properly noted. |
|
|
|
await using var fs = File.OpenRead("openid-configuration.json"); |
|
|
|
await using var fs = File.OpenRead("openid-configuration.json"); |
|
|
|
@ -372,10 +372,10 @@ public class IdentityServerTests : IClassFixture<IdentityApplicationFactory> |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
/// <summary> |
|
|
|
/// This test currently does not test any code that is not covered by other tests but |
|
|
|
/// This test currently does not test any code that is not covered by other tests but |
|
|
|
/// it shows that we probably have some dead code in <see cref="ClientStore"/> |
|
|
|
/// it shows that we probably have some dead code in <see cref="ClientStore"/> |
|
|
|
/// for installation, organization, and user they split on a <c>'.'</c> but have already checked that at least one |
|
|
|
/// for installation, organization, and user they split on a <c>'.'</c> but have already checked that at least one |
|
|
|
/// <c>'.'</c> exists in the <c>client_id</c> by checking it with <see cref="string.StartsWith(string)"/> |
|
|
|
/// <c>'.'</c> exists in the <c>client_id</c> by checking it with <see cref="string.StartsWith(string)"/> |
|
|
|
/// I believe that idParts.Length > 1 will ALWAYS return true |
|
|
|
/// I believe that idParts.Length > 1 will ALWAYS return true |
|
|
|
/// </summary> |
|
|
|
/// </summary> |
|
|
|
[Fact] |
|
|
|
[Fact] |
|
|
|
@ -488,9 +488,9 @@ public class IdentityServerTests : IClassFixture<IdentityApplicationFactory> |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[Theory, BitAutoData] |
|
|
|
[Theory, BitAutoData] |
|
|
|
public async Task TokenEndpoint_ToQuickInOneSecond_BlockRequest(string deviceId) |
|
|
|
public async Task TokenEndpoint_TooQuickInOneSecond_BlockRequest(string deviceId) |
|
|
|
{ |
|
|
|
{ |
|
|
|
const int AmountInOneSecondAllowed = 5; |
|
|
|
const int AmountInOneSecondAllowed = 10; |
|
|
|
|
|
|
|
|
|
|
|
// The rule we are testing is 10 requests in 1 second |
|
|
|
// The rule we are testing is 10 requests in 1 second |
|
|
|
var username = "test+ratelimiting@email.com"; |
|
|
|
var username = "test+ratelimiting@email.com"; |
|
|
|
@ -514,9 +514,9 @@ public class IdentityServerTests : IClassFixture<IdentityApplicationFactory> |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var responses = (await Task.WhenAll(tasks)).ToList(); |
|
|
|
var responses = (await Task.WhenAll(tasks)).ToList(); |
|
|
|
|
|
|
|
var blockResponses = responses.Where(c => c.Response.StatusCode == StatusCodes.Status429TooManyRequests); |
|
|
|
|
|
|
|
|
|
|
|
Assert.Equal(5, responses.Count(c => c.Response.StatusCode == StatusCodes.Status200OK)); |
|
|
|
Assert.True(blockResponses.Count() > 0); |
|
|
|
Assert.Equal(1, responses.Count(c => c.Response.StatusCode == StatusCodes.Status429TooManyRequests)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Task<HttpContext> MakeRequest() |
|
|
|
Task<HttpContext> MakeRequest() |
|
|
|
{ |
|
|
|
{ |
|
|
|
|