Browse Source
Address Copilot review: fix nullability and add whitespace tests
pull/25212/head
maliming
6 months ago
No known key found for this signature in database
GPG Key ID: A646B9CB645ECEA4
2 changed files with
17 additions and
1 deletions
-
framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/QueryStringTenantResolveContributor.cs
-
framework/test/Volo.Abp.AspNetCore.MultiTenancy.Tests/Volo/Abp/AspNetCore/MultiTenancy/AspNetCoreMultiTenancy_Without_DomainResolver_Tests.cs
|
|
|
@ -21,7 +21,7 @@ public class QueryStringTenantResolveContributor : HttpTenantResolveContributorB |
|
|
|
var tenantValue = httpContext.Request.Query[tenantKey].ToString(); |
|
|
|
if (!tenantValue.IsNullOrWhiteSpace()) |
|
|
|
{ |
|
|
|
return Task.FromResult(tenantValue)!; |
|
|
|
return Task.FromResult<string?>(tenantValue); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -86,4 +86,20 @@ public class AspNetCoreMultiTenancy_Without_DomainResolver_Tests : AspNetCoreMul |
|
|
|
var result = await GetResponseAsObjectAsync<Dictionary<string, string>>($"http://abp.io?{_options.TenantKey}="); |
|
|
|
result["TenantId"].ShouldBe(""); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public async Task Should_Use_Header_Tenant_Id_When_QueryString_Tenant_Is_Whitespace() |
|
|
|
{ |
|
|
|
Client.DefaultRequestHeaders.Add(_options.TenantKey, _testTenantId.ToString()); |
|
|
|
|
|
|
|
var result = await GetResponseAsObjectAsync<Dictionary<string, string>>($"http://abp.io?{_options.TenantKey}=%20"); |
|
|
|
result["TenantId"].ShouldBe(_testTenantId.ToString()); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public async Task Should_Fallback_To_Host_When_QueryString_Tenant_Is_Whitespace_And_No_Other_Resolver() |
|
|
|
{ |
|
|
|
var result = await GetResponseAsObjectAsync<Dictionary<string, string>>($"http://abp.io?{_options.TenantKey}=%20"); |
|
|
|
result["TenantId"].ShouldBe(""); |
|
|
|
} |
|
|
|
} |
|
|
|
|