pryscraper/tests
cryptorugmunch 14a59708ee feat(pry): wire secrets_backend.get_secret() into PrySettings for sensitive fields
PrySettings (settings.py) was reading sensitive values (api_key, *_api_key,
webhook_secret) only from PRY_* env vars. The existing secrets_backend
(used by x402.py and auth.py for jwt_secret) supports gopass as the
default backend, so secrets never needed to live in .env.

This commit:
- Adds PrySettings._apply_secrets_backend() in model_post_init
- For each sensitive field with empty current value, calls
  secrets_backend.get_secret(name) and uses the result
- Priority order: secrets_backend.get_secret > env var > field default
- This means `gopass insert -m pry/api_key` now sets the API key
  without touching .env or environment

Tests added (tests/test_secrets_backend_integration.py):
- test_settings_pulls_from_secrets_backend: confirms gopass fills empty fields
- test_x402_constants_come_from_secrets_backend: confirms x402.py honors gopass
- test_settings_does_not_override_set_env: env beats gopass when both set

Tests updated (tests/conftest.py):
- Session-scope fixture sets PRY_SECRET_BACKEND=env to prevent test runs from
  pulling real gopass secrets (which would cause the auth middleware to
  reject unauthenticated test requests)
- Per-test fixture zeros settings.settings.api_key for in-process tests

Audit item 12. Tests: 623 passed, 1 skipped (pre-existing /ready failure
unrelated to this change).
2026-07-06 11:01:08 +02:00
..
__init__.py chore(license): re-license to dual MIT (core) + BSL 1.1 (stealth) 2026-07-02 19:59:18 +02:00
conftest.py feat(pry): wire secrets_backend.get_secret() into PrySettings for sensitive fields 2026-07-06 11:01:08 +02:00
test_adaptive.py chore(license): re-license to dual MIT (core) + BSL 1.1 (stealth) 2026-07-02 19:59:18 +02:00
test_advanced_features.py chore(license): re-license to dual MIT (core) + BSL 1.1 (stealth) 2026-07-02 19:59:18 +02:00
test_advanced_scraping.py chore(lint): auto-fix 253 of 283 ruff issues (F401, I001, E402, RUF100, UP037, SIM105) 2026-07-02 21:51:25 +02:00
test_agency.py chore(license): re-license to dual MIT (core) + BSL 1.1 (stealth) 2026-07-02 19:59:18 +02:00
test_ai_plugin.py feat(logging): add structlog + JSON logging (CONVENTIONS.md Part 5) 2026-07-02 20:55:41 +02:00
test_alerter.py chore(license): re-license to dual MIT (core) + BSL 1.1 (stealth) 2026-07-02 19:59:18 +02:00
test_api.py feat(pry): phase 0 — split routers, add tests, apify schema, pry api key (#5) 2026-07-03 03:43:02 +02:00
test_api_integration.py feat(pry): production readiness pass — apify actor, async db, retry wiring, tests, observability, mypy 2026-07-03 14:41:41 +02:00
test_api_mcp.py feat(pry): production readiness pass — apify actor, async db, retry wiring, tests, observability, mypy 2026-07-03 14:41:41 +02:00
test_api_mcp_x402.py fix(lint): resolve remaining ruff errors and unblock MCP SSE test (#1) 2026-07-02 23:18:40 +02:00
test_api_scraping.py feat(db): add Alembic migrations (#6) 2026-07-03 02:22:33 +02:00
test_api_surface_snapshot.py style(tests): fix ruff lint errors in new snapshot/fallback/retry tests 2026-07-03 15:36:59 +02:00
test_api_templates.py feat(db): add Alembic migrations (#6) 2026-07-03 02:22:33 +02:00
test_apify_schema.py feat(db): add Alembic migrations (#6) 2026-07-03 02:22:33 +02:00
test_auth_connector.py chore(license): re-license to dual MIT (core) + BSL 1.1 (stealth) 2026-07-02 19:59:18 +02:00
test_block_detector.py chore(license): re-license to dual MIT (core) + BSL 1.1 (stealth) 2026-07-02 19:59:18 +02:00
test_cache.py chore(license): re-license to dual MIT (core) + BSL 1.1 (stealth) 2026-07-02 19:59:18 +02:00
test_camoufox.py chore(lint): auto-fix 253 of 283 ruff issues (F401, I001, E402, RUF100, UP037, SIM105) 2026-07-02 21:51:25 +02:00
test_commerce_sync.py chore(license): re-license to dual MIT (core) + BSL 1.1 (stealth) 2026-07-02 19:59:18 +02:00
test_compliance.py chore(license): re-license to dual MIT (core) + BSL 1.1 (stealth) 2026-07-02 19:59:18 +02:00
test_costing.py chore(license): re-license to dual MIT (core) + BSL 1.1 (stealth) 2026-07-02 19:59:18 +02:00
test_crm_sync.py chore(license): re-license to dual MIT (core) + BSL 1.1 (stealth) 2026-07-02 19:59:18 +02:00
test_db.py feat(db): add Alembic migrations (#6) 2026-07-03 02:22:33 +02:00
test_destinations.py chore(license): re-license to dual MIT (core) + BSL 1.1 (stealth) 2026-07-02 19:59:18 +02:00
test_email_scraper.py chore(license): re-license to dual MIT (core) + BSL 1.1 (stealth) 2026-07-02 19:59:18 +02:00
test_enrichment.py chore(license): re-license to dual MIT (core) + BSL 1.1 (stealth) 2026-07-02 19:59:18 +02:00
test_extractor.py chore(license): re-license to dual MIT (core) + BSL 1.1 (stealth) 2026-07-02 19:59:18 +02:00
test_fallback_integration.py style(tests): fix ruff lint errors in new snapshot/fallback/retry tests 2026-07-03 15:36:59 +02:00
test_freshness.py chore(license): re-license to dual MIT (core) + BSL 1.1 (stealth) 2026-07-02 19:59:18 +02:00
test_gdpr.py chore(license): re-license to dual MIT (core) + BSL 1.1 (stealth) 2026-07-02 19:59:18 +02:00
test_infrastructure.py chore(lint): auto-fix 253 of 283 ruff issues (F401, I001, E402, RUF100, UP037, SIM105) 2026-07-02 21:51:25 +02:00
test_intelligence.py feat(sql): migrate intelligence, monitor, and referrals to SQLAlchemy (#4) 2026-07-03 01:29:59 +02:00
test_jobqueue.py chore(license): re-license to dual MIT (core) + BSL 1.1 (stealth) 2026-07-02 19:59:18 +02:00
test_lazy_load.py chore(license): re-license to dual MIT (core) + BSL 1.1 (stealth) 2026-07-02 19:59:18 +02:00
test_llm_fallback.py fix(lint): resolve remaining ruff errors and unblock MCP SSE test (#1) 2026-07-02 23:18:40 +02:00
test_llm_providers.py chore(lint): auto-fix 253 of 283 ruff issues (F401, I001, E402, RUF100, UP037, SIM105) 2026-07-02 21:51:25 +02:00
test_logging_config.py fix(lint): resolve remaining ruff errors and unblock MCP SSE test (#1) 2026-07-02 23:18:40 +02:00
test_markdown_gen.py chore(license): re-license to dual MIT (core) + BSL 1.1 (stealth) 2026-07-02 19:59:18 +02:00
test_marketplace.py chore(lint): auto-fix 253 of 283 ruff issues (F401, I001, E402, RUF100, UP037, SIM105) 2026-07-02 21:51:25 +02:00
test_mcp_production.py refactor(mcp): modernize imports to use pry_mcp sub-package directly 2026-07-03 15:18:11 +02:00
test_monitor.py feat(sql): migrate intelligence, monitor, and referrals to SQLAlchemy (#4) 2026-07-03 01:29:59 +02:00
test_network.py chore(license): re-license to dual MIT (core) + BSL 1.1 (stealth) 2026-07-02 19:59:18 +02:00
test_parser.py chore(license): re-license to dual MIT (core) + BSL 1.1 (stealth) 2026-07-02 19:59:18 +02:00
test_pipeline.py chore(license): re-license to dual MIT (core) + BSL 1.1 (stealth) 2026-07-02 19:59:18 +02:00
test_pipelines.py chore(license): re-license to dual MIT (core) + BSL 1.1 (stealth) 2026-07-02 19:59:18 +02:00
test_proxy_manager.py chore(license): re-license to dual MIT (core) + BSL 1.1 (stealth) 2026-07-02 19:59:18 +02:00
test_quality.py chore(license): re-license to dual MIT (core) + BSL 1.1 (stealth) 2026-07-02 19:59:18 +02:00
test_ratelimit.py chore(license): re-license to dual MIT (core) + BSL 1.1 (stealth) 2026-07-02 19:59:18 +02:00
test_real_features.py chore(license): re-license to dual MIT (core) + BSL 1.1 (stealth) 2026-07-02 19:59:18 +02:00
test_reconciliation.py chore(license): re-license to dual MIT (core) + BSL 1.1 (stealth) 2026-07-02 19:59:18 +02:00
test_referrals.py feat(sql): migrate intelligence, monitor, and referrals to SQLAlchemy (#4) 2026-07-03 01:29:59 +02:00
test_reports.py chore(license): re-license to dual MIT (core) + BSL 1.1 (stealth) 2026-07-02 19:59:18 +02:00
test_resilience.py feat(resilience): circuit breakers and per-domain tier memory 2026-07-03 11:49:33 +02:00
test_retry.py style(tests): fix ruff lint errors in new snapshot/fallback/retry tests 2026-07-03 15:36:59 +02:00
test_review.py chore(license): re-license to dual MIT (core) + BSL 1.1 (stealth) 2026-07-02 19:59:18 +02:00
test_scraper.py chore(license): re-license to dual MIT (core) + BSL 1.1 (stealth) 2026-07-02 19:59:18 +02:00
test_sdk.py chore(license): re-license to dual MIT (core) + BSL 1.1 (stealth) 2026-07-02 19:59:18 +02:00
test_secrets_backend.py fix(lint): resolve remaining ruff errors and unblock MCP SSE test (#1) 2026-07-02 23:18:40 +02:00
test_secrets_backend_integration.py feat(pry): wire secrets_backend.get_secret() into PrySettings for sensitive fields 2026-07-06 11:01:08 +02:00
test_seo_monitor.py chore(license): re-license to dual MIT (core) + BSL 1.1 (stealth) 2026-07-02 19:59:18 +02:00
test_settings.py refactor(settings): unify config.py, mconfig.py, and settings.py into single PrySettings 2026-07-03 05:04:29 +02:00
test_shadow_dom.py chore(license): re-license to dual MIT (core) + BSL 1.1 (stealth) 2026-07-02 19:59:18 +02:00
test_structure_monitor.py feat(sql): migrate intelligence, monitor, and referrals to SQLAlchemy (#4) 2026-07-03 01:29:59 +02:00
test_templates.py chore(license): re-license to dual MIT (core) + BSL 1.1 (stealth) 2026-07-02 19:59:18 +02:00
test_training_data.py chore(license): re-license to dual MIT (core) + BSL 1.1 (stealth) 2026-07-02 19:59:18 +02:00
test_ultimate_scraper.py style(tests): fix ruff lint errors in new snapshot/fallback/retry tests 2026-07-03 15:36:59 +02:00
test_url_guard.py feat(url_guard): SSRF and path traversal guard for scraper inputs 2026-07-03 12:00:40 +02:00
test_x402_mcp_spec.py refactor(mcp): modernize imports to use pry_mcp sub-package directly 2026-07-03 15:18:11 +02:00