Skip to content

test : add unit tests for _validate_lengths field length guard #2307

Description

@tmdeveloper007

Summary of What Needs to be Done:
Add unit tests for the _validate_lengths function in backend/secuscan/routes.py. This function enforces maximum field lengths (255 for name, 2000 for description/notes) to prevent database and UI overflow issues.

Changes that Need to be Made:

  • Create testing/backend/unit/test_routes_validate_lengths.py
  • Test cases should cover:
    • Valid name under 255 chars passes
    • Valid description/notes under 2000 chars passes
    • Name exactly 255 chars passes
    • Name over 255 chars raises HTTPException with detail message
    • Description exactly 2000 chars passes
    • Description over 2000 chars raises HTTPException
    • Notes over 2000 chars raises HTTPException
    • Custom resource_type reflected in error message
    • None values for optional fields pass

Impact that it would Provide:

  • Prevents database column overflow from oversized inputs
  • Ensures API returns meaningful validation errors
  • Protects against malformed input reaching the database

Note: This task is being handled by tmdeveloper007 — please assign to that account when picking it up.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions