From 83e5d4213fa27f2a2424307d0b3b9150c4676941 Mon Sep 17 00:00:00 2001 From: maliming Date: Wed, 3 Jan 2024 13:09:29 +0800 Subject: [PATCH] Update AppUrlProvider_Tests.cs --- .../Abp/Ui/Navigation/AppUrlProvider_Tests.cs | 25 +++++++++++++------ 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/framework/test/Volo.Abp.UI.Navigation.Tests/Volo/Abp/Ui/Navigation/AppUrlProvider_Tests.cs b/framework/test/Volo.Abp.UI.Navigation.Tests/Volo/Abp/Ui/Navigation/AppUrlProvider_Tests.cs index a6fc63240d..5b448aa683 100644 --- a/framework/test/Volo.Abp.UI.Navigation.Tests/Volo/Abp/Ui/Navigation/AppUrlProvider_Tests.cs +++ b/framework/test/Volo.Abp.UI.Navigation.Tests/Volo/Abp/Ui/Navigation/AppUrlProvider_Tests.cs @@ -4,6 +4,7 @@ using System.Threading.Tasks; using Microsoft.Extensions.DependencyInjection; using Shouldly; using Volo.Abp.MultiTenancy; +using Volo.Abp.MultiTenancy.ConfigurationStore; using Volo.Abp.Testing; using Volo.Abp.UI.Navigation.Urls; using Xunit; @@ -15,6 +16,8 @@ public class AppUrlProvider_Tests : AbpIntegratedTest private readonly IAppUrlProvider _appUrlProvider; private readonly ICurrentTenant _currentTenant; + private readonly Guid _tenantAId = Guid.NewGuid(); + public AppUrlProvider_Tests() { _appUrlProvider = ServiceProvider.GetRequiredService(); @@ -43,6 +46,14 @@ public class AppUrlProvider_Tests : AbpIntegratedTest options.Applications["BLAZOR"].RootUrl = "https://{{tenantId}}.abp.io"; options.Applications["BLAZOR"].Urls["PasswordReset"] = "account/reset-password"; }); + + services.Configure(options => + { + options.Tenants = new TenantConfiguration[] + { + new(_tenantAId, "community") + }; + }); } [Fact] @@ -66,14 +77,13 @@ public class AppUrlProvider_Tests : AbpIntegratedTest url.ShouldBe("https://community.abp.io/account/reset-password"); } - var tenantId = Guid.NewGuid(); - using (_currentTenant.Change(tenantId)) + using (_currentTenant.Change(_tenantAId)) { var url = await _appUrlProvider.GetUrlAsync("BLAZOR"); - url.ShouldBe($"https://{tenantId}.abp.io"); + url.ShouldBe($"https://{_tenantAId}.abp.io"); url = await _appUrlProvider.GetUrlAsync("BLAZOR", "PasswordReset"); - url.ShouldBe($"https://{tenantId}.abp.io/account/reset-password"); + url.ShouldBe($"https://{_tenantAId}.abp.io/account/reset-password"); } await Assert.ThrowsAsync(async () => @@ -100,16 +110,15 @@ public class AppUrlProvider_Tests : AbpIntegratedTest (await _appUrlProvider.IsRedirectAllowedUrlAsync("https://abp.io")).ShouldBeTrue(); } - using (_currentTenant.Change(Guid.NewGuid(), "community")) + using (_currentTenant.Change(_tenantAId, "community")) { (await _appUrlProvider.IsRedirectAllowedUrlAsync("https://community.abp.io")).ShouldBeTrue(); (await _appUrlProvider.IsRedirectAllowedUrlAsync("https://community2.abp.io")).ShouldBeFalse(); } - var tenantId = Guid.NewGuid(); - using (_currentTenant.Change(tenantId)) + using (_currentTenant.Change(_tenantAId)) { - (await _appUrlProvider.IsRedirectAllowedUrlAsync($"https://{tenantId}.abp.io")).ShouldBeTrue(); + (await _appUrlProvider.IsRedirectAllowedUrlAsync($"https://{_tenantAId}.abp.io")).ShouldBeTrue(); (await _appUrlProvider.IsRedirectAllowedUrlAsync($"https://{Guid.NewGuid()}.abp.io")).ShouldBeFalse(); } }