diff --git a/test/GitHub.Api.UnitTests/LoginManagerTests.cs b/test/GitHub.Api.UnitTests/LoginManagerTests.cs index 6e7ca4c31..2a2fc732b 100644 --- a/test/GitHub.Api.UnitTests/LoginManagerTests.cs +++ b/test/GitHub.Api.UnitTests/LoginManagerTests.cs @@ -298,13 +298,30 @@ public class LoginManagerTests Assert.ThrowsAsync(() => target.Login(host, client, "foo", "bar")); } - IGitHubClient CreateClient(User user = null, string[] responseScopes = null) + [TestCase("X-OAuth-Scopes")] + [TestCase("x-oauth-scopes")] + public void ValidResponseScopesDoesNotThrow(string scopesHeader) + { + var client = CreateClient(responseScopes: scopes, scopesHeader: scopesHeader); + client.Authorization.GetOrCreateApplicationAuthentication("id", "secret", Arg.Any()) + .Returns(CreateApplicationAuthorization("123abc")); + + var keychain = Substitute.For(); + var tfa = new Lazy(() => Substitute.For()); + var oauthListener = Substitute.For(); + + var target = new LoginManager(keychain, tfa, oauthListener, "id", "secret", scopes, scopes); + + Assert.DoesNotThrowAsync(() => target.Login(host, client, "foo", "bar")); + } + + IGitHubClient CreateClient(User user = null, string[] responseScopes = null, string scopesHeader = "X-OAuth-Scopes") { var result = Substitute.For(); var userResponse = Substitute.For>(); userResponse.HttpResponse.Headers.Returns(new Dictionary { - { "X-OAuth-Scopes", string.Join(",", responseScopes ?? scopes) } + { scopesHeader, string.Join(",", responseScopes ?? scopes) } }); userResponse.Body.Returns(user ?? new User()); result.Connection.Get(new Uri("user", UriKind.Relative), null, null).Returns(userResponse);