From a43b16dfb037977293ed9f2c4f2f73664024cf4a Mon Sep 17 00:00:00 2001 From: Ersan Bozduman Date: Wed, 24 Jul 2024 01:14:43 -0700 Subject: [PATCH 1/4] Resolves the wrong return value of BucketExistsAsync api --- Minio.Functional.Tests/FunctionalTest.cs | 15 ++++++++++----- Minio/RequestExtensions.cs | 3 +++ 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/Minio.Functional.Tests/FunctionalTest.cs b/Minio.Functional.Tests/FunctionalTest.cs index 84f02cb5..c3437941 100644 --- a/Minio.Functional.Tests/FunctionalTest.cs +++ b/Minio.Functional.Tests/FunctionalTest.cs @@ -371,21 +371,26 @@ internal static async Task BucketExists_Test(IMinioClient minio) await minio.RemoveBucketAsync(rbArgs).ConfigureAwait(false); var found = await minio.BucketExistsAsync(beArgs).ConfigureAwait(false); - Assert.IsFalse(found); + if (found) + throw(new Exception("BucketExistsAsync api failed to return false for a non-existing bucket")); + await minio.MakeBucketAsync(mbArgs).ConfigureAwait(false); found = await minio.BucketExistsAsync(beArgs).ConfigureAwait(false); - Assert.IsTrue(found); - new MintLogger(nameof(BucketExists_Test), bucketExistsSignature, "Tests whether BucketExists passes", + + if (!found) + throw(new Exception("BucketExistsAsync api failed to return true for an existing bucket")); + + new MintLogger(nameof(BucketExists_Test), bucketExistsSignature, "Tests whether BucketExistsAsync api passes", TestStatus.PASS, DateTime.Now - startTime, args: args).Log(); } catch (NotImplementedException ex) { - new MintLogger(nameof(BucketExists_Test), bucketExistsSignature, "Tests whether BucketExists passes", + new MintLogger(nameof(BucketExists_Test), bucketExistsSignature, "Tests whether BucketExistsAsync api passes", TestStatus.NA, DateTime.Now - startTime, ex.Message, ex.ToString(), args: args).Log(); } catch (Exception ex) { - new MintLogger(nameof(BucketExists_Test), bucketExistsSignature, "Tests whether BucketExists passes", + new MintLogger(nameof(BucketExists_Test), bucketExistsSignature, "Tests whether BucketExistsAsync api passes", TestStatus.FAIL, DateTime.Now - startTime, ex.Message, ex.ToString(), args: args).Log(); throw; } diff --git a/Minio/RequestExtensions.cs b/Minio/RequestExtensions.cs index 5cd32ec5..51979c7f 100644 --- a/Minio/RequestExtensions.cs +++ b/Minio/RequestExtensions.cs @@ -145,7 +145,10 @@ await requestMessageBuilder.ResponseWriter(responseResult.ContentStream, cancell throw new BucketNotFoundException(); if (responseResult is not null) + { responseResult.Exception = ex; + throw; + } else responseResult = new ResponseResult(request, ex); return responseResult; From 5866db2ac40a8b2cb5dedb2a83da3775a97bc823 Mon Sep 17 00:00:00 2001 From: Ersan Bozduman Date: Wed, 24 Jul 2024 16:29:08 -0700 Subject: [PATCH 2/4] lint changes --- Minio.Functional.Tests/FunctionalTest.cs | 13 ++++++++----- Minio/RequestExtensions.cs | 5 +++-- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/Minio.Functional.Tests/FunctionalTest.cs b/Minio.Functional.Tests/FunctionalTest.cs index c3437941..e129e71c 100644 --- a/Minio.Functional.Tests/FunctionalTest.cs +++ b/Minio.Functional.Tests/FunctionalTest.cs @@ -372,25 +372,28 @@ internal static async Task BucketExists_Test(IMinioClient minio) var found = await minio.BucketExistsAsync(beArgs).ConfigureAwait(false); if (found) - throw(new Exception("BucketExistsAsync api failed to return false for a non-existing bucket")); + throw new Exception("BucketExistsAsync api failed to return false for a non-existing bucket"); await minio.MakeBucketAsync(mbArgs).ConfigureAwait(false); found = await minio.BucketExistsAsync(beArgs).ConfigureAwait(false); if (!found) - throw(new Exception("BucketExistsAsync api failed to return true for an existing bucket")); + throw new Exception("BucketExistsAsync api failed to return true for an existing bucket"); - new MintLogger(nameof(BucketExists_Test), bucketExistsSignature, "Tests whether BucketExistsAsync api passes", + new MintLogger(nameof(BucketExists_Test), bucketExistsSignature, + "Tests whether BucketExistsAsync api passes", TestStatus.PASS, DateTime.Now - startTime, args: args).Log(); } catch (NotImplementedException ex) { - new MintLogger(nameof(BucketExists_Test), bucketExistsSignature, "Tests whether BucketExistsAsync api passes", + new MintLogger(nameof(BucketExists_Test), bucketExistsSignature, + "Tests whether BucketExistsAsync api passes", TestStatus.NA, DateTime.Now - startTime, ex.Message, ex.ToString(), args: args).Log(); } catch (Exception ex) { - new MintLogger(nameof(BucketExists_Test), bucketExistsSignature, "Tests whether BucketExistsAsync api passes", + new MintLogger(nameof(BucketExists_Test), bucketExistsSignature, + "Tests whether BucketExistsAsync api passes", TestStatus.FAIL, DateTime.Now - startTime, ex.Message, ex.ToString(), args: args).Log(); throw; } diff --git a/Minio/RequestExtensions.cs b/Minio/RequestExtensions.cs index 51979c7f..8792d340 100644 --- a/Minio/RequestExtensions.cs +++ b/Minio/RequestExtensions.cs @@ -149,8 +149,9 @@ await requestMessageBuilder.ResponseWriter(responseResult.ContentStream, cancell responseResult.Exception = ex; throw; } - else - responseResult = new ResponseResult(request, ex); + + responseResult = new ResponseResult(request, ex); + return responseResult; } } From 8b31ca97e44d45bea3eac4d2a5c90bfdf03e11b0 Mon Sep 17 00:00:00 2001 From: Ersan Bozduman Date: Fri, 26 Jul 2024 02:25:45 -0700 Subject: [PATCH 3/4] review changes --- Minio/RequestExtensions.cs | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/Minio/RequestExtensions.cs b/Minio/RequestExtensions.cs index 8792d340..60a1eea4 100644 --- a/Minio/RequestExtensions.cs +++ b/Minio/RequestExtensions.cs @@ -143,16 +143,7 @@ await requestMessageBuilder.ResponseWriter(responseResult.ContentStream, cancell { if (ex.Message.Equals("ThrowBucketNotFoundException", StringComparison.Ordinal)) throw new BucketNotFoundException(); - - if (responseResult is not null) - { - responseResult.Exception = ex; - throw; - } - - responseResult = new ResponseResult(request, ex); - - return responseResult; + throw; } } From 6de3c2a5c2f3db0abbcb9f2dba8b4f34daad9c2b Mon Sep 17 00:00:00 2001 From: Ersan Bozduman Date: Wed, 7 Aug 2024 21:30:53 -0700 Subject: [PATCH 4/4] Addresses ignored func test case exceptions --- Minio.Functional.Tests/FunctionalTest.cs | 16 ++++++++-------- Minio/RequestExtensions.cs | 3 +++ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/Minio.Functional.Tests/FunctionalTest.cs b/Minio.Functional.Tests/FunctionalTest.cs index e129e71c..2cca174d 100644 --- a/Minio.Functional.Tests/FunctionalTest.cs +++ b/Minio.Functional.Tests/FunctionalTest.cs @@ -594,17 +594,17 @@ internal static async Task TearDown(IMinioClient minio, string bucketName) { var beArgs = new BucketExistsArgs() .WithBucket(bucketName); - var bktExists = await minio.BucketExistsAsync(beArgs).ConfigureAwait(false); - if (!bktExists) - return; var getVersions = false; - // Get Versioning/Retention Info. - var lockConfigurationArgs = - new GetObjectLockConfigurationArgs() - .WithBucket(bucketName); - ObjectLockConfiguration lockConfig = null; + var lockConfig = new ObjectLockConfiguration(); try { + var bktExists = await minio.BucketExistsAsync(beArgs).ConfigureAwait(false); + if (!bktExists) + return; + // Get Versioning/Retention Info. + var lockConfigurationArgs = + new GetObjectLockConfigurationArgs() + .WithBucket(bucketName); var versioningConfig = await minio.GetVersioningAsync(new GetVersioningArgs() .WithBucket(bucketName) .WithVersions(true)).ConfigureAwait(false); diff --git a/Minio/RequestExtensions.cs b/Minio/RequestExtensions.cs index 60a1eea4..b938720e 100644 --- a/Minio/RequestExtensions.cs +++ b/Minio/RequestExtensions.cs @@ -143,6 +143,9 @@ await requestMessageBuilder.ResponseWriter(responseResult.ContentStream, cancell { if (ex.Message.Equals("ThrowBucketNotFoundException", StringComparison.Ordinal)) throw new BucketNotFoundException(); + + if (responseResult is not null) responseResult.Exception = ex; + else return new ResponseResult(request, ex); throw; } }