Skip to content

[TESTING] Add edge case and boundary condition tests #47

@7tg

Description

@7tg

Description

Missing test coverage for edge cases, boundary conditions, and special inputs.

Missing Boundary Tests

Integer Boundaries

  • test_get_with_max_int_id - sys.maxsize as ID
  • test_get_with_negative_id - Negative ID values
  • test_list_with_excessive_limit - limit=999999 (DoS potential)
  • test_list_with_excessive_offset - offset=999999

String Boundaries

  • test_create_max_length_field - Exactly max_length characters
  • test_create_exceeds_max_length - max_length + 1 characters
  • test_create_with_unicode_emoji - Emoji in text fields
  • test_filter_with_very_long_value - 10000+ character filter value

Empty/Null Inputs

  • test_list_with_empty_filter_value - {"filters": {"name": ""}}
  • test_list_with_null_filter_value - {"filters": {"id": null}}
  • test_create_null_on_non_nullable - Null on required field
  • test_order_by_empty_list - {"order_by": []}
  • test_search_with_whitespace_only - {"search": " "}

Special Characters

  • test_filter_with_sql_wildcards - % and _ in filter values
  • test_search_with_regex_chars - .*+?[] in search term
  • test_filter_with_null_bytes - \x00 in values
  • test_filter_with_unicode_rtl - Arabic/Hebrew text

Example Test

@pytest.mark.django_db
@pytest.mark.asyncio
async def test_list_with_excessive_limit(token, async_client):
    """Verify large limit values are handled safely."""
    response = await async_client.post(
        "/mcp/",
        json={
            "method": "tools/call",
            "params": {
                "name": "list_article",
                "arguments": {"limit": 999999}
            }
        },
        headers={"Authorization": f"Bearer {token.token}"}
    )
    data = response.json()
    # Should either cap the limit or return reasonable error
    assert response.status_code == 200 or "error" in data

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions