From 40a7ee171832e9ea62ae257072a2231645240500 Mon Sep 17 00:00:00 2001 From: JD Babac Date: Wed, 14 May 2025 22:15:57 +0800 Subject: [PATCH 1/3] Remove support for MD5 signing. --- domaintools/api.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/domaintools/api.py b/domaintools/api.py index 22a0849..5df9c6c 100644 --- a/domaintools/api.py +++ b/domaintools/api.py @@ -1,5 +1,5 @@ from datetime import datetime, timedelta, timezone -from hashlib import sha1, sha256, md5 +from hashlib import sha1, sha256 from hmac import new as hmac import re @@ -24,7 +24,7 @@ from domaintools.utils import validate_feeds_parameters -AVAILABLE_KEY_SIGN_HASHES = ["sha1", "sha256", "md5"] +AVAILABLE_KEY_SIGN_HASHES = ["sha1", "sha256"] def delimited(items, character="|"): From 9465c9ed41ed3bdf6a17a8336ca0180d2775eb8d Mon Sep 17 00:00:00 2001 From: JD Babac Date: Wed, 14 May 2025 22:16:26 +0800 Subject: [PATCH 2/3] Add and fix some failing tests. --- tests/test_api.py | 11 ++++++++++- tests/test_cli.py | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/tests/test_api.py b/tests/test_api.py index 3876d02..a54f1db 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -342,11 +342,20 @@ def test_exception_handling(): API("notauser", "notakey").domain_search("amazon").data() with pytest.raises( ValueError, - match=r"Invalid value 'notahash' for 'key_sign_hash'. Values available are sha1,sha256,md5", + match=r"Invalid value 'notahash' for 'key_sign_hash'. Values available are sha1,sha256", ): API("notauser", "notakey", always_sign_api_key=True, key_sign_hash="notahash").domain_search("amazon") +@vcr.use_cassette +def test_md5_is_not_supported(): + with pytest.raises( + ValueError, + match=r"Invalid value 'md5' for 'key_sign_hash'. Values available are sha1,sha256", + ): + API("notauser", "notakey", always_sign_api_key=True, key_sign_hash="md5").domain_search("amazon") + + @vcr.use_cassette def test_rate_limiting(): domain_searches = ["google"] * 31 diff --git a/tests/test_cli.py b/tests/test_cli.py index eb3a8b3..7c84c6d 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -27,7 +27,7 @@ def test_valid_command(): def test_invalid_command(): result = runner.invoke(dt_cli, ["test_invalid_command"]) - assert "No such command 'test_invalid_command'." in result.stdout + assert "No such command 'test_invalid_command'." in result.stderr def test_no_creds_file_not_found(): From 81654abfbd841e6eb861b053b9d0a2a5a09f6ba7 Mon Sep 17 00:00:00 2001 From: JD Babac Date: Wed, 14 May 2025 22:34:22 +0800 Subject: [PATCH 3/3] Peg click version to v.8.1.8 to fix failing test in test_cli. --- tests/test_cli.py | 2 +- tox.ini | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/tests/test_cli.py b/tests/test_cli.py index 7c84c6d..eb3a8b3 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -27,7 +27,7 @@ def test_valid_command(): def test_invalid_command(): result = runner.invoke(dt_cli, ["test_invalid_command"]) - assert "No such command 'test_invalid_command'." in result.stderr + assert "No such command 'test_invalid_command'." in result.stdout def test_no_creds_file_not_found(): diff --git a/tox.ini b/tox.ini index e7c06b0..a2a042e 100644 --- a/tox.ini +++ b/tox.ini @@ -1,12 +1,16 @@ [tox] -envlist=py39, py310, py311 +envlist = + py39, + py310, + py311 skip_missing_interpreters=true [testenv] -passenv= +passenv = TEST_USER TEST_KEY -deps= +deps = + click==8.1.8 pytest pytest-cov httpx @@ -14,5 +18,6 @@ deps= rich typer . -commands=py.test -s --capture=sys --cov=domaintools --cov=domaintools_async tests +commands = + py.test -s --capture=sys --cov=domaintools --cov=domaintools_async tests coverage html