telemetry: test `send()` for telemetry classes in `telemetry/`
This commit is contained in:
parent
7960529ee9
commit
c2ed31bde8
|
@ -30,18 +30,15 @@ def exploit_telem_test_instance():
|
||||||
return ExploitTelem(EXPLOITER, RESULT)
|
return ExploitTelem(EXPLOITER, RESULT)
|
||||||
|
|
||||||
|
|
||||||
def test_exploit_telem_category(exploit_telem_test_instance):
|
def test_exploit_telem_send(exploit_telem_test_instance, spy_send_telemetry):
|
||||||
assert exploit_telem_test_instance.telem_category == 'exploit'
|
exploit_telem_test_instance.send()
|
||||||
|
|
||||||
|
|
||||||
def test_exploit_telem_get_data(exploit_telem_test_instance):
|
|
||||||
actual_data = exploit_telem_test_instance.get_data()
|
|
||||||
expected_data = {'result': RESULT,
|
expected_data = {'result': RESULT,
|
||||||
'machine': HOST.as_dict(),
|
'machine': HOST.as_dict(),
|
||||||
'exploiter': EXPLOITER.__class__.__name__,
|
'exploiter': EXPLOITER.__class__.__name__,
|
||||||
'info': EXPLOITER.exploit_info,
|
'info': EXPLOITER.exploit_info,
|
||||||
'attempts': EXPLOITER.exploit_attempts}
|
'attempts': EXPLOITER.exploit_attempts}
|
||||||
assert actual_data == expected_data
|
assert spy_send_telemetry.data == expected_data
|
||||||
|
assert spy_send_telemetry.telem_category == "exploit"
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
|
@ -55,14 +52,15 @@ def test_post_breach_telem_category(post_breach_telem_test_instance):
|
||||||
assert post_breach_telem_test_instance.telem_category == 'post_breach'
|
assert post_breach_telem_test_instance.telem_category == 'post_breach'
|
||||||
|
|
||||||
|
|
||||||
def test_post_breach_telem_get_data(post_breach_telem_test_instance):
|
def test_post_breach_telem_send(post_breach_telem_test_instance, spy_send_telemetry):
|
||||||
actual_data = post_breach_telem_test_instance.get_data()
|
post_breach_telem_test_instance.send()
|
||||||
expected_data = {'command': PBA.command,
|
expected_data = {'command': PBA.command,
|
||||||
'result': RESULT,
|
'result': RESULT,
|
||||||
'name': PBA.name,
|
'name': PBA.name,
|
||||||
'hostname': HOSTNAME,
|
'hostname': HOSTNAME,
|
||||||
'ip': IP}
|
'ip': IP}
|
||||||
assert actual_data == expected_data
|
assert spy_send_telemetry.data == expected_data
|
||||||
|
assert spy_send_telemetry.telem_category == "post_breach"
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
|
@ -70,15 +68,12 @@ def scan_telem_test_instance():
|
||||||
return ScanTelem(HOST)
|
return ScanTelem(HOST)
|
||||||
|
|
||||||
|
|
||||||
def test_scan_telem_category(scan_telem_test_instance):
|
def test_scan_telem_send(scan_telem_test_instance, spy_send_telemetry):
|
||||||
assert scan_telem_test_instance.telem_category == 'scan'
|
scan_telem_test_instance.send()
|
||||||
|
|
||||||
|
|
||||||
def test_scan_telem_get_data(scan_telem_test_instance):
|
|
||||||
actual_data = scan_telem_test_instance.get_data()
|
|
||||||
expected_data = {'machine': HOST.as_dict(),
|
expected_data = {'machine': HOST.as_dict(),
|
||||||
'service_count': len(HOST.services)}
|
'service_count': len(HOST.services)}
|
||||||
assert actual_data == expected_data
|
assert spy_send_telemetry.data == expected_data
|
||||||
|
assert spy_send_telemetry.telem_category == "scan"
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
|
@ -86,15 +81,12 @@ def state_telem_test_instance():
|
||||||
return StateTelem(IS_DONE, VERSION)
|
return StateTelem(IS_DONE, VERSION)
|
||||||
|
|
||||||
|
|
||||||
def test_state_telem_category(state_telem_test_instance):
|
def test_state_telem_send(state_telem_test_instance, spy_send_telemetry):
|
||||||
assert state_telem_test_instance.telem_category == 'state'
|
state_telem_test_instance.send()
|
||||||
|
|
||||||
|
|
||||||
def test_state_telem_get_data(state_telem_test_instance):
|
|
||||||
actual_data = state_telem_test_instance.get_data()
|
|
||||||
expected_data = {'done': IS_DONE,
|
expected_data = {'done': IS_DONE,
|
||||||
'version': VERSION}
|
'version': VERSION}
|
||||||
assert actual_data == expected_data
|
assert spy_send_telemetry.data == expected_data
|
||||||
|
assert spy_send_telemetry.telem_category == "state"
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
|
@ -102,14 +94,11 @@ def system_info_telem_test_instance():
|
||||||
return SystemInfoTelem(SYSTEM_INFO)
|
return SystemInfoTelem(SYSTEM_INFO)
|
||||||
|
|
||||||
|
|
||||||
def test_system_info_telem_category(system_info_telem_test_instance):
|
def test_system_info_telem_send(system_info_telem_test_instance, spy_send_telemetry):
|
||||||
assert system_info_telem_test_instance.telem_category == 'system_info'
|
system_info_telem_test_instance.send()
|
||||||
|
|
||||||
|
|
||||||
def test_system_info_telem_get_data(system_info_telem_test_instance):
|
|
||||||
actual_data = system_info_telem_test_instance.get_data()
|
|
||||||
expected_data = SYSTEM_INFO
|
expected_data = SYSTEM_INFO
|
||||||
assert actual_data == expected_data
|
assert spy_send_telemetry.data == expected_data
|
||||||
|
assert spy_send_telemetry.telem_category == "system_info"
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
|
@ -117,14 +106,11 @@ def trace_telem_test_instance():
|
||||||
return TraceTelem(MSG)
|
return TraceTelem(MSG)
|
||||||
|
|
||||||
|
|
||||||
def test_trace_telem_category(trace_telem_test_instance):
|
def test_trace_telem_send(trace_telem_test_instance, spy_send_telemetry):
|
||||||
assert trace_telem_test_instance.telem_category == 'trace'
|
trace_telem_test_instance.send()
|
||||||
|
|
||||||
|
|
||||||
def test_trace_telem_get_data(trace_telem_test_instance):
|
|
||||||
actual_data = trace_telem_test_instance.get_data()
|
|
||||||
expected_data = {'msg': MSG}
|
expected_data = {'msg': MSG}
|
||||||
assert actual_data == expected_data
|
assert spy_send_telemetry.data == expected_data
|
||||||
|
assert spy_send_telemetry.telem_category == "trace"
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
|
@ -132,11 +118,8 @@ def tunnel_telem_test_instance():
|
||||||
return TunnelTelem()
|
return TunnelTelem()
|
||||||
|
|
||||||
|
|
||||||
def test_tunnel_telem_category(tunnel_telem_test_instance):
|
def test_tunnel_telem_send(tunnel_telem_test_instance, spy_send_telemetry):
|
||||||
assert tunnel_telem_test_instance.telem_category == 'tunnel'
|
tunnel_telem_test_instance.send()
|
||||||
|
|
||||||
|
|
||||||
def test_tunnel_telem_get_data(tunnel_telem_test_instance):
|
|
||||||
actual_data = tunnel_telem_test_instance.get_data()
|
|
||||||
expected_data = {'proxy': None}
|
expected_data = {'proxy': None}
|
||||||
assert actual_data == expected_data
|
assert spy_send_telemetry.data == expected_data
|
||||||
|
assert spy_send_telemetry.telem_category == "tunnel"
|
||||||
|
|
Loading…
Reference in New Issue