[SignalR] Fix DataProtection with parallel tests (#21271)
This commit is contained in:
parent
5fc067266f
commit
600d5ff497
|
|
@ -3,10 +3,12 @@
|
|||
|
||||
using System;
|
||||
using System.IdentityModel.Tokens.Jwt;
|
||||
using System.IO;
|
||||
using System.Security.Claims;
|
||||
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.DataProtection;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Http.Connections;
|
||||
using Microsoft.AspNetCore.Routing;
|
||||
|
|
@ -49,6 +51,11 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
IssuerSigningKey = SecurityKey
|
||||
};
|
||||
});
|
||||
|
||||
// Since tests run in parallel, it's possible multiple servers will startup and read files being written by another test
|
||||
// Use a unique directory per server to avoid this collision
|
||||
services.AddDataProtection()
|
||||
.PersistKeysToFileSystem(Directory.CreateDirectory(Path.GetRandomFileName()));
|
||||
}
|
||||
|
||||
public void Configure(IApplicationBuilder app)
|
||||
|
|
|
|||
|
|
@ -3,11 +3,13 @@
|
|||
|
||||
using System;
|
||||
using System.IdentityModel.Tokens.Jwt;
|
||||
using System.IO;
|
||||
using System.Security.Claims;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.DataProtection;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
|
|
@ -63,6 +65,11 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
|||
services.AddAuthorization();
|
||||
|
||||
services.AddSingleton<IAuthorizationHandler, TestAuthHandler>();
|
||||
|
||||
// Since tests run in parallel, it's possible multiple servers will startup and read files being written by another test
|
||||
// Use a unique directory per server to avoid this collision
|
||||
services.AddDataProtection()
|
||||
.PersistKeysToFileSystem(Directory.CreateDirectory(Path.GetRandomFileName()));
|
||||
}
|
||||
|
||||
public void Configure(IApplicationBuilder app)
|
||||
|
|
|
|||
Loading…
Reference in New Issue