diff options
-rw-r--r-- | Timeline.Tests/IntegratedTests/AuthorizationUnitTest.cs | 9 | ||||
-rw-r--r-- | Timeline.Tests/Timeline.Tests.csproj | 1 | ||||
-rw-r--r-- | Timeline/Controllers/Testing/TestingAuthController.cs (renamed from Timeline/Controllers/UserTestController.cs) | 6 | ||||
-rw-r--r-- | Timeline/Startup.cs | 16 |
4 files changed, 24 insertions, 8 deletions
diff --git a/Timeline.Tests/IntegratedTests/AuthorizationUnitTest.cs b/Timeline.Tests/IntegratedTests/AuthorizationUnitTest.cs index a67bffcf..588e4349 100644 --- a/Timeline.Tests/IntegratedTests/AuthorizationUnitTest.cs +++ b/Timeline.Tests/IntegratedTests/AuthorizationUnitTest.cs @@ -11,10 +11,6 @@ namespace Timeline.Tests.IntegratedTests {
public class AuthorizationUnitTest : IClassFixture<WebApplicationFactory<Startup>>, IDisposable
{
- private const string AuthorizeUrl = "Test/User/Authorize";
- private const string UserUrl = "Test/User/User";
- private const string AdminUrl = "Test/User/Admin";
-
private readonly TestApplication _testApp;
private readonly WebApplicationFactory<Startup> _factory;
@@ -29,6 +25,11 @@ namespace Timeline.Tests.IntegratedTests _testApp.Dispose();
}
+ private const string BaseUrl = "testing/auth/";
+ private const string AuthorizeUrl = BaseUrl + "Authorize";
+ private const string UserUrl = BaseUrl + "User";
+ private const string AdminUrl = BaseUrl + "Admin";
+
[Fact]
public async Task UnauthenticationTest()
{
diff --git a/Timeline.Tests/Timeline.Tests.csproj b/Timeline.Tests/Timeline.Tests.csproj index a611dfd3..497a00b7 100644 --- a/Timeline.Tests/Timeline.Tests.csproj +++ b/Timeline.Tests/Timeline.Tests.csproj @@ -4,7 +4,6 @@ <TargetFramework>netcoreapp3.0</TargetFramework>
<LangVersion>8.0</LangVersion>
- <Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
diff --git a/Timeline/Controllers/UserTestController.cs b/Timeline/Controllers/Testing/TestingAuthController.cs index 2a5f36a1..488a3cff 100644 --- a/Timeline/Controllers/UserTestController.cs +++ b/Timeline/Controllers/Testing/TestingAuthController.cs @@ -2,11 +2,11 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc;
using Timeline.Authenticate;
-namespace Timeline.Controllers
+namespace Timeline.Controllers.Testing
{
- [Route("Test/User")]
+ [Route("testing/auth")]
[ApiController]
- public class UserTestController : Controller
+ public class TestingAuthController : Controller
{
[HttpGet("[action]")]
[Authorize]
diff --git a/Timeline/Startup.cs b/Timeline/Startup.cs index 72c9bf32..5718cf05 100644 --- a/Timeline/Startup.cs +++ b/Timeline/Startup.cs @@ -2,9 +2,12 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Cors.Infrastructure;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.HttpOverrides;
+using Microsoft.AspNetCore.Localization;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
+using System.Collections.Generic;
+using System.Globalization;
using Timeline.Authenticate;
using Timeline.Configs;
using Timeline.Entities;
@@ -86,6 +89,19 @@ namespace Timeline app.UseRouting();
+ var supportedCultures = new List<CultureInfo>
+ {
+ new CultureInfo("en"),
+ new CultureInfo("zh")
+ };
+
+ app.UseRequestLocalization(new RequestLocalizationOptions
+ {
+ DefaultRequestCulture = new RequestCulture("en"),
+ SupportedCultures = supportedCultures,
+ SupportedUICultures = supportedCultures
+ });
+
app.UseCors();
app.UseAuthentication();
|