< Summary

Information
Class: Elsa.Tenants.AspNetCore.HeaderTenantResolver
Assembly: Elsa.Tenants.AspNetCore
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Tenants.AspNetCore/Resolvers/HeaderTenantResolver.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 7
Coverable lines: 7
Total lines: 25
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 2
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%210%
Resolve(...)0%620%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Tenants.AspNetCore/Resolvers/HeaderTenantResolver.cs

#LineLine coverage
 1using Elsa.Common.Multitenancy;
 2using Elsa.Tenants.AspNetCore.Options;
 3using Microsoft.AspNetCore.Http;
 4using Microsoft.Extensions.Options;
 5
 6namespace Elsa.Tenants.AspNetCore;
 7
 8/// <summary>
 9/// Resolves the tenant based on the header in the request.
 10/// </summary>
 011public class HeaderTenantResolver(IHttpContextAccessor httpContextAccessor, IOptions<MultitenancyHttpOptions> options) :
 12{
 13    protected override TenantResolverResult Resolve(TenantResolverContext context)
 14    {
 015        var httpContext = httpContextAccessor.HttpContext;
 16
 017        if (httpContext == null)
 018            return Unresolved();
 19
 020        var headerName = options.Value.TenantHeaderName;
 021        var tenantId = httpContext.Request.Headers[headerName].FirstOrDefault();
 22
 023        return AutoResolve(tenantId);
 24    }
 25}