public void BlobServiceOptionsValidate_BlobSizeLimitCantBeLessThanZero_ShouldThrow()
        {
            var options = new BlobServiceOptions();

            options.MaxBlobSizeInMB = -1;
            Assert.Throws <InvalidOperationException>(() => options.TryValidate());
        }
        public void BlobServiceOptionsValidate_ShouldSuccess()
        {
            var options = new BlobServiceOptions();

            options.CorsPolicyName = "TestPolicy";
            options.TryValidate();
            Assert.True(true);
        }
Esempio n. 3
0
        public void ConfigureServices(IServiceCollection services)
        {
            var options = new BlobServiceOptions();

            Configuration.Bind("Storage", options);

            services
            .AddSingleton <IFileSystem, FileSystem>()
            .AddBlobServiceClient(options)
            .AddControllers();
        }
Esempio n. 4
0
 public SASController(
     BlobServiceOptions options,
     ILoggerFactory loggerFactory,
     ISASStore sasStore,
     IContainerStore containerStore,
     IBlobStore blobStore)
 {
     _options        = options ?? throw new ArgumentNullException(nameof(options));
     _logger         = loggerFactory?.CreateLogger <ContainersController>() ?? throw new ArgumentNullException(nameof(loggerFactory));
     _sasStore       = sasStore ?? throw new ArgumentNullException(nameof(sasStore));
     _containerStore = containerStore ?? throw new ArgumentNullException(nameof(containerStore));
     _blobStore      = blobStore ?? throw new ArgumentNullException(nameof(blobStore));
 }
Esempio n. 5
0
 public BlobMetaDataController(
     BlobServiceOptions options,
     ILoggerFactory loggerFactory,
     IStorageService storageService,
     IBlobStore blobStore,
     IBlobMetaDataStore blobMetaDataStore,
     IContainerStore containerStore)
 {
     _options           = options ?? throw new ArgumentNullException(nameof(options));
     _logger            = loggerFactory?.CreateLogger <BlobsController>() ?? throw new ArgumentNullException(nameof(loggerFactory));
     _storageService    = storageService ?? throw new ArgumentNullException(nameof(storageService));
     _blobStore         = blobStore ?? throw new ArgumentNullException(nameof(blobStore));
     _blobMetaDataStore = blobMetaDataStore ?? throw new ArgumentNullException(nameof(blobMetaDataStore));
     _containerStore    = containerStore ?? throw new ArgumentNullException(nameof(containerStore));
 }
Esempio n. 6
0
        public static IBlobServiceBuilder AddBlobService(this IServiceCollection services, Action <BlobServiceOptions> setupAction = null)
        {
            var blobServiceOptions = new BlobServiceOptions();

            setupAction?.Invoke(blobServiceOptions);

            blobServiceOptions.TryValidate();

            services.AddMvc(options =>
            {
                options.Filters.Add(new CorsAuthorizationFilterFactory(blobServiceOptions.CorsPolicyName));
            });

            services.AddSingleton(typeof(BlobServiceOptions), blobServiceOptions);

            var builder = new BlobServiceBuilder(services);

            return(builder);
        }
Esempio n. 7
0
        public static IServiceCollection AddBlobServiceClient(this IServiceCollection services, BlobServiceOptions options)
        {
            services.AddSingleton <IStorage>(provider =>
            {
                var blobContainerClient = new BlobContainerClient(options.ConnectionString, options.Container);
                var fileSystem          = provider.GetService <IFileSystem>();
                var logger    = provider.GetService <ILogger <StorageLoggerDecorator> >();
                var decorated = new AzureBlobService(blobContainerClient, fileSystem);

                return(new StorageLoggerDecorator(logger, decorated));
            });

            return(services);
        }
        public void BlobServiceOptions_DefaultMaxBlobSize_ShouldBeDefaultBlobSizeLimitInMB()
        {
            var options = new BlobServiceOptions();

            Assert.True(options.MaxBlobSizeInMB == Constants.DefaultBlobSizeLimitInMB);
        }
        public void BlobServiceOptionsValidate_CORSPolicyNameCantBeNullOrEmpty_ShouldThrow()
        {
            var options = new BlobServiceOptions();

            Assert.Throws <InvalidOperationException>(() => options.TryValidate());
        }