public async Task RevokedToken(TestConfig config) { var idToken = await config.CreateIdTokenAsync(); var handler = new MockMessageHandler() { Response = $@"{{ ""users"": [ {{ ""localId"": ""testuser"", ""validSince"": {JwtTestUtils.Clock.UnixTimestamp()} }} ] }}", }; var auth = config.CreateAuth(handler); var decoded = await auth.VerifyIdTokenAsync(idToken); Assert.Equal("testuser", decoded.Uid); Assert.Equal(0, handler.Calls); var exception = await Assert.ThrowsAsync <FirebaseAuthException>( async() => await auth.VerifyIdTokenAsync(idToken, true)); var expectedMessage = "Firebase ID token has been revoked."; this.CheckException(exception, expectedMessage, AuthErrorCode.RevokedIdToken); Assert.Equal(1, handler.Calls); config.AssertRevocationCheckRequest(handler.Requests[0].Url); }
public async Task ValidUnrevokedToken(TestConfig config) { var idToken = await config.CreateIdTokenAsync(); var handler = new MockMessageHandler() { Response = @"{ ""users"": [ { ""localId"": ""testuser"" } ] }", }; var auth = config.CreateAuth(handler); var decoded = await auth.VerifyIdTokenAsync(idToken, true); Assert.Equal("testuser", decoded.Uid); Assert.Equal(1, handler.Calls); config.AssertRevocationCheckRequest(handler.Requests[0].Url); }
public async Task CheckRevokedError(TestConfig config) { var idToken = await config.CreateIdTokenAsync(); var handler = new MockMessageHandler() { StatusCode = HttpStatusCode.InternalServerError, Response = @"{ ""error"": {""message"": ""USER_NOT_FOUND""} }", }; var auth = config.CreateAuth(handler); var exception = await Assert.ThrowsAsync <FirebaseAuthException>( async() => await auth.VerifyIdTokenAsync(idToken, true)); Assert.Equal(ErrorCode.NotFound, exception.ErrorCode); Assert.StartsWith("No user record found for the given identifier", exception.Message); Assert.Equal(AuthErrorCode.UserNotFound, exception.AuthErrorCode); Assert.Null(exception.InnerException); Assert.NotNull(exception.HttpResponse); Assert.Equal(1, handler.Calls); config.AssertRevocationCheckRequest(handler.Requests[0].Url); }