public async Task BeforeAll() { _host = new KestrelHost() .ConfigureServices(services => { services.AddHttpContextAccessor(); services.AddAuthorization(); services .AddAuthentication(JwtBearerDefaults.AuthenticationScheme) .AddJwtBearer(options => { options.RequireHttpsMetadata = false; options.SaveToken = false; options.TokenValidationParameters = new TokenValidationParameters { ValidateLifetime = false, ValidateAudience = false, ValidateIssuer = false, ValidateIssuerSigningKey = false, ValidateTokenReplay = false, RequireAudience = false, RequireExpirationTime = false, IssuerSigningKey = new SymmetricSecurityKey(Guid.Empty.ToByteArray()) }; }); }) .ConfigureApp(app => { app .UseAuthentication() .UseAuthorization(); }); ConfigureKestrelHost(_host); await _host.StartAsync().ConfigureAwait(false); _domainService = _host.ClientFactory.CreateClient <IServiceWithAuthentication>(_host.Channel); }