mirror of
https://github.com/trustedsec/hate_crack.git
synced 2026-07-01 10:35:08 -07:00
fix: resolve CI test failures in ollama and hashview tests
- Mock rulesDirectory in ollama test fixture so hcatOllama doesn't fail with FileNotFoundError on CI where /path/to/hashcat/rules doesn't exist - Mock potfile path in hashview auto-merge test so found file cleanup isn't blocked by missing ~/.hashcat directory - Update pre-push hook to match CI env vars (HATE_CRACK_SKIP_INIT=1) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -587,6 +587,10 @@ class TestHashviewAPI:
|
||||
# Set up session.get to return different responses
|
||||
api.session.get.side_effect = [mock_left_response, mock_found_response]
|
||||
|
||||
# Mock potfile path so cleanup isn't blocked by missing ~/.hashcat dir
|
||||
potfile = str(tmp_path / "hashcat.potfile")
|
||||
monkeypatch.setattr("hate_crack.api.get_hcat_potfile_path", lambda: potfile)
|
||||
|
||||
# Download left hashes (should auto-download and split found for hashcat)
|
||||
left_file = tmp_path / "left_1_2.txt"
|
||||
result = api.download_left_hashes(1, 2, output_file=str(left_file))
|
||||
|
||||
@@ -42,12 +42,15 @@ def ollama_env(tmp_path):
|
||||
@contextmanager
|
||||
def ollama_globals(tmp_path, tuning="", potfile=""):
|
||||
"""Patch the hc_main globals that hcatOllama reads."""
|
||||
rules_dir = str(tmp_path / "rules")
|
||||
os.makedirs(rules_dir, exist_ok=True)
|
||||
with mock.patch.object(hc_main, "ollamaUrl", OLLAMA_URL), \
|
||||
mock.patch.object(hc_main, "ollamaModel", MODEL), \
|
||||
mock.patch.object(hc_main, "hcatBin", "/usr/bin/hashcat"), \
|
||||
mock.patch.object(hc_main, "hcatTuning", tuning), \
|
||||
mock.patch.object(hc_main, "hcatPotfilePath", potfile), \
|
||||
mock.patch.object(hc_main, "hate_path", str(tmp_path)), \
|
||||
mock.patch.object(hc_main, "rulesDirectory", rules_dir), \
|
||||
mock.patch("hate_crack.main.generate_session_id", return_value="test_session"):
|
||||
yield
|
||||
|
||||
|
||||
Reference in New Issue
Block a user