|
1
|
|
|
# -*- coding: utf-8 -*- |
|
2
|
|
|
# Copyright (C) 2018 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.protocols.gmpv7 import Gmp |
|
22
|
|
|
|
|
23
|
|
|
from .. import MockConnection |
|
24
|
|
|
|
|
25
|
|
|
|
|
26
|
|
|
class GmpGetConfigsTestCase(unittest.TestCase): |
|
27
|
|
|
|
|
28
|
|
|
def setUp(self): |
|
29
|
|
|
self.connection = MockConnection() |
|
30
|
|
|
self.gmp = Gmp(self.connection) |
|
31
|
|
|
|
|
32
|
|
|
def test_get_configs_simple(self): |
|
33
|
|
|
self.gmp.get_configs() |
|
34
|
|
|
|
|
35
|
|
|
self.connection.send.has_been_called_with( |
|
36
|
|
|
'<get_configs/>') |
|
37
|
|
|
|
|
38
|
|
|
def test_get_configs_with_filter(self): |
|
39
|
|
|
self.gmp.get_configs(filter='name=foo') |
|
40
|
|
|
|
|
41
|
|
|
self.connection.send.has_been_called_with( |
|
42
|
|
|
'<get_configs filter="name=foo"/>') |
|
43
|
|
|
|
|
44
|
|
|
def test_get_configs_with_filter_id(self): |
|
45
|
|
|
self.gmp.get_configs(filter_id='f1') |
|
46
|
|
|
|
|
47
|
|
|
self.connection.send.has_been_called_with( |
|
48
|
|
|
'<get_configs filt_id="f1"/>') |
|
49
|
|
|
|
|
50
|
|
|
def test_get_configs_from_trash(self): |
|
51
|
|
|
self.gmp.get_configs(trash=True) |
|
52
|
|
|
|
|
53
|
|
|
self.connection.send.has_been_called_with( |
|
54
|
|
|
'<get_configs trash="1"/>') |
|
55
|
|
|
|
|
56
|
|
|
def test_get_configs_with_details(self): |
|
57
|
|
|
self.gmp.get_configs(details=True) |
|
58
|
|
|
|
|
59
|
|
|
self.connection.send.has_been_called_with( |
|
60
|
|
|
'<get_configs details="1"/>') |
|
61
|
|
|
|
|
62
|
|
|
def test_get_configs_without_details(self): |
|
63
|
|
|
self.gmp.get_configs(details=False) |
|
64
|
|
|
|
|
65
|
|
|
self.connection.send.has_been_called_with( |
|
66
|
|
|
'<get_configs details="0"/>') |
|
67
|
|
|
|
|
68
|
|
|
def test_get_configs_with_families(self): |
|
69
|
|
|
self.gmp.get_configs(families=True) |
|
70
|
|
|
|
|
71
|
|
|
self.connection.send.has_been_called_with( |
|
72
|
|
|
'<get_configs families="1"/>') |
|
73
|
|
|
|
|
74
|
|
|
def test_get_configs_without_families(self): |
|
75
|
|
|
self.gmp.get_configs(families=False) |
|
76
|
|
|
|
|
77
|
|
|
self.connection.send.has_been_called_with( |
|
78
|
|
|
'<get_configs families="0"/>') |
|
79
|
|
|
|
|
80
|
|
|
def test_get_configs_with_preferences(self): |
|
81
|
|
|
self.gmp.get_configs(preferences=True) |
|
82
|
|
|
|
|
83
|
|
|
self.connection.send.has_been_called_with( |
|
84
|
|
|
'<get_configs preferences="1"/>') |
|
85
|
|
|
|
|
86
|
|
|
def test_get_configs_without_preferences(self): |
|
87
|
|
|
self.gmp.get_configs(preferences=False) |
|
88
|
|
|
|
|
89
|
|
|
self.connection.send.has_been_called_with( |
|
90
|
|
|
'<get_configs preferences="0"/>') |
|
91
|
|
|
|
|
92
|
|
|
def test_get_configs_with_tasks(self): |
|
93
|
|
|
self.gmp.get_configs(tasks=True) |
|
94
|
|
|
|
|
95
|
|
|
self.connection.send.has_been_called_with( |
|
96
|
|
|
'<get_configs tasks="1"/>') |
|
97
|
|
|
|
|
98
|
|
|
def test_get_configs_without_tasks(self): |
|
99
|
|
|
self.gmp.get_configs(tasks=False) |
|
100
|
|
|
|
|
101
|
|
|
self.connection.send.has_been_called_with( |
|
102
|
|
|
'<get_configs tasks="0"/>') |
|
103
|
|
|
|
|
104
|
|
|
|
|
105
|
|
|
if __name__ == '__main__': |
|
106
|
|
|
unittest.main() |
|
107
|
|
|
|