potpie
potpie copied to clipboard
Add email validation to remove_access and improve test coverage
Summary
This PR fixes #347 by enforcing email validation across all Shared Access APIs and adding comprehensive test coverage.
Changes
- Add email validation to
ShareChatService.remove_access() - Add 18 unit tests for
ShareChatService, covering:- Valid and invalid email formats in
share_chatandremove_access - Edge cases: empty emails, whitespace, malformed formats
- Error handling: non-existent conversations and unauthorized access
- Valid and invalid email formats in
- Add 30+ unit tests for
email_helper.is_valid_email() - Ensure consistent validation across all sharing endpoints
Test Coverage
The tests include:
- Valid email formats (dots, plus signs, numbers, subdomains, etc.)
- Invalid formats (missing @, domain, TLD, spaces, invalid characters, etc.)
- Edge cases (very long emails, empty strings, whitespace-only, etc.)
Summary by CodeRabbit
-
Bug Fixes
- Stricter email validation for sharing and access removal; invalid addresses now return clear 400 errors before any changes.
- Ensures atomic operations: if any email is invalid, no updates are made.
-
Documentation
- Expanded endpoint docs detailing email rules, error cases, and atomic behavior.
-
Tests
- Comprehensive tests for valid/invalid email formats and share/remove access flows to ensure correct behavior and prevent partial updates.