Пример #1
0
 public static string GetLogFileNameTemplate(TenantIdentifier tenantIdentifier)
 {
     if (tenantIdentifier == null)
     {
         throw new ArgumentNullException(nameof(tenantIdentifier));
     }
     return(Path.Combine(HostingEnvironment.MapPath("/Logs"), $"perf-test-{tenantIdentifier.Name}-.log"));
 }
Пример #2
0
        public void Init()
        {
            _mockFeatureSettingsProvider = new Mock <IFeatureSettingsProvider>();
            var tenantIdentifier = new TenantIdentifier(1, string.Empty);

            _featureManager = new FeatureManager(tenantIdentifier, _mockFeatureSettingsProvider.Object);
            _featureManager.ClearCache();
        }
Пример #3
0
        public FeatureManager(TenantIdentifier tenant, IFeatureSettingsProvider dataProvider)
        {
            if (tenant is null)
            {
                throw new ArgumentNullException(nameof(tenant));
            }

            if (dataProvider is null)
            {
                throw new ArgumentNullException(nameof(dataProvider));
            }

            _factory = new Lazy <FeatureFlagCollection>(() =>
                                                        Cache.GetOrAdd(tenant.Id, (tenantId) => InitializeFeatures(dataProvider.GetForTenant(tenantId))));
        }
        public Task <TenantShell <Tenant> > Get(TenantIdentifier distinguisher)
        {
            if (distinguisher.Uri.Port == 5004)
            {
                Guid tenantId = Guid.Parse("b17fcd22-0db1-47c0-9fef-1aa1cb09605e");
                var  tenant   = new Tenant(tenantId)
                {
                    Name = "Foo"
                };
                var result = new TenantShell <Tenant>(tenant);
                return(Task.FromResult(result));
            }

            if (distinguisher.Uri.Port == 5000 || distinguisher.Uri.Port == 5001)
            {
                Guid tenantId = Guid.Parse("049c8cc4-3660-41c7-92f0-85430452be22");
                var  tenant   = new Tenant(tenantId)
                {
                    Name = "Bar"
                };
                var result = new TenantShell <Tenant>(tenant, new Uri("http://localhost:5000"), new Uri("http://localhost:5001")); // additional distinguishers to map this same tenant shell instance too.
                return(Task.FromResult(result));
            }

            // for an unknown tenant, we can either create the tenant shell as a NULL tenant by returning a TenantShell<TTenant>(null),
            // which results in the TenantShell being created, and will explicitly have to be reloaded() in order for this method to be called again.
            if (distinguisher.Uri.Port == 5002)
            {
                var result = new TenantShell <Tenant>(null);
                return(Task.FromResult(result));
            }

            if (distinguisher.Uri.Port == 5003)
            {
                // or we can return null - which means we wil keep attempting to resolve the tenant on every subsequent request until a result is returned in future.
                // (i.e allows tenant to be created in backend in a few moments time).
                return(Task.FromResult <TenantShell <Tenant> >(null));;
            }

            throw new NotImplementedException("Please make request on ports 5000 - 5003 to see various behaviour. Can also use 63291 when launching under IISExpress");
        }
Пример #5
0
        public Task <TenantShell <Tenant> > Get(TenantIdentifier distinguisher)
        {
            if (distinguisher.Uri.Port == 5000 || distinguisher.Uri.Port == 5001)
            {
                Guid tenantId = Guid.Parse("049c8cc4-3660-41c7-92f0-85430452be22");
                var  tenant   = new Tenant(tenantId, "Moogle");
                // Also adding any additional Uri's that should be mapped to this same tenant.
                var result = new TenantShell <Tenant>(tenant, new Uri("http://localhost:5000"),
                                                      new Uri("http://localhost:5001"));
                return(Task.FromResult(result));
            }

            if (distinguisher.Uri.Port == 5002)
            {
                Guid tenantId = Guid.Parse("b17fcd22-0db1-47c0-9fef-1aa1cb09605e");
                var  tenant   = new Tenant(tenantId, "Gicrosoft");
                var  result   = new TenantShell <Tenant>(tenant);
                return(Task.FromResult(result));
            }


            throw new NotImplementedException("Please make request on ports 5000 - 5003 to see various behaviour.");
        }
Пример #6
0
 public string AuthenticationUrl(TenantIdentifier tenant)
 {
     return($"{authBaseUrl}/{tenant.TenantId}");
 }
Пример #7
0
 public string OrganizationQueryUrl(TenantIdentifier tenant)
 {
     return("https://graph.microsoft.com/v1.0/{tenant.TenantId}/organization/");
 }