-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathtest.py
More file actions
97 lines (78 loc) · 3.14 KB
/
test.py
File metadata and controls
97 lines (78 loc) · 3.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import unittest
import netlas
from dotenv import dotenv_values
config = dotenv_values(".env")
class NetlasTests(unittest.TestCase):
DATATYPES = ['response', 'cert', 'domain']
RESPONSE_QUERIES = {'small': 'port:7001', 'empty': 'UIDY&Sdyh&*dhkjkljhas'}
CERT_QUERIES = {
'small': 'certificate.subject.country:US',
'empty': 'UIDY&Sdyh&*dhkjkljhas'
}
DOMAIN_QUERIES = {
'small': 'mx:mail.google.com',
'empty': 'UIDY&Sdyh&*dhkjkljhas'
}
def setUp(self):
self.netlas = netlas.Netlas(api_key=config['TEST_API_KEY'],
apibase=config['TEST_API_SERVER'],
debug=True)
def test_response_query(self):
results = self.netlas.query(query=self.RESPONSE_QUERIES['empty'],
datatype="response")
self.assertIn('items', results)
self.assertCountEqual([], results['items'])
results = self.netlas.query(query=self.RESPONSE_QUERIES['small'],
datatype="response")
self.assertIn('items', results)
self.assertIn('data', results['items'][0])
def test_cert_query(self):
results = self.netlas.query(query=self.CERT_QUERIES['empty'],
datatype="cert")
self.assertIn('items', results)
self.assertCountEqual([], results['items'])
results = self.netlas.query(query=self.CERT_QUERIES['small'],
datatype="cert")
self.assertIn('items', results)
self.assertIn('data', results['items'][0])
def test_domain_query(self):
results = self.netlas.query(query=self.DOMAIN_QUERIES['empty'],
datatype="domain")
self.assertIn('items', results)
self.assertCountEqual([], results['items'])
results = self.netlas.query(query=self.DOMAIN_QUERIES['small'],
datatype="domain")
self.assertIn('items', results)
self.assertIn('data', results['items'][0])
def test_response_download(self):
bin_results: bytes = b''
for results in self.netlas.download(
query=self.RESPONSE_QUERIES['small'],
datatype="response",
size=1,
):
bin_results += results
self.assertLess(b'', bin_results)
def test_cert_download(self):
bin_results: bytes = b''
for results in self.netlas.download(
query=self.CERT_QUERIES['small'],
datatype="cert",
size=1,
):
bin_results += results
self.assertLess(b'', bin_results)
def test_domain_download(self):
bin_results: bytes = b''
for results in self.netlas.download(
query=self.DOMAIN_QUERIES['small'],
datatype="domain",
size=1,
):
bin_results += results
self.assertLess(b'', bin_results)
def test_profile(self):
results = self.netlas.profile()
self.assertIn('email', results)
if __name__ == '__main__':
unittest.main()