|
| 1 | +# SPDX-FileCopyrightText: 2026 Greenbone AG |
| 2 | +# |
| 3 | +# SPDX-License-Identifier: GPL-3.0-or-later |
| 4 | + |
| 5 | +from gvm.errors import RequiredArgument |
| 6 | + |
| 7 | + |
| 8 | +class GmpGetAgentSupportBundleTestMixin: |
| 9 | + def test_get_agent_support_bundle(self): |
| 10 | + self.gmp.get_agent_support_bundle( |
| 11 | + agent_id="agent-123", |
| 12 | + days=7, |
| 13 | + ) |
| 14 | + |
| 15 | + self.connection.send.has_been_called_with( |
| 16 | + b'<get_agent_support_bundle agent_uuid="agent-123" days="7"/>' |
| 17 | + ) |
| 18 | + |
| 19 | + def test_get_agent_support_bundle_without_days_uses_zero(self): |
| 20 | + self.gmp.get_agent_support_bundle( |
| 21 | + agent_id="agent-123", |
| 22 | + ) |
| 23 | + |
| 24 | + self.connection.send.has_been_called_with( |
| 25 | + b'<get_agent_support_bundle agent_uuid="agent-123" days="0"/>' |
| 26 | + ) |
| 27 | + |
| 28 | + def test_get_agent_support_bundle_with_none_days_uses_zero(self): |
| 29 | + self.gmp.get_agent_support_bundle( |
| 30 | + agent_id="agent-123", |
| 31 | + days=None, |
| 32 | + ) |
| 33 | + |
| 34 | + self.connection.send.has_been_called_with( |
| 35 | + b'<get_agent_support_bundle agent_uuid="agent-123" days="0"/>' |
| 36 | + ) |
| 37 | + |
| 38 | + def test_get_agent_support_bundle_with_zero_days(self): |
| 39 | + self.gmp.get_agent_support_bundle( |
| 40 | + agent_id="agent-123", |
| 41 | + days=0, |
| 42 | + ) |
| 43 | + |
| 44 | + self.connection.send.has_been_called_with( |
| 45 | + b'<get_agent_support_bundle agent_uuid="agent-123" days="0"/>' |
| 46 | + ) |
| 47 | + |
| 48 | + def test_get_agent_support_bundle_without_agent_id(self): |
| 49 | + with self.assertRaises(RequiredArgument): |
| 50 | + self.gmp.get_agent_support_bundle( |
| 51 | + agent_id=None, |
| 52 | + days=7, |
| 53 | + ) |
| 54 | + |
| 55 | + with self.assertRaises(RequiredArgument): |
| 56 | + self.gmp.get_agent_support_bundle( |
| 57 | + agent_id="", |
| 58 | + days=7, |
| 59 | + ) |
| 60 | + |
| 61 | + def test_get_agent_support_bundle_with_negative_days(self): |
| 62 | + with self.assertRaises(ValueError): |
| 63 | + self.gmp.get_agent_support_bundle( |
| 64 | + agent_id="agent-123", |
| 65 | + days=-1, |
| 66 | + ) |
0 commit comments