| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| | using Google.Apis.Auth.OAuth2; |
| | using Google.Apis.Auth.OAuth2.Flows; |
| | using Google.Apis.Auth.OAuth2.Responses; |
| | using Google.Apis.Util.Store; |
| | using IntegrationTests.Utils; |
| | using System.Net; |
| | using System.Threading.Tasks; |
| | using Xunit; |
| |
|
| | namespace IntegrationTests |
| | { |
| | public class RevocationTests |
| | { |
| | [Fact] |
| | public async Task RevokeFakeToken_BadRequest() |
| | { |
| | |
| | |
| | using (var f = new GoogleAuthorizationCodeFlow(new GoogleAuthorizationCodeFlow.Initializer |
| | { |
| | ClientSecretsStream = Helper.GetClientSecretStream() |
| | })) |
| | { |
| | var ex = await Assert.ThrowsAsync<TokenResponseException>( |
| | () => f.RevokeTokenAsync("fake-user", "fake-token", default)); |
| | Assert.Equal(HttpStatusCode.BadRequest, ex.StatusCode); |
| | Assert.Equal("invalid_token", ex.Error.Error); |
| | } |
| | } |
| |
|
| | [Fact] |
| | public async Task RevokeRealToken() |
| | { |
| | UserCredential cred = await GoogleWebAuthorizationBroker.AuthorizeAsync( |
| | Helper.GetClientSecretStream(), new string[] { "email" }, |
| | "user", default, new NullDataStore()); |
| | Assert.NotNull(cred); |
| | var accessToken = await cred.GetAccessTokenForRequestAsync(); |
| | using (var f = new GoogleAuthorizationCodeFlow(new GoogleAuthorizationCodeFlow.Initializer |
| | { |
| | ClientSecretsStream = Helper.GetClientSecretStream() |
| | })) |
| | { |
| | |
| | await f.RevokeTokenAsync("a-user", accessToken, default); |
| | |
| | } |
| | } |
| | } |
| | } |
| |
|