-
Notifications
You must be signed in to change notification settings - Fork 66
Expand file tree
/
Copy pathtest_modify_agent_group.py
More file actions
85 lines (73 loc) · 3.04 KB
/
Copy pathtest_modify_agent_group.py
File metadata and controls
85 lines (73 loc) · 3.04 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# SPDX-FileCopyrightText: 2025 Greenbone AG
#
# SPDX-License-Identifier: GPL-3.0-or-later
from gvm.errors import RequiredArgument
class GmpModifyAgentGroupTestMixin:
def test_modify_agent_group(self):
self.gmp.modify_agent_group(
agent_group_id="group-1",
name="NewName",
comment="Updated comment",
scheduler_cron_time="0 */5 * * *",
agent_ids=["agent-1", "agent-2"],
)
self.connection.send.has_been_called_with(
b'<modify_agent_group agent_group_id="group-1">'
b"<scheduler_cron_time>0 */5 * * *</scheduler_cron_time>"
b"<name>NewName</name>"
b"<comment>Updated comment</comment>"
b'<agents><agent id="agent-1"/><agent id="agent-2"/></agents>'
b"</modify_agent_group>"
)
def test_modify_agent_group_without_id(self):
with self.assertRaises(RequiredArgument):
self.gmp.modify_agent_group(
agent_group_id=None, scheduler_cron_time="0 */5 * * *"
)
def test_modify_agent_group_without_scheduler_cron_time(self):
with self.assertRaises(RequiredArgument):
self.gmp.modify_agent_group(
agent_group_id="group-1", scheduler_cron_time=None
)
def test_modify_agent_group_without_name(self):
self.gmp.modify_agent_group(
agent_group_id="group-1",
comment="Updated comment",
scheduler_cron_time="0 */5 * * *",
agent_ids=["agent-1", "agent-2"],
)
self.connection.send.has_been_called_with(
b'<modify_agent_group agent_group_id="group-1">'
b"<scheduler_cron_time>0 */5 * * *</scheduler_cron_time>"
b"<comment>Updated comment</comment>"
b'<agents><agent id="agent-1"/><agent id="agent-2"/></agents>'
b"</modify_agent_group>"
)
def test_modify_agent_group_without_comment(self):
self.gmp.modify_agent_group(
agent_group_id="group-1",
name="NewName",
scheduler_cron_time="0 */5 * * *",
agent_ids=["agent-1", "agent-2"],
)
self.connection.send.has_been_called_with(
b'<modify_agent_group agent_group_id="group-1">'
b"<scheduler_cron_time>0 */5 * * *</scheduler_cron_time>"
b"<name>NewName</name>"
b'<agents><agent id="agent-1"/><agent id="agent-2"/></agents>'
b"</modify_agent_group>"
)
def test_modify_agent_group_without_agent_ids(self):
self.gmp.modify_agent_group(
agent_group_id="group-1",
name="NewName",
comment="Updated comment",
scheduler_cron_time="0 */5 * * *",
)
self.connection.send.has_been_called_with(
b'<modify_agent_group agent_group_id="group-1">'
b"<scheduler_cron_time>0 */5 * * *</scheduler_cron_time>"
b"<name>NewName</name>"
b"<comment>Updated comment</comment>"
b"</modify_agent_group>"
)