increase timeout for security eventlogs
This commit is contained in:
@@ -162,18 +162,44 @@ class TestAgentViews(TacticalTestCase):
|
|||||||
self.check_not_authenticated("get", url)
|
self.check_not_authenticated("get", url)
|
||||||
|
|
||||||
@patch("agents.models.Agent.nats_cmd")
|
@patch("agents.models.Agent.nats_cmd")
|
||||||
def test_get_event_log(self, mock_ret):
|
def test_get_event_log(self, nats_cmd):
|
||||||
url = f"/agents/{self.agent.pk}/geteventlog/Application/30/"
|
url = f"/agents/{self.agent.pk}/geteventlog/Application/22/"
|
||||||
|
|
||||||
with open(
|
with open(
|
||||||
os.path.join(settings.BASE_DIR, "tacticalrmm/test_data/appeventlog.json")
|
os.path.join(settings.BASE_DIR, "tacticalrmm/test_data/appeventlog.json")
|
||||||
) as f:
|
) as f:
|
||||||
mock_ret.return_value = json.load(f)
|
nats_cmd.return_value = json.load(f)
|
||||||
|
|
||||||
r = self.client.get(url)
|
r = self.client.get(url)
|
||||||
self.assertEqual(r.status_code, 200)
|
self.assertEqual(r.status_code, 200)
|
||||||
|
nats_cmd.assert_called_with(
|
||||||
|
{
|
||||||
|
"func": "eventlog",
|
||||||
|
"timeout": 30,
|
||||||
|
"payload": {
|
||||||
|
"logname": "Application",
|
||||||
|
"days": str(22),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
timeout=32,
|
||||||
|
)
|
||||||
|
|
||||||
mock_ret.return_value = "timeout"
|
url = f"/agents/{self.agent.pk}/geteventlog/Security/6/"
|
||||||
|
r = self.client.get(url)
|
||||||
|
self.assertEqual(r.status_code, 200)
|
||||||
|
nats_cmd.assert_called_with(
|
||||||
|
{
|
||||||
|
"func": "eventlog",
|
||||||
|
"timeout": 180,
|
||||||
|
"payload": {
|
||||||
|
"logname": "Security",
|
||||||
|
"days": str(6),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
timeout=182,
|
||||||
|
)
|
||||||
|
|
||||||
|
nats_cmd.return_value = "timeout"
|
||||||
r = self.client.get(url)
|
r = self.client.get(url)
|
||||||
self.assertEqual(r.status_code, 400)
|
self.assertEqual(r.status_code, 400)
|
||||||
|
|
||||||
|
|||||||
@@ -184,15 +184,16 @@ def get_event_log(request, pk, logtype, days):
|
|||||||
agent = get_object_or_404(Agent, pk=pk)
|
agent = get_object_or_404(Agent, pk=pk)
|
||||||
if not agent.has_nats:
|
if not agent.has_nats:
|
||||||
return notify_error("Requires agent version 1.1.0 or greater")
|
return notify_error("Requires agent version 1.1.0 or greater")
|
||||||
|
timeout = 180 if logtype == "Security" else 30
|
||||||
data = {
|
data = {
|
||||||
"func": "eventlog",
|
"func": "eventlog",
|
||||||
"timeout": 30,
|
"timeout": timeout,
|
||||||
"payload": {
|
"payload": {
|
||||||
"logname": logtype,
|
"logname": logtype,
|
||||||
"days": str(days),
|
"days": str(days),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
r = asyncio.run(agent.nats_cmd(data, timeout=32))
|
r = asyncio.run(agent.nats_cmd(data, timeout=timeout + 2))
|
||||||
if r == "timeout":
|
if r == "timeout":
|
||||||
return notify_error("Unable to contact the agent")
|
return notify_error("Unable to contact the agent")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user