-
Notifications
You must be signed in to change notification settings - Fork 154
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 8 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 @@ public void EndpointIsNullByDefault() => | |
| [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"); | ||
|
Member
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. Since the You'll find a bunch of examples of other projects using |
||
|
|
||
| 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"); | ||
|
|
||
| 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"); | ||
|
|
||
| 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"); | ||
|
|
||
| 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"); | ||
|
|
||
| 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"); | ||
|
|
||
| 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); | ||
| Assert.Null(settings.Endpoint); | ||
|
|
||
| settings = new MinioClientSettings(); | ||
| settings.ParseConnectionString(""); | ||
|
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(" "); | ||
| 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"); | ||
|
|
||
| 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.
It seems that you need to explicitly cast useSslObj to string over here