diff --git a/.github/workflows/e2e-happy-path.yml b/.github/workflows/e2e-happy-path.yml index 46f1221f..1f9a711f 100644 --- a/.github/workflows/e2e-happy-path.yml +++ b/.github/workflows/e2e-happy-path.yml @@ -67,6 +67,16 @@ jobs: working-directory: frontend run: mkdir -p test-results + - name: Ensure testmail.app domain is allowlisted + run: | + # testmail.app is used for E2E testing but gets flagged as disposable + # by external APIs. Ensure it's in the allowlist before the test runs. + curl -sf -X POST \ + "https://api.nomadkaraoke.com/api/admin/rate-limits/blocklists/allowlisted-domains" \ + -H "X-Admin-Token: ${{ secrets.E2E_ADMIN_TOKEN }}" \ + -H "Content-Type: application/json" \ + -d '{"domain": "inbox.testmail.app"}' || echo "Warning: failed to allowlist domain (may already exist)" + - name: Refresh E2E session token (when use_test_token enabled) id: refresh_token if: inputs.use_test_token == true diff --git a/backend/services/email_validation_service.py b/backend/services/email_validation_service.py index 574e4a11..a39aa4f5 100644 --- a/backend/services/email_validation_service.py +++ b/backend/services/email_validation_service.py @@ -212,9 +212,11 @@ class EmailValidationService: effective_domains = (external | manual) - allowlisted else: # Old data model (pre-migration): use disposable_domains + defaults + allowlisted = set() effective_domains = set(data.get("disposable_domains", [])) | DEFAULT_DISPOSABLE_DOMAINS config = { "disposable_domains": effective_domains, + "allowlisted_domains": allowlisted, "blocked_emails": set(data.get("blocked_emails", [])), "blocked_ips": set(data.get("blocked_ips", [])), "verified_clean_domains": data.get("verified_clean_domains", {}), @@ -222,6 +224,7 @@ class EmailValidationService: else: config = { "disposable_domains": DEFAULT_DISPOSABLE_DOMAINS.copy(), + "allowlisted_domains": set(), "blocked_emails": set(), "blocked_ips": set(), "verified_clean_domains": {}, @@ -267,6 +270,12 @@ class EmailValidationService: if domain in config["disposable_domains"]: return True + # Tier 1.5: Explicitly allowlisted domains skip external API checks. + # Without this, external APIs can override admin allowlist decisions + # (e.g. inbox.testmail.app is a legitimate testing domain we allow). + if domain in config.get("allowlisted_domains", set()): + return False + # Tier 2: Recently verified clean? Skip API calls if self._is_domain_verified_clean(domain, config): return False diff --git a/backend/tests/test_email_validation_service.py b/backend/tests/test_email_validation_service.py index f3f780de..622bffb9 100644 --- a/backend/tests/test_email_validation_service.py +++ b/backend/tests/test_email_validation_service.py @@ -542,6 +542,41 @@ class TestExternalAPIChecks: # No HTTP calls should have been made mock_client.return_value.get.assert_not_called() + # ========================================================================= + # Allowlisted domain bypass (Tier 1.5) + # ========================================================================= + + def test_allowlisted_domain_skips_external_api_checks(self, mock_db): + """Allowlisted domains should skip external API checks entirely. + + Regression test: inbox.testmail.app was getting flagged by DeBounce + even though it was in the allowlist, because external API calls ran + after the static blocklist check but before checking the allowlist. + """ + from backend.services.email_validation_service import EmailValidationService + mock_doc = Mock() + mock_doc.exists = True + mock_doc.to_dict.return_value = { + "external_domains": ["yopmail.com"], + "manual_domains": ["inbox.testmail.app"], # auto-learned by DeBounce + "allowlisted_domains": ["inbox.testmail.app"], # but also allowlisted + "blocked_emails": [], + "blocked_ips": [], + "verified_clean_domains": {}, + } + mock_db.collection.return_value.document.return_value.get.return_value = mock_doc + EmailValidationService._blocklist_cache = None + EmailValidationService._blocklist_cache_time = None + service = EmailValidationService(db=mock_db) + + with patch( + "backend.services.email_validation_service._get_http_client" + ) as mock_client: + result = service.is_disposable_domain("user@inbox.testmail.app") + assert result is False + # No HTTP calls should have been made — allowlist bypasses external APIs + mock_client.return_value.get.assert_not_called() + # ========================================================================= # DeBounce API # ========================================================================= diff --git a/pyproject.toml b/pyproject.toml index ab1281dc..b8b8a2d7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "karaoke-gen" -version = "0.153.5" +version = "0.153.6" description = "Generate karaoke videos with synchronized lyrics. Handles the entire process from downloading audio and lyrics to creating the final video with title screens." authors = ["Andrew Beveridge "] license = "MIT"