mirror of
https://github.com/thousandeyes/thousandeyes-sdk-python.git
synced 2026-08-04 08:56:50 +00:00
Success response bodies now use valid JSON quotes instead of HTML entities, and optional expand enum params are omitted when OpenAPI examples are invalid. Co-authored-by: Cursor <cursoragent@cursor.com>
2875 lines
112 KiB
Python
2875 lines
112 KiB
Python
# coding: utf-8
|
|
|
|
"""
|
|
Endpoint Agents API
|
|
|
|
**Note:** The Endpoint Agents Transfer APIs are not available for ThousandEyes for Government instance. Manage ThousandEyes Endpoint Agents using this API. For more information about Endpoint Agents, see [Endpoint Agents](https://docs.thousandeyes.com/product-documentation/global-vantage-points/endpoint-agents).
|
|
|
|
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
|
|
|
Do not edit the class manually.
|
|
""" # noqa: E501
|
|
|
|
|
|
import json
|
|
import unittest
|
|
import thousandeyes_sdk.endpoint_agents.models
|
|
|
|
from thousandeyes_sdk.core.exceptions import ApiException
|
|
from thousandeyes_sdk.endpoint_agents.api.endpoint_agents_api import EndpointAgentsApi
|
|
from .integration_test_utils import IntegrationTestBase
|
|
from .test_utils import assert_constructed_model_matches_example_json
|
|
|
|
|
|
class TestEndpointAgentsApiIntegration(IntegrationTestBase):
|
|
"""EndpointAgentsApi integration test stubs"""
|
|
|
|
def setUp(self) -> None:
|
|
super().setUp()
|
|
self.api = EndpointAgentsApi(self.api_client)
|
|
|
|
|
|
def test_delete_endpoint_agent_happy_path(self) -> None:
|
|
"""Integration test for delete_endpoint_agent success path"""
|
|
agent_id = 'agent_id_example'
|
|
aid = '1234'
|
|
response = self.api.delete_endpoint_agent_with_http_info(
|
|
|
|
agent_id=agent_id,
|
|
|
|
aid=aid,
|
|
|
|
_headers=self.te_headers("delete_endpoint_agent"),
|
|
)
|
|
self.assertEqual(204, response.status_code)
|
|
self.assertIsNone(response.data)
|
|
|
|
|
|
def test_delete_endpoint_agent_error_401(self) -> None:
|
|
"""Integration test for delete_endpoint_agent error path (HTTP 401)"""
|
|
agent_id = 'agent_id_example'
|
|
aid = '1234'
|
|
error_body_json = """
|
|
{
|
|
"error_description" : "Invalid access token",
|
|
"error" : "invalid_token"
|
|
}
|
|
"""
|
|
expected_error = json.loads(error_body_json)
|
|
with self.assertRaises(
|
|
ApiException.exception_class_for_http_status(401)
|
|
) as context:
|
|
self.api.delete_endpoint_agent(
|
|
|
|
agent_id=agent_id,
|
|
|
|
aid=aid,
|
|
|
|
_headers=self.te_headers("delete_endpoint_agent", error_status="401"),
|
|
)
|
|
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
|
|
|
|
|
|
def test_delete_endpoint_agent_error_403(self) -> None:
|
|
"""Integration test for delete_endpoint_agent error path (HTTP 403)"""
|
|
agent_id = 'agent_id_example'
|
|
aid = '1234'
|
|
error_body_json = """
|
|
{
|
|
"instance" : "instance",
|
|
"detail" : "detail",
|
|
"type" : "type",
|
|
"title" : "title",
|
|
"status" : 6
|
|
}
|
|
"""
|
|
expected_error = json.loads(error_body_json)
|
|
with self.assertRaises(
|
|
ApiException.exception_class_for_http_status(403)
|
|
) as context:
|
|
self.api.delete_endpoint_agent(
|
|
|
|
agent_id=agent_id,
|
|
|
|
aid=aid,
|
|
|
|
_headers=self.te_headers("delete_endpoint_agent", error_status="403"),
|
|
)
|
|
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
|
|
|
|
|
|
def test_delete_endpoint_agent_error_404(self) -> None:
|
|
"""Integration test for delete_endpoint_agent error path (HTTP 404)"""
|
|
agent_id = 'agent_id_example'
|
|
aid = '1234'
|
|
error_body_json = """
|
|
{
|
|
"instance" : "instance",
|
|
"detail" : "detail",
|
|
"type" : "type",
|
|
"title" : "title",
|
|
"status" : 6
|
|
}
|
|
"""
|
|
expected_error = json.loads(error_body_json)
|
|
with self.assertRaises(
|
|
ApiException.exception_class_for_http_status(404)
|
|
) as context:
|
|
self.api.delete_endpoint_agent(
|
|
|
|
agent_id=agent_id,
|
|
|
|
aid=aid,
|
|
|
|
_headers=self.te_headers("delete_endpoint_agent", error_status="404"),
|
|
)
|
|
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
|
|
|
|
|
|
def test_delete_endpoint_agent_error_429(self) -> None:
|
|
"""Integration test for delete_endpoint_agent error path (HTTP 429)"""
|
|
agent_id = 'agent_id_example'
|
|
aid = '1234'
|
|
error_body_json = """
|
|
{
|
|
"instance" : "instance",
|
|
"detail" : "detail",
|
|
"type" : "type",
|
|
"title" : "title",
|
|
"status" : 6
|
|
}
|
|
"""
|
|
expected_error = json.loads(error_body_json)
|
|
with self.assertRaises(
|
|
ApiException.exception_class_for_http_status(429)
|
|
) as context:
|
|
self.api.delete_endpoint_agent(
|
|
|
|
agent_id=agent_id,
|
|
|
|
aid=aid,
|
|
|
|
_headers=self.te_headers("delete_endpoint_agent", error_status="429"),
|
|
)
|
|
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
|
|
|
|
|
|
|
|
|
|
def test_disable_endpoint_agent_happy_path(self) -> None:
|
|
"""Integration test for disable_endpoint_agent success path"""
|
|
agent_id = 'agent_id_example'
|
|
aid = '1234'
|
|
response_body_json = """
|
|
{
|
|
"npcapVersion" : "npcapVersion",
|
|
"asnDetails" : {
|
|
"asName" : "Virgin Media Limited",
|
|
"asNumber" : 5089
|
|
},
|
|
"clients" : [ {
|
|
"browserExtensions" : [ {
|
|
"browser" : "edge",
|
|
"profile" : "Profile 1",
|
|
"active" : true,
|
|
"error" : "",
|
|
"version" : "0.123.0",
|
|
"enabled" : true
|
|
}, {
|
|
"browser" : "edge",
|
|
"profile" : "Profile 1",
|
|
"active" : true,
|
|
"error" : "",
|
|
"version" : "0.123.0",
|
|
"enabled" : true
|
|
} ],
|
|
"userProfile" : {
|
|
"userName" : "joeblogs32",
|
|
"userPrincipalName" : "joeblogs32@c.com"
|
|
}
|
|
}, {
|
|
"browserExtensions" : [ {
|
|
"browser" : "edge",
|
|
"profile" : "Profile 1",
|
|
"active" : true,
|
|
"error" : "",
|
|
"version" : "0.123.0",
|
|
"enabled" : true
|
|
}, {
|
|
"browser" : "edge",
|
|
"profile" : "Profile 1",
|
|
"active" : true,
|
|
"error" : "",
|
|
"version" : "0.123.0",
|
|
"enabled" : true
|
|
} ],
|
|
"userProfile" : {
|
|
"userName" : "joeblogs32",
|
|
"userPrincipalName" : "joeblogs32@c.com"
|
|
}
|
|
} ],
|
|
"agentType" : "endpoint",
|
|
"_links" : {
|
|
"self" : {
|
|
"hreflang" : "hreflang",
|
|
"templated" : true,
|
|
"profile" : "profile",
|
|
"name" : "name",
|
|
"href" : "https://api.thousandeyes.com/v7/link/to/resource/id",
|
|
"type" : "type",
|
|
"deprecation" : "deprecation",
|
|
"title" : "title"
|
|
}
|
|
},
|
|
"batteryMetrics" : {
|
|
"batteryHealthNormalizedPercent" : 0.92,
|
|
"batteryLevel" : "medium",
|
|
"batteryLevelNormalizedPercent" : 0.3
|
|
},
|
|
"publicIP" : "88.45.2.123",
|
|
"tcpDriverAvailable" : true,
|
|
"platform" : "mac",
|
|
"manufacturer" : "Apple, Inc.",
|
|
"targetVersion" : "0.123.4",
|
|
"cellularProfile" : {
|
|
"rssi" : -10,
|
|
"advertisedNetworkSubtype" : "LTE/HSPA",
|
|
"carrierName" : "T-Mobile",
|
|
"rsrq" : -30,
|
|
"rsrp" : -30,
|
|
"advertisedNetworkGen" : "2g, 3g, 4g, 5g",
|
|
"rscp" : -30,
|
|
"networkGen" : "2g, 3g, 4g, 5g",
|
|
"networkSubtype" : "LTE/HSPA",
|
|
"sinr" : 20
|
|
},
|
|
"nicModel" : "Intel(R) Wi-Fi 6 AX200 160MHz",
|
|
"createdAt" : "2022-05-26T23:37:16Z",
|
|
"numberOfClients" : 3,
|
|
"licenseType" : "essentials",
|
|
"osVersion" : "Version 10.15.2 (Build 19C57)",
|
|
"computerName" : "DESKJET-123",
|
|
"freeDiskSpaceNormalized" : 0.41,
|
|
"model" : "MacBookAir7,2",
|
|
"id" : "861b7557-cd57-4bbb-b648-00bddf88ef49",
|
|
"nicDriverVersion" : "22.250.0.9",
|
|
"serialNumber" : "xaab2ba4-d40f-4e80-9363-7e4826556055",
|
|
"externalMetadata" : [ {
|
|
"key" : "anyConnectDeviceId",
|
|
"value" : "DF434343D"
|
|
}, {
|
|
"key" : "anyConnectDeviceId",
|
|
"value" : "DF434343D"
|
|
} ],
|
|
"version" : "0.123.4",
|
|
"vpnProfiles" : [ {
|
|
"vpnClientNetworkRange" : [ "10.100.0.0/22" ],
|
|
"vpnGatewayAddress" : "vpnGatewayAddress",
|
|
"vpnType" : "cisco-anyconnect",
|
|
"interfaceName" : "interfaceName",
|
|
"vpnClientAddresses" : [ "10.100.0.10" ]
|
|
}, {
|
|
"vpnClientNetworkRange" : [ "10.100.0.0/22" ],
|
|
"vpnGatewayAddress" : "vpnGatewayAddress",
|
|
"vpnType" : "cisco-anyconnect",
|
|
"interfaceName" : "interfaceName",
|
|
"vpnClientAddresses" : [ "10.100.0.10" ]
|
|
} ],
|
|
"lastSeen" : "2022-05-26T23:37:16Z",
|
|
"deleted" : true,
|
|
"totalMemory" : "16384 MB",
|
|
"kernelVersion" : "Darwin 19.2.0",
|
|
"name" : "Office Printer",
|
|
"location" : {
|
|
"locationName" : "London",
|
|
"latitude" : 51.51279,
|
|
"longitude" : -0.09184
|
|
},
|
|
"aid" : "",
|
|
"status" : "enabled",
|
|
"networkInterfaceProfiles" : [ {
|
|
"ethernetProfile" : {
|
|
"linkSpeed" : 0
|
|
},
|
|
"hardwareType" : "wireless",
|
|
"interfaceName" : "en0",
|
|
"addressProfiles" : [ {
|
|
"prefixLength" : 24,
|
|
"addressType" : "unique-local",
|
|
"ipAddress" : "2001:db8:3333:4444:5555:6666:7777:8888",
|
|
"routerHardwareAddress" : "5c:b1:3e:46:1c:84",
|
|
"gateway" : "192.168.0.254"
|
|
}, {
|
|
"prefixLength" : 24,
|
|
"addressType" : "unique-local",
|
|
"ipAddress" : "2001:db8:3333:4444:5555:6666:7777:8888",
|
|
"routerHardwareAddress" : "5c:b1:3e:46:1c:84",
|
|
"gateway" : "192.168.0.254"
|
|
} ],
|
|
"wirelessProfile" : {
|
|
"rssi" : -36,
|
|
"bssid" : "00:11:22:aa:bb:cc",
|
|
"channel" : 48,
|
|
"phyMode" : "802.11ac",
|
|
"ssid" : "GuestWiFi"
|
|
}
|
|
}, {
|
|
"ethernetProfile" : {
|
|
"linkSpeed" : 0
|
|
},
|
|
"hardwareType" : "wireless",
|
|
"interfaceName" : "en0",
|
|
"addressProfiles" : [ {
|
|
"prefixLength" : 24,
|
|
"addressType" : "unique-local",
|
|
"ipAddress" : "2001:db8:3333:4444:5555:6666:7777:8888",
|
|
"routerHardwareAddress" : "5c:b1:3e:46:1c:84",
|
|
"gateway" : "192.168.0.254"
|
|
}, {
|
|
"prefixLength" : 24,
|
|
"addressType" : "unique-local",
|
|
"ipAddress" : "2001:db8:3333:4444:5555:6666:7777:8888",
|
|
"routerHardwareAddress" : "5c:b1:3e:46:1c:84",
|
|
"gateway" : "192.168.0.254"
|
|
} ],
|
|
"wirelessProfile" : {
|
|
"rssi" : -36,
|
|
"bssid" : "00:11:22:aa:bb:cc",
|
|
"channel" : 48,
|
|
"phyMode" : "802.11ac",
|
|
"ssid" : "GuestWiFi"
|
|
}
|
|
} ]
|
|
}
|
|
"""
|
|
expected_response = json.loads(response_body_json)
|
|
response = self.api.disable_endpoint_agent(
|
|
|
|
agent_id=agent_id,
|
|
|
|
aid=aid,
|
|
|
|
_headers=self.te_headers("disable_endpoint_agent"),
|
|
)
|
|
assert_constructed_model_matches_example_json(response, expected_response)
|
|
|
|
|
|
def test_disable_endpoint_agent_error_401(self) -> None:
|
|
"""Integration test for disable_endpoint_agent error path (HTTP 401)"""
|
|
agent_id = 'agent_id_example'
|
|
aid = '1234'
|
|
error_body_json = """
|
|
{
|
|
"error_description" : "Invalid access token",
|
|
"error" : "invalid_token"
|
|
}
|
|
"""
|
|
expected_error = json.loads(error_body_json)
|
|
with self.assertRaises(
|
|
ApiException.exception_class_for_http_status(401)
|
|
) as context:
|
|
self.api.disable_endpoint_agent(
|
|
|
|
agent_id=agent_id,
|
|
|
|
aid=aid,
|
|
|
|
_headers=self.te_headers("disable_endpoint_agent", error_status="401"),
|
|
)
|
|
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
|
|
|
|
|
|
def test_disable_endpoint_agent_error_403(self) -> None:
|
|
"""Integration test for disable_endpoint_agent error path (HTTP 403)"""
|
|
agent_id = 'agent_id_example'
|
|
aid = '1234'
|
|
error_body_json = """
|
|
{
|
|
"instance" : "instance",
|
|
"detail" : "detail",
|
|
"type" : "type",
|
|
"title" : "title",
|
|
"status" : 6
|
|
}
|
|
"""
|
|
expected_error = json.loads(error_body_json)
|
|
with self.assertRaises(
|
|
ApiException.exception_class_for_http_status(403)
|
|
) as context:
|
|
self.api.disable_endpoint_agent(
|
|
|
|
agent_id=agent_id,
|
|
|
|
aid=aid,
|
|
|
|
_headers=self.te_headers("disable_endpoint_agent", error_status="403"),
|
|
)
|
|
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
|
|
|
|
|
|
def test_disable_endpoint_agent_error_404(self) -> None:
|
|
"""Integration test for disable_endpoint_agent error path (HTTP 404)"""
|
|
agent_id = 'agent_id_example'
|
|
aid = '1234'
|
|
error_body_json = """
|
|
{
|
|
"instance" : "instance",
|
|
"detail" : "detail",
|
|
"type" : "type",
|
|
"title" : "title",
|
|
"status" : 6
|
|
}
|
|
"""
|
|
expected_error = json.loads(error_body_json)
|
|
with self.assertRaises(
|
|
ApiException.exception_class_for_http_status(404)
|
|
) as context:
|
|
self.api.disable_endpoint_agent(
|
|
|
|
agent_id=agent_id,
|
|
|
|
aid=aid,
|
|
|
|
_headers=self.te_headers("disable_endpoint_agent", error_status="404"),
|
|
)
|
|
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
|
|
|
|
|
|
def test_disable_endpoint_agent_error_429(self) -> None:
|
|
"""Integration test for disable_endpoint_agent error path (HTTP 429)"""
|
|
agent_id = 'agent_id_example'
|
|
aid = '1234'
|
|
error_body_json = """
|
|
{
|
|
"instance" : "instance",
|
|
"detail" : "detail",
|
|
"type" : "type",
|
|
"title" : "title",
|
|
"status" : 6
|
|
}
|
|
"""
|
|
expected_error = json.loads(error_body_json)
|
|
with self.assertRaises(
|
|
ApiException.exception_class_for_http_status(429)
|
|
) as context:
|
|
self.api.disable_endpoint_agent(
|
|
|
|
agent_id=agent_id,
|
|
|
|
aid=aid,
|
|
|
|
_headers=self.te_headers("disable_endpoint_agent", error_status="429"),
|
|
)
|
|
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
|
|
|
|
|
|
|
|
|
|
def test_enable_endpoint_agent_happy_path(self) -> None:
|
|
"""Integration test for enable_endpoint_agent success path"""
|
|
agent_id = 'agent_id_example'
|
|
aid = '1234'
|
|
response_body_json = """
|
|
{
|
|
"npcapVersion" : "npcapVersion",
|
|
"asnDetails" : {
|
|
"asName" : "Virgin Media Limited",
|
|
"asNumber" : 5089
|
|
},
|
|
"clients" : [ {
|
|
"browserExtensions" : [ {
|
|
"browser" : "edge",
|
|
"profile" : "Profile 1",
|
|
"active" : true,
|
|
"error" : "",
|
|
"version" : "0.123.0",
|
|
"enabled" : true
|
|
}, {
|
|
"browser" : "edge",
|
|
"profile" : "Profile 1",
|
|
"active" : true,
|
|
"error" : "",
|
|
"version" : "0.123.0",
|
|
"enabled" : true
|
|
} ],
|
|
"userProfile" : {
|
|
"userName" : "joeblogs32",
|
|
"userPrincipalName" : "joeblogs32@c.com"
|
|
}
|
|
}, {
|
|
"browserExtensions" : [ {
|
|
"browser" : "edge",
|
|
"profile" : "Profile 1",
|
|
"active" : true,
|
|
"error" : "",
|
|
"version" : "0.123.0",
|
|
"enabled" : true
|
|
}, {
|
|
"browser" : "edge",
|
|
"profile" : "Profile 1",
|
|
"active" : true,
|
|
"error" : "",
|
|
"version" : "0.123.0",
|
|
"enabled" : true
|
|
} ],
|
|
"userProfile" : {
|
|
"userName" : "joeblogs32",
|
|
"userPrincipalName" : "joeblogs32@c.com"
|
|
}
|
|
} ],
|
|
"agentType" : "endpoint",
|
|
"_links" : {
|
|
"self" : {
|
|
"hreflang" : "hreflang",
|
|
"templated" : true,
|
|
"profile" : "profile",
|
|
"name" : "name",
|
|
"href" : "https://api.thousandeyes.com/v7/link/to/resource/id",
|
|
"type" : "type",
|
|
"deprecation" : "deprecation",
|
|
"title" : "title"
|
|
}
|
|
},
|
|
"batteryMetrics" : {
|
|
"batteryHealthNormalizedPercent" : 0.92,
|
|
"batteryLevel" : "medium",
|
|
"batteryLevelNormalizedPercent" : 0.3
|
|
},
|
|
"publicIP" : "88.45.2.123",
|
|
"tcpDriverAvailable" : true,
|
|
"platform" : "mac",
|
|
"manufacturer" : "Apple, Inc.",
|
|
"targetVersion" : "0.123.4",
|
|
"cellularProfile" : {
|
|
"rssi" : -10,
|
|
"advertisedNetworkSubtype" : "LTE/HSPA",
|
|
"carrierName" : "T-Mobile",
|
|
"rsrq" : -30,
|
|
"rsrp" : -30,
|
|
"advertisedNetworkGen" : "2g, 3g, 4g, 5g",
|
|
"rscp" : -30,
|
|
"networkGen" : "2g, 3g, 4g, 5g",
|
|
"networkSubtype" : "LTE/HSPA",
|
|
"sinr" : 20
|
|
},
|
|
"nicModel" : "Intel(R) Wi-Fi 6 AX200 160MHz",
|
|
"createdAt" : "2022-05-26T23:37:16Z",
|
|
"numberOfClients" : 3,
|
|
"licenseType" : "essentials",
|
|
"osVersion" : "Version 10.15.2 (Build 19C57)",
|
|
"computerName" : "DESKJET-123",
|
|
"freeDiskSpaceNormalized" : 0.41,
|
|
"model" : "MacBookAir7,2",
|
|
"id" : "861b7557-cd57-4bbb-b648-00bddf88ef49",
|
|
"nicDriverVersion" : "22.250.0.9",
|
|
"serialNumber" : "xaab2ba4-d40f-4e80-9363-7e4826556055",
|
|
"externalMetadata" : [ {
|
|
"key" : "anyConnectDeviceId",
|
|
"value" : "DF434343D"
|
|
}, {
|
|
"key" : "anyConnectDeviceId",
|
|
"value" : "DF434343D"
|
|
} ],
|
|
"version" : "0.123.4",
|
|
"vpnProfiles" : [ {
|
|
"vpnClientNetworkRange" : [ "10.100.0.0/22" ],
|
|
"vpnGatewayAddress" : "vpnGatewayAddress",
|
|
"vpnType" : "cisco-anyconnect",
|
|
"interfaceName" : "interfaceName",
|
|
"vpnClientAddresses" : [ "10.100.0.10" ]
|
|
}, {
|
|
"vpnClientNetworkRange" : [ "10.100.0.0/22" ],
|
|
"vpnGatewayAddress" : "vpnGatewayAddress",
|
|
"vpnType" : "cisco-anyconnect",
|
|
"interfaceName" : "interfaceName",
|
|
"vpnClientAddresses" : [ "10.100.0.10" ]
|
|
} ],
|
|
"lastSeen" : "2022-05-26T23:37:16Z",
|
|
"deleted" : true,
|
|
"totalMemory" : "16384 MB",
|
|
"kernelVersion" : "Darwin 19.2.0",
|
|
"name" : "Office Printer",
|
|
"location" : {
|
|
"locationName" : "London",
|
|
"latitude" : 51.51279,
|
|
"longitude" : -0.09184
|
|
},
|
|
"aid" : "",
|
|
"status" : "enabled",
|
|
"networkInterfaceProfiles" : [ {
|
|
"ethernetProfile" : {
|
|
"linkSpeed" : 0
|
|
},
|
|
"hardwareType" : "wireless",
|
|
"interfaceName" : "en0",
|
|
"addressProfiles" : [ {
|
|
"prefixLength" : 24,
|
|
"addressType" : "unique-local",
|
|
"ipAddress" : "2001:db8:3333:4444:5555:6666:7777:8888",
|
|
"routerHardwareAddress" : "5c:b1:3e:46:1c:84",
|
|
"gateway" : "192.168.0.254"
|
|
}, {
|
|
"prefixLength" : 24,
|
|
"addressType" : "unique-local",
|
|
"ipAddress" : "2001:db8:3333:4444:5555:6666:7777:8888",
|
|
"routerHardwareAddress" : "5c:b1:3e:46:1c:84",
|
|
"gateway" : "192.168.0.254"
|
|
} ],
|
|
"wirelessProfile" : {
|
|
"rssi" : -36,
|
|
"bssid" : "00:11:22:aa:bb:cc",
|
|
"channel" : 48,
|
|
"phyMode" : "802.11ac",
|
|
"ssid" : "GuestWiFi"
|
|
}
|
|
}, {
|
|
"ethernetProfile" : {
|
|
"linkSpeed" : 0
|
|
},
|
|
"hardwareType" : "wireless",
|
|
"interfaceName" : "en0",
|
|
"addressProfiles" : [ {
|
|
"prefixLength" : 24,
|
|
"addressType" : "unique-local",
|
|
"ipAddress" : "2001:db8:3333:4444:5555:6666:7777:8888",
|
|
"routerHardwareAddress" : "5c:b1:3e:46:1c:84",
|
|
"gateway" : "192.168.0.254"
|
|
}, {
|
|
"prefixLength" : 24,
|
|
"addressType" : "unique-local",
|
|
"ipAddress" : "2001:db8:3333:4444:5555:6666:7777:8888",
|
|
"routerHardwareAddress" : "5c:b1:3e:46:1c:84",
|
|
"gateway" : "192.168.0.254"
|
|
} ],
|
|
"wirelessProfile" : {
|
|
"rssi" : -36,
|
|
"bssid" : "00:11:22:aa:bb:cc",
|
|
"channel" : 48,
|
|
"phyMode" : "802.11ac",
|
|
"ssid" : "GuestWiFi"
|
|
}
|
|
} ]
|
|
}
|
|
"""
|
|
expected_response = json.loads(response_body_json)
|
|
response = self.api.enable_endpoint_agent(
|
|
|
|
agent_id=agent_id,
|
|
|
|
aid=aid,
|
|
|
|
_headers=self.te_headers("enable_endpoint_agent"),
|
|
)
|
|
assert_constructed_model_matches_example_json(response, expected_response)
|
|
|
|
|
|
def test_enable_endpoint_agent_error_401(self) -> None:
|
|
"""Integration test for enable_endpoint_agent error path (HTTP 401)"""
|
|
agent_id = 'agent_id_example'
|
|
aid = '1234'
|
|
error_body_json = """
|
|
{
|
|
"error_description" : "Invalid access token",
|
|
"error" : "invalid_token"
|
|
}
|
|
"""
|
|
expected_error = json.loads(error_body_json)
|
|
with self.assertRaises(
|
|
ApiException.exception_class_for_http_status(401)
|
|
) as context:
|
|
self.api.enable_endpoint_agent(
|
|
|
|
agent_id=agent_id,
|
|
|
|
aid=aid,
|
|
|
|
_headers=self.te_headers("enable_endpoint_agent", error_status="401"),
|
|
)
|
|
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
|
|
|
|
|
|
def test_enable_endpoint_agent_error_403(self) -> None:
|
|
"""Integration test for enable_endpoint_agent error path (HTTP 403)"""
|
|
agent_id = 'agent_id_example'
|
|
aid = '1234'
|
|
error_body_json = """
|
|
{
|
|
"instance" : "instance",
|
|
"detail" : "detail",
|
|
"type" : "type",
|
|
"title" : "title",
|
|
"status" : 6
|
|
}
|
|
"""
|
|
expected_error = json.loads(error_body_json)
|
|
with self.assertRaises(
|
|
ApiException.exception_class_for_http_status(403)
|
|
) as context:
|
|
self.api.enable_endpoint_agent(
|
|
|
|
agent_id=agent_id,
|
|
|
|
aid=aid,
|
|
|
|
_headers=self.te_headers("enable_endpoint_agent", error_status="403"),
|
|
)
|
|
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
|
|
|
|
|
|
def test_enable_endpoint_agent_error_404(self) -> None:
|
|
"""Integration test for enable_endpoint_agent error path (HTTP 404)"""
|
|
agent_id = 'agent_id_example'
|
|
aid = '1234'
|
|
error_body_json = """
|
|
{
|
|
"instance" : "instance",
|
|
"detail" : "detail",
|
|
"type" : "type",
|
|
"title" : "title",
|
|
"status" : 6
|
|
}
|
|
"""
|
|
expected_error = json.loads(error_body_json)
|
|
with self.assertRaises(
|
|
ApiException.exception_class_for_http_status(404)
|
|
) as context:
|
|
self.api.enable_endpoint_agent(
|
|
|
|
agent_id=agent_id,
|
|
|
|
aid=aid,
|
|
|
|
_headers=self.te_headers("enable_endpoint_agent", error_status="404"),
|
|
)
|
|
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
|
|
|
|
|
|
def test_enable_endpoint_agent_error_429(self) -> None:
|
|
"""Integration test for enable_endpoint_agent error path (HTTP 429)"""
|
|
agent_id = 'agent_id_example'
|
|
aid = '1234'
|
|
error_body_json = """
|
|
{
|
|
"instance" : "instance",
|
|
"detail" : "detail",
|
|
"type" : "type",
|
|
"title" : "title",
|
|
"status" : 6
|
|
}
|
|
"""
|
|
expected_error = json.loads(error_body_json)
|
|
with self.assertRaises(
|
|
ApiException.exception_class_for_http_status(429)
|
|
) as context:
|
|
self.api.enable_endpoint_agent(
|
|
|
|
agent_id=agent_id,
|
|
|
|
aid=aid,
|
|
|
|
_headers=self.te_headers("enable_endpoint_agent", error_status="429"),
|
|
)
|
|
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
|
|
|
|
|
|
|
|
|
|
def test_filter_endpoint_agents_happy_path(self) -> None:
|
|
"""Integration test for filter_endpoint_agents success path"""
|
|
request_body_json = """
|
|
|
|
{
|
|
"searchSort" : [ {
|
|
"sort" : "platform",
|
|
"order" : "desc"
|
|
}, {
|
|
"sort" : "platform",
|
|
"order" : "desc"
|
|
} ],
|
|
"searchFilters" : {
|
|
"serialNumber" : [ "xaab2ba4-d40f-4e80-9363-7e4826556055", "xaab2ba4-d40f-4e80-9363-7e4826556055", "xaab2ba4-d40f-4e80-9363-7e4826556055", "xaab2ba4-d40f-4e80-9363-7e4826556055", "xaab2ba4-d40f-4e80-9363-7e4826556055" ],
|
|
"anyConnectDeviceId" : [ "JDLKSLFEIJER004334F" ],
|
|
"agentName" : [ "myagent-1234", "myagent-1234" ],
|
|
"locationSubdivision1Code" : [ "ENG", "ENG" ],
|
|
"platform" : [ "mac", "mac" ],
|
|
"licenseType" : [ "essentials", "essentials" ],
|
|
"osVersion" : [ "Version 10.15.2", "Version 10.15.2" ],
|
|
"computerName" : [ "DESKTOP-45AE8", "DESKTOP-45AE8" ],
|
|
"locationCountryISO" : [ "FR", "FR" ],
|
|
"id" : [ "861b7557-cd57-4bbb-b648-00bddf88ef49", "861b7557-cd57-4bbb-b648-00bddf88ef49" ],
|
|
"userPrincipalName" : [ "picard@c.com" ],
|
|
"locationCity" : [ "Paris", "Paris" ],
|
|
"username" : [ "picard" ]
|
|
},
|
|
"thresholdFilter" : {
|
|
"conditionalOperator" : "and",
|
|
"filters" : [ {
|
|
"name" : "last-seen-ms",
|
|
"value" : 0.8008281904610115,
|
|
"operator" : "gte"
|
|
}, {
|
|
"name" : "last-seen-ms",
|
|
"value" : 0.8008281904610115,
|
|
"operator" : "gte"
|
|
} ]
|
|
}
|
|
}
|
|
|
|
"""
|
|
agent_search_request = thousandeyes_sdk.endpoint_agents.models.AgentSearchRequest.from_json(request_body_json)
|
|
max = 5
|
|
cursor = 'cursor_example'
|
|
aid = '1234'
|
|
include_deleted = false
|
|
response_body_json = """
|
|
{
|
|
"_links" : {
|
|
"next" : {
|
|
"hreflang" : "hreflang",
|
|
"templated" : true,
|
|
"profile" : "profile",
|
|
"name" : "name",
|
|
"href" : "https://api.thousandeyes.com/v7/link/to/resource/id",
|
|
"type" : "type",
|
|
"deprecation" : "deprecation",
|
|
"title" : "title"
|
|
}
|
|
},
|
|
"totalAgents" : 1,
|
|
"agents" : [ {
|
|
"npcapVersion" : "npcapVersion",
|
|
"asnDetails" : {
|
|
"asName" : "Virgin Media Limited",
|
|
"asNumber" : 5089
|
|
},
|
|
"clients" : [ {
|
|
"browserExtensions" : [ {
|
|
"browser" : "edge",
|
|
"profile" : "Profile 1",
|
|
"active" : true,
|
|
"error" : "",
|
|
"version" : "0.123.0",
|
|
"enabled" : true
|
|
}, {
|
|
"browser" : "edge",
|
|
"profile" : "Profile 1",
|
|
"active" : true,
|
|
"error" : "",
|
|
"version" : "0.123.0",
|
|
"enabled" : true
|
|
} ],
|
|
"userProfile" : {
|
|
"userName" : "joeblogs32",
|
|
"userPrincipalName" : "joeblogs32@c.com"
|
|
}
|
|
}, {
|
|
"browserExtensions" : [ {
|
|
"browser" : "edge",
|
|
"profile" : "Profile 1",
|
|
"active" : true,
|
|
"error" : "",
|
|
"version" : "0.123.0",
|
|
"enabled" : true
|
|
}, {
|
|
"browser" : "edge",
|
|
"profile" : "Profile 1",
|
|
"active" : true,
|
|
"error" : "",
|
|
"version" : "0.123.0",
|
|
"enabled" : true
|
|
} ],
|
|
"userProfile" : {
|
|
"userName" : "joeblogs32",
|
|
"userPrincipalName" : "joeblogs32@c.com"
|
|
}
|
|
} ],
|
|
"agentType" : "endpoint",
|
|
"_links" : {
|
|
"self" : {
|
|
"hreflang" : "hreflang",
|
|
"templated" : true,
|
|
"profile" : "profile",
|
|
"name" : "name",
|
|
"href" : "https://api.thousandeyes.com/v7/link/to/resource/id",
|
|
"type" : "type",
|
|
"deprecation" : "deprecation",
|
|
"title" : "title"
|
|
}
|
|
},
|
|
"batteryMetrics" : {
|
|
"batteryHealthNormalizedPercent" : 0.92,
|
|
"batteryLevel" : "medium",
|
|
"batteryLevelNormalizedPercent" : 0.3
|
|
},
|
|
"publicIP" : "88.45.2.123",
|
|
"tcpDriverAvailable" : true,
|
|
"platform" : "mac",
|
|
"manufacturer" : "Apple, Inc.",
|
|
"targetVersion" : "0.123.4",
|
|
"cellularProfile" : {
|
|
"rssi" : -10,
|
|
"advertisedNetworkSubtype" : "LTE/HSPA",
|
|
"carrierName" : "T-Mobile",
|
|
"rsrq" : -30,
|
|
"rsrp" : -30,
|
|
"advertisedNetworkGen" : "2g, 3g, 4g, 5g",
|
|
"rscp" : -30,
|
|
"networkGen" : "2g, 3g, 4g, 5g",
|
|
"networkSubtype" : "LTE/HSPA",
|
|
"sinr" : 20
|
|
},
|
|
"nicModel" : "Intel(R) Wi-Fi 6 AX200 160MHz",
|
|
"createdAt" : "2022-05-26T23:37:16Z",
|
|
"numberOfClients" : 3,
|
|
"licenseType" : "essentials",
|
|
"osVersion" : "Version 10.15.2 (Build 19C57)",
|
|
"computerName" : "DESKJET-123",
|
|
"freeDiskSpaceNormalized" : 0.41,
|
|
"model" : "MacBookAir7,2",
|
|
"id" : "861b7557-cd57-4bbb-b648-00bddf88ef49",
|
|
"nicDriverVersion" : "22.250.0.9",
|
|
"serialNumber" : "xaab2ba4-d40f-4e80-9363-7e4826556055",
|
|
"externalMetadata" : [ {
|
|
"key" : "anyConnectDeviceId",
|
|
"value" : "DF434343D"
|
|
}, {
|
|
"key" : "anyConnectDeviceId",
|
|
"value" : "DF434343D"
|
|
} ],
|
|
"version" : "0.123.4",
|
|
"vpnProfiles" : [ {
|
|
"vpnClientNetworkRange" : [ "10.100.0.0/22" ],
|
|
"vpnGatewayAddress" : "vpnGatewayAddress",
|
|
"vpnType" : "cisco-anyconnect",
|
|
"interfaceName" : "interfaceName",
|
|
"vpnClientAddresses" : [ "10.100.0.10" ]
|
|
}, {
|
|
"vpnClientNetworkRange" : [ "10.100.0.0/22" ],
|
|
"vpnGatewayAddress" : "vpnGatewayAddress",
|
|
"vpnType" : "cisco-anyconnect",
|
|
"interfaceName" : "interfaceName",
|
|
"vpnClientAddresses" : [ "10.100.0.10" ]
|
|
} ],
|
|
"lastSeen" : "2022-05-26T23:37:16Z",
|
|
"deleted" : true,
|
|
"totalMemory" : "16384 MB",
|
|
"kernelVersion" : "Darwin 19.2.0",
|
|
"name" : "Office Printer",
|
|
"location" : {
|
|
"locationName" : "London",
|
|
"latitude" : 51.51279,
|
|
"longitude" : -0.09184
|
|
},
|
|
"aid" : "",
|
|
"status" : "enabled",
|
|
"networkInterfaceProfiles" : [ {
|
|
"ethernetProfile" : {
|
|
"linkSpeed" : 0
|
|
},
|
|
"hardwareType" : "wireless",
|
|
"interfaceName" : "en0",
|
|
"addressProfiles" : [ {
|
|
"prefixLength" : 24,
|
|
"addressType" : "unique-local",
|
|
"ipAddress" : "2001:db8:3333:4444:5555:6666:7777:8888",
|
|
"routerHardwareAddress" : "5c:b1:3e:46:1c:84",
|
|
"gateway" : "192.168.0.254"
|
|
}, {
|
|
"prefixLength" : 24,
|
|
"addressType" : "unique-local",
|
|
"ipAddress" : "2001:db8:3333:4444:5555:6666:7777:8888",
|
|
"routerHardwareAddress" : "5c:b1:3e:46:1c:84",
|
|
"gateway" : "192.168.0.254"
|
|
} ],
|
|
"wirelessProfile" : {
|
|
"rssi" : -36,
|
|
"bssid" : "00:11:22:aa:bb:cc",
|
|
"channel" : 48,
|
|
"phyMode" : "802.11ac",
|
|
"ssid" : "GuestWiFi"
|
|
}
|
|
}, {
|
|
"ethernetProfile" : {
|
|
"linkSpeed" : 0
|
|
},
|
|
"hardwareType" : "wireless",
|
|
"interfaceName" : "en0",
|
|
"addressProfiles" : [ {
|
|
"prefixLength" : 24,
|
|
"addressType" : "unique-local",
|
|
"ipAddress" : "2001:db8:3333:4444:5555:6666:7777:8888",
|
|
"routerHardwareAddress" : "5c:b1:3e:46:1c:84",
|
|
"gateway" : "192.168.0.254"
|
|
}, {
|
|
"prefixLength" : 24,
|
|
"addressType" : "unique-local",
|
|
"ipAddress" : "2001:db8:3333:4444:5555:6666:7777:8888",
|
|
"routerHardwareAddress" : "5c:b1:3e:46:1c:84",
|
|
"gateway" : "192.168.0.254"
|
|
} ],
|
|
"wirelessProfile" : {
|
|
"rssi" : -36,
|
|
"bssid" : "00:11:22:aa:bb:cc",
|
|
"channel" : 48,
|
|
"phyMode" : "802.11ac",
|
|
"ssid" : "GuestWiFi"
|
|
}
|
|
} ]
|
|
}, {
|
|
"npcapVersion" : "npcapVersion",
|
|
"asnDetails" : {
|
|
"asName" : "Virgin Media Limited",
|
|
"asNumber" : 5089
|
|
},
|
|
"clients" : [ {
|
|
"browserExtensions" : [ {
|
|
"browser" : "edge",
|
|
"profile" : "Profile 1",
|
|
"active" : true,
|
|
"error" : "",
|
|
"version" : "0.123.0",
|
|
"enabled" : true
|
|
}, {
|
|
"browser" : "edge",
|
|
"profile" : "Profile 1",
|
|
"active" : true,
|
|
"error" : "",
|
|
"version" : "0.123.0",
|
|
"enabled" : true
|
|
} ],
|
|
"userProfile" : {
|
|
"userName" : "joeblogs32",
|
|
"userPrincipalName" : "joeblogs32@c.com"
|
|
}
|
|
}, {
|
|
"browserExtensions" : [ {
|
|
"browser" : "edge",
|
|
"profile" : "Profile 1",
|
|
"active" : true,
|
|
"error" : "",
|
|
"version" : "0.123.0",
|
|
"enabled" : true
|
|
}, {
|
|
"browser" : "edge",
|
|
"profile" : "Profile 1",
|
|
"active" : true,
|
|
"error" : "",
|
|
"version" : "0.123.0",
|
|
"enabled" : true
|
|
} ],
|
|
"userProfile" : {
|
|
"userName" : "joeblogs32",
|
|
"userPrincipalName" : "joeblogs32@c.com"
|
|
}
|
|
} ],
|
|
"agentType" : "endpoint",
|
|
"_links" : {
|
|
"self" : {
|
|
"hreflang" : "hreflang",
|
|
"templated" : true,
|
|
"profile" : "profile",
|
|
"name" : "name",
|
|
"href" : "https://api.thousandeyes.com/v7/link/to/resource/id",
|
|
"type" : "type",
|
|
"deprecation" : "deprecation",
|
|
"title" : "title"
|
|
}
|
|
},
|
|
"batteryMetrics" : {
|
|
"batteryHealthNormalizedPercent" : 0.92,
|
|
"batteryLevel" : "medium",
|
|
"batteryLevelNormalizedPercent" : 0.3
|
|
},
|
|
"publicIP" : "88.45.2.123",
|
|
"tcpDriverAvailable" : true,
|
|
"platform" : "mac",
|
|
"manufacturer" : "Apple, Inc.",
|
|
"targetVersion" : "0.123.4",
|
|
"cellularProfile" : {
|
|
"rssi" : -10,
|
|
"advertisedNetworkSubtype" : "LTE/HSPA",
|
|
"carrierName" : "T-Mobile",
|
|
"rsrq" : -30,
|
|
"rsrp" : -30,
|
|
"advertisedNetworkGen" : "2g, 3g, 4g, 5g",
|
|
"rscp" : -30,
|
|
"networkGen" : "2g, 3g, 4g, 5g",
|
|
"networkSubtype" : "LTE/HSPA",
|
|
"sinr" : 20
|
|
},
|
|
"nicModel" : "Intel(R) Wi-Fi 6 AX200 160MHz",
|
|
"createdAt" : "2022-05-26T23:37:16Z",
|
|
"numberOfClients" : 3,
|
|
"licenseType" : "essentials",
|
|
"osVersion" : "Version 10.15.2 (Build 19C57)",
|
|
"computerName" : "DESKJET-123",
|
|
"freeDiskSpaceNormalized" : 0.41,
|
|
"model" : "MacBookAir7,2",
|
|
"id" : "861b7557-cd57-4bbb-b648-00bddf88ef49",
|
|
"nicDriverVersion" : "22.250.0.9",
|
|
"serialNumber" : "xaab2ba4-d40f-4e80-9363-7e4826556055",
|
|
"externalMetadata" : [ {
|
|
"key" : "anyConnectDeviceId",
|
|
"value" : "DF434343D"
|
|
}, {
|
|
"key" : "anyConnectDeviceId",
|
|
"value" : "DF434343D"
|
|
} ],
|
|
"version" : "0.123.4",
|
|
"vpnProfiles" : [ {
|
|
"vpnClientNetworkRange" : [ "10.100.0.0/22" ],
|
|
"vpnGatewayAddress" : "vpnGatewayAddress",
|
|
"vpnType" : "cisco-anyconnect",
|
|
"interfaceName" : "interfaceName",
|
|
"vpnClientAddresses" : [ "10.100.0.10" ]
|
|
}, {
|
|
"vpnClientNetworkRange" : [ "10.100.0.0/22" ],
|
|
"vpnGatewayAddress" : "vpnGatewayAddress",
|
|
"vpnType" : "cisco-anyconnect",
|
|
"interfaceName" : "interfaceName",
|
|
"vpnClientAddresses" : [ "10.100.0.10" ]
|
|
} ],
|
|
"lastSeen" : "2022-05-26T23:37:16Z",
|
|
"deleted" : true,
|
|
"totalMemory" : "16384 MB",
|
|
"kernelVersion" : "Darwin 19.2.0",
|
|
"name" : "Office Printer",
|
|
"location" : {
|
|
"locationName" : "London",
|
|
"latitude" : 51.51279,
|
|
"longitude" : -0.09184
|
|
},
|
|
"aid" : "",
|
|
"status" : "enabled",
|
|
"networkInterfaceProfiles" : [ {
|
|
"ethernetProfile" : {
|
|
"linkSpeed" : 0
|
|
},
|
|
"hardwareType" : "wireless",
|
|
"interfaceName" : "en0",
|
|
"addressProfiles" : [ {
|
|
"prefixLength" : 24,
|
|
"addressType" : "unique-local",
|
|
"ipAddress" : "2001:db8:3333:4444:5555:6666:7777:8888",
|
|
"routerHardwareAddress" : "5c:b1:3e:46:1c:84",
|
|
"gateway" : "192.168.0.254"
|
|
}, {
|
|
"prefixLength" : 24,
|
|
"addressType" : "unique-local",
|
|
"ipAddress" : "2001:db8:3333:4444:5555:6666:7777:8888",
|
|
"routerHardwareAddress" : "5c:b1:3e:46:1c:84",
|
|
"gateway" : "192.168.0.254"
|
|
} ],
|
|
"wirelessProfile" : {
|
|
"rssi" : -36,
|
|
"bssid" : "00:11:22:aa:bb:cc",
|
|
"channel" : 48,
|
|
"phyMode" : "802.11ac",
|
|
"ssid" : "GuestWiFi"
|
|
}
|
|
}, {
|
|
"ethernetProfile" : {
|
|
"linkSpeed" : 0
|
|
},
|
|
"hardwareType" : "wireless",
|
|
"interfaceName" : "en0",
|
|
"addressProfiles" : [ {
|
|
"prefixLength" : 24,
|
|
"addressType" : "unique-local",
|
|
"ipAddress" : "2001:db8:3333:4444:5555:6666:7777:8888",
|
|
"routerHardwareAddress" : "5c:b1:3e:46:1c:84",
|
|
"gateway" : "192.168.0.254"
|
|
}, {
|
|
"prefixLength" : 24,
|
|
"addressType" : "unique-local",
|
|
"ipAddress" : "2001:db8:3333:4444:5555:6666:7777:8888",
|
|
"routerHardwareAddress" : "5c:b1:3e:46:1c:84",
|
|
"gateway" : "192.168.0.254"
|
|
} ],
|
|
"wirelessProfile" : {
|
|
"rssi" : -36,
|
|
"bssid" : "00:11:22:aa:bb:cc",
|
|
"channel" : 48,
|
|
"phyMode" : "802.11ac",
|
|
"ssid" : "GuestWiFi"
|
|
}
|
|
} ]
|
|
} ]
|
|
}
|
|
"""
|
|
expected_response = json.loads(response_body_json)
|
|
response = self.api.filter_endpoint_agents(
|
|
|
|
agent_search_request=agent_search_request,
|
|
|
|
max=max,
|
|
|
|
cursor=cursor,
|
|
|
|
aid=aid,
|
|
|
|
include_deleted=include_deleted,
|
|
|
|
_headers=self.te_headers("filter_endpoint_agents"),
|
|
)
|
|
assert_constructed_model_matches_example_json(response, expected_response)
|
|
|
|
|
|
def test_filter_endpoint_agents_error_400(self) -> None:
|
|
"""Integration test for filter_endpoint_agents error path (HTTP 400)"""
|
|
request_body_json = """
|
|
|
|
{
|
|
"searchSort" : [ {
|
|
"sort" : "platform",
|
|
"order" : "desc"
|
|
}, {
|
|
"sort" : "platform",
|
|
"order" : "desc"
|
|
} ],
|
|
"searchFilters" : {
|
|
"serialNumber" : [ "xaab2ba4-d40f-4e80-9363-7e4826556055", "xaab2ba4-d40f-4e80-9363-7e4826556055", "xaab2ba4-d40f-4e80-9363-7e4826556055", "xaab2ba4-d40f-4e80-9363-7e4826556055", "xaab2ba4-d40f-4e80-9363-7e4826556055" ],
|
|
"anyConnectDeviceId" : [ "JDLKSLFEIJER004334F" ],
|
|
"agentName" : [ "myagent-1234", "myagent-1234" ],
|
|
"locationSubdivision1Code" : [ "ENG", "ENG" ],
|
|
"platform" : [ "mac", "mac" ],
|
|
"licenseType" : [ "essentials", "essentials" ],
|
|
"osVersion" : [ "Version 10.15.2", "Version 10.15.2" ],
|
|
"computerName" : [ "DESKTOP-45AE8", "DESKTOP-45AE8" ],
|
|
"locationCountryISO" : [ "FR", "FR" ],
|
|
"id" : [ "861b7557-cd57-4bbb-b648-00bddf88ef49", "861b7557-cd57-4bbb-b648-00bddf88ef49" ],
|
|
"userPrincipalName" : [ "picard@c.com" ],
|
|
"locationCity" : [ "Paris", "Paris" ],
|
|
"username" : [ "picard" ]
|
|
},
|
|
"thresholdFilter" : {
|
|
"conditionalOperator" : "and",
|
|
"filters" : [ {
|
|
"name" : "last-seen-ms",
|
|
"value" : 0.8008281904610115,
|
|
"operator" : "gte"
|
|
}, {
|
|
"name" : "last-seen-ms",
|
|
"value" : 0.8008281904610115,
|
|
"operator" : "gte"
|
|
} ]
|
|
}
|
|
}
|
|
|
|
"""
|
|
agent_search_request = thousandeyes_sdk.endpoint_agents.models.AgentSearchRequest.from_json(request_body_json)
|
|
max = 5
|
|
cursor = 'cursor_example'
|
|
aid = '1234'
|
|
include_deleted = false
|
|
error_body_json = """
|
|
{
|
|
"instance" : "instance",
|
|
"detail" : "detail",
|
|
"type" : "type",
|
|
"title" : "title",
|
|
"errors" : [ {
|
|
"code" : "code",
|
|
"field" : "field",
|
|
"message" : "message"
|
|
}, {
|
|
"code" : "code",
|
|
"field" : "field",
|
|
"message" : "message"
|
|
} ],
|
|
"status" : 0
|
|
}
|
|
"""
|
|
expected_error = json.loads(error_body_json)
|
|
with self.assertRaises(
|
|
ApiException.exception_class_for_http_status(400)
|
|
) as context:
|
|
self.api.filter_endpoint_agents(
|
|
|
|
agent_search_request=agent_search_request,
|
|
|
|
max=max,
|
|
|
|
cursor=cursor,
|
|
|
|
aid=aid,
|
|
|
|
include_deleted=include_deleted,
|
|
|
|
_headers=self.te_headers("filter_endpoint_agents", error_status="400"),
|
|
)
|
|
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
|
|
|
|
|
|
def test_filter_endpoint_agents_error_401(self) -> None:
|
|
"""Integration test for filter_endpoint_agents error path (HTTP 401)"""
|
|
request_body_json = """
|
|
|
|
{
|
|
"searchSort" : [ {
|
|
"sort" : "platform",
|
|
"order" : "desc"
|
|
}, {
|
|
"sort" : "platform",
|
|
"order" : "desc"
|
|
} ],
|
|
"searchFilters" : {
|
|
"serialNumber" : [ "xaab2ba4-d40f-4e80-9363-7e4826556055", "xaab2ba4-d40f-4e80-9363-7e4826556055", "xaab2ba4-d40f-4e80-9363-7e4826556055", "xaab2ba4-d40f-4e80-9363-7e4826556055", "xaab2ba4-d40f-4e80-9363-7e4826556055" ],
|
|
"anyConnectDeviceId" : [ "JDLKSLFEIJER004334F" ],
|
|
"agentName" : [ "myagent-1234", "myagent-1234" ],
|
|
"locationSubdivision1Code" : [ "ENG", "ENG" ],
|
|
"platform" : [ "mac", "mac" ],
|
|
"licenseType" : [ "essentials", "essentials" ],
|
|
"osVersion" : [ "Version 10.15.2", "Version 10.15.2" ],
|
|
"computerName" : [ "DESKTOP-45AE8", "DESKTOP-45AE8" ],
|
|
"locationCountryISO" : [ "FR", "FR" ],
|
|
"id" : [ "861b7557-cd57-4bbb-b648-00bddf88ef49", "861b7557-cd57-4bbb-b648-00bddf88ef49" ],
|
|
"userPrincipalName" : [ "picard@c.com" ],
|
|
"locationCity" : [ "Paris", "Paris" ],
|
|
"username" : [ "picard" ]
|
|
},
|
|
"thresholdFilter" : {
|
|
"conditionalOperator" : "and",
|
|
"filters" : [ {
|
|
"name" : "last-seen-ms",
|
|
"value" : 0.8008281904610115,
|
|
"operator" : "gte"
|
|
}, {
|
|
"name" : "last-seen-ms",
|
|
"value" : 0.8008281904610115,
|
|
"operator" : "gte"
|
|
} ]
|
|
}
|
|
}
|
|
|
|
"""
|
|
agent_search_request = thousandeyes_sdk.endpoint_agents.models.AgentSearchRequest.from_json(request_body_json)
|
|
max = 5
|
|
cursor = 'cursor_example'
|
|
aid = '1234'
|
|
include_deleted = false
|
|
error_body_json = """
|
|
{
|
|
"error_description" : "Invalid access token",
|
|
"error" : "invalid_token"
|
|
}
|
|
"""
|
|
expected_error = json.loads(error_body_json)
|
|
with self.assertRaises(
|
|
ApiException.exception_class_for_http_status(401)
|
|
) as context:
|
|
self.api.filter_endpoint_agents(
|
|
|
|
agent_search_request=agent_search_request,
|
|
|
|
max=max,
|
|
|
|
cursor=cursor,
|
|
|
|
aid=aid,
|
|
|
|
include_deleted=include_deleted,
|
|
|
|
_headers=self.te_headers("filter_endpoint_agents", error_status="401"),
|
|
)
|
|
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
|
|
|
|
|
|
def test_filter_endpoint_agents_error_403(self) -> None:
|
|
"""Integration test for filter_endpoint_agents error path (HTTP 403)"""
|
|
request_body_json = """
|
|
|
|
{
|
|
"searchSort" : [ {
|
|
"sort" : "platform",
|
|
"order" : "desc"
|
|
}, {
|
|
"sort" : "platform",
|
|
"order" : "desc"
|
|
} ],
|
|
"searchFilters" : {
|
|
"serialNumber" : [ "xaab2ba4-d40f-4e80-9363-7e4826556055", "xaab2ba4-d40f-4e80-9363-7e4826556055", "xaab2ba4-d40f-4e80-9363-7e4826556055", "xaab2ba4-d40f-4e80-9363-7e4826556055", "xaab2ba4-d40f-4e80-9363-7e4826556055" ],
|
|
"anyConnectDeviceId" : [ "JDLKSLFEIJER004334F" ],
|
|
"agentName" : [ "myagent-1234", "myagent-1234" ],
|
|
"locationSubdivision1Code" : [ "ENG", "ENG" ],
|
|
"platform" : [ "mac", "mac" ],
|
|
"licenseType" : [ "essentials", "essentials" ],
|
|
"osVersion" : [ "Version 10.15.2", "Version 10.15.2" ],
|
|
"computerName" : [ "DESKTOP-45AE8", "DESKTOP-45AE8" ],
|
|
"locationCountryISO" : [ "FR", "FR" ],
|
|
"id" : [ "861b7557-cd57-4bbb-b648-00bddf88ef49", "861b7557-cd57-4bbb-b648-00bddf88ef49" ],
|
|
"userPrincipalName" : [ "picard@c.com" ],
|
|
"locationCity" : [ "Paris", "Paris" ],
|
|
"username" : [ "picard" ]
|
|
},
|
|
"thresholdFilter" : {
|
|
"conditionalOperator" : "and",
|
|
"filters" : [ {
|
|
"name" : "last-seen-ms",
|
|
"value" : 0.8008281904610115,
|
|
"operator" : "gte"
|
|
}, {
|
|
"name" : "last-seen-ms",
|
|
"value" : 0.8008281904610115,
|
|
"operator" : "gte"
|
|
} ]
|
|
}
|
|
}
|
|
|
|
"""
|
|
agent_search_request = thousandeyes_sdk.endpoint_agents.models.AgentSearchRequest.from_json(request_body_json)
|
|
max = 5
|
|
cursor = 'cursor_example'
|
|
aid = '1234'
|
|
include_deleted = false
|
|
error_body_json = """
|
|
{
|
|
"instance" : "instance",
|
|
"detail" : "detail",
|
|
"type" : "type",
|
|
"title" : "title",
|
|
"status" : 6
|
|
}
|
|
"""
|
|
expected_error = json.loads(error_body_json)
|
|
with self.assertRaises(
|
|
ApiException.exception_class_for_http_status(403)
|
|
) as context:
|
|
self.api.filter_endpoint_agents(
|
|
|
|
agent_search_request=agent_search_request,
|
|
|
|
max=max,
|
|
|
|
cursor=cursor,
|
|
|
|
aid=aid,
|
|
|
|
include_deleted=include_deleted,
|
|
|
|
_headers=self.te_headers("filter_endpoint_agents", error_status="403"),
|
|
)
|
|
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
|
|
|
|
|
|
def test_filter_endpoint_agents_error_429(self) -> None:
|
|
"""Integration test for filter_endpoint_agents error path (HTTP 429)"""
|
|
request_body_json = """
|
|
|
|
{
|
|
"searchSort" : [ {
|
|
"sort" : "platform",
|
|
"order" : "desc"
|
|
}, {
|
|
"sort" : "platform",
|
|
"order" : "desc"
|
|
} ],
|
|
"searchFilters" : {
|
|
"serialNumber" : [ "xaab2ba4-d40f-4e80-9363-7e4826556055", "xaab2ba4-d40f-4e80-9363-7e4826556055", "xaab2ba4-d40f-4e80-9363-7e4826556055", "xaab2ba4-d40f-4e80-9363-7e4826556055", "xaab2ba4-d40f-4e80-9363-7e4826556055" ],
|
|
"anyConnectDeviceId" : [ "JDLKSLFEIJER004334F" ],
|
|
"agentName" : [ "myagent-1234", "myagent-1234" ],
|
|
"locationSubdivision1Code" : [ "ENG", "ENG" ],
|
|
"platform" : [ "mac", "mac" ],
|
|
"licenseType" : [ "essentials", "essentials" ],
|
|
"osVersion" : [ "Version 10.15.2", "Version 10.15.2" ],
|
|
"computerName" : [ "DESKTOP-45AE8", "DESKTOP-45AE8" ],
|
|
"locationCountryISO" : [ "FR", "FR" ],
|
|
"id" : [ "861b7557-cd57-4bbb-b648-00bddf88ef49", "861b7557-cd57-4bbb-b648-00bddf88ef49" ],
|
|
"userPrincipalName" : [ "picard@c.com" ],
|
|
"locationCity" : [ "Paris", "Paris" ],
|
|
"username" : [ "picard" ]
|
|
},
|
|
"thresholdFilter" : {
|
|
"conditionalOperator" : "and",
|
|
"filters" : [ {
|
|
"name" : "last-seen-ms",
|
|
"value" : 0.8008281904610115,
|
|
"operator" : "gte"
|
|
}, {
|
|
"name" : "last-seen-ms",
|
|
"value" : 0.8008281904610115,
|
|
"operator" : "gte"
|
|
} ]
|
|
}
|
|
}
|
|
|
|
"""
|
|
agent_search_request = thousandeyes_sdk.endpoint_agents.models.AgentSearchRequest.from_json(request_body_json)
|
|
max = 5
|
|
cursor = 'cursor_example'
|
|
aid = '1234'
|
|
include_deleted = false
|
|
error_body_json = """
|
|
{
|
|
"instance" : "instance",
|
|
"detail" : "detail",
|
|
"type" : "type",
|
|
"title" : "title",
|
|
"status" : 6
|
|
}
|
|
"""
|
|
expected_error = json.loads(error_body_json)
|
|
with self.assertRaises(
|
|
ApiException.exception_class_for_http_status(429)
|
|
) as context:
|
|
self.api.filter_endpoint_agents(
|
|
|
|
agent_search_request=agent_search_request,
|
|
|
|
max=max,
|
|
|
|
cursor=cursor,
|
|
|
|
aid=aid,
|
|
|
|
include_deleted=include_deleted,
|
|
|
|
_headers=self.te_headers("filter_endpoint_agents", error_status="429"),
|
|
)
|
|
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
|
|
|
|
|
|
|
|
|
|
def test_get_endpoint_agent_happy_path(self) -> None:
|
|
"""Integration test for get_endpoint_agent success path"""
|
|
agent_id = 'agent_id_example'
|
|
aid = '1234'
|
|
include_deleted = false
|
|
response_body_json = """
|
|
{
|
|
"npcapVersion" : "npcapVersion",
|
|
"asnDetails" : {
|
|
"asName" : "Virgin Media Limited",
|
|
"asNumber" : 5089
|
|
},
|
|
"clients" : [ {
|
|
"browserExtensions" : [ {
|
|
"browser" : "edge",
|
|
"profile" : "Profile 1",
|
|
"active" : true,
|
|
"error" : "",
|
|
"version" : "0.123.0",
|
|
"enabled" : true
|
|
}, {
|
|
"browser" : "edge",
|
|
"profile" : "Profile 1",
|
|
"active" : true,
|
|
"error" : "",
|
|
"version" : "0.123.0",
|
|
"enabled" : true
|
|
} ],
|
|
"userProfile" : {
|
|
"userName" : "joeblogs32",
|
|
"userPrincipalName" : "joeblogs32@c.com"
|
|
}
|
|
}, {
|
|
"browserExtensions" : [ {
|
|
"browser" : "edge",
|
|
"profile" : "Profile 1",
|
|
"active" : true,
|
|
"error" : "",
|
|
"version" : "0.123.0",
|
|
"enabled" : true
|
|
}, {
|
|
"browser" : "edge",
|
|
"profile" : "Profile 1",
|
|
"active" : true,
|
|
"error" : "",
|
|
"version" : "0.123.0",
|
|
"enabled" : true
|
|
} ],
|
|
"userProfile" : {
|
|
"userName" : "joeblogs32",
|
|
"userPrincipalName" : "joeblogs32@c.com"
|
|
}
|
|
} ],
|
|
"agentType" : "endpoint",
|
|
"_links" : {
|
|
"self" : {
|
|
"hreflang" : "hreflang",
|
|
"templated" : true,
|
|
"profile" : "profile",
|
|
"name" : "name",
|
|
"href" : "https://api.thousandeyes.com/v7/link/to/resource/id",
|
|
"type" : "type",
|
|
"deprecation" : "deprecation",
|
|
"title" : "title"
|
|
}
|
|
},
|
|
"batteryMetrics" : {
|
|
"batteryHealthNormalizedPercent" : 0.92,
|
|
"batteryLevel" : "medium",
|
|
"batteryLevelNormalizedPercent" : 0.3
|
|
},
|
|
"publicIP" : "88.45.2.123",
|
|
"tcpDriverAvailable" : true,
|
|
"platform" : "mac",
|
|
"manufacturer" : "Apple, Inc.",
|
|
"targetVersion" : "0.123.4",
|
|
"cellularProfile" : {
|
|
"rssi" : -10,
|
|
"advertisedNetworkSubtype" : "LTE/HSPA",
|
|
"carrierName" : "T-Mobile",
|
|
"rsrq" : -30,
|
|
"rsrp" : -30,
|
|
"advertisedNetworkGen" : "2g, 3g, 4g, 5g",
|
|
"rscp" : -30,
|
|
"networkGen" : "2g, 3g, 4g, 5g",
|
|
"networkSubtype" : "LTE/HSPA",
|
|
"sinr" : 20
|
|
},
|
|
"nicModel" : "Intel(R) Wi-Fi 6 AX200 160MHz",
|
|
"createdAt" : "2022-05-26T23:37:16Z",
|
|
"numberOfClients" : 3,
|
|
"licenseType" : "essentials",
|
|
"osVersion" : "Version 10.15.2 (Build 19C57)",
|
|
"computerName" : "DESKJET-123",
|
|
"freeDiskSpaceNormalized" : 0.41,
|
|
"model" : "MacBookAir7,2",
|
|
"id" : "861b7557-cd57-4bbb-b648-00bddf88ef49",
|
|
"nicDriverVersion" : "22.250.0.9",
|
|
"serialNumber" : "xaab2ba4-d40f-4e80-9363-7e4826556055",
|
|
"externalMetadata" : [ {
|
|
"key" : "anyConnectDeviceId",
|
|
"value" : "DF434343D"
|
|
}, {
|
|
"key" : "anyConnectDeviceId",
|
|
"value" : "DF434343D"
|
|
} ],
|
|
"version" : "0.123.4",
|
|
"vpnProfiles" : [ {
|
|
"vpnClientNetworkRange" : [ "10.100.0.0/22" ],
|
|
"vpnGatewayAddress" : "vpnGatewayAddress",
|
|
"vpnType" : "cisco-anyconnect",
|
|
"interfaceName" : "interfaceName",
|
|
"vpnClientAddresses" : [ "10.100.0.10" ]
|
|
}, {
|
|
"vpnClientNetworkRange" : [ "10.100.0.0/22" ],
|
|
"vpnGatewayAddress" : "vpnGatewayAddress",
|
|
"vpnType" : "cisco-anyconnect",
|
|
"interfaceName" : "interfaceName",
|
|
"vpnClientAddresses" : [ "10.100.0.10" ]
|
|
} ],
|
|
"lastSeen" : "2022-05-26T23:37:16Z",
|
|
"deleted" : true,
|
|
"totalMemory" : "16384 MB",
|
|
"kernelVersion" : "Darwin 19.2.0",
|
|
"name" : "Office Printer",
|
|
"location" : {
|
|
"locationName" : "London",
|
|
"latitude" : 51.51279,
|
|
"longitude" : -0.09184
|
|
},
|
|
"aid" : "",
|
|
"status" : "enabled",
|
|
"networkInterfaceProfiles" : [ {
|
|
"ethernetProfile" : {
|
|
"linkSpeed" : 0
|
|
},
|
|
"hardwareType" : "wireless",
|
|
"interfaceName" : "en0",
|
|
"addressProfiles" : [ {
|
|
"prefixLength" : 24,
|
|
"addressType" : "unique-local",
|
|
"ipAddress" : "2001:db8:3333:4444:5555:6666:7777:8888",
|
|
"routerHardwareAddress" : "5c:b1:3e:46:1c:84",
|
|
"gateway" : "192.168.0.254"
|
|
}, {
|
|
"prefixLength" : 24,
|
|
"addressType" : "unique-local",
|
|
"ipAddress" : "2001:db8:3333:4444:5555:6666:7777:8888",
|
|
"routerHardwareAddress" : "5c:b1:3e:46:1c:84",
|
|
"gateway" : "192.168.0.254"
|
|
} ],
|
|
"wirelessProfile" : {
|
|
"rssi" : -36,
|
|
"bssid" : "00:11:22:aa:bb:cc",
|
|
"channel" : 48,
|
|
"phyMode" : "802.11ac",
|
|
"ssid" : "GuestWiFi"
|
|
}
|
|
}, {
|
|
"ethernetProfile" : {
|
|
"linkSpeed" : 0
|
|
},
|
|
"hardwareType" : "wireless",
|
|
"interfaceName" : "en0",
|
|
"addressProfiles" : [ {
|
|
"prefixLength" : 24,
|
|
"addressType" : "unique-local",
|
|
"ipAddress" : "2001:db8:3333:4444:5555:6666:7777:8888",
|
|
"routerHardwareAddress" : "5c:b1:3e:46:1c:84",
|
|
"gateway" : "192.168.0.254"
|
|
}, {
|
|
"prefixLength" : 24,
|
|
"addressType" : "unique-local",
|
|
"ipAddress" : "2001:db8:3333:4444:5555:6666:7777:8888",
|
|
"routerHardwareAddress" : "5c:b1:3e:46:1c:84",
|
|
"gateway" : "192.168.0.254"
|
|
} ],
|
|
"wirelessProfile" : {
|
|
"rssi" : -36,
|
|
"bssid" : "00:11:22:aa:bb:cc",
|
|
"channel" : 48,
|
|
"phyMode" : "802.11ac",
|
|
"ssid" : "GuestWiFi"
|
|
}
|
|
} ]
|
|
}
|
|
"""
|
|
expected_response = json.loads(response_body_json)
|
|
response = self.api.get_endpoint_agent(
|
|
|
|
agent_id=agent_id,
|
|
|
|
aid=aid,
|
|
|
|
include_deleted=include_deleted,
|
|
|
|
_headers=self.te_headers("get_endpoint_agent"),
|
|
)
|
|
assert_constructed_model_matches_example_json(response, expected_response)
|
|
|
|
|
|
def test_get_endpoint_agent_error_401(self) -> None:
|
|
"""Integration test for get_endpoint_agent error path (HTTP 401)"""
|
|
agent_id = 'agent_id_example'
|
|
aid = '1234'
|
|
include_deleted = false
|
|
error_body_json = """
|
|
{
|
|
"error_description" : "Invalid access token",
|
|
"error" : "invalid_token"
|
|
}
|
|
"""
|
|
expected_error = json.loads(error_body_json)
|
|
with self.assertRaises(
|
|
ApiException.exception_class_for_http_status(401)
|
|
) as context:
|
|
self.api.get_endpoint_agent(
|
|
|
|
agent_id=agent_id,
|
|
|
|
aid=aid,
|
|
|
|
include_deleted=include_deleted,
|
|
|
|
_headers=self.te_headers("get_endpoint_agent", error_status="401"),
|
|
)
|
|
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
|
|
|
|
|
|
def test_get_endpoint_agent_error_403(self) -> None:
|
|
"""Integration test for get_endpoint_agent error path (HTTP 403)"""
|
|
agent_id = 'agent_id_example'
|
|
aid = '1234'
|
|
include_deleted = false
|
|
error_body_json = """
|
|
{
|
|
"instance" : "instance",
|
|
"detail" : "detail",
|
|
"type" : "type",
|
|
"title" : "title",
|
|
"status" : 6
|
|
}
|
|
"""
|
|
expected_error = json.loads(error_body_json)
|
|
with self.assertRaises(
|
|
ApiException.exception_class_for_http_status(403)
|
|
) as context:
|
|
self.api.get_endpoint_agent(
|
|
|
|
agent_id=agent_id,
|
|
|
|
aid=aid,
|
|
|
|
include_deleted=include_deleted,
|
|
|
|
_headers=self.te_headers("get_endpoint_agent", error_status="403"),
|
|
)
|
|
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
|
|
|
|
|
|
def test_get_endpoint_agent_error_404(self) -> None:
|
|
"""Integration test for get_endpoint_agent error path (HTTP 404)"""
|
|
agent_id = 'agent_id_example'
|
|
aid = '1234'
|
|
include_deleted = false
|
|
error_body_json = """
|
|
{
|
|
"instance" : "instance",
|
|
"detail" : "detail",
|
|
"type" : "type",
|
|
"title" : "title",
|
|
"status" : 6
|
|
}
|
|
"""
|
|
expected_error = json.loads(error_body_json)
|
|
with self.assertRaises(
|
|
ApiException.exception_class_for_http_status(404)
|
|
) as context:
|
|
self.api.get_endpoint_agent(
|
|
|
|
agent_id=agent_id,
|
|
|
|
aid=aid,
|
|
|
|
include_deleted=include_deleted,
|
|
|
|
_headers=self.te_headers("get_endpoint_agent", error_status="404"),
|
|
)
|
|
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
|
|
|
|
|
|
def test_get_endpoint_agent_error_429(self) -> None:
|
|
"""Integration test for get_endpoint_agent error path (HTTP 429)"""
|
|
agent_id = 'agent_id_example'
|
|
aid = '1234'
|
|
include_deleted = false
|
|
error_body_json = """
|
|
{
|
|
"instance" : "instance",
|
|
"detail" : "detail",
|
|
"type" : "type",
|
|
"title" : "title",
|
|
"status" : 6
|
|
}
|
|
"""
|
|
expected_error = json.loads(error_body_json)
|
|
with self.assertRaises(
|
|
ApiException.exception_class_for_http_status(429)
|
|
) as context:
|
|
self.api.get_endpoint_agent(
|
|
|
|
agent_id=agent_id,
|
|
|
|
aid=aid,
|
|
|
|
include_deleted=include_deleted,
|
|
|
|
_headers=self.te_headers("get_endpoint_agent", error_status="429"),
|
|
)
|
|
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
|
|
|
|
|
|
|
|
|
|
def test_get_endpoint_agents_happy_path(self) -> None:
|
|
"""Integration test for get_endpoint_agents success path"""
|
|
max = 5
|
|
cursor = 'cursor_example'
|
|
aid = '1234'
|
|
include_deleted = false
|
|
use_all_permitted_aids = False
|
|
agent_name = 'agent_name_example'
|
|
computer_name = 'computer_name_example'
|
|
response_body_json = """
|
|
{
|
|
"_links" : {
|
|
"next" : {
|
|
"hreflang" : "hreflang",
|
|
"templated" : true,
|
|
"profile" : "profile",
|
|
"name" : "name",
|
|
"href" : "https://api.thousandeyes.com/v7/link/to/resource/id",
|
|
"type" : "type",
|
|
"deprecation" : "deprecation",
|
|
"title" : "title"
|
|
},
|
|
"self" : {
|
|
"hreflang" : "hreflang",
|
|
"templated" : true,
|
|
"profile" : "profile",
|
|
"name" : "name",
|
|
"href" : "https://api.thousandeyes.com/v7/link/to/resource/id",
|
|
"type" : "type",
|
|
"deprecation" : "deprecation",
|
|
"title" : "title"
|
|
}
|
|
},
|
|
"totalAgents" : 1,
|
|
"agents" : [ {
|
|
"npcapVersion" : "npcapVersion",
|
|
"asnDetails" : {
|
|
"asName" : "Virgin Media Limited",
|
|
"asNumber" : 5089
|
|
},
|
|
"clients" : [ {
|
|
"browserExtensions" : [ {
|
|
"browser" : "edge",
|
|
"profile" : "Profile 1",
|
|
"active" : true,
|
|
"error" : "",
|
|
"version" : "0.123.0",
|
|
"enabled" : true
|
|
}, {
|
|
"browser" : "edge",
|
|
"profile" : "Profile 1",
|
|
"active" : true,
|
|
"error" : "",
|
|
"version" : "0.123.0",
|
|
"enabled" : true
|
|
} ],
|
|
"userProfile" : {
|
|
"userName" : "joeblogs32",
|
|
"userPrincipalName" : "joeblogs32@c.com"
|
|
}
|
|
}, {
|
|
"browserExtensions" : [ {
|
|
"browser" : "edge",
|
|
"profile" : "Profile 1",
|
|
"active" : true,
|
|
"error" : "",
|
|
"version" : "0.123.0",
|
|
"enabled" : true
|
|
}, {
|
|
"browser" : "edge",
|
|
"profile" : "Profile 1",
|
|
"active" : true,
|
|
"error" : "",
|
|
"version" : "0.123.0",
|
|
"enabled" : true
|
|
} ],
|
|
"userProfile" : {
|
|
"userName" : "joeblogs32",
|
|
"userPrincipalName" : "joeblogs32@c.com"
|
|
}
|
|
} ],
|
|
"agentType" : "endpoint",
|
|
"_links" : {
|
|
"self" : {
|
|
"hreflang" : "hreflang",
|
|
"templated" : true,
|
|
"profile" : "profile",
|
|
"name" : "name",
|
|
"href" : "https://api.thousandeyes.com/v7/link/to/resource/id",
|
|
"type" : "type",
|
|
"deprecation" : "deprecation",
|
|
"title" : "title"
|
|
}
|
|
},
|
|
"batteryMetrics" : {
|
|
"batteryHealthNormalizedPercent" : 0.92,
|
|
"batteryLevel" : "medium",
|
|
"batteryLevelNormalizedPercent" : 0.3
|
|
},
|
|
"publicIP" : "88.45.2.123",
|
|
"tcpDriverAvailable" : true,
|
|
"platform" : "mac",
|
|
"manufacturer" : "Apple, Inc.",
|
|
"targetVersion" : "0.123.4",
|
|
"cellularProfile" : {
|
|
"rssi" : -10,
|
|
"advertisedNetworkSubtype" : "LTE/HSPA",
|
|
"carrierName" : "T-Mobile",
|
|
"rsrq" : -30,
|
|
"rsrp" : -30,
|
|
"advertisedNetworkGen" : "2g, 3g, 4g, 5g",
|
|
"rscp" : -30,
|
|
"networkGen" : "2g, 3g, 4g, 5g",
|
|
"networkSubtype" : "LTE/HSPA",
|
|
"sinr" : 20
|
|
},
|
|
"nicModel" : "Intel(R) Wi-Fi 6 AX200 160MHz",
|
|
"createdAt" : "2022-05-26T23:37:16Z",
|
|
"numberOfClients" : 3,
|
|
"licenseType" : "essentials",
|
|
"osVersion" : "Version 10.15.2 (Build 19C57)",
|
|
"computerName" : "DESKJET-123",
|
|
"freeDiskSpaceNormalized" : 0.41,
|
|
"model" : "MacBookAir7,2",
|
|
"id" : "861b7557-cd57-4bbb-b648-00bddf88ef49",
|
|
"nicDriverVersion" : "22.250.0.9",
|
|
"serialNumber" : "xaab2ba4-d40f-4e80-9363-7e4826556055",
|
|
"externalMetadata" : [ {
|
|
"key" : "anyConnectDeviceId",
|
|
"value" : "DF434343D"
|
|
}, {
|
|
"key" : "anyConnectDeviceId",
|
|
"value" : "DF434343D"
|
|
} ],
|
|
"version" : "0.123.4",
|
|
"vpnProfiles" : [ {
|
|
"vpnClientNetworkRange" : [ "10.100.0.0/22" ],
|
|
"vpnGatewayAddress" : "vpnGatewayAddress",
|
|
"vpnType" : "cisco-anyconnect",
|
|
"interfaceName" : "interfaceName",
|
|
"vpnClientAddresses" : [ "10.100.0.10" ]
|
|
}, {
|
|
"vpnClientNetworkRange" : [ "10.100.0.0/22" ],
|
|
"vpnGatewayAddress" : "vpnGatewayAddress",
|
|
"vpnType" : "cisco-anyconnect",
|
|
"interfaceName" : "interfaceName",
|
|
"vpnClientAddresses" : [ "10.100.0.10" ]
|
|
} ],
|
|
"lastSeen" : "2022-05-26T23:37:16Z",
|
|
"deleted" : true,
|
|
"totalMemory" : "16384 MB",
|
|
"kernelVersion" : "Darwin 19.2.0",
|
|
"name" : "Office Printer",
|
|
"location" : {
|
|
"locationName" : "London",
|
|
"latitude" : 51.51279,
|
|
"longitude" : -0.09184
|
|
},
|
|
"aid" : "",
|
|
"status" : "enabled",
|
|
"networkInterfaceProfiles" : [ {
|
|
"ethernetProfile" : {
|
|
"linkSpeed" : 0
|
|
},
|
|
"hardwareType" : "wireless",
|
|
"interfaceName" : "en0",
|
|
"addressProfiles" : [ {
|
|
"prefixLength" : 24,
|
|
"addressType" : "unique-local",
|
|
"ipAddress" : "2001:db8:3333:4444:5555:6666:7777:8888",
|
|
"routerHardwareAddress" : "5c:b1:3e:46:1c:84",
|
|
"gateway" : "192.168.0.254"
|
|
}, {
|
|
"prefixLength" : 24,
|
|
"addressType" : "unique-local",
|
|
"ipAddress" : "2001:db8:3333:4444:5555:6666:7777:8888",
|
|
"routerHardwareAddress" : "5c:b1:3e:46:1c:84",
|
|
"gateway" : "192.168.0.254"
|
|
} ],
|
|
"wirelessProfile" : {
|
|
"rssi" : -36,
|
|
"bssid" : "00:11:22:aa:bb:cc",
|
|
"channel" : 48,
|
|
"phyMode" : "802.11ac",
|
|
"ssid" : "GuestWiFi"
|
|
}
|
|
}, {
|
|
"ethernetProfile" : {
|
|
"linkSpeed" : 0
|
|
},
|
|
"hardwareType" : "wireless",
|
|
"interfaceName" : "en0",
|
|
"addressProfiles" : [ {
|
|
"prefixLength" : 24,
|
|
"addressType" : "unique-local",
|
|
"ipAddress" : "2001:db8:3333:4444:5555:6666:7777:8888",
|
|
"routerHardwareAddress" : "5c:b1:3e:46:1c:84",
|
|
"gateway" : "192.168.0.254"
|
|
}, {
|
|
"prefixLength" : 24,
|
|
"addressType" : "unique-local",
|
|
"ipAddress" : "2001:db8:3333:4444:5555:6666:7777:8888",
|
|
"routerHardwareAddress" : "5c:b1:3e:46:1c:84",
|
|
"gateway" : "192.168.0.254"
|
|
} ],
|
|
"wirelessProfile" : {
|
|
"rssi" : -36,
|
|
"bssid" : "00:11:22:aa:bb:cc",
|
|
"channel" : 48,
|
|
"phyMode" : "802.11ac",
|
|
"ssid" : "GuestWiFi"
|
|
}
|
|
} ]
|
|
}, {
|
|
"npcapVersion" : "npcapVersion",
|
|
"asnDetails" : {
|
|
"asName" : "Virgin Media Limited",
|
|
"asNumber" : 5089
|
|
},
|
|
"clients" : [ {
|
|
"browserExtensions" : [ {
|
|
"browser" : "edge",
|
|
"profile" : "Profile 1",
|
|
"active" : true,
|
|
"error" : "",
|
|
"version" : "0.123.0",
|
|
"enabled" : true
|
|
}, {
|
|
"browser" : "edge",
|
|
"profile" : "Profile 1",
|
|
"active" : true,
|
|
"error" : "",
|
|
"version" : "0.123.0",
|
|
"enabled" : true
|
|
} ],
|
|
"userProfile" : {
|
|
"userName" : "joeblogs32",
|
|
"userPrincipalName" : "joeblogs32@c.com"
|
|
}
|
|
}, {
|
|
"browserExtensions" : [ {
|
|
"browser" : "edge",
|
|
"profile" : "Profile 1",
|
|
"active" : true,
|
|
"error" : "",
|
|
"version" : "0.123.0",
|
|
"enabled" : true
|
|
}, {
|
|
"browser" : "edge",
|
|
"profile" : "Profile 1",
|
|
"active" : true,
|
|
"error" : "",
|
|
"version" : "0.123.0",
|
|
"enabled" : true
|
|
} ],
|
|
"userProfile" : {
|
|
"userName" : "joeblogs32",
|
|
"userPrincipalName" : "joeblogs32@c.com"
|
|
}
|
|
} ],
|
|
"agentType" : "endpoint",
|
|
"_links" : {
|
|
"self" : {
|
|
"hreflang" : "hreflang",
|
|
"templated" : true,
|
|
"profile" : "profile",
|
|
"name" : "name",
|
|
"href" : "https://api.thousandeyes.com/v7/link/to/resource/id",
|
|
"type" : "type",
|
|
"deprecation" : "deprecation",
|
|
"title" : "title"
|
|
}
|
|
},
|
|
"batteryMetrics" : {
|
|
"batteryHealthNormalizedPercent" : 0.92,
|
|
"batteryLevel" : "medium",
|
|
"batteryLevelNormalizedPercent" : 0.3
|
|
},
|
|
"publicIP" : "88.45.2.123",
|
|
"tcpDriverAvailable" : true,
|
|
"platform" : "mac",
|
|
"manufacturer" : "Apple, Inc.",
|
|
"targetVersion" : "0.123.4",
|
|
"cellularProfile" : {
|
|
"rssi" : -10,
|
|
"advertisedNetworkSubtype" : "LTE/HSPA",
|
|
"carrierName" : "T-Mobile",
|
|
"rsrq" : -30,
|
|
"rsrp" : -30,
|
|
"advertisedNetworkGen" : "2g, 3g, 4g, 5g",
|
|
"rscp" : -30,
|
|
"networkGen" : "2g, 3g, 4g, 5g",
|
|
"networkSubtype" : "LTE/HSPA",
|
|
"sinr" : 20
|
|
},
|
|
"nicModel" : "Intel(R) Wi-Fi 6 AX200 160MHz",
|
|
"createdAt" : "2022-05-26T23:37:16Z",
|
|
"numberOfClients" : 3,
|
|
"licenseType" : "essentials",
|
|
"osVersion" : "Version 10.15.2 (Build 19C57)",
|
|
"computerName" : "DESKJET-123",
|
|
"freeDiskSpaceNormalized" : 0.41,
|
|
"model" : "MacBookAir7,2",
|
|
"id" : "861b7557-cd57-4bbb-b648-00bddf88ef49",
|
|
"nicDriverVersion" : "22.250.0.9",
|
|
"serialNumber" : "xaab2ba4-d40f-4e80-9363-7e4826556055",
|
|
"externalMetadata" : [ {
|
|
"key" : "anyConnectDeviceId",
|
|
"value" : "DF434343D"
|
|
}, {
|
|
"key" : "anyConnectDeviceId",
|
|
"value" : "DF434343D"
|
|
} ],
|
|
"version" : "0.123.4",
|
|
"vpnProfiles" : [ {
|
|
"vpnClientNetworkRange" : [ "10.100.0.0/22" ],
|
|
"vpnGatewayAddress" : "vpnGatewayAddress",
|
|
"vpnType" : "cisco-anyconnect",
|
|
"interfaceName" : "interfaceName",
|
|
"vpnClientAddresses" : [ "10.100.0.10" ]
|
|
}, {
|
|
"vpnClientNetworkRange" : [ "10.100.0.0/22" ],
|
|
"vpnGatewayAddress" : "vpnGatewayAddress",
|
|
"vpnType" : "cisco-anyconnect",
|
|
"interfaceName" : "interfaceName",
|
|
"vpnClientAddresses" : [ "10.100.0.10" ]
|
|
} ],
|
|
"lastSeen" : "2022-05-26T23:37:16Z",
|
|
"deleted" : true,
|
|
"totalMemory" : "16384 MB",
|
|
"kernelVersion" : "Darwin 19.2.0",
|
|
"name" : "Office Printer",
|
|
"location" : {
|
|
"locationName" : "London",
|
|
"latitude" : 51.51279,
|
|
"longitude" : -0.09184
|
|
},
|
|
"aid" : "",
|
|
"status" : "enabled",
|
|
"networkInterfaceProfiles" : [ {
|
|
"ethernetProfile" : {
|
|
"linkSpeed" : 0
|
|
},
|
|
"hardwareType" : "wireless",
|
|
"interfaceName" : "en0",
|
|
"addressProfiles" : [ {
|
|
"prefixLength" : 24,
|
|
"addressType" : "unique-local",
|
|
"ipAddress" : "2001:db8:3333:4444:5555:6666:7777:8888",
|
|
"routerHardwareAddress" : "5c:b1:3e:46:1c:84",
|
|
"gateway" : "192.168.0.254"
|
|
}, {
|
|
"prefixLength" : 24,
|
|
"addressType" : "unique-local",
|
|
"ipAddress" : "2001:db8:3333:4444:5555:6666:7777:8888",
|
|
"routerHardwareAddress" : "5c:b1:3e:46:1c:84",
|
|
"gateway" : "192.168.0.254"
|
|
} ],
|
|
"wirelessProfile" : {
|
|
"rssi" : -36,
|
|
"bssid" : "00:11:22:aa:bb:cc",
|
|
"channel" : 48,
|
|
"phyMode" : "802.11ac",
|
|
"ssid" : "GuestWiFi"
|
|
}
|
|
}, {
|
|
"ethernetProfile" : {
|
|
"linkSpeed" : 0
|
|
},
|
|
"hardwareType" : "wireless",
|
|
"interfaceName" : "en0",
|
|
"addressProfiles" : [ {
|
|
"prefixLength" : 24,
|
|
"addressType" : "unique-local",
|
|
"ipAddress" : "2001:db8:3333:4444:5555:6666:7777:8888",
|
|
"routerHardwareAddress" : "5c:b1:3e:46:1c:84",
|
|
"gateway" : "192.168.0.254"
|
|
}, {
|
|
"prefixLength" : 24,
|
|
"addressType" : "unique-local",
|
|
"ipAddress" : "2001:db8:3333:4444:5555:6666:7777:8888",
|
|
"routerHardwareAddress" : "5c:b1:3e:46:1c:84",
|
|
"gateway" : "192.168.0.254"
|
|
} ],
|
|
"wirelessProfile" : {
|
|
"rssi" : -36,
|
|
"bssid" : "00:11:22:aa:bb:cc",
|
|
"channel" : 48,
|
|
"phyMode" : "802.11ac",
|
|
"ssid" : "GuestWiFi"
|
|
}
|
|
} ]
|
|
} ]
|
|
}
|
|
"""
|
|
expected_response = json.loads(response_body_json)
|
|
response = self.api.get_endpoint_agents(
|
|
|
|
max=max,
|
|
|
|
cursor=cursor,
|
|
|
|
aid=aid,
|
|
|
|
include_deleted=include_deleted,
|
|
|
|
use_all_permitted_aids=use_all_permitted_aids,
|
|
|
|
agent_name=agent_name,
|
|
|
|
computer_name=computer_name,
|
|
|
|
_headers=self.te_headers("get_endpoint_agents"),
|
|
)
|
|
assert_constructed_model_matches_example_json(response, expected_response)
|
|
|
|
|
|
def test_get_endpoint_agents_error_401(self) -> None:
|
|
"""Integration test for get_endpoint_agents error path (HTTP 401)"""
|
|
max = 5
|
|
cursor = 'cursor_example'
|
|
aid = '1234'
|
|
include_deleted = false
|
|
use_all_permitted_aids = False
|
|
agent_name = 'agent_name_example'
|
|
computer_name = 'computer_name_example'
|
|
error_body_json = """
|
|
{
|
|
"error_description" : "Invalid access token",
|
|
"error" : "invalid_token"
|
|
}
|
|
"""
|
|
expected_error = json.loads(error_body_json)
|
|
with self.assertRaises(
|
|
ApiException.exception_class_for_http_status(401)
|
|
) as context:
|
|
self.api.get_endpoint_agents(
|
|
|
|
max=max,
|
|
|
|
cursor=cursor,
|
|
|
|
aid=aid,
|
|
|
|
include_deleted=include_deleted,
|
|
|
|
use_all_permitted_aids=use_all_permitted_aids,
|
|
|
|
agent_name=agent_name,
|
|
|
|
computer_name=computer_name,
|
|
|
|
_headers=self.te_headers("get_endpoint_agents", error_status="401"),
|
|
)
|
|
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
|
|
|
|
|
|
def test_get_endpoint_agents_error_403(self) -> None:
|
|
"""Integration test for get_endpoint_agents error path (HTTP 403)"""
|
|
max = 5
|
|
cursor = 'cursor_example'
|
|
aid = '1234'
|
|
include_deleted = false
|
|
use_all_permitted_aids = False
|
|
agent_name = 'agent_name_example'
|
|
computer_name = 'computer_name_example'
|
|
error_body_json = """
|
|
{
|
|
"instance" : "instance",
|
|
"detail" : "detail",
|
|
"type" : "type",
|
|
"title" : "title",
|
|
"status" : 6
|
|
}
|
|
"""
|
|
expected_error = json.loads(error_body_json)
|
|
with self.assertRaises(
|
|
ApiException.exception_class_for_http_status(403)
|
|
) as context:
|
|
self.api.get_endpoint_agents(
|
|
|
|
max=max,
|
|
|
|
cursor=cursor,
|
|
|
|
aid=aid,
|
|
|
|
include_deleted=include_deleted,
|
|
|
|
use_all_permitted_aids=use_all_permitted_aids,
|
|
|
|
agent_name=agent_name,
|
|
|
|
computer_name=computer_name,
|
|
|
|
_headers=self.te_headers("get_endpoint_agents", error_status="403"),
|
|
)
|
|
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
|
|
|
|
|
|
def test_get_endpoint_agents_error_429(self) -> None:
|
|
"""Integration test for get_endpoint_agents error path (HTTP 429)"""
|
|
max = 5
|
|
cursor = 'cursor_example'
|
|
aid = '1234'
|
|
include_deleted = false
|
|
use_all_permitted_aids = False
|
|
agent_name = 'agent_name_example'
|
|
computer_name = 'computer_name_example'
|
|
error_body_json = """
|
|
{
|
|
"instance" : "instance",
|
|
"detail" : "detail",
|
|
"type" : "type",
|
|
"title" : "title",
|
|
"status" : 6
|
|
}
|
|
"""
|
|
expected_error = json.loads(error_body_json)
|
|
with self.assertRaises(
|
|
ApiException.exception_class_for_http_status(429)
|
|
) as context:
|
|
self.api.get_endpoint_agents(
|
|
|
|
max=max,
|
|
|
|
cursor=cursor,
|
|
|
|
aid=aid,
|
|
|
|
include_deleted=include_deleted,
|
|
|
|
use_all_permitted_aids=use_all_permitted_aids,
|
|
|
|
agent_name=agent_name,
|
|
|
|
computer_name=computer_name,
|
|
|
|
_headers=self.te_headers("get_endpoint_agents", error_status="429"),
|
|
)
|
|
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
|
|
|
|
|
|
|
|
|
|
def test_get_endpoint_agents_connection_string_happy_path(self) -> None:
|
|
"""Integration test for get_endpoint_agents_connection_string success path"""
|
|
aid = '1234'
|
|
response_body_json = """
|
|
{
|
|
"connectionString" : "D2xZSLlqo64Xe2EnYisklA==",
|
|
"_links" : {
|
|
"self" : {
|
|
"hreflang" : "hreflang",
|
|
"templated" : true,
|
|
"profile" : "profile",
|
|
"name" : "name",
|
|
"href" : "https://api.thousandeyes.com/v7/link/to/resource/id",
|
|
"type" : "type",
|
|
"deprecation" : "deprecation",
|
|
"title" : "title"
|
|
}
|
|
}
|
|
}
|
|
"""
|
|
expected_response = json.loads(response_body_json)
|
|
response = self.api.get_endpoint_agents_connection_string(
|
|
|
|
aid=aid,
|
|
|
|
_headers=self.te_headers("get_endpoint_agents_connection_string"),
|
|
)
|
|
assert_constructed_model_matches_example_json(response, expected_response)
|
|
|
|
|
|
def test_get_endpoint_agents_connection_string_error_401(self) -> None:
|
|
"""Integration test for get_endpoint_agents_connection_string error path (HTTP 401)"""
|
|
aid = '1234'
|
|
error_body_json = """
|
|
{
|
|
"error_description" : "Invalid access token",
|
|
"error" : "invalid_token"
|
|
}
|
|
"""
|
|
expected_error = json.loads(error_body_json)
|
|
with self.assertRaises(
|
|
ApiException.exception_class_for_http_status(401)
|
|
) as context:
|
|
self.api.get_endpoint_agents_connection_string(
|
|
|
|
aid=aid,
|
|
|
|
_headers=self.te_headers("get_endpoint_agents_connection_string", error_status="401"),
|
|
)
|
|
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
|
|
|
|
|
|
def test_get_endpoint_agents_connection_string_error_403(self) -> None:
|
|
"""Integration test for get_endpoint_agents_connection_string error path (HTTP 403)"""
|
|
aid = '1234'
|
|
error_body_json = """
|
|
{
|
|
"instance" : "instance",
|
|
"detail" : "detail",
|
|
"type" : "type",
|
|
"title" : "title",
|
|
"status" : 6
|
|
}
|
|
"""
|
|
expected_error = json.loads(error_body_json)
|
|
with self.assertRaises(
|
|
ApiException.exception_class_for_http_status(403)
|
|
) as context:
|
|
self.api.get_endpoint_agents_connection_string(
|
|
|
|
aid=aid,
|
|
|
|
_headers=self.te_headers("get_endpoint_agents_connection_string", error_status="403"),
|
|
)
|
|
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
|
|
|
|
|
|
def test_get_endpoint_agents_connection_string_error_429(self) -> None:
|
|
"""Integration test for get_endpoint_agents_connection_string error path (HTTP 429)"""
|
|
aid = '1234'
|
|
error_body_json = """
|
|
{
|
|
"instance" : "instance",
|
|
"detail" : "detail",
|
|
"type" : "type",
|
|
"title" : "title",
|
|
"status" : 6
|
|
}
|
|
"""
|
|
expected_error = json.loads(error_body_json)
|
|
with self.assertRaises(
|
|
ApiException.exception_class_for_http_status(429)
|
|
) as context:
|
|
self.api.get_endpoint_agents_connection_string(
|
|
|
|
aid=aid,
|
|
|
|
_headers=self.te_headers("get_endpoint_agents_connection_string", error_status="429"),
|
|
)
|
|
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
|
|
|
|
|
|
|
|
|
|
def test_update_endpoint_agent_happy_path(self) -> None:
|
|
"""Integration test for update_endpoint_agent success path"""
|
|
request_body_json = """
|
|
|
|
{
|
|
"licenseType" : "essentials",
|
|
"name" : "Office Printer"
|
|
}
|
|
|
|
"""
|
|
endpoint_agent_update = thousandeyes_sdk.endpoint_agents.models.EndpointAgentUpdate.from_json(request_body_json)
|
|
agent_id = 'agent_id_example'
|
|
aid = '1234'
|
|
response_body_json = """
|
|
{
|
|
"npcapVersion" : "npcapVersion",
|
|
"asnDetails" : {
|
|
"asName" : "Virgin Media Limited",
|
|
"asNumber" : 5089
|
|
},
|
|
"clients" : [ {
|
|
"browserExtensions" : [ {
|
|
"browser" : "edge",
|
|
"profile" : "Profile 1",
|
|
"active" : true,
|
|
"error" : "",
|
|
"version" : "0.123.0",
|
|
"enabled" : true
|
|
}, {
|
|
"browser" : "edge",
|
|
"profile" : "Profile 1",
|
|
"active" : true,
|
|
"error" : "",
|
|
"version" : "0.123.0",
|
|
"enabled" : true
|
|
} ],
|
|
"userProfile" : {
|
|
"userName" : "joeblogs32",
|
|
"userPrincipalName" : "joeblogs32@c.com"
|
|
}
|
|
}, {
|
|
"browserExtensions" : [ {
|
|
"browser" : "edge",
|
|
"profile" : "Profile 1",
|
|
"active" : true,
|
|
"error" : "",
|
|
"version" : "0.123.0",
|
|
"enabled" : true
|
|
}, {
|
|
"browser" : "edge",
|
|
"profile" : "Profile 1",
|
|
"active" : true,
|
|
"error" : "",
|
|
"version" : "0.123.0",
|
|
"enabled" : true
|
|
} ],
|
|
"userProfile" : {
|
|
"userName" : "joeblogs32",
|
|
"userPrincipalName" : "joeblogs32@c.com"
|
|
}
|
|
} ],
|
|
"agentType" : "endpoint",
|
|
"_links" : {
|
|
"self" : {
|
|
"hreflang" : "hreflang",
|
|
"templated" : true,
|
|
"profile" : "profile",
|
|
"name" : "name",
|
|
"href" : "https://api.thousandeyes.com/v7/link/to/resource/id",
|
|
"type" : "type",
|
|
"deprecation" : "deprecation",
|
|
"title" : "title"
|
|
}
|
|
},
|
|
"batteryMetrics" : {
|
|
"batteryHealthNormalizedPercent" : 0.92,
|
|
"batteryLevel" : "medium",
|
|
"batteryLevelNormalizedPercent" : 0.3
|
|
},
|
|
"publicIP" : "88.45.2.123",
|
|
"tcpDriverAvailable" : true,
|
|
"platform" : "mac",
|
|
"manufacturer" : "Apple, Inc.",
|
|
"targetVersion" : "0.123.4",
|
|
"cellularProfile" : {
|
|
"rssi" : -10,
|
|
"advertisedNetworkSubtype" : "LTE/HSPA",
|
|
"carrierName" : "T-Mobile",
|
|
"rsrq" : -30,
|
|
"rsrp" : -30,
|
|
"advertisedNetworkGen" : "2g, 3g, 4g, 5g",
|
|
"rscp" : -30,
|
|
"networkGen" : "2g, 3g, 4g, 5g",
|
|
"networkSubtype" : "LTE/HSPA",
|
|
"sinr" : 20
|
|
},
|
|
"nicModel" : "Intel(R) Wi-Fi 6 AX200 160MHz",
|
|
"createdAt" : "2022-05-26T23:37:16Z",
|
|
"numberOfClients" : 3,
|
|
"licenseType" : "essentials",
|
|
"osVersion" : "Version 10.15.2 (Build 19C57)",
|
|
"computerName" : "DESKJET-123",
|
|
"freeDiskSpaceNormalized" : 0.41,
|
|
"model" : "MacBookAir7,2",
|
|
"id" : "861b7557-cd57-4bbb-b648-00bddf88ef49",
|
|
"nicDriverVersion" : "22.250.0.9",
|
|
"serialNumber" : "xaab2ba4-d40f-4e80-9363-7e4826556055",
|
|
"externalMetadata" : [ {
|
|
"key" : "anyConnectDeviceId",
|
|
"value" : "DF434343D"
|
|
}, {
|
|
"key" : "anyConnectDeviceId",
|
|
"value" : "DF434343D"
|
|
} ],
|
|
"version" : "0.123.4",
|
|
"vpnProfiles" : [ {
|
|
"vpnClientNetworkRange" : [ "10.100.0.0/22" ],
|
|
"vpnGatewayAddress" : "vpnGatewayAddress",
|
|
"vpnType" : "cisco-anyconnect",
|
|
"interfaceName" : "interfaceName",
|
|
"vpnClientAddresses" : [ "10.100.0.10" ]
|
|
}, {
|
|
"vpnClientNetworkRange" : [ "10.100.0.0/22" ],
|
|
"vpnGatewayAddress" : "vpnGatewayAddress",
|
|
"vpnType" : "cisco-anyconnect",
|
|
"interfaceName" : "interfaceName",
|
|
"vpnClientAddresses" : [ "10.100.0.10" ]
|
|
} ],
|
|
"lastSeen" : "2022-05-26T23:37:16Z",
|
|
"deleted" : true,
|
|
"totalMemory" : "16384 MB",
|
|
"kernelVersion" : "Darwin 19.2.0",
|
|
"name" : "Office Printer",
|
|
"location" : {
|
|
"locationName" : "London",
|
|
"latitude" : 51.51279,
|
|
"longitude" : -0.09184
|
|
},
|
|
"aid" : "",
|
|
"status" : "enabled",
|
|
"networkInterfaceProfiles" : [ {
|
|
"ethernetProfile" : {
|
|
"linkSpeed" : 0
|
|
},
|
|
"hardwareType" : "wireless",
|
|
"interfaceName" : "en0",
|
|
"addressProfiles" : [ {
|
|
"prefixLength" : 24,
|
|
"addressType" : "unique-local",
|
|
"ipAddress" : "2001:db8:3333:4444:5555:6666:7777:8888",
|
|
"routerHardwareAddress" : "5c:b1:3e:46:1c:84",
|
|
"gateway" : "192.168.0.254"
|
|
}, {
|
|
"prefixLength" : 24,
|
|
"addressType" : "unique-local",
|
|
"ipAddress" : "2001:db8:3333:4444:5555:6666:7777:8888",
|
|
"routerHardwareAddress" : "5c:b1:3e:46:1c:84",
|
|
"gateway" : "192.168.0.254"
|
|
} ],
|
|
"wirelessProfile" : {
|
|
"rssi" : -36,
|
|
"bssid" : "00:11:22:aa:bb:cc",
|
|
"channel" : 48,
|
|
"phyMode" : "802.11ac",
|
|
"ssid" : "GuestWiFi"
|
|
}
|
|
}, {
|
|
"ethernetProfile" : {
|
|
"linkSpeed" : 0
|
|
},
|
|
"hardwareType" : "wireless",
|
|
"interfaceName" : "en0",
|
|
"addressProfiles" : [ {
|
|
"prefixLength" : 24,
|
|
"addressType" : "unique-local",
|
|
"ipAddress" : "2001:db8:3333:4444:5555:6666:7777:8888",
|
|
"routerHardwareAddress" : "5c:b1:3e:46:1c:84",
|
|
"gateway" : "192.168.0.254"
|
|
}, {
|
|
"prefixLength" : 24,
|
|
"addressType" : "unique-local",
|
|
"ipAddress" : "2001:db8:3333:4444:5555:6666:7777:8888",
|
|
"routerHardwareAddress" : "5c:b1:3e:46:1c:84",
|
|
"gateway" : "192.168.0.254"
|
|
} ],
|
|
"wirelessProfile" : {
|
|
"rssi" : -36,
|
|
"bssid" : "00:11:22:aa:bb:cc",
|
|
"channel" : 48,
|
|
"phyMode" : "802.11ac",
|
|
"ssid" : "GuestWiFi"
|
|
}
|
|
} ]
|
|
}
|
|
"""
|
|
expected_response = json.loads(response_body_json)
|
|
response = self.api.update_endpoint_agent(
|
|
|
|
agent_id=agent_id,
|
|
|
|
aid=aid,
|
|
|
|
endpoint_agent_update=endpoint_agent_update,
|
|
|
|
_headers=self.te_headers("update_endpoint_agent"),
|
|
)
|
|
assert_constructed_model_matches_example_json(response, expected_response)
|
|
|
|
|
|
def test_update_endpoint_agent_error_401(self) -> None:
|
|
"""Integration test for update_endpoint_agent error path (HTTP 401)"""
|
|
request_body_json = """
|
|
|
|
{
|
|
"licenseType" : "essentials",
|
|
"name" : "Office Printer"
|
|
}
|
|
|
|
"""
|
|
endpoint_agent_update = thousandeyes_sdk.endpoint_agents.models.EndpointAgentUpdate.from_json(request_body_json)
|
|
agent_id = 'agent_id_example'
|
|
aid = '1234'
|
|
error_body_json = """
|
|
{
|
|
"error_description" : "Invalid access token",
|
|
"error" : "invalid_token"
|
|
}
|
|
"""
|
|
expected_error = json.loads(error_body_json)
|
|
with self.assertRaises(
|
|
ApiException.exception_class_for_http_status(401)
|
|
) as context:
|
|
self.api.update_endpoint_agent(
|
|
|
|
agent_id=agent_id,
|
|
|
|
aid=aid,
|
|
|
|
endpoint_agent_update=endpoint_agent_update,
|
|
|
|
_headers=self.te_headers("update_endpoint_agent", error_status="401"),
|
|
)
|
|
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
|
|
|
|
|
|
def test_update_endpoint_agent_error_403(self) -> None:
|
|
"""Integration test for update_endpoint_agent error path (HTTP 403)"""
|
|
request_body_json = """
|
|
|
|
{
|
|
"licenseType" : "essentials",
|
|
"name" : "Office Printer"
|
|
}
|
|
|
|
"""
|
|
endpoint_agent_update = thousandeyes_sdk.endpoint_agents.models.EndpointAgentUpdate.from_json(request_body_json)
|
|
agent_id = 'agent_id_example'
|
|
aid = '1234'
|
|
error_body_json = """
|
|
{
|
|
"instance" : "instance",
|
|
"detail" : "detail",
|
|
"type" : "type",
|
|
"title" : "title",
|
|
"status" : 6
|
|
}
|
|
"""
|
|
expected_error = json.loads(error_body_json)
|
|
with self.assertRaises(
|
|
ApiException.exception_class_for_http_status(403)
|
|
) as context:
|
|
self.api.update_endpoint_agent(
|
|
|
|
agent_id=agent_id,
|
|
|
|
aid=aid,
|
|
|
|
endpoint_agent_update=endpoint_agent_update,
|
|
|
|
_headers=self.te_headers("update_endpoint_agent", error_status="403"),
|
|
)
|
|
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
|
|
|
|
|
|
def test_update_endpoint_agent_error_404(self) -> None:
|
|
"""Integration test for update_endpoint_agent error path (HTTP 404)"""
|
|
request_body_json = """
|
|
|
|
{
|
|
"licenseType" : "essentials",
|
|
"name" : "Office Printer"
|
|
}
|
|
|
|
"""
|
|
endpoint_agent_update = thousandeyes_sdk.endpoint_agents.models.EndpointAgentUpdate.from_json(request_body_json)
|
|
agent_id = 'agent_id_example'
|
|
aid = '1234'
|
|
error_body_json = """
|
|
{
|
|
"instance" : "instance",
|
|
"detail" : "detail",
|
|
"type" : "type",
|
|
"title" : "title",
|
|
"status" : 6
|
|
}
|
|
"""
|
|
expected_error = json.loads(error_body_json)
|
|
with self.assertRaises(
|
|
ApiException.exception_class_for_http_status(404)
|
|
) as context:
|
|
self.api.update_endpoint_agent(
|
|
|
|
agent_id=agent_id,
|
|
|
|
aid=aid,
|
|
|
|
endpoint_agent_update=endpoint_agent_update,
|
|
|
|
_headers=self.te_headers("update_endpoint_agent", error_status="404"),
|
|
)
|
|
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
|
|
|
|
|
|
def test_update_endpoint_agent_error_429(self) -> None:
|
|
"""Integration test for update_endpoint_agent error path (HTTP 429)"""
|
|
request_body_json = """
|
|
|
|
{
|
|
"licenseType" : "essentials",
|
|
"name" : "Office Printer"
|
|
}
|
|
|
|
"""
|
|
endpoint_agent_update = thousandeyes_sdk.endpoint_agents.models.EndpointAgentUpdate.from_json(request_body_json)
|
|
agent_id = 'agent_id_example'
|
|
aid = '1234'
|
|
error_body_json = """
|
|
{
|
|
"instance" : "instance",
|
|
"detail" : "detail",
|
|
"type" : "type",
|
|
"title" : "title",
|
|
"status" : 6
|
|
}
|
|
"""
|
|
expected_error = json.loads(error_body_json)
|
|
with self.assertRaises(
|
|
ApiException.exception_class_for_http_status(429)
|
|
) as context:
|
|
self.api.update_endpoint_agent(
|
|
|
|
agent_id=agent_id,
|
|
|
|
aid=aid,
|
|
|
|
endpoint_agent_update=endpoint_agent_update,
|
|
|
|
_headers=self.te_headers("update_endpoint_agent", error_status="429"),
|
|
)
|
|
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
unittest.main()
|