mirror of
https://github.com/zoriya/octokit.net.git
synced 2026-06-04 03:16:11 +00:00
added failing test for deserializing OAuth scopes
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using NSubstitute;
|
||||
using Octokit;
|
||||
using Octokit.Internal;
|
||||
using Octokit.Tests;
|
||||
using Xunit;
|
||||
using Xunit.Extensions;
|
||||
@@ -82,5 +84,21 @@ public class OauthClientTests
|
||||
"client_id=secretid&client_secret=secretsecret&code=code&redirect_uri=https%3A%2F%2Fexample.com%2Ffoo",
|
||||
await calledBody.ReadAsStringAsync());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task DeserializesOAuthScopeFormat()
|
||||
{
|
||||
var responseText =
|
||||
"{\"access_token\":\"token-goes-here\",\"token_type\":\"bearer\",\"scope\":\"notifications,user,user:email\"}";
|
||||
|
||||
var strategy = new SimpleJsonSerializer();
|
||||
|
||||
var token = strategy.Deserialize<OauthToken>(responseText);
|
||||
|
||||
Assert.Equal(token.AccessToken, "token-goes-here");
|
||||
Assert.Equal(token.TokenType, "bearer");
|
||||
Assert.True(token.Scope.Contains("notifications"));
|
||||
Assert.True(token.Scope.Contains("user:email"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user