diff --git a/tests/test_hashview.py b/tests/test_hashview.py index f8abd77..752e426 100644 --- a/tests/test_hashview.py +++ b/tests/test_hashview.py @@ -361,15 +361,29 @@ class TestHashviewAPI: assert "Cookie" in auth_headers or "uuid" in str(auth_headers) assert HASHVIEW_API_KEY in str(auth_headers) - @pytest.mark.skipif( - os.environ.get("HASHVIEW_TEST_REAL", "").lower() not in ("1", "true", "yes"), - reason="Set HASHVIEW_TEST_REAL=1 to run live Hashview list_wordlists test.", - ) def test_list_wordlists_live(self): """Live test for Hashview wordlist listing with auth headers.""" + # Only run this test if explicitly enabled + if os.environ.get("HASHVIEW_TEST_REAL", "").lower() not in ("1", "true", "yes"): + pytest.skip("Set HASHVIEW_TEST_REAL=1 to run live Hashview list_wordlists test.") + hashview_url, hashview_api_key = self._get_hashview_config() if not hashview_url or not hashview_api_key: pytest.skip("Missing hashview_url/hashview_api_key in config.json or env.") + + # Only proceed if the server is actually reachable + try: + import socket + host, port = "127.0.0.1", 5000 + sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + sock.settimeout(2) + result = sock.connect_ex((host, port)) + sock.close() + if result != 0: + pytest.skip(f"Hashview server not reachable at {host}:{port}") + except Exception as e: + pytest.skip(f"Could not check Hashview server availability: {e}") + real_api = HashviewAPI(hashview_url, hashview_api_key) wordlists = real_api.list_wordlists() assert isinstance(wordlists, list)