Skip to content

Commit c4b85b2

Browse files
committed
add test cases for ip feeds
1 parent 7e1fdc9 commit c4b85b2

5 files changed

Lines changed: 270 additions & 2 deletions

File tree

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.9.0
1+
2.8.1

domaintools/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@
2020
2121
"""
2222

23-
current = "2.9.0"
23+
current = "2.8.1"
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
interactions:
2+
- request:
3+
body: ''
4+
headers:
5+
accept:
6+
- '*/*'
7+
accept-encoding:
8+
- gzip, deflate
9+
connection:
10+
- keep-alive
11+
host:
12+
- api.domaintools.com
13+
user-agent:
14+
- python-httpx/0.28.1
15+
method: GET
16+
uri: https://api.domaintools.com/v1/account?app_name=python_wrapper&app_version=2.8.1
17+
response:
18+
body:
19+
string: '{"timestamp":"2025-01-06T15:30:42Z","ip":"192.0.2.1","asn":12345,"organization":"Example
20+
Hosting LLC","city":"Amsterdam","country":"NL","latitude":52.3676,"longitude":4.9041,"pdns_resolutions":47,"bad_pdns_resolutions":42,"total_domains":183,"zerolist_domains":0,"zerolist_ip":false,"third_party_threats":38,"all_threats_combined_count":45,"all_threats_combined_percent":91.2,"all_threats_percent":91.2,"combined_phishing_percent":72.1,"combined_malware_percent":85.3,"combined_spam_percent":61.4,"malicious_phishing":28,"malicious_malware":33,"malicious_spam":22,"percent_phishing":57.4,"percent_malware":67.8,"percent_spam":45.2,"compromised_phishing":6,"compromised_malware":8,"compromised_spam":4,"predicted_phishing":7,"predicted_malware":9,"predicted_spam":5}
21+
22+
{"timestamp":"2025-01-06T15:30:45Z","ip":"192.0.2.2","asn":67890,"organization":"Bulletproof
23+
Networks Inc","city":"Moscow","country":"RU","latitude":55.7558,"longitude":37.6173,"pdns_resolutions":31,"bad_pdns_resolutions":29,"total_domains":94,"zerolist_domains":0,"zerolist_ip":false,"third_party_threats":25,"all_threats_combined_count":30,"all_threats_combined_percent":88.7,"all_threats_percent":88.7,"combined_phishing_percent":65.9,"combined_malware_percent":79.4,"combined_spam_percent":55.3,"malicious_phishing":19,"malicious_malware":24,"malicious_spam":15,"percent_phishing":48.9,"percent_malware":61.7,"percent_spam":38.3,"compromised_phishing":4,"compromised_malware":5,"compromised_spam":3,"predicted_phishing":6,"predicted_malware":7,"predicted_spam":4}
24+
25+
'
26+
headers:
27+
Cache-Control:
28+
- no-store, no-cache, must-revalidate
29+
Connection:
30+
- keep-alive
31+
Content-Encoding:
32+
- gzip
33+
Content-Security-Policy:
34+
- 'default-src * data: blob: ''unsafe-eval'' ''unsafe-inline'''
35+
Content-Type:
36+
- application/json;charset=utf-8
37+
Date:
38+
- Mon, 28 Apr 2025 18:00:47 GMT
39+
Expires:
40+
- Thu, 19 Nov 1981 08:52:00 GMT
41+
Pragma:
42+
- no-cache
43+
Set-Cookie:
44+
- dtsession=fsli3ccledtncc8l0agq08ceif; expires=Wed, 28-May-2025 18:00:47 GMT;
45+
Max-Age=2592000; path=/; domain=.domaintools.test; secure; HttpOnly
46+
Strict-Transport-Security:
47+
- max-age=31536000; includeSubDomains
48+
Transfer-Encoding:
49+
- chunked
50+
Vary:
51+
- Accept-Encoding
52+
X-API-USERNAME:
53+
- jbabac
54+
X-GROUP-ID:
55+
- '1117'
56+
X-Powered-By:
57+
- PHP/7.1.33
58+
X-TIME:
59+
- '49818'
60+
status:
61+
code: 200
62+
message: OK
63+
- request:
64+
body: ''
65+
headers:
66+
accept:
67+
- '*/*'
68+
accept-encoding:
69+
- identity
70+
connection:
71+
- keep-alive
72+
host:
73+
- api.domaintools.com
74+
user-agent:
75+
- python-httpx/0.28.1
76+
method: GET
77+
uri: https://api.domaintools.com/v1/feed/iphotlist/?after=-60&app_name=python_wrapper&app_version=2.8.1&top=5
78+
response:
79+
body:
80+
string: '{"timestamp":"2025-01-06T15:30:42Z","ip":"192.0.2.1","asn":12345,"organization":"Example
81+
Hosting LLC","city":"Amsterdam","country":"NL","latitude":52.3676,"longitude":4.9041,"pdns_resolutions":47,"bad_pdns_resolutions":42,"total_domains":183,"zerolist_domains":0,"zerolist_ip":false,"third_party_threats":38,"all_threats_combined_count":45,"all_threats_combined_percent":91.2,"all_threats_percent":91.2,"combined_phishing_percent":72.1,"combined_malware_percent":85.3,"combined_spam_percent":61.4,"malicious_phishing":28,"malicious_malware":33,"malicious_spam":22,"percent_phishing":57.4,"percent_malware":67.8,"percent_spam":45.2,"compromised_phishing":6,"compromised_malware":8,"compromised_spam":4,"predicted_phishing":7,"predicted_malware":9,"predicted_spam":5}
82+
83+
{"timestamp":"2025-01-06T15:30:45Z","ip":"192.0.2.2","asn":67890,"organization":"Bulletproof
84+
Networks Inc","city":"Moscow","country":"RU","latitude":55.7558,"longitude":37.6173,"pdns_resolutions":31,"bad_pdns_resolutions":29,"total_domains":94,"zerolist_domains":0,"zerolist_ip":false,"third_party_threats":25,"all_threats_combined_count":30,"all_threats_combined_percent":88.7,"all_threats_percent":88.7,"combined_phishing_percent":65.9,"combined_malware_percent":79.4,"combined_spam_percent":55.3,"malicious_phishing":19,"malicious_malware":24,"malicious_spam":15,"percent_phishing":48.9,"percent_malware":61.7,"percent_spam":38.3,"compromised_phishing":4,"compromised_malware":5,"compromised_spam":3,"predicted_phishing":6,"predicted_malware":7,"predicted_spam":4}
85+
86+
'
87+
headers:
88+
Cache-Control:
89+
- no-store, no-cache, must-revalidate
90+
Content-Length:
91+
- '932'
92+
Content-Security-Policy:
93+
- 'default-src * data: blob: ''unsafe-eval'' ''unsafe-inline'''
94+
Content-Type:
95+
- application/x-ndjson
96+
Date:
97+
- Thu, 23 Oct 2025 18:33:09 GMT
98+
Expires:
99+
- Thu, 19 Nov 1981 08:52:00 GMT
100+
Pragma:
101+
- no-cache
102+
Set-Cookie:
103+
- dtsession=41acrdm0r445tr0kqd8rsdu121jfg5tv05s572e3qtcn424ii0lpg6cm7gn5lliuk3fgk7dpflgr6potnis2mefki53adjcits91k1g;
104+
expires=Sat, 22-Nov-2025 18:33:08 GMT; Max-Age=2592000; path=/; domain=.domaintools.com;
105+
secure; HttpOnly
106+
- 0566fae076d9b6615cd8f47a9e9500f2=4556b46b52fb2ae62de3b26ddc27dfa0; path=/;
107+
HttpOnly
108+
Strict-Transport-Security:
109+
- max-age=31536000; includeSubDomains
110+
X-Request-Id:
111+
- 68211925-a5bb-4487-90d0-9ed3887f3728
112+
status:
113+
code: 200
114+
message: OK
115+
version: 1
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
interactions:
2+
- request:
3+
body: ''
4+
headers:
5+
accept:
6+
- '*/*'
7+
accept-encoding:
8+
- gzip, deflate
9+
connection:
10+
- keep-alive
11+
host:
12+
- api.domaintools.com
13+
user-agent:
14+
- python-httpx/0.28.1
15+
method: GET
16+
uri: https://api.domaintools.com/v1/account?app_name=python_wrapper&app_version=2.8.1
17+
response:
18+
body:
19+
string: '{"timestamp":"2025-01-06T15:30:42Z","ip":"192.0.2.10","asn":12345,"organization":"Example
20+
Hosting LLC","city":"Amsterdam","country":"NL","latitude":52.3676,"longitude":4.9041,"pdns_resolutions":12,"bad_pdns_resolutions":3,"total_domains":47,"zerolist_domains":2,"zerolist_ip":false,"third_party_threats":2,"all_threats_combined_count":5,"all_threats_combined_percent":10.6,"all_threats_percent":10.6,"combined_phishing_percent":6.4,"combined_malware_percent":8.5,"combined_spam_percent":4.3,"malicious_phishing":1,"malicious_malware":2,"malicious_spam":1,"percent_phishing":2.1,"percent_malware":4.3,"percent_spam":2.1,"compromised_phishing":0,"compromised_malware":1,"compromised_spam":0,"predicted_phishing":1,"predicted_malware":2,"predicted_spam":1}
21+
22+
{"timestamp":"2025-01-06T15:30:45Z","ip":"192.0.2.11","asn":67890,"organization":"Cloud
23+
Provider Corp","city":"Frankfurt","country":"DE","latitude":50.1109,"longitude":8.6821,"pdns_resolutions":5,"bad_pdns_resolutions":0,"total_domains":18,"zerolist_domains":0,"zerolist_ip":false,"third_party_threats":0,"all_threats_combined_count":1,"all_threats_combined_percent":5.6,"all_threats_percent":5.6,"combined_phishing_percent":0.0,"combined_malware_percent":5.6,"combined_spam_percent":0.0,"malicious_phishing":0,"malicious_malware":0,"malicious_spam":0,"percent_phishing":0.0,"percent_malware":0.0,"percent_spam":0.0,"compromised_phishing":0,"compromised_malware":0,"compromised_spam":0,"predicted_phishing":0,"predicted_malware":1,"predicted_spam":0}
24+
25+
'
26+
headers:
27+
Cache-Control:
28+
- no-store, no-cache, must-revalidate
29+
Connection:
30+
- keep-alive
31+
Content-Encoding:
32+
- gzip
33+
Content-Security-Policy:
34+
- 'default-src * data: blob: ''unsafe-eval'' ''unsafe-inline'''
35+
Content-Type:
36+
- application/json;charset=utf-8
37+
Date:
38+
- Mon, 28 Apr 2025 18:00:47 GMT
39+
Expires:
40+
- Thu, 19 Nov 1981 08:52:00 GMT
41+
Pragma:
42+
- no-cache
43+
Set-Cookie:
44+
- dtsession=fsli3ccledtncc8l0agq08ceif; expires=Wed, 28-May-2025 18:00:47 GMT;
45+
Max-Age=2592000; path=/; domain=.domaintools.test; secure; HttpOnly
46+
Strict-Transport-Security:
47+
- max-age=31536000; includeSubDomains
48+
Transfer-Encoding:
49+
- chunked
50+
Vary:
51+
- Accept-Encoding
52+
X-API-USERNAME:
53+
- jbabac
54+
X-GROUP-ID:
55+
- '1117'
56+
X-Powered-By:
57+
- PHP/7.1.33
58+
X-TIME:
59+
- '49818'
60+
status:
61+
code: 200
62+
message: OK
63+
- request:
64+
body: ''
65+
headers:
66+
accept:
67+
- '*/*'
68+
accept-encoding:
69+
- identity
70+
connection:
71+
- keep-alive
72+
host:
73+
- api.domaintools.com
74+
user-agent:
75+
- python-httpx/0.28.1
76+
method: GET
77+
uri: https://api.domaintools.com/v1/feed/iprisk/?after=-60&app_name=python_wrapper&app_version=2.8.1&top=5
78+
response:
79+
body:
80+
string: '{"timestamp":"2025-01-06T15:30:42Z","ip":"192.0.2.10","asn":12345,"organization":"Example
81+
Hosting LLC","city":"Amsterdam","country":"NL","latitude":52.3676,"longitude":4.9041,"pdns_resolutions":12,"bad_pdns_resolutions":3,"total_domains":47,"zerolist_domains":2,"zerolist_ip":false,"third_party_threats":2,"all_threats_combined_count":5,"all_threats_combined_percent":10.6,"all_threats_percent":10.6,"combined_phishing_percent":6.4,"combined_malware_percent":8.5,"combined_spam_percent":4.3,"malicious_phishing":1,"malicious_malware":2,"malicious_spam":1,"percent_phishing":2.1,"percent_malware":4.3,"percent_spam":2.1,"compromised_phishing":0,"compromised_malware":1,"compromised_spam":0,"predicted_phishing":1,"predicted_malware":2,"predicted_spam":1}
82+
83+
{"timestamp":"2025-01-06T15:30:45Z","ip":"192.0.2.11","asn":67890,"organization":"Cloud
84+
Provider Corp","city":"Frankfurt","country":"DE","latitude":50.1109,"longitude":8.6821,"pdns_resolutions":5,"bad_pdns_resolutions":0,"total_domains":18,"zerolist_domains":0,"zerolist_ip":false,"third_party_threats":0,"all_threats_combined_count":1,"all_threats_combined_percent":5.6,"all_threats_percent":5.6,"combined_phishing_percent":0.0,"combined_malware_percent":5.6,"combined_spam_percent":0.0,"malicious_phishing":0,"malicious_malware":0,"malicious_spam":0,"percent_phishing":0.0,"percent_malware":0.0,"percent_spam":0.0,"compromised_phishing":0,"compromised_malware":0,"compromised_spam":0,"predicted_phishing":0,"predicted_malware":1,"predicted_spam":0}
85+
86+
'
87+
headers:
88+
Cache-Control:
89+
- no-store, no-cache, must-revalidate
90+
Content-Length:
91+
- '932'
92+
Content-Security-Policy:
93+
- 'default-src * data: blob: ''unsafe-eval'' ''unsafe-inline'''
94+
Content-Type:
95+
- application/x-ndjson
96+
Date:
97+
- Thu, 23 Oct 2025 18:33:09 GMT
98+
Expires:
99+
- Thu, 19 Nov 1981 08:52:00 GMT
100+
Pragma:
101+
- no-cache
102+
Set-Cookie:
103+
- dtsession=41acrdm0r445tr0kqd8rsdu121jfg5tv05s572e3qtcn424ii0lpg6cm7gn5lliuk3fgk7dpflgr6potnis2mefki53adjcits91k1g;
104+
expires=Sat, 22-Nov-2025 18:33:08 GMT; Max-Age=2592000; path=/; domain=.domaintools.com;
105+
secure; HttpOnly
106+
- 0566fae076d9b6615cd8f47a9e9500f2=4556b46b52fb2ae62de3b26ddc27dfa0; path=/;
107+
HttpOnly
108+
Strict-Transport-Security:
109+
- max-age=31536000; includeSubDomains
110+
X-Request-Id:
111+
- 68211925-a5bb-4487-90d0-9ed3887f3728
112+
status:
113+
code: 200
114+
message: OK
115+
version: 1

tests/test_api.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -835,3 +835,41 @@ def test_feeds_endpoint_should_raise_error_if_signed_api_key_is_used():
835835
feeds_api.domaindiscovery(after="-60")
836836

837837
assert str(excinfo.value) == "Real Time Threat Feeds do not support signed API keys."
838+
839+
840+
@vcr.use_cassette
841+
def test_ip_hotlist():
842+
results = feeds_api.iphotlist(after="-60", top=5)
843+
for response in results.response():
844+
assert results.status == 200
845+
846+
response = response.strip()
847+
assert response is not None
848+
849+
feed_result = json.loads(response)
850+
assert "timestamp" in feed_result.keys()
851+
assert "ip" in feed_result.keys()
852+
assert "asn" in feed_result.keys()
853+
assert "organization" in feed_result.keys()
854+
assert "total_domains" in feed_result.keys()
855+
assert "all_threats_combined_count" in feed_result.keys()
856+
assert "all_threats_combined_percent" in feed_result.keys()
857+
858+
859+
@vcr.use_cassette
860+
def test_ip_risk():
861+
results = feeds_api.iprisk(after="-60", top=5)
862+
for response in results.response():
863+
assert results.status == 200
864+
865+
response = response.strip()
866+
assert response is not None
867+
868+
feed_result = json.loads(response)
869+
assert "timestamp" in feed_result.keys()
870+
assert "ip" in feed_result.keys()
871+
assert "asn" in feed_result.keys()
872+
assert "organization" in feed_result.keys()
873+
assert "total_domains" in feed_result.keys()
874+
assert "all_threats_combined_count" in feed_result.keys()
875+
assert "all_threats_combined_percent" in feed_result.keys()

0 commit comments

Comments
 (0)