Skip to content

Commit

Permalink
add failing test for parsing ApiInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
shiftkey committed Apr 9, 2020
1 parent a25863f commit 272c2d0
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions Octokit.Tests/Http/ApiInfoParserTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,28 @@ public void ParsesApiInfoFromHeaders()
Assert.Equal("5634b0b187fd2e91e3126a75006cc4fa", apiInfo.Etag);
}

[Fact]
public void ParsesApiInfoFromCaseInsensitiveHeaders()
{
var headers = new Dictionary<string, string>
{
{ "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()
{
Expand Down

0 comments on commit 272c2d0

Please sign in to comment.