File: test_delete_user.py

package info (click to toggle)
python-gvm 26.9.1-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 5,316 kB
  • sloc: python: 46,784; makefile: 18
file content (50 lines) | stat: -rw-r--r-- 1,473 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# SPDX-FileCopyrightText: 2018-2024 Greenbone AG
#
# SPDX-License-Identifier: GPL-3.0-or-later
#

from gvm.errors import RequiredArgument


class GmpDeleteUserTestMixin:
    def test_delete_user_with_user_id(self):
        self.gmp.delete_user("a1")

        self.connection.send.has_been_called_with(
            b'<delete_user user_id="a1"/>'
        )

        self.gmp.delete_user(user_id="a1")

        self.connection.send.has_been_called_with(
            b'<delete_user user_id="a1"/>'
        )

    def test_delete_user_with_inheritor_id(self):
        self.gmp.delete_user("a1", inheritor_id="u1")

        self.connection.send.has_been_called_with(
            b'<delete_user user_id="a1" inheritor_id="u1"/>'
        )

    def test_delete_user_with_name(self):
        self.gmp.delete_user(name="foo")

        self.connection.send.has_been_called_with(b'<delete_user name="foo"/>')

    def test_delete_user_with_inheritor_name(self):
        self.gmp.delete_user("a1", inheritor_name="foo")

        self.connection.send.has_been_called_with(
            b'<delete_user user_id="a1" inheritor_name="foo"/>'
        )

    def test_delete_user_missing_user_id_and_name(self):
        with self.assertRaises(RequiredArgument):
            self.gmp.delete_user(None)

        with self.assertRaises(RequiredArgument):
            self.gmp.delete_user("")

        with self.assertRaises(RequiredArgument):
            self.gmp.delete_user(user_id="", name="")