Browse Source

Update AppUrlProvider_Tests.cs

pull/18492/head
maliming 3 years ago
parent
commit
83e5d4213f
No known key found for this signature in database GPG Key ID: A646B9CB645ECEA4
  1. 25
      framework/test/Volo.Abp.UI.Navigation.Tests/Volo/Abp/Ui/Navigation/AppUrlProvider_Tests.cs

25
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 Microsoft.Extensions.DependencyInjection;
using Shouldly; using Shouldly;
using Volo.Abp.MultiTenancy; using Volo.Abp.MultiTenancy;
using Volo.Abp.MultiTenancy.ConfigurationStore;
using Volo.Abp.Testing; using Volo.Abp.Testing;
using Volo.Abp.UI.Navigation.Urls; using Volo.Abp.UI.Navigation.Urls;
using Xunit; using Xunit;
@ -15,6 +16,8 @@ public class AppUrlProvider_Tests : AbpIntegratedTest<AbpUiNavigationTestModule>
private readonly IAppUrlProvider _appUrlProvider; private readonly IAppUrlProvider _appUrlProvider;
private readonly ICurrentTenant _currentTenant; private readonly ICurrentTenant _currentTenant;
private readonly Guid _tenantAId = Guid.NewGuid();
public AppUrlProvider_Tests() public AppUrlProvider_Tests()
{ {
_appUrlProvider = ServiceProvider.GetRequiredService<AppUrlProvider>(); _appUrlProvider = ServiceProvider.GetRequiredService<AppUrlProvider>();
@ -43,6 +46,14 @@ public class AppUrlProvider_Tests : AbpIntegratedTest<AbpUiNavigationTestModule>
options.Applications["BLAZOR"].RootUrl = "https://{{tenantId}}.abp.io"; options.Applications["BLAZOR"].RootUrl = "https://{{tenantId}}.abp.io";
options.Applications["BLAZOR"].Urls["PasswordReset"] = "account/reset-password"; options.Applications["BLAZOR"].Urls["PasswordReset"] = "account/reset-password";
}); });
services.Configure<AbpDefaultTenantStoreOptions>(options =>
{
options.Tenants = new TenantConfiguration[]
{
new(_tenantAId, "community")
};
});
} }
[Fact] [Fact]
@ -66,14 +77,13 @@ public class AppUrlProvider_Tests : AbpIntegratedTest<AbpUiNavigationTestModule>
url.ShouldBe("https://community.abp.io/account/reset-password"); url.ShouldBe("https://community.abp.io/account/reset-password");
} }
var tenantId = Guid.NewGuid(); using (_currentTenant.Change(_tenantAId))
using (_currentTenant.Change(tenantId))
{ {
var url = await _appUrlProvider.GetUrlAsync("BLAZOR"); 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 = 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<AbpException>(async () => await Assert.ThrowsAsync<AbpException>(async () =>
@ -100,16 +110,15 @@ public class AppUrlProvider_Tests : AbpIntegratedTest<AbpUiNavigationTestModule>
(await _appUrlProvider.IsRedirectAllowedUrlAsync("https://abp.io")).ShouldBeTrue(); (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://community.abp.io")).ShouldBeTrue();
(await _appUrlProvider.IsRedirectAllowedUrlAsync("https://community2.abp.io")).ShouldBeFalse(); (await _appUrlProvider.IsRedirectAllowedUrlAsync("https://community2.abp.io")).ShouldBeFalse();
} }
var tenantId = Guid.NewGuid(); using (_currentTenant.Change(_tenantAId))
using (_currentTenant.Change(tenantId))
{ {
(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(); (await _appUrlProvider.IsRedirectAllowedUrlAsync($"https://{Guid.NewGuid()}.abp.io")).ShouldBeFalse();
} }
} }

Loading…
Cancel
Save