From 272c2d0cc896664674d40e10517676bee7b7dfdd Mon Sep 17 00:00:00 2001 From: Brendan Forster Date: Thu, 9 Apr 2020 12:14:54 -0300 Subject: [PATCH] add failing test for parsing ApiInfo --- Octokit.Tests/Http/ApiInfoParserTests.cs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/Octokit.Tests/Http/ApiInfoParserTests.cs b/Octokit.Tests/Http/ApiInfoParserTests.cs index 00e3215b4e..ed837640ac 100644 --- a/Octokit.Tests/Http/ApiInfoParserTests.cs +++ b/Octokit.Tests/Http/ApiInfoParserTests.cs @@ -32,6 +32,28 @@ public void ParsesApiInfoFromHeaders() Assert.Equal("5634b0b187fd2e91e3126a75006cc4fa", apiInfo.Etag); } + [Fact] + public void ParsesApiInfoFromCaseInsensitiveHeaders() + { + var headers = new Dictionary + { + { "x-accepted-oauth-scopes", "user" }, + { "x-oauth-scopes", "user, public_repo, repo, gist" }, + { "x-ratelimit-limit", "5000" }, + { "x-ratelimit-remaining", "4997" }, + { "etag", "5634b0b187fd2e91e3126a75006cc4fa" } + }; + + var apiInfo = ApiInfoParser.ParseResponseHeaders(headers); + + Assert.NotNull(apiInfo); + Assert.Equal(new[] { "user" }, apiInfo.AcceptedOauthScopes.ToArray()); + Assert.Equal(new[] { "user", "public_repo", "repo", "gist" }, apiInfo.OauthScopes.ToArray()); + Assert.Equal(5000, apiInfo.RateLimit.Limit); + Assert.Equal(4997, apiInfo.RateLimit.Remaining); + Assert.Equal("5634b0b187fd2e91e3126a75006cc4fa", apiInfo.Etag); + } + [Fact] public void BadHeadersAreIgnored() {