-
Notifications
You must be signed in to change notification settings - Fork 138
feat: add JDBC URL params and SSL config support to MySQL connector #560
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
Open
siiddhantt
wants to merge
15
commits into
datazip-inc:staging
Choose a base branch
from
siiddhantt:feat/JDBC-url-params
base: staging
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
3afa192
feat: add JDBC URL params and SSL config support to MySQL connector
siiddhantt 5069077
refactor: address PR review feedback
siiddhantt 023e219
Merge branch 'staging' into feat/JDBC-url-params
vaibhav-datazip 7949212
Merge branch 'staging' into feat/JDBC-url-params
vaibhav-datazip a7a343c
refactor: simplify nested if-else in SSL config handling
siiddhantt d79565e
Merge branch 'staging' into feat/JDBC-url-params
hash-data 61db15e
Merge branch 'staging' into feat/JDBC-url-params
vaibhav-datazip 9b04e53
Merge branch 'staging' into feat/JDBC-url-params
hash-data cff81bf
Merge branch 'staging' into feat/JDBC-url-params
hash-data f785f35
fix: correct TLS configuration by ensuring MinVersion is set
siiddhantt 9a3f301
Merge branch 'staging' into feat/JDBC-url-params
siiddhantt c3d7e62
Merge branch 'staging' into feat/JDBC-url-params
siiddhantt 1b75ed6
Merge branch 'staging' into feat/JDBC-url-params
siiddhantt e34c1bf
fix: improve TLS configuration error handling and logging
siiddhantt 064daa0
Merge branch 'staging' into feat/JDBC-url-params
vaibhav-datazip File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,175 @@ | ||
| package driver | ||
|
|
||
| import ( | ||
| "strings" | ||
| "testing" | ||
|
|
||
| "github.com/datazip-inc/olake/utils" | ||
| ) | ||
|
|
||
| func TestConfig_URI_WithJDBCParams(t *testing.T) { | ||
| config := &Config{ | ||
| Host: "localhost", | ||
| Port: 3306, | ||
| Username: "testuser", | ||
| Password: "testpass", | ||
| Database: "testdb", | ||
| JDBCURLParams: map[string]string{ | ||
| "charset": "utf8mb4", | ||
| "parseTime": "true", | ||
| "loc": "Local", | ||
| }, | ||
| } | ||
|
|
||
| uri := config.URI() | ||
|
|
||
| // Check that JDBC params are included in the URI | ||
| if !strings.Contains(uri, "charset=utf8mb4") { | ||
| t.Errorf("Expected charset parameter in URI, got: %s", uri) | ||
| } | ||
| if !strings.Contains(uri, "parseTime=true") { | ||
| t.Errorf("Expected parseTime parameter in URI, got: %s", uri) | ||
| } | ||
| if !strings.Contains(uri, "loc=Local") { | ||
| t.Errorf("Expected loc parameter in URI, got: %s", uri) | ||
| } | ||
| } | ||
|
|
||
| func TestConfig_URI_WithSSLDisabled(t *testing.T) { | ||
| config := &Config{ | ||
| Host: "localhost", | ||
| Port: 3306, | ||
| Username: "testuser", | ||
| Password: "testpass", | ||
| Database: "testdb", | ||
| SSLConfiguration: &utils.SSLConfig{ | ||
| Mode: utils.SSLModeDisable, | ||
| }, | ||
| } | ||
|
|
||
| uri := config.URI() | ||
|
|
||
| // Check that TLS is disabled | ||
| if !strings.Contains(uri, "tls=false") { | ||
| t.Errorf("Expected tls=false in URI, got: %s", uri) | ||
| } | ||
| } | ||
|
|
||
| func TestConfig_URI_WithSSLRequired(t *testing.T) { | ||
| config := &Config{ | ||
| Host: "localhost", | ||
| Port: 3306, | ||
| Username: "testuser", | ||
| Password: "testpass", | ||
| Database: "testdb", | ||
| SSLConfiguration: &utils.SSLConfig{ | ||
| Mode: utils.SSLModeRequire, | ||
| }, | ||
| } | ||
|
|
||
| uri := config.URI() | ||
|
|
||
| // Check that TLS is enabled | ||
| if !strings.Contains(uri, "tls=true") { | ||
| t.Errorf("Expected tls=true in URI, got: %s", uri) | ||
| } | ||
| } | ||
|
|
||
| func TestConfig_Validate_WithSSLConfig(t *testing.T) { | ||
| tests := []struct { | ||
| name string | ||
| config *Config | ||
| expectErr bool | ||
| }{ | ||
| { | ||
| name: "Valid SSL config with disable mode", | ||
| config: &Config{ | ||
| Host: "localhost", | ||
| Port: 3306, | ||
| Username: "testuser", | ||
| Password: "testpass", | ||
| Database: "testdb", | ||
| SSLConfiguration: &utils.SSLConfig{ | ||
| Mode: utils.SSLModeDisable, | ||
| }, | ||
| }, | ||
| expectErr: false, | ||
| }, | ||
| { | ||
| name: "Valid SSL config with require mode", | ||
| config: &Config{ | ||
| Host: "localhost", | ||
| Port: 3306, | ||
| Username: "testuser", | ||
| Password: "testpass", | ||
| Database: "testdb", | ||
| SSLConfiguration: &utils.SSLConfig{ | ||
| Mode: utils.SSLModeRequire, | ||
| }, | ||
| }, | ||
| expectErr: false, | ||
| }, | ||
| { | ||
| name: "Invalid SSL config - verify-ca without certificates", | ||
| config: &Config{ | ||
| Host: "localhost", | ||
| Port: 3306, | ||
| Username: "testuser", | ||
| Password: "testpass", | ||
| Database: "testdb", | ||
| SSLConfiguration: &utils.SSLConfig{ | ||
| Mode: utils.SSLModeVerifyCA, | ||
| }, | ||
| }, | ||
| expectErr: true, | ||
| }, | ||
| } | ||
|
|
||
| for _, tt := range tests { | ||
| t.Run(tt.name, func(t *testing.T) { | ||
| err := tt.config.Validate() | ||
| if tt.expectErr && err == nil { | ||
| t.Errorf("Expected error but got none") | ||
| } | ||
| if !tt.expectErr && err != nil { | ||
| t.Errorf("Expected no error but got: %v", err) | ||
| } | ||
| }) | ||
| } | ||
| } | ||
|
|
||
| func TestConfig_URI_CombinedParams(t *testing.T) { | ||
| config := &Config{ | ||
| Host: "mysql.example.com", | ||
| Port: 3306, | ||
| Username: "appuser", | ||
| Password: "securepass", | ||
| Database: "appdb", | ||
| JDBCURLParams: map[string]string{ | ||
| "charset": "utf8mb4", | ||
| "parseTime": "true", | ||
| "timeout": "10s", | ||
| "readTimeout": "30s", | ||
| "writeTimeout": "30s", | ||
| }, | ||
| SSLConfiguration: &utils.SSLConfig{ | ||
| Mode: utils.SSLModeRequire, | ||
| }, | ||
| } | ||
|
|
||
| uri := config.URI() | ||
|
|
||
| // Verify both JDBC params and SSL config are present | ||
| if !strings.Contains(uri, "charset=utf8mb4") { | ||
| t.Errorf("Expected charset parameter in URI") | ||
| } | ||
| if !strings.Contains(uri, "tls=true") { | ||
| t.Errorf("Expected TLS enabled in URI") | ||
| } | ||
| if !strings.Contains(uri, "mysql.example.com:3306") { | ||
| t.Errorf("Expected correct host and port in URI") | ||
| } | ||
| if !strings.Contains(uri, "appdb") { | ||
| t.Errorf("Expected database name in URI") | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.