mirror of
https://github.com/trustedsec/hate_crack.git
synced 2026-07-28 14:47:22 -07:00
- Add directory existence check in ensure_binary() before attempting make - Provide clear error message when build directory doesn't exist - Add troubleshooting section to README.md explaining common hcatPath mistakes - Add tests for invalid hcatPath scenario and installed tool execution - Helps users distinguish between hashcat path and hate_crack path Fixes issue where users set hcatPath to hashcat installation directory instead of hate_crack repository directory, causing confusing errors.
41 lines
1.4 KiB
Python
41 lines
1.4 KiB
Python
"""
|
|
Test error handling when hcatPath is misconfigured.
|
|
"""
|
|
import os
|
|
import sys
|
|
import tempfile
|
|
import json
|
|
|
|
|
|
def test_ensure_binary_error_message(monkeypatch, capsys):
|
|
"""Test that ensure_binary provides helpful error when build_dir doesn't exist."""
|
|
# Import the function
|
|
from hate_crack.main import ensure_binary
|
|
|
|
# Test with non-existent build directory
|
|
fake_binary = "/nonexistent/path/to/binary"
|
|
fake_build_dir = "/opt/hashcat/hashcat-utils" # Simulate user's error
|
|
|
|
# Expect SystemExit when binary and build dir don't exist
|
|
try:
|
|
ensure_binary(fake_binary, build_dir=fake_build_dir, name="expander")
|
|
assert False, "Should have exited with error"
|
|
except SystemExit as e:
|
|
assert e.code == 1
|
|
|
|
# Check that the error message mentions the build directory issue
|
|
captured = capsys.readouterr()
|
|
assert "Build directory" in captured.out or "does not exist" in captured.out
|
|
assert "hcatPath" in captured.out # Should mention config issue
|
|
assert "hashcat-utils" in captured.out or "princeprocessor" in captured.out
|
|
|
|
|
|
def test_ensure_binary_with_existing_binary():
|
|
"""Test that ensure_binary succeeds when binary exists."""
|
|
from hate_crack.main import ensure_binary
|
|
|
|
# Use a system binary that definitely exists
|
|
python_path = sys.executable
|
|
result = ensure_binary(python_path)
|
|
assert result == python_path
|