test: add null connection SSL fallback test#41839
Conversation
WalkthroughA new test method ChangesMSSQL SSL Default Verification Test
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 4❌ Failed checks (4 warnings)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@app/server/appsmith-plugins/mssqlPlugin/src/test/java/com/external/plugins/MssqlPluginTest.java`:
- Line 778: The test method name testSslDefaultsToNoVerify_whenConnectionIsNull
is inconsistent with its assertion (it asserts encrypt=false / DISABLE); rename
the method to reflect the asserted SSL mode (e.g.,
testSslDefaultsToDisable_whenConnectionIsNull) or alternatively change the
assertion to match a NoVerify expectation; update the method declaration and any
references to testSslDefaultsToNoVerify_whenConnectionIsNull so the name and
asserted behavior (encrypt=false / DISABLE) are aligned.
- Around line 784-789: The test expects datasource creation to complete even
when the incoming connection is null, but MssqlPlugin.addSslOptionsToUrlBuilder
currently throws on a null connection; change addSslOptionsToUrlBuilder to
null-guard the connection parameter (e.g., if connection == null return the
original URLBuilder or a builder with default/no-op SSL options) so it does not
throw, ensuring datasourceCreate/dsConnectionMono can complete and the test in
MssqlPluginTest that asserts the JDBC URL contains "encrypt=false" can proceed;
locate and update the addSslOptionsToUrlBuilder method (and any callers in
datasourceCreate) to handle null safely without altering other behavior.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 432099a5-7aef-4610-880b-0f6b5dceef82
📒 Files selected for processing (1)
app/server/appsmith-plugins/mssqlPlugin/src/test/java/com/external/plugins/MssqlPluginTest.java
| } | ||
|
|
||
| @Test | ||
| public void testSslDefaultsToNoVerify_whenConnectionIsNull() { |
There was a problem hiding this comment.
Rename the test to match the asserted SSL mode.
Line 778 says NoVerify, but Line 787 asserts encrypt=false, which corresponds to DISABLE behavior. Rename the method (or change assertion) to avoid semantic drift in test intent.
Suggested rename
- public void testSslDefaultsToNoVerify_whenConnectionIsNull() {
+ public void testSslDefaultsToDisable_whenConnectionIsNull() {Also applies to: 787-787
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In
`@app/server/appsmith-plugins/mssqlPlugin/src/test/java/com/external/plugins/MssqlPluginTest.java`
at line 778, The test method name testSslDefaultsToNoVerify_whenConnectionIsNull
is inconsistent with its assertion (it asserts encrypt=false / DISABLE); rename
the method to reflect the asserted SSL mode (e.g.,
testSslDefaultsToDisable_whenConnectionIsNull) or alternatively change the
assertion to match a NoVerify expectation; update the method declaration and any
references to testSslDefaultsToNoVerify_whenConnectionIsNull so the name and
asserted behavior (encrypt=false / DISABLE) are aligned.
| StepVerifier.create(dsConnectionMono) | ||
| .assertNext(hikariDataSource -> { | ||
| assertNotNull(hikariDataSource); | ||
| assertTrue(hikariDataSource.getJdbcUrl().contains("encrypt=false")); | ||
| }) | ||
| .verifyComplete(); |
There was a problem hiding this comment.
Test expectation conflicts with current null-guard behavior.
This assertion expects datasourceCreate to complete, but MssqlPlugin.addSslOptionsToUrlBuilder(...) currently throws when connection is null. Unless the fallback fix is included in this stack, this test will fail before reaching the JDBC URL assertion.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In
`@app/server/appsmith-plugins/mssqlPlugin/src/test/java/com/external/plugins/MssqlPluginTest.java`
around lines 784 - 789, The test expects datasource creation to complete even
when the incoming connection is null, but MssqlPlugin.addSslOptionsToUrlBuilder
currently throws on a null connection; change addSslOptionsToUrlBuilder to
null-guard the connection parameter (e.g., if connection == null return the
original URLBuilder or a builder with default/no-op SSL options) so it does not
throw, ensuring datasourceCreate/dsConnectionMono can complete and the test in
MssqlPluginTest that asserts the JDBC URL contains "encrypt=false" can proceed;
locate and update the addSslOptionsToUrlBuilder method (and any callers in
datasourceCreate) to handle null safely without altering other behavior.
Summary
Adds a regression test for the MSSQL SSL fallback fix.
This test verifies that when the DatasourceConfiguration connection object is null, the plugin gracefully defaults to encrypt=false instead of throwing an exception.
Why this test matters
This test validates the outermost null-guard branch in addSslOptionsToUrlBuilder() and prevents regressions where missing connection configuration could crash datasource creation.
Fixes #41627
Summary by CodeRabbit