diff --git a/tests/Auth0.Core.UnitTests/HttpClientManagementConnectionTests.cs b/tests/Auth0.Core.UnitTests/HttpClientManagementConnectionTests.cs index c3d515c5a..718886095 100644 --- a/tests/Auth0.Core.UnitTests/HttpClientManagementConnectionTests.cs +++ b/tests/Auth0.Core.UnitTests/HttpClientManagementConnectionTests.cs @@ -137,5 +137,33 @@ public void Should_Not_Retry_When_Limit_Set_To_Zero() amountOfTimesCalled.Should().Be(1); } + + [Fact] + public void Should_Not_Retry_When_Not_A_RateLimitApiException() + { + var mockHandler = new Mock(MockBehavior.Strict); + var amountOfTimesCalled = 0; + + mockHandler.Protected() + .Setup>( + "SendAsync", + ItExpr.Is(req => req.RequestUri.ToString() == $"https://test.com/"), + ItExpr.IsAny() + ) + .Callback(() => amountOfTimesCalled++) + .ReturnsAsync(new HttpResponseMessage() + { + StatusCode = HttpStatusCode.BadRequest, + Content = new StringContent("", Encoding.UTF8, "application/json"), + }); + + var httpClient = new HttpClient(mockHandler.Object); + var connection = new HttpClientManagementConnection(httpClient, new HttpClientManagementConnectionOptions { NumberOfHttpRetries = 6 }); + + Func getFunc = async () => await connection.SendAsync(HttpMethod.Get, new Uri("https://test.com/"), null, null, null); + getFunc.Should().Throw(); + + amountOfTimesCalled.Should().Be(1); + } } }