| 1 |
import responses |
| 2 |
|
| 3 |
from censys.asm.client import AsmClient |
| 4 |
|
| 5 |
from ..utils import CensysTestCase |
| 6 |
from .utils import V1_URL |
| 7 |
|
| 8 |
TEST_COUNT_JSON = { |
| 9 |
"totalAssetCount": 0, |
| 10 |
"totalNewAssetCount": 0, |
| 11 |
"totalCloudAssetCount": 0, |
| 12 |
"totalCloudNewAssetCount": 0, |
| 13 |
"assetCountByProvider": [{"cloudProvider": "string", "assetCount": 0, "newAssetCount": 0}], |
| 14 |
} |
| 15 |
|
| 16 |
|
| 17 |
class CloudsUnitTest(CensysTestCase): |
| 18 |
def setup_method(self): |
| 19 |
self.client = AsmClient(self.api_key) |
| 20 |
|
| 21 |
def test_get_host_counts(self): |
| 22 |
# Setup response |
| 23 |
self.responses.add( |
| 24 |
responses.GET, |
| 25 |
V1_URL + "/clouds/hostCounts/2021-01-01", |
| 26 |
status=200, |
| 27 |
json=TEST_COUNT_JSON, |
| 28 |
) |
| 29 |
# Actual call |
| 30 |
res = self.client.clouds.get_host_counts("2021-01-01") |
| 31 |
# Assertions |
| 32 |
assert res == TEST_COUNT_JSON |
| 33 |
|
| 34 |
def test_get_domain_counts(self): |
| 35 |
# Setup response |
| 36 |
self.responses.add( |
| 37 |
responses.GET, |
| 38 |
V1_URL + "/clouds/domainCounts/2021-01-01", |
| 39 |
status=200, |
| 40 |
json=TEST_COUNT_JSON, |
| 41 |
) |
| 42 |
# Actual call |
| 43 |
res = self.client.clouds.get_domain_counts("2021-01-01") |
| 44 |
# Assertions |
| 45 |
assert res == TEST_COUNT_JSON |
| 46 |
|
| 47 |
def test_get_object_store_counts(self): |
| 48 |
# Setup response |
| 49 |
self.responses.add( |
| 50 |
responses.GET, |
| 51 |
V1_URL + "/clouds/objectStoreCounts/2021-01-01", |
| 52 |
status=200, |
| 53 |
json=TEST_COUNT_JSON, |
| 54 |
) |
| 55 |
# Actual call |
| 56 |
res = self.client.clouds.get_object_store_counts("2021-01-01") |
| 57 |
# Assertions |
| 58 |
assert res == TEST_COUNT_JSON |
| 59 |
|
| 60 |
def test_get_subdomain_counts(self): |
| 61 |
# Setup response |
| 62 |
self.responses.add( |
| 63 |
responses.GET, |
| 64 |
V1_URL + "/clouds/subdomainCounts/2021-01-01", |
| 65 |
status=200, |
| 66 |
json=TEST_COUNT_JSON, |
| 67 |
) |
| 68 |
# Actual call |
| 69 |
res = self.client.clouds.get_subdomain_counts("2021-01-01") |
| 70 |
# Assertions |
| 71 |
assert res == TEST_COUNT_JSON |
| 72 |
|
| 73 |
def test_get_unknown_counts(self): |
| 74 |
# Setup response |
| 75 |
self.responses.add( |
| 76 |
responses.GET, |
| 77 |
V1_URL + "/clouds/unknownCounts", |
| 78 |
status=200, |
| 79 |
json=TEST_COUNT_JSON, |
| 80 |
) |
| 81 |
# Actual call |
| 82 |
res = self.client.clouds.get_unknown_counts() |
| 83 |
# Assertions |
| 84 |
assert res == TEST_COUNT_JSON |