-
Notifications
You must be signed in to change notification settings - Fork 138
Update MinioClientSettings to UseSsl parsing #943
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 9 commits
1232c27
5087708
0535933
0cef174
637d11a
20de448
f20210d
b204313
f80d221
b759195
bc67f69
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,4 +12,103 @@ | |
| [Fact] | ||
| public void CredentialsIsNullByDefault() => | ||
| Assert.Null(new MinioClientSettings().Credentials); | ||
|
|
||
| [Fact] | ||
| public void UseSslIsFalseByDefault() | ||
| { | ||
| var settings = new MinioClientSettings(); | ||
| Assert.False(settings.UseSsl); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void ParseConnectionString_HttpsUri_DoesNotInferUseSsl() | ||
| { | ||
| var settings = new MinioClientSettings(); | ||
| settings.ParseConnectionString("https://minio.example.com:9000"); | ||
|
Check failure on line 27 in tests/CommunityToolkit.Aspire.Minio.Client.Tests/ConfigurationTests.cs
|
||
|
|
||
| Assert.NotNull(settings.Endpoint); | ||
| Assert.Equal("https://minio.example.com:9000/", settings.Endpoint.ToString()); | ||
| Assert.False(settings.UseSsl); // Should remain false since UseSsl was not explicitly set | ||
| } | ||
|
|
||
| [Fact] | ||
| public void ParseConnectionString_HttpUri_DoesNotInferUseSsl() | ||
| { | ||
| var settings = new MinioClientSettings(); | ||
| settings.ParseConnectionString("http://minio.example.com:9000"); | ||
|
Check failure on line 38 in tests/CommunityToolkit.Aspire.Minio.Client.Tests/ConfigurationTests.cs
|
||
|
|
||
| Assert.NotNull(settings.Endpoint); | ||
| Assert.Equal("http://minio.example.com:9000/", settings.Endpoint.ToString()); | ||
| Assert.False(settings.UseSsl); // Should remain false | ||
| } | ||
|
|
||
| [Fact] | ||
| public void ParseConnectionString_ExplicitUseSslTrue() | ||
| { | ||
| var settings = new MinioClientSettings(); | ||
| settings.ParseConnectionString("Endpoint=http://minio.example.com:9000;UseSsl=true;AccessKey=key;SecretKey=secret"); | ||
|
Check failure on line 49 in tests/CommunityToolkit.Aspire.Minio.Client.Tests/ConfigurationTests.cs
|
||
|
|
||
| Assert.NotNull(settings.Endpoint); | ||
| Assert.True(settings.UseSsl); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void ParseConnectionString_ExplicitUseSslFalse() | ||
| { | ||
| var settings = new MinioClientSettings(); | ||
| settings.ParseConnectionString("Endpoint=https://minio.example.com:9000;UseSsl=false;AccessKey=key;SecretKey=secret"); | ||
|
Check failure on line 59 in tests/CommunityToolkit.Aspire.Minio.Client.Tests/ConfigurationTests.cs
|
||
|
|
||
| Assert.NotNull(settings.Endpoint); | ||
| Assert.False(settings.UseSsl); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void ParseConnectionString_UseSslCaseInsensitive() | ||
| { | ||
| var settings = new MinioClientSettings(); | ||
| settings.ParseConnectionString("Endpoint=http://minio.example.com:9000;UseSsl=True;AccessKey=key;SecretKey=secret"); | ||
|
Check failure on line 69 in tests/CommunityToolkit.Aspire.Minio.Client.Tests/ConfigurationTests.cs
|
||
|
|
||
| Assert.True(settings.UseSsl); | ||
| } | ||
|
|
||
|
|
||
| [Fact] | ||
| public void ParseConnectionString_WithCredentials() | ||
| { | ||
| var settings = new MinioClientSettings(); | ||
| settings.ParseConnectionString("Endpoint=http://minio.example.com:9000;AccessKey=mykey;SecretKey=mysecret;UseSsl=true"); | ||
|
Check failure on line 79 in tests/CommunityToolkit.Aspire.Minio.Client.Tests/ConfigurationTests.cs
|
||
|
|
||
| Assert.NotNull(settings.Endpoint); | ||
| Assert.NotNull(settings.Credentials); | ||
| Assert.Equal("mykey", settings.Credentials.AccessKey); | ||
| Assert.Equal("mysecret", settings.Credentials.SecretKey); | ||
| Assert.True(settings.UseSsl); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void ParseConnectionString_NullOrEmpty_DoesNotThrow() | ||
| { | ||
| var settings = new MinioClientSettings(); | ||
| settings.ParseConnectionString(null); | ||
|
Check failure on line 92 in tests/CommunityToolkit.Aspire.Minio.Client.Tests/ConfigurationTests.cs
|
||
| Assert.Null(settings.Endpoint); | ||
|
|
||
| settings = new MinioClientSettings(); | ||
| settings.ParseConnectionString(""); | ||
|
Check failure on line 96 in tests/CommunityToolkit.Aspire.Minio.Client.Tests/ConfigurationTests.cs
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: string.Empty could be more convenient here |
||
| Assert.Null(settings.Endpoint); | ||
|
|
||
| settings = new MinioClientSettings(); | ||
| settings.ParseConnectionString(" "); | ||
|
Check failure on line 100 in tests/CommunityToolkit.Aspire.Minio.Client.Tests/ConfigurationTests.cs
|
||
| Assert.Null(settings.Endpoint); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void ParseConnectionString_HttpsEndpointInConnectionString_DoesNotInferUseSsl() | ||
| { | ||
| var settings = new MinioClientSettings(); | ||
| settings.ParseConnectionString("Endpoint=https://minio.example.com:9000;AccessKey=key;SecretKey=secret"); | ||
|
Check failure on line 108 in tests/CommunityToolkit.Aspire.Minio.Client.Tests/ConfigurationTests.cs
|
||
|
|
||
| Assert.NotNull(settings.Endpoint); | ||
| Assert.Equal("https://minio.example.com:9000/", settings.Endpoint.ToString()); | ||
| Assert.False(settings.UseSsl); // Should remain false without explicit UseSsl | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the
ParseConnectionStringmethod is internal you'll need to expose it to the test project with<InternalsVisibleTo Include="CommunityToolkit.Aspire.Minio.Client.Tests" />You'll find a bunch of examples of other projects using
InternalsVisibleToin the repo