From a34b7f90a0df056e0a3a44b0a4443c4e8e9ed47d Mon Sep 17 00:00:00 2001
From: Sergey Shaykhullin <46970457+sergeyshaykhullin@users.noreply.github.com>
Date: Mon, 8 Jan 2024 16:35:54 +0300
Subject: [PATCH] Bump packages (#69)
---
.../Minio.AspNetCore.HealthChecks.csproj | 23 ++++-
src/Minio.AspNetCore/IMinioClientFactory.cs | 4 +-
src/Minio.AspNetCore/Minio.AspNetCore.csproj | 27 +++++-
src/Minio.AspNetCore/MinioClientFactory.cs | 8 +-
src/Minio.AspNetCore/MinioOptions.cs | 4 +-
tests/Minio.AspNetCore.Tests.csproj | 31 ++++++-
tests/MinioAsserts.cs | 91 ++++---------------
tests/ServiceCollectionExtensionsTests.cs | 10 +-
.../ServiceCollectionNamedExtensionsTests.cs | 2 +-
9 files changed, 106 insertions(+), 94 deletions(-)
diff --git a/src/Minio.AspNetCore.HealthChecks/Minio.AspNetCore.HealthChecks.csproj b/src/Minio.AspNetCore.HealthChecks/Minio.AspNetCore.HealthChecks.csproj
index 36dce40..6ac81b8 100644
--- a/src/Minio.AspNetCore.HealthChecks/Minio.AspNetCore.HealthChecks.csproj
+++ b/src/Minio.AspNetCore.HealthChecks/Minio.AspNetCore.HealthChecks.csproj
@@ -10,7 +10,28 @@
-
+
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
+ all
+ runtime; build; native; contentfiles; analyzers
+
+
+ all
+ runtime; build; native; contentfiles; analyzers
+
+
+ all
+ runtime; build; native; contentfiles; analyzers
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
diff --git a/src/Minio.AspNetCore/IMinioClientFactory.cs b/src/Minio.AspNetCore/IMinioClientFactory.cs
index fc6ad69..c7e22b3 100644
--- a/src/Minio.AspNetCore/IMinioClientFactory.cs
+++ b/src/Minio.AspNetCore/IMinioClientFactory.cs
@@ -2,7 +2,7 @@ namespace Minio.AspNetCore
{
public interface IMinioClientFactory
{
- MinioClient CreateClient();
- MinioClient CreateClient(string name);
+ IMinioClient CreateClient();
+ IMinioClient CreateClient(string name);
}
}
diff --git a/src/Minio.AspNetCore/Minio.AspNetCore.csproj b/src/Minio.AspNetCore/Minio.AspNetCore.csproj
index 2005c41..66e7266 100644
--- a/src/Minio.AspNetCore/Minio.AspNetCore.csproj
+++ b/src/Minio.AspNetCore/Minio.AspNetCore.csproj
@@ -6,9 +6,30 @@
-
-
-
+
+
+
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
+ all
+ runtime; build; native; contentfiles; analyzers
+
+
+ all
+ runtime; build; native; contentfiles; analyzers
+
+
+ all
+ runtime; build; native; contentfiles; analyzers
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
diff --git a/src/Minio.AspNetCore/MinioClientFactory.cs b/src/Minio.AspNetCore/MinioClientFactory.cs
index fbfa0b1..c2e65f1 100644
--- a/src/Minio.AspNetCore/MinioClientFactory.cs
+++ b/src/Minio.AspNetCore/MinioClientFactory.cs
@@ -11,19 +11,23 @@ public MinioClientFactory(IOptionsMonitor optionsMonitor)
this.optionsMonitor = optionsMonitor;
}
- public MinioClient CreateClient()
+ public IMinioClient CreateClient()
{
return CreateClient(Options.DefaultName);
}
- public MinioClient CreateClient(string name)
+ public IMinioClient CreateClient(string name)
{
var options = optionsMonitor.Get(name);
+#pragma warning disable IDISP001
+#pragma warning disable CA2000
var client = new MinioClient()
+#pragma warning restore CA2000
.WithEndpoint(options.Endpoint)
.WithCredentials(options.AccessKey, options.SecretKey)
.WithSessionToken(options.SessionToken);
+#pragma warning restore IDISP001
if (!string.IsNullOrEmpty(options.Region))
{
diff --git a/src/Minio.AspNetCore/MinioOptions.cs b/src/Minio.AspNetCore/MinioOptions.cs
index d0ede2e..5dedb21 100644
--- a/src/Minio.AspNetCore/MinioOptions.cs
+++ b/src/Minio.AspNetCore/MinioOptions.cs
@@ -8,9 +8,9 @@ public class MinioOptions
public string Region { get; set; } = string.Empty;
public string SessionToken { get; set; } = string.Empty;
- internal Action? Configure { get; private set; }
+ internal Action? Configure { get; private set; }
- public void ConfigureClient(Action configure)
+ public void ConfigureClient(Action configure)
{
Configure = configure;
}
diff --git a/tests/Minio.AspNetCore.Tests.csproj b/tests/Minio.AspNetCore.Tests.csproj
index 91616ab..b928e93 100644
--- a/tests/Minio.AspNetCore.Tests.csproj
+++ b/tests/Minio.AspNetCore.Tests.csproj
@@ -1,7 +1,7 @@
- net6.0
+ net8.0
false
enable
@@ -11,13 +11,34 @@
-
+
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
+ all
+ runtime; build; native; contentfiles; analyzers
+
+
+ all
+ runtime; build; native; contentfiles; analyzers
+
+
+ all
+ runtime; build; native; contentfiles; analyzers
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
-
-
-
+
+
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
diff --git a/tests/MinioAsserts.cs b/tests/MinioAsserts.cs
index 35ba9f0..e4da40d 100644
--- a/tests/MinioAsserts.cs
+++ b/tests/MinioAsserts.cs
@@ -6,92 +6,37 @@ namespace Minio.AspNetCore.Tests
{
public static class MinioAsserts
{
- public static void AssertOptionsMatch(MinioClient client, MinioOptions options)
+ public static void AssertOptionsMatch(IMinioClient client, MinioOptions options)
{
- if (client is null)
- {
- throw new ArgumentNullException(nameof(client));
- }
-
- if (options is null)
- {
- throw new ArgumentNullException(nameof(options));
- }
-
- var clientType = client.GetType();
-
- var endpoint = clientType
- .GetProperty("BaseUrl", BindingFlags.Instance | BindingFlags.NonPublic)
- ?.GetValue(client);
- Assert.Equal(options.Endpoint, endpoint);
-
- var region = clientType
- .GetField(nameof(MinioOptions.Region), BindingFlags.Instance | BindingFlags.NonPublic)
- ?.GetValue(client);
- Assert.Equal(options.Region, region);
-
- var accessKey = clientType
- .GetProperty(nameof(MinioOptions.AccessKey), BindingFlags.Instance | BindingFlags.NonPublic)
- ?.GetValue(client);
- Assert.Equal(options.AccessKey, accessKey);
-
- var secretKey = clientType
- .GetProperty(nameof(MinioOptions.SecretKey), BindingFlags.Instance | BindingFlags.NonPublic)
- ?.GetValue(client);
- Assert.Equal(options.SecretKey, secretKey);
-
- var sessionToken = clientType
- .GetProperty(nameof(MinioOptions.SessionToken), BindingFlags.Instance | BindingFlags.NonPublic)
- ?.GetValue(client);
- Assert.Equal(options.SessionToken, sessionToken);
+ ArgumentNullException.ThrowIfNull(client);
+ ArgumentNullException.ThrowIfNull(options);
+
+ Assert.Equal($"{(client.Config.Secure ? "https" : "http")}://{options.Endpoint}", client.Config.Endpoint);
+ Assert.Equal(options.Region, client.Config.Region);
+ Assert.Equal(options.AccessKey, client.Config.AccessKey);
+ Assert.Equal(options.SecretKey, client.Config.SecretKey);
+ Assert.Equal(options.SessionToken, client.Config.SessionToken);
}
- public static void AssertSecure(MinioClient client)
+ public static void AssertSecure(IMinioClient client)
{
- if (client is null)
- {
- throw new ArgumentNullException(nameof(client));
- }
+ ArgumentNullException.ThrowIfNull(client);
- var clientType = client.GetType();
-
- var secure = (bool)clientType
- .GetProperty("Secure", BindingFlags.Instance | BindingFlags.NonPublic)
- ?.GetValue(client)!;
-
- Assert.True(secure);
+ Assert.True(client.Config.Secure);
}
- public static void AssertTimeout(MinioClient client, int timeout)
+ public static void AssertTimeout(IMinioClient client, int timeout)
{
- if (client is null)
- {
- throw new ArgumentNullException(nameof(client));
- }
-
- var clientType = client.GetType();
+ ArgumentNullException.ThrowIfNull(client);
- var clientTimeout = (int)clientType
- .GetField("RequestTimeout", BindingFlags.Instance | BindingFlags.NonPublic)
- ?.GetValue(client)!;
-
- Assert.Equal(timeout, clientTimeout);
+ Assert.Equal(timeout, client.Config.RequestTimeout);
}
- public static void AssertWebProxy(MinioClient client, IWebProxy webProxy)
+ public static void AssertWebProxy(IMinioClient client, IWebProxy webProxy)
{
- if (client is null)
- {
- throw new ArgumentNullException(nameof(client));
- }
-
- var clientType = client.GetType();
-
- var clientProxy = clientType
- .GetProperty("Proxy", BindingFlags.Instance | BindingFlags.NonPublic)
- ?.GetValue(client) as IWebProxy;
+ ArgumentNullException.ThrowIfNull(client);
- Assert.Equal(webProxy, clientProxy);
+ Assert.Equal(webProxy, client.Config.Proxy);
}
}
}
diff --git a/tests/ServiceCollectionExtensionsTests.cs b/tests/ServiceCollectionExtensionsTests.cs
index cc017bb..93b1cfb 100644
--- a/tests/ServiceCollectionExtensionsTests.cs
+++ b/tests/ServiceCollectionExtensionsTests.cs
@@ -26,7 +26,7 @@ public void AddToServices()
{
Assert.Contains(services, x => x.ServiceType == typeof(IMinioClientFactory));
Assert.Contains(services, x => x.ServiceType == typeof(IConfigureOptions));
- Assert.Contains(services, x => x.ServiceType == typeof(MinioClient));
+ Assert.Contains(services, x => x.ServiceType == typeof(IMinioClient));
}
[Fact]
@@ -37,7 +37,7 @@ public void GetFromServices()
var factory = serviceProvider.GetService();
Assert.NotNull(factory);
- var client = serviceProvider.GetService();
+ var client = serviceProvider.GetService();
Assert.NotNull(client);
var options = serviceProvider.GetService>()?.Value;
@@ -57,8 +57,8 @@ public void SameClients()
{
using var serviceProvider = services.BuildServiceProvider();
- var client1 = serviceProvider.GetRequiredService();
- var client2 = serviceProvider.GetRequiredService();
+ var client1 = serviceProvider.GetRequiredService();
+ var client2 = serviceProvider.GetRequiredService();
Assert.Same(client1, client2);
}
@@ -68,7 +68,7 @@ public void MultipleClients()
{
using var serviceProvider = services.BuildServiceProvider();
- var client1 = serviceProvider.GetRequiredService();
+ var client1 = serviceProvider.GetRequiredService();
using var client2 = serviceProvider.GetRequiredService().CreateClient();
Assert.NotSame(client1, client2);
diff --git a/tests/ServiceCollectionNamedExtensionsTests.cs b/tests/ServiceCollectionNamedExtensionsTests.cs
index 8406da4..3282ac4 100644
--- a/tests/ServiceCollectionNamedExtensionsTests.cs
+++ b/tests/ServiceCollectionNamedExtensionsTests.cs
@@ -29,7 +29,7 @@ public void GetFromServices()
var factory = serviceProvider.GetService();
Assert.NotNull(factory);
- var client = serviceProvider.GetService();
+ var client = serviceProvider.GetService();
Assert.NotNull(client);
var monitor = serviceProvider.GetRequiredService>();