Skip to content

fix(test/security): unbreak 3 src.* mock paths in secure_command_executor_test (#6987 part 1/N) - #7146

Closed
mrveiss wants to merge 0 commit into
Dev_new_guifrom
issue-6987
Closed

mrveiss wants to merge 0 commit into
Dev_new_guifrom
issue-6987

Conversation

@mrveiss

@mrveiss mrveiss commented May 7, 2026

Copy link
Copy Markdown
Owner

Summary

First slice of #6987 (the 48 broken `patch("src.*")` sites across 14 test files). Fixes 3 sites in `secure_command_executor_test.py` — security-critical test file.

Before/after

```

Before:

$ python3 -m pytest secure_command_executor_test.py::test_run_shell_command_timeout
ModuleNotFoundError: No module named 'src'

After:

$ python3 -m pytest \
autobot-backend/secure_command_executor_test.py::TestSecureCommandExecutor::test_run_shell_command_timeout \
autobot-backend/secure_command_executor_test.py::TestSecureCommandExecutor::test_run_shell_command_execution_error \
autobot-backend/secure_command_executor_test.py::TestSecureCommandExecutor::test_run_shell_command_docker_sandbox
3 passed in 1.02s
```

Fix is mechanical: drop the bogus `src.` prefix. `secure_command_executor` is importable directly via `pythonpath = autobot-backend autobot_shared` in pytest.ini.

Discovery surfaced (NOT introduced)

Running the WHOLE file shows 2 pre-existing test failures unrelated to the src.* bug — `TestSecurityPolicy.test_security_policy_initialization` and `TestSecureCommandExecutor.test_check_dangerous_patterns` both fail because `SecurityPolicy` has been refactored. Test-file rot. Filing as separate tracker.

Per #6987 issue body: "if any tests fail after the fix, those are real regressions to address" — these qualify, but separate scope.

Approach for the rest of #6987

Per-file PRs going forward — each test file may surface its own pre-existing rot when the mocks start firing. Per-file isolation lets each PR carry its own discovery follow-ups cleanly.

Closes part 1/N of #6987 (3 of 48 sites cleaned)

@github-actions

github-actions Bot commented May 7, 2026

Copy link
Copy Markdown
Contributor

✅ SSOT Configuration Compliance: Passing

🎉 No hardcoded values detected that have SSOT config equivalents!

@mrveiss mrveiss closed this May 7, 2026
mrveiss added a commit that referenced this pull request May 7, 2026
…o canonical (#7202) (#7209)

The #6987 sweep (#7146/#7153/#7160/#7176/#7181) missed 7 sites in 3 files
where the mock path utils.redis_client was wrong. utils/redis_client does
not exist as a module — patch() raises ModuleNotFoundError, hard-failing
each test.

Per-symbol resolution:
- redis_thread_safety_test.py × 4 → autobot_shared.redis_management.connection_manager.datetime
  (datetime.now() lives in connection_manager.py for idle cleanup)
- redis_prometheus_metrics_test.py × 2 → autobot_shared.monitoring.prometheus_metrics.get_metrics_manager
  (get_metrics_manager is defined there)
- config_migration_integration_test.py × 1 → drop the dead `with patch(...)` wrapper
  (target never existed; assertions don't depend on the mock)

Verification:
  python3 -m py_compile <each file>: PASS
  grep 'patch.*"utils.redis_client': 0 sites remain

Closes #7202

Co-authored-by: t <t@t>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant