mirror of
https://github.com/bitwarden/server.git
synced 2024-11-21 12:05:42 +01:00
Allow acceptable result ranges for integration tests (#3161)
This commit is contained in:
parent
ab5c6d088b
commit
ca368466ce
@ -33,7 +33,7 @@ public class IdentityServerTests : IClassFixture<IdentityApplicationFactory>
|
||||
using var body = await AssertHelper.AssertResponseTypeIs<JsonDocument>(context);
|
||||
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
|
||||
// or loss of functionality is properly noted.
|
||||
await using var fs = File.OpenRead("openid-configuration.json");
|
||||
@ -372,10 +372,10 @@ public class IdentityServerTests : IClassFixture<IdentityApplicationFactory>
|
||||
}
|
||||
|
||||
/// <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"/>
|
||||
/// 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
|
||||
/// </summary>
|
||||
[Fact]
|
||||
@ -488,9 +488,9 @@ public class IdentityServerTests : IClassFixture<IdentityApplicationFactory>
|
||||
}
|
||||
|
||||
[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
|
||||
var username = "test+ratelimiting@email.com";
|
||||
@ -514,9 +514,9 @@ public class IdentityServerTests : IClassFixture<IdentityApplicationFactory>
|
||||
}
|
||||
|
||||
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.Equal(1, responses.Count(c => c.Response.StatusCode == StatusCodes.Status429TooManyRequests));
|
||||
Assert.True(blockResponses.Count() > 0);
|
||||
|
||||
Task<HttpContext> MakeRequest()
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user