Exemple #1
0
 public BlobBatchClientTests(bool async, BlobClientOptions.ServiceVersion serviceVersion)
     : base(async, serviceVersion, null /* RecordedTestMode.Record /* to re-record */)
 {
     // Batch delimiters are random so disable body comparison
     Matcher   = new RecordMatcher(compareBodies: false);
     Sanitizer = new BatchStorageRecordedTestSanitizer();
 }
Exemple #2
0
 public BlobBaseClientTransactionalHashingTests(
     bool async,
     BlobClientOptions.ServiceVersion serviceVersion,
     RecordedTestMode?mode = null)
     : base(async, _blobResourcePrefix, mode)
 {
     ClientBuilder = ClientBuilderExtensions.GetNewBlobsClientBuilder(Tenants, serviceVersion);
 }
 public static string ToSasVersion(BlobClientOptions.ServiceVersion serviceVersion)
 {
     return(serviceVersion switch
     {
         BlobClientOptions.ServiceVersion.V2019_02_02 => "2019-02-02",
         BlobClientOptions.ServiceVersion.V2019_07_07 => "2019-07-07",
         BlobClientOptions.ServiceVersion.V2019_12_12 => "2019-12-12",
         _ => throw new ArgumentException("Invalid service version"),
     });
Exemple #4
0
 public BlobBaseClientOpenWriteTests(
     bool async,
     BlobClientOptions.ServiceVersion serviceVersion,
     RecordedTestMode?mode = null)
     : base(async, _blobResourcePrefix, mode)
 {
     ClientBuilder  = ClientBuilderExtensions.GetNewBlobsClientBuilder(Tenants, serviceVersion);
     BlobConditions = new BlobAccessConditionConfigs(this);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="BlobClient"/>
 /// class.
 /// </summary>
 /// <param name="blobUri">
 /// A <see cref="Uri"/> referencing the blob that includes the
 /// name of the account, the name of the container, and the name of
 /// the blob.
 /// This is likely to be similar to "https://{account_name}.blob.core.windows.net/{container_name}/{blob_name}".
 /// </param>
 /// <param name="pipeline">
 /// The transport pipeline used to send every request.
 /// </param>
 /// <param name="version">
 /// The version of the service to use when sending requests.
 /// </param>
 /// <param name="clientDiagnostics">Client diagnostics.</param>
 /// <param name="customerProvidedKey">Customer provided key.</param>
 /// <param name="encryptionScope">Encryption scope.</param>
 internal BlobClient(
     Uri blobUri,
     HttpPipeline pipeline,
     BlobClientOptions.ServiceVersion version,
     ClientDiagnostics clientDiagnostics,
     CustomerProvidedKey?customerProvidedKey,
     string encryptionScope)
     : base(blobUri, pipeline, version, clientDiagnostics, customerProvidedKey, encryptionScope)
 {
 }
 public BlobClientOpenWriteTests(bool async, BlobClientOptions.ServiceVersion serviceVersion)
     : base(async, serviceVersion, null /* RecordedTestMode.Record /* to re-record */)
 {
     // Validate every test didn't accidentally use client-side encryption when writing a blob.
     AdditionalAssertions += async(client) =>
     {
         IDictionary <string, string> metadata = (await client.GetPropertiesAsync()).Value.Metadata;
         Assert.IsFalse(metadata.ContainsKey(Constants.ClientSideEncryption.EncryptionDataKey));
     };
 }
 public BlobClientConfiguration(
     HttpPipeline pipeline,
     StorageSharedKeyCredential sharedKeyCredential,
     ClientDiagnostics clientDiagnostics,
     BlobClientOptions.ServiceVersion version,
     CustomerProvidedKey?customerProvidedKey,
     string encryptionScope)
     : base(pipeline, sharedKeyCredential, clientDiagnostics)
 {
     Version             = version;
     CustomerProvidedKey = customerProvidedKey;
     EncryptionScope     = encryptionScope;
 }
Exemple #8
0
        private static string ToSasVersion(BlobClientOptions.ServiceVersion serviceVersion)
        {
            switch (serviceVersion)
            {
            case BlobClientOptions.ServiceVersion.V2019_02_02:
                return("2019-02-02");

            case BlobClientOptions.ServiceVersion.V2019_07_07:
                return("2019-07-07");

            default:
                throw new ArgumentException("Invalid service version");
            }
        }
 public static BlobServiceClient Create(
     Uri uri,
     HttpPipeline pipeline,
     HttpPipelinePolicy authentication,
     BlobClientOptions.ServiceVersion version,
     ClientDiagnostics diagnostics)
 {
     return(BlobServiceClient.CreateClient(
                uri,
                new BlobClientOptions(version)
     {
         Diagnostics = { IsDistributedTracingEnabled = diagnostics.IsActivityEnabled }
     },
                authentication,
                pipeline));
 }
Exemple #10
0
        /// <summary>
        /// Initializes a new instance of the <see cref="BlobBatchClient"/>
        /// class for the same account as the <see cref="BlobServiceClient"/>.
        /// The new <see cref="BlobBatchClient"/> uses the same request policy
        /// pipeline as the <see cref="BlobServiceClient"/>.
        /// </summary>
        /// <param name="client">The <see cref="BlobServiceClient"/>.</param>
        public BlobBatchClient(BlobServiceClient client)
        {
            _uri      = client.Uri;
            _pipeline = BlobServiceClientInternals.GetHttpPipeline(client);
            BlobClientOptions options = BlobServiceClientInternals.GetClientOptions(client);

            _version           = options.Version;
            _clientDiagnostics = new StorageClientDiagnostics(options);

            // Construct a dummy pipeline for processing batch sub-operations
            // if we don't have one cached on the service
            _batchOperationPipeline = CreateBatchPipeline(
                _pipeline,
                BlobServiceClientInternals.GetAuthenticationPolicy(client),
                _version);

            (ServiceRestClient serviceRestClient, ContainerRestClient containerRestClient) = BuildRestClients(_uri);
            _serviceRestClient   = serviceRestClient;
            _containerRestClient = containerRestClient;

            _isContainerScoped = false;
        }
Exemple #11
0
        /// <summary>
        /// Creates a pipeline to use for processing sub-operations before they
        /// are combined into a single multipart request.
        /// </summary>
        /// <param name="pipeline">
        /// The pipeline used to submit the live request.
        /// </param>
        /// <param name="authenticationPolicy">
        /// An optional <see cref="HttpPipelinePolicy"/> used to authenticate
        /// the sub-operations.
        /// </param>
        /// <param name="serviceVersion">
        /// The serviceVersion used when generating sub-requests.
        /// </param>
        /// <returns>A pipeline to use for processing sub-operations.</returns>
        private static HttpPipeline CreateBatchPipeline(
            HttpPipeline pipeline,
            HttpPipelinePolicy authenticationPolicy,
            BlobClientOptions.ServiceVersion serviceVersion)
        {
            // Configure the options to use minimal policies
            var options = new BlobClientOptions(serviceVersion);

            options.Diagnostics.IsLoggingEnabled            = false;
            options.Diagnostics.IsTelemetryEnabled          = false;
            options.Diagnostics.IsDistributedTracingEnabled = false;
            options.Retry.MaxRetries = 0;

            // Use an empty transport so requests aren't sent
            options.Transport = new BatchPipelineTransport(pipeline);

            // Use the same authentication mechanism
            return(HttpPipelineBuilder.Build(
                       options,
                       RemoveVersionHeaderPolicy.Shared,
                       authenticationPolicy));
        }
 public ChangeFeedTestBase(bool async, BlobClientOptions.ServiceVersion serviceVersion, RecordedTestMode?mode = null)
     : base(async, mode)
 {
     _serviceVersion = serviceVersion;
 }
 public CommonTestBase(bool async, BlobClientOptions.ServiceVersion serviceVersion, RecordedTestMode?mode = null)
     : base(async, mode /* RecordedTestMode.Record to re-record */)
 {
     _serviceVersion = serviceVersion;
 }
Exemple #14
0
 public AppendBlobClientOpenWriteTests(bool async, BlobClientOptions.ServiceVersion serviceVersion)
     : base(async, serviceVersion, null /* RecordedTestMode.Record /* to re-record */)
 {
 }
Exemple #15
0
 public ProgressHandlingTests(bool async, BlobClientOptions.ServiceVersion serviceVersion)
     : base(async, serviceVersion, null /* RecordedTestMode.Record /* to re-record */)
 {
 }
Exemple #16
0
 public LazyLoadingBlobStreamTests(bool async, BlobClientOptions.ServiceVersion serviceVersion)
     : base(async, serviceVersion, null /* RecordedTestMode.Record /* to re-record */)
 {
 }
 public StorageSharedKeyCredentialsTests(bool async, BlobClientOptions.ServiceVersion serviceVersion)
     : base(async, serviceVersion, null /* RecordedTestMode.Record to re-record */)
 {
 }
Exemple #18
0
 public BlobChangeFeedExtensionsTests(bool async, BlobClientOptions.ServiceVersion serviceVersion)
     : base(async, serviceVersion, null /* RecordedTestMode.Record /* to re-record */)
 {
 }
Exemple #19
0
 public ImmutableStorageWithVersioningTests(bool async, BlobClientOptions.ServiceVersion serviceVersion)
     : base(async, serviceVersion, null /* RecordedTestMode.Record /* to re-record */)
 {
 }
Exemple #20
0
 public ManagedDiskTests(bool async, BlobClientOptions.ServiceVersion serviceVersion)
     : base(async, serviceVersion, null /* RecordedTestMode.Record /* to re-record */)
 {
 }
Exemple #21
0
 public BlobTestBase(bool async, BlobClientOptions.ServiceVersion serviceVersion, RecordedTestMode?mode = null)
     : base(async, mode)
 {
     _serviceVersion    = serviceVersion;
     BlobsClientBuilder = ClientBuilderExtensions.GetNewBlobsClientBuilder(Tenants, _serviceVersion);
 }
 public EncryptedBlockBlobClientTests(bool async, BlobClientOptions.ServiceVersion serviceVersion)
     : base(async, serviceVersion, null /* RecordedTestMode.Record /* to re-record */)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="AppendBlobClient"/>
 /// class.
 /// </summary>
 /// <param name="blobUri">
 /// A <see cref="Uri"/> referencing the append blob that includes the
 /// name of the account, the name of the container, and the name of
 /// the blob.
 /// This is likely to be similar to "https://{account_name}.blob.core.windows.net/{container_name}/{blob_name}".
 /// </param>
 /// <param name="pipeline">
 /// The transport pipeline used to send every request.
 /// </param>
 /// <param name="version">
 /// The version of the service to use when sending requests.
 /// </param>
 /// <param name="clientDiagnostics">Client diagnostics.</param>
 /// <param name="customerProvidedKey">Customer provided key.</param>
 internal AppendBlobClient(Uri blobUri, HttpPipeline pipeline, BlobClientOptions.ServiceVersion version, ClientDiagnostics clientDiagnostics, CustomerProvidedKey?customerProvidedKey)
     : base(blobUri, pipeline, version, clientDiagnostics, customerProvidedKey)
 {
 }
Exemple #24
0
 public TenantDiscoveryBlobBaseClientTests(bool async, BlobClientOptions.ServiceVersion serviceVersion)
     : base(async, serviceVersion)
 {
 }
 /// <summary>
 /// For derived classes to mimic <see cref="BlobClientOpenWriteTests(bool, BlobClientOptions.ServiceVersion)"/>
 /// and have a place to pass a <see cref="RecordedTestMode"/> through.
 /// </summary>
 /// <param name="async"></param>
 /// <param name="serviceVersion"></param>
 protected BlobClientOpenWriteTests(bool async, BlobClientOptions.ServiceVersion serviceVersion, RecordedTestMode?mode)
     : base(async, serviceVersion, mode)
 {
 }
Exemple #26
0
 public AppendBlobClientTransactionalHashingTests(bool async, BlobClientOptions.ServiceVersion serviceVersion)
     : base(async, serviceVersion, null /* RecordedTestMode.Record /* to re-record */)
 {
 }
 public BlobQuickQueryTests(bool async, BlobClientOptions.ServiceVersion serviceVersion)
     : base(async, serviceVersion, null /* RecordedTestMode.Record /* to re-record */)
 {
 }
 /// <summary>
 /// Creates a new <see cref="ClientBuilder{TServiceClient, TServiceClientOptions}"/>
 /// setup to generate <see cref="BlobServiceClient"/>s.
 /// </summary>
 /// <param name="tenants"><see cref="TenantConfigurationBuilder"/> powering this client builder.</param>
 /// <param name="serviceVersion">Service version for clients to target.</param>
 public static BlobsClientBuilder GetNewBlobsClientBuilder(TenantConfigurationBuilder tenants, BlobClientOptions.ServiceVersion serviceVersion)
 => new BlobsClientBuilder(
     ServiceEndpoint.Blob,
     tenants,
     (uri, clientOptions) => new BlobServiceClient(uri, clientOptions),
     (uri, sharedKeyCredential, clientOptions) => new BlobServiceClient(uri, sharedKeyCredential, clientOptions),
     (uri, tokenCredential, clientOptions) => new BlobServiceClient(uri, tokenCredential, clientOptions),
     (uri, azureSasCredential, clientOptions) => new BlobServiceClient(uri, azureSasCredential, clientOptions),
     () => new BlobClientOptions(serviceVersion));