public static async Task ValidateAsync_WrongAudience() { var authenticationSettings = new AuthenticationSettings { Google = new GoogleAuthenticationSettings { ClientId = ClientId, }, }; var options = Options.Create(authenticationSettings); using (var http = new HttpClientTestingFactory()) { var handler = new GoogleAssertionGrantHandler(options, http.HttpClient); var resultTask = handler.ValidateAsync(Assertion); http.Expect(ValidationEndpoint).Respond(JsonConvert.SerializeObject(new JsonWebToken { Aud = "SomeOtherClientId", Sub = ExternalUserId, })); var result = await resultTask; Assert.NotNull(result); Assert.False(result.IsSuccessful); http.EnsureNoOutstandingRequests(); } }
public static async Task ValidateAsync_HttpError() { var authenticationSettings = new AuthenticationSettings(); var options = Options.Create(authenticationSettings); using (var http = new HttpClientTestingFactory()) { var handler = new GoogleAssertionGrantHandler(options, http.HttpClient); var resultTask = handler.ValidateAsync(Assertion); http.Expect(ValidationEndpoint).Respond(HttpStatusCode.BadRequest); var result = await resultTask; Assert.NotNull(result); Assert.False(result.IsSuccessful); http.EnsureNoOutstandingRequests(); } }