1
|
|
|
# -*- coding: utf-8 -*- |
2
|
|
|
# Copyright (C) 2021 Greenbone Networks GmbH |
3
|
|
|
# |
4
|
|
|
# SPDX-License-Identifier: GPL-3.0-or-later |
5
|
|
|
# |
6
|
|
|
# This program is free software: you can redistribute it and/or modify |
7
|
|
|
# it under the terms of the GNU General Public License as published by |
8
|
|
|
# the Free Software Foundation, either version 3 of the License, or |
9
|
|
|
# (at your option) any later version. |
10
|
|
|
# |
11
|
|
|
# This program is distributed in the hope that it will be useful, |
12
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
13
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14
|
|
|
# GNU General Public License for more details. |
15
|
|
|
# |
16
|
|
|
# You should have received a copy of the GNU General Public License |
17
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
18
|
|
|
|
19
|
|
|
import unittest |
20
|
|
|
|
21
|
|
|
from gvm.errors import InvalidArgument |
22
|
|
|
from gvm.protocols.gmpv214 import AlertMethod, get_alert_method_from_string |
23
|
|
|
|
24
|
|
|
|
25
|
|
View Code Duplication |
class GetAlertMethodFromStringTestCase(unittest.TestCase): |
|
|
|
|
26
|
|
|
def test_invalid(self): |
27
|
|
|
with self.assertRaises(InvalidArgument): |
28
|
|
|
get_alert_method_from_string('foo') |
29
|
|
|
|
30
|
|
|
def test_none_or_empty(self): |
31
|
|
|
ct = get_alert_method_from_string(None) |
32
|
|
|
self.assertIsNone(ct) |
33
|
|
|
ct = get_alert_method_from_string('') |
34
|
|
|
self.assertIsNone(ct) |
35
|
|
|
|
36
|
|
|
def test_email(self): |
37
|
|
|
ct = get_alert_method_from_string('email') |
38
|
|
|
self.assertEqual(ct, AlertMethod.EMAIL) |
39
|
|
|
|
40
|
|
|
def test_scp(self): |
41
|
|
|
ct = get_alert_method_from_string('scp') |
42
|
|
|
self.assertEqual(ct, AlertMethod.SCP) |
43
|
|
|
|
44
|
|
|
def test_send(self): |
45
|
|
|
ct = get_alert_method_from_string('send') |
46
|
|
|
self.assertEqual(ct, AlertMethod.SEND) |
47
|
|
|
|
48
|
|
|
def test_smb(self): |
49
|
|
|
ct = get_alert_method_from_string('smb') |
50
|
|
|
self.assertEqual(ct, AlertMethod.SMB) |
51
|
|
|
|
52
|
|
|
def test_snmp(self): |
53
|
|
|
ct = get_alert_method_from_string('snmp') |
54
|
|
|
self.assertEqual(ct, AlertMethod.SNMP) |
55
|
|
|
|
56
|
|
|
def test_syslog(self): |
57
|
|
|
ct = get_alert_method_from_string('syslog') |
58
|
|
|
self.assertEqual(ct, AlertMethod.SYSLOG) |
59
|
|
|
|
60
|
|
|
def test_http_get(self): |
61
|
|
|
ct = get_alert_method_from_string('HTTP Get') |
62
|
|
|
self.assertEqual(ct, AlertMethod.HTTP_GET) |
63
|
|
|
|
64
|
|
|
def test_start_task(self): |
65
|
|
|
ct = get_alert_method_from_string('Start Task') |
66
|
|
|
self.assertEqual(ct, AlertMethod.START_TASK) |
67
|
|
|
|
68
|
|
|
def test_sourcefire_connector(self): |
69
|
|
|
ct = get_alert_method_from_string('sourcefire Connector') |
70
|
|
|
self.assertEqual(ct, AlertMethod.SOURCEFIRE_CONNECTOR) |
71
|
|
|
|
72
|
|
|
def test_verinice_connector(self): |
73
|
|
|
ct = get_alert_method_from_string('verinice Connector') |
74
|
|
|
self.assertEqual(ct, AlertMethod.VERINICE_CONNECTOR) |
75
|
|
|
|
76
|
|
|
def test_tippingpoint_sms(self): |
77
|
|
|
ct = get_alert_method_from_string('Tippingpoint SMS') |
78
|
|
|
self.assertEqual(ct, AlertMethod.TIPPINGPOINT_SMS) |
79
|
|
|
|
80
|
|
|
def test_alemba_vfire(self): |
81
|
|
|
ct = get_alert_method_from_string('Alemba vFire') |
82
|
|
|
self.assertEqual(ct, AlertMethod.ALEMBA_VFIRE) |
83
|
|
|
|
84
|
|
|
|
85
|
|
|
if __name__ == '__main__': |
86
|
|
|
unittest.main() |
87
|
|
|
|