TestServer上未触发CookieAuthenticationOptions事件

TestServer上未触发CookieAuthenticationOptions事件,authentication,cookies,asp.net-identity,integration-testing,identityserver4,Authentication,Cookies,Asp.net Identity,Integration Testing,Identityserver4,我使用Microsoft.AspNetCore.TestHost进行了集成测试。在启动时,我添加了CookieAuthentication(Microsoft.AspNetCore.Authentication.Cookies)中间件 app.UseCookieAuthentication(new CookieAuthenticationOptions { AuthenticationScheme = "Cookies", AutomaticAuthenticate = true

我使用Microsoft.AspNetCore.TestHost进行了集成测试。在启动时,我添加了
CookieAuthentication(Microsoft.AspNetCore.Authentication.Cookies)
中间件

app.UseCookieAuthentication(new CookieAuthenticationOptions
{
    AuthenticationScheme = "Cookies",
    AutomaticAuthenticate = true,
    AutomaticChallenge = true,
    Events = new CookieAuthenticationEvents()
    {
        OnValidatePrincipal = CookieAuthenticationOnValidatePrincipal    
    }
});
在测试中,我可以成功登录并获得访问令牌。当我尝试访问未触发的
OnValidatePrincipal
事件时,我有一个带有
[Authorize]
属性的操作,但如果我将AuthenticationScheme更改为其他中间件,则身份验证首先失败。我的问题是为什么没有为
AuthenticationScheme=“Cookies”
触发任何事件?我想我错过了什么