Exemple #1
0
                    public void NoRetryAfterHeader_RetryAfterSecondsIsSetToTheDefaultOfNull()
                    {
                        var response       = CreateResponse(HttpStatusCode.Forbidden);
                        var abuseException = new AbuseException(response);

                        Assert.False(abuseException.RetryAfterSeconds.HasValue);
                    }
                public void HasDefaultMessage()
                {
                    var response       = new Response(HttpStatusCode.Forbidden, null, new Dictionary <string, string>(), "application/json");
                    var abuseException = new AbuseException(response);

                    Assert.Equal("Request Forbidden - Abuse Detection", abuseException.Message);
                }
Exemple #3
0
                public void HasDefaultMessage()
                {
                    var response       = CreateResponse(HttpStatusCode.Forbidden);
                    var abuseException = new AbuseException(response);

                    Assert.Equal("Request Forbidden - Abuse Detection", abuseException.Message);
                }
                    public void NoRetryAfterHeader_RetryAfterSecondsIsSetToTheDefaultOfNull()
                    {
                        var headerDictionary = new Dictionary <string, string>();

                        var response       = new Response(HttpStatusCode.Forbidden, null, headerDictionary, "application/json");
                        var abuseException = new AbuseException(response);

                        Assert.False(abuseException.RetryAfterSeconds.HasValue);
                    }
                    public void EmptyHeaderValue_RetryAfterSecondsDefaultsToNull(string emptyValueToTry)
                    {
                        var headerDictionary = new Dictionary <string, string> {
                            { "Retry-After", emptyValueToTry }
                        };

                        var response       = new Response(HttpStatusCode.Forbidden, null, headerDictionary, "application/json");
                        var abuseException = new AbuseException(response);

                        Assert.False(abuseException.RetryAfterSeconds.HasValue);
                    }
                    public void WithZeroHeaderValue_RetryAfterSecondsIsZero()
                    {
                        var headerDictionary = new Dictionary <string, string> {
                            { "Retry-After", "0" }
                        };

                        var response       = new Response(HttpStatusCode.Forbidden, null, headerDictionary, "application/json");
                        var abuseException = new AbuseException(response);

                        Assert.Equal(0, abuseException.RetryAfterSeconds);
                    }
                    public void WithRetryAfterHeader_PopulatesRetryAfterSeconds()
                    {
                        var headerDictionary = new Dictionary <string, string> {
                            { "Retry-After", "30" }
                        };

                        var response       = new Response(HttpStatusCode.Forbidden, null, headerDictionary, "application/json");
                        var abuseException = new AbuseException(response);

                        Assert.Equal(30, abuseException.RetryAfterSeconds);
                    }
Exemple #8
0
                    public void WithRetryAfterCaseInsensitiveHeader_PopulatesRetryAfterSeconds()
                    {
                        var headerDictionary = new Dictionary <string, string> {
                            { "retry-after", "20" }
                        };

                        var response       = CreateResponse(HttpStatusCode.Forbidden, headerDictionary);
                        var abuseException = new AbuseException(response);

                        Assert.Equal(20, abuseException.RetryAfterSeconds);
                    }
Exemple #9
0
                    public void NegativeHeaderValue_RetryAfterSecondsDefaultsToNull()
                    {
                        var headerDictionary = new Dictionary <string, string> {
                            { "Retry-After", "-123" }
                        };

                        var response       = CreateResponse(HttpStatusCode.Forbidden, headerDictionary);
                        var abuseException = new AbuseException(response);

                        Assert.False(abuseException.RetryAfterSeconds.HasValue);
                    }
Exemple #10
0
                public void ContainsAbuseMessageFromApi()
                {
                    const string responseBody = "{\"message\":\"You have triggered an abuse detection mechanism. Please wait a few minutes before you try again.\"," +
                                                "\"documentation_url\":\"https://developer.github.com/v3/#abuse-rate-limits\"}";

                    var response = CreateResponse(
                        HttpStatusCode.Forbidden,
                        responseBody);

                    var abuseException = new AbuseException(response);

                    Assert.Equal("You have triggered an abuse detection mechanism. Please wait a few minutes before you try again.", abuseException.ApiError.Message);
                }
                public void ContainsAbuseMessageFromApi()
                {
                    const string responseBody = "{\"error\":\"You have triggered an abuse detection mechanism. Please wait a few minutes before you try again.\"," +
                                                "\"error_info\":\"https://developer.github.com/v3/#abuse-rate-limits\"}";

                    var response = new Response(
                        HttpStatusCode.Forbidden,
                        responseBody,
                        new Dictionary <string, string>(),
                        "application/json");

                    var abuseException = new AbuseException(response);

                    Assert.Equal("You have triggered an abuse detection mechanism. Please wait a few minutes before you try again.", abuseException.ApiError.Error);
                }