1
|
|
|
# -*- coding: utf-8 -*- |
2
|
|
|
# Copyright (C) 2019-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 RequiredArgument |
22
|
|
|
|
23
|
|
|
|
24
|
|
View Code Duplication |
class GmpCreateTicketTestCase: |
|
|
|
|
25
|
|
|
def test_create_ticket(self): |
26
|
|
|
self.gmp.create_ticket( |
27
|
|
|
result_id='r1', assigned_to_user_id='u1', note='lorem ipsum' |
28
|
|
|
) |
29
|
|
|
|
30
|
|
|
self.connection.send.has_been_called_with( |
31
|
|
|
'<create_ticket>' |
32
|
|
|
'<result id="r1"/>' |
33
|
|
|
'<assigned_to>' |
34
|
|
|
'<user id="u1"/>' |
35
|
|
|
'</assigned_to>' |
36
|
|
|
'<open_note>lorem ipsum</open_note>' |
37
|
|
|
'</create_ticket>' |
38
|
|
|
) |
39
|
|
|
|
40
|
|
|
def test_create_ticket_with_comment(self): |
41
|
|
|
self.gmp.create_ticket( |
42
|
|
|
result_id='r1', |
43
|
|
|
assigned_to_user_id='u1', |
44
|
|
|
note='lorem ipsum', |
45
|
|
|
comment='bar', |
46
|
|
|
) |
47
|
|
|
|
48
|
|
|
self.connection.send.has_been_called_with( |
49
|
|
|
'<create_ticket>' |
50
|
|
|
'<result id="r1"/>' |
51
|
|
|
'<assigned_to>' |
52
|
|
|
'<user id="u1"/>' |
53
|
|
|
'</assigned_to>' |
54
|
|
|
'<open_note>lorem ipsum</open_note>' |
55
|
|
|
'<comment>bar</comment>' |
56
|
|
|
'</create_ticket>' |
57
|
|
|
) |
58
|
|
|
|
59
|
|
|
def test_create_ticket_missing_result_id(self): |
60
|
|
|
with self.assertRaises(RequiredArgument): |
61
|
|
|
self.gmp.create_ticket( |
62
|
|
|
result_id='', assigned_to_user_id='u1', note='lorem ipsum' |
63
|
|
|
) |
64
|
|
|
|
65
|
|
|
def test_create_ticket_missing_assigned_to_user_id(self): |
66
|
|
|
with self.assertRaises(RequiredArgument): |
67
|
|
|
self.gmp.create_ticket( |
68
|
|
|
result_id='r1', assigned_to_user_id='', note='lorem ipsum' |
69
|
|
|
) |
70
|
|
|
|
71
|
|
|
def test_create_ticket_missing_open_note(self): |
72
|
|
|
with self.assertRaises(RequiredArgument): |
73
|
|
|
self.gmp.create_ticket( |
74
|
|
|
result_id='r1', assigned_to_user_id='u1', note='' |
75
|
|
|
) |
76
|
|
|
|
77
|
|
|
|
78
|
|
|
if __name__ == '__main__': |
79
|
|
|
unittest.main() |
80
|
|
|
|