mirror of
https://github.com/trustedsec/hate_crack.git
synced 2026-04-28 12:03:11 -07:00
hcatPath now exclusively points to the hashcat install directory and is auto-discovered from PATH when not configured. hate_path is resolved from the package directory (installed) or repo root (development) with no auto-discovery. Extracted vendor-assets/clean-vendor Makefile targets to deduplicate the install logic. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
42 lines
1.4 KiB
Python
42 lines
1.4 KiB
Python
"""
|
|
Test error handling when hcatPath is misconfigured.
|
|
"""
|
|
|
|
import os
|
|
import sys
|
|
import tempfile
|
|
|
|
|
|
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"
|
|
with tempfile.TemporaryDirectory() as tmpdir:
|
|
fake_build_dir = os.path.join(tmpdir, "hashcat-utils")
|
|
|
|
# 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 "make install" 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
|