-
-
Notifications
You must be signed in to change notification settings - Fork 80
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
Allow TLS enabled connections when providing an established channel #526
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #526 +/- ##
=======================================
Coverage 61.77% 61.78%
=======================================
Files 125 125
Lines 10072 10074 +2
=======================================
+ Hits 6222 6224 +2
Misses 3850 3850
|
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.
Great addition! Thanks for opening a PR. Please see the comment! If you need help please reach out.
@@ -193,8 +193,8 @@ extension PostgresConnection { | |||
/// - channel: The `NIOCore/Channel` to use. The channel must already be active and connected to an | |||
/// endpoint (i.e. `NIOCore/Channel/isActive` must be `true`). | |||
/// - tls: The TLS mode to use. Defaults to ``TLS-swift.struct/disable``. | |||
public init(establishedChannel channel: Channel, username: String, password: String?, database: String?) { | |||
self.init(endpointInfo: .configureChannel(channel), tls: .disable, username: username, password: password, database: database) | |||
public init(establishedChannel channel: Channel, tls: PostgresConnection.Configuration.TLS = .disable, username: String, password: String?, database: String?) { |
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.
This is a breaking API change. Would you mind adding an additional initializer? This initializer should then call the new one that you just created.
Do you feel comfortable to add a unit test using a NIOAsyncTestingChannel
? An example can be found here:
https://github.com/vapor/postgres-nio/blob/f2a6394a2e7157d547727b975fc0328b92f89fb1/Tests/PostgresNIOTests/New/PostgresConnectionTests.swift#L41C1-L82C1
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.
I probably won't have time to do the test right now, as I need to fix the wrong channel handler order first for TLS 🤭
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.
I need to fix the wrong channel handler order first for TLS
Not sure I follow here.
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.
See #527
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.
In an ideal case we would add at least one unit test for this...
When connecting through an established channel (e.g. an SSH tunnel) it can still be useful to allow postgres to connect using TLS. This PR exposes the tls parameter on the connection method for using an established channel.