Repository navigation
[P1] Add Database Explorer read-only query regression tests - #197
Open
ahamed3620 wants to merge 1 commit into
Open
ahamed3620 wants to merge 1 commit into
ahamed3620 wants to merge 1 commit into
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
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.
Description
Add extension-local regression coverage for the Database Explorer's read-only SQL contract. Shared query validation now rejects data-modifying CTE statements as well as direct writes, and both the HTTP endpoint and canvas action use the same validated query runner.
Related Issue
Closes #164
Type of Change
Changes Made
Testing
npm run test:unit— passed; 5 test files, 58 tests.npx vitest run .github/extensions/database-explorer/query-policy.test.ts --reporter=verbose— passed; 19 Database Explorer tests.npm run lint— passed.npm run typecheck:all— passed; 37 Astro files checked with 0 errors, warnings, or hints.git diff --cached --check— passed.npm run test:e2eandnpm run buildwere not run; this change does not modify the Astro UI or site build behavior.The new
Database Explorer query policytest cases are:accepts a select query and returns fixture rows,accepts a read-only CTE and returns fixture rows,accepts a CTE with a quoted identifier and returns fixture rows,accepts comments and quoted semicolons and returns fixture rows;rejects empty input explicitly,rejects whitespace input explicitly,rejects non-string input explicitly,rejects invalid statement explicitly,rejects multiple statements explicitly,rejects unclosed SQL string explicitly,rejects unclosed comment explicitly,rejects insert statement explicitly,rejects update statement explicitly,rejects delete statement explicitly,rejects schema statement explicitly,rejects write statement after a CTE explicitly;does not execute rejected requests,preserves fixture rows and schema while enforcing the policy against SQLite, andenforces the shared policy through HTTP and canvas actions.Data Layer Changes
npm run test:unit- all tests passnpm run db:generate) for any schema change (N/A; no schema change)Frontend Changes
npm run test:e2e- all tests passdata-testidattributes to interactive elementsnpm run build)Checklist
Additional Notes
All database checks use an in-memory SQLite database; tests do not access the project database, credentials, or remote databases.