Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 32 additions & 27 deletions tests/test_sdk.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import time
from datetime import date, datetime, timedelta, timezone

import pytest
Expand All @@ -23,6 +24,12 @@
)


@pytest.fixture(autouse=True)
def delay_between_tests():
yield
time.sleep(2)


@pytest.fixture
def sdk_client():
api_key = os.getenv("CENSYS_PAT")
Expand Down Expand Up @@ -171,18 +178,23 @@ def test_convert_legacy_search_queries(self, sdk_client):
class TestGlobalData_TrackedScans:
def test_create_and_get_tracked_scan(self, sdk_client):
with sdk_client as s:
create_res = s.global_data.create_tracked_scan(
scans_rescan_input_body={
"target": {
"service_id": {
"ip": "1.1.1.1",
"port": 80,
"protocol": "HTTP",
"transport_protocol": "tcp",
try:
create_res = s.global_data.create_tracked_scan(
scans_rescan_input_body={
"target": {
"service_id": {
"ip": "1.1.1.1",
"port": 80,
"protocol": "HTTP",
"transport_protocol": "tcp",
}
}
}
}
)
)
except models.SDKError as e:
if e.status_code == 429:
pytest.skip("Rate limited (429)")
raise
assert create_res is not None
scan_id = create_res.result.result.tracked_scan_id
assert scan_id is not None
Expand Down Expand Up @@ -288,10 +300,6 @@ def test_get_organization_credits(self, sdk_client, org_id):
)
assert res is not None

@pytest.mark.xfail(
reason="TODO: fix optional response fields",
raises=Exception,
)
def test_get_organization_credit_usage(self, sdk_client, org_id):
with sdk_client as s:
res = s.account_management.get_organization_credit_usage(
Expand All @@ -317,10 +325,6 @@ def test_list_organization_members(self, sdk_client, org_id):
)
assert res is not None

@pytest.mark.xfail(
reason="TODO: fix optional response fields",
raises=Exception,
)
def test_get_member_credit_usage(self, sdk_client, org_id):
with sdk_client as s:
members_res = s.account_management.list_organization_members(
Expand Down Expand Up @@ -351,10 +355,6 @@ def test_get_user_credits(self, sdk_client):
res = s.account_management.get_user_credits()
assert res is not None

@pytest.mark.xfail(
reason="TODO: fix optional response fields",
raises=Exception,
)
def test_get_user_credits_usage(self, sdk_client):
with sdk_client as s:
res = s.account_management.get_user_credits_usage(
Expand Down Expand Up @@ -399,11 +399,16 @@ def test_list_threats(self, sdk_client):

def test_create_and_get_tracked_scan(self, sdk_client):
with sdk_client as s:
create_res = s.threat_hunting.create_tracked_scan(
scans_discovery_input_body={
"target": {"host_port": {"ip": "1.1.1.1", "port": 443}}
}
)
try:
create_res = s.threat_hunting.create_tracked_scan(
scans_discovery_input_body={
"target": {"host_port": {"ip": "1.1.1.1", "port": 443}}
}
)
except models.SDKError as e:
if e.status_code == 429:
pytest.skip("Rate limited (429)")
raise
assert create_res is not None
scan_id = create_res.result.result.tracked_scan_id
assert scan_id is not None
Expand Down