Skip to content

test: add pytest suite for AI assistant SQL guardrails, bump dependency pins - #6

Draft
HelloBryte wants to merge 1 commit into
mainfrom
claude/bold-noether-izyofn
Draft

test: add pytest suite for AI assistant SQL guardrails, bump dependency pins#6
HelloBryte wants to merge 1 commit into
mainfrom
claude/bold-noether-izyofn

Conversation

@HelloBryte

Copy link
Copy Markdown
Owner

Summary

Routine maintenance pass: this repo had zero test coverage, so this adds a first pytest suite for the one area that most needed it — the AI assistant's SQL guardrails — plus a few small drift/pin fixes found along the way.

  • New tests (tests/test_assistant_data.py, 15 cases, no DB needed): covers validate_sql() — the SELECT-only allowlist, destructive-keyword blocklist, and per-role table RBAC (admin vs user access to the users table) — and extract_sql_payload()'s JSON parsing of model output, including a documented edge case (a single-brace JSON object embedded in prose currently isn't extracted; multi-brace/fenced cases are).
  • Dev tooling: requirements-dev.txt (pytest) and pytest.ini; documented pytest usage in the README (English + Chinese sections).
  • Dependency pins bumped to current releases: PySide6 6.10.3 → 6.11.2, mysql-connector-python 9.4.0 → 26.7.0, python-dotenv 1.1.1 → 1.2.3 (httpx was already current at 0.28.1). The mysql-connector-python jump is a large version-number change (Oracle realigned its versioning scheme) — I verified it imports cleanly and MySQLConnectionPool/Error/cursor APIs used by this repo are unaffected, but there's no live MySQL server in this environment to run a full integration check against it.
  • Doc drift fix: utils/project_knowledge.py (the text fed into the AI assistant's prompt context) described utils/security.py as doing "password hashing and verification," but that module is actually a plain-text comparison for this experimental build. Fixed the description to match reality so the assistant doesn't misrepresent the app's security posture to users.

Test plan

  • pytest — 15/15 passing locally
  • Verified utils/assistant_data.py (and its database.db import chain) imports cleanly against mysql-connector-python==26.7.0 with no live DB (pool creation fails gracefully, as designed)
  • Full manual run of the app against a real MySQL instance (not available in this environment)

🤖 Generated with Claude Code

https://claude.ai/code/session_01GpjUyJ8dbmBvZz7EfaJYe5


Generated by Claude Code

…cy pins

- Add tests/ covering utils/assistant_data.py's validate_sql() (SELECT-only
  allowlist, destructive-keyword blocklist, per-role table RBAC) and
  extract_sql_payload() JSON parsing — previously untested despite being
  the security boundary for the AI assistant's generated SQL.
- Add requirements-dev.txt (pytest) and pytest.ini; document `pytest` usage
  in the README (English + Chinese).
- Bump requirements.txt pins to current releases: PySide6 6.11.2,
  mysql-connector-python 26.7.0, python-dotenv 1.2.3 (verified importable
  against this repo's usage; httpx already at latest).
- Fix stale doc drift in utils/project_knowledge.py: it described
  security.py as doing "password hashing" when the module is actually
  plain-text comparison for this experimental build — this text is fed
  directly into the AI assistant's prompt context.
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.

2 participants