Skip to content

test: add coverage for paths.py validation utilities#114

Merged
tjb-tech merged 1 commit intoHKUDS:mainfrom
xzq-xu:test/paths-coverage
Apr 9, 2026
Merged

test: add coverage for paths.py validation utilities#114
tjb-tech merged 1 commit intoHKUDS:mainfrom
xzq-xu:test/paths-coverage

Conversation

@xzq-xu
Copy link
Copy Markdown
Contributor

@xzq-xu xzq-xu commented Mar 31, 2026

Summary

  • Add 30 tests for clawteam/paths.py: validate_identifier and ensure_within_root are the core path-safety primitives used across store, mailbox, and workspace modules but previously had zero dedicated tests.

Test coverage includes:

validate_identifier (16 tests):

  • Valid identifiers: letters, digits, dots, hyphens, underscores
  • Invalid identifiers: slashes, backslashes, spaces, tabs, newlines, null bytes, non-ASCII (Unicode)
  • Dots-only identifiers (., ..) are accepted by the regex — path traversal is handled by ensure_within_root
  • allow_empty flag behavior
  • Custom kind parameter in error messages

ensure_within_root (7 tests):

  • Normal path joining
  • .. traversal rejection
  • Absolute segment rejection
  • Nested .. escape rejection
  • Symlink-based escape rejection
  • Return value is the unresolved join (not the resolved path)

Test plan

  • All 30 new tests pass
  • Ruff lint clean

Made with Cursor

@xzq-xu xzq-xu force-pushed the test/paths-coverage branch from 8607a88 to 5ea782c Compare April 3, 2026 03:31
validate_identifier and ensure_within_root are the core path-safety
primitives used across store, mailbox, and workspace modules but had
zero dedicated tests. Adds 30 tests covering valid/invalid identifiers,
allow_empty flag, custom error kind, path traversal via .., absolute
segments, symlink escapes, and normal join behavior.

Made-with: Cursor
@xzq-xu xzq-xu force-pushed the test/paths-coverage branch from 5ea782c to f9a3a1c Compare April 7, 2026 02:34
@tjb-tech tjb-tech merged commit 7019b26 into HKUDS:main Apr 9, 2026
7 checks 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.

2 participants