Skip to content

Commit

Permalink
Adds missing Minio.Config property initializations
Browse files Browse the repository at this point in the history
  • Loading branch information
Ersan Bozduman committed Sep 6, 2023
1 parent 33301d5 commit 3c05445
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 15 deletions.
9 changes: 3 additions & 6 deletions Minio.Functional.Tests/FunctionalTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -590,10 +590,9 @@ internal static async Task TearDown(IMinioClient minio, string bucketName)
new GetObjectLockConfigurationArgs()
.WithBucket(bucketName);
ObjectLockConfiguration lockConfig = null;
VersioningConfiguration versioningConfig = null;
try
{
versioningConfig = await minio.GetVersioningAsync(new GetVersioningArgs()
var versioningConfig = await minio.GetVersioningAsync(new GetVersioningArgs()
.WithBucket(bucketName)).ConfigureAwait(false);
if (versioningConfig is not null &&
(versioningConfig.Status.Contains("Enabled", StringComparison.Ordinal) ||
Expand Down Expand Up @@ -6057,9 +6056,8 @@ internal static async Task BucketLifecycleAsync_Test1(IMinioClient minio)
var expDate = baseDate.AddYears(1);
var exp = new Expiration(expDate);

var calculatedExpDate = expDate.AddDays(1).AddSeconds(-1).ToUniversalTime().Date.ToString("o");
var realExpDate = DateTime.Parse(calculatedExpDate, CultureInfo.InvariantCulture);
var expInDays = (realExpDate.Date - baseDate.Date).TotalDays;
var calculatedExpDate = expDate.AddDays(1).AddSeconds(-1).ToUniversalTime().Date;
var expInDays = (calculatedExpDate.ToLocalTime().Date - baseDate.Date).TotalDays;

var rule1 = new LifecycleRule(null, "txt", exp, null,
new RuleFilter(null, "txt/", null), null, null, LifecycleRule.LifecycleRuleStatusEnabled);
Expand All @@ -6084,7 +6082,6 @@ internal static async Task BucketLifecycleAsync_Test1(IMinioClient minio)
}
catch (Exception ex)
{
await TearDown(minio, bucketName).ConfigureAwait(false);
new MintLogger(nameof(BucketLifecycleAsync_Test1) + ".1", setBucketLifecycleSignature,
"Tests whether SetBucketLifecycleAsync passes", TestStatus.FAIL, DateTime.Now - startTime, ex.Message,
ex.ToString(), args: args).Log();
Expand Down
13 changes: 4 additions & 9 deletions Minio/MinioClientExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public static IMinioClient WithEndpoint(this IMinioClient minioClient, string en
if (minioClient is null) throw new ArgumentNullException(nameof(minioClient));

minioClient.Config.BaseUrl = endpoint;
minioClient.Config.Endpoint = endpoint;
minioClient.SetBaseURL(GetBaseUrl(endpoint));
return minioClient;
}
Expand All @@ -63,6 +64,7 @@ public static IMinioClient WithEndpoint(this IMinioClient minioClient, string en
throw new ArgumentException(
string.Format(CultureInfo.InvariantCulture, "Port {0} is not a number between 1 and 65535", port),
nameof(port));
minioClient.Config.Endpoint = endpoint;
return minioClient.WithEndpoint(endpoint + ":" + port);
}

Expand All @@ -71,6 +73,7 @@ public static IMinioClient WithEndpoint(this IMinioClient minioClient, Uri url)
if (minioClient is null) throw new ArgumentNullException(nameof(minioClient));

if (url is null) throw new ArgumentNullException(nameof(url));
minioClient.Config.Endpoint = url.AbsoluteUri;

return minioClient.WithEndpoint(url.AbsoluteUri);
}
Expand Down Expand Up @@ -120,15 +123,7 @@ public static IMinioClient WithSessionToken(this IMinioClient minioClient, strin
public static IMinioClient WithSSL(this IMinioClient minioClient, bool secure = true)
{
if (minioClient is null) throw new ArgumentNullException(nameof(minioClient));

if (secure)
{
minioClient.Config.Secure = true;
if (string.IsNullOrEmpty(minioClient.Config.BaseUrl))
return minioClient;
//var secureUrl = RequestUtil.MakeTargetURL(minioClient.BaseUrl, minioClient.Secure);
}

minioClient.Config.Secure = secure;
return minioClient;
}

Expand Down

0 comments on commit 3c05445

Please sign in to comment.