File: test_modify_agents.py

package info (click to toggle)
python-gvm 26.5.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 5,132 kB
  • sloc: python: 44,662; makefile: 18
file content (41 lines) | stat: -rw-r--r-- 1,347 bytes parent folder | download
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
# SPDX-FileCopyrightText: 2025 Greenbone AG
#
# SPDX-License-Identifier: GPL-3.0-or-later

from gvm.errors import RequiredArgument


class GmpModifyAgentsTestMixin:
    def test_modify_agents_basic(self):
        self.gmp.modify_agents(agent_ids=["agent-123"])

        self.connection.send.has_been_called_with(
            b"<modify_agents>"
            b'<agents><agent id="agent-123"/></agents>'
            b"</modify_agents>"
        )

    def test_modify_agents_with_all_fields(self):
        self.gmp.modify_agents(
            agent_ids=["agent-123", "agent-456"],
            authorized=True,
            min_interval=300,
            heartbeat_interval=600,
            schedule="@every 6h",
            comment="Updated agents",
        )

        self.connection.send.has_been_called_with(
            b"<modify_agents>"
            b'<agents><agent id="agent-123"/><agent id="agent-456"/></agents>'
            b"<authorized>1</authorized>"
            b"<min_interval>300</min_interval>"
            b"<heartbeat_interval>600</heartbeat_interval>"
            b"<schedule>@every 6h</schedule>"
            b"<comment>Updated agents</comment>"
            b"</modify_agents>"
        )

    def test_modify_agents_without_ids(self):
        with self.assertRaises(RequiredArgument):
            self.gmp.modify_agents(agent_ids=[])