test: add null auth type SSL fallback test#41841
Conversation
WalkthroughA new unit test validates MSSQL datasource creation behavior when SSL authentication type is explicitly null. The test configures the datasource, executes plugin creation logic, and asserts the resulting JDBC connection string disables encryption as expected. ChangesMSSQL SSL null auth type validation
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 3❌ Failed checks (2 warnings, 1 inconclusive)
✅ Passed checks (2 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: 1
🧹 Nitpick comments (1)
app/server/appsmith-plugins/mssqlPlugin/src/test/java/com/external/plugins/MssqlPluginTest.java (1)
784-788: 💤 Low valueInconsistent indentation in assertion block.
The lines inside the
assertNextlambda have extra indentation. While this doesn't affect functionality, it's inconsistent with the indentation style used in other tests in this file (e.g., lines 142-146, 669-673).♻️ Align indentation with existing test style
StepVerifier.create(dsConnectionMono) .assertNext(hikariDataSource -> { - assertNotNull(hikariDataSource); - assertTrue(hikariDataSource.getJdbcUrl().contains("encrypt=false")); + assertNotNull(hikariDataSource); + assertTrue(hikariDataSource.getJdbcUrl().contains("encrypt=false")); }) .verifyComplete();🤖 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 - 788, The assertion block inside the Reactor test's .assertNext lambda has extra indentation that differs from the file's standard; locate the chain using .assertNext(hikariDataSource -> { ... }) and .verifyComplete() and reformat the lines within the lambda (the assertNotNull and assertTrue calls referencing hikariDataSource and getJdbcUrl().contains("encrypt=false")) to match the surrounding test style (remove the extra indent so the two assertions align with other tests).
🤖 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`:
- Around line 776-789: The test fails because addSslOptionsToUrlBuilder(...)
throws when Connection.getSsl().getAuthType() is null; update
addSslOptionsToUrlBuilder (used by datasourceCreate(...)) to treat a null
authType as the disabled/default case (do not throw), and build the JDBC URL
with encrypt=false in that path so the test expecting "encrypt=false" passes;
also adjust the indentation of the assertions inside the assertNext(...) lambda
in MssqlPluginTest.testSslDefaultsToDisable_whenAuthTypeIsNull to align
assertNotNull(...) and assertTrue(...).
---
Nitpick comments:
In
`@app/server/appsmith-plugins/mssqlPlugin/src/test/java/com/external/plugins/MssqlPluginTest.java`:
- Around line 784-788: The assertion block inside the Reactor test's .assertNext
lambda has extra indentation that differs from the file's standard; locate the
chain using .assertNext(hikariDataSource -> { ... }) and .verifyComplete() and
reformat the lines within the lambda (the assertNotNull and assertTrue calls
referencing hikariDataSource and getJdbcUrl().contains("encrypt=false")) to
match the surrounding test style (remove the extra indent so the two assertions
align with other tests).
🪄 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: 41087161-9bea-49e2-999b-5521118f795d
📒 Files selected for processing (1)
app/server/appsmith-plugins/mssqlPlugin/src/test/java/com/external/plugins/MssqlPluginTest.java
| @Test | ||
| public void testSslDefaultsToDisable_whenAuthTypeIsNull() { | ||
| DatasourceConfiguration dsConfig = createDatasourceConfiguration(container); | ||
| dsConfig.getConnection().getSsl().setAuthType(null); | ||
|
|
||
| Mono<HikariDataSource> dsConnectionMono = mssqlPluginExecutor.datasourceCreate(dsConfig); | ||
|
|
||
| StepVerifier.create(dsConnectionMono) | ||
| .assertNext(hikariDataSource -> { | ||
| assertNotNull(hikariDataSource); | ||
| assertTrue(hikariDataSource.getJdbcUrl().contains("encrypt=false")); | ||
| }) | ||
| .verifyComplete(); | ||
| } |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Description: Check if MssqlPlugin.java still throws exception for null authType or handles it gracefully
# Search for the null authType check in addSslOptionsToUrlBuilder
rg -n -A 8 -B 2 'addSslOptionsToUrlBuilder' app/server/appsmith-plugins/mssqlPlugin/src/main/java/com/external/plugins/MssqlPlugin.java
# Also check if there's any null-safe handling logic for authType
rg -n -C 5 'getAuthType\(\)\s*==\s*null' app/server/appsmith-plugins/mssqlPlugin/src/main/java/com/external/plugins/MssqlPlugin.javaRepository: appsmithorg/appsmith
Length of output: 1865
🏁 Script executed:
#!/bin/bash
sed -n '760,805p' app/server/appsmith-plugins/mssqlPlugin/src/test/java/com/external/plugins/MssqlPluginTest.javaRepository: appsmithorg/appsmith
Length of output: 1400
Fix failing test: null authType currently throws in MssqlPlugin
addSslOptionsToUrlBuilder(...)throwsAppsmithPluginExceptionwhengetAuthType()isnull, buttestSslDefaultsToDisable_whenAuthTypeIsNullexpectsdatasourceCreate(...)to succeed and the JDBC URL to containencrypt=false.- Minor: align the indentation of
assertNotNull(...)/assertTrue(...)inside theassertNext(...)lambda.
🤖 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 776 - 789, The test fails because addSslOptionsToUrlBuilder(...)
throws when Connection.getSsl().getAuthType() is null; update
addSslOptionsToUrlBuilder (used by datasourceCreate(...)) to treat a null
authType as the disabled/default case (do not throw), and build the JDBC URL
with encrypt=false in that path so the test expecting "encrypt=false" passes;
also adjust the indentation of the assertions inside the assertNext(...) lambda
in MssqlPluginTest.testSslDefaultsToDisable_whenAuthTypeIsNull to align
assertNotNull(...) and assertTrue(...).
Summary
Adds a regression test for the MSSQL SSL fallback fix.
This test verifies that when the SSL AuthType is null, the plugin gracefully defaults to encrypt=false instead of throwing an exception.
Why this test matters
This test validates the innermost null-guard branch in addSslOptionsToUrlBuilder() and ensures datasource creation remains robust when the SSL wrapper exists but no auth type is provided.
Fixes #41627
Summary by CodeRabbit