[test-improver] Add DatabaseHelper bug-pin and functional tests (11 tests)#79
Draft
github-actions[bot] wants to merge 1 commit into
Draft
Conversation
- Document SQL injection vulnerabilities in searchTasks and getTasksByUser - Document non-portable empty IN clause in deleteTasks([]) - Verify basic CRUD operations: searchTasks, updateTaskStatus, deleteTasks Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
15 tasks
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
🤖 Test Improver — automated AI assistant focused on improving tests.
Goal & Rationale
DatabaseHelperis the project's raw JDBC layer with zero test coverage. It contains several well-commented security vulnerabilities and a portability bug that are completely invisible without tests. This PR adds 11 tests that document both the happy-path behaviour and the known defects.Approach
Used
@SpringBootTestso that JPA/Hibernate creates the full H2 schema before the raw JDBC calls run. The Spring-managed datasource and theDatabaseHelperstatic connection share the samejdbc:h2:mem:taskflowin-memory database, so inserts viaTaskRepositoryare immediately visible toDatabaseHelperqueries.Tests added (
DatabaseHelperTest.java)getConnection_returnsOpenConnectiongetConnection_reusesSameConnectionsearchTasks_matchesByTitlesearchTasks_noMatch_returnsEmptyListsearchTasks_sqlInjection_BUG_returnsAllRows' OR '1'='1injection returns all rowsgetTasksByUser_returnsTasksForAssigneeupdateTaskStatus_existingTask_returnsTruetrueon successful updateupdateTaskStatus_nonExistentId_returnsFalsefalsewhen id not founddeleteTasks_singleId_deletesRowdeleteTasks_emptyList_BUG_returnsZeroInH2IN ()clause: H2 silently returns 0, but MySQL/PostgreSQL throw syntax errordeleteTasks_multipleIds_deletesAllBug-pin highlights
SQL injection in
searchTasks(andgetTasksByUser,getProjectStats): string concatenation into SQL statements. The testsearchTasks_sqlInjection_BUG_returnsAllRowsdemonstrates that' OR '1'='1returns every row in the table.Non-portable empty IN clause in
deleteTasks:deleteTasks(emptyList())generatesDELETE FROM tasks WHERE id IN (). H2 accepts this gracefully (returns 0), but MySQL and PostgreSQL raise a syntax error, making the method silently broken when targeting production databases.Coverage Impact
DatabaseHelperhad 0% coverage; these 11 tests exercise all 5 public methods.Trade-offs
@SpringBootTest(slow context load), but this is the only practical way to get the schema without duplicating DDLPreparedStatementTest Status
(Pre-existing failures on
main—DateUtilsTest.testGetQuarterandTaskServiceTest.testGetTaskStatistics— are unaffected.)Reproducibility
mvn test -Dtest=DatabaseHelperTest -BAdd this agentic workflows to your repo
To install this agentic workflow, run