Browse Source

Fix: MakeBucketAsync returns deserialization exception if BucketName is null (#382)

pull/385/head
Adam Hodgson 5 years ago
committed by GitHub
parent
commit
c0d18bf85d
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 22
      Minio.Functional.Tests/FunctionalTest.cs
  2. 2
      Minio.Functional.Tests/Program.cs
  3. 6
      Minio/ApiEndpoints/BucketOperations.cs

22
Minio.Functional.Tests/FunctionalTest.cs

@ -300,6 +300,28 @@ namespace Minio.Functional.Tests
}
}
internal async static Task MakeBucket_Test5(MinioClient minio)
{
DateTime startTime = DateTime.Now;
string bucketName = null;
var args = new Dictionary<string, string>
{
{ "bucketName", bucketName },
{ "region", "us-east-1" },
};
try
{
await Assert.ThrowsExceptionAsync<InvalidBucketNameException>(() =>
minio.MakeBucketAsync(bucketName));
new MintLogger(nameof(MakeBucket_Test5), makeBucketSignature, "Tests whether MakeBucket throws InvalidBucketNameException when bucketName is null", TestStatus.PASS, (DateTime.Now - startTime), args: args).Log();
}
catch (MinioException ex)
{
new MintLogger(nameof(MakeBucket_Test5), makeBucketSignature, "Tests whether MakeBucket throws InvalidBucketNameException when bucketName is null", TestStatus.FAIL, (DateTime.Now - startTime), "", ex.Message, ex.ToString(), args).Log();
}
}
#endregion
internal async static Task RemoveBucket_Test1(MinioClient minio)

2
Minio.Functional.Tests/Program.cs

@ -85,6 +85,8 @@ namespace Minio.Functional.Tests
// Create a new bucket
FunctionalTest.MakeBucket_Test1(minioClient).Wait();
FunctionalTest.MakeBucket_Test2(minioClient).Wait();
FunctionalTest.MakeBucket_Test5(minioClient).Wait();
if (useAWS)
{
FunctionalTest.MakeBucket_Test3(minioClient).Wait();

6
Minio/ApiEndpoints/BucketOperations.cs

@ -63,8 +63,14 @@ namespace Minio
/// <param name="location">Region</param>
/// <param name="cancellationToken">Optional cancellation token to cancel the operation</param>
/// <returns> Task </returns>
/// <exception cref="InvalidBucketNameException">When bucketName is null</exception>
public async Task MakeBucketAsync(string bucketName, string location = "us-east-1", CancellationToken cancellationToken = default(CancellationToken))
{
if (bucketName == null)
{
throw new InvalidBucketNameException(bucketName, "bucketName cannot be null");
}
if (location == "us-east-1")
{
if (this.Region != string.Empty)

Loading…
Cancel
Save