Skip to content

test: reject a malformed JDBC URL - #347

Merged
fjlopez merged 5 commits into
devfrom
test/314-jdbc-url-typo
Oct 21, 2026
Merged

fjlopez merged 5 commits into
devfrom
test/314-jdbc-url-typo

Conversation

@fjlopez

@fjlopez fjlopez commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

Why

DatabaseConnectionTesterServiceTest and both connection-test HTTP methods used jdb:h2:mem:testdb. That string is not a JDBC URL. DriverManager rejects it with "No suitable driver" before H2 parses it, so the malformed-URL test passed for that reason. The GET fixture also set the connection name instead of the user. The same jdbc:h2:mem:testdb URL with a null user connects, so the GET 400 depended on the missing c.

The unit test locks the SQLException. GET and POST were both asserting that same rejection.

What changed

  • The malformed URL is jdbc:h2:mem:testdb;MODE=NOT_A_MODE. The unit test requires an SQLException whose message names the unknown mode.
  • POST /api/connections/test returns HTTP 400 for that URL.
  • GET /api/connections/{id}/test no longer repeats that rejection. It still covers a missing driver, a valid connection, 404, and 401.
  • [Unreleased] ### Changed records the test change with Tests and #314.

Scope

Test fixtures and the changelog. Production code is unchanged.

Blast Radius

DatabaseConnectionTesterServiceTest and DatabaseConnectionControllerTest. The tester and both HTTP routes behave as before.

Verification

  • DatabaseConnectionTesterServiceTest and DatabaseConnectionControllerTest passed.
  • The pre-commit hook ran spotlessCheck, the full ./gradlew test suite, and jacocoTestReport. All passed.

Fixes #314

@fjlopez
fjlopez merged commit dec5d25 into dev Oct 21, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant