|
|
|
@ -1,5 +1,7 @@
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using Microsoft.Extensions.Options;
|
|
|
|
|
using Microsoft.Net.Http.Headers;
|
|
|
|
|
using Shouldly;
|
|
|
|
|
using Volo.Abp.AspNetCore.App;
|
|
|
|
@ -9,6 +11,13 @@ namespace Volo.Abp.AspNetCore.MultiTenancy
|
|
|
|
|
{
|
|
|
|
|
public class AspNetCoreMultiTenancy_Tests : AppTestBase
|
|
|
|
|
{
|
|
|
|
|
private readonly AspNetCoreMultiTenancyOptions _options;
|
|
|
|
|
|
|
|
|
|
public AspNetCoreMultiTenancy_Tests()
|
|
|
|
|
{
|
|
|
|
|
_options = ServiceProvider.GetRequiredService<IOptions<AspNetCoreMultiTenancyOptions>>().Value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public async Task Should_Use_Host_If_Tenant_Is_Not_Specified()
|
|
|
|
|
{
|
|
|
|
@ -21,7 +30,7 @@ namespace Volo.Abp.AspNetCore.MultiTenancy
|
|
|
|
|
{
|
|
|
|
|
const string testTenantId = "42";
|
|
|
|
|
|
|
|
|
|
var result = await GetResponseAsObjectAsync<Dictionary<string, string>>($"http://abp.io?{AbpAspNetCoreMultiTenancyConsts.TenantIdKey}={testTenantId}");
|
|
|
|
|
var result = await GetResponseAsObjectAsync<Dictionary<string, string>>($"http://abp.io?{_options.TenantIdKey}={testTenantId}");
|
|
|
|
|
result["TenantId"].ShouldBe(testTenantId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -30,7 +39,7 @@ namespace Volo.Abp.AspNetCore.MultiTenancy
|
|
|
|
|
{
|
|
|
|
|
const string testTenantId = "42";
|
|
|
|
|
|
|
|
|
|
Client.DefaultRequestHeaders.Add(AbpAspNetCoreMultiTenancyConsts.TenantIdKey, testTenantId);
|
|
|
|
|
Client.DefaultRequestHeaders.Add(_options.TenantIdKey, testTenantId);
|
|
|
|
|
|
|
|
|
|
var result = await GetResponseAsObjectAsync<Dictionary<string, string>>("http://abp.io");
|
|
|
|
|
result["TenantId"].ShouldBe(testTenantId);
|
|
|
|
@ -41,7 +50,7 @@ namespace Volo.Abp.AspNetCore.MultiTenancy
|
|
|
|
|
{
|
|
|
|
|
const string testTenantId = "42";
|
|
|
|
|
|
|
|
|
|
Client.DefaultRequestHeaders.Add("Cookie", new CookieHeaderValue(AbpAspNetCoreMultiTenancyConsts.TenantIdKey, testTenantId).ToString());
|
|
|
|
|
Client.DefaultRequestHeaders.Add("Cookie", new CookieHeaderValue(_options.TenantIdKey, testTenantId).ToString());
|
|
|
|
|
|
|
|
|
|
var result = await GetResponseAsObjectAsync<Dictionary<string, string>>("http://abp.io");
|
|
|
|
|
result["TenantId"].ShouldBe(testTenantId);
|
|
|
|
|