Files
hate_crack/tests/test_invalid_hcatpath.py
T
Justin Bollinger 52f8d5ee8b Fix asset path resolution: separate hashcat and hate_crack locations
BREAKING CHANGE: Corrected understanding of hcatPath configuration

- hcatPath should point to hashcat binary location (or omit if in PATH)
- hashcat-utils and princeprocessor are located in hate_crack repo
- Changed code to use hate_path for utilities instead of hcatPath
- Updated error messages to guide users correctly
- Updated README with correct configuration examples
- Asset discovery now properly uses HATE_CRACK_HOME environment variable

This fixes the issue where users had hcatPath pointing to hashcat
installation but the code was looking there for hashcat-utils.
2026-02-01 22:05:27 -05:00

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/hate_crack/hashcat-utils" # Simulate missing assets
# 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 correct issue
captured = capsys.readouterr()
assert "Build directory" in captured.out or "does not exist" in captured.out
assert "hate_crack" in captured.out.lower() # Should mention hate_crack assets
assert "HATE_CRACK_HOME" in captured.out or "repository" 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