imap-migration-tools/test
Nathan Moinvaziri e932190618 Add imap_session module for centralized OAuth2 refresh (#21)
* Add .claude to gitignore

* Add imap_session module for centralized OAuth2 refresh

Create new imap_session.py module that combines imap_common and
imap_oauth2 for unified session management:

- ensure_connection(): Refreshes OAuth2 token and ensures connection health
- ensure_folder_session(): Ensures connection AND folder selection

Updated backup, migrate, and restore scripts to use the new module,
simplifying the proactive token refresh pattern in process_batch
functions.

* Move is_token_expired_error to imap_oauth2 module

Relocates the OAuth2 token expiration detection function to the oauth2-specific module where it logically belongs.

* Add retry logic for auth errors during email processing

Extract single-UID processing into dedicated functions with retry capability
for recoverable authentication failures. Broadens auth error detection beyond
token expiration to include session loss and authentication failures.

* Cache Microsoft tenant discovery results

Avoids repeated OpenID Connect discovery requests for the same email domain
during OAuth2 authentication flows. Normalizes domain to lowercase for
consistent cache keys.

* Add tests for is_token_expired_error and is_auth_error

Covers token expiration, session invalidation, and authentication failure
detection with case-insensitive matching verification. Ensures non-auth
errors like connection and timeout issues are correctly excluded.

* Add tests for imap_session module

Covers ensure_connection and ensure_folder_session functions including
OAuth2 token refresh, folder selection, and error handling scenarios.
Verifies connection change detection triggers folder re-selection.

* Add tests for auth error re-raising in get_message_ids_in_folder

Verifies that authentication errors are propagated to callers for
reconnection handling while non-auth errors return empty results.
Clarifies test names to distinguish error handling behaviors.
2026-02-06 13:26:44 -05:00
..
conftest.py Add Microsoft/Google OAuth2 authentication support for IMAP 2026-01-31 20:32:59 -08:00
test_backup_imap_emails.py Add imap_session module for centralized OAuth2 refresh (#21) 2026-02-06 13:26:44 -05:00
test_compare_imap_folders.py Refactor authentication handling and improve documentation for IMAP email migration scripts 2026-01-31 20:32:59 -08:00
test_count_imap_emails.py Refactor authentication handling and improve documentation for IMAP email migration scripts 2026-01-31 20:32:59 -08:00
test_imap_common.py Add imap_session module for centralized OAuth2 refresh (#21) 2026-02-06 13:26:44 -05:00
test_imap_oauth2.py Add imap_session module for centralized OAuth2 refresh (#21) 2026-02-06 13:26:44 -05:00
test_imap_session.py Add imap_session module for centralized OAuth2 refresh (#21) 2026-02-06 13:26:44 -05:00
test_migrate_imap_emails.py Add batch Message-ID fetching for faster duplicate detection (#9) 2026-02-01 14:01:34 -05:00
test_restore_imap_emails.py Implement incremental restore with full restore option via restore cache. (#12) 2026-02-01 15:17:37 -05:00