-
Notifications
You must be signed in to change notification settings - Fork 66
Expand file tree
/
Copy pathtest_create_agent_group.py
More file actions
59 lines (50 loc) · 2.02 KB
/
Copy pathtest_create_agent_group.py
File metadata and controls
59 lines (50 loc) · 2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# SPDX-FileCopyrightText: 2025 Greenbone AG
#
# SPDX-License-Identifier: GPL-3.0-or-later
from gvm.errors import RequiredArgument
class GmpCreateAgentGroupTestMixin:
def test_create_agent_group(self):
self.gmp.create_agent_group(
name="ExampleGroup",
agent_ids=["agent-1", "agent-2"],
comment="Sample comment",
scheduler_cron_time="0 */5 * * *",
)
self.connection.send.has_been_called_with(
b"<create_agent_group>"
b"<name>ExampleGroup</name>"
b"<scheduler_cron_time>0 */5 * * *</scheduler_cron_time>"
b"<comment>Sample comment</comment>"
b'<agents><agent id="agent-1"/><agent id="agent-2"/></agents>'
b"</create_agent_group>"
)
def test_create_agent_group_without_name(self):
with self.assertRaises(RequiredArgument):
self.gmp.create_agent_group(
name="",
agent_ids=["agent-1"],
scheduler_cron_time="0 */5 * * *",
)
def test_create_agent_group_without_agents(self):
with self.assertRaises(RequiredArgument):
self.gmp.create_agent_group(
name="Group", agent_ids=[], scheduler_cron_time="0 */5 * * *"
)
def test_create_agent_group_without_scheduler_cron_time(self):
with self.assertRaises(RequiredArgument):
self.gmp.create_agent_group(
name="Group", agent_ids=["agent-1"], scheduler_cron_time=None
)
def test_create_agent_group_without_comment(self):
self.gmp.create_agent_group(
name="GroupX",
agent_ids=["a1", "a2"],
scheduler_cron_time="0 */5 * * *",
)
self.connection.send.has_been_called_with(
b"<create_agent_group>"
b"<name>GroupX</name>"
b"<scheduler_cron_time>0 */5 * * *</scheduler_cron_time>"
b'<agents><agent id="a1"/><agent id="a2"/></agents>'
b"</create_agent_group>"
)