|
|
|
@ -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<AbpUiNavigationTestModule> |
|
|
|
private readonly IAppUrlProvider _appUrlProvider; |
|
|
|
private readonly ICurrentTenant _currentTenant; |
|
|
|
|
|
|
|
private readonly Guid _tenantAId = Guid.NewGuid(); |
|
|
|
|
|
|
|
public AppUrlProvider_Tests() |
|
|
|
{ |
|
|
|
_appUrlProvider = ServiceProvider.GetRequiredService<AppUrlProvider>(); |
|
|
|
@ -35,12 +38,22 @@ public class AppUrlProvider_Tests : AbpIntegratedTest<AbpUiNavigationTestModule> |
|
|
|
options.RedirectAllowedUrls.AddRange(new List<string>() |
|
|
|
{ |
|
|
|
"https://wwww.volosoft.com", |
|
|
|
"https://wwww.aspnetzero.com" |
|
|
|
"https://wwww.aspnetzero.com", |
|
|
|
"https://{{tenantName}}.abp.io", |
|
|
|
"https://{{tenantId}}.abp.io" |
|
|
|
}); |
|
|
|
|
|
|
|
options.Applications["BLAZOR"].RootUrl = "https://{{tenantId}}.abp.io"; |
|
|
|
options.Applications["BLAZOR"].Urls["PasswordReset"] = "account/reset-password"; |
|
|
|
}); |
|
|
|
|
|
|
|
services.Configure<AbpDefaultTenantStoreOptions>(options => |
|
|
|
{ |
|
|
|
options.Tenants = new TenantConfiguration[] |
|
|
|
{ |
|
|
|
new(_tenantAId, "community") |
|
|
|
}; |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
@ -64,14 +77,13 @@ public class AppUrlProvider_Tests : AbpIntegratedTest<AbpUiNavigationTestModule> |
|
|
|
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<AbpException>(async () => |
|
|
|
@ -87,9 +99,27 @@ public class AppUrlProvider_Tests : AbpIntegratedTest<AbpUiNavigationTestModule> |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void IsRedirectAllowedUrl() |
|
|
|
public async Task IsRedirectAllowedUrlAsync() |
|
|
|
{ |
|
|
|
_appUrlProvider.IsRedirectAllowedUrl("https://community.abp.io").ShouldBeFalse(); |
|
|
|
_appUrlProvider.IsRedirectAllowedUrl("https://wwww.volosoft.com").ShouldBeTrue(); |
|
|
|
(await _appUrlProvider.IsRedirectAllowedUrlAsync("https://community.abp.io")).ShouldBeFalse(); |
|
|
|
(await _appUrlProvider.IsRedirectAllowedUrlAsync("https://wwww.volosoft.com")).ShouldBeTrue(); |
|
|
|
|
|
|
|
using (_currentTenant.Change(null)) |
|
|
|
{ |
|
|
|
(await _appUrlProvider.IsRedirectAllowedUrlAsync("https://www.abp.io")).ShouldBeFalse(); |
|
|
|
(await _appUrlProvider.IsRedirectAllowedUrlAsync("https://abp.io")).ShouldBeTrue(); |
|
|
|
} |
|
|
|
|
|
|
|
using (_currentTenant.Change(_tenantAId, "community")) |
|
|
|
{ |
|
|
|
(await _appUrlProvider.IsRedirectAllowedUrlAsync("https://community.abp.io")).ShouldBeTrue(); |
|
|
|
(await _appUrlProvider.IsRedirectAllowedUrlAsync("https://community2.abp.io")).ShouldBeFalse(); |
|
|
|
} |
|
|
|
|
|
|
|
using (_currentTenant.Change(_tenantAId)) |
|
|
|
{ |
|
|
|
(await _appUrlProvider.IsRedirectAllowedUrlAsync($"https://{_tenantAId}.abp.io")).ShouldBeTrue(); |
|
|
|
(await _appUrlProvider.IsRedirectAllowedUrlAsync($"https://{Guid.NewGuid()}.abp.io")).ShouldBeFalse(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|