Passed
Push — master ( 48952f...b1214c )
by Jaspar
34:32 queued 33:09
created

GmpModifyAuthTestMixin.test_modify_auth()   A

Complexity

Conditions 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
nop 1
dl 0
loc 7
rs 10
c 0
b 0
f 0
1
# -*- coding: utf-8 -*-
2
# Copyright (C) 2018-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
from collections import OrderedDict
20
21
from gvm.errors import RequiredArgument
22
23
24
class GmpModifyAuthTestMixin:
25
    def test_modify_auth(self):
26
        self.gmp.modify_auth(
27
            'foo', OrderedDict([('foo', 'bar'), ('lorem', 'ipsum')])
28
        )
29
30
        self.connection.send.has_been_called_with(
31
            '<modify_auth>'
32
            '<group name="foo">'
33
            '<auth_conf_setting>'
34
            '<key>foo</key>'
35
            '<value>bar</value>'
36
            '</auth_conf_setting>'
37
            '<auth_conf_setting>'
38
            '<key>lorem</key>'
39
            '<value>ipsum</value>'
40
            '</auth_conf_setting>'
41
            '</group>'
42
            '</modify_auth>'
43
        )
44
45
    def test_modify_auth_missing_group_name(self):
46
        with self.assertRaises(RequiredArgument):
47
            self.gmp.modify_auth(
48
                group_name=None, auth_conf_settings={'foo': 'bar'}
49
            )
50
51
        with self.assertRaises(RequiredArgument):
52
            self.gmp.modify_auth(
53
                group_name='', auth_conf_settings={'foo': 'bar'}
54
            )
55
56
        with self.assertRaises(RequiredArgument):
57
            self.gmp.modify_auth('', auth_conf_settings={'foo': 'bar'})
58
59
    def test_modify_auth_auth_conf_settings(self):
60
        with self.assertRaises(RequiredArgument):
61
            self.gmp.modify_auth(group_name='foo', auth_conf_settings=None)
62
63
        with self.assertRaises(RequiredArgument):
64
            self.gmp.modify_auth(group_name='foo', auth_conf_settings='')
65
66
        with self.assertRaises(RequiredArgument):
67
            self.gmp.modify_auth('foo', '')
68
69
        with self.assertRaises(RequiredArgument):
70
            self.gmp.modify_auth('foo', {})
71