public void ThrowIfNullParamAddingHostStrategy() { var services = new ServiceCollection(); var builder = new FinbuckleMultiTenantBuilder(services); Assert.Throws <ArgumentException>(() => builder.WithHostStrategy(null)); }
public void AddHostStrategy() { var services = new ServiceCollection(); var builder = new FinbuckleMultiTenantBuilder(services); builder.WithHostStrategy(); var sp = services.BuildServiceProvider(); var strategy = sp.GetRequiredService <IMultiTenantStrategy>(); Assert.IsType <MultiTenantStrategyWrapper <HostStrategy> >(strategy); }
private static FinbuckleMultiTenantBuilder <TenantInfo> WithMultiTenantStrategy(this FinbuckleMultiTenantBuilder <TenantInfo> builder) { // Build the intermediate service provider var defaultTenantConfig = _configuration.GetSection("DefaultTenant"); return(builder // A template pattern can be specified with the overloaded version. The default pattern is "__tenant__.*" // For example, a request to "https://contoso.example.com/abc123" would use "contoso" as the identifier when resolving the tenant. .WithHostStrategy() // For example, a request to "https://www.example.com/contoso" would use "contoso" as the identifier when resolving the tenant. .WithBasePathStrategy() // For example, a request to "https://www.example.com/contoso/home/" and a route configuration of {__tenant__}/{controller=Home}/{action=Index} would use "contoso" as the identifier when resolving the tenant. .WithRouteStrategy() // If the called with e.g. "not_a_tenant.mysite.com" and the identifer "not_a_tenant" // is not in the store, then the identifier of "DefaultTenant" will be used as a fallback. // Make sure to include a multitenant store ! .WithStaticStrategy(defaultTenantConfig.GetValue <string>("Identifier"))); // .WithRemoteAuthentication() for per-tenant remote authentication }