Skip to content

Commit

Permalink
undo http change; clean up tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshLove-msft committed Dec 3, 2019
1 parent 076f31b commit 55a0fe8
Show file tree
Hide file tree
Showing 60 changed files with 68 additions and 839 deletions.
3 changes: 0 additions & 3 deletions sdk/storage/Azure.Storage.Blobs/src/BlobBaseClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,6 @@ public BlobBaseClient(string connectionString, string blobContainerName, string
_clientDiagnostics = new ClientDiagnostics(options);
_customerProvidedKey = options.CustomerProvidedKey;
BlobErrors.VerifyHttpsCustomerProvidedKey(_uri, _customerProvidedKey);
Errors.VerifyHttpSas(_uri, builder.Sas);
}

/// <summary>
Expand Down Expand Up @@ -280,7 +279,6 @@ internal BlobBaseClient(Uri blobUri, HttpPipelinePolicy authentication, BlobClie
_clientDiagnostics = new ClientDiagnostics(options);
_customerProvidedKey = options.CustomerProvidedKey;
BlobErrors.VerifyHttpsCustomerProvidedKey(_uri, _customerProvidedKey);
Errors.VerifyHttpSas(_uri, new BlobUriBuilder(_uri).Sas);
}

/// <summary>
Expand All @@ -305,7 +303,6 @@ internal BlobBaseClient(Uri blobUri, HttpPipeline pipeline, ClientDiagnostics cl
_clientDiagnostics = clientDiagnostics;
_customerProvidedKey = customerProvidedKey;
BlobErrors.VerifyHttpsCustomerProvidedKey(_uri, _customerProvidedKey);
Errors.VerifyHttpSas(_uri, new BlobUriBuilder(_uri).Sas);
}
#endregion ctors

Expand Down
3 changes: 0 additions & 3 deletions sdk/storage/Azure.Storage.Blobs/src/BlobContainerClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@ public BlobContainerClient(string connectionString, string blobContainerName, Bl
_pipeline = options.Build(conn.Credentials);
_clientDiagnostics = new ClientDiagnostics(options);
_customerProvidedKey = options.CustomerProvidedKey;
Errors.VerifyHttpSas(_uri, builder.Sas);
}

/// <summary>
Expand Down Expand Up @@ -263,7 +262,6 @@ internal BlobContainerClient(Uri blobContainerUri, HttpPipelinePolicy authentica
_clientDiagnostics = new ClientDiagnostics(options);
_customerProvidedKey = options.CustomerProvidedKey;
BlobErrors.VerifyHttpsCustomerProvidedKey(_uri, _customerProvidedKey);
Errors.VerifyHttpSas(_uri, new BlobUriBuilder(_uri).Sas);
}

/// <summary>
Expand All @@ -287,7 +285,6 @@ internal BlobContainerClient(Uri containerUri, HttpPipeline pipeline, ClientDiag
_clientDiagnostics = clientDiagnostics;
_customerProvidedKey = customerProvidedKey;
BlobErrors.VerifyHttpsCustomerProvidedKey(_uri, _customerProvidedKey);
Errors.VerifyHttpSas(_uri, new BlobUriBuilder(_uri).Sas);
}

/// <summary>
Expand Down
2 changes: 0 additions & 2 deletions sdk/storage/Azure.Storage.Blobs/src/BlobServiceClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ public BlobServiceClient(string connectionString, BlobClientOptions options)
_pipeline = options.Build(_authenticationPolicy);
_clientDiagnostics = new ClientDiagnostics(options);
_customerProvidedKey = options.CustomerProvidedKey;
Errors.VerifyHttpSas(_uri, new BlobUriBuilder(_uri).Sas);
}

/// <summary>
Expand Down Expand Up @@ -250,7 +249,6 @@ internal BlobServiceClient(Uri serviceUri, HttpPipelinePolicy authentication, Cl
_clientDiagnostics = clientDiagnostics;
_customerProvidedKey = customerProvidedKey;
BlobErrors.VerifyHttpsCustomerProvidedKey(_uri, _customerProvidedKey);
Errors.VerifyHttpSas(_uri, new BlobUriBuilder(_uri).Sas);
}

/// <summary>
Expand Down
44 changes: 0 additions & 44 deletions sdk/storage/Azure.Storage.Blobs/tests/BlobBaseClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,50 +100,6 @@ public void Ctor_CPK_Http()
new ArgumentException("Cannot use client-provided key without HTTPS."));
}

[Test]
public void Ctor_SAS_Http()
{
// Arrange
BlobUriBuilder builder = new BlobUriBuilder(new Uri(TestConfigDefault.BlobServiceEndpoint))
{
Sas = GetNewBlobServiceSasCredentialsContainer(GetNewContainerName())
};
Uri httpUri = builder.ToUri().ToHttp();
TokenCredential tokenCredential = GetOAuthCredential(TestConfigHierarchicalNamespace);
StorageSharedKeyCredential sharedKeyCredential = GetNewSharedKeyCredentials();

// Act
TestHelper.AssertExpectedException(
() => new BlobBaseClient(httpUri),
new ArgumentException(Constants.ErrorMessages.SasHttps));
TestHelper.AssertExpectedException(
() => new BlobBaseClient(httpUri, GetOptions()),
new ArgumentException(Constants.ErrorMessages.SasHttps));
TestHelper.AssertExpectedException(
() => new BlobBaseClient(httpUri, tokenCredential),
new ArgumentException(Constants.ErrorMessages.SasHttps));
TestHelper.AssertExpectedException(
() => new BlobBaseClient(httpUri, tokenCredential, GetOptions()),
new ArgumentException(Constants.ErrorMessages.SasHttps));
TestHelper.AssertExpectedException(
() => new BlobBaseClient(httpUri, sharedKeyCredential),
new ArgumentException(Constants.ErrorMessages.SasHttps));
TestHelper.AssertExpectedException(
() => new BlobBaseClient(httpUri, sharedKeyCredential, GetOptions()),
new ArgumentException(Constants.ErrorMessages.SasHttps));

// Arrange
StorageConnectionString conn = GetConnectionString(true);

// Act
TestHelper.AssertExpectedException(
() => new BlobBaseClient(conn.ToString(true), GetNewContainerName(), GetNewBlobName()),
new ArgumentException(Constants.ErrorMessages.SasHttps));
TestHelper.AssertExpectedException(
() => new BlobBaseClient(conn.ToString(true), GetNewContainerName(), GetNewBlobName(), GetOptions()),
new ArgumentException(Constants.ErrorMessages.SasHttps));
}

#region Sequential Download

[Test]
Expand Down
16 changes: 12 additions & 4 deletions sdk/storage/Azure.Storage.Blobs/tests/BlobTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -430,17 +430,25 @@ public BlobSignedIdentifier[] BuildSignedIdentifiers() =>
};

internal StorageConnectionString GetConnectionString(
bool useHttp = false,
SharedAccessSignatureCredentials credentials = default)
SharedAccessSignatureCredentials credentials = default,
bool includeEndpoint = true)
{
credentials ??= GetAccountSasCredentials();
if (!includeEndpoint)
{
return TestExtensions.CreateStorageConnectionString(
credentials,
TestConfigDefault.AccountName);
}

(Uri, Uri) blobUri = StorageConnectionString.ConstructBlobEndpoint(
useHttp ? Constants.Http : Constants.Https,
Constants.Https,
TestConfigDefault.AccountName,
default,
default);

return new StorageConnectionString(
credentials ?? GetSasCredentials(),
credentials,
blobUri,
(default, default),
(default, default));
Expand Down
51 changes: 11 additions & 40 deletions sdk/storage/Azure.Storage.Blobs/tests/ContainerClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,20 +54,22 @@ public void Ctor_ConnectionString()
public async Task Ctor_ConnectionString_Sas()
{
// Arrange
SharedAccessSignatureCredentials sasCred = GetSasCredentials(
SharedAccessSignatureCredentials sasCred = GetAccountSasCredentials(
AccountSasServices.All,
AccountSasResourceTypes.All,
AccountSasPermissions.All);

StorageConnectionString conn1 = GetConnectionString();
StorageConnectionString conn1 = GetConnectionString(
credentials: sasCred,
includeEndpoint: true);

BlobContainerClient containerClient1 = GetBlobContainerClient(conn1.ToString(exportSecrets: true));

// Also test with a connection string not containing the blob endpoint.
// This should still work provided account name and Sas credential are present.
StorageConnectionString conn2 = TestExtensions.CreateStorageConnectionString(
sasCred,
TestConfigDefault.AccountName);
StorageConnectionString conn2 = GetConnectionString(
credentials: sasCred,
includeEndpoint: false);

BlobContainerClient containerClient2 = GetBlobContainerClient(conn2.ToString(exportSecrets: true));

Expand Down Expand Up @@ -107,7 +109,7 @@ public async Task Ctor_ConnectionString_Sas()
public async Task Ctor_ConnectionString_Sas_Resource_Types_Container()
{
// Arrange
SharedAccessSignatureCredentials sasCred = GetSasCredentials(
SharedAccessSignatureCredentials sasCred = GetAccountSasCredentials(
AccountSasServices.All,
AccountSasResourceTypes.Container,
AccountSasPermissions.All);
Expand Down Expand Up @@ -142,7 +144,7 @@ await TestHelper.AssertExpectedExceptionAsync<RequestFailedException>(
public async Task Ctor_ConnectionString_Sas_Resource_Types_Service()
{
// Arrange
SharedAccessSignatureCredentials sasCred = GetSasCredentials(
SharedAccessSignatureCredentials sasCred = GetAccountSasCredentials(
AccountSasServices.All,
AccountSasResourceTypes.Service,
AccountSasPermissions.All);
Expand All @@ -161,7 +163,7 @@ await TestHelper.AssertExpectedExceptionAsync<RequestFailedException>(
public async Task Ctor_ConnectionString_Sas_Permissions_ReadOnly()
{
// Arrange
SharedAccessSignatureCredentials sasCred = GetSasCredentials(
SharedAccessSignatureCredentials sasCred = GetAccountSasCredentials(
AccountSasServices.All,
AccountSasResourceTypes.All,
AccountSasPermissions.Read);
Expand All @@ -184,7 +186,7 @@ await TestHelper.AssertExpectedExceptionAsync<RequestFailedException>(
public async Task Ctor_ConnectionString_Sas_Permissions_WriteOnly()
{
// Arrange
SharedAccessSignatureCredentials sasCred = GetSasCredentials(
SharedAccessSignatureCredentials sasCred = GetAccountSasCredentials(
AccountSasServices.All,
AccountSasResourceTypes.All,
// include Delete so we can clean up the test
Expand Down Expand Up @@ -214,37 +216,6 @@ await TestHelper.AssertExpectedExceptionAsync<RequestFailedException>(
await containerClient.DeleteAsync();
}
}

[Test]
public void Ctor_SAS_Http()
{
// Arrange
BlobUriBuilder builder = new BlobUriBuilder(new Uri(TestConfigDefault.BlobServiceEndpoint))
{
Sas = GetNewBlobServiceSasCredentialsContainer(GetNewContainerName())
};
Uri httpUri = builder.ToUri().ToHttp();

// Act
TestHelper.AssertExpectedException(
() => new BlobContainerClient(httpUri),
new ArgumentException(Constants.ErrorMessages.SasHttps));
TestHelper.AssertExpectedException(
() => new BlobContainerClient(httpUri, new BlobClientOptions()),
new ArgumentException(Constants.ErrorMessages.SasHttps));

// Arrange
StorageConnectionString conn = GetConnectionString(true);

// Act
TestHelper.AssertExpectedException(
() => new BlobContainerClient(conn.ToString(true), GetNewContainerName()),
new ArgumentException(Constants.ErrorMessages.SasHttps));
TestHelper.AssertExpectedException(
() => new BlobContainerClient(conn.ToString(true), GetNewContainerName(), GetOptions()),
new ArgumentException(Constants.ErrorMessages.SasHttps));
}

private BlobContainerClient GetBlobContainerClient(string connectionString) =>
InstrumentClient(
new BlobContainerClient(
Expand Down
30 changes: 0 additions & 30 deletions sdk/storage/Azure.Storage.Blobs/tests/ServiceClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,36 +99,6 @@ public void Ctor_CPK_Http()
new ArgumentException("Cannot use client-provided key without HTTPS."));
}

[Test]
public void Ctor_SAS_Http()
{
// Arrange
BlobUriBuilder builder = new BlobUriBuilder(new Uri(TestConfigDefault.BlobServiceEndpoint))
{
Sas = GetNewBlobServiceSasCredentialsContainer(GetNewContainerName())
};
Uri httpUri = builder.ToUri().ToHttp();

// Act
TestHelper.AssertExpectedException(
() => new BlobServiceClient(httpUri),
new ArgumentException(Constants.ErrorMessages.SasHttps));
TestHelper.AssertExpectedException(
() => new BlobServiceClient(httpUri, new BlobClientOptions()),
new ArgumentException(Constants.ErrorMessages.SasHttps));

// Arrange
StorageConnectionString conn = GetConnectionString(true);

// Act
TestHelper.AssertExpectedException(
() => new BlobServiceClient(conn.ToString(true)),
new ArgumentException(Constants.ErrorMessages.SasHttps));
TestHelper.AssertExpectedException(
() => new BlobServiceClient(conn.ToString(true), GetOptions()),
new ArgumentException(Constants.ErrorMessages.SasHttps));
}

[Test]
public async Task ListContainersSegmentAsync()
{
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 55a0fe8

Please sign in to comment.