예제 #1
0
        public ClaimsBenchmarksBase()
        {
            IConfigurationBuilder configurationBuilder = new ConfigurationBuilder()
                                                         .AddEnvironmentVariables()
                                                         .AddJsonFile("local.settings.json", optional: true, reloadOnChange: true);

            IConfiguration configuration = configurationBuilder.Build();

            this.ClientTenantId = configuration["ClientTenantId"];
            this.AdministratorPrincipalObjectId = configuration["AdministratorPrincipalObjectId"];

            ServiceProvider serviceProvider = new ServiceCollection()
                                              .AddClaimsClient(sp => configuration.GetSection("ClaimsClient").Get <ClaimsClientOptions>())
                                              .AddSingleton(sp => configuration.GetSection("TenancyClient").Get <TenancyClientOptions>())
                                              .AddTenancyClient(enableResponseCaching: true)
                                              .AddJsonNetPropertyBag()
                                              .AddBlobContainerV2ToV3Transition()
                                              .AddAzureBlobStorageClientSourceFromDynamicConfiguration()
                                              .AddServiceIdentityAzureTokenCredentialSourceFromLegacyConnectionString(configuration["AzureServicesAuthConnectionString"])
                                              .AddMicrosoftRestAdapterForServiceIdentityAccessTokenSource()
                                              .BuildServiceProvider();

            this.ClaimsService  = serviceProvider.GetRequiredService <IClaimsService>();
            this.TenancyService = serviceProvider.GetRequiredService <ITenancyService>();
            this.TenantBlobContainerClientFactory = serviceProvider.GetRequiredService <IBlobContainerSourceWithTenantLegacyTransition>();
            this.PropertyBagFactory = serviceProvider.GetRequiredService <IPropertyBagFactory>();
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="OperationsRepository"/> class.
 /// </summary>
 /// <param name="containerFactory">The blob container factory to use to get the container in which operations should be stored.</param>
 /// <param name="serializerSettingsProvider">The serializer settings factory.</param>
 public OperationsRepository(
     IBlobContainerSourceWithTenantLegacyTransition containerFactory,
     IJsonSerializerSettingsProvider serializerSettingsProvider)
 {
     this.containerSource    = containerFactory;
     this.serializerSettings = serializerSettingsProvider.Instance;
 }
 /// <summary>
 ///     Initializes a new instance of the <see cref="BlobContainerPermissionsStoreFactory"/> class.
 /// </summary>
 /// <param name="tenantBlobContainerSource">
 ///     The repository factory.
 /// </param>
 /// <param name="serializerSettingsProvider">
 ///     The <see cref="IJsonSerializerSettingsProvider"/> to use for the stores.
 /// </param>
 public BlobContainerPermissionsStoreFactory(
     IBlobContainerSourceWithTenantLegacyTransition tenantBlobContainerSource,
     IJsonSerializerSettingsProvider serializerSettingsProvider)
 {
     this.tenantBlobContainerSource  = tenantBlobContainerSource ?? throw new System.ArgumentNullException(nameof(tenantBlobContainerSource));
     this.serializerSettingsProvider = serializerSettingsProvider ?? throw new System.ArgumentNullException(nameof(serializerSettingsProvider));
 }
예제 #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TenantedBlobWorkflowStoreFactory"/> class.
 /// </summary>
 /// <param name="containerFactory">
 /// The <see cref="IBlobContainerSourceWithTenantLegacyTransition"/> that will be used to
 /// create underlying <see cref="BlobContainerClient"/> instances for the content stores.</param>
 /// <param name="v2ConfigurationKey">
 /// The tenant properties configuration key in which to find V2-style settings.
 /// </param>
 /// <param name="v3ConfigurationKey">
 /// The tenant properties configuration key in which to find V3-style settings.
 /// </param>
 /// <param name="serializerSettingsProvider">The current <see cref="IJsonSerializerSettingsProvider"/>.</param>
 public TenantedBlobWorkflowStoreFactory(
     IBlobContainerSourceWithTenantLegacyTransition containerFactory,
     string v2ConfigurationKey,
     string v3ConfigurationKey,
     IJsonSerializerSettingsProvider serializerSettingsProvider)
 {
     this.containerFactory = containerFactory
                             ?? throw new ArgumentNullException(nameof(containerFactory));
     this.v2ConfigurationKey = v2ConfigurationKey
                               ?? throw new ArgumentNullException(nameof(v2ConfigurationKey));
     this.v3ConfigurationKey         = v3ConfigurationKey;
     this.serializerSettingsProvider = serializerSettingsProvider
                                       ?? throw new ArgumentNullException(nameof(serializerSettingsProvider));
 }
        public static async Task TearDownTenants(FeatureContext featureContext)
        {
            var tenantManager = TransientTenantManager.GetInstance(featureContext);

            await featureContext.RunAndStoreExceptionsAsync(async() =>
            {
                IBlobContainerSourceWithTenantLegacyTransition cloudBlobContainerFactory = ContainerBindings.GetServiceProvider(featureContext).GetRequiredService <IBlobContainerSourceWithTenantLegacyTransition>();
                BlobContainerClient testContainer = await cloudBlobContainerFactory.GetBlobContainerClientFromTenantAsync(
                    tenantManager.PrimaryTransientClient,
                    OperationsRepository.OperationsV2ConfigKey,
                    OperationsRepository.OperationsV3ConfigKey).ConfigureAwait(false);
                await testContainer.DeleteIfExistsAsync().ConfigureAwait(false);
            }).ConfigureAwait(false);

            await featureContext.RunAndStoreExceptionsAsync(() => tenantManager.CleanupAsync()).ConfigureAwait(false);
        }
        /// <summary>
        /// Creates a <see cref="AzureBlobStorageTenantStore"/>.
        /// </summary>
        /// <param name="configuration">Configuration settings.</param>
        /// <param name="containerSource">Provides access to tenanted blob storage.</param>
        /// <param name="serializerSettingsProvider">Settings for tenant serialization.</param>
        /// <param name="propertyBagFactory">Property bag services.</param>
        public AzureBlobStorageTenantStore(
            AzureBlobStorageTenantStoreConfiguration configuration,
            IBlobContainerSourceWithTenantLegacyTransition containerSource,
            IJsonSerializerSettingsProvider serializerSettingsProvider,
            IPropertyBagFactory propertyBagFactory)
        {
            this.containerSource                = containerSource;
            this.propertyBagFactory             = propertyBagFactory;
            this.jsonSerializer                 = JsonSerializer.Create(serializerSettingsProvider.Instance);
            this.propagateRootStorageConfigAsV2 = configuration.PropagateRootTenancyStorageConfigAsV2;

            // The root tenant is necessarily synthetic because we can't get access to storage
            // without it. And regardless of what stage of v2 to v3 transition we're in with
            // the store, we always configure the root tenant in v3 mode.
            this.Root = new RootTenant(propertyBagFactory);
            this.Root.UpdateProperties(values =>
                                       values.Append(new KeyValuePair <string, object>(
                                                         TenancyV3ConfigKey,
                                                         configuration.RootStorageConfiguration)));
        }
예제 #7
0
        public static void SetupBlobStorageRepository(FeatureContext featureContext)
        {
            IServiceProvider serviceProvider = ContainerBindings.GetServiceProvider(featureContext);
            IBlobContainerSourceWithTenantLegacyTransition factory = serviceProvider.GetRequiredService <IBlobContainerSourceWithTenantLegacyTransition>();
            ITenantProvider tenantProvider = serviceProvider.GetRequiredService <ITenantProvider>();
            IConfiguration  configuration  = serviceProvider.GetRequiredService <IConfiguration>();

            ITenant rootTenant = tenantProvider.Root;

            LegacyV2BlobStorageConfiguration storageConfig =
                configuration.GetSection("TestStorageConfiguration").Get <LegacyV2BlobStorageConfiguration>()
                ?? new LegacyV2BlobStorageConfiguration();

            // Generate a container name just for this test, otherwise you can end up with collisions
            // on subsequent tests runs while containers are still being deleted.
            storageConfig.Container = Guid.NewGuid().ToString();

            tenantProvider.Root.UpdateProperties(data => data.Append(new KeyValuePair <string, object>(
                                                                         "StorageConfiguration__workflowdefinitions",
                                                                         storageConfig)));
        }